7

In beamer, I would like to use alert in a nested list so that each line is red (i.e., the default alert color) stepwise, one line at a time. This code produces the output I would like:

\documentclass[pdf]{beamer}
\begin{document}
\begin{frame}
\begin{itemize}
    \item\alert<+>{Parent 1}
    \item\alert<+>{Parent 2}
    \begin{itemize}
        \item\alert<+>{child 1}
        \item\alert<+>{child 2}
    \end{itemize}
    \item\alert<+>{Parent 3}
\end{itemize}
\end{frame}
\end{document}

However, the code above requires using \alert<+>{...} with every \item. I would like to generate this output using a specification for the entire list with the \begin{itemize}. Without the nested list, the following works:

\documentclass[pdf]{beamer}
\begin{document}
\begin{frame}
\begin{itemize}[<alert@+>]
    \item Parent 1
    \item Parent 2
    \begin{itemize}[<alert@+>]
        \item child 1
        \item child 2
    \end{itemize}
    \item Parent 3
\end{itemize}
\end{frame}
\end{document}

This makes 5 slides, as does my first example. The first slide is the same, with "Parent 1" in red. The second slide, however, has "Parent 2", as well as "child 1" and "child 2", all in red. This is the part I would like to behave differently. I would like the second slide to have only "Parent 2" in red, but not "child 1" or "child 2". Then slides 3, 4, and 5 would have "child 1", "child 2", and "Parent 3", respectively, in red, just as occurs in both examples.

I've looked through similar questions (e.g., this doesn't highlight all children, but still highlights the first child with the parent and requires manually specifying slide numbers which I'd like to avoid). I tried putting the [<alert@+>] with the inner \begin{itemize} as well as the outer \begin{itemize} and various combinations of . and , with the +, etc. It seems like there must be a way to get it to make each line red one at a time using a default alert specification with the \begin{itemize}, but nothing I've tried has worked. I would be ok with defining a new list environment (e.g., a "nestedStepwiseAlert" environment) but haven't had luck getting that to work either.

1
  • 2
    This has bugged me for ages!
    – cfr
    Jan 17, 2014 at 0:46

1 Answer 1

4

My solution involves defining a new command \alertitem to replace \item. This is not the ideal solution, as it requires adding { and } to enclose each item's content. But here it goes.

\newcommand\alertitem[1]{\alert<+>{\item {#1}}}

Code

\documentclass{beamer}
\begin{document}

\newcommand\alertitem[1]{\alert<+>{\item {#1}}}

\begin{frame}
\begin{itemize}
    \alertitem {Parent 1}
    \alertitem {Parent 2}
    \begin{itemize}
        \alertitem {child 1}
        \alertitem {child 2}
    \end{itemize}
    \alertitem {Parent 3}
\end{itemize}
\end{frame}
\end{document}

Output

enter image description here

2
  • Is it possible to modify the [<alert@+>] instead of using new command alertitem?
    – Say OL
    May 27, 2015 at 13:58
  • 1
    @OLSAY: The issue with <alert@+> is that both child 1 and child 2 will be highlighted when Parent 2 is highlighted. The reason is that when options are given at the "parent" level, all the "children" items will be affected as well, unless you specifically set it otherwise. I thought doing this will require more hassle than simply introducing a new command.
    – Herr K.
    May 27, 2015 at 18:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .