9

I am working on a Beamer presentation, and I would like to use sans serif font (CMBright) for text, and a serif font (Computer Modern) for maths. Sans serif maths looks pretty ugly to me.

Beamer default settings are sans serif maths and text :

enter image description here

I found I can switch maths font to serif with the line

\usefonttheme[onlymath]{serif}

which yields (see MWE1 below)

enter image description here

Now maths look nice, but I would like to change the default text font to CMBright. I tried to naively combine those two lines (see MWE2)

\usefonttheme[onlymath]{serif}
\usepackage{cmbright}

but is gives me everything in CBMright (ie sans serif)

enter image description here

I seemed to find some people using LuaTeX or related systems, but I would like to find a solution using PDFLaTeX only.

More generally, is there a way to set the maths and text fonts independently using PDFLaTeX, ie to any font different than CM and CMBright ?


MWE1

\documentclass{beamer}  
\usefonttheme[onlymath]{serif}  
\begin{document}
\begin{frame}
Some text, $x^2 + y^2 = r^2$
\end{frame}
\end{document}

MWE2

\documentclass{beamer}  
\usepackage{cmbright}
\begin{document}
\begin{frame}
Some text, $x^2 + y^2 = r^2$
\end{frame}
\end{document}      
presenter
  • 435

2 Answers2

8
\documentclass{beamer}  
\usepackage[T1]{fontenc}
\usefonttheme[onlymath]{serif}
\renewcommand\sfdefault{cmbr}
\begin{document}
\begin{frame}
Some text, $x^2 + y^2 = r^2$
\end{frame}
\end{document}

or

\documentclass[professionalfonts]{beamer}  
\usepackage[T1]{fontenc}
\usepackage{cmbright}
\usefonttheme[onlymath]{serif}
\begin{document}
    \begin{frame}
    Some text, $x^2 + y^2 = r^2$
\end{frame}
\end{document}
  • Thank you ! How do we know one has to refer to CMBright as cmbr in this context ? Where can I find the abbreviation to use in case I want another font ? – presenter Aug 29 '14 at 09:48
  • Go into the directory of cmbright.sty. There you find files like t1cmbr.fd. This is the file definition file (.fd) of family cmbr in T1 font encoding –  Aug 29 '14 at 10:15
  • But \usepackage{cmbright} does a lot more settings than just \renewcommand\sfdefault{cmbr}. How to keep these? – AlexG Nov 26 '18 at 10:40
  • see edited answer –  Nov 26 '18 at 10:46
  • Unfortunately, \usefonttheme[onlymath]{serif} has no effect if cmbright is loaded as a package. (As shown by OP.) – AlexG Nov 26 '18 at 11:04
  • 1
    run it with xelatex or lualatex –  Nov 26 '18 at 11:25
5

It might be late for this answer but I found a workaround for your problem. Simply put sefif and professionalfont into the preamble like this:

\documentclass[serif,professionalfont]{beamer}

and then load your font package (in my case it is iwona)

\usepackage{iwona}

You do NOT need to use

\usefonttheme[onlymath]{serif}

I've tested on Overleaf with PDFLatex Compiler and TexLive2019. Hope others will find this useful.

Different Body text font and Math font

k2pctdn
  • 194