% \iffalse meta-comment
%
% Copyright (C) 2004 by Scott Pakin <scott+dtx@pakin.org>
% -------------------------------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{bhamthesis.dtx}
%</driver>
%<class|package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%<class>\ProvidesClass{bhamthesis}
%<package>\ProvidesPackage{bhamthesis}
%<package>    [2009/12/26 v3.3 UoB thesis package]
%<*class>
    [2009/12/26 v3.3 UoB thesis class]
%</class>
%
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{bhamthesis.dtx}
  \PrintChanges
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{1462}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \GetFileInfo{bhamthesis.dtx}
%
% \OnlyDescription
%
% \DoNotIndex{\newcommand,\newenvironment,\renewenvironment,\renewcommand,\providecommand,
%             \\,\par,\protect,\protected@edef,\setcounter,\settowidth,\usecounter,\value,
%             \begin,\end,\begingroup,\endgroup,\csname,\endcsname,\global,\sloppy,
%             \newlength,\setlength,\addtolength,\advance,\expandafter,\noexpand,
%             \newcounter,\newif,\def,\gdef,\let,\@firstofone,\@ifclassloaded,
%             \baselineskip,\space,\relax,\@empty,\@plus,\p@,\and,\or,\box,\sbox,\wd,
%             \m@ne,\z@,\null,\makebox,\refstepcounter,\rule,\stretch,\addvspace,
%             \@tempboxa,\@tempcmd,\@tempskipa,\number,\numberline,\nobreakspace,
%             \if@minipage,\if@openright,\if@restonecol,\if@twocolumn,
%             \ifcase,\ifdim,\iffalse,\if,\ifx,\ifnum,\else,\fi,\@latex@warning,
%             \ClassWarning,\ClassInfo,\PackageInfo,\ClassWarningNoLine,\MessageBreak,
%             \ProcessOptions,\CurrentOption,\DeclareOption,\ExecuteOptions,
%             \AtBeginDocument,\AtEndDocument,\AtEndOfClass,\LoadClass,\PassOptionsToClass,
%             \RequirePackage,\@ifpackageloaded,\addtocontents,\contentsline,\typeout,
%             \@float,\end@float,\@parboxrestore,\@starttoc,\@svsec,\@svsechd,
%             \@afterheading,\@afterindentfalse,\@biblabel,\@captype,\sfcode,
%             \@chapapp,\@idxitem,\@makepagecaption,\@minipagefalse,\@thanks,
%             \@noitemerr,\@openbib@code,\@seccntformat,\@setminipage,\@topnewpage,
%             \@xsect,\abovecaptionskip,\addcontentsline,\belowcaptionskip,
%             \cleardoublepage,\clearpage,\columnsep,\columnseprule,
%             \@gobble,\nobreak,\@hangfrom,\@mkboth,\@undefined,
%             \@beginparpenalty,\@clubpenalty,\@endparpenalty,\@lowpenalty,\clubpenalty,
%             \interlinepenalty,\widowpenalty,
%             \@restonecolfalse,\@restonecoltrue,\@topnum,
%             \.,\@@par,\@Alph,\@M,\@arabic,\@m,\hb@xt@,\p@enumiv,
%             \c@chapter,\c@enumiv,\c@secnumdepth,\secdef,\pagenumbering,\pagestyle,
%             \paperheight,\paperwidth,\parindent,\parsep,\parskip,
%             \normalfont,\bfseries,\centering,\hfil,\vfil,\vfill,\vskip,\hsize,\hskip,\vspace,
%             \ignorespaces,\raggedright,\thispagestyle,
%             \LARGE,\Large,\large,\small,\normalsize,\MakeUppercase,\uppercase,\newpage,\noindent,
%             \abstractname,\acknowledgements,\abstract,\section,\appendixname,\indexname,\thechapter,
%             \contentsname,\dedication,\quotation,\quote,\titlepage,\theenumiv,
%             \endlist,\endtitlepage,\figurepage,\month,\year,
%             \thanks,\footnote,\footnotemark,\footnoterule,\footnotesize,\indexname
%             \item,\itemindent,\leftmargin,\rightmargin,\labelwidth,\listparindent,\labelsep,\list,
%             \listfigurename,\listtablename,\onecolumn,\twocolumn}
%
%
% ^^A |-------------|
% ^^A | User Macros |
% ^^A |-------------|
% \newcommand{\opt}[1]{\texttt{#1}}
% \newcommand{\pkg}[1]{\textsf{#1}}
% \newcommand{\pkgname}{\pkg{bhamthesis}}
% \newcommand{\cls}[1]{\textsf{#1}}
% \newcommand{\clsname}{\cls{bhamthesis}}
% \newcommand{\env}[1]{\texttt{#1}}
% \newcommand{\file}[1]{\texttt{#1}}
% \newcommand{\url}[1]{\texttt{#1}}
% \newcommand{\cm}{\mathrm{cm}}
% \newcommand{\doc}{\textsf{doc}}
% \newcommand{\docstrip}{\textsc{docstrip}}
% \newenvironment{dispcode}{\begin{quote}}{\end{quote}}
% \newenvironment{dispcodelong}{\begin{dispcode}\small}{\end{dispcode}}
%
% \MakeShortVerb{\+}
%
% \changes{v3.2}{2009/12/23}{First \docstrip\ version}
%
% \title{The \clsname\ class}
% \author{Tin Lok Wong}
% \date{26~December, 2009}
%
% \maketitle
%
%
% \section*{Disclaimer}
% \emph{This document is neither produced nor approved by the University of Birmingham.}
% Always make sure your thesis conform to the requirements after printing and before submitting.
%
%
% \tableofcontents
%
%
% \section{Introduction}
% This documentation corresponds to~\fileversion\ of \clsname,
% dated~\filedate.
%
% The \clsname\ class is meant to help \TeX-ers more easily
% conform to the thesis requirements set by the University of Birmingham, UK.
% I only did the minimum work to program in these thesis requirements.
% Please e-mail me any comments or any bugs you find.
% I did not try to make the documents produced beautiful.
% If you think some parts of the output look awful,
% then please first try your document on the standard \LaTeX\ \cls{report} class
% --- it may just be a `feature' of the \cls{report} class
%     on which \clsname\ builds.
%
%
% \section{Major changes in the current version}
% The thesis requirements~\cite{unpub:thereq} have `evolved' slightly
% since I wrote the previous versions
% (and it is time to write a thesis again).
% So I updated some features of the class.
% The main changes include the following.
% \begin{itemize}
% \item The class is `repackaged' using \doc, \docstrip, etc.
%   Hopefully, this will help future generations modify this more easily
%   when the thesis requirements `evolve' again
%   (and if they still want parts of my code).
% \item The ugly \pkg{bhamthesisfill} is placed by the (I believe) more tidy \pkgname.
% \item There seems to be more choice in the bibliography style now~\cite{web:icite}.
%   So I do not provide a \BibTeX\ style in this version.
%   (I prefer \file{plain.bst} after all.)
%   However, remember to include the date of access
%   if your reference is from the Internet.
% \item In view of the new college structure of the university,
%   we need to say in which college our school is now.
%   An appropriate command is added to put it on the title page.
% \item This version has a couple of new options to change the fonts of the text.
% \item (This is not really a change.)
%   It seems that the requirements allow theses to be printed on both sides of the paper now.
%   The \opt{twoside} and \opt{openright} options have now been considered,
%   although they have not been thoroughly tested yet.
% \item In previous versions of \clsname, the whole bibliography is single-spaced by default.
%   Now, only items \emph{within} the bibliography are single-spaced, not between the items.
% \item In the current version,
%   I made the list of references appear in the table of contents automatically.
% \item Some new options and commands are added
%   to change how the appendix looks like in the table of contents.
% \end{itemize}
%
%
% \section{Packages required}
% \clsname\ needs the \pkg{setspace} package to making double line spacing,
% and the \pkg{perpage} package to make footnote numbering reset on each page.
% \pkg{setspace} and \pkg{perpage} can be downloaded from
% \begin{dispcodelong}
%  \url{http://www.ctan.org/pub/tex-archive/macros/latex/contrib/setspace/setspace.sty}
% \end{dispcodelong}
% and
% \begin{dispcodelong}
%  \url{http://tug.ctan.org/tex-archive/macros/latex/contrib/bigfoot/}
% \end{dispcodelong}
% respectively.
%
% If the \opt{reqfont} option is called,
% then \clsname\ will additionally need the \pkg{fontenc} package
% and the font packages \pkg{mathptmx}, \pkg{uarial}, and \pkg{courier}.
% Otherwise, these packages are not needed.
% \pkg{fontenc} is included in most \LaTeX\ distributions,
% but it can also be downloaded from
% \begin{dispcodelong}
%  \url{http://www.ctan.org/tex-archive/macros/latex/unpacked/fontenc.sty}.
% \end{dispcodelong}
% \pkg{uarial}, which is also known as \pkg{urw-arial}, can be downloaded from
% \begin{dispcodelong}
%  \url{http://www.ctan.org/tex-archive/fonts/urw/arial/}.
% \end{dispcodelong}
% \pkg{mathptmx} and \pkg{courier} are included in the usual \LaTeX\ macro package called \pkg{psnfss},
% which can be downloaded from
% \begin{dispcodelong}
%  \url{http://www.ctan.org/tex-archive/macros/latex/required/psnfss/}.
% \end{dispcodelong}
%
% If the \opt{fancyfonts} option is called,
% then \clsname\ will additionally need the \pkg{fontenc} package
% and the font packages \pkg{mathptmx}, \pkg{tgtermes}, \pkg{tgheros} and \pkg{tgcursor}.
% As mentioned above, the \pkg{fontenc} package and the \pkg{mathptmx} package can be found at
% \begin{dispcodelong}
%  \url{http://www.ctan.org/tex-archive/macros/latex/unpacked/fontenc.sty}
% \end{dispcodelong}
% and at
% \begin{dispcodelong}
%  \url{http://www.ctan.org/tex-archive/macros/latex/required/psnfss/}
% \end{dispcodelong}
% respectively.
% The latest version of \pkg{tgtermes}, \pkg{tgheros} and \pkg{tgcursor}
% can respectively be downloaded from
% \begin{dispcodelong}
%  \url{http://www.gust.org.pl/projects/e-foundry/tex-gyre/termes},\\
%  \url{http://www.gust.org.pl/projects/e-foundry/tex-gyre/heros}, and\\
%  \url{http://www.gust.org.pl/projects/e-foundry/tex-gyre/cursor}.
% \end{dispcodelong}
% It would be safe to have a version dated no earlier than +2009/09/10+.
%
% All these packages are free of charge,
% and probably (most of) these are already in your \LaTeX\ installation.
%
%
% \section{Files in \clsname}
% The following files are included in the distribution.
% \begin{description}
% \item[\file{bhamthesis.pdf}] --- the user manual.
% \item[\file{bhamthesis.dtx}] --- the documented code.
% \item[\file{bhamthesis.ins}] --- the installer file.
% \item[\file{bhamthesis.cls}] --- the main class file.
% \item[\file{bhamthesis.sty}] --- the complementary package.
% \item[\file{thesiseg.tex}]   --- an example using \clsname.
% \item[\file{bibeg.bib}]      --- the \BibTeX\ `database' accompanying the example.
% \item[\file{README}]         --- a text-only description of \clsname.
% \end{description}
%
%
% \section{Usage}
% \subsection{Extracting the package}
% The \file{cls} and \file{sty} files are already included in the distribution.
% So \emph{it is not necessary to extract the files again}.
% However, if you really want to try it, then
% (make sure you have \LaTeX\ installed on your computer, and) run
% \begin{dispcode}
%  +latex bhamthesis.ins+.
% \end{dispcode}
% This should give \file{bhamthesis.cls} and \file{bhamthesis.sty}.
%
% Move the \file{cls} and \file{sty} files to a place where you \LaTeX\ can find,
% e.g.,~in the same directory as your \file{tex} files.
%
% \subsection{Producing the documentation}
% Again, a \file{pdf} version of the (user) documentation is already included in the distribution
% (i.e.,~the one you are reading now).
% The following describes a way to produce the (user and programmer) documentation yourself.
%
% To produce a \file{dvi} version of the user documentation,
% run the following commands in the order given.
% \begin{dispcode}
%  +latex bhamthesis.dtx+\\
%  +makeindex -s gglo.ist -o bhamthesis.gls bhamthesis.glo+\\
%  +makeindex -s gind.ist -o bhamthesis.ind bhamthesis.idx+\\
%  +latex bhamthesis.dtx+
% \end{dispcode}
% To produce a \file{dvi} version of the programmer documentation, remove the line
% \begin{dispcode}
%  +% \OnlyDescription+
% \end{dispcode}
% in \file{bhamthesis.dtx} before running the above commands.
% To produce the documentation in \file{pdf} format, replace +latex+ in the above sequence by +pdflatex+.
%
% \subsection{Loading the class}
% At the beginning of your \file{tex} file,
% in the place where you usually put your \cmd{\documentclass}\ldots, write
% \begin{dispcode}
%  \cmd{\documentclass}\oarg{class options}+{bhamthesis}+
% \end{dispcode}
% instead.
% The \meta{class options} can include any combinations of
% the options available in the standard \LaTeX\ \cls{report} class.
% The other \meta{class options} made available by \clsname\ are the following.
% \begin{description}
% \item[\opt{reqfonts}]
%   The typefaces Times Roman, Arial, and Courier are recommended by the thesis requirements.
%   This option makes the document use (something similar to) these fonts.
%   You need additional packages for using this option:
%   \pkg{fontenc}, \pkg{mathptmx}, \pkg{uarial}, and \pkg{courier}.
%   As usual, the math fonts will not look good under this option.
% \item[\opt{alldoublespace}]
%   According to the thesis requirements, not every part of a thesis needs to be double-spaced.
%   This option makes everything double-spaced,
%   including the quotations, captions, and the bibliography,
%   \emph{but excluding the footnotes},
%   which was made to be single-spaced by \pkg{setspace}, not by me.
% \item[\opt{nodoublespace}]
%   This makes everything single-spaced.
% \item[\opt{savespace}]
%   This is essentially the combination of \opt{10pt} and \opt{nodoublespace}.
% \item[\opt{toclineappendix}]
%   This makes the word `Appendix' to appear in the table of contents on a new line.
% \item[\opt{prefixappendix}]
%   This adds the prefix `Appendix' to appendix chapters in the table of contents.
% \item[\opt{fancyfonts}]
%   This is for people who like something more adventurous.
%   These will make use of \TeX-Gyre fonts Termes, Heros, and Cursor.
%   These fonts are still not very stable yet.
%   So this option is still experimental.
%   You need \pkg{fontenc}, \pkg{mathptmx}, \pkg{tgtermes}, \pkg{tgheros} and \pkg{tgcursor}.
%   As with \opt{reqfonts}, the math fonts will still not look good under this option.
%   Hopefully the developers of these fonts will get round to fixing this soon.
%   The main difference of this option from \opt{reqfonts} is that
%   one can do more combinations now, e.g.,~a typewriter smallcaps font.
% \end{description}
% I don't know what will happen if you load both \opt{reqfonts} and \opt{fancyfonts}.
% I guess it depends on which order you specify it.
% Avoid it.
% If both \opt{toclineappendix} and \opt{prefixappendix} are loaded
% (and the flags are not changed throughout),
% then \opt{prefixappendix} is ignored.
%
% All commands available in the standard \LaTeX\ \cls{report} class are available in \clsname.
%
% \subsection{The title page}
% Quite a lot of information is shown on the title page,
% and \clsname\ needs to know these pieces of information.
% \DescribeMacro{\submissionstatement}\DescribeMacro{\degree}\DescribeMacro{\school}%
% \DescribeMacro{\college}\DescribeMacro{\university}%
% In addition to the usual \cmd{\title}, \cmd{\author} and \cmd{\date},
% \cmd{\degree}, \cmd{\school}, \cmd{\college} and \cmd{\university} allows you to put in
% respectively the degree you are studying for, your school, your college, and your university.
% The `submission statement' is a piece of text that appears below your name on the title page,
% and it can be changed by \cmd{\submissionstatement}.
% All these have convenient default values.
%
% As usual, \cmd{\maketitle} is used to make title pages.
%
% \subsection{Parts of the thesis}
% \DescribeMacro{\frontmatter}\DescribeMacro{\mainmatter}\DescribeMacro{\backmatter}%
% \clsname\ divides theses into three parts: \cmd{\frontmatter}, \cmd{\mainmatter}, and \cmd{\backmatter}.
% (Sorry for misusing these words.)
% \cmd{\frontmatter} should be put at the very beginning of the document, before \cmd{\maketitle}.
% \cmd{\mainmatter} should be put
% after the \cmd{\tableofcontents}, the \cmd{\listoffigures}, and the \cmd{\listoftables},
% and before the first \cmd{\chapter}.
% \cmd{\backmatter} should be put
% immediately before the \cmd{\bibliographystyle}, and after the appendix, if any.
% In summary, theses should be arranged in the following order.
% \begin{enumerate}
% \item[] \textbf{Frontmatter}
% \item Title page
% \item Abstract
% \item Dedication (if any)
% \item Acknowledgements (if any)
% \item Table of contents
% \item List of figures (if any)
% \item List of tables (if any)
% \item List of definitions and abbreviations (if any)
% \item[] \textbf{Mainmatter}
% \item Main text
% \item Appendices (if any)
% \item[] \textbf{Backmatter}
% \item List of references
% \end{enumerate}
%
% \DescribeEnv{dedication}\DescribeEnv{acknowledgements}%
% You can use the environments \env{dedication} and \env{acknowledgements}
% for your dedication page and your acknowledgements.
%
% \changes{v3.3}{2009/12/26}{Description for appendix commands added.}
% \DescribeMacro{\toclineappendix}\DescribeMacro{\prefixappendix}\DescribeMacro{\prefixappendixoff}%
% One can control how the appendix appear in the table of contents.
% Having \cmd{\toclineappendix} and \cmd{\prefixappendix} are the same as
% including the \opt{toclineappendix} option and the \opt{toclineappendix} option respectively.
% \cmd{\prefixappendixoff} turns off the prefix-ing triggered by $\cmd{\prefixappendix}$.
% You can put these commands in the preamble or within your document.
% If you have both \cmd{\toclineappendix} and \cmd{\prefixappendix} when you reach the appendix,
% then the chapter titles will \emph{not} be prefix-ed in the table of contents.
% It is recommended that you number your chapters in the appendix
% unless there is only one appendix chapter.
%
% All other parts are as in the \LaTeX\ \cls{report} class.
%
% \subsection{Double-spaced quotations}
% \DescribeEnv{display}\DescribeEnv{displaypar}%
% Sometimes, one may prefer double-spaced quotations
% (or he/she may just want to display something).
% This can be done using \env{display} and \env{displaypar}
% in place of \env{quote} and \env{quotation} respectively.
%
% \subsection{Page-size figures and tables}
% \DescribeEnv{figurepage}\DescribeEnv{tablepage}%
% The thesis requirements want page-size figures and tables to be treated a little differently.
% \env{figurepage} and \env{tablepage} are designed for this.
% Put your page-size figures and tables into these environments,
% use the \cmd{\caption} command as you would in \env{figure}s and \env{table}s.
% The binding margin will be slightly increased,
% the figure/table will always be numbered,
% and the numbering will always appear on the top.
%
% \subsection{The supplementary package}
% This new version of \clsname\ comes with a supplementary package, also called \pkgname.
% The \clsname\ class loads the \pkgname\ package automatically,
% so you don't need to load this package separately.
% However, there would be no problem even if you have
% \begin{dispcode}
%  +\documentclass{bhamthesis}+\\
%  +...+\\
%  +\usepackage{bhamthesis}+\\
%  +...+
% \end{dispcode}
% for example.
% If for some reason you need to switch back to the usual \LaTeX\ classes temporarily,
% then you can put
% \begin{dispcode}
%  +\usepackage{bhamthesis}+
% \end{dispcode}
% in the preamble of your document
% so that all commands provided by the \clsname\ are still (properly) defined.
%
% \subsection{User parameters}
% More advanced users can choose to change the default appearance of \clsname\ documents
% by altering the following parameters (or otherwise).
% \begin{description}
% \item[\cmd{\addsswidth}]
%   This is the width of the bottom-right box on the title page.
%   If not specified, then it is calculated so that it is the smallest possible.
% \item[\cmd{\acknowname}]
%   This is the caption of the \env{acknowledgements} page.
% \item[\cmd{\dedwidth}]
%   This stores the width of the dedication text in \env{dedication}.
% \item[\cmd{\dedabove},\cmd{\dedbelow}]
%   They are respectively the proportion of white space above and below the dedication text.
% \item[\mdseries\cmd{\namepart}\marg{number}]
%   \cmd{\namepart}\marg{number} returns the name of part~\meta{number} in the document
%   as predefined in \clsname.
% \end{description}
%
%
% \StopEventually{%
% \begin{thebibliography}{8}
% \addcontentsline{toc}{section}{\refname}
% \bibitem{unpub:thereq} University of Birmingham.
%   \newblock Presenting your thesis: Notes on the arrangements of theses and their preparation for binding and deposit.
%   \newblock Downloaded from \url{http://www.library.bham.ac.uk/searching/guides/sk05presentingthesis.pdf}
%             on 18~Decmeber, 2009.
%   \newblock Document number SK05-JR -- 02/06/2009.
% \bibitem{web:icite} University of Birmingham.
%   \newblock i-cite: Guide to Citing References.
%   \newblock Web address \url{http://www.i-cite.bham.ac.uk}.
% \bibitem{book:texbook} Donald E.~Knuth.
%   \newblock \textit{The \TeX book}.
%   \newblock Stanford University, 1986.
%   \newblock Downloaded from \url{http://www.ctan.org/tex-archive/systems/knuth/tex/}
%             on 8~April, 2007.
% \bibitem{book:LaTeX} Leslie Lamport.
%   \newblock \textit{\LaTeX: A Document Preparation System --- User's Guide and Reference Manual},
%             second edition.
%   \newblock Addison-Wesley Publishing Company, Inc.: Reading, Massachusetts, 1994.
%   \newblock Illustrated by Duane Bibby. Updated for \LaTeXe.
% \bibitem{book:LaTeXComp} Frank Mittelbach, Michel Gossens, Johannes Braams, David Carlisle, and Chris Rowley.
%   \newblock \textit{The \LaTeX\ Companion}, second edition.
%   \newblock Tools and Techniques for Computer Typesetting.
%   \newblock Addison-Wesley: Boston, 2004
%   \newblock With contributions by Christine Detig and Joachim Schrod.
% \bibitem{web:rwkexam} Richard Kaye.
%   \newblock The \cls{mathsexm} class: LaTeX class to set Mathematics Exams at The University of Birmingham.
%   \newblock Version dated 12~February, 2007.
%   \newblock Downloaded from \url{http://mat140.bham.ac.uk/\char`\~richard/programming/tex/exams/}
%             on 3~January, 2008.
% \bibitem{web:adfa} Stephen Harker.
%   \newblock The \cls{adfathesis} class: ADFA PhD thesis style.
%   \newblock Version~2.50, dated 16~April, 2004.
%   \newblock Downloaded from \url{http://tug.ctan.org/tex-archive/macros/latex/contrib/adfathesis/}
%             on 25~December, 2007.
% \bibitem{web:oarg} UK List of TeX FAQs on the Web.
%   \newblock Optional arguments like \cmd{\section}.
%   \newblock Web address \url{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=oarglikesect}.
%   \newblock Accessed on 24~December, 2007.  FAQ~version 3.17-1, last modified on 11~November, 2007.
% \end{thebibliography}%
% }
%
%
% \section{The code}
% \clsname\ is split into two parts: \file{bhamthesis.cls} and \file{bhamthesis.sty}.
% The \file{sty} file is designed mainly to allow some compatibility
% when the user wants to switch to other classes temporarily.
% The +<class>+ tag indicates some code to be written to the \file{cls} file,
% and the +<package>+ tag indicates some code to be written to the \file{sty} file.
%
% \subsection{Class messages}
% I need to emphasize again that this class is \emph{unofficial}.
%    \begin{macrocode}
%<*class>
\ClassInfo{bhamthesis}
  {University of Birmingham (unofficial)\MessageBreak
   MPhil/PhD thesis document class\@gobble}
%</class>
%    \end{macrocode}
%    \begin{macrocode}
%<*package>
\PackageInfo{bhamthesis}
  {University of Birmingham (unofficial)\MessageBreak
   MPhil/PhD thesis macros\@gobble}
%</package>
%    \end{macrocode}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% \begin{macro}{\bt@ptsize}
% \begin{macro}{\if@paperspecexists}
%
% \subsection{Class options}
% We only declare the options that we need to change here.
% All others are passed to the \cls{report} class.
% We need some additional registers to make the default options.
%    \begin{macrocode}
\newcommand{\bt@ptsize}{2}
\DeclareOption{10pt}{\renewcommand{\bt@ptsize}{0}}
\DeclareOption{11pt}{\renewcommand{\bt@ptsize}{1}}
\DeclareOption{12pt}{\renewcommand{\bt@ptsize}{2}}
\newif\if@paperspecexists \@paperspecexistsfalse
\DeclareOption{a4paper}
  {\PassOptionsToClass{a4paper}{report}\@paperspecexiststrue}
\DeclareOption{a5paper}
  {\PassOptionsToClass{a5paper}{report}\@paperspecexiststrue}
\DeclareOption{b5paper}
  {\PassOptionsToClass{b5paper}{report}\@paperspecexiststrue}
\DeclareOption{letterpaper}
  {\PassOptionsToClass{letterpaper}{report}\@paperspecexiststrue}
\DeclareOption{legalpaper}
  {\PassOptionsToClass{legalpaper}{report}\@paperspecexiststrue}
\DeclareOption{executivepaper}
  {\PassOptionsToClass{executivepaper}{report}\@paperspecexiststrue}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\if@apxline}\changes{v3.3}{2009/12/26}{Option \opt{toclineappendix} added.}%
% \begin{macro}{\if@apxprefix}\changes{v3.3}{2009/12/26}{Option \opt{prefixappendix} added.}%
% These two options control how the appendix appears in the table of contents.
% The \opt{toclineappendix} option puts a separate line
% for the title \cmd{\appendixname} in the table of contents.
% The \opt{prefixappendix} option adds a prefix to the appendix titles
% in the table of contents.
%    \begin{macrocode}
\newif\if@apxline   \@apxlinefalse
\newif\if@apxprefix \@apxprefixfalse
\DeclareOption{toclineappendix}{\@apxlinetrue}
\DeclareOption{prefixappendix}{\@apxprefixtrue}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% This option tells \clsname\ to use Times, Arial, and Courier
% for the serif, sans-serifs, and monotype fonts respectively,
% which is what the thesis requirements wants.
% The scaling for \pkg{uarial} is taken from Richard Kaye's maths exam class~\cite{web:rwkexam}.
%    \begin{macrocode}
\DeclareOption{reqfonts}{\AtEndOfClass{%
                          \RequirePackage[T1]{fontenc}
                          \RequirePackage{mathptmx}
                          \RequirePackage[scaled=0.89]{uarial}
                          \RequirePackage{courier}}}
%    \end{macrocode}
% Similarly, we declare the \opt{fancyfonts} option.
% I need a late enough version of these packages to use the \opt{mathlowercase} option.
%    \begin{macrocode}
\DeclareOption{fancyfonts}{\AtEndOfClass{%
                            \RequirePackage{mathptmx}
                            \RequirePackage{tgtermes}[2009/09/27]
                            \RequirePackage[matchlowercase]{tgheros}[2009/09/27]
                            \RequirePackage[matchlowercase]{tgcursor}[2009/09/10]}}
%    \end{macrocode}
% I lied.  Actually, \pkg{fontenc} is not needed here.
% It is safe to load it though, in case anything changes in the future.
% \begin{macro}{\if@alldoublespace}
% This option makes `everything' double-spaced,
% including marginal notes, bibliography, quotations, chapter and section titles,
% \emph{excluding footnotes}.
% I don't know how to deal with footnotes because they are omitted by \pkg{setspace}.
%    \begin{macrocode}
\newif\if@alldoublespace \@alldoublespacefalse
\DeclareOption{alldoublespace}{\@alldoublespacetrue}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\if@nodoublespace}
% This option switches off double spacing.
% \pkg{setspace} is still loaded though.
%    \begin{macrocode}
\newif\if@nodoublespace \@nodoublespacefalse
\DeclareOption{nodoublespace}{\@nodoublespacetrue}
%    \end{macrocode}
% \end{macro}
% This option provides a way to print out drafts while saving paper.
% Of course, the layout, line-breaking, etc.\ will be different,
% but it is good enough for checking the mathematics.
%    \begin{macrocode}
\DeclareOption{savespace}
  {\ExecuteOptions{10pt,nodoublespace,openany,draft}}
%    \end{macrocode}
% Everything else is passed on to \pkg{report}.
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
%    \end{macrocode}
% It's now time to process the options.
%    \begin{macrocode}
\ProcessOptions\relax
%    \end{macrocode}
%
% After all the switches are set, we deal with the default options.
% Since we are passing options to \cls{report},
% this code will be more complicated than it is.
%    \begin{macrocode}
\if\bt@ptsize0\PassOptionsToClass{10pt}{report}\else%
 \if\bt@ptsize1\PassOptionsToClass{11pt}{report}\else%
  \PassOptionsToClass{12pt}{report}\fi\fi
\if@paperspecexists\else\PassOptionsToClass{a4paper}{report}\fi
%    \end{macrocode}
%
% \subsection{Loading the \cls{report} class and other packages}
%    \begin{macrocode}
\LoadClass{report}
%    \end{macrocode}
% Next we load the packages needed.
%    \begin{macrocode}
\RequirePackage{setspace}[2000/12/01]
%    \end{macrocode}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
% \begin{macro}{\optsinglespacing}
% \begin{environment}{optsinglespace}
% We need a couple of some new commands and environments
% to make single spacing while the \opt{alldoublespacing} option is not on.
% \cmd{\optlisinglespacing} is taken from \file{setspace.sty}.
%    \begin{macrocode}
%<*class>
\newcommand{\optsinglespacing}{\if@alldoublespace\else\singlespacing\fi}
\newenvironment{optsinglespace}
 {\if@alldoublespace\begingroup\else\begin{singlespace}\fi}
 {\if@alldoublespace\endgroup\else\end{singlespace}\fi}
%</class>
%<*package>
\providecommand{\optsinglespacing}{\relax}
\ifx\optsinglespace\@undefined%
 \newenvironment{optsinglespace}{\relax}{\relax}%
\fi
%</package>
%    \end{macrocode}
% \end{environment}
% \end{macro}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
%    \begin{macrocode}
\RequirePackage{perpage}[2006/07/15]
%    \end{macrocode}
%
% All the commands that possibly appear in the text
% will be defined in \file{bhamthesis.sty}.
% The \clsname\ class will then load the \pkgname\ package
% for the definitions of these commands at the end of the class.
%    \begin{macrocode}
\AtEndOfClass{\RequirePackage{bhamthesis}}
%    \end{macrocode}
%
% \subsection{Page layout}
% We start with the horizontal spaces.
% The binding margin is set to $3\,\cm$,
% and the outside margin is $2\,\cm$.
%    \begin{macrocode}
\setlength  {\oddsidemargin} {3cm}
\addtolength{\oddsidemargin} {-1in}
\setlength  {\evensidemargin}{2cm}
\addtolength{\evensidemargin}{-1in}
\setlength  {\textwidth}{\paperwidth}
\addtolength{\textwidth}{-3cm}
\addtolength{\textwidth}{-2cm}
%    \end{macrocode}
% Next set the vertical spaces.
% The top and bottom margins are $3\,\cm$,
% and the page number is $2\,\cm$ above the bottom edge.
%    \begin{macrocode}
\setlength  {\topmargin}{3cm}
\addtolength{\topmargin}{-1in}
\addtolength{\topmargin}{-\headheight}
\addtolength{\topmargin}{-\headsep}
\setlength  {\textheight}{\paperheight}
\addtolength{\textheight}{-3cm}
\addtolength{\textheight}{-3cm}
\setlength  {\footskip}{1cm}
%    \end{macrocode}
% Note that we have not insisted \cmd{\textheight} to be an integer multiple of \cmd{\baselineskip}.
% Neither did we round all the measurements to the nearest point.
% These are done in \file{report.sty} probably to save memory.
%
% \begin{macro}{\lmarginparwidth}
% \begin{macro}{\rmarginparwidth}
% We next tweak the width of marginal notes.
% We distinguish between `left' and `right' marginal notes,
% where `left' means towards the binding edge,
% and `right' means towards the outside edge.
%    \begin{macrocode}
\newlength{\lmarginparwidth}
\newlength{\rmarginparwidth}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% Recall that the left margin is $3\,\cm$ wide.
% We leave a $0.2$~inch gap.
%    \begin{macrocode}
\setlength  {\lmarginparwidth}{3cm}
\addtolength{\lmarginparwidth}{-\marginparsep}
\addtolength{\lmarginparwidth}{-0.2in}
%    \end{macrocode}
% The right margin is $2\,\cm$ wide.
% We also leave a $0.2$~inch gap.
%    \begin{macrocode}
\setlength  {\rmarginparwidth}{2cm}
\addtolength{\rmarginparwidth}{-\marginparsep}
\addtolength{\rmarginparwidth}{-0.2in}
%    \end{macrocode}
% Since we have more space one the left, it is more preferable.
% So we set this as default.
%    \begin{macrocode}
\reversemarginpar
\setlength{\marginparwidth}{\lmarginparwidth}
%    \end{macrocode}
% \begin{macro}{\oldnormalm@rginpar}
% \begin{macro}{\oldreversem@rginpar}
% We will redefine the \cmd{\marginpar} and related commands.
% So it is safer to save a copy.
%    \begin{macrocode}
\let\oldnormalm@rginpar\normalmarginpar
\let\oldreversem@rginpar\reversemarginpar
\let\oldm@rginpar\marginpar
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\normalmarginpar}
% \begin{macro}{\reversemarginpar}
% \begin{macro}{\marginpar}
% We then redefine \cmd{\marginpar} so that the widths are different on different sides.
% `Normal' now means `left' or towards the binding edge,
% and `reverse' now means `right' or towards the outside edge.
% This is the opposite to the normal convention
% --- if you want the marginal notes to appear in a bound hard copy,
%     then you may want to `reverse' the \cmd{\marginpar}.
%    \begin{macrocode}
\renewcommand{\normalmarginpar}%
 {\oldreversem@rginpar%
  \setlength\marginparwidth\lmarginparwidth}
\renewcommand{\reversemarginpar}%
 {\oldnormalm@rginpar%
  \setlength\marginparwidth\rmarginparwidth}
%    \end{macrocode}
% This makes use of a trick from \texttt{TeX~FAQ: oarglikesect}~\cite{web:oarg}
% to set up the default optional argument as the mandatory argument.
% Marginal notes are single-spaced to save space.
%    \begin{macrocode}
\renewcommand\marginpar[2][\dummy@rg]%
 {\def\dummy@rg{#2}%
  \oldm@rginpar[\optsinglespacing#2]{\optsinglespacing#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%
% \subsection{Parts of the thesis}
% Many macros from the \cls{report} class need to be modified.
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand{\bibname}{List of References}
%    \end{macrocode}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% \begin{macro}{\acknowname}
% I make the name of the acknowledgement part a macro
% so that the user can change it to whatever they like.
%    \begin{macrocode}
\providecommand{\acknowname}{Acknowledgements}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@submissionstatement}
% \begin{macro}{\@degree}
% \begin{macro}{\@school}
% \begin{macro}{\@college}
% \begin{macro}{\@university}
% Here are some default words to go onto the title page.
%    \begin{macrocode}
\providecommand{\@submissionstatement}%
 {A thesis submitted to\\
  \@university\\
  for the degree of}
\providecommand*{\@degree}{Doctor of Philosophy}
\providecommand*{\@school}{School of Mathematics}
\providecommand*{\@college}{College of Engineering and Physical Sciences}
\providecommand*{\@university}{The University of Birmingham}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% Using the predefined commands, set the default user and title.
%    \begin{macrocode}
\author{[Author Missing]}
\title{[Title Missing]}
%    \end{macrocode}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% \begin{macro}{\submissionstatement}
% \begin{macro}{\degree}
% \begin{macro}{\school}
% \begin{macro}{\college}
% \begin{macro}{\university}
% Here are commands to change these words.
%    \begin{macrocode}
\providecommand{\submissionstatement}[1]
  {\renewcommand{\@submissionstatement}{#1}}
\providecommand{\degree}[1]{\renewcommand{\@degree}{#1}}
\providecommand{\school}[1]{\renewcommand{\@school}{#1}}
\providecommand{\college}[1]{\renewcommand{\@college}{#1}}
\providecommand{\university}[1]{\renewcommand{\@university}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% The date does not need the day of the month.
%    \begin{macrocode}
\renewcommand{\today}{\ifcase\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~\number\year}
%    \end{macrocode}
% \begin{macro}{\addsswidth}
% This is used to store the width of the bottom right hand box in title page.
% If it has a non-positive value while the title page is typeset,
% then it will automatically be calculated to be the width of the text.
% If it has a positive value while the title page is typeset,
% then it will be the fixed width of the box.
%    \begin{macrocode}
\newlength{\addsswidth}
\setlength{\addsswidth}{\z@}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\bt@adjusti}
% \begin{macro}{\bt@adjustii}
% \begin{macro}{\bt@adjustiii}
% We have a couple of fine adjustments to the dimension
% that I can't figure out how to do in general.
% So I did some testing manually to determine the adjustments.
% They are to do with distances between lines,
% These distances needs to be different for different fonts and different font sizes.
%    \begin{macrocode}
\newlength{\bt@adjusti}
\newlength{\bt@adjustii}
\newlength{\bt@adjustiii}
%    \end{macrocode}
% The following measurements are obtained by trial-and-error.
% If neither \pkg{tgtermes} nor \pkg{mathptmx} is loaded,
% then I assume the document is using the standard fonts of \LaTeX.
% I also assume the title page is single spaced,
% e.g.,~the option \opt{alldoublespace} is not loaded.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{tgtermes}
   {\setlength{\bt@adjusti}{-.457\baselineskip}
    \setlength{\bt@adjustii}{-.029\baselineskip}
    \setlength{\bt@adjustiii}{-.340\baselineskip}}
   {\@ifpackageloaded{mathptmx}
    {\setlength{\bt@adjusti}{-.454\baselineskip}
     \setlength{\bt@adjustii}{-.039\baselineskip}
     \setlength{\bt@adjustiii}{-.332\baselineskip}}
    {\setlength{\bt@adjusti}{-.430\baselineskip}
     \setlength{\bt@adjustii}{-.027\baselineskip}
     \setlength{\bt@adjustiii}{-.321\baselineskip}}}}
%    \end{macrocode}
% Hopefully one day I will find a cleaner way to do this.
% Before I manage to do that,
% this piece of code will help us adapt to a few situations.
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\maketitle}
% This is how one makes the title page.
%    \begin{macrocode}
\renewcommand{\maketitle}{%
  \checkorder{1}\setcounter{currpart}{1}%
  \begin{titlepage}%
%    \end{macrocode}
% I decided to make the whole title page single-spaced.
%    \begin{macrocode}
  \optsinglespacing
%    \end{macrocode}
% These are from the original \cmd{\maketitle}.
%    \begin{macrocode}
  \let\footnotesize\small
  \let\footnoterule\relax
  \let\footnote\thanks
%    \end{macrocode}
% We need no justification.  The title will be \cmd{\LARGE}.
%    \begin{macrocode}
  \raggedright\LARGE%
%    \end{macrocode}
% The top margin is $3\,\cm$ wide,
% and so we need an extra $3\,\cm$ to make up $6\,\cm$.
% The length \cmd{\bt@adjusti} is the adjustment needed to make exactly $6\,\cm$ on the screen.
%    \begin{macrocode}
  \rule{0cm}{3cm}\\[\bt@adjusti]%
%    \end{macrocode}
% This is adopted from \file{adfathesis.cls}~\cite{web:adfa} so as to allow
% \cmd{\thanks} when doing \cmd{\uppercase}.
% Again, the lengths \cmd{\bt@adjustii} and \cmd{\bt@adjustiii} are the adjustments needed
% to make exactly $5\,\cm$ between the author name and the `submission statement'.
%    \begin{macrocode}
  \uppercase\expandafter{\@title}%
   \if@alldoublespace\\[.2\baselineskip]\else\\[\baselineskip]\fi
  {\large by}%
   \if@alldoublespace\\[.2\baselineskip]\else\\[\baselineskip]\fi
  \uppercase\expandafter{\@author}\\[\bt@adjustii]
  \rule{0cm}{5cm}\\[\bt@adjustiii]
  \large\noindent\@submissionstatement\\
  \MakeUppercase{\@degree}
  \vfill
%    \end{macrocode}
% We then calculate \cmd{\addsswidth} if it is not specified.
% It will be the maximum of the widths of
% \cmd{\@school}, \cmd{\@university} and \cmd{\@date}.
% I need to disable the footnotes first
% so that they don't interfere with the calculations.
%    \begin{macrocode}
  \ifdim\addsswidth>\z@\else%  %%
   \let\@tempcmd\thanks
   \renewcommand\thanks[1]{\footnotemark}
   \renewcommand\footnote[1]{\footnotemark}
   \settowidth{\addsswidth}{\@school}%
   \sbox\@tempboxa{\@college}%
   \ifdim\wd\@tempboxa>\addsswidth%
    \settowidth{\addsswidth}{\@college}%
   \fi
   \sbox\@tempboxa{\@university}%
   \ifdim\wd\@tempboxa>\addsswidth%
    \settowidth{\addsswidth}{\@university}%
   \fi
   \sbox\@tempboxa{\@date}%
   \ifdim\wd\@tempboxa>\addsswidth%
    \settowidth{\addsswidth}{\@date}%
   \fi
   \let\thanks\@tempcmd
   \let\footnote\@tempcmd
  \fi
%    \end{macrocode}
% Then output the bottom-right box.
%    \begin{macrocode}
  \begin{flushright}\begin{minipage}{\addsswidth}%
   \raggedright\large
   \@school\\
   \@college\\
   \@university\\
   \@date
  \end{minipage}\end{flushright}\par
  \@thanks
  \vfil\null
  \end{titlepage}%
  \setcounter{footnote}{0}%
  \@titleexiststrue%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
%    \end{macrocode}
% I just follow what is done in \file{report.cls}.
% They say this saves memory.
%    \begin{macrocode}
  \global\let\@submissionstatement\@empty
  \global\let\@degree\@empty
  \global\let\@college\@empty
  \global\let\@school\@empty
  \global\let\@university\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\submissionstatement\relax
  \global\let\degree\relax
  \global\let\school\relax
  \global\let\university\relax
  \global\let\and\relax
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
% \begin{environment}{abstract}
% The only extra thing that we want to do in the abstract environment
% is to keep track of the order of things.
% All other things are the same as in \file{report.cls}.
%    \begin{macrocode}
%<*class>
\renewenvironment{abstract}{%
    \global\@abstractexiststrue%
%    \end{macrocode}
% Why is \cmd{\global} needed?
%    \begin{macrocode}
    \checkorder{2}\setcounter{currpart}{2}%
    \titlepage
    \null\vfil
    \@beginparpenalty\@lowpenalty
    \begin{center}%
      \bfseries \abstractname
      \@endparpenalty\@M
    \end{center}}%
   {\par\vfil\null\endtitlepage}
%</class>
%<*package>
\ifx\abstract\@undefined%
 \providecommand{\abstractname}{Abstract}
 \@ifclassloaded{book}
   {\newenvironment{abstract}{\chapter*{\abstractname}}{}}
   {\newenvironment{abstract}{\section*{\abstractname}}{}}
\fi
%</package>
%    \end{macrocode}
% \end{environment}
% \begin{environment}{dedication}
% \begin{macro}{\dedwidth}
% \begin{macro}{\dedabove}
% \begin{macro}{\dedbelow}
% Next, we program the dedication part.
% \cmd{\dedwidth} stores the width of the dedication.
% \cmd{\dedabove} and \cmd{\dedbelow} are respectively
% the proportions of white space above and below the dedication.
%    \begin{macrocode}
%<*class>
\newlength{\dedwidth}
\setlength{\dedwidth}{.5\textwidth}
\newcommand{\dedabove}{3}
\newcommand{\dedbelow}{8}
%</class>
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% I actually don't care what happens when the document is in two-column mode,
% because (anything close to) a thesis is not supposed to be in two columns.
% However, it seems there is something I can copy from \file{report.cls},
% which stops the two-column mode temporarily; so why not?
% Actually it may be cleaner just to use a title page.
%    \begin{macrocode}
%<*class>
\newenvironment{dedication}
 {\if@twocolumn%
   \@restonecoltrue\onecolumn%
  \else%
   \@restonecolfalse\newpage%
  \fi%
  \checkorder{3}\setcounter{currpart}{3}%
  \if@openright\cleardoublepage\else\clearpage\fi
  \null\vspace*{\stretch{\dedabove}}%
  \begin{center}\begin{minipage}{\dedwidth}\raggedright}%
 {\end{minipage}\end{center}\vspace*{\stretch{\dedbelow}}\null%
  \if@restonecol\twocolumn \else \newpage \fi}
%</class>
%<*package>
\ifx\dedication\@undefined%
 \@ifclassloaded{book}
   {\newenvironment{dedication}{\chapter*{Dedication}}{}}
   {\@ifclassloaded{report}
      {\newenvironment{dedication}{\chapter*{Dedication}}{}}
      {\newenvironment{dedication}{\section*{Dedication}}{}}}
\fi
%</package>
%    \end{macrocode}
% \end{environment}
% \begin{environment}{acknowledgements}
% Acknowledgements are simpler,
% and I may still take care of two-column documents.
%    \begin{macrocode}
%<*class>
\newenvironment{acknowledgements}
 {\if@twocolumn%
   \@restonecoltrue\onecolumn%
  \else%
   \@restonecolfalse\newpage%
  \fi%
  \checkorder{4}\setcounter{currpart}{4}%
  \chapter*{\acknowname}}
 {\if@restonecol\twocolumn \else \newpage \fi}
%</class>
%<*package>
\ifx\acknowledgements\@undefined%
 \@ifclassloaded{book}
   {\newenvironment{acknowledgements}{\chapter*{\acknowname}}{}}
   {\@ifclassloaded{report}
      {\newenvironment{acknowledgements}{\chapter*{\acknowname}}{}}
      {\newenvironment{acknowledgements}{\section*{\acknowname}}{}}}
\fi
%</package>
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% \begin{macro}{\tableofcontents}
% Next, we look at the table of contents.
% The only thing to change is to add commands to check order.
% We even need to have double spacing in the table of contents!
% The remaining is all from \file{report.sty}.
%    \begin{macrocode}
\renewcommand{\tableofcontents}{\@tocexiststrue%
    \checkorder{5}\setcounter{currpart}{5}%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname
        \@mkboth{%
           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\listoffigures}
% \begin{macro}{\listoftables}
% Similarly, we modify \cmd{\listoffigures} and \cmd{\listoftables}.
%    \begin{macrocode}
\renewcommand{\listoffigures}{%
    \checkorder{6}\setcounter{currpart}{6}%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listfigurename}%
      \@mkboth{\MakeUppercase\listfigurename}%
              {\MakeUppercase\listfigurename}%
    \@starttoc{lof}%
    \if@restonecol\twocolumn\fi
    }
\renewcommand{\listoftables}{%
    \checkorder{7}\setcounter{currpart}{7}%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listtablename}%
      \@mkboth{%
          \MakeUppercase\listtablename}%
         {\MakeUppercase\listtablename}%
    \@starttoc{lot}%
    \if@restonecol\twocolumn\fi
    }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
% \begin{macro}{\toclineappendix}\changes{v3.3}{2009/12/26}{Command added.}%
% \begin{macro}{\prefixappendix}\changes{v3.3}{2009/12/26}{Command added.}%
% \begin{macro}{\prefixappendixoff}\changes{v3.3}{2009/12/26}{Command added.}%
% We make some commands to allow the user to configure
% how the appendix looks like in the table of contents.
%    \begin{macrocode}
%<*class>
\newcommand{\toclineappendix}{\@apxlinetrue}
\newcommand{\prefixappendix}{\@apxprefixtrue}
\newcommand{\prefixappendixoff}{\@apxprefixfalse}
%</class>
%<*package>
\providecommand{\toclineappendix}{\relax}
\providecommand{\prefixappendix}{\relax}
\providecommand{\prefixappendixoff}{\@apxprefixfalse}
%</package>
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% \begin{macro}{\appendix}\changes{v3.3}{2009/12/26}{Contents line added.}
% \cmd{\appendix} needs to be modified
% for order checking and for the table of contents.
%    \begin{macrocode}
\renewcommand{\appendix}{%
  \checkorder{10}\setcounter{currpart}{10}
  \if@apxline%
   \addtocontents{toc}{\protect\contentsline {chapter}{\appendixname}{}}
  \fi\par
  \setcounter{chapter}{0}%
  \setcounter{section}{0}%
  \gdef\@chapapp{\appendixname}%
  \gdef\thechapter{\@Alph\c@chapter}}
%    \end{macrocode}
% \end{macro}
% \begin{environment}{thebibliography}
% In addition to checking the order of things,
% \emph{within items} in the bibliography are made single-spaced
% because this is allowed by the thesis requirements.
% Spacing between items is still `doubled'.
%    \begin{macrocode}
\renewenvironment{thebibliography}[1]
     {\checkorder{11}\setcounter{currpart}{11}%
      \begin{optsinglespace}%
      \chapter*{\bibname}%
      \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m%
      \if@nodoublespace\else%
       \if@alldoublespace\else%
        \addtolength{\itemsep}{\baselineskip}
       \fi
      \fi}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist\end{optsinglespace}}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{theindex}
% As hinted by the thesis requirements, theses should have no index.
% I see no reason to stop one from making one though.
% I will, however, issue a warning message.
%    \begin{macrocode}
\renewenvironment{theindex}
               {\checkorder{12}\setcounter{currpart}{12}%
                \if@twocolumn
                  \@restonecolfalse
                \else
                  \@restonecoltrue
                \fi
                \columnseprule \z@
                \columnsep 35\p@
                \twocolumn[\@makeschapterhead{\indexname}]%
                \@mkboth{\MakeUppercase\indexname}%
                        {\MakeUppercase\indexname}%
                \thispagestyle{plain}\parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem}
               {\if@restonecol\onecolumn\else\clearpage\fi%
                \ClassWarningNoLine{bhamthesis}%
                 {No index should exist in theses}}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%
% \subsection{Contents and ordering of the thesis}
% \begin{macro}{\namepart}
% Starting from~$0$, this sets the mnemonics for the names of parts.
%    \begin{macrocode}
%<*class>
\newcommand{\namepart}[1]%
 {\ifcase#1 Very Beginning\or Title Page\or
  \abstractname\or Dedication\or \acknowname\or \contentsname\or
  \listfigurename\or \listtablename\or List of Definitions and
  Abbreviations\or Main Text\or \appendixname\or \bibname\or
  \indexname\fi}
%</class>
%<*package>
\providecommand{\namepart}[1]{\relax}
%</package>
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% This is a counter that keeps track of where we are.
%    \begin{macrocode}
\newcounter{currpart}
\setcounter{currpart}{0}
%    \end{macrocode}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
% \begin{macro}{\checkorder}
% This is used to check if everything is in order.
%    \begin{macrocode}
%<*class>
\newcommand{\checkorder}[1]
  {\ifnum#1<\value{currpart}%
    \ClassWarningNoLine{bhamthesis}%
     {The \namepart{#1} should not
      come after the \namepart{\value{currpart}}}%
   \else\ifnum#1=\value{currpart}%
       \ClassWarningNoLine{bhamthesis}{There are two \namepart{#1}'s}%
     \fi%
   \fi}
%</class>
%<*package>
\providecommand{\checkorder}[1]{\relax}
%</package>
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% \begin{macro}{\if@titleexists}
% \begin{macro}{\if@abstractexists}
% \begin{macro}{\if@tocexists}
% \begin{macro}{\if@mainexists}
% \begin{macro}{\if@frontexists}
% These are flags for checking the mandatory parts of the thesis exist.
%    \begin{macrocode}
\newif\if@titleexists \@titleexistsfalse
\newif\if@abstractexists \@abstractexistsfalse
\newif\if@tocexists \@tocexistsfalse
\newif\if@mainexists \@mainexistsfalse
\newif\if@frontexists \@frontexistsfalse
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\if@pagenumber}
% An extra flag is needed to keep track of when to print page numbers.
% This seems unnecessary but \LaTeX\ changes \cmd{\pagestyle}s
% at places that I can't (or don't want to) control.
%    \begin{macrocode}
\newif\if@pagenumber \@pagenumbertrue
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
% \begin{macro}{\frontmatter}\changes{v3.3}{2009/12/26}{Warning added.}
% \begin{macro}{\mainmatter}
% \begin{macro}{\backmatter}
% These are for separating the chunks of the thesis that needs
% different formatting, e.g., page numberings.
% All of them are taken from the standard \LaTeX\ \file{book.cls}.
%    \begin{macrocode}
%<*class>
\newcommand{\frontmatter}{%
  \cleardoublepage
  \@pagenumberfalse
  \pagenumbering{roman}%
  \pagestyle{empty}%
  \@frontexiststrue%
  \ifnum\value{currpart}=0\else%
    \ClassWarningNoLine{bhamthesis}%
     {Please put \noexpand\frontmatter before everything}%
  \fi}%
\newcommand{\mainmatter}{%
    \cleardoublepage
  \@pagenumbertrue
  \pagenumbering{arabic}%
  \pagestyle{plain}%
  \@mainexiststrue%
  \checkorder{9}\setcounter{currpart}{9}}
%    \end{macrocode}
% \cmd{\backmatter} does not do anything at the moment.
% So I don't even check whether it is in the right place.
%    \begin{macrocode}
\newcommand{\backmatter}{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \@pagenumbertrue}
%</class>
%<*package>
\providecommand{\frontmatter}{\relax}
\providecommand{\mainmatter}{\relax}
\providecommand{\backmatter}{\relax}
%</package>
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% We check if there is a title page (at the end).
%    \begin{macrocode}
\AtEndDocument{%
 \if@titleexists\else%
  \ClassWarningNoLine{bhamthesis}{Remember to include a \namepart{1}}%
 \fi}
%    \end{macrocode}
% We check if there is an abstract.
%    \begin{macrocode}
\AtEndDocument{%
 \if@abstractexists\else%
  \ClassWarningNoLine{bhamthesis}{Remember to include a \namepart{2}}%
 \fi}
%    \end{macrocode}
% We check if there is a table of contents.
%    \begin{macrocode}
\AtEndDocument{%
 \if@tocexists\else%
  \ClassWarningNoLine{bhamthesis}{Remember to include a \namepart{5}}%
 \fi}
%    \end{macrocode}
% We check if there are frontmatter and main text.
%    \begin{macrocode}
\AtEndDocument{%
 \if@frontexists%
  \if@mainexists\else%
%    \end{macrocode}
% This case is with frontmatter but no main text.
%    \begin{macrocode}
   \ClassWarningNoLine{bhamthesis}%
    {Remember to use \noexpand\mainmatter to activate page numbering}%
  \fi
 \else
  \if@mainexists%
%    \end{macrocode}
% This case is with no frontmatter but with main text.
%    \begin{macrocode}
   \ClassWarningNoLine{bhamthesis}%
    {Remember to use \noexpand\frontmatter to suppress page numbering}%
  \else
%    \end{macrocode}
% This case is without frontmatter and main text.
%    \begin{macrocode}
   \ClassWarningNoLine{bhamthesis}%
    {Remember to use \noexpand\frontmatter and \noexpand\mainmatter
     to tweak page numbering}%
  \fi%
 \fi}
%    \end{macrocode}
% All these are done at the end of the document.
%
%
% \subsection{Style of the thesis}
% Set double spacing using \pkg{setspace}.
%    \begin{macrocode}
\if@nodoublespace\else\doublespacing\fi
%    \end{macrocode}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
% \begin{environment}{display}
% \begin{environment}{displaypar}
% We then need to return to single spacing at appropriate places.
% However, sometimes one may need to stick to double spacing in these environments.
% So we store the originals under different names.
%    \begin{macrocode}
%<*class>
\let\display\quote
\let\enddisplay\endquote
\let\displaypar\quotation
\let\enddisplaypar\endquotation
%</class>
%<*package>
\ifx\display\@undefined%
 \newenvironment{display}{\begin{quote}}{\end{quote}}
\fi
\ifx\displaypar\@undefined%
 \newenvironment{displaypar}{\begin{quotation}}{\end{quotation}}
\fi
%</package>
%    \end{macrocode}
% \end{environment}
% \end{environment}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% \begin{environment}{quotation}\changes{v3.3}{2009/12/26}{Spacing problem fixed.}
% \begin{environment}{quote}\changes{v3.3}{2009/12/26}{Spacing problem fixed.}
% The line spacing commands used are taken from \file{setspace.sty}.
%    \begin{macrocode}
\renewenvironment{quotation}
               {\list{}{\listparindent 1.5em%
                        \itemindent    \listparindent
                        \rightmargin   \leftmargin
                        \parsep        \z@ \@plus\p@}%
                \item\relax
                \begin{optsinglespace}}
               {\end{optsinglespace}\endlist}
\renewenvironment{quote}
               {\list{}{\rightmargin\leftmargin}%
                \item\relax
                \begin{optsinglespace}}
               {\end{optsinglespace}\endlist}
%    \end{macrocode}
% \end{environment}
% \end{environment}
% Make footnote numbering reset on each page using \pkg{perpage}.
%    \begin{macrocode}
\MakePerPage{footnote}
%    \end{macrocode}
% Footnotes are automatically single-spaced as preset by \pkg{setspace}.
%
% \begin{macro}{\chapter}
% We then tweak chapter headings.
% Firstly, we need to make sure page numbers disappear when they should.
% Here is where we use the dirty flag \cs{if@pagenumber}.
% There must be a better way to do it.
%    \begin{macrocode}
\renewcommand{\chapter}%
 {\if@openright\cleardoublepage\else\clearpage\fi
  \if@pagenumber\thispagestyle{plain}\else\thispagestyle{empty}\fi
  \global\@topnum\z@
  \@afterindentfalse
  \secdef\@chapter\@schapter}
%    \end{macrocode}
% \begin{macro}{\@chapter}\changes{v3.3}{2009/12/26}{Command modified.}
% We need to change \cmd{\@chapter} for the appendix prefix.
% I am too lazy to find out how to change \cs{def} to \cs{renewcommand}.
%    \begin{macrocode}
\def\@chapter[#1]#2{%
 \ifnum \c@secnumdepth >\m@ne
  \refstepcounter{chapter}%
  \typeout{\@chapapp\space\thechapter.}%
  \ifnum\value{currpart}=10%
%    \end{macrocode}
% The the \cmd{\appendixname} has already gone into the contents page in a new line,
% then no prefix is added.
%    \begin{macrocode}
   \if@apxline%
    \addcontentsline{toc}{chapter}%
              {\protect\numberline{\thechapter}#1}%
   \else%
    \if@apxprefix%
     \addcontentsline{toc}{chapter}{\appendixname\nobreakspace\thechapter: #1}%
    \else%
     \addcontentsline{toc}{chapter}%
               {\protect\numberline{\thechapter}#1}%
    \fi%
   \fi%
  \else%
   \addcontentsline{toc}{chapter}%
             {\protect\numberline{\thechapter}#1}%
  \fi%
%    \end{macrocode}
% The rest is copied from \file{report.cls}.
%    \begin{macrocode}
 \else
  \addcontentsline{toc}{chapter}{#1}%
 \fi
 \chaptermark{#1}%
 \addtocontents{lof}{\protect\addvspace{10\p@}}%
 \addtocontents{lot}{\protect\addvspace{10\p@}}%
 \if@twocolumn
   \@topnewpage[\@makechapterhead{#2}]%
 \else
   \@makechapterhead{#2}%
   \@afterheading
 \fi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@makechapterhead}
% \begin{macro}{\@makeschapterhead}
% The chapter heads should be in upper case and centred.
% Within chapter titles, single spacing is used.
% I am really not sure whether the \cmd{\Large} and \cmd{\centering}
% should be put outside the \env{optsinglespace} environments,
% but I don't seem to have a choice.
% We need to take care of the `plain form' and the `starred form' separately.
%    \begin{macrocode}
\renewcommand{\@makechapterhead}[1]{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
%    \end{macrocode}
% This is the chapter number.
%    \begin{macrocode}
    \ifnum \c@secnumdepth >\m@ne
        \Large\centering
        \begin{optsinglespace}%
         \MakeUppercase{\@chapapp\space \thechapter}%
        \end{optsinglespace}%
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
%    \end{macrocode}
% This is the chapter title.
%    \begin{macrocode}
    \LARGE\centering
    \begin{optsinglespace}%
     \MakeUppercase{#1}%
    \end{optsinglespace}%
    \par\nobreak
    \vskip 40\p@
  }}
%    \end{macrocode}
% This is for unnumbered chapters.
% If we are in the appendix, then we always show the word \cmd{\appendixname}.%
% \changes{v3.3}{2009/12/26}{The word \cmd{\appendixname} added.}
%    \begin{macrocode}
\renewcommand{\@makeschapterhead}[1]{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum\value{currpart}=10%
        \Large\centering
        \begin{optsinglespace}%
         \MakeUppercase{\@chapapp}%
        \end{optsinglespace}%
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \LARGE\centering
    \begin{optsinglespace}%
     \MakeUppercase{#1}%
    \end{optsinglespace}%
    \par\nobreak
    \vskip 40\p@
  }}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\@schapter}\changes{v3.3}{2009/12/26}{\cmd{\if@apxprefix} added.}
% but if it is the only chapter in the appendix, then according the rules,
% we don't need to assign a number to it, but it has to be listed in the table of contents.
% In addition, I want the list of references to appear in the table of contents too.
%    \begin{macrocode}
\renewcommand{\@schapter}[1]{%
%    \end{macrocode}
% Firstly, I need to explicitly force the list of references to appear in the table of contents
% because standard \LaTeX\ does not put unnumbered chapters on the contents page.
% Recall that 11 means the list of references.
%    \begin{macrocode}
  \ifnum\value{currpart}=11%
   \addcontentsline{toc}{chapter}{#1}%
  \else%
%    \end{macrocode}
% Secondly, unnumbered chapters in the appendix need to go to the table of contents too.
% If \cmd{\@apxprefix} is set to true \emph{but if \cmd{\@apxline} is not},
% then \cmd{\appendixname} is added before the chapter title in the contents page.
% The second condition is there to avoid too many \cmd{\appendixname} to go onto the contents page.
% Recall 10 means the appendix.
% The \cs{protect} is only there to make the \file{toc} file look more tidy.
%    \begin{macrocode}
   \ifnum\value{currpart}=10%
    \if@apxline%
     \addcontentsline{toc}{chapter}{#1}%
    \else%
     \if@apxprefix%
      \addcontentsline{toc}{chapter}{\protect\appendixname: #1}%
     \else%
      \addcontentsline{toc}{chapter}{#1}%
     \fi%
    \fi%
   \fi%
  \fi%
  \if@twocolumn
   \@topnewpage[\@makeschapterhead{#1}]%
  \else
   \@makeschapterhead{#1}%
   \@afterheading
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\@sect}
% \begin{macro}{\@ssect}
% As for chapter titles, I want to return to single spacing in section titles.
% I have added four \cmd{\singlespacing} into the definitions of \cmd{\@sect} and \cmd{\@ssect},
% which are taken from \file{latex.ltx}.
% \emph{I have no idea what these commands do.}
% I just tried out where to put my \cmd{\singlespacing}s,
% and since they \emph{seem} to give what I want, I am happy.
% \emph{They may well be in the wrong places.}
% If you discover so, please let me know.
%    \begin{macrocode}
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \protected@edef\@svsec{\@seccntformat{#1}\relax}%
  \fi
  \@tempskipa #5\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #6{\optsinglespacing%
        \@hangfrom{\hskip #3\relax\@svsec}%
          \interlinepenalty \@M #8\@@par}%
    \endgroup
    \csname #1mark\endcsname{#7}%
    \addcontentsline{toc}{#1}{%
      \ifnum #2>\c@secnumdepth \else
        \protect\numberline{\csname the#1\endcsname}%
      \fi
      #7}%
  \else
    \def\@svsechd{%
      #6{\optsinglespacing\hskip #3\relax
      \@svsec #8}%
      \csname #1mark\endcsname{#7}%
      \addcontentsline{toc}{#1}{%
        \ifnum #2>\c@secnumdepth \else
          \protect\numberline{\csname the#1\endcsname}%
        \fi
        #7}}%
  \fi
  \@xsect{#5}}
\def\@ssect#1#2#3#4#5{%
  \@tempskipa #3\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #4{\optsinglespacing%
        \@hangfrom{\hskip #1}%
          \interlinepenalty \@M #5\@@par}%
    \endgroup
  \else
    \def\@svsechd{#4{\optsinglespacing\hskip #1\relax #5}}%
  \fi
  \@xsect{#3}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%
% Here are some new environments for page-size floats.
% According to the thesis requirements,
% we need at least $4\,\cm$ of binding margin on such pages,
% which is $1\,\cm$ more than a usual page.
% The caption also needs to be put in a different place.
%
% To prevent unwanted floats to go onto a new page,
% one can increase \cmd{\floatpagefraction},
% which is the minimum proportion of the float(s) needed to start a new page.
% The following is a maximum of this value, correct to 8~d.p.,
% that one can use without affecting \env{figurepage} and \env{tablepage}.
% It is found by trial and error.
%    \begin{macrocode}
%<*class|package>
\iffalse
 \renewcommand{\floatpagefraction}{0.99999237}
\fi
%</class|package>
%    \end{macrocode}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% \begin{macro}{\captiontext}
% \cmd{\captiontext} holds the text in the caption.
%    \begin{macrocode}
\newcommand{\captiontext}{\@empty}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pl@tewidth}
% \begin{macro}{\plateextramar}
% \cmd{\pl@tewidth} is meant to hold the width of the plate,
% while \cmd{\plateextramar} stores the extra margin needed on the left.
% Some user may want to change \cmd{\textwidth} in the preamble.
% So I set \cmd{\pl@tewidth} at the beginning of the document.
%    \begin{macrocode}
\newlength{\pl@tewidth}
\AtBeginDocument{\setlength{\pl@tewidth}  {\textwidth}
                 \addtolength{\pl@tewidth}{-\plateextramar}}
\newlength{\plateextramar}
\setlength{\plateextramar}{1cm}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\giveflo@tnum}
% According to the regulations, in page-size floats,
% the number has to be placed above the float,
% and the caption has to be place below.
% I chose to number all such floats.
% The caption will be optional (for \clsname).
% This is done by redefining \cmd{\caption},
% and using separate commands for showing the numbering and the caption.
% The following commands are modified from \cmd{\caption} and \cmd{\@caption} in \file{latex.ltx}.
%    \begin{macrocode}
\newcommand{\giveflo@tnum}{%
   \refstepcounter\@captype
   \expandafter\@firstofone
   \par
   \begingroup
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
   \normalsize
   \@makepagecaption{\csname fnum@\@captype\endcsname}\par
   \endgroup}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\giveflo@tcaption}
% We try not to do anything silly if no caption is given.
%    \begin{macrocode}
\newcommand{\giveflo@tcaption}{%
 \if\captiontext\@empty\else%
  \@makepagecaption{\captiontext}%
 \fi%
 \addcontentsline{\csname ext@\@captype\endcsname}{\@captype}%
   {\protect\numberline{\csname the\@captype\endcsname}%
   {\ignorespaces \captiontext}}
 \renewcommand\captiontext\@empty}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@makepagecaption}
% The following is modified from \cmd{\@makecaption}.
%    \begin{macrocode}
\newcommand{\@makepagecaption}[1]{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#1}%
  \ifdim \wd\@tempboxa >\hsize
    #1\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
% \begin{environment}{figurepage}
% \env{figurepage} and \env{tablepage} put the floats onto separate pages and add margins.
%    \begin{macrocode}
\newenvironment{figurepage}
%    \end{macrocode}
% \cmd{\caption} is redefined locally only so that
% its behaviour outside this environment is not affected.
%    \begin{macrocode}
  {\renewcommand{\caption}[1]%
    {\renewcommand{\captiontext}{{}##1}}%
%    \end{macrocode}
% This float is recommended to go on a float-page.
%    \begin{macrocode}
   \@float{figure}[p]%
%    \end{macrocode}
% To increase the left margin,
% we make an empty box of width \cmd{\plateextramar} and height \cmd{\textwidth},
% and ensure that the box lines up correctly with the \env{minipage} that comes afterwards.
% This also (hopefully) forces the float to go onto a new page and stay on its own.
%    \begin{macrocode}
   \makebox[\plateextramar][l]%
    {\rule[-.5\textheight]%
     {\z@}{\textheight}}%
%    \end{macrocode}
% Everything in the float goes into this \env{minipage} of the right width.
%    \begin{macrocode}
   \begin{minipage}[c]{\pl@tewidth}%
%    \end{macrocode}
% No matter what happens, I give the float a number.
%    \begin{macrocode}
   \giveflo@tnum}%
  {\giveflo@tcaption%
   \end{minipage}%
   \end@float}
%    \end{macrocode}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%    \begin{macrocode}
\ifx\figurepage\@undefined%
 \newenvironment{figurepage}
  {\begin{figure}[p]}{\end{figure}}%
\fi
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \end{environment}
% \begin{environment}{tablepage}
% What happens in \env{tablepage} is analogous.
%    \begin{macrocode}
%<*class>
%    \end{macrocode}
%    \begin{macrocode}
\newenvironment{tablepage}
  {\renewcommand{\caption}[1]%
    {\renewcommand{\captiontext}{{}##1}}%
   \@float{table}[p]%
   \makebox[\plateextramar][l]%
    {\rule[-.5\textheight]%
     {\z@}{\textheight}}%
   \begin{minipage}{\pl@tewidth}%
   \giveflo@tnum}%
  {\giveflo@tcaption%
   \end{minipage}%
   \end@float}
%    \end{macrocode}
%    \begin{macrocode}
%</class>
%    \end{macrocode}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%    \begin{macrocode}
\ifx\figurepage\@undefined%
 \newenvironment{tablepage}
  {\begin{table}[p]}{\end{table}}%
\fi
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \end{environment}
%
% \subsection{Some support in \file{bhamthesis.sty}}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% We finally add some support in the \pkgname\ package
% for the external packages loaded in \clsname.
% This first line will hopefully prevents the (first) absence of \pkg{perpage} to interrupt \TeX{}ing.
% I can't put it at the beginning of the document
% because they will (probably) go after the \file{aux} file,
% which is too late.
%    \begin{macrocode}
\providecommand{\pp@pagectr}[4]{\relax}
%    \end{macrocode}
% I delay all the remaining definitions to the end
% in case they are loaded in between by the user.
%    \begin{macrocode}
\AtBeginDocument{%
  \providecommand{\singlespacing}{\relax}
  \providecommand{\onehalfspacing}{\relax}
  \providecommand{\doublespacing}{\relax}
  \ifx\singlespace\@undefined%
   \newenvironment{singlespace}{\relax}{\relax}%
  \fi
  \ifx\onehalfspace\@undefined%
   \newenvironment{onehalfspace}{\relax}{\relax}%
  \fi
  \ifx\doublespace\@undefined%
   \newenvironment{doublespace}{\relax}{\relax}%
  \fi}
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \Finale
\endinput
