[Tex/LaTex] How to Draw a Horizontal Rule on a Beamer Handout

beamerpgfpagesrules

I have a beamer handout with a 16-on-1 layout via \pgfpagesuselayout{16 on 1}.

I would like to draw a horizontal rule beneath each row of slides so that the viewer is more easily led to read left to right, not top to bottom first.

Possibly this is an argument to \pgfpagesuselayout?

I can draw a border around the entirety of a frame with:

\pgfpageslogicalpageoptions{1}{border code=\pgfusepath{stroke}}

but I really just want one long border along the bottom of the slides on rows 1, 2, and 3.

Here's a minimal working example for borders everywhere:

\documentclass[xcolor=dvipsnames, handout]{beamer}

\usepackage{pgfpages}
\beamertemplatenavigationsymbolsempty
\pgfpagesuselayout{16 on 1}[a0paper,border shrink=5mm, landscape]

\pgfpageslogicalpageoptions{1}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{2}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{3}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{4}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{5}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{6}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{7}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{8}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{9}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{10}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{11}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{12}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{13}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{14}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{15}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{16}{border code=\pgfusepath{stroke}}


\begin{document}

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


\end{document}

Best Answer

You could do this by some sneaky border code stuff which threw away the given path (which is a box around each subpage) and drew just the bottom line for the relevant pages but I don't think that would look all that great since the lines wouldn't join up and wouldn't be vertically centred (as the pages are slightly shrunken).

So here's an alternative which defines a "background" page which is put behind all the others and which takes up the whole page. On this we draw three horizontal lines. This is never written to by the pgfpages page collection mechanism and is copied from (physical) page to (physical) page. The only downside is that if you have a total of 17 slides then the second physical page (which has only one logical page) still has all three lines drawn on it.

Here's the code:

\documentclass[xcolor=dvipsnames, handout]{beamer}

\usepackage{pgfpages}
\usepackage{pgffor}
\beamertemplatenavigationsymbolsempty

\pgfpagesdeclarelayout{16 on 1 with background}
{
  \edef\pgfpageoptionheight{\the\paperheight} 
  \edef\pgfpageoptionwidth{\the\paperwidth}
  \edef\pgfpageoptionborder{0pt}
}
{
  \pgfpagesphysicalpageoptions
  {%
    logical pages=17,%
    physical height=\pgfpageoptionheight,%
    physical width=\pgfpageoptionwidth,%
    first logical shipout=2,%
  }
  \pgfpageslogicalpageoptions{1}
  {%
    resized width=\pgfphysicalwidth,%
    resized height=\pgfphysicalheight,%
    center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight},%
    border code={%
      \pgfusepath{discard}%
      \pgfpathmoveto{\pgfpoint{0pt}{.25\ht0}}%
      \pgfpathlineto{\pgfpoint{\wd0}{.25\ht0}}%
      \pgfpathmoveto{\pgfpoint{0pt}{.5\ht0}}%
      \pgfpathlineto{\pgfpoint{\wd0}{.5\ht0}}%
      \pgfpathmoveto{\pgfpoint{0pt}{.75\ht0}}%
      \pgfpathlineto{\pgfpoint{\wd0}{.75\ht0}}%
      \pgfusepath{stroke}%
    },%
    copy from=1,%
  }%
  \pgfpageslogicalpageoptions{2}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.125\pgfphysicalwidth}{.875\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{3}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.375\pgfphysicalwidth}{.875\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{4}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.625\pgfphysicalwidth}{.875\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{5}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.875\pgfphysicalwidth}{.875\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{6}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.125\pgfphysicalwidth}{.625\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{7}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.375\pgfphysicalwidth}{.625\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{8}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.625\pgfphysicalwidth}{.625\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{9}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.875\pgfphysicalwidth}{.625\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{10}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.125\pgfphysicalwidth}{.375\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{11}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.375\pgfphysicalwidth}{.375\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{12}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.625\pgfphysicalwidth}{.375\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{13}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.875\pgfphysicalwidth}{.375\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{14}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.125\pgfphysicalwidth}{.125\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{15}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.375\pgfphysicalwidth}{.125\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{16}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.625\pgfphysicalwidth}{.125\pgfphysicalheight}%
  }%
  \pgfpageslogicalpageoptions{17}
  {%
    border shrink=\pgfpageoptionborder,%
    resized width=.25\pgfphysicalwidth,%
    resized height=.25\pgfphysicalheight,%
    center=\pgfpoint{.875\pgfphysicalwidth}{.125\pgfphysicalheight}%
  }%
}

\pgfpagesuselayout{16 on 1 with background}[a0paper,border shrink=5mm, landscape]



\begin{document}

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

\foreach \k in {1,...,31} {
  \begin{frame}{Frame \k}
  This is frame \k
  \end{frame}
}

\end{document}

Result:

background page with pgfpages