# Operator font in beamer/metropolis

When using the metropolis theme for beamer, I get text and math in Fira Sans, except for math operators. I compile the following MWE using LuaTeX.

\documentclass{beamer}

\usetheme{metropolis}

\begin{document}

\begin{frame}
Ordinary text.
$a^2 + b^2 = \sin^2(x) - \mathsf{y} + \mathrm{z}$
\end{frame}

\end{document}


The outcome for me is that a, b, 2 and x are set in Fira Sans Light Italic, and y is set in Fira Sans Light, but sin is set in the sans font of (I guess) Latin Modern. (The z is also in Latin Modern, but this is expected behaviour from beamer.)

Unsurprisingly, I get the same result if I replace \usetheme{metropolis} with

\usepackage[no-math]{fontspec}
\setsansfont[ItalicFont={Fira Sans Light Italic},
BoldFont={Fira Sans},
BoldItalicFont={Fira Sans Italic}]%
{Fira Sans Light}


I guess that this is to do with beamer's patching parts of the math fonts to match the text font (see this previous question). However, I don't understand the font system well enough to modify this.

There was a similar question asked before, but I've no idea how to apply that answer when using fontspec, or if this is even possible.

Is there a way to change the operator font to match the upright/sans math font (i.e., Fira Sans Light)?

• I have found that loading \usepackage[italic]{mathastext} automatically sets the operators in the (upright) text font, and looks otherwise almost identical to beamer's output, the exception being that \mathrm is now the upright text font instead of the inherited Latin Modern. Still, I would be interested to know how to change the operator font by hand! Mar 1, 2019 at 21:48

Maybe changing the operator font could be a workaround:

% !TeX TS-program = xelatex
\documentclass{beamer}

\usetheme{metropolis}

\DeclareSymbolFont{sfoperators}{OT1}{FiraSans-LF}{l}{n}
\makeatletter
\renewcommand{\operator@font}{\mathgroup\symsfoperators}
\makeatother

\begin{document}

\begin{frame}
Ordinary text.
$a^2 + b^2 = \sin^2(x) - \mathsf{y} + \mathrm{z}$
\end{frame}

\end{document}


• This is perfect, thank you! Would you mind explaining a bit about what's going on with \DeclareSymbolFont here? In particular, how do you know that FiraSans-LF is the right thing to enter for the font family? I can't figure this out from fntguide.pdf (which must presumably be out of date, because it says "Font family names should contain up to five lower case letters"). Mar 24, 2019 at 18:46
• @AlexWatson I'm actually not a font expert, so other people might be able to explain this better or even judge if this really a solution or just some dirty hack. About the font name: I actually searched in the tex installation for some fira font files and found some in /usr/local/texlive/2019/texmf-dist/tex/latex/fira from where I got the name to use in \DeclareSymbolFont. Mar 24, 2019 at 20:36