7

In beamer, I'd like to display all the labels in a description environment at once, then fill in the descriptions sequentially. I want the labels to be positioned correctly on the first slide, with enough room for the descriptions, so that the labels don't jump around as the descriptions are displayed.

The code

\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{description}
  \item<1->[Label1] Description1
  \item<2->[Label2] Description2
\end{description}
\end{frame}
\end{document}

displays Label1 and Description1 on the first slide and Label2 and Description2 on the second slide, which is not what I want. I want Label1, Description1, and Label2 on the first slide, and, in addition, Description2 on the second slide.

I tried

\documentclass{beamer}
\begin{document}
\begin{frame}
\def\reveal<#1>#2{\alt<#1>{#2}{\phantom{#2}}}
\begin{description}
  \item[Label1] \reveal<1->{Description1}
  \item[Label2] \reveal<2->{Description2}
\end{description}
\end{frame}
\end{document}

but that puts extra vertical space between the items. (Is that a bug in beamer, or do I misunderstand \phantom?)

My current solution is

\documentclass{beamer}
\begin{document}
\begin{frame}
\def\reveal<#1>#2{\alt<#1>{#2}{\color{white}{#2}}}
\begin{description}
  \item[Label1] \reveal<1->{Description1}
  \item[Label2] \reveal<2->{Description2}
\end{description}
\end{frame}
\end{document}

although that works for me only because the background color of my slides is white and does not work if #2 contains a paragraph break. Is there a better solution?

  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Adam Liter Jan 16 '14 at 3:30
  • OK---I've edited my post. – Martin J. Osborne Jan 16 '14 at 3:54
6

It seems that the description environment will only typeset the label under certain conditions (see comments) so I've used \mbox{} to convince it to do typeset the label without actually typesetting description text itself:

\documentclass{beamer}
\newcommand<>{\reveal}[1]{\mbox{}\visible#2{#1}}

\begin{document}
\begin{frame}
    \begin{description}
        \item[Label1] Description of the first item. Shown on all slides.
        \item[Label2] \reveal<2->{Description of the second item. This is not shown on the first slide although it occupies space.}
        \item[Label3] \reveal<3->{Description of the third item. This is only shown on the third slide although it occupies space on the first two.}
    \end{description}
\end{frame}

\end{document}

First slide

Second slide

Third slide

\visible typesets the text invisibly on other slides. So it takes up space, ensuring that the labels are in the right places. But it will work no matter what colour your background. (It may be using the background colour to fake transparency but that's all automatic.)

  • "the description environment will only typeset the label if it thinks something is there": that's not literally true, is it? When I typeset \begin{description}\item[Label]\end{description} I see the label. The code \begin{description}\item[Label]\visible<2>{x}\end{description} does not show Label on the first slide, although \begin{description}\item[Label]\visible<2>{}\end{description} curiously does. (The same is true for \uncover rather than \visible.) That seems a bit odd. – Martin J. Osborne Jan 16 '14 at 17:51
  • @MartinJ.Osborne You mean it shows the label even on the first slide if you use that? When I tried, the label only showed on the second slide in that case. – cfr Jan 16 '14 at 19:36
  • Yes, \begin{description}\item[Label]\end{description} shows the label, and \begin{description}\item[Label]\visible<2>{}\end{description} shows it on both slides. \begin{description}\item[Label]\visible<2>{x}\end{description} shows it only on the second slide. – Martin J. Osborne Jan 16 '14 at 19:55
  • @MartinJ.Osborne How odd. (I can't think of anything even vaguely intelligent to say.) I've edited the answer to be... er... vaguer. – cfr Jan 16 '14 at 21:50

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.