# Non-math fonts with unicode-math kill \widetilde and \widehat

I suspect this might be a bug in unicode-math, but you never know. It appears that loading any non-math font for any purpose at all breaks \widehat and \widetilde. Consider, for instance, the MWE below where I load XITS Math as my math font, but try some other fonts for \mathbfup. That should have absolutely no effect for what happens to my math except when using bold upright math. However, even though the font does not change for the math I type, the \widetildeand \widehat become either normal \tilde and \hat... or disappear completely, depending on the font I load.

Is this a bug, or am I doing something wrong somewhere?

(As the MWE suggests, I am compiling using LuaLaTeX.)

% !TeX program=luatex

\documentclass{article}

\usepackage{unicode-math}

\setmathfont{XITS Math}

\begin{document}

$\widetilde X\widehat X$

\setmathfont[range=\mathbfup]{Minion Pro Bold}

$\widetilde X\widehat X$

\setmathfont[range=\mathbfup]{Linux Libertine O Bold}

$\widetilde X\widehat X$

\end{document}


EDIT: Compiling using XeLaTeX, I get the following instead. This makes me even more confident that there is a bug somewhere.

The workaround suggested by Ulrike Fischer in her answer to \sqrt[x]{y} Breaks With unicode-math works also in this case:

\documentclass{article}

\usepackage{unicode-math}

\setmathfont{XITS Math}
\setmathfont[range=\mathbfup]{Linux Libertine O Bold}
\setmathfont[range=\int]{XITS Math}

\begin{document}

$\widetilde X\widehat X\mathbf{X}$

\end{document}


Note that you shouldn't be changing math font inside the document. The problem is that unicode-math gets some values for math typesetting from the last loaded math font. Since Linux Libertine isn't a math font, it doesn't have some necessary parameters.

Note that the last glyph is from Linux Libertine.

• I guess this is the cleaner solution, since it directly addresses the cause of the issue. Accepted. Isn't it kind of a bug that the last loaded font determines how fractions and accents look? Shouldn't that come from the main math font? – Gaussler Jun 2 '15 at 6:27
• do you think it would cause problems to just put the line \setmathfont{XITS Math} last, after all other \setmathfonts? – Gaussler Jun 2 '15 at 16:14
• @Gaussler I prefer not doing it, just for consistency, but you can experiment. – egreg Jun 2 '15 at 16:15

The accent is not there as warned in the log

Missing character: There is no ̃ (U+0303) in font "MinionProBold:mode=base;scri
pt=latn;language=DFLT;"!


Why \widetilde is being redefined to use the new \symnum_fam1 allocated to the bold minion font, I'm not sure, but you can define it back again:

% !TeX program=luatex

\documentclass{article}

\show\widetilde

\usepackage{unicode-math}

\setmathfont{XITS Math}

\begin{document}
\show\widetilde
\show\symoperators
$\widetilde X\widehat X$

\let\oldwidetilde\widetilde
\let\oldwidehat\widehat
\setmathfont[range=\mathbfup]{Minion Pro Bold}
\let\widetilde\oldwidetilde
\let\widehat\oldwidehat

$\widetilde X\widehat X$

\setmathfont[range=\mathbfup]{Linux Libertine O Bold}

$\widetilde X\widehat X$

\end{document}


I don't think unicode-math really claims to support non math fonts in this way, so it's not clearly a bug, but may be worth raising on the unicode-math issue tracker anyway.

• In order for the interface to work logically, I think that changing what happens in \mathbfup should have no effect on what happens to the rest of the math. Particularly so when replacing range=\mathbfup by range=\mathbfup/{latin,Latin,greek,Greek}; however, it also happens in that case. – Gaussler Jun 1 '15 at 19:09