Newer
Older
LaTeX / lecturefig.cls
\def\filedate{21 July 2020}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Document class for lecture figures & examples.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Version History
% v1.1   Switched to using geometry instead of a4wide.
% v1.2   Fixed loading order of geometry and fancyhdr so that margins are correct.
%        Removed nohead from geometry initialisation to avoid wonky interaction
%        with fancyhdr.
% v1.3   Dropped use of Trebuchet font. Now just uses \sffamily.
% v1.4   Removed reliance on pdftex output driver (specify in documentclass
%        options).
%        Changed paragraph formatting.
% v1.5   Switched to common infrastructure for all lecture documents.
%        Added "UNDEFINED" default for the paper, chapter & title macros.
% v1.5.1 Changed package loading order to ensure that hyperref is last.
% v1.6   Added nochapters option.
% v1.7   Added support for configurable class types.
% v1.8   Replaced deprecated fancyhdr macros.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}[2001/06/01]
\ProvidesClass{lecturefig}%
         [2020/07/21 INFO lecture figures style, v.1.8]


% "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}{report}}
\ProcessOptions
\LoadClass{report}


% Load required packages.
\RequirePackage{geometry}
\RequirePackage{fancyhdr}
\RequirePackage[normalem]{ulem}
% DO NOT REMOVE THE NEXT LINE! The lecturecommon package loads a bunch
% of other packages and sets up various counters, etc., several of which
% are used below.
\RequirePackage{lecturecommon}


% Miscellaneous initialisation.
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}


% Figure numbers.
\newcounter{lfigure}[chapter]
\renewcommand{\thelfigure}{\arabic{chapter}--\arabic{lfigure}}


% Figure, table & example captions.
\newcommand{\@docaption}[1]%
{	\begin{center}
		\Large\bfseries\sffamily #1
	\end{center}
}

\newcommand{\newheading}[1]{\@docaption{#1}}

% Specialised sub-caption for citing the source of something.
\newcommand{\source}[1]{\sffamily\footnotesize SOURCE: #1}


% Figures.
\newcommand{\newfigure}[1]%
{	\refstepcounter{lfigure}
	\@docaption{Figure \thelfigure: #1}
}
\newcommand{\continuefigure}%
{	\hfill\emph{\small continues over\ldots}
	\newpage
	\@docaption{Figure \thelfigure, cont'd}
}


% Tables.
\newcommand{\newtable}[1]%
{	\refstepcounter{lfigure}
	\@docaption{Table \thelfigure: #1}
}
\newcommand{\continuetable}%
{	\hfill\emph{\small continues over\ldots}
	\newpage
	\@docaption{Table \thelfigure, cont'd}
}


% Example.
\newcommand{\newexample}[1]%
{	\refstepcounter{lfigure}
	\@docaption{Example \thelfigure: #1}
}
\newcommand{\continueexample}%
{	\hfill\emph{\small continues over\ldots}
	\newpage
	\@docaption{Example \thelfigure, cont'd}
}


% Package initialisation.

% geometry setup.
\geometry{a4paper,margin={1in,1in}}

% fancyhdr setup.
\fancyhf{}
\fancyfoot[L]{\sffamily \PaperCode\ \ClassType\ \thechapter: \ShortClassTitle}
\fancyfoot[R]{\sffamily F-\thepage}

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\setlength{\parskip}{0.5\baselineskip}

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

\pagestyle{fancy}

\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\ Figures and Examples},%
		pdfsubject={\ShortClassTitle},%
		colorlinks,%
		urlcolor=blue,%
		linkcolor=blue,%
	}%
}


\endinput