1

This answer shows how to modify theorem environments to avoid a linebreak after the theorem title (which is nice when vertical space is a precious commodity).

I would like to adapt that answer so that the theorem title's text---by which I mean the text "Theorem 1.1 (ABC)"---respects alert. Here is an example based on the answer in that thread:

\documentclass[envcountsect]{beamer}

\usetheme{CambridgeUS}
\usefonttheme{serif}

\usepackage{etoolbox}

\makeatletter
\setbeamertemplate{theorem begin}
{%
\begin{\inserttheoremblockenv}
  {}{\usebeamerfont*{block title}\usebeamercolor[fg]{block title}%
  \inserttheoremname
  \inserttheoremnumber
  \ifx \inserttheoremaddition \empty \else\ (\inserttheoremaddition)\fi
  \inserttheorempunctuation}
  \normalfont
  }
  \setbeamertemplate{theorem end}{\end{\inserttheoremblockenv}}
\makeatother

\begin{document}

\section{ABC}

\begin{frame}

\begin{alertenv}<+>
  \begin{theorem}[ABC]
    This is a theorem
  \end{theorem}
\end{alertenv}

  \begin{theorem}[DEF]
    This is a another theorem (not alerted).
  \end{theorem}

  Text.

  \begin{block}{Block title}
    A block with title.
  \end{block}

  Text.

  \begin{block}{}
    A block without title.
  \end{block}

\end{frame}

\end{document}

Note the code that uses the color "block title". Because of this, in alert mode, it still uses "block title". How can I use "block title alert" when the text should be alerted? That is, in the example file, I would like "Theorem 1.1 (ABC)" to be in the alerted color, and "Theorem 1.2 (DEF)" to be in the non-alerted color.

1 Answer 1

1

If you use the default blue colour for the theorem title, you could replace the block title color with local structure - a colour which does get changed by the alert environment:

\documentclass[envcountsect]{beamer}

\usetheme{CambridgeUS}
\usefonttheme{serif}

\usepackage{etoolbox}

\makeatletter
\setbeamertemplate{theorem begin}
{%
\begin{\inserttheoremblockenv}
  {}{\usebeamerfont*{block title}\usebeamercolor[fg]{local structure}%
  \inserttheoremname
  \inserttheoremnumber
  \ifx \inserttheoremaddition \empty \else\ (\inserttheoremaddition)\fi
  \inserttheorempunctuation}
  \normalfont
  }
  \setbeamertemplate{theorem end}{\end{\inserttheoremblockenv}}
\makeatother

\begin{document}

\section{ABC}

\begin{frame}

\begin{alertenv}<+>
  \begin{theorem}[ABC]
    This is a theorem
  \end{theorem}
\end{alertenv}

  \begin{theorem}[DEF]
    This is a another theorem (not alerted).
  \end{theorem}

  Text.

  \begin{block}{Block title}
    A block with title.
  \end{block}

  Text.

  \begin{block}{}
    A block without title.
  \end{block}

\end{frame}

\end{document}

If you are using special colours for the block title and/or structure, you could instead tell the alert environment to change the block title colour:

\documentclass[envcountsect]{beamer}

\usetheme{CambridgeUS}
\usefonttheme{serif}

\usepackage{etoolbox}

\makeatletter
\setbeamertemplate{theorem begin}
{%
\begin{\inserttheoremblockenv}
  {}{\usebeamerfont*{block title}\usebeamercolor[fg]{block title}%
  \inserttheoremname
  \inserttheoremnumber
  \ifx \inserttheoremaddition \empty \else\ (\inserttheoremaddition)\fi
  \inserttheorempunctuation}
  \normalfont
  }
  \setbeamertemplate{theorem end}{\end{\inserttheoremblockenv}}
  
\addtobeamertemplate{alerted text begin}{}{%
  \setbeamercolor{block title}{parent=alerted text}%
}  
\makeatother

\begin{document}

\section{ABC}

\begin{frame}

\begin{alertenv}<+>
  \begin{theorem}[ABC]
    This is a theorem
  \end{theorem}
\end{alertenv}

  \begin{theorem}[DEF]
    This is a another theorem (not alerted).
  \end{theorem}

  Text.

  \begin{block}{Block title}
    A block with title.
  \end{block}

  Text.

  \begin{block}{}
    A block without title.
  \end{block}

\end{frame}

\end{document}

enter image description here

2

You must log in to answer this question.

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