0

When writing slides using beamer, the commands \usefonttheme{professionalfonts} and \usefonttheme[onlymath]{serif} are useful.

In texdoc beamer, I quote:

onlymath is a short-cut for selecting all of the above options except for the first. Recall that, by default, mathematical formulas are also typeset using sans-serif letters. In most cases, this is visually the most pleasing and easily readable way of typesetting mathematical formulas if the surrounding text is typeset using sans serif. However, in mathematical texts the font used to render, say, a variable is sometimes used to differentiate between different meanings of this variable. In such case, it may be necessary to typeset mathematical text using serif letters. Also, if you have a lot of mathematical text, the audience may be quicker to “parse” it if it is typeset the way people usually read mathematical text: in a serif font.

But they have different behaviors, especially evident when typesetting bold serif maths. Giving this MWE:

\documentclass{beamer}
\usepackage{bm}

% \usefonttheme{professionalfonts}
% \usefonttheme{serif}
% \usefonttheme[onlymath]{serif}

\title{Title}
\author{Author}
\institute{Institute}
\date{\today}

\begin{document}
\begin{frame}
\frametitle{title}
\[
1 + \bm{n} + 2 + n
\]
and\boldmath
\[
1 + n + 2 + n
\]\unboldmath

$1 + \bm{n} + 2 + n$ and \boldmath$1 + n + 2 + n$\unboldmath
\end{frame}
\end{document}

You can compile it using xelatex, with three commented lines uncommented. Note that I used bm package and \boldmath and \unboldmath commands.

With no lines uncommented: enter image description here

{professionalfonts}: enter image description here

{serif}: enter image description here

[onlymath]{serif}: enter image description here

Questions:

  1. What did \usefonttheme{professionalfonts} and \usefonttheme[onlymath]{serif} do exactly? How can I use them more properly?
  2. Should I use \boldmath and \unboldmath then? Is using bm package and \bm command always the best choice?
    I ask this because I want to define a command that changes both the font weight and font color, as (using xparse and xcolor)
    \NewDocumentCommand{\textboldcolor}{o m}{%
      \IfNoValueTF{#1}{%
        \ifmmode%
          {\bm{{#2}}}%
        \else%
          {\bfseries{}\boldmath{}#2\unboldmath{}}%
        \fi%
      }{%
        \ifmmode%
          \textcolor{#1}{\bm{{#2}}}%
        \else%
          \textcolor{#1}{\bfseries{}\boldmath{}#2\unboldmath{}}%
        \fi%
      }%
    }
    
    How can I achieve this with a better approach?
  3. Why are these examples selecting different fonts? When compiling {serif} and [onlymath]{serif}, the following warnings are output:
    LaTeX Font Warning: Font shape `TU/lmr/b/it' in size <10.95> not available
    (Font)              Font shape `TU/lmr/b/sl' tried instead on input line 26.
    
    
    LaTeX Font Warning: Font shape `TU/lmr/b/it' in size <8> not available
    (Font)              Font shape `TU/lmr/b/sl' tried instead on input line 26.
    
    
    LaTeX Font Warning: Font shape `TU/lmr/b/it' in size <6> not available
    (Font)              Font shape `TU/lmr/b/sl' tried instead on input line 26.
    
    Why is that happening? In {professionalfonts}, CMMIB10 is used, but in {serif}, LMRoman*** is used. Why?

Here I post some relevant TeX-SE Q/A. Here, here, and here.

1 Answer 1

2

To answer your first question:

Beamer normally uses a sans serif font. As there are not a lot of sans serif math fonts (and probably even less at the time beamer was written), beamer uses a trick to get its math to match the sans serif text: instead of using characters from a math font, it takes letters etc. from italic text font.

  • with \usefonttheme{professionalfonts} you switch these substitutions completely off. This is for example useful if you use a font package which comes with a dedicated math font.

  • with \usefonttheme[onlymath]{serif} you don't switch the replacement completely off, some characters will be substituted with ones from italic serif font

2
  • Does beamer really still take italic text letters for math? That was surely true up to some years ago but I thought beamer switched to sansmathfonts a couple of years ago.
    – campa
    Commented May 3, 2023 at 20:53
  • @campa you are so modern :) Commented May 3, 2023 at 21:07

You must log in to answer this question.

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