[Tex/LaTex] Custom beamer blocks for pros and cons

beamercolor

I want to be able to define custom block environments in Beamer.
That is, where for now I use alertblock and exampleblock I would rather use problock and conblock for a pro/con discussion.

This just seems more appropriate because a con is not an alert and a pro is not an example.

The code should then look something like this:

\begin{problock}{Pros}
\begin{itemize}
\item Good reason
\item Better reason
\end{itemize}
\end{problock}

\begin{conblock}{Contra}
\begin{itemize}
\item Small drawback
\item Big drawback
\end{itemize}
\end{conblock}

For each defined block environment I would then provide the proper formatting overrides in the preamble such as bg, fg and especially the structure color for bullets and such.

which would be the most beamer-like way to go?

Best Answer

Here's a simple example (emulating the definition of alertblock as it appears in beamerbaselocalstructure.sty) of the definition of a new block-like environment; using \setbeamercolor and \setbeamertemplate you can then customize the different elements of the new block (background and foreground color for title and body, aspect of the items in an itemize environment, etc.). You can procceed analogously for the definition of the conblock environment:

\documentclass{beamer}
\usetheme{Warsaw}

\newenvironment<>{problock}[1]{%
  \begin{actionenv}#2%
      \def\insertblocktitle{#1}%
      \par%
      \mode<presentation>{%
        \setbeamercolor{block title}{fg=white,bg=orange!20!black}
       \setbeamercolor{block body}{fg=black,bg=olive!50}
       \setbeamercolor{itemize item}{fg=orange!20!black}
       \setbeamertemplate{itemize item}[triangle]
     }%
      \usebeamertemplate{block begin}}
    {\par\usebeamertemplate{block end}\end{actionenv}}

\begin{document}

\begin{frame}
\begin{alertblock}{A regular alert block with regular itemize}
  \begin{itemize}
    \item First.
  \end{itemize}
\end{alertblock}
\begin{problock}{A customized pro block with customized itemize}
  \begin{itemize}
    \item First.
  \end{itemize}
\end{problock}
\end{frame}

\end{document}

enter image description here

Related Question