MaTeX


A package for using LaTeX in Mathematica graphics, legends, plot labels, etc. Ideal for publication quality figures or for matching the style of figure labels with that of LaTeX-generated documents.


Load the package using

<<MaTeX`

then simply evaluate

MaTeX["\\int_0^\\inty e^{-x} \\, dx"]

to get

Instead of passing it a string containing a $\LaTeX$ snippet, we can also use any Mathematica expression. It will automatically be converted to TeX using TeXForm.

MaTeX[HoldForm@Integrate[Exp[-x], {x, 0, Infinity}]]

If you prefer $\LaTeX$'s default Computer Modern font face, install and use the Latin Modern OpenType fonts with MaTeX.

Plot[{Cos[x], Sin[x]}, {x, 0, 2 Pi}, 
 Ticks -> {{#, MaTeX[#, "DisplayStyle" -> False]} & /@ Range[0, 2 Pi, Pi/4], Automatic}, 
 BaseStyle -> {FontFamily -> "Latin Modern Roman"},
 PlotLegends -> MaTeX /@ {"\\cos x", "\\sin x"}]

Alternatively, we can change the font MaTeX uses to match Mathematica.

MaTeX[Exp[x] + O[x]^4, "Preamble" -> {"\\usepackage{txfonts}"}]

MaTeX also supports XeTeX, so any unicode font can be used. Please see the MaTeX website for additional examples and documentation, or search for "MaTeX" in Mathematica's Documentation Centre.