9
$\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$
3
  • $\begingroup$ It doesn't work with the Latin Modern OpenType fonts either. As a non-ideal workaround you can use MaTeX. $\endgroup$
    – Szabolcs
    Commented Jun 2, 2015 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
    Commented Jun 2, 2015 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
    Commented Jun 2, 2015 at 8:27

5 Answers 5

10
$\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$
6
  • $\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$ Commented Aug 12, 2015 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
    Commented Aug 12, 2015 at 8:38
  • $\begingroup$ @AlexeyPopkov But then I just notice that δ is missing, so I probably dind't copy it ... $\endgroup$
    – Szabolcs
    Commented Aug 12, 2015 at 8:39
  • $\begingroup$ Probably you modified Mathematica system files as described here or here? $\endgroup$ Commented Aug 12, 2015 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
    Commented Aug 12, 2015 at 11:50
7
$\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$
3
$\begingroup$

Even though this question was asked quite some time ago, the problem is still relevant today I believe (at least for me it was).

I found that combining yohbs' approach using "FromCharacterCode" and the OpenType-Font "Latin Modern Math" works very well for me (I now use this workflow on Mathematica 12.0).

Greek Letters in Mathematica 12

The character codes for the corresponding Greek letters can be looked up in LibreOffice: Character Codes for Greek Letters from LibreOffice

I hope this was of help to someone!

$\endgroup$
1
$\begingroup$

Check this http://www.ams.org/publications/authors/tex/amsfonts and Install "cmmi12", then Use in Wolfram "FontFamily -> "Computer Modern" "

or

You can check https://tex.stackexchange.com/questions/38632/image-with-axis

Plot from wolfram

JjSa

$\endgroup$
1
$\begingroup$

I just checked the solution by Szabolcs and it kinda works for me, only the letter heights are wrong:

{greekLetters, variantForms, archaicalGreekLetters} =
  {{α, Α, β, Β, γ, Γ,
    δ, Δ, ϵ, Ε, ζ, Ζ,
    η, Η, θ, Θ, ι, Ι,
    κ, Κ, λ, Λ, μ, Μ,
    ν, Ν, ξ, Ξ, ο, Ο,
    π, Π, ρ, Ρ, σ, Σ,
    τ, Τ, υ, Υ, ϕ, Φ,
    χ, Χ, ψ, Ψ, ω, Ω},
   {ε, ϑ, ϰ, ϖ, ϱ, 
    ς, φ, ϒ},
   {ϝ, ϟ, ϛ, ϡ, Ϝ, Ϟ, 
    Ϛ, Ϡ}};

Style[greekLetters, FontFamily -> "Latin Modern Math", FontSlant -> Italic]
Style[variantForms, FontFamily -> "Latin Modern Math", FontSlant -> Italic]
Style[archaicalGreekLetters, FontFamily -> "Latin Modern Math", FontSlant -> Italic]

screenshot

I simply installed the Latin Modern Math (OTF), version 1.959. My operating system is Windows 7 x64. These fonts are compatible with MS Word (the archive includes a test .docx file), but on my system in Word letters also have wrong heights (very large). In the test .docx file they are used only inside formulas, where they appear with correct heights.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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