Search code examples
latexbeamer

Changing the font for alert in beamer for math mode


I would like to change the font of the alerted text in my beamer, I want it to be in bold, in both text and math mode. I tried using boldmath but it doesn't work :

\begin{frame}{Test}

\setbeamercovered{invisible}
\setbeamercolor{alerted text}{fg=vertf}

\setbeamerfont{alerted text}{family=\sffamily, series=\bfseries\boldmath}

$$\alert<2>{x} + \alert<3>{y} + \alert<4>{z}$$

\begin{itemize}
    \item <2-| alert@2>x 
    \item <3-| alert@3>y 
    \item <4-| alert@4>z
\end{itemize}

\end{frame}

Solution

  • You could work around the problem with something like this:

    \documentclass{beamer}
    
    \setbeamercovered{invisible}
    \setbeamercolor{alerted text}{fg=green}
    
    
    \setbeamerfont{alerted text}{series=\bfseries\boldmath}
    
    \renewcommand<>{\alert}[1]{%
      \ifmmode\text{%
        \begin{alertenv}#2\relax$#1$\end{alertenv}%
      }%
      \else%
        \begin{alertenv}#2\relax#1\end{alertenv}%
      \fi%
    }
    
    
    \begin{document}
        
    \begin{frame}
    \frametitle{Test}
    
    
    \[
    \alert<2>{x} + \alert<3>{y} + \alert<4>{z}
    \]
    
    \begin{itemize}
        \item <2-| alert@2>x 
        \item <3-| alert@3>y 
        \item <4-| alert@4>z
    \end{itemize}
    
    \end{frame}
    
    \end{document}