- Fix use of sizes (maybe set exception for 13pt?) - Prepare keys for margins - Show example of bibfile modification on the go - Show how to use `\xkvview` to check defined keys
290 lines
11 KiB
TeX
290 lines
11 KiB
TeX
%% uoythesis.cls
|
|
%% Copyright 2023 A. Grau
|
|
%
|
|
% This work may be distributed and/or modified under the conditions of the LaTeX
|
|
% Project Public License, either version 1.3 of this license or (at your option)
|
|
% any later version, with the exception that distribution of Derived Work is not
|
|
% subject to the requirements of section 6.2.
|
|
% The latest version of this license is in
|
|
% http://www.latex-project.org/lppl.txt
|
|
% and version 1.3 or later is part of all distributions of LaTeX version
|
|
% 2005/12/01 or later.
|
|
%
|
|
%
|
|
% This work has the LPPL maintenance status `maintained`.
|
|
%
|
|
% The Current Maintainer of this work is A. Grau.
|
|
%
|
|
% This work consists of all the files listed in the README.md,
|
|
% and provides a copy of the original hosted on
|
|
% https://git.tigrau.ovh/Ambroise/LaTeX-Templates/.
|
|
|
|
|
|
% Comments starting with `FORMAT` highlight requirements from the
|
|
% University of York thesis regulations, as of November 2023.
|
|
% See https://www.york.ac.uk/research/graduate-school/academic/thesis/format/#tab-2
|
|
|
|
\NeedsTeXFormat{LaTeX2e}
|
|
\ProvidesClass{uoythesis}[2023/11/13 v1.0 UoY Thesis]
|
|
|
|
\providecommand{\is@uoyth@classloaded}{true}
|
|
\RequirePackage{xkeyval}
|
|
\RequirePackage{etoolbox}
|
|
\RequirePackage{xstring}
|
|
|
|
% To be able to check which keys are set
|
|
\RequirePackage{xkvview}
|
|
\let\tablename=\undefined % reset this which is defined in memoir
|
|
|
|
%%% Set class options
|
|
\newcommand{\uoyth@tmp@classoptionslist}{}
|
|
\newcommand{\AddToClassOptionList}[1]{\csappto{uoyth@tmp@classoptionslist}{, #1}}
|
|
%\newcommand{\changeoptions}[1]{\cspreto{@classoptionslist}{#1,}}
|
|
\newcommand{\RaiseBooleanValueWarning}[1]{
|
|
\ClassError{uoythesis}{The option {#1} must be set with either true or false}{Option #1 only accepts a boolean value}
|
|
}
|
|
\newcommand{\RaiseFontSizeValueWarning}[1]{
|
|
\ClassWarning{uoythesis}{You gave size '#1' which is too small according to the guidelines. Automatically changing to the smallest value accepted: 11pt. (Classoptions:\@classoptionslist )}
|
|
}
|
|
\newcommand{\uoyth@fontsize}{12pt}
|
|
\newcommand{\uoyth@SetFontSize}[1]{
|
|
\AddToClassOptionList{#1}
|
|
\renewcommand{\uoyth@fontsize}{#1}
|
|
\PassOptionsToClass{#1}{memoir}
|
|
}
|
|
|
|
% options passed onto memoir: draft, final, oneside, twoside
|
|
|
|
\newif\ifuoyth@draft
|
|
\uoyth@draftfalse
|
|
\DeclareOptionX{draft}{\uoyth@drafttrue \PassOptionsToClass{draft}{memoir}}
|
|
\DeclareOptionX{final}{\uoyth@draftfalse \PassOptionsToClass{final}{memoir}}
|
|
\newif\ifuoyth@onesided
|
|
\uoyth@onesidedfalse
|
|
\DeclareOptionX{oneside}{\uoyth@onesidedtrue \PassOptionsToClass{oneside}{memoir}}
|
|
\DeclareOptionX{twoside}{\uoyth@onesidedfalse \PassOptionsToClass{twoside}{memoir}}
|
|
|
|
% new available options: pagenb (head or foot), noxr, nohyperref, hyperfinal, margins
|
|
\newif\ifuoyth@pgnbhead
|
|
\uoyth@pgnbheadtrue
|
|
\define@choicekey*+{uoythesis.cls}{pagenb}[\userval\choiceval]{head,foot}[head]{
|
|
\ifcase\choiceval\relax
|
|
\uoyth@pgnbheadtrue
|
|
\or
|
|
\uoyth@pgnbheadfalse
|
|
\fi
|
|
}{
|
|
\ClassWarning{uoythesis}{The \texttt{pagenb} option must be set to either `head' or `foot', but you gave `#1'}
|
|
}
|
|
\ExecuteOptionsX{pagenb=head}
|
|
\define@boolkey+{uoythesis.cls}[uoyth@]{noxr}[true]{}{\RaiseBooleanValueWarning{noxr}}
|
|
\ExecuteOptionsX{noxr=false}
|
|
\define@boolkey+{uoythesis.cls}[uoyth@]{nohyperref}[true]{}{\RaiseBooleanValueWarning{nohyperref}}
|
|
\ExecuteOptionsX{nohyperref=false}
|
|
\define@boolkey+{uoythesis.cls}[uoyth@]{hyperfinal}[true]{}{\RaiseBooleanValueWarning{hyperfinal}}
|
|
\ExecuteOptionsX{hyperfinal}
|
|
\DeclareOptionX{hyperoptions}{
|
|
\ClassInfo{uoythesis}{Passing options '#1' to package hyperref}
|
|
\PassOptionsToPackage{#1}{hyperref}
|
|
}
|
|
\ExecuteOptionsX{hyperoptions={}}
|
|
|
|
\define@cmdkey{uoythesis.cls}[uoyth@]{spine}{}
|
|
\define@cmdkey{uoythesis.cls}[uoyth@]{foredge}{}
|
|
\define@cmdkey{uoythesis.cls}[uoyth@]{hratio}{}
|
|
\define@cmdkey{uoythesis.cls}[uoyth@]{top}{}
|
|
\define@cmdkey{uoythesis.cls}[uoyth@]{bottom}{}
|
|
\define@cmdkey{uoythesis.cls}[uoyth@]{vratio}{}
|
|
\define@cmdkey{uoythesis.cls}[uoyth@]{margins}{\setkeys{uoythesis.cls}{#1}}
|
|
|
|
\newcommand{\showmargins}{
|
|
all margins=\key@ifundefined{uoythesis.cls}{margins}{undef}{`\uoyth@margins '};
|
|
spine=\key@ifundefined{uoythesis.cls}{spine}{undef}{`\uoyth@spine '};
|
|
foredge=\key@ifundefined{uoythesis.cls}{foredge}{undef}{\@ifundefined{uoyth@foredge}{unset}{`\uoyth@foredge'}}
|
|
}
|
|
\newcommand{\uoythsetup}[1]{\setkeys{uoythesis.cls}{#1}}
|
|
% FORMAT: Font size must be at least 11pt, so we disable small values
|
|
%\DeclareOptionX{8pt}{
|
|
% \RaiseFontSizeValueWarning{\CurrentOption}
|
|
% \changeoptions{11pt}
|
|
% \ChangeSizeToSmallest
|
|
% \ClassWarning{uoythesis}{Options passed are KV:\XKV@classoptionslist; and normal:\@classoptionslist}
|
|
%}
|
|
%\DeclareOptionX{9pt}{
|
|
% \RaiseFontSizeValueWarning{\CurrentOption} \ChangeSizeToSmallest
|
|
%}
|
|
%\DeclareOptionX{10pt}{
|
|
% \RaiseFontSizeValueWarning{\CurrentOption} \ChangeSizeToSmallest
|
|
%}
|
|
%\DeclareOptionX{13pt}{
|
|
% \ClassInfo{uoythesis}{Font size 13pt not available, downsizing to 12pt}
|
|
% \uoyth@SetFontSize{12pt}
|
|
%}
|
|
|
|
% Pass all remaining unknown options to memoir to deal with them
|
|
\DeclareOptionX*{%
|
|
\IfEndWith{\CurrentOption}{pt}{ % this is possibly a font size
|
|
\StrGobbleRight{\CurrentOption}{2}[\val]
|
|
\IfInteger{\val}{ % as a font size verifies if at least 11
|
|
\ifnum\val<12 % if too small, set to 11 and raise warning
|
|
\RaiseFontSizeValueWarning{\CurrentOption}
|
|
\uoyth@SetFontSize{11pt}
|
|
\else
|
|
\uoyth@SetFontSize{\CurrentOption}
|
|
\fi
|
|
}{
|
|
\PassOptionsToClass{\CurrentOption}{memoir}
|
|
}
|
|
}{
|
|
\PassOptionsToClass{\CurrentOption}{memoir}
|
|
}
|
|
}
|
|
|
|
\ProcessOptionsX
|
|
\ifuoyth@draft
|
|
\AddToClassOptionList{draft}
|
|
\else
|
|
\AddToClassOptionList{final}
|
|
\fi
|
|
\ifuoyth@onesided
|
|
\AddToClassOptionList{oneside}
|
|
\else
|
|
\AddToClassOptionList{twoside}
|
|
\fi
|
|
|
|
\renewcommand{\@classoptionslist}{\uoyth@tmp@classoptionslist}
|
|
% FORMAT: Document must be on A4 paper and avoid blank pages when starting new chapters
|
|
\LoadClass[a4paper,openany,\uoyth@fontsize]{memoir}
|
|
|
|
\disable@keys{uoythesis.cls}{draft,oneside}
|
|
|
|
|
|
\ifuoyth@hyperfinal
|
|
\newcommand{\uoyth@hyperoptions}{final}
|
|
\else
|
|
\newcommand{\uoyth@hyperoptions}{}
|
|
\fi
|
|
\ifuoyth@noxr
|
|
\ifuoyth@nohyperref
|
|
\else
|
|
\RequirePackage[\uoyth@hyperoptions]{hyperref}
|
|
\fi
|
|
\else
|
|
\ifuoyth@nohyperref
|
|
\RequirePackage{xr}
|
|
\else
|
|
\RequirePackage{xr-hyper}
|
|
\RequirePackage[\uoyth@hyperoptions]{hyperref}
|
|
\fi
|
|
\fi
|
|
|
|
\disable@keys{uoythesis.cls}{noxr,nohyperref,hyperfinal,hyperoptions}
|
|
|
|
%%% Formatting options
|
|
|
|
% FORMAT: Use 1.5 line spacing.
|
|
\OnehalfSpacing
|
|
|
|
% FORMAT: GRS states as a recommendation that:
|
|
% spine margin should be at least 40mm,
|
|
% other margins should be at least 15mm.
|
|
% In effect, their view is the following:
|
|
% "We would recommend that they stick with the guidance re. margin on binding edge merely because we still get examiners who prefer to make themselves a physical copy to mark up, rather than using the digital annotation."
|
|
% I have taken the stand to set the default value to 3cm on both sizes horizontally,
|
|
% while putting 4cm vertically. The implementation below prevents the use of setting
|
|
% the blocksize and then letting the margins be defined by a value relatively to that
|
|
% blocksize. If you want to use these instead, you need to delete the macros below.
|
|
% DOC: Check memoir package sec2.4.2 p.17-21
|
|
\newcommand{\horizontalmarginsvalue}[2][*]{\def\margin@spine{#2} \def\margin@foredge{#1}}
|
|
\newcommand{\horizontalmarginsratio}[2][*]{\def\margin@spine{#2} \def\margin@hratio{#1}}
|
|
\newcommand{\verticalmarginsvalue}[2][*]{\def\margin@up{#2} \def\margin@low{#1}}
|
|
\newcommand{\verticalmarginsratio}[2][*]{\def\margin@up{#2} \def\margin@vratio{#1}}
|
|
|
|
\@ifundefined{margin@spine}{ % none of the horizontal commands have been called
|
|
\setlrmarginsandblock{3cm}{*}{1} % default with 3cm each side
|
|
}{ % if margin@spine is defined, so is one of margin@foredge or margin@hratio
|
|
\@ifundefined{margin@foredge}{ % at least ratio value is defined
|
|
\setlrmarginsandblock{\margin@spine}{*}{\margin@hratio}
|
|
}{ % at least foredge value is defined; hratio value is discarded if defined
|
|
\setlrmarginsandblock{\margin@spine}{\margin@foredge}{*}
|
|
}
|
|
}
|
|
|
|
\@ifundefined{margin@up}{ % none of the vertical commands have been called
|
|
\setulmarginsandblock{4cm}{*}{1} % default with 3cm each side
|
|
}{ % if margin@up is defined, so is one of margin@low or margin@vratio
|
|
\@ifundefined{margin@low}{ % at least ratio value is defined
|
|
\setulmarginsandblock{\margin@up}{*}{\margin@vratio}
|
|
}{ % at least low value is defined; vratio value is discarded if defined
|
|
\setulmarginsandblock{\margin@up}{\margin@low}{*}
|
|
}
|
|
}
|
|
% Call the layout to respect the values set
|
|
\checkandfixthelayout
|
|
|
|
% FORMAT: Table of contents must include all document subdivisions.
|
|
% Do not go below subsubsections.
|
|
\settocdepth{subsubsection}
|
|
\setsecnumdepth{subsubsection}
|
|
|
|
% FORMAT: The font size of the headings should be smaller than the font size of
|
|
% the main text.
|
|
% NOTE: Hyperref messes up the capitalisation of headings containing a reference
|
|
% label, so we use small-caps headings as a workaround.
|
|
% See https://tex.stackexchange.com/q/562773/27664
|
|
\nouppercaseheads
|
|
\pagestyle{headings}
|
|
%\makeevenhead{headings}{\thepage}{}{\small\slshape\scshape\leftmark}
|
|
%\makeoddhead{headings}{\small\slshape\scshape\rightmark}{}{\thepage}
|
|
|
|
% FORMAT: A bibliography should contain every item consulted in writing the
|
|
% thesis, while a list of references only contains the items explicitly
|
|
% mentioned in the document.
|
|
\renewcommand{\bibname}{References}
|
|
|
|
|
|
%%% Title page
|
|
|
|
\newcommand{\department}[1]{\def\@department{#1}}
|
|
\newcommand{\qualification}[1]{\def\@qualification{#1}}
|
|
\newcommand{\submitdate}[1]{\def\@submitdate{#1}}
|
|
\newcommand{\subtitle}[1]{\gdef\cfg@subtitle{#1}}
|
|
|
|
% Empty submitdate defaults to the current month and year.
|
|
% Taken from the yorkThesis class by J H Pickering:
|
|
% https://www.york.ac.uk/language/current/resources/software-resources/latex/
|
|
\def\@submitdate{%
|
|
\ifcase\the\month\or
|
|
January\or February\or March\or April\or May\or June\or
|
|
July\or August\or September\or October\or November\or December\fi
|
|
\space \number\the\year}
|
|
|
|
\newlength{\droplen}
|
|
\newcommand*{\makethesistitle}{\begingroup%
|
|
% FORMAT: The title page should have number 1 (not visible),
|
|
% hence the starred version of `titlingpage`.
|
|
\begin{titlingpage*}
|
|
% Centre the title with respect to the physical page, not the typeblock
|
|
\calccentering{\unitlength}
|
|
\begin{adjustwidth*}{\unitlength}{-\unitlength}
|
|
\droplen=0.1\textheight
|
|
\vspace*{\droplen}
|
|
\centering
|
|
{\Huge \@title}
|
|
\@ifundefined{cfg@subtitle}{}{\\[\baselineskip]{\large\scshape\cfg@subtitle}} \\[2\baselineskip]
|
|
{\Large \itshape \@author}\par
|
|
\begin{vplace}[2] % Split surrounding vertical space with a 2:1 ratio
|
|
{\large \scshape \@qualification}\\[2\baselineskip]
|
|
{\LARGE \scshape University of York}\\[.5\baselineskip]
|
|
{\LARGE \scshape \@department}
|
|
\end{vplace}
|
|
{\large \@submitdate}\par
|
|
\vspace*{\droplen}
|
|
\end{adjustwidth*}
|
|
% FORMAT: The abstract should be on page 2, so we prevent clearing to
|
|
% the next recto page.
|
|
\titlingpageend{\clearforchapter}{\clearforchapter}
|
|
\end{titlingpage*}
|
|
\endgroup}
|
|
|
|
\endinput |