Newer
Older
LaTeX / lectures / otagohandout.cls
\def\filedate{24 March 2021}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Document class for lecture handout document.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Version History
% v1.0   Initial version, rebuilt from deprecated lecturehandout class.
% v1.0.1 Tweaked header so it always fits.
% v1.0.2 Corrected page number generation.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}[2001/06/01]
\ProvidesClass{otagohandout}%
         [2021/03/24 INFO lecture handout document style, v.1.0.2]


\DeclareOption*{\PassOptionsToClass{\CurrentOption}{otagoslides}}
\ProcessOptions
\LoadClass{otagoslides}


% Load required packages.
\RequirePackage{array}
\RequirePackage{background}
\RequirePackage{pgfpages}


\if@chapters
    \SetClassType{Chapter}
\fi


% hyperref setup. We have to use a slightly convoluted method, because the
% macros referenced here haven't been set yet. Define the hyperref setup
% as a new macro, and call this AFTER initialising the paper and chapter
% variables.
\renewcommand{\inithyperref}{%
	\hypersetup{%
		pdftitle={\PaperCode\ \ClassType\ \thechapter\ Lecture Material},%
		pdfsubject={\ShortClassTitle},%
		colorlinks=false%
	}%
}


% Set up notes 6-up page layout using pgfpages.
% This only looks good in landscape, but then it's not intended for
% any other layout anyway...
%
% If there aren't enough frames to fill the final page, any missing ones
% will appear as empty boxes. Meh.
\pgfpagesdeclarelayout{handout 6up}{%
    \def\pgfpageoptionborder{0pt}%
}{%
    \pgfpagesphysicalpageoptions{%
        logical pages=6,%
        physical height=\pgfpageoptionheight,%
        physical width=\pgfpageoptionwidth,%
    }%
    \pgfpageslogicalpageoptions{1}
    {%
        border code=\pgfsetlinewidth{0.6pt}\pgfstroke,%
        border shrink=\pgfpageoptionborder,%
        resized width=.3\pgfphysicalwidth,%
        resized height=.5\pgfphysicalheight,%
        center=\pgfpoint{.183\pgfphysicalwidth}{.67\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{2}
    {%
        border code=\pgfsetlinewidth{0.6pt}\pgfstroke,%
        border shrink=\pgfpageoptionborder,%
        resized width=.3\pgfphysicalwidth,%
        resized height=.5\pgfphysicalheight,%
        center=\pgfpoint{.5\pgfphysicalwidth}{.67\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{3}
    {%
        border code=\pgfsetlinewidth{0.6pt}\pgfstroke,%
        border shrink=\pgfpageoptionborder,%
        resized width=.3\pgfphysicalwidth,%
        resized height=.5\pgfphysicalheight,%
        center=\pgfpoint{.817\pgfphysicalwidth}{.67\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{4}
    {%
        border code=\pgfsetlinewidth{0.6pt}\pgfstroke,%
        border shrink=\pgfpageoptionborder,%
        resized width=.3\pgfphysicalwidth,%
        resized height=.5\pgfphysicalheight,%
        center=\pgfpoint{.183\pgfphysicalwidth}{.33\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{5}
    {%
        border code=\pgfsetlinewidth{0.6pt}\pgfstroke,%
        border shrink=\pgfpageoptionborder,%
        resized width=.3\pgfphysicalwidth,%
        resized height=.5\pgfphysicalheight,%
        center=\pgfpoint{.5\pgfphysicalwidth}{.33\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{6}
    {%
        border code=\pgfsetlinewidth{0.6pt}\pgfstroke,%
        border shrink=\pgfpageoptionborder,%
        resized width=.3\pgfphysicalwidth,%
        resized height=.5\pgfphysicalheight,%
        center=\pgfpoint{.817\pgfphysicalwidth}{.33\pgfphysicalheight}%
    }%
}

\pgfpagesuselayout{handout 6up}[a4paper, landscape]


% Set transparent slide background colour.
\setbeamercolor{background canvas}{bg=}


% Set up "headers" and "footers". Because pgfpages converts the original
% pages to logical pages, we can't use normal techniques like fancyhdr,
% because that will get applied to the logical pages, not the physical
% ones. We therefore use a slightly bizarre hack with the background
% package and a tabular to dangle the "header" and "footer" off the
% first logical page.
% (Adapted from <https://tex.stackexchange.com/a/83270>.)
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\newlength{\headerwidth}
% Three slides @ 0.3\pgfphysicalwidth plus two 5mm gaps.
\setlength{\headerwidth}{0.9\pgfphysicalwidth+1cm}
\SetBgAngle{0}
% Scale factor looks about right, and seems logical.
\SetBgScale{1.414}
\SetBgColor{black}
\SetBgOpacity{1}
\SetBgPosition{current page.north}
% Offsets from current page.north determined empirically.
\SetBgVshift{-0.35\pgfphysicalheight}
\SetBgHshift{0.317\pgfphysicalwidth+1.5mm}
\SetBgContents{}
\makeatletter
\AddEverypageHook{%
    % Index off the first logical page, because it's the only one
    % we can guarantee to exist on any given page.
    \ifnum\pgf@currentshipout=1%
        \SetBgContents{%
            \sffamily\bfseries\large%
            \begin{tabular*}{\headerwidth}{@{}L{\headerwidth/3}@{}C{\headerwidth/3}@{}R{\headerwidth/3}@{}}%
                \multicolumn{3}{@{}C{\headerwidth}@{}}{\resizebox*{\headerwidth}{!}{\Huge\PaperCode, \PaperTitle, \TeachingPeriod\ \YearOffered}} \\[0.85\pgfphysicalheight]%
                % A skip of 0.85\pgfphysicalheight looks about right.
                \ClassType\ \thechapter: \ShortClassTitle & Lecture Slides & \the\numexpr(\thepage-1)/6+1 \\%
            \end{tabular*}%
        }%
    \fi%
    \bg@material%
}
\makeatother


\endinput