13

I noticed that the spacing between math inside a pair of delimiters using \left and \right and the closing delimiter (the one with \right) itself is sometimes wrong when using LuaTeX and unicode-math. This MWE

\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{mleftright}
\mleftright

\begin{document}
\begin{align*}
  &\left|T\right| \left(T\right) & &\left|P\right| \left(P\right) & &\left|O\right| \left(O\right) & &\left|A\right| \left(A\right) & &\left|V\right| \left(V\right) \\
       &|T|            (T)       &      &|P|            (P)       &      &|O|            (O)       &      &|A|            (A)       &      &|V|             (V) \\
\end{align*}
\end{document}

produces this output enter image description here The first line is with \left| and \right|, while the second with just | pairs. O and A are fine, while the spacing between T, P or Vand the closing | or ) is too small in the first line.

mleftright is used to correct the spacing outside the delimiters and provide a better comparison, but the same spacing issue remains without mleftright. I tried different fonts, same result. I am using TeXLive 2016, but I manually updated LuaTeX to the version from http://minimals.contextgarden.net/current/bin/luatex/linux-64/bin/ (currently 1.0.3) to try to solve the problem, without success.

The spacing is correct with XeTeX with unicode-math, or with LuaTeX without unicode-math.

Is this a unicode-math or a LuaTeX bug? Is there any workaround? Of course in this case there is no need of using \left and \right, but I need them in defining macros that scale the delimiters according to the surrounded math. Thanks!

simpler test

\documentclass{article}

\showoutput
\ifx\Umathchar\undefined\else
\usepackage{unicode-math}
\fi


\begin{document}


$\left|T\right|\showlists$

$|T|\showlists$

\end{document}
7
  • 1
    Looks like a luatex engine issue I think, in the simpler test version I just added pdftex and xetex give a kern between T and | even when there is a \right acting,. but luatex does not. Feb 18, 2017 at 13:01
  • 1
    @DavidCarlisle I see the problem in context too. Feb 18, 2017 at 13:18
  • raised on luatex list as tug.org/pipermail/luatex/2017-February/006348.html Feb 18, 2017 at 14:16
  • @DavidCarlisle Thank you for your quick reply. I am compiling your test with xelatex to know the kerning, and (re)adding it using something like \ifluatex\kern1.48pt\fi before \right when I notice that it is missing. However, the exact kerning depends on the specific letter... Do you have a better workaround to suggest? Thanks
    – Marco
    Feb 18, 2017 at 19:09
  • @Marco you might like to follow the discussion on the luatex list archive above. I'm pushing back a bit to Hans, the main luatex and lua font loader author, to get clarification of the issue. Feb 18, 2017 at 19:54

1 Answer 1

10

The following plain TeX file shows that it is an engine (or luaotfload) issue, with pdftex or xetex the kern between T and | is used even when there is a \right but in luatex the kern is dropped.

xetex enter image description here

luatex enter image description here

\tracingonline1

\ifx\directlua\undefined\else
\input{luaotfload.sty}
\font\mmm="[latinmodern-math.otf]:mode=base;script=math;language=DFLT;"
\font\mmms="[latinmodern-math.otf]:mode=base;script=math;language=DFLT;" at 7pt
\font\mmmss="[latinmodern-math.otf]:mode=base;script=math;language=DFLT;" at 5pt

\Umathcode`T= 0 0 "1D447
\Umathcode`|= 0 0 `|
\Udelcode`|= 0 `|
\textfont0=\mmm
\scriptfont0=\mmms
\scriptscriptfont0=\mmmss
\textfont1=\mmm
\scriptfont1=\mmms
\scriptscriptfont1=\mmmss
\textfont2=\mmm
\scriptfont2=\mmms
\scriptscriptfont2=\mmmss

\fi

\ifx\XeTeX\XeTeXcharclass\else
\font\mmm="[latinmodern-math.otf]/OT:script=math;language=DFLT;"
\font\mmms="[latinmodern-math.otf]/OT:script=math;language=DFLT;" at 7pt
\font\mmmss="[latinmodern-math.otf]/OT:script=math;language=DFLT;" at 5pt

\Umathcode`T= 0 0 "1D447
\Umathcode`|= 0 0 `|
\Udelcode`|= 0 `|
\textfont0=\mmm
\scriptfont0=\mmms
\scriptscriptfont0=\mmmss
\textfont1=\mmm
\scriptfont1=\mmms
\scriptscriptfont1=\mmmss
\textfont2=\mmm
\scriptfont2=\mmms
\scriptscriptfont2=\mmmss

\fi





1 $\left|T\right|\showlists$

\ifx\Uleft\undefined\else 2 $\Uleft|T\Uright|\showlists$\fi

3 $|T|\showlists$


\bye

Update

As a result of discussion following from this Q&A, Hans has extended luatex in its development build to have a new mode to adjust the setting in this case. This is just in development branch of luatex 1.04 so may not be in quite this form when it reaches stable builds but already it is showing improvement on this example. mode=0 should match the existing behaviour, the \mathitalicsmode=1 option is new.

enter image description here

\documentclass{article}
\usepackage{unicode-math}

% , $\left|T\kern\fontcharic\textfont0"1D447 \right|$
\newcommand{\test}[1]{%

{mode=0 \setmathfont{#1}#1: $|T|$,  $\left|T\right|$\par}
{\mathitalicsmode=1 mode=1 \setmathfont{#1}#1: $|T|$, $\left|T\right|$\par}
\medskip
}

\begin{document}
\test{Latin Modern Math}

\test{TeX Gyre Termes Math}

\test{TeX Gyre Pagella Math}

\test{TeX Gyre Bonum Math}

\test{Asana Math}

\test{XITS Math}

\test{STIX2Math.otf}

\test{Cambria Math}

\end{document}
3
  • LuaTeX on $\left|T\right|$\bye will show correct kerning.
    – egreg
    Feb 18, 2017 at 14:02
  • @egreg with an upright T yes I noticed that (or do you mean just that, with tfm fonts?) Feb 18, 2017 at 14:03
  • Yes, legacy fonts.
    – egreg
    Feb 18, 2017 at 14:05

You must log in to answer this question.

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