Is there a compact way of referencing the last slide (build stage) in beamer's overlay specification? I'm looking for something similar to <.> (which references the current slide) or <+> (which generates a new slide at the current location).

To be more specific, consider the following MWE. It creates a list where each item appears on a new slide. And then, at the end, I want to highlight the text "B".

\documentclass{beamer}

\begin{document}

\begin{frame}
  \begin{itemize}[<+->]
    \item A
    \item \alert<4>{B}
    \item C
  \end{itemize}
\end{frame}

\end{document}

This does what I intend, but if I now add another item

    \item D

and still want the highlight to appear once the list is completed, then I have to manually change the number in <4>. This can be a bit cumbersome when the frame contains a lot of slides... it would be much more elegant if there way, say, a way to specify the slide by counting from the end as well, but I couldn't find anything of the sort in the manual. I could then simply append a \pause at the end of my code, and replace the second item with something like

    \item \alert<n1>{B}

where "n1" refers to "negative 1" to avoid confusion with "-1" (all slides until 1). Does something like that exist?

up vote 2 down vote accepted

This is actually a very tricky question -- highlighting something on the last slide of a frame is easy to do (you can calculate the total number of slides from frameendpage-framestartpage), but if I understand your question correctly, you don't want the highlight on the last slide of the frame, but on the one after it. This means an additional overlay has to be created and this changes the number of slides in this frame which would mean that in the next run the last slide is no longer the last slide .......

A way out from this dilemma is to create the additional overlay manually:

\documentclass{beamer}

\newcounter{foo}

\begin{document}

\begin{frame}
  \begin{itemize}[<+->]
    \item A
    \item 
        \setcounter{foo}{\insertframeendpage}
        \addtocounter{foo}{-\insertframestartpage}
        \addtocounter{foo}{1}
        \alert<\thefoo>{B}   
    \item C
    \item D 
  \end{itemize}
    \only<+>{}
\end{frame}

\end{document}

enter image description here

  • Awesome, thanks! – mimuller Dec 7 at 2:06
  • @mimuller You're welcome! – samcarter Dec 7 at 2:08

Something like this?

\documentclass{beamer}

\begin{document}

\begin{frame}
  \begin{itemize}[<+->]
    \item A
    \item \alert<4>{B}
    \item C 
    \item<\thebeamerpauses> D
  \end{itemize}
\end{frame}
\end{document}

enter image description here

Depending on the other things you are doing, \item<\value{beamerpauses}> D might be better.

  • What exactly does <\thebeamerpauses> change? It seems like the red color and D now just appear at the same time, wouldn't that be the same behavior as if I just insert `\item D' instead? – mimuller Dec 6 at 18:18
  • oooh... now I see. I can reference the total number of slides up to a point by <\thebeamerpauses>. So what I would have to do is somehow save the value that this counter has at the end of the slide, and then insert that value (+1) instead of the <4>. That would be elegant, but I don't know how to make that happen... – mimuller Dec 6 at 18:19
  • ... and by "at the end of the slide" I really mean "at the end of the frame", sorry. – mimuller Dec 6 at 23:18

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.