# How to use Fira font and mathpazo within the metropolis theme?

I am trying to use the Fira font within the metropolis presentation theme for the text and the mathpazo font for the math mode. How can I do this?

My MWE is as follows:

\documentclass{beamer}
\usetheme{metropolis} % Use metropolis theme
\usepackage{FiraSans}
\usefonttheme[onlymath]{serif}
\usepackage{mathpazo}
\usepackage{mathtools}
\begin{document}
\begin{frame}{First Frame}
Hello, world! Here some random math:
\begin{equation*}
s_{t}=\begin{cases}
\bar{s}, & t\in \left\lbrace 0,\dots, T-1\right\rbrace  \\
\tilde{s}, & t\geq T
\end{cases}
\end{equation*}
\end{frame}
\end{document}


This results in:

The math stuff does not have the shape of the usual mathpazo font.

• What engine are you using when compiling the document? You should be using PDFLaTeX! – AboAmmar Dec 31 '18 at 15:54
• I compiled with XeLaTeX because it was suggested by metropolis. However, it works with pdfLaTeX! Thanks! – Hazards Dec 31 '18 at 16:30
• The problem is \usefonttheme[onlymath]{serif}. I'm not exactly sure why it's conflicting, but using \usefonttheme{professionalfonts} will give you basically the same output with pdfLaTeX or XeLaTeX. The latter font theme has slightly different spacing, it seems. Former is more condensed and latter more expanded. – whatisit Dec 31 '18 at 17:07

## In the Modern Toolchain

I personally recommend you use unicode-math when you can, and legacy fonts when you have to. Not everyone agrees, so I present the alternatives.

With the package unicode-math, you can use any OpenType fonts of your choice, including Fira Sans and its successor FiraGO. Asana Math is a Unicode math font based on mathpazo, but with many more symbols. There is, additionally, an experimental Fira Math font for use with unicode-math, but as of 2019, it is a work in progress.

This example additionally sets all letters and numerals in math mode to Fira Sans. You could change this to FiraGO as well, if you wanted. It supports the mathematical Greek OpenType feature.

\documentclass[10pt]{beamer}

\useinnertheme{metropolis}
\useoutertheme{metropolis}
\usecolortheme{metropolis}
\usefonttheme{professionalfonts}
\usepackage{unicode-math}

\defaultfontfeatures{ Scale = MatchUppercase }
\setmainfont{FiraGO}[Scale = 1.0]
\setsansfont{FiraGO}
\setmonofont{Fira Mono}
\setmathfont{Asana Math}
\setmathfont[range=up]{Fira Sans Regular}
\setmathfont[range=it]{Fira Sans Italic}
\setmathfont[range=bfup]{Fira Sans Bold}
\setmathfont[range=bfit]{Fira Sans Bold Italic}

\begin{document}

\begin{frame}{Math}
\begin{equation*}
\symup{e} = \lim_{n\to \infty} \left(1 + \frac{1}{n}\right)^n
\end{equation*}
\end{frame}

\end{document}


Note that you want to enable \usefonttheme{professionalfonts} for certain math features to work (such as the resized parentheses in this example). Therefore, I overrode all the fonts. The metropolis theme also allows you to select the color theme of your choice.

## Mixing OpenType with Legacy Math Fonts

If you want to use a legacy NFSS math package, such as mathpazo, or its successor newpxmath, or the sans-serif modification newtxsf, load the math package and use mathastext.

With XeLaTeX, you have the option to load mathspec and \setmathsfont{Fira Sans} or \setmathsfont{FiraGO}.

## Using only Legacy Fonts

You do not need to do this if you are using metropolis, but for completeness, you can also do this in PDFLaTeX:

\usepackage[T1]{fontenc}
\usepackage[sfdefault,scaled=.85]{FiraSans}
\usepackage{newtxsf}


As long as the metropolis theme is compiled with a suitable engine (e.g. xelatex) it uses fira fonts per default. So simply do not load any other packages or themes and you'll get fira font for text.

% !TeX TS-program = xelatex

\documentclass{beamer}
\usetheme{metropolis} % Use metropolis theme

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

\begin{document}
\begin{frame}{First Frame}
Hello, world! Here some random math:
\begin{equation*}
s_{t}=\begin{cases}
\bar{s}, & t\in \left\lbrace 0,\dots, T-1\right\rbrace  \\
\tilde{s}, & t\geq T
\end{cases}
\end{equation*}
\end{frame}
\end{document}


A version of the math font which plays nicer with xelatex:

% !TeX TS-program = xelatex

\documentclass{beamer}

\usetheme{metropolis}
\usefonttheme{professionalfonts}
\usepackage{unicode-math}
\setmathfont{TeX Gyre Pagella Math}

\begin{document}
\begin{frame}{First Frame}
Hello, world! Here some random math:
\begin{equation*}
s_{t}=\begin{cases}
\bar{s}, & t\in \left\lbrace 0,\dots, T-1\right\rbrace  \\
\tilde{s}, & t\geq T
\end{cases}
\end{equation*}
\end{frame}
\end{document}


• OP said "The math stuff does not have the shape of the usual mathpazo font." and the screenshots looked like Fira was used for non-math mode. I think OP was talking about wanting standard italics when s/he wrote "the shape of the usual mathpazo font". For some reason italics appear with \usefonttheme[onlymath]{serif} with pdfLaTeX but non-italics with XeLaTeX. – whatisit Jan 1 at 0:05
• @whatisit In the image of the OP the "math stuff" looked like the computer modern serif font, not mathpazo. \usefonttheme[onlymath]{serif} will result in math italic for both pdflatex and xelatex, just the font is different. – user36296 Jan 1 at 0:15
• When I compile this with pdfLaTeX, I get italics in math. When I compile it with XeLaTeX, I do not have italics in math (and get the same as in OP's screenshot). Maybe it should be italic in both...but in practice that is not what I am seeing. – whatisit Jan 1 at 0:18
• @whatisit The missing math italic is a consequence of the encoding. mathpazo would need T1 or OT1, but this would kind of invalid all the advantages of using xelatex. ... If math italic is a must, I suggest to use \usepackage{unicode-math} \setmathfont{TeX Gyre Pagella Math} instead of mathpazo – user36296 Jan 1 at 1:06
• @Davislor Thanks a lot for your comment, I added the professionalfonts theme. Happy new year! – user36296 Jan 1 at 12:56