6
$\begingroup$

I want to use the $\LaTeX$ font in graphics. For text/numbers, this is easily done by FontFamily -> "CMU Serif" (on Ubuntu) like this:

Plot[Sin[x], {x, -Pi, Pi}, 
LabelStyle -> Directive[16, FontFamily -> "CMU Serif"],
AxesLabel -> {"Greek: \[Alpha],\[Beta],\[Gamma]", "Fancy font!"}]

enter image description here

The English text and numbers are in LaTeX computer modern font, which is great, but the Greek is not. For comparison, it should be

enter image description here

This is because Latex does not use computer modern for Greek letters, but rather a font which (in Ubuntu, at least) is called cmmi10 font, as I found by looking at the PDF properties. The Greek letters correspond to characters in the range 161-195, as seen by this picture (obtained in LibreOffice Special character menu)

enter image description here

but sadly only some of them work. The output of

Style[FromCharacterCode[Range[161, 195]], FontFamily -> "cmmi10"]

is

enter image description here

So for some reason $\beta, \epsilon, \zeta $ and some more are displaying correctly, but others don't. Is there any way to fix this?

$\endgroup$
  • $\begingroup$ It doesn't work with the Latin Modern OpenType fonts either. As a non-ideal workaround you can use MaTeX. $\endgroup$ – Szabolcs Jun 2 '15 at 7:38
  • $\begingroup$ @Szabolcs Thanks. I know about MaTeX, but I thought I could avoid that by using simple textual stuff (I don't need fancy math, just the Greek letters) $\endgroup$ – yohbs Jun 2 '15 at 7:51
  • $\begingroup$ Have you tried typing the actual greek letters instead of the character codes and using cmmi10? I only tried Latin Modern. I hope my answer is useful but it's only based on some quick research... $\endgroup$ – Szabolcs Jun 2 '15 at 8:27
8
$\begingroup$

I can no longer get this working. The commands shown below don't give me an output with the correct typeface with Greek letters. I don't know why.


tl;dr Use the Latin Modern Math OpenType fonts downloadable from here and make all Greek italic.


According to my research this is not a Mathematica-specific issue. The Computer Modern fonts do not have a full set of Greek letters and were not meant to typeset Greek. This means that even the Unicode OpenType-packaged Latin Modern set of fonts doesn't include Greek glyphs. The CM fonts only have those Greek glyphs that are needed for typesetting math and look different from their Latin counterpart. E.g. α is included but not Α (capital alpha).

The Latin Modern Roman set of fonts is meant for typesetting text and has no Greek.

The Latin Modern Math set of fonts is meant for typesetting math, and has Greek, but it's not suitable for typesetting text. It is very likely sufficient for figure labels though.

If you install Latin Modern Math, and then restart Mathematica, you will be able to use Greek letters. The catch is that they only look good when explicitly made italic. You'll need to format all Greek as italic manually and the rest of the text as upright.

Here's a demonstration and a comparison with $\LaTeX$ to show that it's indeed the same font:

enter image description here

Unfortunately I do not know how to get the variants working:

enter image description here

I think the Latin Modern Math is the same font as cmmi10 but it's packaged differently (following this standard?) to make it compatible with modern math typesetting software like recent versions of MS Word.

$\endgroup$
  • $\begingroup$ From your screenshots I see that the Greek letters are displayed Plain Bold in your "Input" Cells. How have you achieved this? By default Greek letters are auto-replaced by corresponding letters from Mathematica font and are displayed Italic in the "Input" Cells. $\endgroup$ – Alexey Popkov Aug 12 '15 at 8:35
  • $\begingroup$ @AlexeyPopkov You're right and I don't know! I don't remember. It is possible that I copied it from somewhere as didn't remember the full Greek alphabet off-hand. $\endgroup$ – Szabolcs Aug 12 '15 at 8:38
  • $\begingroup$ @AlexeyPopkov But then I just notice that δ is missing, so I probably dind't copy it ... $\endgroup$ – Szabolcs Aug 12 '15 at 8:39
  • $\begingroup$ Probably you modified Mathematica system files as described here or here? $\endgroup$ – Alexey Popkov Aug 12 '15 at 11:12
  • $\begingroup$ @Alexey I didn't, and I can't get the fonts to look like that any more ... I really don't know what happened here ... $\endgroup$ – Szabolcs Aug 12 '15 at 11:50
5
$\begingroup$

What you could do is download and install the STIX fonts by following the instructions here. These fonts are (if I'm not mistaken) also used by MathJAX, the engine that renders $\LaTeX$ code on this web site.

Then, in Mathematica, do something like this:

baseStyle = {FontFamily -> "STIXGeneral", 12, 
          ScriptSizeMultipliers -> .66, ScriptMinSize -> 6};

    Map[SetOptions[#, BaseStyle -> baseStyle] &, {Plot, ListPlot}];

    Plot[Sin[x], {x, -2, 2}, 
      AxesLabel -> {HoldForm@Subscript[x, 1], 
          HoldForm@Sin[Subscript[x, 1]]}]

plot

The STIX fonts could also be replaced by "Times New Roman", but I suggest the former because they are designed for scientific typesetting and have all the necessary symbols, including Greek. In the Map command, I apply this choice of fonts to the types of plots I think are needed. You can customize the list {Plot, ListPlot} to whatever you like.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.