[Tex/LaTex] Beamer handout: Problem when creating border around frames

beamer

I am trying to create handouts from a Beamer presentation. I want multiple frames to be on each sheet of printed paper, and I want the frames to have a border, say a border made with a thin line. To save ink, I do not want a shaded background.

I have two problems that need solved. First, how do I create a border for the frames in the handout? The portion of the code below marked Border creates a border, but it also creates a border for frames that do not exist. The portion of the code below marked Prints 8 on 1 allows me to put eight frames one each sheet of paper, but part of the top frames do not print (they're cut off). How can this be fixed without changing printer settings?

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

\usepackage{amsmath,amssymb,amsfonts,amsthm}
\usepackage{graphics}
\usepackage{color}
\usepackage{framed}
\usepackage{amsthm, array}
\usepackage{yhmath}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfpages} 
%
% Prints 8 on 1
\pgfpagesuselayout{8 on 1}[letterpaper,border shrink=1mm]
%
%
% Border
\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}}
%
%
\begin{document}

%Stuff goes here.

\end{document}

Best Answer

For handouts, you can either comment out all the theme modifications and stay with the default theme or you can specify what would different cases presentation,article, handout etc. be, using the \mode{} command. For the frame borders, one can use a TikZ rectangle drawn on the border of the special current page node. Here is a simple example:

\documentclass[10pt,handout,onlymath]{beamer}
\usepackage{tikz}
\usepackage{pgfpages} 
\usefonttheme{serif}
\setbeamertemplate{background canvas}{
    \tikz \draw (current page.north west) rectangle (current page.south east);
        }
\pgfpagesuselayout{8 on 1}[letterpaper,border shrink=5mm]
\begin{document}

\foreach \x in {1,...,8} {\begin{frame}{Title \x}The frame number \x\end{frame}}

\end{document}

enter image description here

Related Question