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).