8 votes

LaTeX: Using a different font for glyphs used in commands like \sum

Hello everyone. I consider myself fairly competent when it comes to my work with LaTeX, but as everyone who uses it knows, it is definetely strange sometimes. And right now I have a problem which just irks me in the wrong ways:

I use XeTeX and a number of custom fonts for my documents, but when writing mathematical formulas I found out that the font I set for Greek letters (Gentium Plus) is used for letter commands like \alpha, \Alpha, ... but not for commands like \sum, \prod. As you can see in this example here. You can see XeTeX defaults to Computer Modern.

I've looked all over the net for solutions but I can't find one. I'm using mathspec, amsmath, amsfonts, amssymb as my font related packages and I set my fonts like this:

\setmainfont{Charis SIL}
\setsansfont{Helvetica Now Display}
\setmonofont[Scale=MatchLowercase]{Fira Code Retina}
\setmathfont(Digits,Latin){Charis SIL}
\setmathfont(Greek){Gentium Plus}

I feel like I'm going insane not solving this problem. Should you require it, my entire LaTeX template is here on Github. Please help, thank you.

2 comments

  1. [2]
    bltzkrg22
    Link
    Short answer: Gentium Plus is not a full math font. \sum and \Sigma are different characters. \Sigma is a standard Greek letter, and is included in Gentium Plus, while \sum is a special...

    Short answer: Gentium Plus is not a full math font.

    \sum and \Sigma are different characters. \Sigma is a standard Greek letter, and is included in Gentium Plus, while \sum is a special mathematical character – and is not.

    To replace such symbols you will need to use a proper font with full mathematical character set, for example:


    Whenever I want to use an OpenType font X with no math range:

    1. I find a math font that looks good enough
    2. Then I overwrite a subset of characters (i.e. digits, latin alphabet, sometimes greek, some symbols) with font X.

    It will never look 100% correct, as you end up with a mix of two fonts, but usually it is passable.

    (This is not the best example, since FiraGO and Fira Math are closely related, but I hope you see what I meant. The trick here is to get a slashed zero, as Fira Math does not support it yet).

    \usepackage{fontspec}
        \setmainfont[Ligatures=TeX,Numbers=SlashedZero]{FiraGO}
        \setmonofont[Scale=0.9,Ligatures=TeX,StylisticSet={3,5}]{Fira Code}
        \setmathrm[Ligatures={NoCommon, NoDiscretionary, NoHistoric, NoRequired, NoContextual},Numbers=SlashedZero]{FiraGO}
    
    \usepackage{unicode-math}
       %Here I define a main math font, FiraMath
        \setmathfont[math-style=ISO,bold-style=ISO,Numbers=SlashedZero]{FiraMath-Regular.otf}
       %Here I overwrite FiraMath’s digits with characters from FiraGO, because I want a slashed zero
        \setmathfont[range=\mathup/{num},Numbers=SlashedZero]{FiraGO-Regular.otf}
        \setmathfont[range=\mathbfup/{num},Numbers=SlashedZero]{FiraGO-Bold.otf}
    

    More info can be found in the manuals for fontspec and unicode-math – for example how to define proper ranges like: \setmathfont[range=\mathup/{num}

    6 votes
    1. Grzmot
      Link Parent
      Ah, for some reason I assumed that LaTeX pulled the characters from the same source and not that they were actually different characters in the glyph table. I did actually find the unicode-math...

      Ah, for some reason I assumed that LaTeX pulled the characters from the same source and not that they were actually different characters in the glyph table. I did actually find the unicode-math package, but I couldn't quite make sense of the range option it provided. This might be the way to go for me, or maybe I'll find a proper math font.

      Many thanks for your help.

      3 votes