5

Consider the following MWE:

\documentclass{beamer}
\begin{document}
  \begin{frame}
  \frametitle{Test}
  \begin{block}{First}
    block
  \end{block}
  \begin{block}{Second}
    \begin{itemize}
    \item Foo
    \item Bar
    \end{itemize}
  \end{block}
  \end{frame}
\end{document}

So far, so simple. Now, let us overlay the blocks:

\documentclass{beamer}
\begin{document}
  \begin{frame}
  \frametitle{Test}
  \begin{block}<1->{First}
    block
  \end{block}
  \begin{block}<2->{Second}
    \begin{itemize}
    \item Foo
    \item Bar
    \end{itemize}
  \end{block}
  \end{frame}
\end{document}

Still fine and simple. Now, what I want is to overlay the items in the second block and alert them.

 \documentclass{beamer}
 \begin{document}
 \begin{frame}
 \frametitle{Test}
   \begin{block}<1->{First}
     block
   \end{block}
   \begin{block}<2->{Second}
     \begin{itemize}
     \item\alert<+(1)> {Foo}
     \item\alert<+(1)> {Bar}
     \end{itemize}
   \end{block}
 \end{frame}
 \end{document}

Is the a way to shorten the overlaying specifications? I tried many variant of <+-| @alert+> but nothing worked. I could make the code from this answer to work, but it is still not flexible. So my question is: Is there a nicer and more flexible and generic way to achieve this kind of overlyaing?

2

With 3 slides

enter image description here

\documentclass{beamer}
\begin{document}
\begin{frame}
  \frametitle{Test}
  \begin{block}<+->{First}
    block
  \end{block}
  \begin{block}<+->{Second}
    \begin{itemize}
    \item<.-|alert@.> Foo
    \item<+-|alert@+> Bar
    \end{itemize}
  \end{block}
\end{frame}
\end{document}

A factorized version:

\documentclass{beamer}
\begin{document}
\begin{frame}
  \frametitle{Test}
  \begin{block}<+->{First}
    block
  \end{block}
  \begin{block}<+->{Second}
    \begin{itemize}[<+-|alert@+>]
    \item<.-|alert@.> Foo
    \item Bar
    \end{itemize}
  \end{block}
\end{frame}
\end{document}

With 4 slides

enter image description here

Version with a syntax similar as the first example:

\documentclass{beamer}
\begin{document}
\begin{frame}
  \frametitle{Test}
  \begin{block}<+->{First}
    block
  \end{block}
  \begin{block}<+->{Second}
    \begin{itemize}
    \item<+-|alert@+> Foo
    \item<+-|alert@+> Bar
    \end{itemize}
  \end{block}
\end{frame}
\end{document}

Version with a factorized syntax:

\documentclass{beamer}
\begin{document}
\begin{frame}
  \frametitle{Test}
  \begin{block}<+->{First}
    block
  \end{block}
  \begin{block}<+->{Second}
    \begin{itemize}[<+-|alert@+>]
    \item Foo
    \item Bar
    \end{itemize}
  \end{block}
\end{frame}
\end{document}
  • It seems like the second alternative can be compactified further: In the second block the overlaying specification of the items can be removed, and instead the itemize block should be: \begin{itemize}[<+-|alert@+>]. Is there something similar for the first case? – Dror Apr 8 '14 at 19:01
  • @Dror Thanks for your suggestion. I edited my answer. – Paul Gaborit Apr 8 '14 at 21:28
  • Is it correct that there's no way to factorize the first case? – Dror Apr 9 '14 at 4:33
  • @Dror In the first case, you can factorize <+-|alert@+> (useful if you have three or more items) but the first item still needs its special overlaying specification (<.-|alert@.>). – Paul Gaborit Apr 9 '14 at 5:51
3

Perhaps this is what you are looking for. I create a macro (not an environment!) called \makealerts{} to which you pass the groups that are to be successively highlighted with an alert.

EDITED to be forgiving of an extra space at the end of the \makealerts argument list (in this MWE, of the line feed that follows {Bar none}).

\documentclass{beamer}
\usepackage{readarray}
\usepackage{ifthen}
\newcounter{index}
\newcommand\makealerts[1]{\itemize\relax
  \getargsC{#1}%
  \ifthenelse{\equal{\csname arg\romannumeral\narg\endcsname}{}}%
    {\def\maxnarg{\numexpr\narg-1\relax}}{\def\maxnarg{\narg}}%
  \setcounter{index}{0}%
  \whiledo{\theindex<\maxnarg}{%
    \stepcounter{index}%
    \item\alert<+(1)> {\csname arg\romannumeral\theindex\endcsname}%
  }%
  \enditemize%
}
\begin{document}
 \begin{frame}
 \frametitle{Test}
   \begin{block}<1->{First}
     block
   \end{block}
   \begin{block}<2->{Second}
     \makealerts{%
       {Foo of many words}
       {Bar none}
     }
   \end{block}
 \end{frame}
\end{document}

enter image description here

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.