36

The fraction in textstyle is off the math axis in XeTeX when I use a Unicode math font. In LuaTeX, though, it aligns nicely with the math axis. The follwing MWE should illustrate this. Also, in displaystyle everything is fine.

\ifdefined\directlua
  \input luaotfload.sty
\fi
$-{1\over 2}$%
\font\ms="Latin Modern Math:script=math;+ssty=0" at 7pt
\scriptfont0=\ms
$-{1\over 2}$
\bye

Here you can see the output for XeTeX and LuaTeX:

enter image description here

enter image description here

How can I fix this? Does it suffice to adjust \fontdimen parameters?


This does not only happen in plain XeTeX, but also in LaTeX with the unicode-math package. Unfortunately, I cannot show a side-by-side comparison here, because unicode-math immediately changes the math font to “Latin Modern Math”.

\documentclass{standalone}
\usepackage{unicode-math}
\begin{document}
$-\frac{1}{2}$
\end{document}

enter image description here

enter image description here


As can be seen from Herbert's reply, the problem also occurs in other situations. Here I collect an incomplete list of questions reporting similar issues:


Unfortunately, the problem was not entirely fixed and messed up fontdimens still turn up in some places.

5
  • There's evidently some problem in computing the \fontdimen parameters.
    – egreg
    Dec 4, 2015 at 15:57
  • The at 7pt seems to scale the fontdimen (try out 3pt for a more pronounced effect). Dec 4, 2015 at 16:19
  • @egreg Which \fontdimen is responsible for that? I can only find ones for raising or lowering numerator and denominator but none for the bar or axis. Also setting, e.g., \fontdimen42\scriptfont0=10pt does not seem to have any effect. Dec 5, 2015 at 12:24
  • I think this is a good one for the XeTeX mailing list at tug.org/mailman/listinfo/xetex. It seems that XeTeX is using \fontdimen22 pertaining to \scriptfont2 instead of \textfont2.
    – egreg
    Dec 6, 2015 at 13:54
  • IIRC, there's a difference between lua +ssty (scriptstyle!) and xetex; ie for lua: 2 and xetex: 1 or something
    – morbusg
    Aug 9, 2016 at 13:00

2 Answers 2

9

This seems to be fixed in the development version of XeTeX (looks like it was the same underlying issue as \setbox containing maths interferes with surrounding math mode in XeTeX):

enter image description here

5
  • This is great news! I'll mark your answer as accepted once TL 2017 is released which will probably contain the fixed version. Oct 7, 2016 at 18:18
  • 1
    Was it you who fixed this bug? The person who corrected this deserves a reward I think. Oct 7, 2016 at 18:19
  • 5
    @HenriMenke: Jonathan Kew fixed it (and a few other math bugs). It was me, however, who introduced this bug in the first place, so I guess this makes me deserve the reverse of being rewarded. Oct 7, 2016 at 20:57
  • 1
    Don't worry :) Can you maybe point me to the corresponding diffs and commits in the code? I'd like to study in detail what was wrong. Oct 7, 2016 at 21:11
  • 2
    @HenriMenke: I’m not 100% sure which commit fixed it, but my guess is this one. Oct 7, 2016 at 23:50
13

I played a bit ... black is xelatex and red lualatex and yes, this is not an answer ...

\documentclass{standalone}
\usepackage{amsmath,xcolor}
\usepackage{unicode-math}
\setmathfont{xits-math.otf}
\begin{document}
\makebox[0pt][l]{\raisebox{-1.6ex}{\includegraphics{xetex}}}%
\textcolor{red}{$-\frac12=-\dfrac12=-\tfrac12$}
\end{document}

enter image description here

2
  • 5
    Ugh… I used this approach to test luatex, xetex, and pdftex against Knuth tex and it turned out that tex, pdftex, and luatex overlay exactly, whereas xetex is off, as shown in your picture. That is to say, that math typesetting with Unicode math fonts is inherently broken in XeTeX. Dec 6, 2015 at 14:19
  • 1
    After some more playing, I found that this is also related to the “at 7pt”. For some reason even the spacings between the math atoms are scaled by that factor. But even after that there is a small difference left, cf. gist.github.com/anonymous/75e5b006effae7d3b860 Dec 6, 2015 at 15:06

You must log in to answer this question.

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