# Alert items in a block that is overlayed

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}
\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?

## With 3 slides

\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Test}
\begin{block}<+->{First}
block
\end{block}
\begin{block}<+->{Second}
\begin{itemize}
\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}
\item Bar
\end{itemize}
\end{block}
\end{frame}
\end{document}


## With 4 slides

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}
\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}
\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

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{ifthen}
\newcounter{index}
\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}%
}%
\enditemize%
}
\begin{document}
\begin{frame}
\frametitle{Test}
\begin{block}<1->{First}
block
\end{block}
\begin{block}<2->{Second}