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}      
1
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.
    – jub0bs
    Aug 28, 2014 at 16:02

2 Answers 2

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}
6
  • 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, 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?
    – AlexG
    Nov 26, 2018 at 10:40
  • see edited answer
    – user2478
    Nov 26, 2018 at 10:46
  • 1
    run it with xelatex or lualatex
    – user2478
    Nov 26, 2018 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.