2

After reading section 12.4 Theorem Environments from beameruserguide I understand that all theorem like environments (theorem, lemma, corollary, ...) except example use same beamertemplate which means same block colors. Is it true?

If the answer is yes, is there any beamer (not using tcolorbox or mdframed theorems) way to customizing colors for each environment?

If the answer is no, could you show me an example?

Nex there's a little code to start with:

\documentclass{beamer}
\usetheme{Warsaw}

\begin{document}

\begin{frame}

\begin{theorem}[A]
Theorem body
\end{theorem}

\begin{example}[B]
Example body
\end{example}

\begin{proof}[C]
Proof body
\end{proof}

\begin{lemma}[D]
Lemma body
\end{lemma}

\end{frame}
\end{document}
1

To start the answer small: as you will have found in the docs, the actual environment inserted depends on the value of \inserttheoremblockenv. Unfortunately, the docs only do what the docs say:

if a theorem that has theorem style example is typeset, it will expand to exampleblock

and not what they might seem to suggest (i.e. something along the lines of "if the style is X, and environment Xblock exists, I'll use Xblock, otherwise block). The way this is done is simplistic (beamerbasetheorems.sty):

  \def\th@example{%
    \normalfont % body font
    \def\inserttheoremblockenv{exampleblock}
  }

\th@example is the macro that stores the look and layout of theorem style example. So for a different style, you can change the environment.

Defining an environment for the color combinations you want seems to be done best in a brute-force way by adapting the definition of, e.g. exampleblock (beamerbaselocalstructure.tex):

\newenvironment<>{exampleblock}[1]{%
    \begin{actionenv}#2%
      \def\insertblocktitle{#1}%
      \par%
      \mode<presentation>{%\usebeamerfont{block}%
        \setbeamercolor{local structure}{parent=example text}}%
      \usebeamertemplate{block example begin}}
    {\par%
      \usebeamertemplate{block example end}%
    \end{actionenv}}

On first thought, though, this won't help you with the pre-defined theorem names, so you might want to give the class optionnotheorems to disable the predefined theorem etc. and define them yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.