Using Greek $\LaTeX$ fonts

8

3

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?

yohbs

Posted 2015-06-02T06:55:37.693

Reputation: 6 816

It doesn't work with the Latin Modern OpenType fonts either. As a non-ideal workaround you can use MaTeX.

– Szabolcs – 2015-06-02T07:38:52.357

@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) – yohbs – 2015-06-02T07:51:23.570

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... – Szabolcs – 2015-06-02T08:27:48.827

Answers

9

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.

Szabolcs

Posted 2015-06-02T06:55:37.693

Reputation: 213 047

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. – Alexey Popkov – 2015-08-12T08:35:42.757

@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. – Szabolcs – 2015-08-12T08:38:08.767

@AlexeyPopkov But then I just notice that δ is missing, so I probably dind't copy it ... – Szabolcs – 2015-08-12T08:39:17.020

Probably you modified Mathematica system files as described here or here?

– Alexey Popkov – 2015-08-12T11:12:58.937

@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 ... – Szabolcs – 2015-08-12T11:50:09.563

Your solution seems to work, please check my answer. – Alexey Popkov – 2019-10-18T06:50:03.823

7

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.

Jens

Posted 2015-06-02T06:55:37.693

Reputation: 93 191

3

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!

d9D57tE7

Posted 2015-06-02T06:55:37.693

Reputation: 69

1

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

JjSa

Posted 2015-06-02T06:55:37.693

Reputation: 11

1

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.

Alexey Popkov

Posted 2015-06-02T06:55:37.693

Reputation: 50 220