[Tex/LaTex] How to use Fira font and mathpazo within the metropolis theme

beamerbeamer-metropolisfontsmathpazo

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:

enter image description here

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 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}

Math Sample

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}.

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:

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