[Tex/LaTex] Beamer: how to convince “includeslide” to include the last slide of a frame

beamerpdftikz-pgf

I'm using \includeslide to create copies of my Beamer presentation slides in handouts, but have hit a small snag. By default, it appears to choose the first slide in a frame unless I specify the page number with an option or a suffix:

% assume 4 slides in the frame
\includeslide{mylabel}  % this shows the first slide
\includeslide{mylabel<4>} % this shows the fourth slide

Now, my presentation is very big, so I'm using a lot of new commands and environments to speed things up. Is there some way I can convince \includeslide to default to the last slide in a frame? e.g. is there a Beamer variable that contains the number of slides, or an option to pgfimage I can somehow hack into a new version of includeslide?

Best Answer

When I started doing presentations with beamer, I kept getting caught out by the fact that I'd forget exactly when the end of a frame was going to happen so I'd jump to the next frame before I intended as I wasn't sure that everything on the current frame had been displayed. (Now, of course, I print out the handout version and have it in front of me.) So I came up with a hack that modified the title when it was on the last frame to give me a visual clue that it was the last frame. This might be adaptable to what you want (though there may well be a better solution) as it uses a counter to keep track of the last frame number. It's not completely robust as it can get confused if a frame changes size radically between compilations (in which case, delete the aux file).

This was my "experiment" file to test the system. It also allows for one to define an "offset".

\documentclass[12pt,color=dvipsnames]{beamer}

\newcounter{last}
\newcounter{lastoffset}[framenumber]
\setcounter{last}{1}
\setcounter{lastoffset}{0}

\newcommand{\last}{%
\setcounter{last}{1}%
\addtocounter{last}{\insertframeendpage}%
\addtocounter{last}{-\insertframestartpage}%
\addtocounter{last}{\value{lastoffset}}%
}

\newcommand{\lastlabel}[1]{%
\last%
\label<\value{last}>{#1}%
}

\definecolor{last}{named}{purple}

\newcommand{\lastframetitle}[1]{%
\last%
\frametitle{\color<\value{last}| trans:0>{last}#1}
}

% Either: \reset redefines \last
% Or: just redefine the \lastframetitle and \lastlabel to the originals.

\newcommand{\reset}{%
\renewcommand{\last}{%
\setcounter{last}{1}%
}}

\begin{document}

\begin{frame}
\setcounter{lastoffset}{-1}
\lastframetitle{Example Frame}
\lastlabel{ex}

\arabic{lastoffset}

\hyperlink{ex}{\beamergotobutton{Last Slide}}

This is an example frame.
\pause

Wait here    
\pause

Paws for Thought

\onslide    
Visible all along?    
\end{frame}    

\begin{frame}
\lastframetitle{Second Frame}

\arabic{lastoffset}

This is the second frame.    
\pause

Another slide appears    
\pause

Yet more appear
\pause

Wait until the end    
\onslide

Should be here any time soon    
\pause

What's going on?    
\onslide

When do all these appear?    
\pause

Phew, that's all folks.
\end{frame}    

\end{document}