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.
Thanks in advance!
Best Answer
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 onmathpazo
, but with many more symbols. There is, additionally, an experimental Fira Math font for use withunicode-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.
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. Themetropolis
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 successornewpxmath
, or the sans-serif modificationnewtxsf
, load the math package and usemathastext
.With XeLaTeX, you have the option to load
mathspec
and\setmathsfont{Fira Sans}
or\setmathsfont{FiraGO}
.Or see @samcarter’s excellent answer.
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: