Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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 '11 at 19:20
    
@AlanMunn: Yes. Basically I want to have exercise questions and proposed answers in different fonts. –  Caramdir Sep 25 '11 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. –  Khaled Hosny Sep 25 '11 at 21:29

2 Answers 2

up vote 14 down vote accepted

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}
share|improve this answer

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]

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.