5

I am making my presentation in beamer and want to use a sans font for text and mathpazo font for math. I would like, though, that operator names are by default set in the same sans font as my text, rather than a different one.

I could redefine every single operator, but it seems like there should be a cleaner way.

Here is a MWE

\documentclass{beamer}

\usepackage[scaled=1.04]{biolinum} 
\usepackage{mathpazo}
\renewcommand*\familydefault{\sfdefault} 

\begin{document}

\begin{frame}

I get this with for the operators by default

\begin{equation*}
\sin x = \log x = \lim x
\end{equation*}

I want something that looks like this, with text (which by default is textsf) for the operators

\begin{equation*}
\mathop{\text{sin}} x = \mathop{\text{log}} x = \mathop{\text{lim}} x
\end{equation*}

\end{frame}

\end{document}

It looks like this enter image description here

2
  • 1
    \SetSymbolFont{operators} {normal}{OT1}{LinuxBiolinumT-TLF} {m}{n} \SetSymbolFont{operators} {bold} {OT1}{LinuxBiolinumT-TLF} {b}{n}
    – cfr
    Sep 19 at 4:10
  • Note that your code isn't properly applying mathpazo so if you want the same output, you probably need not to use mathpazo or to override more than just the font used for operators.
    – cfr
    Sep 19 at 4:39

3 Answers 3

8

You can change the operators font and use professionalfonts from Beamer to take control of the font setup:

\documentclass{beamer}
\usefonttheme{professionalfonts}

\usepackage[scaled=1.04]{biolinum} 
\usepackage{mathpazo}
\SetSymbolFont{operators}   {normal}{OT1}{LinuxBiolinumT-TLF} {m}{n} 
\SetSymbolFont{operators}   {bold}  {OT1}{LinuxBiolinumT-TLF} {b}{n}

\begin{document}

\begin{frame}
  Now you get this
  \begin{equation*}
    \sin x = \log x = \lim x
  \end{equation*}
\end{frame}

\end{document}

Note that it isn't necessary to set sans as default for text, since Beamer does this anyway.

use correct sans for text and maths

2
  • 2
    Thanks, that's perfect. With beamer \usefonttheme{professionalfonts} is required for this to work. The SetSymbolFont solution seems to work also in other contexts (e.g. article class). without \usefonttheme{professionalfonts}
    – innisfree
    Sep 19 at 4:38
  • @innisfree Yes, Beamer does its own thing. \usefonttheme{professionalfonts} is a Beamer-specific thing which gives you control of the fonts. In other classes, you don't need it. (Or if you do, the thing you need would be specific to those classes.)
    – cfr
    Sep 19 at 4:42
3

Since you’re using Beamer, you aren’t submitting to one of the people who still only accept 8-bit fonts in 2023, and can use modern OpenType forks of your fonts. Specifically, Libertinus Sans is based on Phillip Poll’s Linux Biolinum, and Asana Math is based on Young Ryu’s Pazo Math, but both have a much larger repertoire and work with modern tools.

A MWE:

\documentclass[professionalfonts]{beamer}

\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX}
\setmainfont{Libertinus Sans}[Scale=1.04]
\setsansfont{Libertinus Sans}
\setmathfont{Asana Math}
\setmathfont{LibertinusSans-Regular}[range=up]
\setmathfont{LibertinusSans-Bold}[range=bfup]
\setmathfont{LibertinusSans-Italic}[range=it]
% Linux Biolinum and Libertinus Sans have no Bold Italic,
% but you could fake one with FakeBold if needed.

\begin{document}

\begin{frame}

I want something that looks like this, with text (which by default is textsf) for the operators.

\begin{equation*}
\sin x = \log x = \lim x
\end{equation*}

\end{frame}

\end{document}

Libertinus Sans sample

By the Way, Some Alternatives

For a single, consistent font that has the look you’re going for, you might try \setmathfont{KpMath-Sans.otf} from the kpfonts-otf package. You can change the operator font in unicode-math with the command \setoperatorfont\mathsf:

\documentclass[professionalfonts]{beamer}

\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX}
\setmainfont{Libertinus Sans}[Scale=1.0]
\setsansfont{Libertinus Sans}
\setmathfont{KpMath-Sans.otf}
\setoperatorfont\mathsf


\begin{document}

\begin{frame}

I want something that looks like this, with text (which by default is textsf) for the operators.

\begin{equation*}
\sin x = \log x = \lim x
\end{equation*}

\end{frame}

\end{document}

Biolinum/KpMath-Sans sample

Or if you really like Pazo Math: It was designed to match Hermann Zapf’s Palatino. Zapf’s fonts Optima and AMS Euler go great with them and each other. (And a monospace font that goes well with that family is the humanist Inconsolata.)

Here’s what Euler’s formula looks like in Euler Math (a fork of AMS Euler) with URW Classico (a clone of Optima available from CTAN) as the text font:

\documentclass{article}
\usepackage[math-style=upright]{unicode-math}

\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont{URW Classico}[Scale=1.0]
\setsansfont{URW Classico}
\setmathfont{Asana Math}
\setmathfont{Euler Math}[range={up/{Latin,latin,Greek,greek},
                    bfup/{Latin,latin,Greek,greek},
                    cal, bfcal, frak, bffrak},
            ]
\setmathfont{URW Classico}[range={up/num}]
\setmathfont{URW Classico Bold}[range={bfup/num}]

\newcommand\upi{\symup{i}}
\newcommand\upe{\symup{e}}

\begin{document}
\begin{align*}
  \upe^{\upi x} &= \cos{x} + \upi \sin{x} \\
  \upe^{\upi \uppi} + 1 &= 0
\end{align*}
\end{document}

Euler Math + URW Classico sample

2

An example for lualatex:

\documentclass[professionalfonts]{beamer}
\usepackage{FiraSans}
\usepackage[mathrm=sym]{firamath-otf}

\begin{document}

    \begin{frame}
        Now you get this
        \begin{equation*}
            \sin x = \log x = \lim x
        \end{equation*}
    \end{frame}
    
\end{document}

enter image description here

2
  • Cool. Which bit of your code achieved this? Was it the mathrm=sym keyword?
    – innisfree
    Sep 19 at 7:03
  • yes. This means that \mathrm should be replaced by \symrm which takes the letters/symbols from the math font.
    – user187802
    Sep 19 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .