[Tex/LaTex] Beamer frame: adding something to the last slide

beameroverlays

How can one create a new environment eframe so that some element is added (the place can be hardcoded) on the last slide of the frame?

Suppose I have many frames with lots of \pauses:

\begin{frame}{Frame 1}
    one\pause two
\end{frame}

\begin{frame}{Frame 2}
    one\pause two\pause three
\end{frame}

Replacing frame by eframe I would like to end up with the following behaviour:

\begin{frame}{Frame 1{\onslide<3>{END}}}
    one\pause two
\end{frame}

\begin{frame}{Frame 2{\onslide<4>{END}}}
    one\pause two\pause three
\end{frame}

I don't want to hardcode this numbers 3 and 4 because if later I decide to add more pauses, I would have to change those numbers.

Best Answer

The eframe environment defined below works just like a normal frame but appends (END) on the last slide of that frame.

This solution rests on mainly two tricks:

  1. accessing the value of the beamerpauses counter (which, at a given point of a frame environment, contains the number of overlay specifications used so far in that frame) only at the very end of the environment, in order to get the total number of overlay specifications in that frame; and
  2. Joseph Wright's solution for programmatically changing the frame title mid frame.

You can easily redefined the eframe environment to suit your needs.

enter image description here

\documentclass{beamer}

\makeatletter
\newcommand*{\augmentframetitle}[1]
{%
    \expandafter\frametitle\expandafter%
    {\beamer@frametitle #1}%
}
\makeatother

\newenvironment{eframe}
{%
    \begin{frame}
}{%
    \augmentframetitle{\ \onslide<\value{beamerpauses}>{(END)}}         
    \end{frame}
}

\begin{document}
    \begin{eframe}
    \frametitle{My last topic}
        foo\\
        \pause
        bar
    \end{eframe}
\end{document}