Please consider the following MWE:
\documentclass{beamer}
\usepackage{unicode-math}
\usepackage{fontspec}
\setsansfont{some-font.otf}
\usefonttheme[onlymath]{serif}
\begin{document}
\begin{frame}
Some text with the number \textit{two} in text mode (2) and math mode ($2$).
\begin{equation*}
\vec{s}(t) = \frac{\vec{a}}{2} t^2 + \vec{v}_0 t + \vec{s}_0
\end{equation*}
\end{frame}
\end{document}
How to change the font of all math digits to the sans font defined with fontspec
's \setsansfont
command (font-independent)?
I tried to experiment with the \Umathcode
XeTeX primitive as well as with \setmathfont
provided by unicode-math
, however, I had no success.
I am aware of the package mathspec
and its \setmathfont(digits)
command, but I realized that the combination of a beamer
class document and fontspec
/mathspec
causes misplaced math elements (see figures 1 and 2 for a comparison; for figure 2, \usepackage{unicode-math}
package has been commented out in the MWE).
Update:
This MWE compiles without any error in my setup. However, if the line \setmainfont{Arial}
is commented out, an error will be thrown. The same is true if I specify a font as a file (*.ttf or *.otf) instead of a system-installed font.
\documentclass{beamer}
\usefonttheme{professionalfonts}
\usepackage{unicode-math}
\usepackage{fontspec}
\setmainfont{Arial}
\setmathfont[range={\mathup}]{Lucida Sans}
\begin{document}
\begin{frame}
\begin{equation}
x = \int\limits_0^\infty f(q) \,\mathrm{d} q
\end{equation}
\end{frame}
\end{document}
Best Answer
Disable the font setting of
beamer
: