# beamer detecting last shipped out frame

Related to this wrongly repeated frame question, I use handoutWithNotes for the handout version of a beamer presentation. How can one know that there is no more frame to be displayed so one can suppress the corresponding Notes lines?

\documentclass[10pt,handout,onlymath]{beamer}

\usepackage{pgfpages}
\usepackage{pgffor}

\usepackage{handoutWithNotes}
\pgfpagesuselayout{3 on 1 with notes}[a4paper,border shrink=3mm]

\AtBeginSubsection[]
{
\frametitle{Detailed outline}
subsubsectionstyle=show/show/hide]
\end{frame}
}

\date{}

\let\newblock\relax
\begin{document}

\title{Handout}
\subtitle{Yellow pgfpages}

\begin{frame}
\titlepage
\end{frame}

\section{Intro}
\subsection{Sub 1}
\foreach \x in {1} {%
\begin{frame}{Title \x}
This is frame number \x
\end{frame}}

\subsection{Sub 2}
\foreach \x in {2,...,3} {%
\begin{frame}{Title \x}
This is frame number \x
\end{frame}}

\section{Main}
\subsection{Sub 3}
\foreach \x in {4,...,7} {%
\begin{frame}{Title \x}
This is frame number \x
\end{frame}}

\end{document}


Bad news: handoutWithNotes.sty uses pgfpages, which copies the note-part before typesets the beamer-part. That is to say. That is to say, those note-lines are put on pdf before pgfpages knows how many pages left.

Good news: you can do it manually. Put \pgfpagesshipoutlogicalpage{6}\vbox{} at the end. This will clean up the bottom-right logical page.

Even better: You can check whether the left hand side is empty before you empty it.

\ifvoid\csname pgfpages@box@2\endcsname\pgfpagesshipoutlogicalpage{5}\vbox{}\fi
\ifvoid\csname pgfpages@box@3\endcsname\pgfpagesshipoutlogicalpage{6}\vbox{}\fi


But I prefer to fill the rest of page using note-lines:

\ifvoid\csname pgfpages@box@2\endcsname\pgfpagesshipoutlogicalpage{2}\copy\notesbox\fi
\ifvoid\csname pgfpages@box@3\endcsname\pgfpagesshipoutlogicalpage{3}\copy\notesbox\fi

• Hi Symbol 1, I inserted the first two lines instead of %%% Output note-lines everywhere % \pgfpagesshipoutlogicalpage{5}\copy\notesbox % \pgfpagesshipoutlogicalpage{6}\copy\notesbox but the problem is these two lines empty indifferently both logical pages 5 and 6. It's as if the test was not working. – green diod Sep 24 '14 at 15:09