# Tag Info

85

I would like to make my graphics homogeneous with my (LaTeX) document. That means that I would like to use the same font in the graphics (labels for axis etc) as the main text. I recently wrote a package, called MaTeX, to solve this exact problem. MaTeX makes it easy to compile short LaTeX snippets and embed them in Mathematica notebooks or graphics. Tip: ...

58

Here is my attempt to generate a pseudocode for algorithmicx package. Current features Functions (as SetDelayed) Set If with 2 and 3 arguments While Do (any number of variables of any type) New! Return Module, With, and Block CompoundExpression (;) Test functions (EvenQ, etc., and Not@EvenQ, etc.) New! Indentation Code ClearAll[pseudocode, pscd] ...

49

MaTeX is a package made exactly for this purpose. It can automatically compile small LaTeX snippets and import them as Mathematica graphics. It is described in detail in this other Mathematica.SE answer. A short tutorial is available here. Finally, to show what it can do, this is an example plot made with MaTeX labels (borrowed from the tutorial above, ...

39

Introduction Below I present usage of my CellsToTeX package. It provides functions for converting Mathematica cells to $\TeX$ code compatible with $\TeX$ package mmacells. Compilation of this $\TeX$ code results in output resembling FrontEnd appearance of converted cells. Full capabilities of $\TeX$ package are described in my post in "Fanciest way to ...

35

You can use ToExpression. ToExpression["string", TeXForm, HoldForm] Paste your content inside quotes and click the button "yes", when the following dialog box opens, in order to escape backslashes and use them verbatim In your example, Mathematica 12.1 produces the following output

32

This is a good application for the highly underused Splice function which has been in Mathematica since version 1 (I don't recall it ever being used on this site). Create a file called main.mtex with the following text: \documentclass[preview,border=12pt,12pt]{standalone} \usepackage{amsmath} \def\f(#1){(#1)^2-5*(#1)+6} \begin{document} \section{Problem}...

27

The following Mathematica construction translates to $\TeX$ just fine: \left( \begin{array}{c} e_{\bot } \\ e_{\parallel } \\ \end{array} \right) Which looks like this in StackExchange's MathJax: $\left( \begin{array}{c} e_{\bot } \\ e_{\parallel } \\ \end{array} \right)$ The key issue is to enter the initial Mathematica construction correctly. That ...

25

Why we're getting this buggy result In process of conversion to $\TeX$, whenever Mathematica encounters "something delimited" i.e. RowBox with something surrounded with Strings matching: "(" | "[" | "$LeftModified]" | "\[LeftDoubleBracket]" | "{" | "\[Piecewise]" | "\[LeftFloor]" | "\[LeftCeiling]" | "\[LeftAngleBracket]" | "\[LeftSkeleton]" | "«" | "\[... 24 TeXForm is indeed your friend. It even gives you nicely formatted code: Table[RandomInteger[10], {3}, {4}] // TeXForm gives (* \left( \begin{array}{cccc} 9 & 5 & 10 & 9 \\ 6 & 10 & 3 & 9 \\ 9 & 5 & 9 & 7 \\ \end{array} \right) *) 24 I too had a need for a better syntax highlighting engine for Mathematica that can be used in different formats (so the javascript plugin is ruled out), so I wrote a better lexer and highlighter for Pygments than the one that ships with pygments. From the README: It can currently lex and highlight: All builtin functions in the System context ... 22 I am not willing to make MaTeX compatible with Mathematica 9 for the simple reason that it would create too much of a maintenance burden, and I already don't have time to properly respond to all support requests. If anyone is willing to hack MaTeX to work with Mathematica 9, here's what needs to be done. The primary reason why Mathematica 10 is required is ... 21 You can match formatting between Mathematica figures and LaTeX using a small package I just wrote for using LaTeX-snippets in Mathematica: MaTeX. Here's an example: <<MaTeX Plot[Sin[z], {z, -2 Pi, 2 Pi}, Frame -> True, FrameStyle -> BlackFrame, FrameLabel -> (MaTeX[#, Magnification -> 20/12] &) /@ {"z", "a(z) = \\sin z"}, ... 19 Since no one dares an answer, let me make some statements that you probably won't like since you seem keen to switch to Mathematica. I don't think this is a good idea. It is just not the right tool for this. My background is academic, I'm using Mathematica on a daily basis and I love it. For writing I'm using LaTeX for manuscripts and persistent documents, ... 15 Endorsing Szabolcs' excellent MaTeX package as a way to manage \LaTeX in Mathematica but with an addition that for me at least has removed the significant irritant of having to escape backslashes in strings. For example, given some previous \LaTeX "\tilde{x}=\begin{cases} (\frac{n+1}{2}) \text{th term} & \text{n odd} \\ ((\frac{n}{2}) \text{... 14 Here's a way that I find clear: Make sure i and n have no value: i=.; n=.. Generate a list of the held sum expressions, taking care to make the exponent go away from i^1. list = Table[With[{e = i^k}, HoldForm[Sum[e, {i, 1, n}]]], {k, 5}] Use ReleaseHold to make a table of results: TeXForm@TableForm[# == ReleaseHold[#] & /@ list]  \begin{... 14 What Format does Role of Format, as I understand it, is to set appropriate transformation rules. One can check those rules using FormatValues function: Format[x, TeXForm] = "{\\bf x}"; FormatValues[x] // FullForm (* List[RuleDelayed[HoldPattern[Format[x, TeXForm]], "{\\bf x}"]] *) One can also see those rules by inspecting symbol for which rules where set:... 14 This is not answer, but an extended comment that displays a graphic. The code you post in your question does not work in any recent version of Mathematica. It is syntactically and semantically incorrect. The following modified code does work. My question is: does it produce the plot you want to translate into LaTeX? rose[x_, theta_] := Module[ {... 14 You could use my TeXUtilities package: Import@"https://raw.githubusercontent.com/jkuczm/MathematicaTeXUtilities/master/NoInstall.m" Unprotect[FresnelC, CosIntegral]; Format[FresnelC@x_, TeXForm] := TeXVerbatim["\\operatorname{FresnelC}"]@x Format[CosIntegral@x_, TeXForm] := TeXVerbatim["\\operatorname{CosIntegral}"]@x (* Move TeXForm format to begining of ... 14 content = WolframAlpha["integrate (sin(x))^4 dx", {{"IndefiniteIntegral", 2}, "Content"}, PodStates -> {"IndefiniteIntegral__Step-by-step solution"}][[1]]; BoxFormUseTemplateSlotSequenceForRow = False; TeXForm[Column@(MakeExpression[content //. StyleBox[a_, ___] :> a, StandardForm] /. {{{a_}, {b_, c___}} :> Column[{HoldForm[a], ... 13 Here is a start (adjusted based on Szabolcs's statement that Row and TeXForm don't work together in v9): Clear[n] # == ReleaseHold[#] & /@ Array[HoldForm[Sum[i^#, {i, 1, n}]] &, 5] // Column // TeXForm \begin{array}{l} \sum _{i=1}^n i^1=\frac{1}{2} n (n+1) \\ \sum _{i=1}^n i^2=\frac{1}{6} n (n+1) (2 n+1) \\ \sum _{i=1}^n i^3=\frac{1}{4} n^2 ... 13 To get syntax highlighting for Mathematica in a latex code listing, try this: \usepackage{listings} \usepackage{color} \definecolor{listinggray}{gray}{0.9} \definecolor{graphgray}{gray}{0.7} \definecolor{blue}{rgb}{0,0,1} \definecolor{mygreen}{rgb}{0,0.6,0} \definecolor{mygray}{rgb}{0.5,0.5,0.5} \definecolor{mymauve}{rgb}{0.58,0,0.82} % define a custom ... 13 Unfortunately, the Mathematica's Copy As > LaTeX command is not (as you'd expect) a command that copies the selected expressions as LaTeX. Instead, it performs additional reformatting that can only be avoided by changing behavior of the relevant built-in function with: SystemFEDumpCopyAsTeXMakeBoxes = #& Details Why copied boxes are reformatted ... 12 Caveat: Since this uses hidden, undocumented functions, it will probably break at some point in the future. Also, I do not have any knowledge of how these functions work, except guesses from observed behavior. Some information is available via Information. Under the hood of TexForm is ConvertTeXExpressionToTeX, which in turn calls ConvertTeXBoxesToTeX ... 12 It can be traced that, in minimal example from question, following definition of SystemConvertTeXFormDumpmaketex function is used: SystemConvertTeXFormDumpmaketex[str_String?SystemConvertCommonDumpEmbeddedStringWithLinearSyntaxQ] := ( SystemConvertCommonDumpDebugPrint["------------------------------------"]; SystemConvertCommonDump... 12 The same sizes show up using pure Latex. \documentclass[11pt]{article} \begin{document} \Huge \[ \sqrt{\phantom{a^2}b}$ $\sqrt{a^2b}$ \end{document} Gives (compiled with pdflatex) And this is inside Mathematica: I do not see any difference. But I think your question is really about Latex itself and not Matex, which just compiles using Latex. ...

11

The following works in Version 9.0.1.0 and Version 10.0.1.0 BoxForm`\$UseTemplateSlotSequenceForRow = False; {x^a, Sqrt@b, ArcSin[c]} // Row // TeXForm (* x^a\sqrt{b}\sin^{-1}(c) *)

11

There are a few ways to do this. The easiest is probably the switch off the script level changes that are taking place by selecting the cell bracket and setting AllowScriptLevelChange->False in the options inspector: For more subtle tweeking you need to leave AllowScriptLevelChange->True and adjust ScriptSizeMultipliers. For example with ...

11

This answer has two proposed solutions one with a dedicated parser the other using conversion to JSON. The programming of the JSON conversion happened three times faster. (But it was also done earlier in the day when I was also properly caffeinated...) Making a dedicated parser We can make a dedicated parser in a manner similar to the approach explained in ...

11

Question not clear. But to insert Latex Matrix (or any other latex output, such as equations etc..) in textcell using the notebook, here is an example. If OP does not want to use the notebook at all, then this is not possible and will delete this. Load Matex to render the Latex. Start text cell. Insert the latex in the textcell from the rendered output. ...

10

There is a similar problem with Adobe Illustrator, too. For that purpose, I use the following function (see my web site for more info): toPDF[x_, opts : OptionsPattern[]] := If[! ImageQ[x], First@ImportString[ ExportString[ Pane[Style[TraditionalForm[HoldForm[x]], FilterRules[{opts}, Options[Style]]], FilterRules[{opts}, ...

Only top voted, non community-wiki answers of a minimum length are eligible