I am using xelatex and the mathspec package to use the Calibri font found on recent Windows machines. The font metrics used to typeset italic characters are fine for text but not for math; glyphs often collide.

With mathspec, one can precede a character in math mode with " to increase its spacing. The characters in the figure below were typeset using

$f(x)$, $"f(x)$, $f'(x)$, $"f'(x)$, $e^{jx}$,$"e^{"jx}$.

enter image description here

While this works fine when one only has to use it infrequently, for a long document it becomes tedious. Is there a way to always use this corrected spacing without manually preceding every character of the alphabet with "?

  • 1
    Short answer: no. Longer answer: mathspec does its best in order to emulate math fonts, but if the fonts lack the necessary specifications for being used in math mode, it's a lost battle.
    – egreg
    Commented Dec 15, 2014 at 22:50
  • Bummer. I really like using alternate fonts but some of the math definitely looks wrong without tweaking. I was hoping there was a global setting I could use ... Thanks.
    – GregH
    Commented Dec 16, 2014 at 13:38

1 Answer 1


A “real” math font, such as those that can be used with unicode-math, has glyphs specially tailored for math fonts.

For instance with


\setmainfont{Latin Modern Roman}
\setmathfont{Latin Modern Math}


\textit{f} $f(x)$


the character used for the second “f” is U+1D453 MATHEMATICAL ITALIC SMALL F in Latin Modern Math, which has the same shape as an italic “f” (the first one), but different side bearings and other metric parameters.

If you use mathspec, say with


\setmainfont{Hoefler Text}
\setmathfont(Latin){Hoefler Text}


\textit{f} $f(x)$ $"f(x)$


you get

enter image description here

The package makes its best for getting decent output, but using glyphs not specially designed for a math font clashes with the rules of TeX's math mode, in particular when the letters are slanted.

Thus the "f trick is a “necessary evil”. You see that in some cases you need it, in others you don't: it depends on pairs of adjacent characters that are taken from different fonts. With unicode-math the same font is used, but this is not the main aspect; the relevant fact is that the math letters have special parameters.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .