5

Compiling the file

\documentclass{article}
\usepackage{unicode-math}
\setmathfont[
  Extension=.otf,
  range={\smallblacktriangleright},
  BoldFont = *bold
]{xits-math}
\begin{document}
\[\vphantom{\smallblacktriangleright}^a\smallblacktriangleright^a\]
\end{document}

produces the two copies of 'a' on the same height (which I expect) under lualatex, but lowers the first 'a' (which I consider wrong) under xelatex:

result of compiling with xelatex

Any hints on how to place the first 'a' on the correct height when compiling with xelatex?

5
  • Welcome to LaTeX! Welcome to TeX.SX!
    – JP-Ellis
    Feb 26, 2016 at 11:17
  • 2
    See Why should the minimal class be avoided? for the reason I edited your example.
    – egreg
    Feb 26, 2016 at 11:26
  • 1
    You can try, with LuaLaTeX, \vphantom{\bigg|}^a and you'll see that the phantom has no influence on the placement of the superscript, because a box doesn't make a math atom.
    – egreg
    Feb 26, 2016 at 16:14
  • 1
    @egreg \mathord{\vphantom{..}} works with lualatex. But with xelatex the results are quite confusing. E.g. the order matter. In \[\mathord{\vphantom{x}}^a x^a \mathord{\vphantom{x}}^a\] the first is wrong, the second ok. Feb 26, 2016 at 18:58
  • 4
    I'm voting to close this question as off-topic because the bug is fixed in TL2017. Jun 11, 2017 at 1:23

2 Answers 2

7

Looks as if xelatex is using cramped style in this case. You can avoid it by using an additional box:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont[
  Extension=.otf,
  range={\smallblacktriangleright},
  BoldFont = *bold
]{xits-math}


\begin{document}

\[\mbox{\vphantom{$\smallblacktriangleright$}}^a \smallblacktriangleright^a\]
\end{document}

enter image description here

5
  • 1
    This defeats the purpose of \vphantom and the size would be the same independently of the current style.
    – egreg
    Feb 26, 2016 at 14:30
  • 1
    @egreg: Yes, it wouldn't work as a general solution. But perhaps it is enough. Feb 26, 2016 at 15:09
  • Works like a charm! Feb 26, 2016 at 20:46
  • @UlrikeFischer Try without the \mbox{$\vphantom{...}$} and you'll get the same.
    – egreg
    Feb 26, 2016 at 20:54
  • XITS is probably unrelated to the problem. See tex.stackexchange.com/questions/296177/… Feb 26, 2016 at 20:59
4

I believe that there are several bugs involved.

First of all, doing \vphantom{something}^a in TeX should be exactly the same as saying {}^a, because \vphantom can never be the nucleus of a math atom. So when TeX scans ^, it adds an empty subformula as the nucleus of the math atom that should be superscripted.

I'll simplify the setting by using {>} instead of \smallblacktriangleright that's not relevant for the matter. Here's an example, first compiled with legacy pdflatex, then with LuaLaTeX and finally with XeLaTeX.

The \hrule is meant to show the top of the boxes, while the initial x marks the baseline. The fractions at the bottom will be explained later.

Code for the example

\documentclass{article}
\usepackage{ifxetex,ifluatex}

\ifx\ifxetex\ifluatex
\else
\usepackage{unicode-math}
\setmathfont{latinmodern-math.otf}
\fi

\begin{document}

\hrule height 0.1pt
x\(\displaystyle{}^a{>}^a\)

\hrule height 0.1pt
x\(\displaystyle\vphantom{>}^a{>}^a\)

\hrule height 0.1pt
x\(\displaystyle{\vphantom{>}}^a{>}^a\)

\hrule height 0.1pt
x\(\displaystyle{}^a{\sum}^a\)

\hrule height 0.1pt
x\(\displaystyle\vphantom{{\sum}}^a{\sum}^a\)

\hrule height 0.1pt
x\(\displaystyle{\vphantom{{\sum}}}^a{\sum}^a\)

\hrule height 0.1pt
\(\displaystyle\frac{\scriptstyle a}{\scriptstyle b}\frac{a}{b}\)

\end{document}

Output with pdflatex

enter image description here

As you can clearly see, there's no difference in the placement of the left superscript when {} or \vphantom{>} is used. Nor there is in the third line, where {\vphantom{>}} is the nucleus of the math atom that receives the superscript.

Similarly there's no difference in the first two lines when \sum is used instead of >, but the difference shows up in the third line.

Output with LuaLaTeX

enter image description here

This is essentially the same as before.

Output with XeLaTeX

enter image description here

A few differences show up. The top three lines are different from each other. For the first and third lines, this might have to do with how XeTeX processes the information from the OpenType font, in order to transform it into the appropriate \fontdimen parameters and should be fixed to match the legacy typesetting.

The second line is plainly wrong. It seems that when a \vphantom is concerned, which involves \mathchoice, the dimension used to set the superscript to the added empty nucleus is relative to the scriptscriptstyle font.

This might be connected with another known bug of XeTeX, that shows up with fractions. If you compare the fractions in the first two images, the fraction line is at the same level; in the XeLaTeX output, the fraction with scriptstyle numerator and denominator has a lower and thicker fraction line.

The connection seems quite likely, because fractions and \mathchoice (on which \vphantom is built) use a very similar mechanism.

Solution?

None that can be deemed as general as one could hope. Use an appropriate

{\vphantom{?}}^a

where ? is some symbol whose height makes the height of the superscript to match the desired one.

4

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