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.
Questions:
- What did
\usefonttheme{professionalfonts}
and\usefonttheme[onlymath]{serif}
do exactly? How can I use them more properly? - Should I use
\boldmath
and\unboldmath
then? Is usingbm
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 (usingxparse
andxcolor
)
How can I achieve this with a better approach?\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% }% }
- Why are these examples selecting different fonts? When compiling
{serif}
and[onlymath]{serif}
, the following warnings are output:
Why is that happening? InLaTeX 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.
{professionalfonts}
, CMMIB10 is used, but in{serif}
, LMRoman*** is used. Why?