Newer
Older
LaTeX / lectures / otagonotes.cls
\def\filedate{23 February 2021}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Document class for lecture slide notes.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Version History
% v1.0   Initial version, rebuilt from deprecated lecturenotes class.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}[2001/06/01]
\ProvidesClass{lecturenotes}%
         [2021/02/23 INFO lecture notes style, v1.0]


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


% 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\ Speaker Notes},%
		pdfsubject={\ShortClassTitle},%
		colorlinks=false%
	}%
}


% Set up notes 6-up page layout using pgfpages.
% This only looks good in portrait, but then it's not intended for
% any other layout anyway...
\pgfpagesdeclarelayout{notes 6up}{%
    \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
    \edef\pgfpageoptionwidth{\the\paperheight}%
    \def\pgfpageoptionborder{0pt}%
}{%
    \pgfpagesphysicalpageoptions{%
        logical pages=6,%
        physical height=\pgfpageoptionheight,%
        physical width=\pgfpageoptionwidth,%
    }%
    \pgfpageslogicalpageoptions{1}
    {%
        border shrink=\pgfpageoptionborder,%
        resized width=.5\pgfphysicalwidth,%
        resized height=.25\pgfphysicalheight,%
        center=\pgfpoint{.26\pgfphysicalwidth}{.76\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{2}
    {%
        border shrink=\pgfpageoptionborder,%
        resized width=.5\pgfphysicalwidth,%
        resized height=.25\pgfphysicalheight,%
        center=\pgfpoint{.74\pgfphysicalwidth}{.76\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{3}
    {%
        border shrink=\pgfpageoptionborder,%
        resized width=.5\pgfphysicalwidth,%
        resized height=.25\pgfphysicalheight,%
        center=\pgfpoint{.26\pgfphysicalwidth}{.5\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{4}
    {%
        border shrink=\pgfpageoptionborder,%
        resized width=.5\pgfphysicalwidth,%
        resized height=.25\pgfphysicalheight,%
        center=\pgfpoint{.74\pgfphysicalwidth}{.5\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{5}
    {%
        border shrink=\pgfpageoptionborder,%
        resized width=.5\pgfphysicalwidth,%
        resized height=.25\pgfphysicalheight,%
        center=\pgfpoint{.26\pgfphysicalwidth}{.24\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{6}
    {%
        border shrink=\pgfpageoptionborder,%
        resized width=.5\pgfphysicalwidth,%
        resized height=.25\pgfphysicalheight,%
        center=\pgfpoint{.74\pgfphysicalwidth}{.24\pgfphysicalheight}%
    }%
}

\pgfpagesuselayout{notes 6up}[a4paper]


% 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}
% Determined empirically for A4 paper.
\setlength{\headerwidth}{0.85\pgfphysicalwidth+1mm}
\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.53\pgfphysicalheight}
\SetBgHshift{0.134\pgfphysicalwidth}
\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{2\headerwidth/3}@{}R{\headerwidth/3}@{}}%
                \multicolumn{2}{@{}C{\headerwidth}@{}}{\Huge\PaperCode, \TeachingPeriod\ \YearOffered} \\[0.8\pgfphysicalheight]%
                % A skip of 0.8\pgfphysicalheight looks about right.
                \ClassType\ \thechapter: \ShortClassTitle\ --- Notes & \the\numexpr\thepage/7+1 \\%
            \end{tabular*}%
        }%
    \fi%
    \bg@material%
}
\makeatother


\endinput