With mathspec, when you change the math font to an OpenType font, the spacing within equations is not fine: it is the same than the text mode spacing. For example in the equation $e^j$, the 'j' will collide with the 'e', most of time. So with mathspec you have to type $e^{"j}$ to space the 'j'. This is refered as the 'glyph bounds' problem in the mathspec doc. What is really too bad is that it breaks compatibility with LaTeX.

Is there any way to both have correct spacing AND compatibility with LaTeX?

Here is an example with two clashes :

\setmathsfont(Latin,Digits){Times New Roman}

$e^j + |f|$ should be written $e^{"j} + |"f|$.
$abcdefghijklmnopqrstuvw$ : the spacing is too thin, suitable for text, not for math.
  • 2
    When I run xelatex to typeset $e^j$ with the default math font (Computer Modern), I do not get a clash between the e and the raised j. Incidentally, $e^{"j}$ produces the exact same output on my system as $e^j$ does. Are you maybe using a non-default set of math fonts and/or babel with a non-English language setting?
    – Mico
    Aug 24, 2011 at 15:08
  • Yes you're right, it is only with non standard (OpenType) fonts, which do not have proper math bounds for the glyphs. (Question edited in this sense.)
    – Lierre
    Aug 24, 2011 at 17:00
  • Lierre: I'm not sure I follow you on the distinction between standard (i.e., Computer Modern or Latin Modern) and "nonstandard (OpenType)" fonts. The Latin Modern fonts are now available in OpenType format, and they don't exhibit the problem you're describing. Which font (opentype or not) are you using?
    – Mico
    Aug 24, 2011 at 17:47
  • I added an example with Times New Roman, but collisions also arise with Adobe's Garamond, Caslon, Jenson, etc... I also have the problem with Latin Modern in OpenType format : which seems reasonable because OpenType fonts do not include math glyph bounds.
    – Lierre
    Aug 25, 2011 at 13:11

2 Answers 2


Lierre: Thanks for posting a complete MWE. Good news: I can reproduce your problems. Better news: On my system at least, they go away entirely when I omit the "(Latin,Digits)" option. Why do you specify these options, incidentally?

Addendum, 18/20 Sept 2011: I've just found out about the latest release of the XITS math (and text) fonts; see the XITS site for the five .otf files. The XITS Math letters have much better, i.e., larger sidebearings. If XITS and XITS Math are sufficiently Times-like for your needs, I think you'll be very pleased. The new MWE would look something like

% !TeX program = xelatex
\setmathfont{XITS Math}
$e^j + |f|$ \\
$abcdefghijklmnopqrstuvwxyz$ XITS-Math math italics\\    
\textit{abcdefghijklmnopqrstuvwxyz} XITS text italics\\    
\setmainfont{Times New Roman}
\textit{abcdefghijklmnopqrstuvwxyz} TNR text italics

enter image description here

I guess the right-hand sidebearing of the f in the first line could still be a bit more generous, but it's a huge improvement over the example with TNR that you posted originally!

Comparing the italics letters of the XITS Math font with the (text) italics letters of Times New Roman, the main new characteristics of the new math font seem to be:

  • very different shapes of v and w
  • larger "teardrop" terminals of the letters f and r
  • the letter z has a rudimentary "swash" (but it's nowhere near as pronounced as the swash of the italic z in either Computer Modern or MathtimePro (the latter with the zswash option set)
  • most letters are a bit more condensed and their vertical strokes are a bit thicker

Second Addendum, 27 May 2017: Recently, the STIX fonts project has released version 2.0 of the Stix Fonts. The STIX Two Text and STIX Two Math fonts may be obtained for free from https://sourceforge.net/projects/stixfonts/. The STIX Two Math (and Text) fonts represent a major step forward relative to the XITS and orginal Stix fonts. To wit, the math kerning is much improved in the following screenshot relative to what would be provided by XITS Math (see the screenshot above). The STIX Two italic glyphs -- in both text and math mode -- are also less slanted (or: more upright) than their Stix, XITS, and Times New Roman counterparts.

enter image description here

% !TeX program = lualatex
\setmainfont{STIX Two Text}
\setmathfont{STIX Two Math}
\obeylines % just for this example
$e^j + |f|$ 
$abcdefghijklmnopqrstuvwxyz$ --- STIX Two Math, math italics   
\textit{abcdefghijklmnopqrstuvwxyz} --- STIX Two Text, text italics

\setmainfont{XITS}[Scale=MatchLowercase] % make sure x-heights match
\emph{abcdefghijklmnopqrstuvwxyz} --- XITS Text, text italics
  • 2
    without these options, the math is not in Times New Roman at all. The Latin option tells the package to use Times New Roman for the Latin letters in math mode and the Digits option does the same for the numbers. These two options (Latin,Digits) are thus more or less a minimum if you want to change the font used in math (if you use greek letters, you would also want to use the Greek option). Aug 27, 2011 at 6:10
  • Thank you for the answer ! (And sorry for my late reaction, it seems that I don't receive the notifications...) But unfortunately @Philippe Goutet is right. I think I will ask the creator of mathspec. He should know if a solution exists. If I have an answer, I will post it here.
    – Lierre
    Aug 29, 2011 at 11:38
  • Lierre and @Philippe Goutet: I've added a new paragraph and MSE to my answer, in which I discuss the improvements brought about by the latest release of the XITS Math font, a "Times compatible" font.
    – Mico
    Sep 18, 2011 at 19:16
  • Shouldn't you load unicode-math somewhere? texlive is a bit broken for me now and I can't test, but without unicode-math I don't this this is going to work as expected. Sep 18, 2011 at 19:42
  • @mico — I updated unicode-math yesterday to fix this problem (sorry, broken for a few days after I updated fontspec out of sync) and it will be in TL shortly; lead times are usually a day or two. Sep 18, 2011 at 22:10

I was struggling with similar mathspec/opentype/spacing problems and I solved them by resorting to plain latex math mode spacing commands:

\,      % a small space
\:      % a medium space
\;      % a large space
\quad   % a really large space
\qquad  % a huge space
\!      % a negative space (moves things back to the left)

The advantage over mathspec's " and \"..." is two-fold: you can use these commands anywhere (as apposed to only right in front of single characters) and they are LaTeX and XeTeX compatible.

I'm not sure if this is exactly what you need but it fixed my (similar) problems.

You must log in to answer this question.

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