# mathcal in beamer does not work

I have a symbol in my presentation(beamer) that should be \mathcal{P}, but it appears like the following: I want this:

could you help me with that? Thanks

This is the code:

\documentclass{beamer}
\mode<presentation> {
%\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs,dsfont}
\usepackage{color}
\usepackage{float}
\usepackage{mathtools}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{etoolbox}
\usepackage{ragged2e}
\usepackage{mathtools} % must go before semantic
%\usepackage{semantic}
\usepackage{cases}
\usepackage{stackengine}
\usepackage{graphicx}
\usepackage{flexisym}
\usepackage{ thmtools, amssymb}
\usepackage{commath}
\usepackage{mathrsfs,dsfont}
\usefonttheme[onlymath]{serif}  #I want the font be serif

\begin{document}
\begin{align}
\boldsymbol{\mathcal{P}}_{\mathrm{A}}\!= [\boldsymbol{P}_{\mathrm{m},1}, \boldsymbol{P}_{\mathrm{m},2},  \cdots, \boldsymbol{P}_{\mathrm{m},N} ]^\top
\end{align}
\end{document}

• Can you post MWE from \documentclass to \end{document} Jun 23 '21 at 19:03
• Thanks for the comments. I have edited the question. Jun 23 '21 at 19:16
• Still no \documentclass in your MWE. Jun 23 '21 at 19:49
• the  \documentclass{beamer}is at the top of that. I've just edited again Jun 23 '21 at 20:19
• @Meskaj: You're probably compiling this on Overleaf? Remove \usepackage{flexisym} and things will compile to the desired output. There are a number of unnecessary packages you're loading (also some twice).
– Werner
Jun 23 '21 at 20:40

Remove flexisym from your preamble. The following minimal example provides the desired output.

\documentclass{beamer}

\usepackage{amssymb}
\usepackage{mathtools}

\usefonttheme[onlymath]{serif} %I want the font be serif

\begin{document}

\begin{frame}

$\boldsymbol{\mathcal{P}}_{\mathrm{A}} = [ \boldsymbol{P}_{\mathrm{m},1}, \boldsymbol{P}_{\mathrm{m},2}, \dots, \boldsymbol{P}_{\mathrm{m},N} ]^\top$

\end{frame}

\end{document}


The culprit is package flexisym, which cause error:

\mathchardef\ordinarycolon\mathcode\:


and after forcing compilation gives wrong character.

Do you really need this package? Removing them gives desired result:

BTW, you need to clean-up your document preamble. In it you load soma packages, twice, also load packages which are already load by beamer (as graphicx, amsmath etc).

\documentclass{beamer}
\usefonttheme[onlymath]{serif}  %I want the font be serif

\mode<presentation> {
%\usepackage{amsfonts}
\usepackage{flexisym}
\usepackage{amssymb}
\usepackage{mathrsfs, dsfont}
\usepackage{etoolbox}
\usepackage{ragged2e}
\usepackage{semantic}
\usepackage{cases}
\usepackage{stackengine}
\usepackage{thmtools}
\usepackage{commath}
}

\begin{document}
\begin{frame}
$$\boldsymbol{\mathcal{P}}_{\mathrm{A}} = [\boldsymbol{P}_{\mathrm{m},1}, \boldsymbol{P}_{\mathrm{m},2}, \cdots, \boldsymbol{P}_{\mathrm{m},N} ]^\top$$
\end{frame}
\end{document}