\def\filedate{21 July 2020}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Document class for lecture combined document.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Version History
% v1.0   Initial version
% v1.0.1 Changed package loading order to ensure that hyperref is last.
% v1.1   Added nochapters option.
% v1.2   Added support for configurable class types.
% v1.3   Replaced deprecated fancyhdr macros.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}[2001/06/01]
\ProvidesClass{lecturecombined}%
         [2020/07/21 INFO lecture combined document style, v.1.3]


% "Stream of conciousness" chapters vs. explicit individual classes. NOTE:
% you can't have both chapters and classes! This is because we use the same
% chapter macros for both cases, but they're applied differently (e.g., if
% nochapters is set, then \insertchapternumber represent the class number).
\newif\if@chapters \@chapterstrue
\DeclareOption{nochapters}{\@chaptersfalse}


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


% The article class doesn't have a chapter counter.
\newcounter{chapter}


% Load required packages.
\RequirePackage{pdfpages}
\RequirePackage[a4paper,landscape,pdftex]{geometry}
\RequirePackage{fancyhdr}
% DO NOT REMOVE THE NEXT LINE! The lecturesetup package loads a bunch
% of other packages, some of which are referenced below.
\RequirePackage{lecturecommon}


% Fix margins.
\geometry{vmargin=0.9in,hmargin=0.5in}

\raggedright


\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.
\newcommand{\inithyperref}{%
	\hypersetup{%
		pdftitle={\PaperCode\ \ClassType\ \thechapter\ Lecture Material},%
		pdfsubject={\ShortClassTitle},%
		colorlinks=false%
	}%
}


% Set up fancy headings.
\fancyhf{}
\fancyhead[C]{\Huge\sffamily\bfseries \PaperCode, \PaperTitle, \TeachingPeriod\ \YearOffered}

\fancyfoot[L]{\large\sffamily\bfseries \ClassType\ \thechapter: \ShortClassTitle}
\fancyfoot[R]{\large\sffamily\bfseries\thepage}

\renewcommand{\footrulewidth}{0mm}
\renewcommand{\headrulewidth}{0mm}

% Ensure first page footer is correctly positioned.
% (see https://tex.stackexchange.com/a/442558)
\setlength{\headheight}{30pt}

\pagestyle{fancy}


\endinput
