\sqrt[x]{y} Breaks With unicode-math
Tracing through the code, the issue is that unicode-math
redefines \r@@t
, which is used by LaTeX when it typesets a root with an index. The redefinition is different for LuaTeX and XeTeX, so you only see the issue with XeTeX. In that case, it is
\cs_set_nopar:Npn \r@@t #1 #2 {
\hbox_set:Nn \l_tmpa_box {
\c_math_toggle_token
\m@th
#1
\sqrtsign { #2 }
\c_math_toggle_token
}
\um_mathstyle_scale:Nnn #1 { \kern } {
\fontdimen 63 \l_um_font
}
\box_move_up:nn {
(\box_ht:N \l_tmpa_box - \box_dp:N \l_tmpa_box)
* \number \fontdimen 65 \l_um_font / 100
} {
\box_use:N \rootbox
}
\um_mathstyle_scale:Nnn #1 { \kern } {
\fontdimen 64 \l_um_font
}
\box_use_drop:N \l_tmpa_box
}
The key here is the \fontdimen
business: these are 'high number' font dimensions which are not available in traditional TeX. As such, these are not defined for text fonts: they are only available for 'proper' Unicode math fonts. You therefore see the error only if you set up some symbols to be taken from a text font.
Obviously unicode-math
maps the last font set with \setmathfont
to \l_um_font
and then uses it in \r@@t
to get the \fontdimen
values. So you could try as a workaround to remap \l_um_font
to your "main" math font:
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont[range=\mathbb]{Arial}
\setmathfont[range=\int]{Latin Modern Math}
\begin{document}
\[ \sqrt[5]{2} \mathbb{ABC} \]
\end{document}
I'm not quite sure what unicode-math
should do in this situation, but probably \r@@t
should use the font of the actual radical symbol. (And it should sort out the redefinitions of \r@@t
. at line 2098 is looks as if it would redefine only when amsmath
is not loaded but later on it does it anyway. Very confusing ;-).)