How can you change the font of MATH and Text of a section of your document?
Using the default packages (LaTeX) or system fonts (XeLaTex)?
How can you change the font of MATH and Text of a section of your document?
Using the default packages (LaTeX) or system fonts (XeLaTex)?
If you can use either XeLaTeX or LuaLaTeX, you may employ \begingroup and \endgroup statements to limit the scope of a \setmainfont instruction. To keep the change of the math font "local" to a (TeX) group, don't use \setmathfont directly. Instead, set up all math versions in the preamble and employ \mathversion directives in the body of the document.
An MWE (minimum working example), to be compiled with either XeLaTeX or LuaLaTeX.
\documentclass{article}
\usepackage{unicode-math} % load 'fontspec' automatically
\setmathfont{Latin Modern Math}[version=LM]
\setmathfont{XITS Math}[version=XITS]
\newcommand\qbf{The quick brown fox jumps over the lazy dog.\quad $E=mc^2$.\par}
\begin{document}
\setmainfont{Latin Modern Roman}
\mathversion{LM}
\qbf
\begingroup
\setmainfont{XITS} % Times Roman clone
\mathversion{XITS}
\qbf
\endgroup
\qbf % back to Latin Modern font family for both text and math
\end{document}
"LaTeX Error: Missing \begin{document}. ..... 1.3 \setmathfont{Latin Modern Math}[version=LM] ?"
And if I press enter, another error "1.15 \mathversion{LM} ?"
And at the end all math fonts will be times new roman
– David R Apr 26 '17 at 22:06/Users/mico/Library/Fonts/euler.otf. I understand it's supposed to be the OpenType equivalent of the set of glyphs provided by the eulervm package. That said, I've never used the "Neo Euler" math font for any work yet.
– Mico
Apr 27 '17 at 19:35
{...} instead of \begingroup...\endgroup in your MWE?
– Diaa
Oct 13 '19 at 20:05