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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use a different math font in figures (namely tikzpictures). I already asked a question about this topic where I tried to mix mathspec and unicode-math. Now after some reseach I realized that mathspec does not allow to switch the font at all and I should use only unicode-math.

But there I also get build errors in my MWE (or should I say MnWE, because it does not work):

% !TEX TS-program = xelatex

\setmainfont{TeX Gyre Pagella}
\newcommand{\rmmath}{\setmathfont{TeX Gyre Pagella Math}}

\newcommand{\sfmath}{ %
    \setmathfont{TeX Gyre Pagella Math} %
    \setmathfont[range=\mathup, Numbers=Lining, Scale=MatchUppercase]{Candara} %
    \setmathfont[range=\mathit, Scale=MatchUppercase]{Candara Italic} %
    \setmathfont[range=\mathbf, Scale=MatchUppercase]{Candara Bold} %


% This would work, but I actually do not need sans math in running text
%   \sfmath $I$
%   \rmmath $I$
%   \sfmath $I$
%   \rmmath $I$
%   \sfmath $I$
%   \rmmath $I$
%   \sfmath $I$
%   \rmmath $I$

    Text $I$
        \node {Node: $I$};
    \caption{Caption text with math $I$}
% If you remove the following lines it will compile
        \node {Node: $I$};
    \caption{with math $I$}

Some interesting notes: if I remove the figure environment, i.e. only use tikzpicture it will build. If I use center instead of figure it also does not work. Funnily enough, if I have only one figure it will build.

The first error I get:

. fontspec info: "defining-font"
. Font family 'Candara(1)' created for font 'Candara' with options
. [BoldItalicFont={},ItalicFont={},Script=Math,SizeFeatures={{Size=10-},{Size=7
. This font family consists of the following shapes:

! LaTeX Error: Symbol font `um_fam1' not defined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.

l.43 ^^I\begin{tikzpicture}

Your command was ignored.
share|improve this question
See also how to select math font in document – Mico Aug 23 '13 at 13:34
@Mico, that's right. The version option and \mathversion would be the best, unfortunately the version option does not work with range. – quinmars Aug 23 '13 at 16:21

I had exactly the same problem. You can partly circumvent it by using math versions, i.e.

\setmathfont{version=default,TeX Gyre Pagella Math} %
\setmathfont[version=sansserif, Numbers=Lining, Scale=MatchUppercase]{Candara}

and then use


to switch back and forth.

Math versions are however not compatible with the range= argument, which probably renders this approach useless. For myself I actually quickly put together a version of Tex Gyre Pagella Math which has all serif latin letters and numbers replaced by sans serif versions from Tex Gyre Heros. Not everything works, e.g. \sqrt has a problem, but for simple math it seems to be fine. You can download it here: http://n.ethz.ch/~thomasu/download/TeXGyrePagellaMathSans-Normal.otf

share|improve this answer
That sounds at least like a approach that works, although very hackish. How did you replaced the characters? – quinmars Aug 23 '13 at 16:58
On my Mac I used a trial version of glyphsapp.com. I guess something like FontForge would also work. It needs some manual intervention though as you have to identify the parts to be replaced and then manually (I used a Python script) adjust the glyph names and unicode IDs. – thomasius Aug 25 '13 at 19:52
Thanks alot, i'll give it at try, when I have some time. – quinmars Aug 25 '13 at 20:34
Actually I even managed to retain the full math functionality by also transferring the MATH table entries by copying the relevant directly from one Spline Font Database Format (.sdf) file produced by FontForge to the other. – thomasius Aug 26 '13 at 20:35

Your Answer


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.