Set math and text fonts independently in Beamer (using PDFLaTeX)

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 :

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

\usefonttheme[onlymath]{serif}


which yields (see MWE1 below)

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)

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}

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Aug 28, 2014 at 16:02

\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 ? Aug 29, 2014 at 9: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
– user2478
Aug 29, 2014 at 10:15
• But \usepackage{cmbright} does a lot more settings than just \renewcommand\sfdefault{cmbr}. How to keep these? Nov 26, 2018 at 10:40
– user2478
Nov 26, 2018 at 10:46
• run it with xelatex or lualatex
– user2478
Nov 26, 2018 at 11:25

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.