# Arrow length in LuaTeX in combination with the unicode-math package

I have a probably rather simple question: Is it possible to use the unicode-math package within LuaLaTeX such that arrows stretch when writing some longer expression above or below it?

For example the following code with the package unicode-math loaded doesn't produce stretched arrows and the text over the arrow is much longer than the arrow itself:

% TeX engine: LuaLaTeX
% TeX Live 2014
% TeX encoding = UTF-8
\documentclass{minimal}
\usepackage{amsmath,
unicode-math}

\begin{document}

$a \xrightarrow{b \to \infty} c$

\end{document}


I'd consider this a bug both in unicode-math, which should provide a good equivalent of \std@minus when amsmath is loaded and of Latin Modern Math, that doesn't provide a glyph for \harrowextender (U+23AF HORIZONTAL LINE EXTENSION). See the related question Why fontspec breaks extarrows package

For your problem, you can do

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

\makeatletter
\AtBeginDocument{\Umathcharnumdef\std@minus\Umathcodenum- }% \std@minus is minus
\makeatother

\begin{document}

$a \xrightarrow{b \to \infty} c$

\end{document}


A better workaround should use \harrowextender when available:

\documentclass{article}
\usepackage{amsmath,unicode-math}
%\setmathfont{Asana Math} % if uncommented, \harrowextender would be used

\makeatletter
\AtBeginDocument{%
\check@mathfonts
\iffontchar\textfont\tw@\string"23AF
\renewcommand{\relbar}{\mathrel\harrowextender}%
\else
\Umathcharnumdef\std@minus\Umathcodenum-
\fi}
\makeatother

\begin{document}

$a \xrightarrow{b \to \infty} c$

\end{document}


The second code uses \check@mathfonts to ensure fonts are associated to the math families (LaTeX normally doesn't do this until the first formula is being typeset in order to avoid using up math families that couldn't be unused in the document).

With unicode-math, the math font defined by \setmathfont is associated to math family 2, so we check whether the character corresponding to \harrowextender exists in the font (see the e-TeX manual, texdoc etex for \iffontchar). If the character exists, we redefine \relbar to be that symbol as math relation. Otherwise, we resort to using a minus sign, under the name \std@minus that's used by amsmath in this context.

What happens without the code is that \std@minus becomes “choose character 0 in math family 2“, which is correct for the traditional TeX math fonts, but is not true any more for unicode-math. So in this case we redefine \std@minus to be a math char having the same code as the minus sign (see the XeTeX manual, texdoc xetex, for more information about \Umath... commands).

• Thank you very much! It works for me now. Do you know where I can find a documentation on the LaTeX-code you used? – bfc Dec 17 '14 at 14:28
• @bfc I added some notes. – egreg Dec 17 '14 at 14:55
• Any possibility to report that problem to LM Math? Can't find any issue tracker or alike. – LaRiFaRi Nov 17 '15 at 15:32
• I think only email to the TeX Gyre team, but I'm not sure it can have any effect. – egreg Nov 17 '15 at 15:34