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.

For my current document I want to use a normal serif font for the main text. Most diagrams from other sources and myself are with sans serif fonts (TeX Gyre Heros). Now I want to use pgfplots to create figures using these fonts but keep the math in the main text in the normal font. Something similar has been achieved with sansmath here but this does not switch to completely different font, as I am trying here. I thought with unicode-math I can switch back and forth easily but the switching back part fails.

My MWE looks as follows:


\setmathfont{Latin Modern Math}


    \setmathfont{TeX Gyre Heros}  
    \setmathfont[range=\mathit/{latin, Latin, greek, Greek}]{texgyreheros-italic.otf} 
            \addplot [blue] coordinates { (0,0) (1,2) };
        \node at (4, 1) { $\Delta T_{\mathrm S}$};
        \node at (2, 5) {normal sans serif text};
    \setmathfont{Latin Modern Math}  
\caption{Some caption text.}

Normal text in Latin Modern Roman here but math fails unless the next line is used.
%\setmathfont{Latin Modern Math} 
a^2 + b^2 = c^2


and gives the following output:

enter image description here Thank you for any hints, why the switching back fails and comments in general how this might be improved.

share|improve this question
Try to shift \rmfamily\setmathfont{Latin Modern Math} after the figure environment. Does it helps? –  Claudio Fiandrino Aug 3 '12 at 6:20
If you want to switch between math versions you should better declare a \mathversion. Imho the newest unicode-math contains the necessary code. –  Ulrike Fischer Aug 3 '12 at 6:26
You can't use TeX Gyre Heros as math font, because it lacks the basic math functionalities. –  egreg Mar 2 '13 at 21:37
@UlrikeFischer: We need an answer ;-) –  Marco Daniel Mar 3 '13 at 14:33
@MarcoDaniel: I don't have one: It is not difficult to set up a mathversion with another math font, but the use of TeX Gyre and the range part has some side effects. –  Ulrike Fischer Mar 3 '13 at 17:21

Your Answer


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

Browse other questions tagged or ask your own question.