3

I'm trying to change the math font in a beamer (with metropolis user theme) document. I'm using XeLatex. I've managed to change the text font using fontenc but this style does not apply to math equation. Thank you.

\documentclass[11pt]{beamer}
\usepackage[italian]{babel}
\usepackage{ragged2e}
\usepackage{etoolbox}
\apptocmd{\frame}{}{\justifying}{} % Allow optional arguments after frame.

\usetheme[progressbar=frametitle]{metropolis}
\usepackage{appendixnumberbeamer}
\usepackage[T1]{fontenc}
    \setmainfont{CMU Serif}


  
\usepackage{booktabs}
\usepackage[scale=2]{ccicons}

\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}

\usepackage{xspace}
\newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}


\title{\textbf{Title}}
\date{24 Giugno 2018}
\author{Me}

\begin{document}

\maketitle

\begin{frame}{Indice}
  \setbeamertemplate{section in toc}[sections numbered]
  \tableofcontents%[hideallsubsections]
\end{frame}

\section[Introduction]{Introduction}

\begin{frame}[fragile]{Concetti generali della rinormalizzazione (I)}
Equation number 1
\begin{equation}
    F(x) = g_0 + g_0^2F_1(x) + g_0^3F_2(x) + \dots .
\end{equation}
Second equation for F1
\begin{equation}
    F_1(x) = \alpha \int_0^\infty dt \frac{1}{x+t},
\end{equation}
\end{frame}
\end{document}

I want to change the math font to the default LaTeX font.

2 Answers 2

1

Just load unicode-math and set the font theme to serif.

\documentclass[11pt]{beamer}
\usepackage[italian]{babel}

% you don't want to have long paragraphs
% so why justify?
%\usepackage{ragged2e}
%\usepackage{etoolbox}
%\apptocmd{\frame}{}{\justifying}{} % Allow optional arguments after frame.

\usetheme[progressbar=frametitle]{metropolis}
\usefonttheme{serif}
\usepackage{appendixnumberbeamer}
\usepackage{unicode-math}
\usepackage{booktabs}
\usepackage[scale=2]{ccicons}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}

\usepackage{xspace}

\setmainfont{CMU Serif}

\newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}


\title{\textbf{Title}}
\date{24 Giugno 2018}
\author{Me}

\begin{document}

\maketitle

\begin{frame}{Indice}
  \setbeamertemplate{section in toc}[sections numbered]
  \tableofcontents%[hideallsubsections]
\end{frame}

\section[Introduction]{Introduction}

\begin{frame}[fragile]{Concetti generali della rinormalizzazione (I)}
Equation number 1 with \themename and CMU Serif
\begin{equation}
    F(x) = g_0 + g_0^2F_1(x) + g_0^3F_2(x) + \dots .
\end{equation}
Second equation for F1
\begin{equation}
    F_1(x) = \alpha \int_0^\infty dt \, \frac{1}{x+t},
\end{equation}
\end{frame}
\end{document}

enter image description here

1

The easiest way to use computer modern font with the metropolis theme is to simply not compile with xelatex/lualatex. If you compile with pdflatex, the theme will automatically use the default computer modern font. You could also switch to the moloch theme, a more modern fork of the metropolis theme, which does not mess with the fonts.

If you then want to switch from sans serif to serif, you can do this by loading the serif font theme:

\documentclass[11pt]{beamer}
\usepackage[italian]{babel}
\usepackage{ragged2e}
\usepackage{etoolbox}
\apptocmd{\frame}{}{\justifying}{} % Allow optional arguments after frame.

\usetheme[progressbar=frametitle]{moloch}% modern fork of the metropolis theme
\usepackage{appendixnumberbeamer}
\usepackage[T1]{fontenc}
\usefonttheme{serif}
%    \setmainfont{CMU Serif}


  
\usepackage{booktabs}
\usepackage[scale=2]{ccicons}

\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}

\usepackage{xspace}
\newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}


\title{\textbf{Title}}
\date{24 Giugno 2018}
\author{Me}

\begin{document}

\begin{frame}[fragile]{Concetti generali della rinormalizzazione (I)}
Equation number 1
\begin{equation}
    F(x) = g_0 + g_0^2F_1(x) + g_0^3F_2(x) + \dots .
\end{equation}
Second equation for F1
\begin{equation}
    F_1(x) = \alpha \int_0^\infty dt \frac{1}{x+t},
\end{equation}
\end{frame}
\end{document}

enter image description here

If you insist on using xelatex, you could use the unicode-math theme to change the math font. In the following example, I'm using Libertinus Math. Change this to whatever math font would like to use. Please note that you should not use the fontenc package with xelatex. You probably meant to use the fontspec package, which is automatically loaded by the metropolis theme if you compile with xelatex.

% !TeX TS-program = xelatex
\documentclass[11pt]{beamer}
\usepackage[italian]{babel}
\usepackage{ragged2e}
\usepackage{etoolbox}
\apptocmd{\frame}{}{\justifying}{} % Allow optional arguments after frame.

\usetheme[progressbar=frametitle]{metropolis}
\usepackage{appendixnumberbeamer}

\usefonttheme{professionalfonts}
\setsansfont{CMU Serif}
\usepackage{unicode-math}
\setmathfont{Libertinus Math}


  
\usepackage{booktabs}
\usepackage[scale=2]{ccicons}

\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}

\usepackage{xspace}
\newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}


\title{\textbf{Title}}
\date{24 Giugno 2018}
\author{Me}

\begin{document}


\begin{frame}[fragile]{Concetti generali della rinormalizzazione (I)}
Equation number 1
\begin{equation}
    F(x) = g_0 + g_0^2F_1(x) + g_0^3F_2(x) + \dots .
\end{equation}
Second equation for F1
\begin{equation}
    F_1(x) = \alpha \int_0^\infty dt \frac{1}{x+t},
\end{equation}
\end{frame}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .