Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to make a sort of "trainer's guide" from a beamer presentation using pgfpage (cf. example below), but I have one problem: the handout does not work correctly for the last frame - and I don't know why.

As a workaround, I have to add an empty frame, but I find this not very clean.

Why does the code of \AtEveryBeginFrame seem to be not executed for the last frame?


\documentclass[a4paper,handout]{beamer}

\usepackage{pgfpages}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{xparse}


\makeatletter
\g@addto@macro\beamer@frameslide{\form@everybeginframe@hook    \beamer@checkframetitle}
\def\form@everybeginframe@hook{}
\long\def\AtEveryBeginFrame#1{\g@addto@macro\form@everybeginframe@hook{#1}}
\makeatother

\pgfpagesdeclarelayout{myHandout}{% before action
     }
{ % afteraction
    \setkeys{pgfpagesuselayoutoption}{landscape}
    \pgfpagesphysicalpageoptions{%
        logical pages=2,%
        physical height=29.7cm,%
        physical width=21cm,%
        first logical shipout=2,%
        last logical shipout=2%
    }
    \pgfpageslogicalpageoptions{2}{%
        resized width=.5\pgfphysicalwidth,
        resized height=.28\pgfphysicalheight,
        center=\pgfpoint{.37\pgfphysicalwidth}{.8\pgfphysicalheight},%
        border code=\pgfstroke
    }
    \pgfpageslogicalpageoptions{1}{%
        original width=\pgfphysicalwidth,
        original height=\pgfphysicalheight,
        resized width=\pgfphysicalwidth,
        resized height=\pgfphysicalheight,
        center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight},%
    }
}


\makeatletter

\def\tmp@frame{}

\long\def\@notes{}
\long\def\mynote#1{%
    \long\gdef\@notes{ #1 } %
    \long\xdef\tmp@frame{\insertframenumber}%
} 

\newsavebox{\tmpboxA} % page
\newsavebox{\tmpboxB} % infos
\newsavebox{\tmpboxC} % notes


\AtEveryBeginFrame{%
    \savebox{\tmpboxB}{%
        \parbox[t][7.5cm][t]{5cm}{%
            \Large%
            Frame: \dotfill \tmp@frame \par
            Duration: \dotfill \par
        }
    }
    \savebox{\tmpboxC}{ \parbox{15cm}{\@notes} }
    \savebox{\tmpboxA}[16cm][r]{%
        \parbox{16cm}{%
            \raggedleft
            \usebox{\tmpboxB}\par
            \usebox{\tmpboxC} \long\def\@notes{} 
        }
    }
    \pgfpagesshipoutlogicalpage{1}\copy\tmpboxA
}
\makeatother



\pgfpagesuselayout{myHandout}


\begin{document}

\section{Section 1}

\begin{frame}{Frame 1} 
    \begin{enumerate}
    \item<1-> enum 1
    \item<2-> enum 2
    \item<3-> enum 3
    \item<4-> enum 4
    \end{enumerate}

    \mynote{\lipsum[6]}
\end{frame}

\section{Section 2}

\begin{frame}{Frame 1} 
    \begin{enumerate}
    \item<1-> enum 1
    \item<2-> enum 2
    \item<3-> enum 3
    \item<4-> enum 4
    \end{enumerate}

    \mynote{\lipsum[5]}
\end{frame}

%\clearpage
%\begin{frame}
%\end{frame}

\end{document}
share|improve this question
    
Welcome to TeX.sx! I've marked your inline code and added a line break in your sample because one % hid a closing brace. –  Qrrbrbirlbel Sep 25 '12 at 19:29
    
Adding some random text to the argument of \AtBeginDocument shows that this command is being excuted. So there is something wrong in the code that it is calling. –  Andrew Swann Oct 7 '12 at 16:33
add comment

1 Answer 1

up vote 4 down vote accepted

There are some timing issues, that I only partially understand. But part of the problem is that at the beginning of the frame when you try to construct the surrounding notes, the material for this has not yet been defined. pgfpages is good enough to wait for this, I believe what you are seeing on page 1 is triggered by the code excuted at the beginning of frame 2. Anyway in the last instance the command doesn't get triggered. So one solution is to package that code in to a separate command and call it explicitly after the last frame. (Patching this into \endframe does not work, because `beamer' messes around with that command.)

\documentclass[a4paper,handout]{beamer}

\usepackage{pgfpages}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{lipsum}

\makeatletter
\g@addto@macro\beamer@frameslide{\form@everybeginframe@hook    \beamer@checkframetitle}
\def\form@everybeginframe@hook{}
\long\def\AtEveryBeginFrame#1{\g@addto@macro\form@everybeginframe@hook{#1}}
\makeatother

\pgfpagesdeclarelayout{myHandout}{% before action
     }
{ % afteraction
    \setkeys{pgfpagesuselayoutoption}{landscape}
    \pgfpagesphysicalpageoptions{%
        logical pages=2,%
        physical height=29.7cm,%
        physical width=21cm,%
        first logical shipout=2,%
        last logical shipout=2%
    }
    \pgfpageslogicalpageoptions{2}{%
        resized width=.5\pgfphysicalwidth,
        resized height=.28\pgfphysicalheight,
        center=\pgfpoint{.37\pgfphysicalwidth}{.8\pgfphysicalheight},%
        border code=\pgfstroke
    }
    \pgfpageslogicalpageoptions{1}{%
        original width=\pgfphysicalwidth,
        original height=\pgfphysicalheight,
        resized width=\pgfphysicalwidth,
        resized height=\pgfphysicalheight,
        center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight},%
    }
}

\makeatletter

\def\tmp@frame{}

\long\def\@notes{}
\long\def\mynote#1{%
    \long\gdef\@notes{ #1 } %
    \long\xdef\tmp@frame{\insertframenumber}%
} 

\newsavebox{\tmpboxA} % page
\newsavebox{\tmpboxB} % infos
\newsavebox{\tmpboxC} % notes

\def\layoutnotes{%
    \savebox{\tmpboxB}{%
        \parbox[t][7.5cm][t]{5cm}{%
            \Large%
            Frame: \dotfill \tmp@frame \par
            Duration: \dotfill \par
        }
    }
    \savebox{\tmpboxC}{ \parbox{15cm}{\@notes} }
    \savebox{\tmpboxA}[16cm][r]{%
        \parbox{16cm}{%
            \raggedleft
            \usebox{\tmpboxB}\par
            \usebox{\tmpboxC} \long\def\@notes{} 
        }
    }
    \pgfpagesshipoutlogicalpage{1}\copy\tmpboxA
}
\AtEveryBeginFrame{\layoutnotes}
\makeatother

\pgfpagesuselayout{myHandout}

\begin{document}

\section{Section 1}

\begin{frame}{Frame 1} 
    \begin{enumerate}
    \item<1-> enum 1
    \item<2-> enum 2
    \item<3-> enum 3
    \item<4-> enum 4
    \end{enumerate}

    \mynote{\lipsum[6]}
\end{frame}

\section{Section 2}

\begin{frame}{Frame 2} 
    \begin{enumerate}
    \item<1-> enum 1
    \item<2-> enum 2
    \item<3-> enum 3
    \item<4-> enum 4
    \end{enumerate}

    \mynote{\lipsum[5]}
\end{frame}

\layoutnotes

\end{document}

Sample output

share|improve this answer
    
I thank you for your solution. –  Lionel MANSUY Oct 10 '12 at 12:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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