[Tex/LaTex] Using several math fonts with unicode-math

fontsunicode-math

I'd like to typeset a document that uses two different math fonts with unicode-math. In the documentation I can't find anything about switching the font mid-document. Just writing

\setmathfont{xits-math.otf} $a$
\setmathfont{lmmath-regular.otf} $a$

does work, but I'm wondering whether this is the correct way to do it when switching between fonts several times in a document.

Best Answer

unicode-math, starting from v0.6, supports LaTeX math versions, which is a more efficient way for switching math fonts mid-document than re-loading the font each time:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont[version=xits]{xits-math.otf}
\setmathfont[version=lm]{lmmath-regular.otf}
\begin{document}
\mathversion{xits} $a$
\mathversion{lm} $a$
\end{document}