# Unicode-math changes font outside of range

I'm using the unicode-math package with LuaLaTeX (TeXlive 2017). I'm trying to set the math font for the \setminus character as in this answer, because it doesn't exist in the Latin Modern math font.

With the following MWE:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\begin{document}
$\pi \in \mathbb{R} \setminus \mathbb{Q}$
\end{document}


I get this result:

As expected, the \setminus character doesn't appear, and I have the Latin Modern font.

But now if I try this:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont[range=\setminus]{XITS Math} % This changed
\begin{document}
$\pi \in \mathbb{R} \setminus \mathbb{Q}$
\end{document}


I get this:

The \setminus character now appears, but the mathbb font changed! And if I try with random letters (or the \pi character above), I see that the "normal" font remains Latin Modern. What happened?

• The bug has been fixed with unicode-math version 0.8j, released 2018-01-07. Jan 10 '18 at 12:07

It is one of the side effects of the range option - it is a bit buggy. Reset things to your main font afterwards. I would also use \symbb instead of \mathbb -- it is the more modern and semantic correct command:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont[range=\setminus]{XITS Math} % This changed
\setmathfont[range=\int]{Latin Modern Math} % This changed
\begin{document}
$\pi \in \symbb{R} \setminus \symbb{Q}$
\end{document}


• Thanks. What's the difference between mathbb and symbb? I couldn't find anything online. Jul 25 '17 at 13:21
• The sym** commands take the glyph from the relevant unicode block of the current math font, while the math** commands (can) use a different font (even a textfont). So I would use \sym** for all normal single glyphs variables from the set [a-Z]. Jul 25 '17 at 13:27