# Font style in Mathematica and .tex file

I am using Mathematica 8. I want to label the axes of figure in "Times" font.

Plot[Sin[z], {z, -2 Pi, 2 Pi}, Frame -> True,
FrameLabel -> {"z", "a(z)"},
LabelStyle -> Directive[FontSize -> 20, FontFamily -> "Times"]]


And the plot is

However in Miktex, when I am using FontStyle, Times then z is different. So I want to replace by

the second one is the default z appearing pdf generarted from .tex file in math mode. So what extra information should be given to Mathematica, besides "Times".

• The second Z is Times Italic. To get that in Mathematica add the option FontSlant-> Italic to your Plot function call. – Sjoerd C. de Vries Mar 2 '15 at 19:33
• did not resolve the problem for me in Mathematica 8 – zenith Mar 2 '15 at 20:19
• You mean you did not get the italic version of the font? – Sjoerd C. de Vries Mar 2 '15 at 20:56
• @ Sjoerd Now its been resolved. I made a mistake previously as i added FontSlant-> Italic in Label style. So that it italicized all the tikz labels also. Moreover, the required font was not visible in Mathematica 8.0, but when I saved it in .eps format and seen in the .pdf generated through Miktex it was visible. Thank you – zenith Mar 2 '15 at 21:12
• If you can wait a couple of days, I'll have an answer for this. It's an accident that I'm doing this at the same time when you asked the question. I didn't even see your question until now. – Szabolcs Mar 3 '15 at 0:15

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"},
BaseStyle -> {FontFamily -> "Latin Modern Roman", FontSize -> 20}]


Additionally, I used the Latin Modern font for tick labels to fully match the "LaTeX look", and set the frame to be black instead of gray.

If you prefer the Times font, we can do that too:

SetOptions[MaTeX, "Preamble" -> {"\\usepackage{amsmath,amssymb}", "\\usepackage{txfonts}"}];

Plot[Sin[z], {z, -2 Pi, 2 Pi}, Frame -> True,
FrameStyle -> BlackFrame,
FrameLabel -> (MaTeX[#, Magnification -> 20/12] &) /@ {"z", "a(z) = \\sin z"},
BaseStyle -> {FontFamily -> "Times", FontSize -> 20}]


• Today I also wanted to ask a similar question, but just when I had almost given up hope that a nice, clean solution would exist, I came across your answer and your easy-to-use package "MaTeX." Many thanks for developing such a convenient package (and for clearly documenting the steps needed to make it work)! – TMM Mar 30 '15 at 23:35
• @TMM I'm glad you find it useful. Feel free to email me if you have any comments or suggestions. – Szabolcs Mar 31 '15 at 2:04
• Actually there's one question I had, which may also be useful to readers of this website: is it possible to automate the MaTeXing further? i.e. Write something like MaTeX[Plot[x, {x,0,1}]] and it automatically TeXifies the tick labels on the axes? Alternatively, is there a convenient way to TeXify automatically generated ticks on axes? Many thanks again! – TMM Apr 1 '15 at 2:05
• @TMM For ticks, I would recommend simply using the Latin Modern font instead of MaTeX. While theoretically it should be possible to auto-process tick labels, there are many obstacle ... Option 1: Use FullGraphics to render the axes and ticks as graphics objects, then go from there. FullGraphics has stayed neglected since Mma6 and it's practically unusable in v10. Option 2: Get the tick labels using AbsoluteOptions, then process those. This works better, but not perfectly. Often, what AbsoluteOptions returns is quite a bit different from the automatically rendered ticks. – Szabolcs Apr 1 '15 at 18:15
• @axsvl77 Just use \text, not \textrm`. This is shown in several examples in the documentation. Suggestions on how to improve the documentation are always welcome, but keep in mind that just adding more information and making it longer is not going to help—people already don't read it. – Szabolcs Jul 12 at 16:53