2

When I use the \Pr in math mode, it displays a different font rather than computer modern as below: enter image description here

My MWE (in XeLaTeX):

\documentclass[aspectratio=32, hyperref=unicode, dvipsnames]{beamer}

\usefonttheme{professionalfonts} \usefonttheme{serif} \usetheme{Boadilla} \usecolortheme{rose} \beamertemplatenavigationsymbolsempty

\usepackage{datetime} \usepackage{mathtools} \usepackage{amssymb} \let\mathbbalt\mathbb \usepackage{unicode-math} \let\mathbb\mathbbalt \usepackage{polyglossia} \setdefaultlanguage{english} \usepackage{fontspec} \setmainfont{Iwona}

\title{A title} \author{Some authors} \date{A date}

\begin{document}

\maketitle

\begin{frame} $p(s',r\mid s,a) = \Pr{S_{t+1} = s', R_{t+1} = r \mid S_t = s, A_t = a}$ \end{frame}

\end{document}

Is there a way to force \Pr to use Computer Modern font there?


Thank you for all of your suggestions and answers. I found some more points that I think should be shared for other people that face this problem:

  • I use Overleaf with TeXLive 2022 so the command \usepackage[no-math]{fontspec} got the option clash:
The package fontspec has already been loaded with options:
  []
There has now been an attempt to load it with options
  [no-math]
Adding the global options:
  ,no-math
to your \documentclass declaration may fix this.

put the no-math option to the preamble will fix this error:

\documentclass[aspectratio=32, hyperref=unicode, dvipsnames, no-math]{beamer}
  • One can use another solution: by adding the option mathrm=sym to unicode-math package, the problem goes away.
\usepackage[mathrm=sym]{unicode-math}

Edit 1: update the title for clarification. Edit 2: adding anther solution.

k2pctdn
  • 194
  • 1
    BTW you can remove all lines from \usepackage{datetime} to \setdefaultlanguage{english} and get the same output. I'd also suggest changing the title of the question to something similar to Beamer - serif font theme, wrong font for operators or similar. It more precisely describes the question. – daleif Jan 25 '23 at 09:08
  • Possible duplicate https://tex.stackexchange.com/questions/476516/operator-font-in-beamer-metropolis/478920#478920 – samcarter_is_at_topanswers.xyz Jan 25 '23 at 09:09
  • What is the command \Pr? – Sebastiano Jan 25 '23 at 09:09
  • 2
    \Pr is used to denote a probability – user94293 Jan 25 '23 at 09:25
  • @daleif: thank you, these are the packages that I load in a full document so I think I should include them in the question. I will rename the title for more clarification. – k2pctdn Jan 25 '23 at 09:30
  • 2
    It is called minimal example for a reason. Here the issue can be replicated with a smaller example. – daleif Jan 25 '23 at 09:36

2 Answers2

3

If you'd like to use the default computer modern font, I suggest to load fontspec with the no-math option so it lets the fonts used for math alone (and also not to load unicode-math, as you don't want to change the font used for math)

% !TeX TS-program = lualatex

\documentclass[aspectratio=32, xcolor=dvipsnames]{beamer}

\usefonttheme{serif} \usefonttheme{professionalfonts} \usetheme{Boadilla} \usecolortheme{rose} \beamertemplatenavigationsymbolsempty

%\usepackage{datetime} %\usepackage{mathtools} %\usepackage{amssymb} %\let\mathbbalt\mathbb \usepackage[no-math]{fontspec} %\usepackage{unicode-math} %\let\mathbb\mathbbalt \usepackage{polyglossia} \setdefaultlanguage{english}

\setmainfont{Iwona}

\title{A title} \author{Some authors} \date{A date}

\begin{document}

\maketitle

\begin{frame} $p(s',r\mid s,a) = \Pr{S_{t+1} = s', R_{t+1} = r \mid S_t = s, A_t = a}$ \end{frame}

\end{document}

enter image description here

0

Thank you for all of your suggestions and answers. I found some more points that I think should be shared for other people that face this problem:

  • I use Overleaf with TeXLive 2022 so the command \usepackage[no-math]{fontspec} got the option clash:
The package fontspec has already been loaded with options:
  []
There has now been an attempt to load it with options
  [no-math]
Adding the global options:
  ,no-math
to your \documentclass declaration may fix this.

put the no-math option to the preamble will fix this error:

\documentclass[aspectratio=32, hyperref=unicode, dvipsnames, no-math]{beamer}
  • One can use another solution: by adding the option mathrm=sym to unicode-math package, the problem goes away.
\usepackage[mathrm=sym]{unicode-math}
k2pctdn
  • 194