Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 21 down vote accepted

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

share|improve this answer
    
this worked like a charm. I am using a custom sty file though so I placed the \newenvironment there which also works. –  black_puppydog Sep 18 '11 at 8:46
    
probably you also would like to adjust \setbeamercolor{enumerate item}{fg=orange!20!black} –  someonr Oct 21 '12 at 13:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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