9

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
    Commented Jan 17, 2014 at 0:46

3 Answers 3

6

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
    Commented 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.
    Commented May 27, 2015 at 18:06
2

The beamer action alert@ does more than the macro \alert{...} (changing the colour of the bullet point etc.). If you'd like to replicate the behaviour of \alert{...} for your items, you could create a new action which changes the colour like this:

\documentclass{beamer}

\newenvironment{fooenv}{\alt{\color{alerted text.fg}}{\color{normal text.fg}}}{}

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

enter image description here

2
  • That's very neat. I didn't know you could do that.
    – cfr
    Commented Apr 9 at 16:41
  • @cfr beamer magic :) Commented Apr 9 at 16:47
1

Another solution is adding [<+-| alert@+>] after the \begin{itemize} sentence.

One example is this:

\documentclass{beamer}

\begin{document}

\section{Introduction}

\begin{frame}{Title}
    \begin{itemize}[<+-| alert@+>] % stepwise alerts
        \item Parent 1
        \item Parent 2
        \begin{itemize}
            \item Child 1
            \item Child 2
        \end{itemize}
        \item Parent 3
    \end{itemize}
\end{frame}

\end{document}

Edit: Alert in a nested list, each line is red stepwise, one line at a time

enter image description here

5
  • Welcome! Would you be able to include a complete example people can compile as-is?
    – cfr
    Commented Apr 6 at 3:46
  • 1
    You are right @cfr 👍, I'm editting it.
    – emichester
    Commented Apr 7 at 17:29
  • Thanks! I already upvoted this, even though I don't actually think it answers the question. I take it the nested list aspect is crucial and this doesn't solve that problem.
    – cfr
    Commented Apr 8 at 3:22
  • Hello, I editted the answer again, I think this actually behaves on the way of the description of the question.
    – emichester
    Commented Apr 9 at 11:51
  • You're quite right ;). But I take it the OP wanted every item on every slide and only the colour to change. I'm not sure the question strictly says that, but that's what I took from the example. However, other people may well be happy with this solution (or even prefer it).
    – cfr
    Commented Apr 9 at 16:40

You must log in to answer this question.

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