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've been trying to obtain some stylized handouts using beamer with handoutWithNotes by Guido. What I have now is the 4 framed handouts purely but I'd like to put the page number on the bottom of the handout page and kind of a header on the top.

Here's some minimal example:

\documentclass[12pt,xcolor=pdftex,dvipsnames,handout]{beamer}
\usetheme{Darmstadt}  

\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[portuges,brazil]{babel}
\newcommand{\Autor}{Arthur Alvim}
\newcounter{countpag}
\setcounter{countpag}{0}
\title{Title}
\author{Author}
\date{\today}
%%%% Handouts
\usepackage{pgfpages}
% \usepackage{handoutWithNotes}
\include{style4x}
\pgfpagesuselayout{4 on 1 with notes}[a4paper,border shrink=5mm]

\begin{document}
\begin{frame}[plain]
  \titlepage
\end{frame}

\section{First section}
\subsection{First subsection}
\begin{frame}{First frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\begin{frame}{Second frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\subsection{Second subsection}
\begin{frame}{Third frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\begin{frame}{Fourth frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\section{Second section}
\subsection{First subsection}
\begin{frame}{First frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\begin{frame}{Second frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\subsection{Second subsection}
\begin{frame}{Third frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\begin{frame}{Fourth frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\end{document}

This \include{style4x} is part of the code inside the package handoutWithNotes that I've extracted. Here it goes:

   \pgfpagesdeclarelayout{4 on 1 with notes}{
       \edef\pgfpageoptionheight{\the\paperheight}
       \edef\pgfpageoptionwidth{\the\paperwidth}
       \edef\pgfpageoptionborder{0pt}
   }
   {
   \pgfpagesphysicalpageoptions{%
       logical pages=8,%
       physical height=\pgfpageoptionheight,%
       physical width=\pgfpageoptionwidth,%
       %last logical shipout=3%
       last logical shipout=4%
   }
   \pgfpageslogicalpageoptions{1}{%
       scale=.70,
       center=\pgfpoint{.25\pgfphysicalwidth}{.875\pgfphysicalheight}%
   }%
   \pgfpageslogicalpageoptions{2}{%
       scale=.70,
       center=\pgfpoint{.25\pgfphysicalwidth}{.625\pgfphysicalheight}%
   }%
   \pgfpageslogicalpageoptions{3}{%
       scale=.70,
       center=\pgfpoint{.25\pgfphysicalwidth}{.375\pgfphysicalheight}%
   }%
   \pgfpageslogicalpageoptions{4}{%
       scale=.70,
       center=\pgfpoint{.25\pgfphysicalwidth}{.125\pgfphysicalheight}%
   }%
   \pgfpageslogicalpageoptions{5}{%
       border shrink=\pgfpageoptionborder,%
       resized width=.5\pgfphysicalwidth,%
       resized height=.3333\pgfphysicalheight,%
       center=\pgfpoint{.75\pgfphysicalwidth}{.875\pgfphysicalheight},%
       copy from=5
   }%
   \pgfpageslogicalpageoptions{6}{%
       border shrink=\pgfpageoptionborder,%
       resized width=.5\pgfphysicalwidth,%
       resized height=.3333\pgfphysicalheight,%
       center=\pgfpoint{.75\pgfphysicalwidth}{.625\pgfphysicalheight},%
       copy from=6
   }%
   \pgfpageslogicalpageoptions{7}{%
       border shrink=\pgfpageoptionborder,%
       resized width=.5\pgfphysicalwidth,%
       resized height=.3333\pgfphysicalheight,%
       center=\pgfpoint{.75\pgfphysicalwidth}{.375\pgfphysicalheight},%
       copy from=7
   }%
   \pgfpageslogicalpageoptions{8}{%
       border shrink=\pgfpageoptionborder,%
       resized width=.5\pgfphysicalwidth,%
       resized height=.3333\pgfphysicalheight,%
       center=\pgfpoint{.75\pgfphysicalwidth}{.125\pgfphysicalheight},%
       copy from=8
   }%
   \AtBeginDocument{
       \newbox\notesbox
       \setbox\notesbox=\vbox{
           \hsize=\paperwidth
           \vskip-1in\hskip-1in\vbox{
               \color{black}{
                   \vskip1cm
                   Notes:\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth
               }
           }
       }
       \newbox\notesboxInitial
       \setbox\notesboxInitial=\vbox{
           \hsize=\paperwidth
           \vskip-1in\hskip-1in\vbox{
               \color{black}{
                   \vskip1cm
                   \centering{\Large{\textbf{\Autor => the rest do not appear \title - \author}}}
                   \vskip1cm
                   Notes:\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
               }
           }
       }
       \newbox\notesboxFinal
       \setbox\notesboxFinal=\vbox{
           \hsize=\paperwidth
           \vskip-1in\hskip-1in\vbox{
               \color{black}{
                   \vskip1cm
                   Notes:\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \thepage \hfill -> do not increment \stepcounter{countpag} Page\arabic{countpag} 
               }
           }
       }
     \pgfpagesshipoutlogicalpage{5}\copy\notesboxInitial
     \pgfpagesshipoutlogicalpage{6}\copy\notesbox
     \pgfpagesshipoutlogicalpage{7}\copy\notesbox
     \pgfpagesshipoutlogicalpage{8}\copy\notesboxFinal
   }
}

I've tried all these variables -> (\thepage, \insertpagenumber, \insertframenumber, \insertpresentationendpage, and created countpag) but in some way they don't change. I think its a problem with the scope of the variables I'm using. So guys, what can we do to make these variables increment?

share|improve this question
add comment

1 Answer

Here's a "proof of concept". It would need polishing and adapting to the specific circumstances that you want. I'm posting it at the unpolished stage to see if anyone has any recommendations on how to improve it before spending the time on polishing - since if it is completely the wrong approach then that would be good to know beforehand!

It works by defining an "extra" page in the pgfpages layout. This is actually the same as how the "with notes" bit works. This page is put over the top of all the other pages (it would be just as easy to put it behind them, but my first attempt was in front as it involved fewer changes to my template code) and is blank apart from the headers and footers. What is a bit kludgey about this is the way that the headers and footers are constructed. It is possible to specify an "extra" page in this way by giving just a box, but then that box is discarded at each shipout so we need to construct it again. We can just copy it from one to another, but that is a literal copy and doesn't let us change it again (without deconstructing and reconstructing, but I'd rather not do that!). So we make it an empty box and use the fact that pgfpages lets us specify some code for a "border" for the page. This can be arbitrary pgf code, so we throw away the border and then stick in some nodes. I've guessed a bit at the dimensions, but that's one area for polishing.

This "literal copying" is, I think, the source of the problem in what you tried (if I read the question right). The boxes \notesboxInitial and so forth are set at the start of the document and do not change afterwards, even if you change the commands that appear in them. This is because they have already been processed by TeX and all commands expanded.

Getting the content right for these nodes (the header and footer) is also a bit complicated. What would be best would be to copy the header and footer somehow from the inner pages, but figuring out exactly what to copy might be complicated. Probably, one should hook in to commands like \section and save the argument for later insertion, or use things like the \insertframetitle or whatever you want. Again, this is for polishing later.

Here's the code:

\documentclass{article}

\pagestyle{empty}
\usepackage{lipsum}
\usepackage{pgf}
\usepackage{pgfpages}

\pgfpagesdeclarelayout{2 on 1 with header}
{
  \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
  \edef\pgfpageoptionwidth{\the\paperheight}
  \def\pgfpageoptionborder{0pt}
  \def\pgfpageoptionfirstshipout{1}
}
{
  \pgfpagesphysicalpageoptions
  {%
    logical pages=3,%
    last logical shipout=2,
    physical height=\pgfpageoptionheight,%
    physical width=\pgfpageoptionwidth,%
    current logical shipout=\pgfpageoptionfirstshipout%
  }
  \ifdim\paperheight>\paperwidth\relax
    % put side-by-side
    \pgfpageslogicalpageoptions{1}
    {%
      border shrink=\pgfpageoptionborder,%
      resized width=.5\pgfphysicalwidth,%
      resized height=\pgfphysicalheight,%
      center=\pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{2}
    {%
      border shrink=\pgfpageoptionborder,%
      resized width=.5\pgfphysicalwidth,%
      resized height=\pgfphysicalheight,%
      center=\pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}%
    }%
  \else
    % stack on top of one another
    \pgfpageslogicalpageoptions{1}
    {%
      border shrink=\pgfpageoptionborder,%
      resized width=\pgfphysicalwidth,%
      resized height=.5\pgfphysicalheight,%
      center=\pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{2}
    {%
      border shrink=\pgfpageoptionborder,%
      resized width=\pgfphysicalwidth,%
      resized height=.5\pgfphysicalheight,%
      center=\pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight}%
    }%
  \fi
    \pgfpageslogicalpageoptions{3}
    {%
      resized width=\pgfphysicalheight,%
      resized height=\pgfphysicalwidth,%
      center=\pgfpoint{.5\pgfphysicalheight}{.5\pgfphysicalwidth},%
      border code={\setheaders},
      copy from=3,%
    }%
}
\pgfpagesuselayout{2 on 1 with header}

\newcounter{physpage}
\setcounter{physpage}{0}
\def\setheaders{%
\pgfusepath{discard}
\stepcounter{physpage}
\pgftransformshift{\pgfpoint{0pt}{\pgfphysicalheight - (1in + \voffset + \topmargin)}}
\pgfscope
\pgftransformshift{\pgfpoint{.7 * (1in + \hoffset + \oddsidemargin + \marginparsep)}{0pt}}
\pgfnode{rectangle}{north west}{Section}{}{}
\endpgfscope
\pgfscope
\pgftransformshift{\pgfpoint{.5\pgfphysicalwidth}{.7*(-\headheight -\headsep -\textheight - \footskip)}}
\pgfnode{rectangle}{south}{Page \thephyspage}{}{}
\endpgfscope
}
\pgfpagesshipoutlogicalpage{3}\vbox{}%


\begin{document}
\section {Introduction}
\lipsum
\section {Main Part}
\lipsum
\section {Conclusion}
\lipsum
\end{document}

and here's what the second page looks like, to show that the page number is correct!

pgfpages with background page

share|improve this answer
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.