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.

  • I'm assuming the switch needs to be total, and not just for particular ranges of characters (in which case the range facility of unicode-math might help).
    – Alan Munn
    Sep 25, 2011 at 19:20
  • @AlanMunn: Yes. Basically I want to have exercise questions and proposed answers in different fonts.
    – Caramdir
    Sep 25, 2011 at 19:29
  • Check the support for math version in the latest unicode-math (should be covered in the documentation), also check the source of the latest unimath-symbols file. Sep 25, 2011 at 21:29

2 Answers 2


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:

\mathversion{xits} $a$
\mathversion{lm} $a$

The method you note in your question works in the sense that it does a global reset on the font used in math mode. The documentation for the fontspec and unicode-math packages provides examples of how one may restrict the scope of a math font to various subsets of math-font applications. Section 4.1 (pp. 6f.) of the unicode-math manual starts off by noting that "[t]here will probably be few cases where a single Unicode maths font suffices. ... It will therefore be necessary to delegate specific Unicode ranges of glyphs to separate fonts". It then gives examples for selecting a math font for

  • specific glyphs such as \int, \sum, and \prod
  • a collection of symbols with the same math type, such as \mathopen
  • complete math styles such as \mathbb
  • comma-separated lists of Unicode slots and ranges

Section 3.1 of the fontspec manual states that "By default, fontspec adjusts LaTeX's default maths setup in order to maintain the correct Computer Modern symbols when the roman font changes. However, it will attempt to avoid doing this if another maths font package is loaded (such as mathpazo or the unicode-math package). If you find that fontspec is incorrectly changing the maths font when it should be leaving well enough alone, apply the [no-math] package option to manually suppress its maths font." [highlighting via backticks added]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .