summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/exam-n
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/exam-n
Initial commit
Diffstat (limited to 'macros/latex/contrib/exam-n')
-rw-r--r--macros/latex/contrib/exam-n/A1.clo82
-rw-r--r--macros/latex/contrib/exam-n/README69
-rw-r--r--macros/latex/contrib/exam-n/README.ctan3
-rw-r--r--macros/latex/contrib/exam-n/exam-n.dtx3213
-rw-r--r--macros/latex/contrib/exam-n/exam-n.html163
-rw-r--r--macros/latex/contrib/exam-n/exam-n.ins15
-rw-r--r--macros/latex/contrib/exam-n/exam-n.pdfbin0 -> 271514 bytes
-rw-r--r--macros/latex/contrib/exam-n/lppl.txt416
-rw-r--r--macros/latex/contrib/exam-n/notes-for-authors.pdfbin0 -> 228150 bytes
-rw-r--r--macros/latex/contrib/exam-n/notes-for-authors.tex304
-rw-r--r--macros/latex/contrib/exam-n/release-notes.html340
-rw-r--r--macros/latex/contrib/exam-n/sample/Makefile23
-rw-r--r--macros/latex/contrib/exam-n/sample/cosmo1.tex93
-rw-r--r--macros/latex/contrib/exam-n/sample/cosmo2.tex60
-rw-r--r--macros/latex/contrib/exam-n/sample/cosmo3.tex50
-rw-r--r--macros/latex/contrib/exam-n/sample/dynamical1.tex96
-rw-r--r--macros/latex/contrib/exam-n/sample/dynamical2.tex24
-rw-r--r--macros/latex/contrib/exam-n/sample/dynamical3.tex59
-rw-r--r--macros/latex/contrib/exam-n/sample/excos1.tex46
-rw-r--r--macros/latex/contrib/exam-n/sample/fig/spiral.eps22
-rw-r--r--macros/latex/contrib/exam-n/sample/fig/spiral.pdfbin0 -> 1799 bytes
-rw-r--r--macros/latex/contrib/exam-n/sample/numerical1-solution.tex21
-rw-r--r--macros/latex/contrib/exam-n/sample/numerical1.tex58
-rw-r--r--macros/latex/contrib/exam-n/sample/numerical2.tex44
-rw-r--r--macros/latex/contrib/exam-n/sample/numerical3.tex46
-rw-r--r--macros/latex/contrib/exam-n/sample/sample_exam.tex65
-rw-r--r--macros/latex/contrib/exam-n/sample/sample_exam_solution.tex65
-rw-r--r--macros/latex/contrib/exam-n/sample/sample_mcq.tex87
-rw-r--r--macros/latex/contrib/exam-n/sample_exam.pdfbin0 -> 192111 bytes
-rw-r--r--macros/latex/contrib/exam-n/sample_exam_solution.pdfbin0 -> 246164 bytes
-rw-r--r--macros/latex/contrib/exam-n/style.css230
31 files changed, 5694 insertions, 0 deletions
diff --git a/macros/latex/contrib/exam-n/A1.clo b/macros/latex/contrib/exam-n/A1.clo
new file mode 100644
index 0000000000..d40b8c26a9
--- /dev/null
+++ b/macros/latex/contrib/exam-n/A1.clo
@@ -0,0 +1,82 @@
+\ProvidesFile{A1.clo}[2016/12/19 1.1.4]
+\typeout{A1 exam options, 1.1.4}
+%%%% Source: Mercurial revision e8a612cb25f4, 2016-12-19 16:49 +0000, tag exam-n-1.1.4 + 0
+%%%% File: A1.clo
+%%%% Copyright 2005--2016, Norman Gray
+%%
+%% 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.
+%% 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 Norman Gray <http://nxg.me.uk>
+%%
+%% This work consists of the files exam-n.dtx and exam-n.ins,
+%% the derived file exam-n.cls,
+%% and the associated *.clo files.
+
+% Nothing here beyond the constants sheet
+\constantssheet{
+\begin{center}
+\def\e{{\rm e}}\def\deg{^\circ}
+\def\dmin{^{\rm m}}
+\def\dsec{^{\rm s}}
+\def\ez{\epsilon_{\rm 0}} % permittivity of free space
+\def\er{\epsilon_{\rm r}} % relative permittivity
+\def\ep{\epsilon} % permittivity
+\def\muz{\mu_{\rm 0}} % permeability of free space
+\def\mur{\mu_{\rm r}} % relative permeability
+\def\me{m_{\rm e}} % mass of the electron
+\def\mprot{m_{\rm p}} % mass of the proton
+\def\az{\a_{\rm 0}} % Bohr radius
+\def\mub{\mu_{\rm B}} % Bohr magneton
+%
+\def\tothe#1{$^{#1}$} % raise to the power #1
+\def\metre{\,{\rm m}}
+\def\kg{\,{\rm kg}}
+\def\sec{\,{\rm s}}
+\def\mm{\,{\rm mm}}
+\def\mol{\,{\rm mol}}
+\def\kelvin{\,{\rm K}}
+\def\joule{\,{\rm J}}
+\def\farad{\,{\rm F}}
+\def\ampere{\,{\rm A}}
+\def\ev{\,{\rm eV}}
+\def\hz{\,{\rm Hz}}
+\def\volt{\,{\rm V}}
+\def\watt{\,{\rm W}}
+\def\newton{\,{\rm N}}
+\def\unit#1{\,{\rm #1}}
+%
+{\Large\textbf{Values of astrophysical constants}}\\[\bigskipamount]
+\begin{tabular}{lll} \hline\\[-1.5ex] % slightly hacky extra space after hline
+ speed of light & $c$ & $2.998\times 10^8 \metre\sec^{-1}$\\
+ gravitational constant & $G$ & $6.673\times10^{-11}\newton\metre^2\kg^{-2}$\\
+ Planck constant & $h$ & $6.626\times10^{-34}\joule\sec$\\
+ Boltzmann constant & $k_{\rm B}$ & $1.381\times10^{-23} \joule\kelvin^{-1}$\\
+ Stefan-Boltzmann constant & $\sigma$ & $5.671\times10^{-8}\watt\metre^{-2}\kelvin^{-4}$\\
+ Rydberg constant & $R_\infty$ &$1.097\times10^{7}\metre^{-1}$\\
+ Avogadro constant & $N_{\rm A}$ & $6.022\times 10^{23}\unit{mol}^{-1}$\\
+ gas constant & $R$ & $8.315 \joule\mol^{-1}\kelvin^{-1}$\\
+ proton mass & $\mprot$ & $1.673\times10^{-27} \kg$\\
+ electron mass & $\me$ & $9.109\times10^{-31} \kg$\\
+ elementary charge & $e$ & $1.602\times 10^{-19}\unit{C}$\\
+ electronvolt & ${\rm eV}$ & $1.602\times 10^{-19}\unit{J}$\\[3pt]
+ astronomical unit & au & $1.496\times10^{11} \metre$\\
+ parsec & pc & $3.086\times10^{16}\metre$\\
+ light year & ly & $9.461\times10^{15} \metre$\\[3pt]
+ solar mass & $M_\odot$ & $1.989\times10^{30} \kg$\\
+ solar radius & $R_\odot$ & $6.960\times10^8 \metre$\\
+ solar luminosity & $L_\odot$ & $3.826\times10^{26}\watt$\\
+ Earth mass & $M_\oplus$ & $5.976\times10^{24} \kg$\\
+ Earth radius & $R_\oplus$ & $6.378\times10^6 \metre$\\
+ obliquity of the ecliptic & $\epsilon$ & $23^\circ\,26'$\\[\medskipamount]
+\hline
+\end{tabular}
+\end{center}
+}
diff --git a/macros/latex/contrib/exam-n/README b/macros/latex/contrib/exam-n/README
new file mode 100644
index 0000000000..a128c336ef
--- /dev/null
+++ b/macros/latex/contrib/exam-n/README
@@ -0,0 +1,69 @@
+
+exam-n: LaTeX class file for exams, version 1.1.4, 2016 December 19.
+====================================
+
+[ Mercurial revision e8a612cb25f4, 2016-12-19 16:49 +0000, tag exam-n-1.1.4 + 0 ]
+
+
+Overview
+--------
+
+The class is designed to be localised to a particular institution's
+exam layout, by a suitably skilled LaTeX hacker. There are three
+possible ways of doing this, in increasing order of sophistication:
+
+ 1. Make suitable adjustments to individual exam `.tex` files; or
+
+ 2. Rename the distributed `exam-n.dtx` file to something more locally
+ suitable, and edit it with suitable changes (search for
+ `%%%CONFIGURE` for hints on where to adjust); or
+
+ 3. Fork the Mercurial repository at
+ [bitbucket](https://bitbucket.org/nxg/exam-n), change the
+ value of the `EXAM-N` variable in the `Makefile`, and then
+ edit the `exam-n.dtx` file. See the comments at the top of the
+ `Makefile`.
+
+In case 2, you _must_ change the name of the `.dtx` file, and in case
+3, you must change the `EXAM-N` variable, to avoid terrible confusion
+(you probably also want to avoid the names of the other exam style
+files at CTAN, since they just might have found their way into your
+TEXINPUTS path).
+
+For general details, talk to Norman Gray <norman@astro.gla.ac.uk>.
+
+This is free software, and you are encouraged to use and adapt it as
+you see fit. Norman can give advice. If, however, you need more
+substantial help with the customisations of option 3 above, or need
+continuing support, then we can surely arrange something more
+elaborate.
+
+With the version 1.1 release, the interface should now be regarded
+as rather stable. However version 1.1 was the first to be released
+outside Glasgow University, so there may be some changes to the
+interface which will emerge with broader use, as well as some bug
+fixes. The interface _may_, therefore, yet change. If you use
+this class to produce exams, it would be wise to include a copy of
+the class file locally, rather than relying on a central version. If
+you need an earlier version of the class, let me know.
+
+
+Documentation
+------------
+
+ * Documentation for question authors is in `notes-for-authors.pdf`.
+ * The full version of the documentation, for 'exam conveners' (or
+ equivalent) is in `exam-n.pdf`. This and the author
+ documentation are built as part of the distribution.
+ * Basic documentation for a LaTeX localiser is in this file (see
+ above), with extra remarks at the top of the `Makefile`.
+
+There are brief release notes in exam-n.html.
+
+
+Distribution and copyright
+--------------------------
+
+Copyright 2005--2016, Norman Gray <http://nxg.me.uk>
+Distributed under the terms of The LaTeX Project Public License (LPPL);
+see the file lppl.txt for details.
diff --git a/macros/latex/contrib/exam-n/README.ctan b/macros/latex/contrib/exam-n/README.ctan
new file mode 100644
index 0000000000..872ae0b92a
--- /dev/null
+++ b/macros/latex/contrib/exam-n/README.ctan
@@ -0,0 +1,3 @@
+On CTAN, this package lives in /macros/latex/contrib/exam-n.
+
+Its canonical CTAN URL is https://www.ctan.org/pkg/exam-n
diff --git a/macros/latex/contrib/exam-n/exam-n.dtx b/macros/latex/contrib/exam-n/exam-n.dtx
new file mode 100644
index 0000000000..043d2c9f7c
--- /dev/null
+++ b/macros/latex/contrib/exam-n/exam-n.dtx
@@ -0,0 +1,3213 @@
+% \iffalse
+% This is exam-n.dtx, which supports formatting exam papers.
+%
+% Generated file : DO NOT EDIT
+%
+%% Release version 1.1.4, 2016 December 19.
+%%
+%%%% File: exam-n.dtx
+%%%% Copyright 2005--2016, Norman Gray
+%%
+%% 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.
+%% 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 Norman Gray <http://nxg.me.uk>
+%%
+%% This work consists of the files exam-n.dtx and exam-n.ins,
+%% the derived file exam-n.cls,
+%% and the associated *.clo files.
+
+%<+package|driver|example>%%%% Source: Mercurial revision e8a612cb25f4, 2016-12-19 16:49 +0000, tag exam-n-1.1.4 + 0
+%%
+%<*package|driver>
+
+%</package|driver>
+%<+package>\NeedsTeXFormat{LaTeX2e}
+%<+package>\ProvidesClass{exam-n}[2016/12/19 1.1.4]
+%<+package>\typeout{Class: `exam-n 1.1.4 <2016/12/19>}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\title{exam-n: exam papers}
+\author{Norman Gray\\(\texttt{norman@astro.gla.ac.uk})}
+\date{Release 1.1.4}
+\usepackage{url}
+\newcommand\Lopt[1]{\textsf {#1}} % options
+\newcommand\file[1]{\texttt {#1}}
+\newcommand\Lcount[1]{\textsl {\small#1}}
+\newcommand\Lenv[1]{\texttt{\{#1\}}} %environments
+\newcommand\Lpackage[1]{\{\textsf{#1}\}} %packages
+%Make command strings easier to write
+%{\catcode`\<=\active \gdef<#1>{\meta{#1}}}
+{\catcode`\<=\active
+ \gdef<#1>{{\ensuremath\langle\normalfont\textsl{#1}\ensuremath\rangle}}}
+\def\cmd{\begingroup
+ \catcode`\\=12 \catcode`\{=12 \catcode`\}=12
+ \catcode`\<=\active \catcode`\|=12
+ \docmd}
+\def\docmd|#1|{\texttt{#1}\endgroup}
+%%% \url macro (url.sty does this better)
+%\def\setpathdots{\discretionary{.}{}{.}}
+%\def\setpathslash{\discretionary{/}{}{/}}
+%{\catcode`\.=\active
+% \catcode`\/=\active
+% \gdef\pathcats{%
+% \catcode`\%=12 \catcode`\~=12
+% \catcode`\.=\active \let.\setpathdots
+% \catcode`\/=\active \let/\setpathslash
+% \catcode`\#=12 \catcode`\_=12}%
+% }
+%\def\setpath#1{\ttfamily <\nobreak #1\nobreak>\endgroup}
+%\def\url{\begingroup\pathcats\setpath}
+
+\def\bs{$\backslash$}
+\makeatletter
+% See Makefile for gymnastics here...
+% This hoiks the extra symbols at the bottom of the file, into the
+% text here, so they can be documented.
+% Abbreviations for degrees.
+% \begin{macrocode}
+\newcommand\BSc{B.Sc.{}}
+\newcommand\MSci{M.Sci.{}}
+\newcommand\MSc{M.Sc.{}}
+\newcommand\MA{M.A.{}}
+\newcommand\MEng{M.Eng.{}}
+\newcommand\BEng{B.Eng.{}}
+% \end{macrocode}
+%
+% Tweaks to differentials.
+% \begin{macrocode}
+\newcommand{\dd}{\mathrm{d}}
+\newcommand{\ddd}{\,\mathrm{d}} % inside an integral, including thinspace
+
+\def\Diffl{\@ifstar\@Difflflat\@Diffl}
+\def\Partial{\@ifstar\@Partialflat\@Partial}
+\def\@Partial{\@ifnextchar[{\@@Diffl\partial}{\@@Diffl\partial[]}}
+\def\@Partialflat{\@ifnextchar[{\@@Difflflat\partial}{\@@Difflflat\partial[]}}
+\def\@Diffl{\@ifnextchar[{\@@Diffl\dd}{\@@Diffl\dd[]}}
+\def\@Difflflat{\@ifnextchar[{\@@Difflflat\dd}{\@@Difflflat\dd[]}}
+\def\@@Diffl#1[#2]#3#4{%
+ \def\@tempa{#2}%
+ \ifx\@tempa\empty
+ \frac{#1#3}{#1#4}%
+ \else
+ \frac{{#1}^{#2}#3}{#1{#4}^{#2}}%
+ \fi}
+\def\@@Difflflat#1[#2]#3#4{%
+ \def\@tempa{#2}%
+ \ifx\@tempa\empty
+ #1#3\mskip-0.8mu/\mskip-1.2mu #1#4%
+ \else
+ {#1}^{#2}#3\mskip-0.8mu /\mskip-1.2mu #1{#4}^{#2}%
+ \fi}
+% \end{macrocode}
+%
+% The exponential sign
+% \begin{macrocode}
+\def\e{{\mathrm e}}
+% \end{macrocode}
+%
+% Physical units in |\rm|. Unstarred version includes leading
+% |\thinspace|. Starred version doesn't, and is used when referring to
+% the unit by itself (eg axis is |$B/\units*T$|), and is not qualifying
+% a number.
+% FIXME: |\mu| in |\units| can come out wrong in some fonts (mtpro2?)
+% -- needs investigation.
+% \begin{macrocode}
+\def\units{\begingroup
+ \catcode`\.=\active
+ \@ifstar{\let\un@tsspace\relax \un@ts}%
+ {\let\un@tsspace\thinspace\un@ts}}
+\begingroup
+ \catcode`\.=\active
+ \gdef\un@ts#1{\let~\thinspace\let.\thinspace
+ \ifmmode
+ \un@tsspace\mathrm{#1}%
+ \else
+ \nobreak$\un@tsspace\mathrm{#1}$%
+ \fi
+ \endgroup}
+\endgroup
+% \end{macrocode}
+%
+% Other miscellaneous symbols:
+% The AU is nothing exciting, but may be adjusted in future
+% \begin{macrocode}
+\def\au{au}
+% \end{macrocode}
+% The symbol for Compton wavelength is a crossed lambda -- the following isn't perfect, but is OK for now.
+% \begin{macrocode}
+\def\lambdabar{\setbox\@tempboxa\hbox{$\lambda$}%
+ \hbox to 0pt{\hbox to \wd\@tempboxa{\hss$\bar{}$\hss}\hss}\box\@tempboxa}
+% \end{macrocode}
+\makeatother
+
+% Uncomment \OnlyDescription to skip the implementation
+%\OnlyDescription
+\begin{document}
+\maketitle
+\tableofcontents
+\bigskip
+\DocInput{exam-n.dtx}
+\end{document}
+%</driver>
+%
+% \fi
+%
+% \noindent This class file supports creating exam papers.
+% This is intended as part of a slightly larger system for assembling
+% and managing the papers, by combining questions from multiple authors.
+%
+% This document is addressed to the exams convener, or someone
+% responsible for the overall exam; it goes into complete detail about
+% the class file, and how to customise it. There is more compact
+% documentation for the class, addressed to the authors of individual
+% questions, in the companion document `Notes for Authors'.
+%
+% The most up-to-date version of this class can be found at
+% \url{http://purl.org/nxg/dist/exam-n}.
+%
+% \newpage
+%
+% \section{Description}
+%
+% Usage:
+% \begin{verbatim}
+% \documentclass[options...]{exam-n}
+% <preamble declarations>
+% \begin{document}
+% \maketitle
+% \begin{question}...\end{question}
+% ...
+% \end{document}
+% \end{verbatim}
+%
+% \subsection{Class options}
+% \label{s:options}
+%
+% The class takes the following options. Note that these options are
+% processed in order, so if an option changes a default
+% (for example, \Lopt{draft} sets \Lopt{showsolutions} by default),
+% then it can be overridden by an option later in the list.
+% \begin{description}
+% \item[\Lopt{compose}, \Lopt{draft}, \Lopt{final}]
+% When composing questions, you should give
+% the \Lopt{compose} option to \Lenv{exam-n}; when assembling the paper, you
+% should use \Lopt{draft}; and you should use \Lopt{final} only for
+% the final version.
+% The \Lopt{draft} option switches on the \Lopt{showsolutions}
+% option (below), displays |\comment| remarks,
+% and makes some mild layout changes.
+% The \Lopt{compose} option implies the \Lopt{showsolutions} option,
+% causes questions to be formatted one per page, and turns off
+% various checks on the number of questions; the \Lopt{draft} option
+% should have the same pagination as the final paper and shifts the
+% body of the paper to the left so that marginal comments are
+% easier to write and read; the \Lopt{final} option turns off the
+% |\comment| command.
+%
+% \item[\Lopt{cmfonts}, \Lopt{psfonts}, \Lopt{mathptm},
+% \Lopt{mathtime}, \Lopt{mtpro2}]
+% The \Lopt{cmfonts} option uses the Computer Modern fonts for the
+% document, and the \Lopt{psfonts} uses PostScript fonts. In this
+% latter case, you will possibly want to use one of the
+% \Lopt{mathtime} or \Lopt{mtpro2} options also, to use the
+% mathtime or MTPro2 font set for the maths in the document;
+% alternatively you can use the \Lopt{mathptm} option to use that
+% free but less good alternative.
+%
+% \item[\Lopt{(no)showsolutions}]
+% These control whether the solutions to
+% the questions are shown on the paper or not. \Lopt{showsolutions} is the
+% default when the either \Lopt{draft} or \Lopt{compose} options is
+% present, and \Lopt{noshowsolutions} in \Lopt{final} case,
+% though this will be overridden by one of the
+% \Lopt{\{no\}showsolutions} options later in the list.
+%
+% \item[\Lopt{(no)perquestionmarks} and \Lopt{(no)showmarktotals}]
+% These control whether mark totals and subtotals are tracked within
+% the question (perquestionmarks), and whether the total available
+% marks are displayed at the end of the question (showmarktotals).
+% See Sect.\,\ref{s:question} for more discussion (this
+% option was called \Lopt{showmarks} up to release 0.15).
+%
+% \item[\Lopt{(no)pageperquestion}]
+% If the option \Lopt{pageperquestion} is present, then each
+% question is on a separate page. Option \Lopt{nopageperquestion}
+% is the default. This is most often set by default by one of the
+% other options, or by a \file{.clo} file.
+%
+% \item[\Lopt{oneside}, \Lopt{twoside}]
+% These control whether the document is formatted for
+% one- or twosided printing. This is a standard option, which is
+% redundant in this case, since in this document style there is no
+% difference in formatting. You may in principle use other
+% {article} options, though you are encouraged not to.
+%
+% \item[\Lopt{fleqn}]
+% Display equations flush-left, rather than centred. You generally
+% won't set this in the |\documentclass| options -- it's here so
+% that it can be set in a |.clo| file.
+%
+% \item[\Lopt{sloppydescription}]
+% Disables the requirement that all exam metadata be present. See
+% the discussion of |\universitycoursecode| below.
+%
+% \item[\Lopt{mono}, \Lopt{colour}]
+% The university logo is typeset in colour by default, as is the
+% solution text; the \Lopt{mono} option causes everything to be in
+% mono instead. The \Lopt{colour} option does nothing, but is
+% present for symmetry.
+%
+% \item[\Lopt{sansserif}]
+% Use a sans serif font for the body text. This is plug-ugly, not
+% least because it doesn't match the maths font; also, it may be
+% easier or harder for dyslexic students to read (depending on your
+% superstition -- there seems remarkably little actual evidence
+% either way).
+%
+% \item[\Lopt{largefont}, or \Lopt{hugefont}]
+% Produce a version of the paper in a `big' font (18pt) or `huge' font (36pt) for
+% the benefit of students with visual impairments. See notes below.
+%
+% \end{description}
+%
+% Any other options are interpreted as an instruction to read in a
+% \file{.clo} file, containing course-, department- or group-specific style
+% modifications. Most typically, these changes will affect the
+% rubric, and the sheet of physical constants.
+% The only generic style option is \Lopt{A1}
+% (which is included as an example of how such a file is written).
+% See section~\ref{s:custom} below.
+%
+% In some circumstances -- for example when processing exam scripts
+% under the control of a Makefile or script -- it can be convenient to
+% control package options from outside the package. If there is a
+% file called \texttt{exam-n.config} in the input path (most likely in
+% the same directory as the exam paper), then this is read in when any
+% exam script is processed, and will supplement any
+% options in the |\documentclass| line. For example, if this file were present
+% and contained the line |\ExecuteOptions{showsolutions}|, then the
+% typeset exam would include the solutions. Note that this will
+% supplement, \emph{but not override}, options in the input file's |\documentclass|;
+% it is therefore useful only for switching options away from the default.
+%
+% The exam-n class includes the \Lpackage{amsmath} package, so you can
+% make immediate use of amsmath features if you wish (see
+% \texttt{\small http://www.ams.org/tex/amslatex.html} for discussion).
+%
+% The change of font size with the \Lopt{hugefont} option requires a
+% couple of minor layout changes. You may need to force some similar
+% changes in the exam paper, in this case. You can do that by bracketing the
+% adjusted text in \cmd|\ifbigfont<big font material>\else<normal font
+% material>\fi|; the |\ifbigfont| flag is true in the case of
+% \Lopt{hugefont}, but not \Lopt{largefont}. If you want the
+% |\ifbigfont| flag to apply to \Lopt{largefont}, too, then you may
+% set |\bigfonttrue| in a suitable place. The \Lpackage{amsmath}
+% \texttt{multline} environment can be useful here. The exams
+% convener should review the result carefully: a few judicious
+% \cmd|\ifbigfont\newpage\fi| insertions can make the result look less
+% awful. The \Lopt{largefont} and \Lopt{hugefont} options apply to
+% the content of solutions if the \Lopt{showsolutions} option is
+% present; this may or may not be the optimal choice.
+%
+% At the bottom of each page, you see a faint identification code, such
+% as `QM/123-456'. This consists of an exam identifier, extracted from
+% the exam preamble, plus a code which changes each time \LaTeX\ is
+% run. This helps you avoid collation accidents, and to distinguish
+% between slightly different versions of the printed document.
+% The identifier is based on the date and time, so changes each time
+% you run \LaTeX\ on the file (that is, it identifies a printing,
+% rather than a source-file version).
+%
+% \subsection{The Question environment}
+% \label{s:question}
+%
+% Within the document, you include questions within a \Lenv{question}
+% environment, within which you may further have
+% \Lenv{questiondata} and \Lenv{solution} environments.
+%
+% \DescribeEnv{question}
+% The \Lenv{question} environment delimits a single exam question.
+%
+% Usage, with \Lopt{perquestionmarks}:
+% \begin{quotation}
+% \noindent
+% |\begin{question}|\oarg{questionnumber}\marg{marks}\\
+% \dots\\
+% |\end{question}|
+% \end{quotation}
+% Or, with \Lopt{noperquestionmarks}:
+% \begin{quotation}
+% \noindent
+% |\begin{question}|\oarg{questionnumber}\\
+% \dots\\
+% |\end{question}|
+% \end{quotation}
+%
+% There are two variants of this environment, depending on whether the
+% \Lopt{perquestionmarks} option is present or not. If it is present
+% (the default) then the \Lenv{question} environment takes a non-empty
+% argument showing the total marks available for a question.
+% In addition, the class checks that the |\partmarks| commands within the
+% question (see below) add up to this declared goal mark.
+% If the \Lopt{showmarktotals} option is present, then this (expected and
+% checked) total is displayed at the end of the question.
+%
+% If the \Lopt{perquestionmarks} option is \emph{not} present,
+% then questions have no individual marks, the
+% environment takes no marks argument, and no marks are shown (this is usual
+% in essay-question exams, which typically comprise a sequence of
+% short equal-valued questions with an explanatory rubric).
+% Also, in this case the |\partmarks| command cannot be used within the question.
+%
+% The \Lenv{question} environment takes an optional argument, giving
+% the expected question number. In \Lopt{compose} mode, this is used
+% as the question number (unsurprisingly). In the two other modes,
+% this is compared with the question number which would be generated based on the
+% position in the sequence of \Lenv{question} environments in the file, so
+% that the first \Lenv{question} environment is for question one, the
+% second for question two, and so on. If these do not match, the exam
+% class displays a warning in \Lopt{draft} mode, and produces a fatal
+% error in \Lopt{final} mode.
+% The intention is that this can act as a check that all expected
+% questions are present; see also the |\numquestions| command.
+% \iffalse XXX How useful is this in fact? Should I just discard this,
+% especially since includequestion has a similar features? \fi
+%
+% \DescribeMacro{\QuestionNumberChecksOff}
+% In some cases, the questions are not numbered in this
+% straightforward fashion, so that you might have questions~`2A'
+% and~`2B'. In this case, the check is not meaningful, and you must
+% suppress it by calling the macro |\QuestionNumberChecksOff| in the
+% preamble. After that, you must provide a question-number argument
+% (in square brackets) for every question.
+%
+% In some odder circumstances, you might not want to have any question
+% numbers at all; for example, you might want to require examinees to
+% attempt \emph{all} of the questions, and so simply have a mark for
+% the whole exam. There isn't a mode for this as such, but if you use
+% the \cs{QuestionNumberChecksOff} macro, and give |[\space]| as the
+% optional `question number' at the beginning of the \Lenv{question}
+% environment, then this will have the desired effect.
+%
+% \DescribeEnv{solution}
+% The \Lenv{solution} environment, contained within the \Lenv{question}
+% environment, contains the solution to the question, or other
+% notes. It is displayed by default in \Lopt{compose} mode, and
+% suppressed by default in the others, though this behaviour may be
+% overridden in either case with the \Lopt{(no)showsolutions}
+% option. You can have one \Lenv{solution} at the end of your
+% question, or have multiple ones scattered throughout it. You may
+% use the |\partmarks| macro within the solution, to indicate the
+% distribution of marks within (this part of) the solution --
+% these, of course, do not count towards the total mark for the
+% question. You must not have a solution inside a solution.
+%
+% \DescribeEnv{questiondata}
+% At the end of a question, it is frequently useful to include further
+% information, such as extra equations, or numerical data. These
+% should be included within a \Lenv{questiondata} environment, in
+% order for them to be formatted appropriately. You may include
+% multiple paragraphs, equations, and displays in this environment, as
+% appropriate. Typically, you will have only one such environment per
+% question, appearing at the end, but may have several of them if you
+% really wish to.
+%
+% \DescribeEnv{mcq}
+% Some exams include multiple-choice questions rather than
+% extended-answer ones. These are numbered in the same sequence as
+% the other questions, but are formatted and marked-up differently.
+% \begin{verbatim}
+% \begin{mcq}
+% In 1908, where was there an airburst `impact'?
+% \answer Tunguska
+% \item Arizona
+% \item Off the Mexican coast
+% \item Egypt
+% \end{mcq}
+% \end{verbatim}
+% That is, the \Lenv{mcq} environment contains a list of possible
+% answers, all of which are indicated by |\item|, except precisely one
+% correct answer, indicated by |\answer|.
+% \DescribeMacro{\multiplechoiceanswers}
+% All multiple-choice questions must have the same number of possible
+% answers, which is declared with the command \cmd|\multiplechoiceanswers{<n>}|
+% The \Lenv{mcq} environment is permitted only after |\multiplechoiceanswers|.
+% It's OK to have a \Lenv{solution} within an \Lenv{mcq} environment,
+% which might provide further commentary on the correct answer.
+%
+% There are various other commands which you may or should use within
+% the document.
+%
+% \DescribeMacro{\includequestion}
+% It may be convenient to split your exam into a number of separate
+% source files, such as having one \texttt{.tex} file for each
+% question. You can include these various source files using the
+% usual |\input| command.
+%
+% If the separate source files have the simple form:\label{s:includequestion}
+% \begin{verbatim}
+% \documentclass[compose]{exam-n}
+% \usepackage{graphicx} % for example
+% \begin{document}
+% \begin{question}
+% ...
+% \end{question}
+% \end{document}
+% \end{verbatim}
+% then they can be \LaTeX ed separately, for example by the authors of
+% different questions, but cannot be |\input|
+% unedited, as described above. If, however, they have \emph{only}
+% these structures (that is, only the |\documentclass| command,
+% the \Lenv{document} environment, and zero or more |\usepackage| commands),
+% then you can most conveniently import them unedited using the
+% |\includequestion| command.
+% \begin{verbatim}
+% \includequestion{dynamics2}
+% \end{verbatim}
+% This acts like the |\input| command, but disables the listed structures.
+% It also puts the included command into a group, so that any
+% (re)definitions of commands are made local-only.
+%
+% Recall that the definition of the |\includequestion| command means
+% that any |\usepackage| commands will be ignored. If you, as a
+% question author, need certain packages to be present for your
+% question, you will have to make sure that whoever is assembling the
+% master file includes those packages there, too.
+%
+% The |\includequestion| command takes an optional argument which
+% overrides the question number. This caters for the case where
+% question authors have (unhelpfully) included question numbers in the
+% files' \Lenv{question} environments, and the case where questions
+% are not numbered in a straightforward sequence, for example `1',
+% `2A', `2B', and so on.
+%
+% \DescribeMacro{\section}
+% \DescribeMacro{\subsection}
+% Some exams are divided into sections, or have other structure which
+% needs to be spelled out. These are described with the |\section|
+% command, in a form such as |\section{II}|. You can also add smaller
+% headers before individual questions with something like
+% |\subsection{Second semester questions}|. These can appear only
+% between questions; it is an error to include one of these commands
+% within a \Lenv{question} or \Lenv{mcq} environment.
+%
+% \DescribeMacro{\part}
+% Questions may be subdivided into parts, such as (a), (b),
+% (c)..., or (i), (ii), (iii), and so on. Precede each of these with
+% this |\part| command. The formatting of the part numbers is
+% controlled by the exam style, as customised in
+% Sect.~\ref{s:custom}. This macro starts a new paragraph.
+%
+% You can use the |\part| macro within solutions: this is useful if
+% you have the entire \Lenv{solution} environment at the end of the
+% question, but distracting if you intersperse the \Lenv{solution}
+% environments between question parts. The |\part| macro within
+% solutions increments separately from the increments within the question,
+% so if you use this in the solutions, you must have as many
+% |\part|s in the solution as there are parts in the question.
+%
+% \DescribeMacro{\partmarks}
+% \DescribeMacro{\partmarks*}
+% Macros \cmd|\partmarks{<num>}| and \cmd|\partmarks*{<num>}| announce
+% the number of marks associated with the current part of a question.
+% The class checks that the number of marks here does add up to the
+% number declared at the beginning of the {question} environment.
+% You will typically have just one |\partmarks| per |\part|, but
+% you can have more if you want.
+% The starred version differs by adjusting the position of the mark
+% indicator, and should be used either (i) after (for example) an
+% itemized list, or some other structure which leaves an expanse of
+% white space on the right-hand side of the page; or (ii) within
+% an \emph{unnumbered} equation. If, in case (ii), the style of
+% the part-marks indicators is such that the indicator may be
+% mistaken for an equation number, then it would be wise to use
+% either |\partmarks*| or plain |\partmarks| after the equation,
+% instead.
+%
+% The unstarred version should only be used at the end of a
+% paragraph, and in fact forces a paragraph end; the starred
+% version should on stylistic grounds generally be used only at the
+% end of a paragraph, but it doesn't force one.
+%
+% \DescribeMacro{\comment}
+% \cmd|\comment{<text>}| associates a comment with a part of the text.
+% This is ignored in \Lopt{final} mode, but appears in the margin in the
+% other modes.
+%
+% \DescribeMacro{\author}
+% The |\author| command is a convenience. Used within a
+% \Lenv{question} environment -- most naturally just after the
+% |\begin{question}| -- it creates a comment with the author's
+% name. Its functionality may be expanded in future, so you should
+% use this command, rather than a generic |\comment|, when noting
+% the authorship of a question.
+%
+% \DescribeMacro{\shout}
+% If there is part of a question which is, for example, incomplete,
+% and which needs a more prominent callout than `comment', then you
+% should |\shout{...}| it. Shouts appear in all modes (\emph{including}
+% \Lopt{final}) and appear whether or not the class is showing solutions.
+% This makes a prominent remark in the text, and also in a list of
+% shouts at the end of the text. Your co-authors, or the exam
+% proof-checker, really have no excuse for missing it after that.
+%
+% \DescribeMacro{\leftnudge}
+% For various reasons, most often because of printing problems, it can
+% be useful to nudge the textblock left or right a little. You should
+% call the |\leftnudge| command to do this, rather than fiddling with
+% the underlying \LaTeX\ dimensions yourself. Give the command a dimension
+% argument such as |\leftnudge{1cm}| to nudge the textblock leftwards
+% by 1cm. You can give a negative dimension to nudge it rightwards
+% instead. The \Lopt{draft} option automatically nudges the text
+% block leftwards, to create a larger right-hand margin for notes.
+%
+% \DescribeMacro{\questionpreamble}
+% If |\questionpreamble| is called, then its contents are displayed
+% just before the start of the next question. This is useful for text like
+% |\questionpreamble{And one of\dots}| which might reinforce information in
+% the examination rubric.
+%
+% \subsection{Preamble}
+% \label{s:preamble}
+%
+% \DescribeMacro{\exambanner}
+% The |\exambanner| macro supplies text like `Examination for the
+% degrees of\dots'.
+% Since the contents of this command is automatically uppercased in
+% some styles, and there are per-department specifics about the punctuation
+% of abbreviations, you should use the commands |\BSc|, |\MSci|, and
+% friends (see section~\ref{s:othercommands}) to set the degree names
+% appropriately.
+%
+% \DescribeMacro{\universitycoursecode}
+% \DescribeMacro{\schoolcoursecode}
+% \DescribeMacro{\degreedescriptions}
+% \DescribeMacro{\coursetitle}
+% Declare the identity of the exam with
+% |\universitycoursecode|, |\schoolcoursecode|, |\coursetitle| and
+% |\degreedescriptions|. The distinction between these is as follows:
+% \begin{description}
+% \item[University course code]
+% This is the code for the course (and thus for the paper) as it
+% appears in university information systems, and is a
+% university-unique code such as `PHYS3031'.
+% \item[School course code]
+% This is a more informal, but more recognisable, code for the
+% course/paper, as it is generally recognised within the school;
+% for example, the honours Quantum Mechanics course is known
+% within the school as P304H.
+% \item[Course title]
+% This is just a textual name for the course, for example `Quantum Mechanics'.
+% \item[Degree descriptions]
+% This is a textual description of the qualifications that the
+% students doing this exam are heading for. This text has little
+% formal weight, but might help a lost student realise they're in
+% completely the wrong exam room\dots. This is something like
+% |{Physics 3\\Chemical Physics 3}| (separate each description
+% using |\\|).
+% \end{description}
+% All of these are required elements, and the \LaTeX\ compilation will
+% halt if they are absent. If for some reason the exam
+% paper does not need these to be present -- perhaps it is a class
+% test, for example -- then give the class option
+% \Lopt{sloppydescription}, and the checks for these elements (and for
+% |\rubric|) are suppressed. The layout may end up looking a little
+% funny.
+%
+% \DescribeMacro{\paperident}
+% It can be convenient to add some identification to each page, if for
+% no other reason than to double-check that you haven't inserted a
+% field theory question into an `astronomy for poets' exam. The command |\paperident|
+% allows you to declare some text which appears at the bottom of each
+% page of the exam. It will typically repeat some of the text in the
+% |\schoolcoursecode| or |\degreedescriptions| arguments.
+% This is generally not necessary, however, as in its absence the
+% class generates an identifier. This identifier contains the name of
+% the exam, plus a pair of counters (for example \emph{QM2/98-1177}). The
+% function is two-fold: (i) since the counters increase monotonically
+% (they actually encode the date and time when the document
+% was \LaTeX ed), you can tell which of two superficially similar
+% documents is the later; and (ii) if you drop a sheaf of papers on the
+% photocopier floor, you can work out which one is which.
+%
+% \DescribeMacro{\examdate}
+% \DescribeMacro{\examtime}
+% Give the date and time of the exam with |\examdate| and |\examtime|.
+% Sometimes an exam may
+% have different time limits for different qualifications: this case,
+% separate the various times with |\\|, as in
+% \texttt{\bs examtime\{9.30am -- 12 noon\bs\bs (or) 9.30am -- 1.45am\}}
+%
+% \DescribeMacro{\rubric}
+% \DescribeMacro{\norubric}
+% The rubric, provided unsurprisingly by the command |\rubric|, may
+% contain more than one paragraph,
+% delimited by the usual blank line. Any emphasised words should be
+% marked with |\emph| -- they are typically
+% emphasised with a bold font. The class checks that a rubric has
+% been specified (unless \Lopt{sloppydescription} is present); if you
+% really wish to suppress this rubric -- perhaps because the
+% |\baserubric| is sufficient -- then give the command |\norubric|.
+% \DescribeMacro{\baserubric}
+% As well as this exam-specific rubric, the style produces an additional
+% boilerplate rubric, containing the usual material such as `Do not on
+% any account attempt to write on both sides of the paper at once.
+% Calculations may be done on the fingers, but candidates should avoid
+% counting on their toes unless special permission has been obtained beforehand.'
+% You will typically not have to change this, but if you do for some
+% reason, you can override it with the |\baserubric| command.
+%
+% \DescribeMacro{\numquestions}
+% Finally, declare the number of questions which are to be in the
+% paper with |\numquestions|.
+% The class issues a warning if we don't have this number, in draft or
+% final mode. This is optional -- no check is done if this isn't present.
+%
+%
+% \subsection{Other useful commands}
+% \label{s:othercommands}
+%
+% \DescribeMacro{\BSc\ and friends}
+% Macros |\BSc|, |\MSci|, |\MSc|, |\MA|, |\MEng| and |\BEng| are used
+% within the preamble macros to give appropriately capitalised and punctuated
+% versions of the degree types.
+%
+% \DescribeMacro{\vec}
+% Macro |\vec| is redefined to give bold-font vectors, rather than
+% vectors with arrows, which is the (weird) \LaTeX\ default. This
+% should work for bold greek as well as roman.
+%
+% \DescribeMacro{\dd}
+% Macros |\dd| and |\ddd|: |\dd| is a roman d, as used for
+% differentials; |\ddd| is the same with a preceding thinspace,
+% as used within integrals; for example
+% \[
+% |\int f(x)\ddd x = \int f(x)\,\dd x| = \int f(x)\ddd x
+% \]
+%
+% \DescribeMacro{\Diffl}
+% You can typeset derivatives neatly:
+% \begin{center}
+% \def\dd{\mathrm{d}}
+% \begin{tabular}{ll}
+% |\Diffl{a}{b}| & $\displaystyle \Diffl ab$ \\[2ex]
+% |\Diffl[2]{a}{b}| & $\displaystyle \Diffl[2]ab$\\[2ex]
+% |\Diffl*{a}{b}| & $\Diffl* ab$ \\
+% |\Diffl*[2]{a}{b}| & $\Diffl*[2]ab$\\
+% \end{tabular}
+% \end{center}
+% The unstarred versions are for displayed equations, the starred
+% ones for inline maths.
+% \DescribeMacro{\Partial}
+% There is analogous support for partial derivatives with |\Partial|.
+%
+% \DescribeMacro{\units}
+% Macros |\units|, |\units*|: you can typeset physical units in
+% |\rm|, with tilde or dot
+% acting as a separator between units. Since this is typeset in maths mode, all
+% other spacing is ignored. The unstarred version includes
+% leading |\thinspace|, as in |$v=10\units{m.s^{-1}}$|, giving
+% $v=10\units{m.s^{-1}}$. The starred
+% version can be used when referring to the unit by itself
+% (eg axis is |$B/\units*T$|, or $B/\units*T$), and is not
+% qualifying a number. These macros might be replaced, in the
+% future, by a recommendation to use the \Lpackage{siunitx} package.
+%
+% For other useful symbols, see table~\ref{t:symbols}.
+%
+% \begin{table}
+% \hrule \medskip
+% \begin{tabular}{rlp{8cm}}
+% |\e|&$\e^{i\pi}=-1$& the exponential is typeset in an upright rather than
+% italic shape, as in |$\e^{i\pi}=-1$|.\\
+% |\au|&10\au& use this macro for astronomical units.\\
+% |\lambdabar|&$\lambdabar$& the Compton wavelength, as a lambda with a
+% bar through it.\\
+% \end{tabular}
+% \caption{\label{t:symbols}Miscellaneous symbols}
+% \medskip\hrule
+% \end{table}
+%
+%
+% \section{Customising the exam style}
+% \label{s:custom}
+%
+% As described in section~\ref{s:options} above, any unrecognised
+% options are interpreted as an instruction to search for and include
+% a class options file, formed from the name of the unrecognised
+% option, suffixed with \file{.clo}, which can be anywhere in the
+% \TeX\ include path. This options file has a fair amount of leeway
+% to override and adjust the layout of the exam.
+%
+% The most typical changes here will be to adjust the exam rubric for
+% a particular class, with the command |\baserubric|, and to change the
+% sheet of physical constants, with the command |\constantssheet|.
+% See the sample file |A1.clo| for examples.
+%
+% Examine this sample \file{SpecialExam.clo} file:
+% \begin{verbatim}
+% \typeout{Physics Special exam options, for Special people}
+% \ExecuteOptions{pageperquestion}
+%
+% \OverrideFormatting{
+% \renewcommand\FormatPartMarks[1]{\{#1\}}
+% \renewcommand\FormatPartNumber
+% {\hbox to 0pt{\hss (\StylePartNumber{partnumber})\hskip1em}}
+% \let\StylePartNumber\roman % as opposed to \alph
+% \renewcommand\FormatQuestionNumber
+% {\hbox to 0pt{\hss \textbf{\@currentquestion}\hskip2.5em}}
+% }
+%
+% \constantssheet{
+% \begin{center}
+% $E=mc^2$ and $c=3\times10^8 {\rm m\,s^{-1}}$
+% \end{center}
+% }
+% \end{verbatim}
+% This announces itself, then invokes the exam style's \Lopt{pageperquestion}
+% option.
+%
+% It then includes a number of formatting adjustments,
+% enclosed within the |\OverrideFormatting| command; the formatting
+% hooks are described below.
+%
+% Then it declares a `constants sheet', which is a display of
+% constants or equations, or indeed anything else, which is to be
+% displayed on the second page of the exam.
+%
+% The available formatting hooks are as follows:
+% \begin{description}
+%
+% \item[FormatPartMarks]
+% This formats the indication of the marks carried by a particular
+% part of a question. In this case, we have chosen to have the marks
+% contains inside curly brackets, rather than the default square
+% brackets. By default, the part-marks text will be placed at the end
+% of the paragraph it completes, flush right, and with at least 2em of
+% space before it. You can change this default space with
+% |\@partmarksspace|; as a special case, you can have the text sitting
+% in the margin instead, by having |\FormatPartMarks| generate a
+% zero-width box, and setting |\@partmarksspace=0pt|.
+%
+% \item[FormatPartNumber]
+% This overrides how to format the various |\part| markers within a
+% question, using the \texttt{partnumber} counter. In this case, the
+% markers will jut into the left-hand margin, rather than being
+% run-in.
+%
+% \item[StylePartNumber]
+% This overrides how to style the |\part| markers. The default is
+% |\alph|, but you might prefer, for example, |\Roman| or |\arabic|.
+% Override this with |\let\StylePartNumber\Roman|.
+%
+% \item[FormatQuestionNumber]
+% If you adjust the part marks, you should probably adjust the
+% formatting of the question number also.
+% \end{description}
+%
+% If you really want to go to town on reformatting, you can redefine
+% the command |\maketitle|, which formats the front-page title. When
+% formatting this, you have access to each of the fragments of text
+% described in section~\ref{s:preamble}, via a macro named after the
+% corresponding command. Thus the argument of the |\exambanner| command
+% is available in the macro |\@exambanner|. The exception is
+% |\numquestions|. If you find yourself needing to do this, it might
+% be worth having a discussion with the style's maintainer -- there
+% may be a simpler way to get what you want.
+%
+% No more clues. If you want to hack at this, see the definition of
+% |\maketitle| in the class file \file{exam-n.cls}.
+% Aspire not to break things.
+
+% \iffalse %%%CONFIGURE%%% change the following to iffalse for a locally-distributed version\fi
+% \iftrue
+% \section{A work-flow}
+% This class file was developed as part of a move to `\LaTeX ify' the
+% production of exams in the School of Physics and Astronomy, in the
+% University of Glasgow. The work-flow which emerged was, roughly, as
+% follows:
+% \begin{enumerate}
+% \item The exam convener (the person in charge of assembling the exam
+% for a given course or lecture series) creates a Sharepoint directory
+% which contains a master file
+% (which consists mostly of |\includequestion| macros),
+% plus subdirectories each containing a short template file for the
+% benefit of question authors, and a copy of the
+% \texttt{notes-for-authors.pdf} instructions.
+% \item Each of those `question' directories is made visible to, and
+% read-writable by, the lecturer responsible for that question. They
+% write and \LaTeX ed their question, and upload it back to
+% Sharepoint.
+% \item The exam convener, who has access to the whole tree of
+% questions, downloads or network-mounts the Sharepoint folder, and
+% either edits the questions or negotiates with the authors, until
+% the exam \LaTeX s successfully. The result can then be
+% snapshotted, and sent off to the external examiner.
+% \end{enumerate}
+% This provides a centralised and easily manageable repository
+% for a previously fiddly and error-prone process.
+%
+% In step one, the template file is just one with a \texttt{[compose]}
+% option, following the brief example on p.\pageref{s:includequestion}.
+% We had excellent secretarial help to manage this step; it was fiddly the
+% first couple of times, but largely mechanical thereafter. In Sharepoint,
+% this step can in principle be automated, though we concluded this
+% was unnecessary in our case.
+%
+% Sharepoint (possibly slightly surprisingly) worked smoothly for us;
+% in other circumstances a group-writable source code repository, or
+% an institutional CMS, or even just a shared drive, would work just
+% as well. The advantage of Sharepoint, from our point of view, was
+% that it integrated with the university's existing authentication
+% framework, and was (axiomatically) acceptably secure for the process
+% of creating exams.
+%
+% The majority of our authors were habitual users of \LaTeX\ for
+% writing journal articles, and with subsequently submitting them to
+% journals or the arXiv; and when the process was presented in
+% those terms, with the same advantages, it was readily accepted.
+%
+% Thanks to Graham Woan and Rachael MacLaughlan for the numerous
+% iterations of this process until both it and the class file were stable.
+% \fi
+
+% \section{Example}
+%
+% Here is a short example file. There are further examples in the
+% \texttt{sample/} directory of the distribution.
+% \begin{macrocode}
+%<*example>
+%%%START example (Makefile strips out this block)
+\documentclass{exam-n} % standard final version
+%%\documentclass[draft,showsolutions]{exam-n} % draft style, showing solutions
+%%\documentclass[compose]{exam-n} % compose (author's) style
+
+\examdate{Wednesday, 18 May 2005}
+\examtime{9.30am -- 12 noon\\(or) 9.30am -- 1.45am}
+
+\exambanner{Examination for the Degrees of \BSc(Science) and
+ \MSci\ on the Honours Standard}
+\schoolcoursecode{P304D and P304H}
+\universitycoursecode{PHYS3031 and PHYS4025}
+\coursetitle{Quantum Mechanics}
+%\degreedescriptions{Physics 3, Chemical Physics 3, Physics with
+% Astrophysics 3, Theoretical Physics 3M, Joint Physics 3}
+\degreedescriptions{Physics 3\\Chemical Physics 3\\Physics with
+ Astrophysics 3\\Theoretical Physics 3M\\Joint Physics 3}
+\paperident{GR/P304}
+
+\rubric{Candidates for examination in \emph{Quantum Mechanics} should
+ answer question 1 (16 marks) and \emph{either 2A or 2B} (24 marks each)}
+
+\numquestions{3}
+
+\begin{document}
+\maketitle
+
+\section{I}
+
+\begin{question}{20}
+\part At various points in the development of the mathematical theory of
+General Relativity, we pick a coordinate system in which
+differentiation is simple, and do a calculation using non-covariant
+differentiation, indicated by a comma. We then immediately deduce the
+covariant result, replacing this comma with a semicolon.
+
+Separately, the strong equivalence principle is sometimes
+referred to as the `comma goes to semicolon' rule.
+
+Explain the logic of each of these replacements of a comma with a
+semicolon, putting particular stress on the distinction between
+them.\partmarks{10}
+
+\part The radial and angular coordinates, $r$ and $\phi$ respectively,
+of a test particle moving in the Schwartzschild metric exterior to a
+star of mass $M\ll r$, are related by the equation
+\[
+ r = \frac{h^2}M \left(
+ 1 + e\cos\phi + \frac{3M^2}{h^2}e\phi\sin\phi
+ \right)^{-1},
+\]
+where $h$ and $e$ are constants. Show that this equation takes the
+form of a precessing ellipse, of semi-latus rectum $l=h^2/M$, in which
+the pericentre line advances each orbit by an amount
+$\Delta=6\pi M^2/h^2$, stating clearly any assumptions that
+you make.\partmarks{6}
+
+The solar-mass star HD83443 has a 0.35 Jupiter-mass planet that
+follows a circular orbit of period 2.986 days and radius 0.038\units\au.
+Calculate the rate of precession, in arcseconds per year, of the
+pericentre line of the planet's orbit.\partmarks{4}
+
+[Schwartzschild radius of the Sun${}= 3.0\times10^3\units{m}$,
+$1\units\au=1.5\times10^{11}\units m$].
+
+\begin{solution}
+ In the first type of calculation, we do a calculation in the LIF, in
+which~$\Gamma^i_{jk}=0$, so that single partial differentiation is the
+same as covariant differentiation. If this process produces a
+geometrical object such as a scalar or a tensor, then we know that the
+result is frame-invariant. If the result involves only single partial
+differentiation -- that is, no second derivatives -- then since
+partial differentiation is the same as covariant differentiation in
+these coordinates, we cannot distinguish partial and covariant
+derivatives, and can replace the commas by semicolons. Since these
+are now manifestly covariant derivatives, so that the result is a
+tensor, and thus frame-invariant, the same expression would be true in
+any frame.
+
+The second situation is the statement that the expressions of physical
+laws in SR, such as the conservation equation
+$T^{\mu\nu}_{,\nu}=0$, must take the same \emph{form} when written
+as a covariant equation in GR, crucially without any curvature
+coupling. The slogan `comma goes to semicolon' is just a mnemonic for
+this.
+
+The distinction is that the first is a mathematical trick, of sorts,
+whereas the second is a version of the equivalence principle, and thus
+a statement with deep physical content.
+
+They don't have to explain things at this length or with this
+coherence (?) to get quite a few marks. They just have to show they
+have a clue.
+\end{solution}
+\end{question}
+
+\end{document}
+%%%END example
+%</example>
+% \end{macrocode}
+%
+% \subsection*{Acknowledgements}
+% \addcontentsline{toc}{subsection}{Acknowledgements}
+%
+% This class has greatly benefitted from comments and bug-reports from
+% Harry Ward, Graham Woan, and Nicolas Labrosse;
+% and it has received code contributions from Morag Casey.
+%
+% \StopEventually{}
+
+% \section{Implementation}
+%
+% \subsection{Options}
+%
+% First, process the compose/draft/final option.
+% Flag |\@draftstatus| 0 represents the final version; 1 is a draft exam; 2 is a
+% single question being composed
+% \begin{macrocode}
+%<*package>
+\newcount\@draftstatus
+\@draftstatus=0 % default is final
+\DeclareOption{compose}{\@draftstatus=2
+ \@showsolutionstrue
+ \@pageperquestiontrue}
+\DeclareOption{draft}{\@draftstatus=1
+ \@showsolutionstrue
+ \@pageperquestionfalse}
+\DeclareOption{final}{\@draftstatus=0
+ \@showsolutionsfalse
+ \@pageperquestionfalse}
+% \end{macrocode}
+%
+% Set true to use PostScript fonts
+% \begin{macrocode}
+\newif\if@psfonts\@psfontsfalse
+\DeclareOption{psfonts}{\@psfontstrue}
+\DeclareOption{cmfonts}{\@psfontsfalse}
+% \end{macrocode}
+%
+% Given that we're using PS fonts, should we use the mathtime fonts,
+% rather than just the mathptm ones (which aren't really ideal)? It
+% turns out that we can't test for the presence of the mathtime fonts
+% from within this class file -- the only reliable way of checking if
+% they're present is to look for something like rmtmi.pfa, but
+% |\IfFileExists| isn't able to search for any of those files, only ones
+% on the TEXINPUTS path such as mathtime.sty, which can be, and are
+% often, installed without the fonts themselves being present.
+% \begin{macrocode}
+\newcount\examn@mtselect \examn@mtselect=0
+\DeclareOption{mathptm}{\@psfontstrue\examn@mtselect=0}
+\DeclareOption{mathtime}{\@psfontstrue\examn@mtselect=1}
+\DeclareOption{mtpro2}{\@psfontstrue\examn@mtselect=2}
+% \end{macrocode}
+%
+% Switch between serif and sans serif fonts. We make little attempt
+% to make the latter attractive; this is purely to conform to the
+% superstition (there seem no more grounds than that) that this is
+% better for dyslexic students.
+% \begin{macrocode}
+\newif\ifexamn@serif
+\examn@seriftrue
+\DeclareOption{serif}{\examn@seriftrue}
+\DeclareOption{sansserif}{\examn@seriffalse}
+% \end{macrocode}
+%
+% Set |\if@showsolutions| true if we are to show the contents of {solution} environments
+% \begin{macrocode}
+\newif\if@showsolutions
+\@showsolutionsfalse
+\DeclareOption{showsolutions}{\@showsolutionstrue}
+\DeclareOption{noshowsolutions}{\@showsolutionsfalse}
+% \end{macrocode}
+%
+% Set |\if@pageperquestion| true if we want a new page after each question
+% (set when printing solutions)
+% \begin{macrocode}
+\newif\if@pageperquestion
+\@pageperquestionfalse
+\DeclareOption{pageperquestion}{\@pageperquestiontrue}
+\DeclareOption{nopageperquestion}{\@pageperquestionfalse}
+% \end{macrocode}
+%
+% Set |\if@perquestionmarks| true if we are to expect a marks total to
+% be specified in the question, subtotals to be specified in the
+% question, and to include a check, at the end, that the two match up.
+% \begin{macrocode}
+\newif\if@perquestionmarks
+\@perquestionmarkstrue
+\DeclareOption{perquestionmarks}{\@perquestionmarkstrue}
+\DeclareOption{noperquestionmarks}{\@perquestionmarksfalse}
+% \end{macrocode}
+%
+% Set |\if@showmarktotals| true if we are to display the expected (and
+% checked to be actual) total marks at the end of the question.
+% \begin{macrocode}
+\newif\if@showmarktotals
+\@showmarktotalstrue
+\DeclareOption{showmarktotals}{\@showmarktotalstrue}
+\DeclareOption{noshowmarktotals}{\@showmarktotalsfalse}
+% \end{macrocode}
+%
+% Support the standard article oneside/twoside options, even though
+% they do nothing in this class.
+% \begin{macrocode}
+\newif\if@twosidepages
+\@twosidepagesfalse
+\DeclareOption{twoside}{\@twosidepagestrue}
+\DeclareOption{oneside}{\@twosidepagesfalse}
+% \end{macrocode}
+%
+% Some options styles want \Lopt{fleqn}, so make it an option to this
+% class, to be passed on to article and amsmath.
+% \begin{macrocode}
+\newif\if@fleqn
+\@fleqnfalse
+\DeclareOption{fleqn}{
+ \@fleqntrue
+ \PassOptionsToPackage{fleqn}{amsmath}
+ \PassOptionsToClass{fleqn}{article}
+}
+% \end{macrocode}
+%
+% If \Lopt{sloppydescription} is given, then we don't demand that all
+% the exam metadata is provided. Failing this, we object, fatally, to
+% missing information.
+% \begin{macrocode}
+\newif\if@fussydescription
+\@fussydescriptiontrue
+\DeclareOption{sloppydescription}{\@fussydescriptionfalse}
+% \end{macrocode}
+%
+% The university logo is typeset in colour by default; the \Lopt{mono}
+% option causes everything to be in mono instead. The \Lopt{colour}
+% option does nothing, but is present for symmetry. These have to be
+% |\def|s, by the way, not |\let|s, since the size macros aren't
+% defined until after \Lpackage{article} has been loaded. It seems
+% prudent to make the `showing solutions' text a bit more shouty in
+% this monochrome case.
+% \begin{macrocode}
+\def\examn@header@shoutformat#1{{\Large\bfseries #1}}
+\DeclareOption{mono}{
+ \PassOptionsToPackage{monochrome}{color}
+ \def\examn@header@shoutformat#1{{\Huge\bfseries #1}}
+}
+\DeclareOption{colour}{}
+% \end{macrocode}
+%
+% Options \Lopt{largefont} and \Lopt{hugefont} print versions of the
+% exam in `big' or `huge' font sizes, to help students with visual impairments.
+% The available font variants are represented as numbers.
+% Note: the |\examn@fontvariant| mechanism is in principle more
+% general than simply size variants, but some of the code below
+% assumes that |\examn@fontvariant| greater than zero means large
+% text, and so would need to be adjusted if this becomes untrue.
+%
+% The flag |\ifbigfont| is true if the font is `significantly large';
+% option \Lopt{hugefont} sets it true, option \Lopt{largefont} does
+% not; it's intended to be a user-visible and -settable flag.
+% \emph{Note:} the \Lopt{hugefont} option used to be \Lopt{bigfont};
+% the latter is deprecated and may be removed in v1.2.
+% \begin{macrocode}
+\newcount\examn@fontvariant
+ \examn@fontvariant=0 % the default
+\newif\ifbigfont
+ \bigfontfalse
+\DeclareOption{largefont}{\examn@fontvariant=1 \bigfontfalse}
+% Deprecate [bigfont]; consider removing in v1.2
+\DeclareOption{bigfont}{%
+ \ClassWarning{exam-n}{OPTION [bigfont] HAS BEEN DEPRECATED; use [hugefont] instead}
+ \examn@fontvariant=2 \bigfonttrue}
+\DeclareOption{hugefont}{\examn@fontvariant=2 \bigfonttrue}
+% \end{macrocode}
+%
+% This class is based on the article class. Load it, and pass the \texttt{a4paper}
+% option to it.
+% \begin{macrocode}
+\PassOptionsToClass{a4paper}{article}
+% \end{macrocode}
+%
+% We allow \file{.clo} files to override elements of the formatting,
+% such as |\maketitle| and the various |\Format...| hooks. They must
+% do this within a |\OverrideFormatting| command, using a sequence of
+% |\renewcommand|s. Carefully.
+% \begin{macrocode}
+\newtoks\@styleoverrides
+\@styleoverrides={}
+\def\OverrideFormatting{\@styleoverrides=}
+% \end{macrocode}
+% If \@constantssheet is defined (using |\constantsheet{...}| in a
+% .clo file), then display it on a page by itself. The macro
+% |\constantssheet| is declared above, before the point where we include
+% .clo files.
+% \begin{macrocode}
+\newtoks\@constantstoks
+\def\@@displayconstants{%
+ \clearpage
+ \begingroup
+ \the\@constantstoks
+ \endgroup
+ \clearpage }
+% \end{macrocode}
+% The macro |\constantssheet| has to be declared here, rather in the
+% more natural place below, with \@exambanner and friends, so that
+% it's usable within .clo files.
+% \begin{macrocode}
+\newtoks\@constantstoks
+\@constantstoks={}
+\let\@displayconstants\relax
+\def\constantssheet{\let\@displayconstants\@@displayconstants
+ \@constantstoks=}
+% \end{macrocode}
+%
+% Spit out the style overrides at the beginning of the document,
+% rather than here.
+% \begin{macrocode}
+\AtBeginDocument{\the\@styleoverrides}
+% \end{macrocode}
+%
+% Any remaining options are interpreted as filenames, and the
+% corresponding \file{.clo} file is read in. We do not permit any
+% other options, for example standard |{article}| options.
+% There's a complication here (which I haven't resolved, to my
+% puzzlement): if the .clo file includes for example
+% |\ExecuteOptions{pageperquestion}|, then a \Lopt{nopageperquestion}
+% appearing after the .clo option in the |\documentclass| line appears
+% to be ignored or overwritten, which is odd, since I thought that
+% options were executed in order; are these file options executed
+% later than others, perhaps?
+% \begin{macrocode}
+\DeclareOption*{\InputIfFileExists{\CurrentOption.clo}{}
+ {\ClassError{exam-n}
+ {Bad option \CurrentOption}
+ {I don't understand the option \CurrentOption\MessageBreak
+ (I didn't find file \CurrentOption.clo, if that's what you meant)}}}
+% \end{macrocode}
+%
+% The default options are set when the options are declared, above.
+%
+% If a file called \texttt{exam-n.config} exists, read it in. It may
+% usefully contain other |\ExecuteOptions{foo}| commands. Note that
+% these supplement but \emph{will not override} any options in the
+% |\documentclass| command; thus these are really only useful for
+% changing away from the default. This last behaviour is
+% unsatisfactory: it would be better if this would reliably override
+% any options supplied in |\documentclass|, but that turns out to be
+% hard to fix, given the \LaTeX\ option logic.
+% \begin{macrocode}
+\InputIfFileExists{exam-n.config}{}{}
+% \end{macrocode}
+% And finally process all the options marked so far.
+% \begin{macrocode}
+\ProcessOptions
+% \end{macrocode}
+%
+% \subsection{Dependencies}
+%
+% We depend on the \Lpackage{article} class.
+%
+% Note: we have to do this this way, so that
+% |\PassOptionsToClass{*side}{article}| is invoked only once --
+% \Lenv{article} gets confused if both options are passed to it
+% \begin{macrocode}
+\if@twosidepages
+ \PassOptionsToClass{twoside}{article}
+\else
+ \PassOptionsToClass{oneside}{article}
+\fi
+\PassOptionsToClass{12pt}{article}
+% \end{macrocode}
+%
+% If the document includes
+% the \Lpackage{graphicx} or \Lpackage{pdfpages} packages,
+% then we don't want the \Lopt{draft} option to be passed on.
+% So explicitly pass the \Lopt{final} option to these packages.
+% \begin{macrocode}
+\PassOptionsToPackage{final}{graphicx}
+\PassOptionsToPackage{final}{pdfpages}
+% \end{macrocode}
+%
+% %%%CONFIGURE%%%
+% Define a logo for the University, which will appear in the exam header.
+% This should be a macro which takes a single argument giving the
+% required width of the logo, and which produces a |\vbox|.
+% \begin{macrocode}
+\def\UniLogo#1{\vbox to 15.5mm{%
+ \hrule
+ \vss\hbox to #1{% Aspect ratio of logo is 100x31
+ \hss no logo available\hss
+ }%
+ \vss
+ \hrule}}
+% \end{macrocode}
+%
+% Other required packages
+% \begin{macrocode}
+\RequirePackage[english]{babel} % UK hyphenation
+\RequirePackage{amsmath}
+\RequirePackage{color}
+% \end{macrocode}
+%
+% I think flush-left equations look MUCH better than centred, but
+% Harry disagrees, so it's not the default.
+% \begin{macrocode}
+\LoadClass{article}
+% \end{macrocode}
+%
+% \subsection{Layout}
+%
+% First, handle PDF metadata, and other document identifiers.
+%
+% Generate an identifier, |\examn@docident| for this paper. This is obtained
+% from the university or school course code, followed by the
+% day-of-year, and the number of minutes since midnight (the goal here
+% is to produce an identifier which automatically increments in time,
+% but which isn't obviously a date
+% \begin{macrocode}
+\def\examn@setdocident{%
+ \begingroup
+ % yes, a big \ifcase would be more straightforward;
+ % no, that wouldn't be any fun at all
+ % (also it ends up looking messy and even tricksier).
+ \def\@step##1##2\@nil{\advance\@tempcnta##1 \def\@tempa{##2}}
+ \def\@tempa{{31}{28}{31}{30}{31}{30}{31}{31}{30}{31}{30}{31}}%
+ \@tempcnta=\day % day of month
+ \@tempcntb=\month % month of year (unit-offset)
+ \loop
+ \advance\@tempcntb-1
+ \ifnum \@tempcntb>0
+ \expandafter\@step\@tempa\@nil
+ \repeat
+ \@tempcntb=\year % yes, do calculate leap years
+ \divide\@tempcntb 4 \multiply\@tempcntb 4
+ \ifnum\@tempcntb=\year
+ \ifnum\month>2 % but let's not worry about century years...
+ \advance\@tempcnta 1
+ \fi
+ \fi
+ % remove any \\ or ~ in the coursecode fields
+ \let\\\space
+ \let~\space
+ \xdef\examn@docident{% first element is based on uni/school course code
+ \ifx\@coursetitle\@empty
+ \ifx\@schoolcoursecode\@empty
+ exam%
+ \else
+ \@schoolcoursecode
+ \fi
+ \else
+ \@coursetitle
+ \fi
+ /\the\@tempcnta % day-of-year
+ -\the\time} % minutes since midnight
+ \endgroup
+}
+% \end{macrocode}
+% Check whether we're generating PDF, and define the |\ifpdf| macro
+% accordingly. This does depend on Oberdiek's \Lpackage{ifpdf} package being
+% available, but that's been available for quite a long while, and if
+% it isn't for some people's installations, we can potentially bring
+% back the code which it replaces.
+% \begin{macrocode}
+\RequirePackage{ifpdf}
+\def\@SetDocumentInfo{%
+ \ifpdf
+ {\pdfinfo{/Title (\examn@docident)}}%
+ % Don't put out an /Author(xxx) info entry -- there may be
+ % multiple authors, and it isn't obviously useful
+ \fi
+}
+\AtBeginDocument{\examn@setdocident\@SetDocumentInfo}
+% \end{macrocode}
+%
+% Choose the font set, based on |\if@psfonts| and |\examn@mtselect|.
+% \begin{macrocode}
+\if@psfonts
+ \ifcase\examn@mtselect
+ \ifexamn@serif
+ \RequirePackage{times}
+ \else
+ \RequirePackage{helvet}
+ \fi
+ \RequirePackage{mathptm}
+ \ClassWarningNoLine{exam-n}{Using mathptm fonts}
+ \or % use mathtime fonts
+ \RequirePackage[LY1]{fontenc} % specify text font encoding
+ \RequirePackage[LY1,mtbold]{mathtime} % switch math fonts
+ \ifexamn@serif
+ \RequirePackage{times}
+ \else
+ \RequirePackage{helvet}
+ \fi
+ \ClassWarningNoLine{exam-n}{Using Mathtime fonts}
+ \or % use mtpro2 fonts
+ \RequirePackage[T1]{fontenc}
+ \RequirePackage{textcomp}
+ \ifexamn@serif
+ \renewcommand\rmdefault{ptm} % the default
+ \else
+ \RequirePackage[scaled=0.9]{helvet}
+ \renewcommand\rmdefault{phv}
+ \fi
+ \RequirePackage[mtpbb]{mtpro2}
+ \ClassWarningNoLine{exam-n}{Using MTPro2 fonts}
+ \else
+ \ClassError{exam-n}{Impossible value of mtselect: \examn@mtselect}
+ \fi
+\else
+ \ClassWarningNoLine{exam-n}{Using CM fonts}
+\fi
+% \end{macrocode}
+% If we're using a sans serif font, then redefine |\normalfont| appropriately.
+% The macro |\examn@bodyfontchange| stores up these font changes until
+% they're applied just after |\maketitle|.
+% \begin{macrocode}
+\def\examn@bodyfontchange{}
+\ifexamn@serif \else
+ \ClassWarningNoLine{exam-n}{Using sans serif fonts}
+ \DeclareRobustCommand\normalfont
+ {\usefont\encodingdefault\sfdefault\seriesdefault\shapedefault \relax}
+\fi
+% \end{macrocode}
+% And similarly for the case where we want large fonts.
+% This (as it turns out) requires changing only |\normalsize| and not
+% |\normalfont|, so the two are in principle compatible; however we
+% implement both of them by redefining |\examn@bodyfontchange|, so
+% they're not in practice (a future fix, perhaps).
+% \begin{macrocode}
+\ifcase\examn@fontvariant
+ % default: do nothing
+\or
+ % font variant 1: 18pt
+ \def\examn@bodyfontchange{
+ \renewcommand\normalsize{%
+ \@setfontsize\normalsize{18}{24}%
+ \abovedisplayskip 18\p@ \@plus3.5\p@ \@minus9\p@
+ \abovedisplayshortskip \z@ \@plus5\p@
+ \belowdisplayshortskip 10\p@ \@plus5\p@ \@minus5\p@
+ \belowdisplayskip \abovedisplayskip
+ \let\@listi\@listI}
+ \parindent=24pt
+ \parskip=18pt
+ % Redefine \FormatPartMarks so that it doesn't push the text off the paper
+ \let\FormatPartMarks\examn@variantFormatPartMarks
+ }
+\or
+ % font variant 2: 36pt
+ \def\examn@bodyfontchange{
+ \renewcommand\normalsize{%
+ \@setfontsize\normalsize{36}{42}%
+ \abovedisplayskip 36\p@ \@plus7\p@ \@minus17.5\p@
+ \abovedisplayshortskip \z@ \@plus10.5\p@
+ \belowdisplayshortskip 21\p@ \@plus10.5\p@ \@minus10.5\p@
+ \belowdisplayskip \abovedisplayskip
+ \let\@listi\@listI}
+ \parindent=48pt
+ \parskip=36pt
+ % Redefine \FormatPartMarks so that it doesn't push the text off the paper
+ \let\FormatPartMarks\examn@variantFormatPartMarks
+ }
+\else
+ % Bad font variant
+ \ClassError{exam-n}
+ {Bad font variant \examn@fontvariant}
+ {I didn't expect to see that number (broken style file re largefont/hugefont?)}
+\fi
+% \end{macrocode}
+% The above font variants require a |\FormatPartMarks| variant which
+% avoids being pushed off the edge of the page.
+% \begin{macrocode}
+\def\examn@variantFormatPartMarks#1{%
+ \setbox0=\hbox{\hskip 1em \textbf{[#1]}}%
+ \@tempdima=0.8\marginsize
+ \ifdim\wd0>\@tempdima
+ \advance\@tempdima -\wd0
+ \hbox to 0pt{\hskip\@tempdima \box0\hss}%
+ \else
+ \hbox to 0pt{\box0\hss}%
+ \fi}
+% \end{macrocode}
+%
+% \subsubsection{Exam metadata}
+%
+% \begin{macrocode}
+\def\@exambanner{}
+\def\exambanner{\def\@exambanner}
+
+\def\@schoolcoursecode{}
+\def\schoolcoursecode{\def\@schoolcoursecode}
+
+\def\@universitycoursecode{}
+\def\universitycoursecode{\def\@universitycoursecode}
+
+\def\@paperident{}
+\def\paperident{\def\@paperident}
+
+\def\@examdate{}
+\def\examdate{\def\@examdate}
+
+\def\@examtime{}
+\def\examtime{\def\@examtime}
+
+\def\@coursetitle{}
+\def\coursetitle{\def\@coursetitle}
+% \end{macrocode}
+% Display the degree descriptions, which are separated by |\\|. Put
+% each one in an |\hbox|, so it doesn't break over the line.
+% \begin{macrocode}
+\def\@degreedescriptions{}
+\def\degreedescriptions{\def\@degreedescriptions}
+\def\@displaydegreedescriptions{%
+ \let\@tempb\leavevmode
+ \def\dd##1\\{%
+ \def\@tempa{##1}%
+ \ifx\@tempa\@empty
+ \let\next\relax
+ \else
+ \@tempb\hbox{##1}\let\next\dd
+ \fi
+ \def\@tempb{\discretionary{}{}{\kern0.5em--\kern0.5em}}%
+ \next}
+ \expandafter\dd\@degreedescriptions\\}
+% \end{macrocode}
+% The rubric is typically a per-exam thing. The `base rubric' is
+% more-or-less common to all exams, though it's possible to override
+% it in a .clo file.
+% \begin{macrocode}
+\def\@rubric{}
+\def\rubric{\long\def\@rubric}
+\def\norubric{\let\@rubric\@nnil}
+
+\def\@baserubric{%
+\textbf{Answer each question in a separate booklet}\par
+Candidates are reminded that devices able to store or display text or
+images may not be used in examinations without prior arrangement.
+\if@perquestionmarks
+ \par
+ Approximate marks are indicated in brackets as a guide for candidates.
+\fi
+}
+\def\baserubric{\long\def\@baserubric}
+% \end{macrocode}
+%
+% We can optionally check the total number of questions. Store this
+% if it is present, and add a check to the |\end{document}| to check
+% it at the end if it was indeed set at the beginning. Command
+% |\CheckTotalQuestions| is added to |\AtEndDocument| below.
+% \begin{macrocode}
+\def\@numquestions{}
+\def\numquestions{\def\@numquestions}
+\def\CheckTotalQuestions{%
+ \ifnum\@draftstatus < 2
+ \ifx\@numquestions\@empty \else
+ \ifnum\c@questionnumber=\@numquestions \else
+ \ClassWarning{exam-n}
+ {Expected \@numquestions\space questions, got \thequestionnumber!}
+ \ifnum\@draftstatus > 0 % draft mode
+ \begin{center}
+ \textbf{\highlighted{Expected \@numquestions\space questions, got \thequestionnumber}}
+ \end{center}
+ \fi
+ \fi
+ \fi
+ \fi
+}
+% \end{macrocode}
+%
+%
+% \subsection{Geometry and colours}
+%
+% Adjust the spacing for article and amsmath flush-left equations.
+% Amsmath doesn't use |\mathindent| in the same way \LaTeX\ does, and
+% this semi-workaround may break with early versions of amsmath. See
+% the amsmath FAQ at http://www.ams.org/tex/amsmath-faq.html for
+% some discussion.
+% \begin{macrocode}
+\if@fleqn
+ \mathindent\parindent
+ \@mathmargin=\parindent
+\fi
+% \end{macrocode}
+%
+% |\marginsize| is the size of the margin all round. Users shouldn't
+% change this in normal circumstances, but are free to if they have
+% some particular reason. Note that if all you want to do is move the
+% text to one side for printing reasons, use |\nudgeleft|.
+% \begin{macrocode}
+\newdimen\marginsize
+ \marginsize=35mm
+
+\headheight=15pt
+\headsep=15pt
+% \end{macrocode}
+%
+% It's useful to colour-code material that's present in the compose
+% and draft modes but which won't appear in the final version; this
+% partly reassures question authors that this is `meta' material.
+% \begin{macrocode}
+\definecolor{meta}{rgb}{0.7,0.2,0.2}
+\def\highlighted{\textcolor{meta}}
+% \end{macrocode}
+% We (currently) want solutions to appear as coloured blocks. The
+% colour is this one:
+% \begin{macrocode}
+\definecolor{solutiontext}{rgb}{0.2,0.2,0.5}
+% \end{macrocode}
+% And finally a colour for `discreet' information, such as identifier
+% numbers.
+% \begin{macrocode}
+\definecolor{discreettext}{rgb}{0.6,0.6,0.6}
+% \end{macrocode}
+%
+% Set up the textblock in |\@settextblock|.
+% The argument is the amount by which the text block is to be nudged
+% to the left.
+% \begin{macrocode}
+\newcommand\@settextblock[1]{
+ \textwidth=\paperwidth
+ \advance\textwidth -2\marginsize
+ \textheight=\paperheight
+ \advance\textheight -2\marginsize
+ \oddsidemargin=\marginsize
+ \advance\oddsidemargin -1in
+ \advance\oddsidemargin -#1
+ \evensidemargin=\oddsidemargin
+ \topmargin=\marginsize
+ \advance\topmargin -\headheight
+ \advance\topmargin -\headsep
+ \advance\topmargin -1in
+ \marginparwidth=\marginsize
+ \advance\marginparwidth -1.5cm
+ \advance\marginparwidth #1
+%% \typeout{paperwidth=\the\paperwidth, paperheight=\the\paperheight,
+%% textwidth=\the\textwidth, textheight=\the\textheight,
+%% oddsidemargin=\the\oddsidemargin,
+%% headheight=\the\headheight, headsep=\the\headsep, topmargin=\the\topmargin}
+ \marginparsep=0.5cm
+}
+
+\ifnum\@draftstatus > 0
+ \@settextblock{2cm}
+\else
+ \@settextblock{0pt}
+\fi
+% \end{macrocode}
+% |\leftnudge| is the amount by which the textblock is shifted
+% leftwards. This is usually zero, but is given a non-zero value in
+% draft modes, to give space for marginal comments, and may be given a
+% non-zero value by users, in the preamble, if that is required for
+% some reason by some limitation of the subsequent printing process.
+% It may be negative, to nudge the block rightwards.
+% \begin{macrocode}
+\let\leftnudge\@settextblock
+% \end{macrocode}
+%
+% Format the marginal paragraphs (ie, comments)
+% \begin{macrocode}
+\renewcommand\@marginparreset{%
+ \reset@font
+ \@setminipage
+ \raggedright
+ \small
+}
+% \end{macrocode}
+%
+% Add a few other formatting parameters.
+%
+% Note that the (default) layout of |\FormatPartNumber| depends on a
+% non-zero |\parindent|, so if the latter is changed, the former must
+% be, too. In fact, if |\parindent| is zero or otherwise small,
+% \begin{quotation}
+% \catcode`\|=0
+% |begingroup |ttfamily
+% \catcode`\{=12 \catcode`\}=12 \catcode`\\=12
+% |noindent \newcommand\FormatPartNumber{|linebreak
+% |noindent|quad\hbox to 2em{(\StylePartNumber{partnumber})\hss}}
+% |endgroup
+% \end{quotation}
+% works adequately as a part number,
+% though this does result in paragraphs being a little hard to make
+% out, unless there's a really generous |\parskip|.
+% \begin{macrocode}
+\setlength{\parindent}{2em}
+\setlength{\parskip}{\bigskipamount}
+% \end{macrocode}
+%
+% We must clear out any floats at the end of the paper, without
+% forcing a new page (figures and tables don't float, but there are
+% other packages which can generate floats, such as the
+% \Lenv{sidewaystable} from the \Lpackage{rotating} package).
+% This technique is simplified form Donald Arsenau's \Lpackage{placeins} package.
+% \begin{macrocode}
+\def\examn@flushfloats{\par
+ \begingroup
+ \edef\@tempa{\@deferlist\@dbldeferlist}
+ \ifx\@tempa\@empty \else
+ \clearpage
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% Text at the end of the paper. Command |\ClosingText| is added to
+% |\AtEndDocument|, below.
+% \begin{macrocode}
+\ifcase\@draftstatus % Final version
+ \def\ClosingText{
+ \examn@flushfloats
+ \begin{center}\textbf{End of Paper}\\\end{center}
+ \mark{END}}
+\or % Draft version
+ \def\ClosingText{
+ \examn@flushfloats
+ \begin{center}\textbf{End of Draft Paper}\\\end{center}
+ \mark{END}}
+\else % Compose version (nothing, because this would be on a page by itself)
+ \def\ClosingText{
+ \examn@flushfloats
+ \mark{END}}
+\fi
+% \end{macrocode}
+%
+% \subsection{Headings and marks}
+%
+% The headers and footers include continuation information.
+% \begin{macrocode}
+\RequirePackage{fancyhdr}
+\pagestyle{fancy}
+\setlength{\headwidth}{\textwidth}
+\renewcommand{\headrulewidth}{0pt}
+\renewcommand{\footrulewidth}{0pt}
+\fancyhead{}
+\fancyfoot{}
+% \end{macrocode}
+% Include an identifier in the footer, unless an identifier is present
+% in |\@paperident|.
+% \begin{macrocode}
+\fancyfoot[L]{{\tiny\textcolor{discreettext}{%
+ \ifx\@paperident\@empty\examn@docident\else\@paperident\fi
+}}}
+% \end{macrocode}
+% We use marks to determine whether, at the top of the page, we're
+% continuing a question or starting a new one. Set |\mark{n}| at the
+% beginning of a question, and |\mark{}| at the end. In principle, if
+% |\topmark| is non-empty, then we're currently in the given question,
+% and if it's empty, we're not. Now, the \LaTeX\ floats mechanism
+% (which is involved in the handling of marginpars as well as floats)
+% interferes with this because it can call the output routine other
+% than at the end of a page. Thus |\topmark| is essentially useless
+% within \LaTeX, if there's any change of a float appearing.
+%
+% However, we can work around this by setting |\examn@topmark| in the
+% page footer, to be the value of |\botmark| there. I think this has
+% exactly the same semantics as |\topmark|, possibly apart from some
+% pathological situations.
+%
+% So, for the footer, we include a continuation mark if and only if
+% |\examn@topmark| is non-empty. We additionally store |\botmark| into |\examn@topmark|.
+% \begin{macrocode}
+\fancyfoot[R]{%
+ \def\@tempa{END}
+ \xdef\examn@topmark{\botmark}
+ \ifx\examn@topmark\@empty
+ \formatcontinuations{Paper continued over\dots}%
+ \else\ifx\examn@topmark\@tempa
+ \formatcontinuations{END}
+ \else
+ \formatcontinuations{Q\,\examn@topmark\ continued over\dots}%
+ \fi\fi
+}
+\fancyfoot[C]{\thepage/\pageref{lastpage}}
+% \end{macrocode}
+% In the header, we perform essentially the same test, using the
+% |\examn@topmark| we saved in the previous page's footer.
+% \begin{macrocode}
+\def\examn@topmark{}
+\ifnum\@draftstatus=0
+ \fancyhead[L]{%
+ \ifx\examn@topmark\@empty \else
+ \formatcontinuations{Q\,\examn@topmark\ continued}%
+ \fi
+ }
+\fi
+% \end{macrocode}
+% We use the header to shout out the status of the paper, in
+% particular making it very clear if we're showing the exam answers:
+% we don't want this version to be accidentally distributed at the exam\dots.
+% The |\examn@bighead| macro sets its contents in a large box, but
+% without making the header any larger -- we want the headheight in
+% drafts to be the same as in the final version (because otherwise
+% we'd get different page breaks).
+% \begin{macrocode}
+\def\examn@bighead#1{\strut\vbox to 0pt{\vss\hbox{\examn@header@shoutformat{#1}}\vskip 10mm}}
+\ifnum\@draftstatus = 1
+ \if@showsolutions
+ \fancyhead[C]{\examn@bighead{\highlighted{DRAFT + SOLUTIONS, p\thepage/\pageref{lastpage}}}}
+ \else
+ \fancyhead[C]{\examn@bighead{\highlighted{DRAFT, p\thepage/\pageref{lastpage}}}}
+ \fi
+\else
+ \if@showsolutions
+ % Add a very prominent banner
+ \fancyhead[C]{\examn@bighead{\highlighted{SHOWING SOLUTIONS}}}
+ \fi
+\fi
+% \end{macrocode}
+%
+% Allow \texttt{.clo} files to override the formatting of the various
+% continuation markers.
+% \begin{macrocode}
+\def\formatcontinuations#1{\textbf{#1}}
+% \end{macrocode}
+%
+% Now define a command which writes out the page number of the last
+% page. This is added to |\AtEndDocument|, in the correct order, below.
+% \begin{macrocode}
+\def\WriteLastPageLabel{\label{lastpage}}
+% \end{macrocode}
+%
+% \subsubsection{The title page}
+%
+% Define a special page style for the title page
+% No header: all of the text on the page is handled by |\maketitle|
+% The first-page footer doesn't show anything, but it does have to set
+% |\examn@topmark| in case Q1 starts on this page.
+% \begin{macrocode}
+\def\ps@titlepage{
+ \def\@oddhead{}
+ \def\@oddfoot{\xdef\examn@topmark{\botmark}}
+}
+% \end{macrocode}
+%
+% Create a custom maketitle.
+% First, handle the 'final' or 'draft' versions.
+% Check all required information is present.
+% \begin{macrocode}
+\renewcommand\maketitle{
+ \ifnum\@draftstatus < 2 % final or draft version
+ \ifx\@examdate\@empty
+ \ClassError{exam-n}
+ {No exam date given}
+ {Specify an exam date using \protect\examdate}
+ \fi
+ \ifx\@examtime\@empty
+ \ClassError{exam-n}
+ {No exam time given}
+ {Specify an exam time using \protect\examtime}
+ \fi
+ \ifx\@exambanner\@empty
+ \ClassError{exam-n}
+ {No exam banner given}
+ {Specify an exam banner (eg Examination for the degree...) using \protect\exambanner}
+ \fi
+ \if@fussydescription
+ \ifx\@schoolcoursecode\@empty
+ \ClassError{exam-n}
+ {No school course code given}
+ {Specify a school course code (eg P304H) using \protect\schoolcoursecode}
+ \fi
+ \ifx\@universitycoursecode\@empty
+ \ClassError{exam-n}
+ {No paper title given}
+ {Specify a university course code (eg PHYS3031) using \protect\universitycoursecode}
+ \fi
+ \ifx\@coursetitle\@empty
+ \ClassError{exam-n}
+ {No course title given}
+ {Specify a course title (eg Quantum Mechanics) using \protect\coursetitle}
+ \fi
+ \ifx\@degreedescriptions\@empty
+ \ClassError{exam-n}
+ {No paper subject given}
+ {Specify a 'degree description' (eg Physics 3) using \protect\degreedescriptions}
+ \fi
+ \ifx\@rubric\@empty
+ \ClassError{exam-n}
+ {No rubric given}
+ {Specify a rubric using \protect\rubric, or declare its absence with \protect\norubric}
+ \fi
+ \fi
+% \end{macrocode}
+% All OK so far\dots. Now produce the actual text.
+% \begin{macrocode}
+ \thispagestyle{titlepage}
+ \begin{center}
+ \null
+ \vskip -1.5cm
+% \end{macrocode}
+% Firse produce headers at the top, which highlight things which make
+% the paper non-distributable (eg, it includes the answers!).
+% Only highlight the number of shouts when we're not showing
+% solutions. The highlights above indicate clearly that the
+% paper is not in its distributable format; the purpose of
+% this output here is to highlight that the paper is still not
+% distributable, \emph{even though} it's not showing solutions.
+% \begin{macrocode}
+ \if@showsolutions
+ \nointerlineskip
+ \vbox to 0pt{\vss
+ \examn@header@shoutformat{\shout{SHOWING SOLUTIONS}}
+ \vskip 1.5\bigskipamount}
+ \else
+ \ifnum\examn@shoutcounttotal>0
+ \typeout{SHOUTS: \the\examn@shoutcounttotal}
+ \nointerlineskip
+ \vbox to 0pt{\vss
+ \examn@header@shoutformat
+ {\highlighted{SHOUTS: \the\examn@shoutcounttotal\ (see end)}}
+ \vskip 1.5\bigskipamount}
+ \fi
+ \fi
+ \nointerlineskip
+% \end{macrocode}
+% The logo, in a zero-size box.
+% \begin{macrocode}
+ \hbox to \textwidth{% date and time
+ \vbox to 0pt{\vskip-2ex \UniLogo{50mm}\vss}
+ \hss
+% \end{macrocode}
+% Make the |\@examtime| box have zero depth, or else fancyhead
+% complains that the size of the header isn't big enough, and
+% ups it for the whole document. In this position, it's OK that
+% it juts out of the bottom of the header line.
+% \begin{macrocode}
+ \setbox0=\hbox{\vtop{% \vtop or \vbox here?
+ % Opinions differ:
+ % This week, Norman prefers \vtop because it gives a cleaner top line.
+ \hsize=0.5\textwidth
+ \leftskip=0pt plus1fil \rightskip=0pt \parfillskip=0pt
+ \baselineskip=2.5ex
+ \parskip=0.25ex
+ \let\\\par
+ \ifx\@examdate\@empty
+ \shout{missing exam date}
+ \else
+ \@examdate
+ \fi
+ \par
+ \ifx\@examtime\@empty
+ \shout{missing exam time}
+ \else
+ \@examtime
+ \fi
+ \par}}
+ \dp0=0pt
+ \box0}
+ \vskip4\bigskipamount
+ %\UoGname\\[\medskipamount]
+ {\uppercase\expandafter{\@exambanner}}\\[\medskipamount]
+ \vbox{}\hrule
+ \ifx\@degreedescriptions\@empty\else
+ \@displaydegreedescriptions\\
+ \fi
+% \end{macrocode}
+% Exam identification. The |\@coursetitle| is the most important
+% item, so make that biggest.
+% Adjust the size of the course title so that it fits on to one line
+% (though if |\Large| is still too big, then we give up and go to multiple lines).
+% \begin{macrocode}
+ \vskip 2\baselineskip plus 0.3fil
+ \def\@tempa{\def\@tempa{\vskip 0.5\baselineskip}}
+ \ifx\@schoolcoursecode\@empty\else
+ \@tempa
+ {\large\textbf{\@schoolcoursecode}}
+ \fi
+ \ifx\@universitycoursecode\@empty\else
+ \@tempa
+ {\large\textbf{[~\@universitycoursecode~]}}
+ \fi
+ \ifx\@coursetitle\@empty\else
+ \setbox0=\hbox{\Huge\textbf{\@coursetitle}}
+ \ifdim\wd0>\columnwidth
+ \setbox0=\hbox{\LARGE\textbf{\@coursetitle}}
+ \ifdim\wd0>\columnwidth
+ % we're not going any smaller than this
+ \setbox0=\vbox{\hsize\columnwidth
+ \Large\bfseries
+ \@coursetitle}
+ \fi
+ \fi
+ \vskip 1.2\ht0 % generous vertical skip, size-dependent
+ \ifhbox0
+ \hbox to \columnwidth{\hss\box0\hss}
+ \else
+ \box0
+ \fi
+ \fi
+% \end{macrocode}
+% Rubric(s). The macros |\@empty| and |\@nnil| both have an empty
+% expansion. The difference between them is that |\@rubric| is set to
+% |\@nnil| by |\norubric| to indicate that |\@rubric| is deliberately
+% empty, whereas if |\@rubric| is |\@empty|, that's trapped in the
+% checks above as an error.
+% \begin{macrocode}
+ \vskip 2\baselineskip plus 0.3fil
+ \parindent=0pt
+ \parskip=0.5\baselineskip
+ \ifnum\examn@fontvariant > 0
+ % Don't put the rubric here (see below)
+ {\LARGE Rubric: see overleaf}
+ \else
+ \ifx\@rubric\@empty\else
+ \ifx\@rubric\@nnil\else
+ % If there's a rubric, separate from the base rubric, then
+ % separate the two with an hrule (the per-exam rubric
+ % presumably represents special instructions for this exam,
+ % so should be highlighted)
+ \vbox{\let\emph\textbf
+ \@rubric
+ \par}
+ \vskip2\baselineskip
+ \hrule
+ \vskip1.5\baselineskip
+ \fi
+ \fi
+% \end{macrocode}
+% Let the base rubric be a justified block of text near the bottom.
+% \begin{macrocode}
+ \ifx\@baserubric\@empty \else
+ \@baserubric \par
+ \fi
+ \fi % end \ifbigfont \else ...
+ \end{center}
+% \end{macrocode}
+% These various fractions of fil glue don't add up as I'd expect
+% them to. No matter: the fractions here produce some spreading
+% out of the rubrics below the titles, which is what I'm after.
+% \begin{macrocode}
+ \vskip 2\baselineskip plus 0.6fil % \newpage is {\vfil\penalty-\@M}
+ \vbox to 0pt{\hbox to \textwidth{%
+ \tiny
+ \textcolor{discreettext}
+ {\hfil\ifx\@paperident\@empty\examn@docident\else\@paperident\fi\hfil}}\vss}
+ \penalty -\@M
+ \@displayconstants
+% \end{macrocode}
+% The compose version is nice and simple, because we don't have to do
+% any checks. FIXME: Hmm: this is largely redundant, because we don't
+% document, and so don't really support, including the metadata in the
+% [compose] mode preamble. However we clearly did include this as one
+% point: was that just out of whim, or was there a requirement for that?
+% \begin{macrocode}
+ \else % compose version
+ \begin{tabular}{rl}
+ \textbf{Exam}&
+ {\def\\{ / }\@schoolcoursecode}\\
+ \textbf{Course codes}&
+ \@universitycoursecode\\
+ %% \textbf{Subject}&
+ %% {\def\and{and}\begin{tabular}
+ %% {\@degreedescriptionstemplate}\@degreedescriptions
+ %% \end{tabular}}\\
+ \textbf{Date \& time}&
+ {\def\\{, }\@examdate, \@examtime}\\
+ \end{tabular}
+ \fi
+% \end{macrocode}
+% And chatter about what decision we've made.
+% \begin{macrocode}
+ \ifcase\@draftstatus
+ % Final version
+ \typeout{Exam \@schoolcoursecode: FINAL VERSION}
+ \or % Draft version
+ \typeout{Exam \@schoolcoursecode: DRAFT VERSION}
+ \else % Compose version
+ \typeout{Exam \@schoolcoursecode: COMPOSE VERSION}
+ \fi
+ %
+ \examn@bodyfontchange
+ \normalfont\normalsize
+ \ifnum\examn@fontvariant>0
+ % Put the rubric on a second page, in the 'huge' size.
+ \begin{center}
+ \parskip=18pt
+ \let\emph\textbf \@rubric\par
+ \vskip\baselineskip
+ \hrule
+ \vskip\baselineskip
+ \ifx\@baserubric\@empty \else
+ \@baserubric \par
+ \fi
+ \end{center}
+ \newpage
+ \fi
+}
+% \end{macrocode}
+%
+% \subsection{Structuring commands}
+%
+% Define simple sectioning commands. We also check that these aren't
+% inside questions.
+% \begin{macrocode}
+\setcounter{secnumdepth}{0}
+% \end{macrocode}
+% Redefine |\section|, to include a check that it's not being called
+% within a question (|\@currentquestion| is defined only inside the
+% \Lenv{question} or \Lenv{mcq} environments).
+% \begin{macrocode}
+\renewcommand\section{
+ \@ifundefined{@currentquestion}\@@section
+ {\ClassError{exam-n}{Misplaced section}
+ {You can't have a section inside a question;\MessageBreak
+ move it before the {question} environment starts}}}
+\newcommand\@@section{\@startsection{section}{1}{\z@}%
+ {-3.5ex \@plus -1ex \@minus -.2ex}%
+ {1ex \@plus.1ex \@minus 0.5ex}%
+ {\fmt@section}}
+\def\fmt@section#1{%
+ \examn@prequestionspace{}
+ \hbox to \textwidth{{\hfil\bfseries SECTION #1\hfil}}%
+}
+% \end{macrocode}
+% Redefine |\subsection| similarly.
+% \begin{macrocode}
+\renewcommand\subsection{
+ \@ifundefined{@currentquestion}\@@subsection
+ {\ClassError{exam-n}{Misplaced subsection}
+ {You can't have a subsection inside a question;\MessageBreak
+ move it before the {question} environment starts}}}
+\newcommand\@@subsection{\@startsection{subsection}{2}{\z@}
+ {-2ex \@plus -3ex \@minus -0.2ex}
+ {0.5ex \@plus .1ex \@minus 0.1ex}
+ {\fmt@subsection}}
+\def\fmt@subsection#1{%
+ \examn@prequestionspace{}
+ \noindent\textbf{#1}}
+% \end{macrocode}
+% We must redefine the section and subsection mark commands to gobble
+% their arguments. If we don't, then \LaTeX\ gets \emph{terribly}
+% confused about what the mark is. I don't quite follow what happens
+% in this case, but symptoms include Babel blowing up, and
+% \TeX\ running out of stack space. So: bad.
+% \begin{macrocode}
+\let\sectionmark\@gobble
+\let\subsectionmark\@gobble
+% \end{macrocode}
+%
+% Just to be safe, we should also disable the other sectioning
+% commands.
+% \begin{macrocode}
+\def\@badsection#1#2{\ClassError{guexam}{Bad section}
+ {The exam class goes not support subdivisions like #1{#2}}}
+\def\subsubsection{\@badsection{subsubsection}}
+\def\paragraph{\@badsection{paragraph}}
+\def\subparagraph{\@badsection{subparagraph}}
+% \end{macrocode}
+%
+% The above redefinitions break the |\tableofcontents| macro.
+% It's unlikely but \emph{possibly} useful, in some cases, to have a
+% table of contents in an exam paper. Whether or not it is, we should
+% avoid breaking it, on a principle of least surprise. The following
+% makes the macro work again, even though it's not particularly
+% pretty.
+% \begin{macrocode}
+\renewcommand\tableofcontents{\bigskip
+ \hbox to \textwidth{\hfil\textbf{\Large Contents}\hfil}%
+ \@starttoc{toc}}
+% \end{macrocode}
+%
+% Counters:
+% \begin{macrocode}
+\newcount\marktotal % number of marks accumulated so far
+\newcount\markgoal % number of marks we should have in the end
+\newcounter{questionnumber}
+\setcounter{questionnumber}0
+% \end{macrocode}
+%
+% Counter partnumber holds the number (i,ii,iii, etc) of the parts
+% within a question. It's a \LaTeX\ counter, so we can use |\roman|.
+%
+% We override the \Lenv{article} |\part| command.
+% \begin{macrocode}
+\newcounter{partnumber}
+\renewcommand\part{%
+ \if@nobreak \else
+ \par
+ \@nobreakfalse
+ \fi
+ \ifvmode
+ \vskip 0pt plus 4\bigskipamount
+ \penalty-50
+ \fi
+ \stepcounter{partnumber}%
+ \noindent\FormatPartNumber
+}
+% \end{macrocode}
+% The default |\FormatPartNumber| creates a box the same size as a
+% parindent. This therefore assumes that it's following a |\noindent|.
+% \begin{macrocode}
+\newcommand\FormatPartNumber{\hbox to \parindent{(\StylePartNumber{partnumber})\hss}}
+% \end{macrocode}
+% And by default we use alphanumeric counters for parts (we abstract
+% this, rather than simply including |\alph| in the definition of
+% |\FormatPartNumber|, so that we use the same style for the
+% `answerpartnumber' counter.
+% \begin{macrocode}
+\let\StylePartNumber\alph
+% \end{macrocode}
+%
+% A flag indicating whether we should start a new page before the next
+% question. This is manipulated by both |\section| and |\question|.
+% \begin{macrocode}
+\newif\if@newpagebeforequestion
+\if@pageperquestion
+ \@newpagebeforequestiontrue
+\else
+ \@newpagebeforequestionfalse
+\fi
+% \end{macrocode}
+%
+% The command |\examn@prequestionspace| is called just before we start a
+% new question, or before we start a header which precedes a
+% question. It adds some vertical space, given in the argument,
+% unless the |@pageperquestion| settings imply that this should be a
+% newpage instead, in which case the vertical space here is ignored.
+% \begin{macrocode}
+\def\examn@prequestionspace#1{%
+ \if@pageperquestion
+ \if@newpagebeforequestion
+ % Add all the stretchability here, rather than stretching out
+ % displays and lists above this on the page.
+ \newpage
+ % Clear the \@newpagebeforequestion flag, to suppress the action
+ % of any following calls to \examn@prequestionspace, until the end
+ % of the next question.
+ \global\@newpagebeforequestionfalse
+ \fi
+ \else
+ #1%
+ \fi
+}
+% \end{macrocode}
+%
+% Macro |\examn@endquestion| gathers here a couple of checks shared
+% between end-of-question macros (see the \Lenv{mcq} environment and
+% the |\endquestion| macro).
+% The argument to the |\examn@endquestion| macro is material (such as the
+% mark-total) which should go at the end of the question,
+% and be surrounded by various spacing and resetting actions.
+% \begin{macrocode}
+\long\def\examn@endquestion#1{%
+ \mark{} % the position of this call is slightly sensitive (but this works)
+ \if@pageperquestion
+ \global\@newpagebeforequestiontrue
+ \fi
+ #1
+ \@nobreakfalse
+ \everypar{}
+}
+% \end{macrocode}
+%
+% |\partmarks| is used at the end of a paragraph to indicate the
+% number of marks associated with this part. The starred variant
+% |\partmarks*| is used when the end of a part is the end of a display
+% maths block which doesn't have an equation number. This moves the
+% part note up a bit, which looks nicer.
+% \begin{macrocode}
+\def\partmarks{%
+ \@ifstar{\@tempswatrue \@partmarks}{\@tempswafalse \@partmarks}}
+\newdimen\@partmarksspace
+ \@partmarksspace=2em % default value
+% \end{macrocode}
+% Now implement the part marks indicator. First, check that
+% `perquestionmarks' is turned on; if it's not, then we shouldn't be
+% using |\partmarks|.
+% \begin{macrocode}
+\def\@partmarks#1{%
+ \if@perquestionmarks
+ \if@insolution
+ % visual display only -- doesn't count towards mark total
+ \setbox0=\vbox to 0pt{\vss
+ \hbox to \textwidth{\hfil\hbox to 0pt{\quad\small[\dots #1]\hss}}
+ \vskip0.25ex }%
+ % the next line is probably unnecessary, but guarantees that box0
+ % has zero depth, so no extra vertical space appears because of
+ % this new box
+ \dp0=0pt
+ \ifvmode
+ \box0
+ \else
+ \vadjust{\nointerlineskip\box0}%
+ \fi
+ \else
+ \global\advance\marktotal #1
+ \if@tempswa
+% \end{macrocode}
+% This is the starred form of |\partmarks|. That is, this is being invoked
+% (i) just after maths (or some other display which doesn't fill the line),
+% \emph{or} (ii) at the end of an unnumbered equation. In case (i),
+% we move the part mark up a bit; in case (ii), we format the
+% partmarks as a type of equation number
+%
+% We handle case (ii) first, by detecting whether we're in a maths
+% display. If so, we format the partmarks as an equation number, using
+% |\eqno|. Note that \Lpackage{amsmath} maths (which is what we're
+% using here) formats this differently if the material following
+% |\eqno| is of zero size, so we make this slightly larger than that.
+% \begin{macrocode}
+ \ifdim\displaywidth>0pt
+ \if@eqnsw
+ \ClassError{exam-n}{\string\partmarks* may not be used
+ within numbered equations}{Replace \string\partmarks*
+ with a \string\partmarks\ after the equation}
+ \global\advance\marktotal -#1 % to cause the mark total to be wrong
+ \else
+ \eqno \hbox to 1sp{\FormatPartMarks{#1}\hfil}%
+ \fi
+% \end{macrocode}
+% Case (i), not in maths: We don't automatically end the
+% paragraph here, because a display will often not be the end of a paragraph.
+% I am not at all convinced that this is the correct approach
+% to nudging the partmarks text up the right amount. The
+% following appears to do roughly the right thing, but there's a
+% strong element of trial and error in it.
+% \begin{macrocode}
+ \else
+ \setbox0=\vbox to 0pt{\vss
+ \hbox to \textwidth{\strut\hfill\FormatPartMarks{#1}}%
+ \vskip 1\baselineskip}% vskip means box has zero depth
+ \ifvmode
+ \box0
+ \else
+ \vadjust{\box0}%
+ \fi
+ \fi
+% \end{macrocode}
+% We've called the unstarred version of |\partmarks|. We also end the paragraph here
+% (this technique is filched from the TeXBook, p106).
+% \begin{macrocode}
+ \else
+ \ifdim\@partmarksspace > 0pt
+ {\unskip\nobreak\hfil\penalty50 \hskip\@partmarksspace
+ \hbox{}\nobreak\hfil\FormatPartMarks{#1}%
+ \parfillskip=0pt \finalhyphendemerits=0 \par}
+ \else
+ \unskip\nobreak\hfill\FormatPartMarks{#1}\par
+ \fi
+ \fi
+ \fi
+ \else
+ \ClassError{exam-n}{\string\partmarks\ is not compatible with
+ noperquestionmarks}{Either remove \string\partmarks\ or remove
+ the noperquestionmarks option}
+ \fi
+ \ignorespaces
+}
+% \end{macrocode}
+%
+% The code above permits page-breaks between lists and |\partmarks|.
+% That's because |\@endparenv|, which is called within |\endtrivlist|,
+% includes a negative |\@endparpenalty|. Override that here. This
+% applies to the whole document, but that's OK, since we want to
+% discourage inconvenient page-breaks generally.
+% \begin{macrocode}
+\@endparpenalty=\@M
+% \end{macrocode}
+
+%
+% The number of marks is formatted by the command |\FormatPartMarks|, which
+% may be overridden, using |\renewcommand| in a |.clo| file.
+% In this default case, |\FormatPartMarks| goes into the margin, so we
+% don't need to keep space for it, so set |\@partmarksspace| to zero.
+% \begin{macrocode}
+\newcommand\FormatPartMarks[1]{\hbox to 0pt{\hskip1em \textbf{[#1]}\hss}}
+\@partmarksspace=\z@
+% \end{macrocode}
+%
+% \subsubsection{The question environments: normal questions}
+%
+% The \Lenv{question} environment. Implement
+% this using with a |\question| macro, rather than using
+% |\newenvironment|, so that we can define an optional argument.
+% \begin{macrocode}
+\newcommand\question{%
+ \if@perquestionmarks
+ \let\ex@next\@questionmarks
+ \else
+ \let\ex@next\@questionnomarks
+ \fi
+ \@ifnextchar[%]
+ {\ex@next}{\ex@next[]}}
+% \end{macrocode}
+% Switch between the perquestionmarks and noperquestionmarks cases.
+% \begin{macrocode}
+\def\@questionmarks[#1]#2{%
+ \def\@tempa{#2}% marks available for this question
+ \ifx\@tempa\@empty
+ \ClassError{exam-n}
+ {Missing mark goal for question (using 0 instead)}
+ {Missing mark goal for question (using 0 instead)}
+ \def\@tempa{0}
+ \fi
+ \ifx\@includequestionoverridenumber\@empty
+ \do@question{#1}{\@tempa}%
+ \else
+ \ClassWarning{exam-n}{Forcing question number
+ \@includequestionoverridenumber, in included question #2}
+ \do@question{\@includequestionoverridenumber}{\@tempa}%
+ \fi
+}
+\def\@questionnomarks[#1]{%
+ \do@question{#1}{0}%
+}
+% \end{macrocode}
+%
+% \subsubsection{The question environments: multiple-choice questions}
+%
+% And finally multiple-choice questions. The \Lenv{mcq} environment
+% contains a list of possible answers, numbered from one up, including
+% precisely one correct answer, indicated by |\answer|. These are
+% laid out in a compact itemized list. We do not indicate the number
+% of marks, since these are always the same.
+%
+% First, counters:
+% \begin{itemize}
+% \item |\ex@nmcq| is the number of answers which MCQs can have. If
+% this is less than 1, it's a flag that MCQs haven't been enabled by
+% |\multiplechoiceanswers|.
+% \item |\ex@mcqi| is the running index of answers.
+% \item |\ex@mcqnanswer| is the number of correct answers found
+% (which is checked to be one, at the end).
+% \end{itemize}
+% \begin{macrocode}
+\newcount\ex@nmcq
+\ex@nmcq=-1
+\newcount\ex@mcqnanswer
+\def\multiplechoiceanswers#1{\ex@nmcq=#1}
+% \end{macrocode}
+% The \Lenv{mcq} environment takes a single argument indicating the
+% correct answer. The environment starts with the text question,
+% followed by a number of |\item| answers.
+% \begin{macrocode}
+\newenvironment{mcq}
+ {\parindent=0pt
+ \ifnum\ex@nmcq<1
+ \ClassError{exam-n}
+ {mcq environment without preceding multiplechoiceanswers declaration}
+ {The mcq environment may only be used if the number of
+ permitted MCQ answers has been declared with \string\multiplechoiceanswers}
+ \else
+% \end{macrocode}
+% Declare |\item| for the individual answers, and |\answer| for the
+% single correct answer.
+% \begin{macrocode}
+ \def\item{\@tempswafalse\ex@mcqitem}
+ \def\answer{\@tempswatrue\ex@mcqitem}
+% \end{macrocode
+% Initialise counters, and invoke the common |\do@question| macro.
+% \begin{macrocode}
+ \ex@mcqi=0
+ \ex@mcqnanswer=0
+ \do@question{}{1}
+ \fi}
+% \end{macrocode}
+% At the end of the \Lenv{mcq} environment, check that we found
+% |\ex@nmcq| answers, and that the count of correct answers,
+% |\ex@nmcqanswer|, is exactly one.
+% \begin{macrocode}
+ {\par
+ \ifnum\ex@mcqi<\ex@nmcq
+ \ClassWarning{exam-n}{Too few potential answers in MCQ \thequestionnumber}
+ \@shout{Too few potential answers in MCQ \thequestionnumber}
+ \ifnum\@draftstatus > 0
+ \highlighted{TOO FEW ANSWERS}\par
+ \fi
+ \fi
+ \ifcase\ex@mcqnanswer
+ \ClassWarning{exam-n}
+ {No correct MCQ answer provided in question \thequestionnumber}
+ \@shout{No correct MCQ answer provided in question \thequestionnumber}
+ \ifnum\@draftstatus > 0
+ \highlighted{NO CORRECT ANSWER PROVIDED}\par
+ \fi
+ \or
+ % ex@mcqanswer=1: correct -- do nothing
+ \else
+ \ClassWarning{exam-n}
+ {Too many correct MCQ answers provided in question \thequestionnumber}
+ \@shout{Too many correct MCQ answers provided in question \thequestionnumber}
+ \ifnum\@draftstatus > 0
+ \highlighted{TOO MANY CORRECT ANSWERS}\par
+ \fi
+ \fi
+% \end{macrocode}
+% Other end-question tidyups (compare |\endquestion|).
+% \begin{macrocode}
+ \examn@endquestion{\relax}
+ }
+% \end{macrocode}
+% Each |\item| within the environment (implemented by |\ex@mcqitem|)
+% creates a new paragraph.
+% \begin{macrocode}
+\newcount\ex@mcqi
+\def\ex@mcqitem{%
+ \par
+ \ifnum\ex@mcqi=0
+ % first one
+ \smallskip
+ \parskip=0pt % nothing fancy -- we assume these won't spread
+ % over more than one line
+ \advance\leftskip by 2em
+ \fi
+ \advance\ex@mcqi by 1
+ \noindent
+ \if@tempswa
+ % the correct answer
+ \advance\ex@mcqnanswer 1
+ \if@showsolutions
+ \hbox to 0pt{\hss \highlighted{$\Longrightarrow$ \@Alph\ex@mcqi . }}%
+ \else
+ \hbox to 0pt{\hss \@Alph\ex@mcqi . }%
+ \fi
+ \else
+ \hbox to 0pt{\hss \@Alph\ex@mcqi . }%
+ \fi
+}
+% \end{macrocode}
+%
+% \subsubsection{The question environments: the common handler}
+%
+% The common question handler. This is the macro which does the work.
+% Argument |#1| is the overriding question number (empty indicates the
+% next one in sequence); argument |#2| is the mark goal, which must be
+% non-zero.
+% \begin{macrocode}
+\def\do@question#1#2{%
+ \par % get that out of the way...
+ \markgoal=#2
+ \marktotal=0
+ \ifx\examn@questionpreamble\@empty
+ \else
+ \vspace{2\baselineskip}
+ \hbox to \textwidth{\hfil\textbf{\examn@questionpreamble}\hfil}
+ \questionpreamble{}
+ \fi
+ \setcounter{partnumber}{0}
+ \setcounter{answerpartnumber}{0}
+% \end{macrocode}
+% If the argument |#1| is non-empty, then it is a number, forcing the
+% question number. This is local, however -- don't use it to change
+% the sequence of questions, so don't set the `questionnumber'
+% counter, but only the current label.
+% \begin{macrocode}
+ \refstepcounter{questionnumber}
+ \def\@tempa{#1}
+ \ifx\@tempa\@empty \else
+ \edef\@currentlabel{#1}
+ \fi
+% \end{macrocode}
+%
+% If |pageperquestion| is true, then start a new page here (unless
+% this is the first question).
+% \begin{macrocode}
+ \examn@prequestionspace{%
+ \if@nobreak
+ % after a heading (or something like that)
+ \else
+ % we're not forcing a new page here, but this would be a good point to choose
+ \vskip 2\baselineskip plus 8\baselineskip
+ \penalty-200
+ \fi
+ }
+% \end{macrocode}
+%
+% The optional argument specifies a question number. In compose mode,
+% this unequivocally specifies the question number -- end of story.
+% In the two other modes, this is expected to match the question
+% number implied by the count of questions so far, and we check this,
+% and warn if it is not so.
+% \begin{macrocode}
+ \if@questionnumberchecks
+ \def\@tempa{#1}% intended question number
+% \end{macrocode}
+% If there's no optional argument, we've got nothing to do
+% \begin{macrocode}
+ \ifx\@tempa\@empty
+ % no optional argument -- easy
+ \def\@currentquestion{\thequestionnumber}
+% \end{macrocode}
+%
+% We have a non-null optional argument in |#1|.
+% Check the question number in the argument. If there's a
+% mismatch, warn in draft mode, and fail in final mode. First,
+% however, check that the argument |#1| is just a number (if it's not,
+% the author should have disabled this check in the preamble, and we
+% shouldn't be here at all). We do that check by setting a counter
+% inside a box. If |#1| is all number, then this will result in a
+% zero-width box; if not, then there will be unparsed characters and a
+% non-zero-width box (nifty, eh?).
+% \begin{macrocode}
+ \else
+ \setbox0=\hbox{\@tempcnta=#1}
+ \ifdim\wd0>0pt
+ \ClassWarning{exam-n}{Non-numeric question number, #1.
+ You probably want to put \string\QuestionNumberChecksOff in the preamble}
+ \par\textbf{Non-numeric question number, #1.
+ You probably want to put \hbox{$\backslash$\ttfamily QuestionNumberChecksOff} in the preamble}
+ (the formatting below may be messed up).\par
+ \fi
+% \end{macrocode}
+% Switch on the draft status: in the final version, this mismatch is an error
+% \begin{macrocode}
+ \ifcase\@draftstatus
+ % Final version
+ \@tempcnta=#1
+ \ifnum\c@questionnumber=\@tempcnta
+ \def\@currentquestion{#1}
+ \else
+ \ifx\@includequestionoverridenumber\@empty
+ \ClassError{exam-n}
+ {\string\question[#1] is actually question \thequestionnumber!}
+ {The question in {question} environment number
+ \thequestionnumber\space is specified as
+ \string\question[#1].\MessageBreak
+ This is an error in 'final' mode.\MessageBreak
+ Perhaps you need \string\QuestionNumberChecksOff?}
+ \def\@currentquestion{???}
+ \else
+ \ClassWarning{exam-n}{Forcing question number \@includequestionoverridenumber,
+ in {question} environment number \thequestionnumber}
+ \edef\@currentquestion{\@includequestionoverridenumber}% this doesn't seem to expand in fact!
+ \message{current question=\@currentquestion, override \@includequestionoverridenumber}
+ \fi
+ \fi
+% \end{macrocode}
+% In the other two modes, we simply need a warning.
+% \begin{macrocode}
+ \or
+ % Draft version -- let the given number override
+ % \the\questionnumber, but warn if there's a difference.
+ \@tempcnta=#1
+ \ifnum\c@questionnumber=\@tempcnta \else
+ \ClassWarning{exam-n}
+ {\string\question[#1] is actually question \thequestionnumber!}
+ \fi
+ \def\@currentquestion{#1}
+ \else
+ % compose mode -- argument overrides without question
+ \def\@currentquestion{#1}
+ \fi
+ \fi
+ \else
+ % skip question-number checks
+ \def\@tempa{#1}% intended question number
+ \ifx\@tempa\@empty
+ % no optional argument -- this is possibly an error, so warn
+ \ClassWarning{exam-n}{\string\QuestionNumberChecksOff\ is in
+ force, but this question has no [number]}
+ \def\@currentquestion{\thequestionnumber}
+ \else
+ \typeout{Forcing question \thequestionnumber\space to be #1}
+ \def\@currentquestion{#1}
+ \fi
+ \fi
+% \end{macrocode}
+% Format the question number, first removing and discarding any parindent
+% (the reason we don't just start with |\noindent| here is because
+% there may be a blank line between the |\begin{question}|, and the
+% text, so we'd (inadvertently) start another new paragraph when the
+% actual question starts).
+% The call to |\mark| should come \emph{after} setting the
+% question number: if it happens before, and there is a page-break
+% immediately before the new question, we can get a spurious
+% `Q?? continued' on the previous page.
+%
+% If a paragraph starts inside a level of grouping -- for example
+% |{\bf 1} text...| or even just |{T}ext| -- then the |\everypar|
+% tokens are expanded inside that group, which means that the
+% resetting of |\everypar| is local, with the result that the tokens
+% are reused for the next paragraph. Make the emptying of |\everypar|
+% global for that reason.
+% \begin{macrocode}
+ \everypar{\setbox0=\lastbox % discard \box0
+ \FormatQuestionNumber
+ \mark{\@currentquestion}%
+ \global\everypar{}}
+}
+% \end{macrocode}
+% Format the question number. This command is documented as existing,
+% so that it can be potentially overridden in a \texttt{.clo} file.
+% \begin{macrocode}
+\newcommand\FormatQuestionNumber
+ {\hbox to 0pt{\hss \textbf{\@currentquestion}\hskip1em}}
+% \end{macrocode}
+%
+% Finish off the question:
+% Format the indication of the total number
+% of marks, and do a few consistency checks.
+% \begin{macrocode}
+\def\endquestion{%
+ \ifnum\marktotal=\markgoal
+ \typeout{Question \@currentquestion\if@perquestionmarks, \the\marktotal\space marks\fi}
+ \iffalse % all of this is redundant, and ends up too shouty
+ \ifcase\@draftstatus
+ % Final version -- do nothing
+ \relax
+ \or % draft version
+ \relax % no, the above is too much; do nothing
+ \else % compose version
+ \par
+ \hfil\textbf{\highlighted{[Q\,\@currentquestion\if@perquestionmarks, \the\marktotal\space marks\fi]}}%
+ \break
+ \fi
+ \fi
+% \end{macrocode}
+% In the case where the mark total doesn't match, make a noise about it.
+% \begin{macrocode}
+ \else
+ \ClassWarning{exam-n}
+ {Question \@currentquestion\space has a total of \the\marktotal\space marks,
+ \MessageBreak
+ when it should have \the\markgoal}
+ \begin{center}
+ \edef\@tempa{Question \@currentquestion\space
+ has a total of \the\marktotal\space marks,
+ when it should have \the\markgoal}
+ \expandafter\shout\expandafter{\@tempa}
+ \end{center}
+ \fi
+% \end{macrocode}
+% Make a few tidyups in the end-question wrapper.
+% \begin{macrocode}
+ \examn@endquestion{%
+ \if@showmarktotals
+ \par % into vertical mode
+ \nobreak % keep the marks total with the question
+ \vbox to 2\baselineskip{
+ \vss
+ % this should be very similar to the call to
+ % \FormatPartMarks in \@partmarks, above
+ \hbox to \textwidth{\strut\hfill\FormatPartMarks{Total: \the\markgoal
+ \ifnum\@draftstatus>0
+ % in draft modes, put a fairly discreet confirmation in the total
+ \space
+ \highlighted{\ifnum\marktotal=\markgoal OK\else X\fi}%
+ \fi}}}
+ \fi
+ }
+}
+% \end{macrocode}
+%
+% \subsubsection{Other structures}
+%
+% The \Lenv{questiondata} environment allows the author to provide
+% some additional data or equations for the question.
+% This environment ends a preceding paragraph.
+% \begin{macrocode}
+\newenvironment{questiondata}{%
+ \par
+ \penalty50 % poor break
+ \vbox\bgroup
+ \slshape
+ \parindent=0pt \parskip=\medskipamount
+ \smallskip
+ \hrule
+ \nobreak
+ \smallskip
+ \noindent \ignorespaces
+}{%
+ \par
+ \nobreak
+ \medskip
+ \hrule width \textwidth
+ \par
+ \egroup % end of \vbox
+}
+% \end{macrocode}
+%
+% If |\questionpreamble| is called some time before the start of a
+% \Lenv{question} environment, then its contents will be printed at
+% the start of the next question.
+% \begin{macrocode}
+\newcommand\questionpreamble[1]{\gdef\examn@questionpreamble{#1}}
+\let\examn@questionpreamble\@empty
+% \end{macrocode}
+%
+% In those cases where the sequence of question numbers is not
+% supposed to match the sequence of question environments, declare
+% that we should turn off the corresponding checks within |\question|.
+% \begin{macrocode}
+\newif\if@questionnumberchecks
+\@questionnumbercheckstrue
+\newcommand\QuestionNumberChecksOff{\@questionnumberchecksfalse}
+% \end{macrocode}
+%
+% The underlying style (article) has enumerate and itemize
+% environments which have a rather generous amount of space. This
+% makes sense in an article, but within an exam, which already has a
+% lot of white space around, such lists end up looking unattractively
+% ragged. So redefine them slightly here, adjusting the spacing
+% appropriately. First `enumerate'\dots
+% \begin{macrocode}
+\def\enumerate{%
+ \ifnum \@enumdepth >\thr@@\@toodeep\else
+ \advance\@enumdepth\@ne
+ \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
+ \expandafter
+ \list
+ \csname label\@enumctr\endcsname
+ {\usecounter\@enumctr
+ \topsep0pt
+ \partopsep0pt
+ %\parskip=5.0pt \parsep=\parskip
+ \def\makelabel##1{\hss\llap{##1}}}%
+ \fi}
+% \end{macrocode}
+% \dots then `itemize'.
+% \begin{macrocode}
+\def\itemize{%
+ \ifnum \@itemdepth >\thr@@\@toodeep\else
+ \advance\@itemdepth\@ne
+ \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
+ \expandafter
+ \list
+ \csname\@itemitem\endcsname
+ {\topsep0pt
+ \partopsep0pt
+ \def\makelabel##1{\hss\llap{##1}}}%
+ \fi}
+% \end{macrocode}
+% To match the format of the question number above, we have to make
+% sure that the enumerate environment's counters are different.
+% \begin{macrocode}
+\renewcommand\theenumi{\@roman\c@enumi}
+% \end{macrocode}
+%
+% \subsection{Other useful commands}
+%
+% |\comment| creates a marginal comment in non-final modes. There is an
+% interaction with the marks mechanism -- see the discussion about
+% |\topmark| above.
+% \begin{macrocode}
+\newcommand\comment[1]{%
+ \ifnum\@draftstatus > 0
+ \marginpar{\highlighted{#1}}%
+ % should we \@shout this, too?
+ \fi
+ \ignorespaces
+}
+% \end{macrocode}
+%
+% The |\author| command is a convenience. Used within a
+% \Lenv{question} environment, it creates a comment with the author's
+% name. I may expand its functionality in future.
+% \begin{macrocode}
+\renewcommand\author[1]{\comment{Author: #1}}
+% \end{macrocode}
+%
+% The |\@shout| macro is intended for use in all modes: it appends a
+% remark to a list of exclamations which are highlighted at the end of
+% the document.
+% The argument to |\@shout| can have expandable things (such as
+% |\thequestionnumber|) in it.
+% Shouts appear in all modes and cannot be suppressed.
+% \begin{macrocode}
+\newtoks\@allshouts \@allshouts={}
+\def\@shout#1{\edef\@tempa{#1}\expandafter\@@shout\expandafter{\@tempa}}
+\def\@@shout#1{\global\@allshouts=\expandafter{\the\@allshouts\t{#1}}}
+\def\showthe@shouts{%
+ {\def\t##1{{\LARGE\noindent\highlighted{NOTE: ##1}\par}}%
+ \the\@allshouts}%
+ % Remark on the number of shouts in the aux file
+ {\@tempcnta=0 \def\t##1{\advance\@tempcnta1}\the\@allshouts
+ \protected@write\@auxout{}%
+ {\string\examn@shoutcount{\the\@tempcnta}}}}
+% \end{macrocode}
+% Define the user macro |\shout|
+% \begin{macrocode}
+\def\shout#1{\textbf{\highlighted{#1}}\@shout{#1}}
+% \end{macrocode}
+% Take note of the number of shouts, and write this information to the
+% \texttt{.aux} file, so that it can be read in next time.
+% \begin{macrocode}
+\newcount\examn@shoutcounttotal
+\examn@shoutcounttotal=0
+\def\examn@shoutcount#1{\global\examn@shoutcounttotal=#1}
+% \end{macrocode}
+%
+% The |\includequestion| command includes a question from another
+% file. For convenience, we disable |\documentclass|, |\usepackage|, and the
+% \Lenv{document} environment, so that the included file may be a
+% complete \LaTeX\ document.
+% \begin{macrocode}
+\def\dummy@documentclass{%
+ \@ifnextchar[\dummy@@documentclass{\dummy@@documentclass[]}}
+\def\dummy@@documentclass[#1]#2{}
+\def\includequestion{
+ \@ifnextchar[%]
+ {\@includequestion}{\@includequestion[]}}
+\def\@includequestion[#1]#2{%
+ \begingroup
+ \let\documentclass\dummy@documentclass
+ \let\document\@empty % not \relax: makes \begin think {document} is undef'd
+ \let\enddocument\relax
+ \def\@tempa{#1}
+ \ifx\@tempa\@empty \else
+ \def\@includequestionoverridenumber{#1}
+ \message{includequestion override: \@includequestionoverridenumber}
+ \fi
+ \def\usepackage##1{\ClassWarning{exam-n}
+ {Ignoring \string\usepackage{##1} in included question #2}}
+ \input{#2}
+ \endgroup
+}
+\let\@includequestionoverridenumber\@empty
+% \end{macrocode}
+%
+% \subsection{The solution environment}
+%
+% The solution environment is made somewhat complicated by the way we
+% implement it. Rather than using a verbatim-like technique to omit
+% the source lines (as done successfully by, for example, the
+% \Lpackage{comments} package) we set the contents of the environment
+% in a box, which we throw away. This technique is more robust in
+% principle, but it does mean we have to disable some things which
+% have global side-effects.
+%
+% Maintain a flag which indicates whether we're in a solution
+% environment or not.
+% \begin{macrocode}
+\newif\if@insolution
+\@insolutionfalse
+% \end{macrocode}
+%
+% We want to use |\part| within solutions. If we were to do so naively
+% however, we would end up incrementing the |partnumber| counter
+% which that macro uses, which either disturbs the numbering of the
+% parts in the question (if the solutions are interspersed in the
+% question) or starts out of sequence (if the solutions are at the
+% end). So we maintain a separate counter. Additionally, we want to
+% force the formatting of the solution parts, to be independent of the
+% formatting in the main question
+% \begin{macrocode}
+\newcounter{answerpartnumber}
+\newcommand{\examn@solutionpart}{%
+ \par
+ \stepcounter{answerpartnumber}
+ \noindent\hbox to \parindent{(\StylePartNumber{answerpartnumber})\hss}}
+% \end{macrocode}
+%
+% Specify how solutions should be shown. The following makes them
+% ragged right, slightly smaller and slanted, with rules fore and aft.
+% This doesn't leap out, but the difference should be detectable.
+% Putting a box round the solution would be desirable (it keeps it all
+% together and would allow a coloured background), but that's rather
+% hard to arrange in practice.
+% \begin{macrocode}
+\def\@formatsolution{\par
+ \if@insolution
+ \ClassError{exam-n}{Misplaced solution}{You can't have a solution within a solution}
+ \else
+ \@insolutiontrue % this happens within a group
+ \fi
+ \examn@dummycaptions % dummy captions within solutions
+ \typeout{SHOWING SOLUTIONS}
+ \let\part\examn@solutionpart
+% \end{macrocode}
+% Checks done; now get on with the layout
+% \begin{macrocode}
+ \vskip 1ex plus 2\bigskipamount % add stretchable space...
+ \penalty-\@lowpenalty % ...and encouragement to break here
+ \parskip 0.5\baselineskip
+ \raggedright
+ \color{solutiontext}%\slshape
+ \ifbigfont \else
+ \small
+ \fi
+ \hrule
+ \hbox to \textwidth{\vrule height 1ex \hfil \vrule height 1ex}
+ \nobreak
+ \vskip -\parskip % cancel out the following parskip
+ \textbf{\highlighted{Solution:}}\hskip2em
+ \ignorespaces
+ \parindent=2em
+}
+% \end{macrocode}
+% The end of the solution environment is simple, and simply matches
+% the box above.
+% \begin{macrocode}
+\def\end@formatsolution{%
+ \par
+ \nobreak
+ \vskip -0.5ex
+ \hbox to \textwidth{\vrule height 1ex \hfil \vrule height 1ex}
+ \hrule
+}
+% \end{macrocode}
+%
+% The content of the \Lenv{solution} environment is balanced \LaTeX\
+% text, and so does not have to be complicated; in particular, it does
+% not have to have the generality, and the consequent restrictions, of
+% for example Eijkhout's \Lpackage{comment} package. If we're including the
+% solutions, then we simply format them in the usual sort of way,
+% inside a group; otherwise we're skipping them, so put the contents in a
+% box and throw it away. Note that \Lenv{solution} is an environment,
+% so we're inside a group at this point.
+% \begin{macrocode}
+\if@showsolutions
+ \let\solution\@formatsolution
+ \let\endsolution\end@formatsolution
+\else
+ \def\solution{%
+ \if@insolution
+ \ClassError{exam-n}{Misplaced solution}{You can't have a solution within a solution}
+ \fi
+ \let\endfigure\endfloat@skipsolutions
+ \let\endtable\endfloat@skipsolutions
+ \examn@dummycaptions % dummy captions avoid counter increments
+ \@ifundefined{includepdf}{}{\let\includepdf\examn@disabledpdfpages}
+ \par
+ \setbox\@tempboxa\vbox\bgroup
+ \@insolutiontrue}
+ \def\endsolution{%
+ \egroup % ...and do nothing with this box
+ }
+\fi
+% \end{macrocode}
+%
+% \subsubsection{Floats in solutions}
+%
+% Figures in solutions must be treated specially, since they mustn't
+% move outside the solution. The most straightforward thing seems to
+% be to avoid them floating at all. Additionally, this is probably true of
+% figures in the question as well (if a question refers to a figure,
+% it's probably civil to have the figure on the same page as the
+% text), so redefine {figure} so that in all cases figures are placed
+% `here', and never float. We also add generous amounts of vertical
+% space, to encourage figures to stay on the same page as the text
+% before them, if this is at all possible.
+%
+% \begin{macrocode}
+\def\examn@badfloat#1[#2]{
+ \ClassError{exam-n}
+ {Bad #1 option #2 ignored}
+ {In the exam-n class, the 'floating' environments take no argument,\MessageBreak
+ and are always placed 'here'}
+ \examn@float{#1}}
+\def\examn@float#1{%
+ % re-using the standard LaTeX parameter means that \caption works
+ \def\@captype{#1}
+ \setbox\@tempboxa\vbox\bgroup}
+\def\examn@endfloat{%
+ \egroup % end \@tempboxa
+ \unskip
+ \nobreak
+ % add lots of stretchability, but non-infinite, for the sake of tidiness
+ \vskip 0pt plus 0.5\textheight
+ \penalty50 % a pagebreak here discards following vskip
+ % (cf TeXBook p106; or try \filbreak of p111)
+ \vskip 2ex plus -0.5\textheight % negative stretch cancels previous vskip
+ \box\@tempboxa
+ %\vskip 1ex
+ \nobreak
+}
+\def\endfloat@skipsolutions{%
+ % variant when skipping solutions -- end the \@tempboxa and do nothing
+ \egroup
+}
+% \end{macrocode}
+% Now, finally, redefine the figure and table environments in terms of
+% these new macros.
+% \begin{macrocode}
+\def\figure{%
+ \@ifnextchar[{\examn@badfloat{figure}}{\examn@float{figure}}%]
+}
+\def\table{%
+ \@ifnextchar[{\examn@badfloat{table}}{\examn@float{table}}%]
+}
+\let\endfigure\examn@endfloat
+\let\endtable\examn@endfloat
+% \end{macrocode}
+% Within these 'floats', we must redefine |\caption|, so that we don't
+% increment the float counters. One motivation for this is so that we don't have
+% table numbers changing depending on whether solutions are included
+% or not; but since we're implementing the solutions by setting the
+% content in a discarded box, it turns out that we get the counter
+% increments whether we include the solutions or not. The following
+% definition of |\caption| is just the standard one, with
+% |\refstepcounter| removed and `Table nnn' redefined appropriately.
+% \begin{macrocode}
+\def\examn@dummycaptions{%
+ \def\fnum@figure{\figurename} % 'Figure nnn' changed to just 'Figure'
+ \def\fnum@table{\tablename}
+ \def\caption{%
+ \ifx\@captype\@undefined
+ \@latex@error{\noexpand\caption outside float}\@ehd
+ \expandafter\@gobble
+ \else
+ %\refstepcounter\@captype % omit this line from the standard definition
+ \expandafter\@firstofone
+ \fi
+ {\@dblarg{\@caption\@captype}}%
+ }
+}
+% \end{macrocode}
+%
+% \subsubsection{Solutions and pdfpages}
+%
+% It appears that the \Lpackage{pdfpages} package is incompatible with
+% the way that I implement \Lopt{noshowsolutions}, largely because (I
+% think) it bypasses \LaTeX\ and fiddles with the generated PDF
+% directly. Therefore, we have to disable the \Lpackage{pdfpages}
+% support when we're skipping solutions. We mustn't do this globally,
+% since sometimes (for example in a .clo option file's
+% constants sheet) we do need pdfpages in the no-show-solutions case.
+% \begin{macrocode}
+\def\examn@disabledpdfpages{\@ifnextchar[% ]
+ \examn@disabledpdfpages@
+ {\examn@disabledpdfpages@[]}}
+\def\examn@disabledpdfpages@[#1]#2{\relax}
+% \end{macrocode}
+%
+% \subsection{End-of-document actions}
+%
+% Add a number of actions to the end-of-document hook. Do them here,
+% rather than by calling |\AtEndDocument| multiple times, because the
+% order matters (in fact, the order here is the same as the order
+% they're defined in, but it's best to be explicit about this).
+% \begin{macrocode}
+\AtEndDocument{
+ \CheckTotalQuestions
+ \ClosingText
+ \showthe@shouts
+ \WriteLastPageLabel}
+% \end{macrocode}
+%
+% \subsection{Other formatting niceties}
+%
+% Format vectors (the default for |\vec| is a symbol with an arrow
+% over it):
+% \begin{macrocode}
+\ifcase\examn@mtselect
+ % mathptm fonts
+ % This is a very clumsy version, but it appears to be our only option
+ \def\vec#1{\mathchoice{\mbox{\boldmath $\displaystyle #1$}}
+ {\mbox{\boldmath $ #1$}}
+ {\mbox{\boldmath $\scriptstyle #1$}}
+ {\mbox{\boldmath $\scriptscriptstyle #1$}}}
+\or % mathtime (should this be the same for mathtime as for mtpro2?
+ \let\vec\mathbf
+\or % mtpro2
+ \let\vec\mathbold
+\fi
+% \end{macrocode}
+% Abbreviations for degrees.
+% \begin{macrocode}
+\newcommand\BSc{B.Sc.{}}
+\newcommand\MSci{M.Sci.{}}
+\newcommand\MSc{M.Sc.{}}
+\newcommand\MA{M.A.{}}
+\newcommand\MEng{M.Eng.{}}
+\newcommand\BEng{B.Eng.{}}
+% \end{macrocode}
+%
+% Tweaks to differentials.
+% \begin{macrocode}
+\newcommand{\dd}{\mathrm{d}}
+\newcommand{\ddd}{\,\mathrm{d}} % inside an integral, including thinspace
+
+\def\Diffl{\@ifstar\@Difflflat\@Diffl}
+\def\Partial{\@ifstar\@Partialflat\@Partial}
+\def\@Partial{\@ifnextchar[{\@@Diffl\partial}{\@@Diffl\partial[]}}
+\def\@Partialflat{\@ifnextchar[{\@@Difflflat\partial}{\@@Difflflat\partial[]}}
+\def\@Diffl{\@ifnextchar[{\@@Diffl\dd}{\@@Diffl\dd[]}}
+\def\@Difflflat{\@ifnextchar[{\@@Difflflat\dd}{\@@Difflflat\dd[]}}
+\def\@@Diffl#1[#2]#3#4{%
+ \def\@tempa{#2}%
+ \ifx\@tempa\empty
+ \frac{#1#3}{#1#4}%
+ \else
+ \frac{{#1}^{#2}#3}{#1{#4}^{#2}}%
+ \fi}
+\def\@@Difflflat#1[#2]#3#4{%
+ \def\@tempa{#2}%
+ \ifx\@tempa\empty
+ #1#3\mskip-0.8mu/\mskip-1.2mu #1#4%
+ \else
+ {#1}^{#2}#3\mskip-0.8mu /\mskip-1.2mu #1{#4}^{#2}%
+ \fi}
+% \end{macrocode}
+%
+% The exponential sign
+% \begin{macrocode}
+\def\e{{\mathrm e}}
+% \end{macrocode}
+%
+% Physical units in |\rm|. Unstarred version includes leading
+% |\thinspace|. Starred version doesn't, and is used when referring to
+% the unit by itself (eg axis is |$B/\units*T$|), and is not qualifying
+% a number.
+% FIXME: |\mu| in |\units| can come out wrong in some fonts (mtpro2?)
+% -- needs investigation.
+% \begin{macrocode}
+\def\units{\begingroup
+ \catcode`\.=\active
+ \@ifstar{\let\un@tsspace\relax \un@ts}%
+ {\let\un@tsspace\thinspace\un@ts}}
+\begingroup
+ \catcode`\.=\active
+ \gdef\un@ts#1{\let~\thinspace\let.\thinspace
+ \ifmmode
+ \un@tsspace\mathrm{#1}%
+ \else
+ \nobreak$\un@tsspace\mathrm{#1}$%
+ \fi
+ \endgroup}
+\endgroup
+% \end{macrocode}
+%
+% Other miscellaneous symbols:
+% The AU is nothing exciting, but may be adjusted in future
+% \begin{macrocode}
+\def\au{au}
+% \end{macrocode}
+% The symbol for Compton wavelength is a crossed lambda -- the following isn't perfect, but is OK for now.
+% \begin{macrocode}
+\def\lambdabar{\setbox\@tempboxa\hbox{$\lambda$}%
+ \hbox to 0pt{\hbox to \wd\@tempboxa{\hss$\bar{}$\hss}\hss}\box\@tempboxa}
+% \end{macrocode}
+%
+% All done.
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+% \Finale
+%
+\endinput
diff --git a/macros/latex/contrib/exam-n/exam-n.html b/macros/latex/contrib/exam-n/exam-n.html
new file mode 100644
index 0000000000..717d683aa9
--- /dev/null
+++ b/macros/latex/contrib/exam-n/exam-n.html
@@ -0,0 +1,163 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>exam-n class</title>
+<link href="http://nxg.me.uk" rev="author"/>
+<link type="text/css" rel="stylesheet"
+ href="style.css"/>
+<style type='text/css'>
+dd ul { padding: 0pt; margin: 0pt; }
+</style>
+</head>
+
+<body>
+<h1>The exam-n class</h1>
+
+<p>Format exam papers</p>
+
+<p>Version 1.1.4, 2016 December 19.</p>
+
+<ul>
+<li>Download: <a href='exam-n-1.1.4.tar.gz'>tarball</a>
+or <a href='exam-n-1.1.4.zip'>zip file</a></li>
+<li>You may want to look at a <a href='sample_exam.pdf'>sample
+exam</a>. See the <code>sample/</code> directory in the distribution
+for the source of this. That demonstrates the final version of the
+paper, as opposed to the ‘draft’ and ‘compose’ versions; there’s also
+a version with this layout but
+<a href='sample_exam_solution.pdf'>showing the solutions</a>.</li>
+<li>If you're a question author, you probably don't want to read the
+full documentation. Stick to the shorter
+<a href='notes-for-authors.pdf'>notes for authors</a>.</li>
+<li>See the <a href='exam-n.pdf' >documentation</a> for fuller
+discussion.</li>
+<li>The package's 'home page' is
+<a href='http://purl.org/nxg/dist/exam-n'><code>http://purl.org/nxg/dist/exam-n</code></a>,
+and the repository is available at
+<a href='https://bitbucket.org/nxg/exam-n'>bitbucket</a>.</li>
+</ul>
+
+<h2>Overview</h2>
+
+<h3>Other exam styles</h3>
+<p>There are already multiple ‘exam’ LaTeX styles on CTAN,
+including
+the (original?) <a href='http://dante.ctan.org/tex-archive/macros/latex/contrib/exam/'>exam class</a>,
+the extensive <a href='http://www.math.uakron.edu/~dpstory/webeq.html' >AcroTeX</a> bundle,
+the
+<a href='http://dante.ctan.org/tex-archive/macros/latex/contrib/examdesign/'>examdesign</a> and
+<a href='http://dante.ctan.org/tex-archive/macros/latex/contrib/exams/'>exams</a>
+classes, and
+<a href='http://www.tex.ac.uk/cgi-bin/CTANcataloguesearch.pl?CATSTRING=exam'>a variety of other packages</a>
+which mention exams in some way.
+Some of these are more focused on generating quizzes
+(even doing things like randomising answers)
+or on having a highly customisable layout.
+Several (including ‘exam-n’) have support for generating versions of
+the exam document which include answers, for the benefit of
+markers.</p>
+
+<h3>The exam-n style</h3>
+<p>What the ‘exam-n’ class can bring to this particular (rather crowded)
+party is:</p>
+<ul>
+<li>Direct support for collaborative development of an exam, using a
+model in which a departmental ‘exams convener’ or ‘exam chair’
+coordinates multiple authors writing individual questions. This
+includes various completeness checks to avoid embarrasing mistakes.
+The class file and associated process is in regular use within a
+physics and astronomy department, and this work-flow is discussed in a
+little more detail within the class file documentation.</li>
+<li>Designed to have all of the ‘traditional’ exam paper features such
+as sectioning, per-part running marks, ‘Question <em>n</em> continued’
+catchwords, and so on.</li>
+<li>Designed to be locally adaptable.</li>
+<li>The class file is freely adaptable (LPPL). The author can provide
+the usual basic free-software support, or potentially more elaborate
+support with a different arrangement.</li>
+</ul>
+
+<p>The focus of the ‘exam-n’ class is on the careful collaborative
+process of assembling an exam, and many of the features are to do with
+checks to avoid mistakes. The result has, in effect, been validated
+by practice.</p>
+
+
+<h2>Releases</h2>
+
+<p>With the version 1.1 release, the interface should now be regarded
+as rather stable. However version 1.1 was the first to be released
+outside Glasgow University, so there may be some changes to the
+interface which will emerge with broader use, as well as some bug
+fixes. The interface <em>may</em>, therefore, yet change. If you use
+this class to produce exams, you should therefore include a copy of
+the class file locally, rather than relying on a central version. If
+you need an earlier version of the class, let me know.</p>
+
+<p>The class was called <code>exam</code> until release 0.14, and
+<code>guexam</code> until release 1.1. In the first case, it was
+renamed to avoid a conflict with a pre-existing LaTeX class with the
+same name; and in the second it was renamed to make it more
+generically useful to other institutions.</p>
+
+<dl>
+
+<!-- @RELEASENOTES@ -->
+<dt><span class='attention'>1.1.4, 2016 December 19</span></dt>
+<dd><ul>
+<li>Documentation: add notes about use of pdfpages.</li>
+<li>Added <code>[largefont]</code> option.
+<strong>Note</strong>:
+option <code>[hugefont]</code> has replaced <code>[bigfont]</code>;
+the latter is now deprecated, and may be removed in v1.2.</li>
+<li>Use of the <code>\part</code> macro is now supported within
+solutions (it produced the wrong numbers before), and there is a new
+<code>\StylePartNumber</code> customisation macro.</li>
+</ul></dd>
+
+<dt>1.1.3</dt>
+<dd><ul>
+<li>Version 1.1.3 was never released</li>
+</ul></dd>
+
+<dt>1.1.2, 2015 November 26</dt>
+<dd><ul>
+<li>Handled trailing floats at end of document (generated by packages
+such as <code>rotating</code>.</li>
+<li><code>\label</code> within question environment now refers to the
+question number.</li>
+<li>Work around a problem when a paragraph starts with <code>{\bf ...}</code>
+rather than (post-1995) <code>\textbf{...}</code>.</li>
+<li><code>\begin{questiondata}</code> now starts a new paragraph.</li>
+<li>Some documentation adjustments.</li>
+</ul></dd>
+
+<dt>1.1.1, 2014 November 27</dt>
+<dd><ul>
+<li>Adjust <code>\partmarks*</code> behaviour; now behaves differently
+within display maths (addresses
+<a href='https://bitbucket.org/nxg/exam-n/issue/1/'>issue 1</a>).</li>
+<li>Various documentation and release fixes.</li>
+</ul></dd>
+
+<dt>1.1, 2014 May 3</dt>
+<dd>Converted to a generic class, <code>exam-n</code>, ready for wider
+distribution.
+Available on <a href='https://bitbucket.org/nxg/exam-n/'>bitbucket</a>
+and at CTAN.</dd>
+
+
+<dt>...</dt>
+<dd><a href='release-notes.html'>Earlier release notes</a> are available</dd>
+
+</dl>
+
+
+<div class="signature">
+<a href='http://nxg.me.uk'>Norman Gray</a><br/>
+2016 December 19
+</div>
+
+</body>
+</html>
+
+
diff --git a/macros/latex/contrib/exam-n/exam-n.ins b/macros/latex/contrib/exam-n/exam-n.ins
new file mode 100644
index 0000000000..af67d0c268
--- /dev/null
+++ b/macros/latex/contrib/exam-n/exam-n.ins
@@ -0,0 +1,15 @@
+\input docstrip
+\preamble
+ exam-n: format exam questions
+\endpreamble
+\keepsilent
+\askforoverwritefalse
+
+\generate{\file{exam-n.drv}{\from{exam-n.dtx}{driver}}
+ \file{exam-n.cls}{\from{exam-n.dtx}{package}}
+ \file{exam-n-example.tex}{\from{exam-n.dtx}{example}}
+ }
+
+\endbatchfile
+
+%% $Id$
diff --git a/macros/latex/contrib/exam-n/exam-n.pdf b/macros/latex/contrib/exam-n/exam-n.pdf
new file mode 100644
index 0000000000..66e4392de8
--- /dev/null
+++ b/macros/latex/contrib/exam-n/exam-n.pdf
Binary files differ
diff --git a/macros/latex/contrib/exam-n/lppl.txt b/macros/latex/contrib/exam-n/lppl.txt
new file mode 100644
index 0000000000..2244313901
--- /dev/null
+++ b/macros/latex/contrib/exam-n/lppl.txt
@@ -0,0 +1,416 @@
+The LaTeX Project Public License
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+
+LPPL Version 1.3c 2008-05-04
+
+Copyright 1999 2002-2008 LaTeX3 Project
+ Everyone is allowed to distribute verbatim copies of this
+ license document, but modification of it is not allowed.
+
+
+PREAMBLE
+========
+
+The LaTeX Project Public License (LPPL) is the primary license under
+which the LaTeX kernel and the base LaTeX packages are distributed.
+
+You may use this license for any work of which you hold the copyright
+and which you wish to distribute. This license may be particularly
+suitable if your work is TeX-related (such as a LaTeX package), but
+it is written in such a way that you can use it even if your work is
+unrelated to TeX.
+
+The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE',
+below, gives instructions, examples, and recommendations for authors
+who are considering distributing their works under this license.
+
+This license gives conditions under which a work may be distributed
+and modified, as well as conditions under which modified versions of
+that work may be distributed.
+
+We, the LaTeX3 Project, believe that the conditions below give you
+the freedom to make and distribute modified versions of your work
+that conform with whatever technical specifications you wish while
+maintaining the availability, integrity, and reliability of
+that work. If you do not see how to achieve your goal while
+meeting these conditions, then read the document `cfgguide.tex'
+and `modguide.tex' in the base LaTeX distribution for suggestions.
+
+
+DEFINITIONS
+===========
+
+In this license document the following terms are used:
+
+ `Work'
+ Any work being distributed under this License.
+
+ `Derived Work'
+ Any work that under any applicable law is derived from the Work.
+
+ `Modification'
+ Any procedure that produces a Derived Work under any applicable
+ law -- for example, the production of a file containing an
+ original file associated with the Work or a significant portion of
+ such a file, either verbatim or with modifications and/or
+ translated into another language.
+
+ `Modify'
+ To apply any procedure that produces a Derived Work under any
+ applicable law.
+
+ `Distribution'
+ Making copies of the Work available from one person to another, in
+ whole or in part. Distribution includes (but is not limited to)
+ making any electronic components of the Work accessible by
+ file transfer protocols such as FTP or HTTP or by shared file
+ systems such as Sun's Network File System (NFS).
+
+ `Compiled Work'
+ A version of the Work that has been processed into a form where it
+ is directly usable on a computer system. This processing may
+ include using installation facilities provided by the Work,
+ transformations of the Work, copying of components of the Work, or
+ other activities. Note that modification of any installation
+ facilities provided by the Work constitutes modification of the Work.
+
+ `Current Maintainer'
+ A person or persons nominated as such within the Work. If there is
+ no such explicit nomination then it is the `Copyright Holder' under
+ any applicable law.
+
+ `Base Interpreter'
+ A program or process that is normally needed for running or
+ interpreting a part or the whole of the Work.
+
+ A Base Interpreter may depend on external components but these
+ are not considered part of the Base Interpreter provided that each
+ external component clearly identifies itself whenever it is used
+ interactively. Unless explicitly specified when applying the
+ license to the Work, the only applicable Base Interpreter is a
+ `LaTeX-Format' or in the case of files belonging to the
+ `LaTeX-format' a program implementing the `TeX language'.
+
+
+
+CONDITIONS ON DISTRIBUTION AND MODIFICATION
+===========================================
+
+1. Activities other than distribution and/or modification of the Work
+are not covered by this license; they are outside its scope. In
+particular, the act of running the Work is not restricted and no
+requirements are made concerning any offers of support for the Work.
+
+2. You may distribute a complete, unmodified copy of the Work as you
+received it. Distribution of only part of the Work is considered
+modification of the Work, and no right to distribute such a Derived
+Work may be assumed under the terms of this clause.
+
+3. You may distribute a Compiled Work that has been generated from a
+complete, unmodified copy of the Work as distributed under Clause 2
+above, as long as that Compiled Work is distributed in such a way that
+the recipients may install the Compiled Work on their system exactly
+as it would have been installed if they generated a Compiled Work
+directly from the Work.
+
+4. If you are the Current Maintainer of the Work, you may, without
+restriction, modify the Work, thus creating a Derived Work. You may
+also distribute the Derived Work without restriction, including
+Compiled Works generated from the Derived Work. Derived Works
+distributed in this manner by the Current Maintainer are considered to
+be updated versions of the Work.
+
+5. If you are not the Current Maintainer of the Work, you may modify
+your copy of the Work, thus creating a Derived Work based on the Work,
+and compile this Derived Work, thus creating a Compiled Work based on
+the Derived Work.
+
+6. If you are not the Current Maintainer of the Work, you may
+distribute a Derived Work provided the following conditions are met
+for every component of the Work unless that component clearly states
+in the copyright notice that it is exempt from that condition. Only
+the Current Maintainer is allowed to add such statements of exemption
+to a component of the Work.
+
+ a. If a component of this Derived Work can be a direct replacement
+ for a component of the Work when that component is used with the
+ Base Interpreter, then, wherever this component of the Work
+ identifies itself to the user when used interactively with that
+ Base Interpreter, the replacement component of this Derived Work
+ clearly and unambiguously identifies itself as a modified version
+ of this component to the user when used interactively with that
+ Base Interpreter.
+
+ b. Every component of the Derived Work contains prominent notices
+ detailing the nature of the changes to that component, or a
+ prominent reference to another file that is distributed as part
+ of the Derived Work and that contains a complete and accurate log
+ of the changes.
+
+ c. No information in the Derived Work implies that any persons,
+ including (but not limited to) the authors of the original version
+ of the Work, provide any support, including (but not limited to)
+ the reporting and handling of errors, to recipients of the
+ Derived Work unless those persons have stated explicitly that
+ they do provide such support for the Derived Work.
+
+ d. You distribute at least one of the following with the Derived Work:
+
+ 1. A complete, unmodified copy of the Work;
+ if your distribution of a modified component is made by
+ offering access to copy the modified component from a
+ designated place, then offering equivalent access to copy
+ the Work from the same or some similar place meets this
+ condition, even though third parties are not compelled to
+ copy the Work along with the modified component;
+
+ 2. Information that is sufficient to obtain a complete,
+ unmodified copy of the Work.
+
+7. If you are not the Current Maintainer of the Work, you may
+distribute a Compiled Work generated from a Derived Work, as long as
+the Derived Work is distributed to all recipients of the Compiled
+Work, and as long as the conditions of Clause 6, above, are met with
+regard to the Derived Work.
+
+8. The conditions above are not intended to prohibit, and hence do not
+apply to, the modification, by any method, of any component so that it
+becomes identical to an updated version of that component of the Work as
+it is distributed by the Current Maintainer under Clause 4, above.
+
+9. Distribution of the Work or any Derived Work in an alternative
+format, where the Work or that Derived Work (in whole or in part) is
+then produced by applying some process to that format, does not relax or
+nullify any sections of this license as they pertain to the results of
+applying that process.
+
+10. a. A Derived Work may be distributed under a different license
+ provided that license itself honors the conditions listed in
+ Clause 6 above, in regard to the Work, though it does not have
+ to honor the rest of the conditions in this license.
+
+ b. If a Derived Work is distributed under a different license, that
+ Derived Work must provide sufficient documentation as part of
+ itself to allow each recipient of that Derived Work to honor the
+ restrictions in Clause 6 above, concerning changes from the Work.
+
+11. This license places no restrictions on works that are unrelated to
+the Work, nor does this license place any restrictions on aggregating
+such works with the Work by any means.
+
+12. Nothing in this license is intended to, or may be used to, prevent
+complete compliance by all parties with all applicable laws.
+
+
+NO WARRANTY
+===========
+
+There is no warranty for the Work. Except when otherwise stated in
+writing, the Copyright Holder provides the Work `as is', without
+warranty of any kind, either expressed or implied, including, but not
+limited to, the implied warranties of merchantability and fitness for a
+particular purpose. The entire risk as to the quality and performance
+of the Work is with you. Should the Work prove defective, you assume
+the cost of all necessary servicing, repair, or correction.
+
+In no event unless required by applicable law or agreed to in writing
+will The Copyright Holder, or any author named in the components of the
+Work, or any other party who may distribute and/or modify the Work as
+permitted above, be liable to you for damages, including any general,
+special, incidental or consequential damages arising out of any use of
+the Work or out of inability to use the Work (including, but not limited
+to, loss of data, data being rendered inaccurate, or losses sustained by
+anyone as a result of any failure of the Work to operate with any other
+programs), even if the Copyright Holder or said author or said other
+party has been advised of the possibility of such damages.
+
+
+MAINTENANCE OF THE WORK
+=======================
+
+The Work has the status `author-maintained' if the Copyright Holder
+explicitly and prominently states near the primary copyright notice in
+the Work that the Work can only be maintained by the Copyright Holder
+or simply that it is `author-maintained'.
+
+The Work has the status `maintained' if there is a Current Maintainer
+who has indicated in the Work that they are willing to receive error
+reports for the Work (for example, by supplying a valid e-mail
+address). It is not required for the Current Maintainer to acknowledge
+or act upon these error reports.
+
+The Work changes from status `maintained' to `unmaintained' if there
+is no Current Maintainer, or the person stated to be Current
+Maintainer of the work cannot be reached through the indicated means
+of communication for a period of six months, and there are no other
+significant signs of active maintenance.
+
+You can become the Current Maintainer of the Work by agreement with
+any existing Current Maintainer to take over this role.
+
+If the Work is unmaintained, you can become the Current Maintainer of
+the Work through the following steps:
+
+ 1. Make a reasonable attempt to trace the Current Maintainer (and
+ the Copyright Holder, if the two differ) through the means of
+ an Internet or similar search.
+
+ 2. If this search is successful, then enquire whether the Work
+ is still maintained.
+
+ a. If it is being maintained, then ask the Current Maintainer
+ to update their communication data within one month.
+
+ b. If the search is unsuccessful or no action to resume active
+ maintenance is taken by the Current Maintainer, then announce
+ within the pertinent community your intention to take over
+ maintenance. (If the Work is a LaTeX work, this could be
+ done, for example, by posting to comp.text.tex.)
+
+ 3a. If the Current Maintainer is reachable and agrees to pass
+ maintenance of the Work to you, then this takes effect
+ immediately upon announcement.
+
+ b. If the Current Maintainer is not reachable and the Copyright
+ Holder agrees that maintenance of the Work be passed to you,
+ then this takes effect immediately upon announcement.
+
+ 4. If you make an `intention announcement' as described in 2b. above
+ and after three months your intention is challenged neither by
+ the Current Maintainer nor by the Copyright Holder nor by other
+ people, then you may arrange for the Work to be changed so as
+ to name you as the (new) Current Maintainer.
+
+ 5. If the previously unreachable Current Maintainer becomes
+ reachable once more within three months of a change completed
+ under the terms of 3b) or 4), then that Current Maintainer must
+ become or remain the Current Maintainer upon request provided
+ they then update their communication data within one month.
+
+A change in the Current Maintainer does not, of itself, alter the fact
+that the Work is distributed under the LPPL license.
+
+If you become the Current Maintainer of the Work, you should
+immediately provide, within the Work, a prominent and unambiguous
+statement of your status as Current Maintainer. You should also
+announce your new status to the same pertinent community as
+in 2b) above.
+
+
+WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE
+======================================================
+
+This section contains important instructions, examples, and
+recommendations for authors who are considering distributing their
+works under this license. These authors are addressed as `you' in
+this section.
+
+Choosing This License or Another License
+----------------------------------------
+
+If for any part of your work you want or need to use *distribution*
+conditions that differ significantly from those in this license, then
+do not refer to this license anywhere in your work but, instead,
+distribute your work under a different license. You may use the text
+of this license as a model for your own license, but your license
+should not refer to the LPPL or otherwise give the impression that
+your work is distributed under the LPPL.
+
+The document `modguide.tex' in the base LaTeX distribution explains
+the motivation behind the conditions of this license. It explains,
+for example, why distributing LaTeX under the GNU General Public
+License (GPL) was considered inappropriate. Even if your work is
+unrelated to LaTeX, the discussion in `modguide.tex' may still be
+relevant, and authors intending to distribute their works under any
+license are encouraged to read it.
+
+A Recommendation on Modification Without Distribution
+-----------------------------------------------------
+
+It is wise never to modify a component of the Work, even for your own
+personal use, without also meeting the above conditions for
+distributing the modified component. While you might intend that such
+modifications will never be distributed, often this will happen by
+accident -- you may forget that you have modified that component; or
+it may not occur to you when allowing others to access the modified
+version that you are thus distributing it and violating the conditions
+of this license in ways that could have legal implications and, worse,
+cause problems for the community. It is therefore usually in your
+best interest to keep your copy of the Work identical with the public
+one. Many works provide ways to control the behavior of that work
+without altering any of its licensed components.
+
+How to Use This License
+-----------------------
+
+To use this license, place in each of the components of your work both
+an explicit copyright notice including your name and the year the work
+was authored and/or last substantially modified. Include also a
+statement that the distribution and/or modification of that
+component is constrained by the conditions in this license.
+
+Here is an example of such a notice and statement:
+
+ %% pig.dtx
+ %% Copyright 2005 M. Y. Name
+ %
+ % 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.
+ % 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 M. Y. Name.
+ %
+ % This work consists of the files pig.dtx and pig.ins
+ % and the derived file pig.sty.
+
+Given such a notice and statement in a file, the conditions
+given in this license document would apply, with the `Work' referring
+to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being
+generated from `pig.dtx' using `pig.ins'), the `Base Interpreter'
+referring to any `LaTeX-Format', and both `Copyright Holder' and
+`Current Maintainer' referring to the person `M. Y. Name'.
+
+If you do not want the Maintenance section of LPPL to apply to your
+Work, change `maintained' above into `author-maintained'.
+However, we recommend that you use `maintained', as the Maintenance
+section was added in order to ensure that your Work remains useful to
+the community even when you can no longer maintain and support it
+yourself.
+
+Derived Works That Are Not Replacements
+---------------------------------------
+
+Several clauses of the LPPL specify means to provide reliability and
+stability for the user community. They therefore concern themselves
+with the case that a Derived Work is intended to be used as a
+(compatible or incompatible) replacement of the original Work. If
+this is not the case (e.g., if a few lines of code are reused for a
+completely different task), then clauses 6b and 6d shall not apply.
+
+
+Important Recommendations
+-------------------------
+
+ Defining What Constitutes the Work
+
+ The LPPL requires that distributions of the Work contain all the
+ files of the Work. It is therefore important that you provide a
+ way for the licensee to determine which files constitute the Work.
+ This could, for example, be achieved by explicitly listing all the
+ files of the Work near the copyright notice of each file or by
+ using a line such as:
+
+ % This work consists of all files listed in manifest.txt.
+
+ in that place. In the absence of an unequivocal list it might be
+ impossible for the licensee to determine what is considered by you
+ to comprise the Work and, in such a case, the licensee would be
+ entitled to make reasonable conjectures as to which files comprise
+ the Work.
+
diff --git a/macros/latex/contrib/exam-n/notes-for-authors.pdf b/macros/latex/contrib/exam-n/notes-for-authors.pdf
new file mode 100644
index 0000000000..ca51908af3
--- /dev/null
+++ b/macros/latex/contrib/exam-n/notes-for-authors.pdf
Binary files differ
diff --git a/macros/latex/contrib/exam-n/notes-for-authors.tex b/macros/latex/contrib/exam-n/notes-for-authors.tex
new file mode 100644
index 0000000000..de9e3a8ba7
--- /dev/null
+++ b/macros/latex/contrib/exam-n/notes-for-authors.tex
@@ -0,0 +1,304 @@
+\documentclass[10pt]{scrartcl}
+%\documentclass[11pt]{scrartcl}
+
+\usepackage{url,pdfpages,moreverb,color}
+\definecolor{cscolour}{rgb}{0.5,0.1,0.1}
+
+\title{Notes for exam question authors}
+\author{Norman Gray}
+\date{exam-n 1.1.4, 2016 December 19}
+
+\parindent=0pt
+\parskip=\medskipamount
+
+\makeatletter
+\def\csarg#1{\texttt\{\textit{#1}\texttt\}%
+ \advance\@tempcnta-1
+ \ifnum\@tempcnta>0
+ \let\next\csarg
+ \else
+ \let\next\endgroup % begun in \cs
+ \fi
+ \next}
+\newcommand\cs[2][0]{\begingroup
+ \color{cscolour}%
+ $\backslash$\texttt{#2}%
+ \@tempcnta=#1
+ \ifnum\@tempcnta>0
+ \let\next\csarg
+ \else
+ \let\next\endgroup
+ \fi
+ \next}
+
+\def\env#1{\texttt{\textcolor{cscolour}{#1}}}
+\def\opt#1{\texttt{[#1]}}
+
+\setcounter{secnumdepth}0
+
+\begin{document}
+\maketitle
+
+The full documentation for the \texttt{exam-n} document class is in
+the file \texttt{exam-n.pdf}, but some of this is quite detailed, and
+addressed to the exams convener, who has to assemble the overall
+exam. This document is a compact account of how to use the exams
+class as a question author.
+
+You can find updated versions of the \texttt{exam-n} document class, and the
+complete documentation, at \url{http://purl.org/nxg/dist/exam-n}.
+
+\subsection{Template}
+\label{s:template}
+\listinginput1{template-question.tex}
+
+Notice first that this is a standalone document -- you can \LaTeX\ it
+to produce a formatted exam paper, as long as you include the
+\opt{compose} option in the document class line. This complete
+document can later be given to the exams convener, who can
+input it unchanged into the master file which pulls the various questions
+together. It follows from that that you should be hesitant about putting anything into
+the preamble other than \cs{usepackage} commands, and you should
+consult with the exams convener to ensure that such packages go into
+the master file, too. It's probably a safe bet that the `graphicx'
+package will be included in the master file. If you want to include
+a \cs{newcommand}, or anything like that,
+it can be placed inside the \env{question} environment. For
+other customisations, negotiate with the exams convener.
+
+The \env{question} environment contains (surprise) a question, broken into
+parts (a, b, c, \dots) by \cs{part} commands, and with the distribution of marks within
+the question being indicated by \cs[1]{partmarks}n; the class will check that the
+marks in \cs{partmarks} do add up to the question goal given as an
+argument in \cs[1]{begin\{question\}}{markgoal}. Within the
+question there can be one or more \env{solution} environments, which are
+not displayed in the final version (obviously), but which do appear in
+draft modes. You'll most typically have a \cs{partmarks} macro and a
+\env{solution} environment for each \cs{part}, but they don't have to
+match up, and you can have the entire solution at the end if you prefer.
+The \cs[1]{partmarks*}n command is almost the same, but places the
+mark indicator in a slightly different position which looks better
+when there would otherwise be a gap at the right of the page. It can
+be placed after a list, or inside but at the end of an equation.
+Note that \cs{partmarks} ends a paragraph (\cs{partmarks*} doesn't): this is
+probably good style, but if you insist on mid-paragraph marks, then a following
+\verb|\noindent| will be useful. It's helpful to use \cs{partmarks} inside a
+\env{solution} to indicate the distribution of marks -- this doesn't mess up
+the mark-totalling calculation.
+
+One common exam or test question type is a multiple-choice question.
+This is indicated by a \cs{begin\{mcq\}} environment, which contains a
+textual question followed by a sequence of possible answers indicated by
+\cs{item}, including precisely one correct answer, indicated by
+\cs{answer} (this is of course formatted identically to the others,
+unless the \opt{showsolutions} option is present). Before you can use
+the \env{mcq} environment, you must call
+\cs[1]{multiplechoiceanswers}{n} to indicate how many options are
+required in each question.
+It's OK to have a \env{solution} within an \env{mcq} environment,
+perhaps to provide commentary on or explanation of the correct answer.
+
+You can include a \env{questiondata} environment at (typically) the end of
+the question: this is intended for extra equations or constants which
+are useful for the examinee.
+
+The \env{figure} and \env{table} environments act differently from the
+way they usually act in \LaTeX: \emph{`floats' don't float}. In each
+case, the content is forced to be always `here', and in addition is
+also tied to the text which follows it, so that a page break will not
+occur immediately after a figure or table. There are \emph{no} figure
+or float options permitted in this class's `floating' environments
+(that is, option \texttt{[h]} is neither necessary nor permissible).
+If you need to tune the page breaking, then you should use
+\verb|\goodbreak|, \verb|\vspace| or, in extremis, \verb|\newpage|.
+The \cs[1]{caption}{text} command works as usual; the figure and table
+numbering sequences continue through the solutions, if they're shown,
+but this isn't expected to be a problem.
+
+If you use \cs{label} within a \env{question} environment, that label
+will, as you might expect, refer to the question number.
+
+Hints:
+Figures can be included with \cs{includegraphics} as usual, as long as
+the `graphicx' package has been included at the top of the master
+file. If you want to include complete pages from a PDF (most
+typically containing a scanned handwritten model answer), then you can
+do so by including the `pdfpages' package at the top of the file, and
+then \cs[1]{includepdf[pages=\{-\}]}{filename} inside a \env{solution}
+environment.
+The \texttt{pages=\{-\}} option means that all pages from the file are
+inserted; you may wish to use \texttt{scale=0.8} to shrink the PDF;
+the option \verb|pagecommand={\thispagestyle{fancy}}| will cause the other
+class apparatus, such as page numbers and headers, to be
+superimposed on the included pages.
+See the documentation of the `pdfpages' package for more information.
+
+Include marginal notes with \cs[1]{comment}{remark} -- these show up in drafting
+modes (\opt{draft} and \opt{compose}), but not in the final version.
+The \cs[1]{author}{name} command is just
+a type of comment. If you need to make more noise, then
+\cs[1]{shout}{remark} inserts a highlighted \emph{remark} in the flow of text
+(so it can be used anywhere) and includes the remark in a prominent
+list of exclamations at the end of the document.
+
+At the bottom of each page, you see a faint identification code, such
+as `QM/123-456'. This consists of an exam identifier, extracted from
+the exam preamble, plus a code which changes each time \LaTeX\ is
+run. This helps you avoid collation accidents, and to distinguish
+between slightly different versions of the printed document.
+
+\subsection{Various convenience commands}
+\label{s:othercommands}
+
+\makeatletter
+% Definitions edited in at build time...
+% Abbreviations for degrees.
+% \begin{macrocode}
+\newcommand\BSc{B.Sc.{}}
+\newcommand\MSci{M.Sci.{}}
+\newcommand\MSc{M.Sc.{}}
+\newcommand\MA{M.A.{}}
+\newcommand\MEng{M.Eng.{}}
+\newcommand\BEng{B.Eng.{}}
+% \end{macrocode}
+%
+% Tweaks to differentials.
+% \begin{macrocode}
+\newcommand{\dd}{\mathrm{d}}
+\newcommand{\ddd}{\,\mathrm{d}} % inside an integral, including thinspace
+
+\def\Diffl{\@ifstar\@Difflflat\@Diffl}
+\def\Partial{\@ifstar\@Partialflat\@Partial}
+\def\@Partial{\@ifnextchar[{\@@Diffl\partial}{\@@Diffl\partial[]}}
+\def\@Partialflat{\@ifnextchar[{\@@Difflflat\partial}{\@@Difflflat\partial[]}}
+\def\@Diffl{\@ifnextchar[{\@@Diffl\dd}{\@@Diffl\dd[]}}
+\def\@Difflflat{\@ifnextchar[{\@@Difflflat\dd}{\@@Difflflat\dd[]}}
+\def\@@Diffl#1[#2]#3#4{%
+ \def\@tempa{#2}%
+ \ifx\@tempa\empty
+ \frac{#1#3}{#1#4}%
+ \else
+ \frac{{#1}^{#2}#3}{#1{#4}^{#2}}%
+ \fi}
+\def\@@Difflflat#1[#2]#3#4{%
+ \def\@tempa{#2}%
+ \ifx\@tempa\empty
+ #1#3\mskip-0.8mu/\mskip-1.2mu #1#4%
+ \else
+ {#1}^{#2}#3\mskip-0.8mu /\mskip-1.2mu #1{#4}^{#2}%
+ \fi}
+% \end{macrocode}
+%
+% The exponential sign
+% \begin{macrocode}
+\def\e{{\mathrm e}}
+% \end{macrocode}
+%
+% Physical units in |\rm|. Unstarred version includes leading
+% |\thinspace|. Starred version doesn't, and is used when referring to
+% the unit by itself (eg axis is |$B/\units*T$|), and is not qualifying
+% a number.
+% FIXME: |\mu| in |\units| can come out wrong in some fonts (mtpro2?)
+% -- needs investigation.
+% \begin{macrocode}
+\def\units{\begingroup
+ \catcode`\.=\active
+ \@ifstar{\let\un@tsspace\relax \un@ts}%
+ {\let\un@tsspace\thinspace\un@ts}}
+\begingroup
+ \catcode`\.=\active
+ \gdef\un@ts#1{\let~\thinspace\let.\thinspace
+ \ifmmode
+ \un@tsspace\mathrm{#1}%
+ \else
+ \nobreak$\un@tsspace\mathrm{#1}$%
+ \fi
+ \endgroup}
+\endgroup
+% \end{macrocode}
+%
+% Other miscellaneous symbols:
+% The AU is nothing exciting, but may be adjusted in future
+% \begin{macrocode}
+\def\au{au}
+% \end{macrocode}
+% The symbol for Compton wavelength is a crossed lambda -- the following isn't perfect, but is OK for now.
+% \begin{macrocode}
+\def\lambdabar{\setbox\@tempboxa\hbox{$\lambda$}%
+ \hbox to 0pt{\hbox to \wd\@tempboxa{\hss$\bar{}$\hss}\hss}\box\@tempboxa}
+% \end{macrocode}
+\makeatother
+
+Macro \cs[1]{vec}{v} is redefined to give bold-font vectors, rather than
+vectors with arrows, which is the (weird) \LaTeX\ default. This
+should work for bold greek as well as roman.
+
+Macros \cs{dd} and \cs{ddd}: \cs{dd} is a roman d, as used for
+differentials; \cs{ddd} is the same with a preceding thinspace,
+as used within integrals; for example
+\[
+ \verb|\int f(x)\ddd x = \int f(x)\,\dd x| = \int f(x)\ddd x
+\]
+
+You can typeset derivatives neatly:
+\begin{center}
+\def\dd{\mathrm{d}}
+\begin{tabular}{rl}
+\verb|\Diffl{a}{b}| & $\displaystyle \Diffl ab$ \\[3ex]
+\verb|\Diffl[2]{a}{b}| & $\displaystyle \Diffl[2]ab$\\[3ex]
+\verb|\Diffl*{a}{b}| & $\Diffl* ab$ \\[2ex]
+\verb|\Diffl*[2]{a}{b}| & $\Diffl*[2]ab$\\
+\end{tabular}
+\end{center}
+The unstarred versions are for displayed equations, the starred
+ones for inline maths.
+There is analogous support for partial derivatives with \cs[2]{Partial}ab.
+
+Macros \cs[1]{units}{expr}, \cs[1]{units*}{expr}: These typeset
+physical units in an upright shape, with tilde or dot acting as a
+separator between units. Since this is typeset in maths mode, all
+other spacing is ignored. For example, \verb|$v=10\units{m.\mu s^{-1}}$|
+gives $v=10\units{m.\mu s^{-1}}$. The unstarred version includes some
+leading space; the starred version can be used when referring to the
+unit by itself, where it is not qualifying a number (eg labelling an
+axis with units \verb|$B/\units*T$|, or $B/\units*T$). These macros
+might be replaced, in the future, by a recommendation to use the
+\texttt{siunitx} package.
+
+For some other useful symbols, see the table below:
+
+\def\arraystretch{1.5}
+\begin{tabular}{rcp{8cm}}
+\cs{e}&$\e^{i\pi}+1=0$& the exponential is typeset in an upright rather than
+an italic shape, as in \verb|$\e^{i\pi} + 1 = 0$|.\\
+\cs{au}&10\units\au& astronomical units:
+\verb|10\units{\au}|.\\
+\cs{lambdabar}&$\lambdabar$& the Compton wavelength, as a lambda with a
+bar through it.\\
+\end{tabular}
+
+
+\subsection{Extra: Creating complete exams}
+\label{s:complete}
+As a question author, you are typically only concerned with one or two
+single questions, and that is why this brief guide concentrates
+exclusively on the \opt{compose} mode. But you might be interested to see
+how your text appears in the final exam. A template master file is
+below. For more detail, see the complete documentation in \texttt{exam-n.pdf}.
+\goodbreak
+\listinginput1{template-master.tex}
+
+The \texttt{exam-n} class currently supports a sample class option \opt{A1}.
+This automatically includes a suitable constants sheet in the
+formatted paper.
+
+On the following pages, you can see the result of \LaTeX ing the sample file on
+p.\pageref{s:template}, and of processing the master file above.
+As you can see, the \opt{compose} mode by default shows solutions,
+and collects the \cs[1]{shout}{text} remarks to the end.
+In the \opt{final} mode (which is the default mode), solutions
+disappear, but the shouted-out alerts remain, just to make sure no-one
+can miss them.
+\includepdf{template-question.pdf}
+\includepdf[pages={2,1},angle=90,nup=1x2,column]{template-master.pdf}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/release-notes.html b/macros/latex/contrib/exam-n/release-notes.html
new file mode 100644
index 0000000000..9f843e11f6
--- /dev/null
+++ b/macros/latex/contrib/exam-n/release-notes.html
@@ -0,0 +1,340 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>exam-n class – release notes</title>
+<link href="http://nxg.me.uk" rev="author"/>
+<link type="text/css" rel="stylesheet"
+ href="style.css"/>
+<style type='text/css'>
+dd ul { padding: 0pt; margin: 0pt; }
+</style>
+</head>
+
+<body>
+<h1>The exam-n class – release notes</h1>
+
+<dl>
+<!-- @CURRENT@ -->
+<dt><span class='attention'>1.1.4, 2016 December 19</span></dt>
+<dd><ul>
+<li>Documentation: add notes about use of pdfpages.</li>
+<li>Added <code>[largefont]</code> option.
+<strong>Note</strong>:
+option <code>[hugefont]</code> has replaced <code>[bigfont]</code>;
+the latter is now deprecated, and may be removed in v1.2.</li>
+<li>Use of the <code>\part</code> macro is now supported within
+solutions (it produced the wrong numbers before), and there is a new
+<code>\StylePartNumber</code> customisation macro.</li>
+</ul></dd>
+
+<dt>1.1.3</dt>
+<dd><ul>
+<li>Version 1.1.3 was never released</li>
+</ul></dd>
+
+<dt>1.1.2, 2015 November 26</dt>
+<dd><ul>
+<li>Handled trailing floats at end of document (generated by packages
+such as <code>rotating</code>.</li>
+<li><code>\label</code> within question environment now refers to the
+question number.</li>
+<li>Work around a problem when a paragraph starts with <code>{\bf ...}</code>
+rather than (post-1995) <code>\textbf{...}</code>.</li>
+<li><code>\begin{questiondata}</code> now starts a new paragraph.</li>
+<li>Some documentation adjustments.</li>
+</ul></dd>
+
+<dt>1.1.1, 2014 November 27</dt>
+<dd><ul>
+<li>Adjust <code>\partmarks*</code> behaviour; now behaves differently
+within display maths (addresses
+<a href='https://bitbucket.org/nxg/exam-n/issue/1/'>issue 1</a>).</li>
+<li>Various documentation and release fixes.</li>
+</ul></dd>
+
+<dt>1.1, 2014 May 3</dt>
+<dd>Converted to a generic class, <code>exam-n</code>, ready for wider
+distribution.
+Available on <a href='https://bitbucket.org/nxg/exam-n/'>bitbucket</a>
+and at CTAN.</dd>
+
+<!-- @ENDCURRENT@ -->
+
+<dt>1.0.16, 2014 February 28</dt>
+<dd><ul>
+<li>Option mtpro2 now switches to times (this fixes a pre-existing bug
+ exposed by the [sansserif] option).</li>
+<li>The [bigfont] option now works (this fixes a pre-existing bug, to
+ do with <code>\subsections</code>, which was exposed by the addition
+ of the [bigfont] option).</li>
+<li>Added the [bigfont] option</li>
+<li>Fixed 'shouts' warning at start (again)</li>
+<li>Forbid *section commands inside questions (and don't freak out)</li>
+<li>Rename <code>\questiontrailer</code> to <code>\questionpreamble</code> (more logical)</li>
+<li>Fixed mcq warnings, and 'question continued' errors.</li>
+<li>Renamed <code>\multiplechoicequestions</code> to more logical
+ <code>\multiplechoiceanswers</code></li>
+<li>Various (further) spacing changes</li>
+<li>Added <code>\subsection</code></li>
+<li>Release includes
+1.0.16b1 (2014 January 20);
+1.0.16b2 (20 January);
+1.0.16b3 (22 January);
+1.0.16b4 (14 February).
+</li>
+</ul>
+</dd>
+
+<dt>1.0.15, 2014 January 19</dt>
+<dd><ul>
+<li>Fixed mcq and showsolutions, to suppress incorrect warning of missing answers.</li>
+</ul></dd>
+
+<dt>1.0.14, 2014 January 10</dt>
+<dd><ul>
+<li>pdfpages content now appears in draft mode.</li>
+<li>The <code>[draft]</code> option now implies [showsolutions] (so if
+you want to suppress the solutions in this mode, you must now follow
+<code>[draft]</code> with <code>[noshowsolutions]</code>).</li>
+<li>Showing missing information: shouts and missing exam date/time are
+now highlighted.</li>
+<li>Fixed bug where excess <code>\QuestionNumberChecksOff</code>
+caused question numbers to disappear.</li>
+<li>Remove indent at start of question.</li>
+</ul></dd>
+
+<dt>1.0.13, 2013 December 4</dt>
+<dd><ul>
+<li>Added a <code>[sansserif]</code> class option.</li>
+<li>Improved spacing and linebreaking; there are now fewer bad page-breaks.</li>
+<li>Added the <code>{mcq}</code> environment.</li>
+<li>Changed the distribution licence from GPL to LPPL.</li>
+</ul>
+</dd>
+
+<dt>1.0.12, 2013 November 11</dt>
+<dd><ul>
+<li>Adjustments to banner text and base rubric (consulting with Morag Casey).</li>
+<li>Added notes about <code>\includepdf</code> in <q>notes for authors</q>.</li>
+<li>Adjustments to the distributed example files.</li>
+</ul></dd>
+
+<dt>1.0.11, 2013 July 18</dt>
+<dd>Adjustments to question data: k_B, etc, should have roman subscripts.</dd>
+
+<dt>1.0.10, 2013 June 27</dt>
+<dd>Minor documentation and distribution fixes</dd>
+
+<dt><span>1.0.9, 2013 March 22</span></dt>
+<dd>Remove leftover debugging code (garhhh)</dd>
+
+<dt>1.0.8, 2013 March 14</dt>
+<dd>Add the <code>mono</code> and <code>colour</code> options.</dd>
+
+<dt>1.0.7, 2013 March 14</dt>
+<dd><ul>
+<li>pdfpages is now disabled <em>only</em> in solutions</li>
+<li>Minor layout changes (exam title adjusts size for long
+titles)</li>
+</ul></dd>
+
+<dt>1.0.6, 2013 March 13</dt>
+<dd><ul>
+<li>Avoid tables and figures in solutions incrementing the float counter.</li>
+<li>Layout changes; adjustment to default base rubric; A345 rubric change</li>
+<li>Some documentation changes</li>
+</ul>
+</dd>
+
+<dt>1.0.4-1, 2013 March 8</dt>
+<dd>This is a bugfix release: it's a re-release of now-deprecated
+1.0.5 minus a breaking change.<ul>
+<li>Add <code>{table}</code> support, paralleling existing
+<code>{figure}</code> support (ie tables don't float, but captions
+work as expected).</li>
+<li>Blank lines after a <code>\begin{question}</code> no longer
+result in extra space.</li>
+<li>Adjust spacing and layout of front page (again); various other
+cosmetic changes.</li>
+<li>A document identifier appears at the bottom of each page,
+corroborating the exam the page is for (to avoid photocopier collation
+accidents), and giving a numeric identifier which increases with time
+(allowing you to identify which of two printouts is later).</li>
+</ul></dd>
+
+<dt>1.0.4, 2013 March 6</dt>
+<dd>Adjust base rubric; assorted distribution and detail fixes.</dd>
+
+<dt>1.0.3, 2013 January 25</dt>
+<dd>Added <code>[A2]</code> class option.</dd>
+
+<dt>1.0.2, 2013 January 25</dt>
+<dd><ul>
+<li>The `pdfpages' package wasn't working when the `noshowsolutions'
+option was present. Fixed, by special-casing, specifically disabling the
+<code>\includepdf</code> command in this case.</li>
+<li>Adjust display of <code>\partmarks</code> (no need for extra
+space, since <code>\partmarks</code> is now fully in the margin).</li>
+<li>Adjusting the front-page layout. Again.</li>
+</ul></dd>
+
+<dt>1.0.1, 2013 January 18</dt>
+<dd><ul>
+<li><code>{figure}</code> now works, because it's explicitly
+supported (<code>{figure}</code> inside solutions could cause problems
+before). The contents don't float.</li>
+<li>Layout adjustments.</li>
+<li>Graphics now appear in draft mode.</li>
+</ul>
+</dd>
+
+<dt>1.0, 2012 December 11</dt>
+<dd>This is the nominal version 1.0 release, and will be used for the
+2012-13 Honours Astronomy exams (it might get further tweaks along the
+way, but we believe this is a complete distribution set).<ul>
+<li>More adjustments to notes-for-authors, now showing example LaTeX results.</li>
+<li>Addition of template-question.tex</li>
+<li>Adjustments to base rubric.</li>
+</ul></dd>
+
+<dt>1.0b5, 2012 December 3</dt>
+<dd><ul>
+<li>Fine formatting adjustments: occasional <code>\nobreak</code> and
+rationalisation of <code>\maketitle</code>.</li>
+<li>Improvements to notes-for-authors.</li>
+</ul></dd>
+
+<dt>1.0b4, 2012 November 30</dt>
+<dd><ul>
+<li>Improve generation of PDF metadata.</li>
+<li>Add macro <code>\shout</code>, for highlighted `FIXME' comments.</li>
+<li>Add showmarktotals option.</li>
+<li>Permit <code>\partmarks</code> in solutions, without it adding to
+the marks added up for the question (at the same time, forbid having a
+solution within a solution).</li>
+<li>Various formatting adjustments.</li>
+</ul>
+</dd>
+
+<dt>1.0b3, 2012 November 8</dt>
+<dd><ul>
+<li>Add [A345] option.</li>
+<li>Make compose/draft material appear in red.</li>
+<li>Some packaging changes and bugfixes.</li>
+</ul></dd>
+
+<dt>1.0b2, 2012 November 6</dt>
+<dd>Mild formatting adjustments.</dd>
+
+<dt>1.0rc1, 2012 November 2</dt>
+<dd><ul>
+<li>Significant rewrite of formatting, producing a consensus
+AandA/PhysHons style, and renaming some confusingly named
+commands.</li>
+<li>Consequently, the AandA.clo and PhysHons.clo options have
+disappeared.</li>
+<li>The <code>\constantssheet</code> macro has appeared, and setting
+this is now the principal function of per-class <code>.clo</code>
+files.
+See the new <code>A1.clo</code> and modified <code>P2.clo</code> option files.</li>
+</ul>
+</dd>
+
+<dt>0.17.1, 2012 September 21</dt>
+<dd>Fix packaging infelicity</dd>
+
+<dt>0.17, 2012 September 21</dt>
+<dd><ul>
+<li>Rework <code>solutions</code> environment to make it a little more robust.</li>
+<li>Add <code>\MSc</code> degree shorthand.</li>
+<li>Bugfix: continuation headers now appear if a question starts on page 1.</li>
+<li>Bugfix: fix wrong syntax in draft+showsolutions mode -- now works again</li>
+</ul>
+</dd>
+
+<dt>0.16, 2012 July 26</dt>
+<dd><ul>
+<li>Renamed the [showmarks] option to more rational [perquestionmarks]
+(because the option doesn't control whether per-question marks are
+<em>displayed</em>, but whether they're tracked at all). Slightly
+improved the documentation of this at the same time.</li>
+<li>Added <code>\lambdabar</code> macro</li>
+<li>Fix long-standing problem with continuation lines -- these should now be robust.</li>
+</ul></dd>
+<dt>0.15, 2011 November 23</dt>
+<dd>Avoid conflict with <code>ifpdf</code> package.
+Now <em>depends</em> on <code>ifpdf</code>.</dd>
+<dt>0.14, 2010 August 6</dt>
+<dd><ul>
+<li>Fixed the problem where the question-continuation marks would be
+messed up by the presence of floats.</li>
+<li>Added P2.clo; adjust 'showing solutions' banner
+to avoid collision with other headers (thanks to Morag Casey for the .clo
+file and the report).</li>
+<li>Changed the name of the class to 'guexam', from potentially confusing 'exam'.
+Support guexam.config for forcing options (for example).</li>
+</ul></dd>
+
+<dt>0.13-1, 2008 November 21</dt>
+<dd>Make the gulogo style optional, so that question authors don't
+have to download and install that before they can draft a question.
+Also adjust the logo size.</dd>
+
+<dt>0.13, 2008 November 11</dt>
+<dd>Add university logo, and slightly rearrange the header.
+Add <code>{questiondata}</code> environment.</dd>
+
+<dt>0.12-2, 2008 April 14</dt>
+<dd>...keep on truckin'. Further changes to the
+<code>\partmarks*</code> spacing code, still largely unprincipled, but
+looking closer to what's required.</dd>
+
+<dt>0.12-1, 2008 April 3</dt>
+<dd>...and again. This time, I think I actually see what the problem
+was. Macro <code>\partmarks</code> now forces a new paragraph (it was
+documented to be usable at the end of a paragraph, so this is again
+forced, and the documentation made more explicit), this makes what I
+thought was the solution actually work. Which is nice. Redefined
+<code>enumerate</code> and <code>itemize</code> environments, to
+improve spacing somewhat.</dd>
+
+<dt>0.12, 2008 April 3</dt>
+<dd>Further adjustments to <code>\partmarks</code>: again, it should
+be more consistent without necessarily being more principled, alas.</dd>
+
+<dt>0.11, 2008 March 30</dt>
+<dd>Minor fixes: Adjust display of partmarks -- should now be more
+consistent; option [showsolutions] no longer defaults
+[{no,}pageperquestion]; add macro <code>\e</code> to format roman
+exponential.</dd>
+
+<dt>0.10, 2008 January 17</dt>
+<dd>Fix <code>\vec</code> when it appears in sub- or superscript
+position. Add <code>\paperident</code> command.</dd>
+
+<dt>0.9, 2007 December 10</dt>
+<dd>Various formatting changes. Added optional argument to
+<code>\includequestion</code> overriding question number.</dd>
+
+<dt>0.8, 2007 November 25</dt>
+<dd>You can now use <code>\usepackage</code> within
+<code>[compose]</code> mode.</dd>
+
+<dt>0.7, 2007 November 20</dt>
+<dd>Make changes to the display of the 'University of Glasgow' banner
+at the top: resolves some font problems. Other minor layout tweaks.</dd>
+
+<dt>0.6, 2007 November 18</dt>
+<dd>Fixed bold maths problems: <code>\vec</code> now works with greek
+letters, too. Support MTpro2 (mathtime maths fonts) with the new
+<code>[mtpro2]</code> class option. The <code>{solution}</code>
+environment can appear multiple times within a question. Question
+numbers now appear correctly in 'final' mode.</dd>
+
+<dt>0.5, 2007 October 30</dt>
+<dd>Fix collision with LaTeX internal: a <code>\comment</code> at the
+start of a <code>{question}</code> now works.</dd>
+
+</dl>
+
+</body>
+</html>
diff --git a/macros/latex/contrib/exam-n/sample/Makefile b/macros/latex/contrib/exam-n/sample/Makefile
new file mode 100644
index 0000000000..253245e534
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/Makefile
@@ -0,0 +1,23 @@
+%.pdf: %.tex ../exam-n.cls
+ TEXINPUTS=..: pdflatex $<
+ if grep 'Rerun to get cross' ${<:.tex=.log}; then TEXINPUTS=..: pdflatex $<; else :; fi
+
+all: sample_exam.pdf
+
+sample_exam.pdf: numerical1-solution.pdf
+
+sample_exam_solution.pdf: sample_exam_solution.tex
+
+sample_exam_solution.tex: sample_exam.tex
+ rm -f $@
+ sed '1s/documentclass/documentclass[showsolutions]/' sample_exam.tex >sample_exam_solution.tex
+
+# This will depend somehow on the .dtx file in the parent directory,
+# but expressing that here second-guesses how that file is actually
+# generated, so skip this ('don't repeat yourself'; also, this is only
+# occasionally used while testing)
+../exam-n.cls:
+ cd ..; $(MAKE) exam-n.cls
+
+clean:
+ rm -f *.pdf *.log *.aux sample_exam_solution.tex
diff --git a/macros/latex/contrib/exam-n/sample/cosmo1.tex b/macros/latex/contrib/exam-n/sample/cosmo1.tex
new file mode 100644
index 0000000000..27045d026a
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/cosmo1.tex
@@ -0,0 +1,93 @@
+\documentclass[compose]{exam-n}
+
+\usepackage{graphics}
+\graphicspath{{fig/}}
+
+\begin{document}
+
+\begin{question}{20} \author{Reginald Q Whimsy}
+% Have a blank line here, to check that the question number remains
+% nicely lined up, even if there are lines between the environment
+% opening and the text.
+
+First, \emph{admire} the restful picture of a spiral in Fig.\ \ref{f:spiral},
+included as a graphic. Fully zenned up? Then let us begin\dots.
+\begin{figure}
+\ifbigfont
+ \includegraphics[width=\textwidth]{spiral}
+\else
+ \includegraphics{spiral}
+\fi
+\caption{\label{f:spiral}A spiral}
+\end{figure}
+
+\part Show that, under the action of gravity alone, the scale size
+of the Universe varies according to
+\begin{equation}
+\ddot{R}=-\frac{4\pi G \rho_0}{3R^2}
+\end{equation}
+\partmarks*{4}
+and that, consequently,
+\begin{equation*}
+\dot{R}^2=-\frac{8\pi G \rho_0}{3R}=-K.
+\partmarks*{3}
+\end{equation*}
+
+Express $K$ in terms of the present values of the Hubble constant
+$H_0$ and of the density parameter $\Omega_0$.
+\partmarks{3}
+\begin{solution}
+This can be solved by \emph{remembering} the solution
+\partmarks{3}
+\end{solution}
+
+\part In the early Universe, the relation between time and
+temperature has the form
+\begin{equation*}
+t=\sqrt{\frac{3c^2}{16\pi G g_{\rm eff}a}}\frac{1}{T^2},
+\end{equation*}
+where $a$ is the radiation constant. Discuss the assumptions
+leading to this equation, but do not carry out the mathematical
+derivation. Discuss the meaning of the factor $g_{\rm eff}$ , and
+find its value just before and after annihilation of electrons and
+positrons.
+\partmarks{6}
+\begin{solution}
+Before, well, geee; after\dots kazamm!
+\end{solution}
+
+\part
+Explain how the present-day neutron/proton ratio was established
+by particle interactions in the Early Universe. How is the ratio
+of deuterium to helium relevant to the nature of dark matter? It is
+\emph{crucially vital} to note
+that Table~\ref{t:dullness} is of absolutely no relevance to this question.
+\begin{table}
+\begin{tabular}{r|l}
+Column 1&and row 1\\
+More content&in row 2
+\end{tabular}
+\caption{\label{t:dullness}A remarkably dull table}
+\end{table}
+Finis.
+\begin{questiondata}
+Hubble's law: $v=H_0 D$
+\end{questiondata}
+\partmarks{4}
+\begin{solution}
+Explanations are superfluous; all that is, is.
+\begin{table}
+\begin{tabular}{r|l}
+First rows&are premier\\
+subsequent rows&are of secondary interest
+\end{tabular}
+\caption{\label{t:dullnessII}A table o'erbrimming with otioseness}
+\end{table}
+In addition, Table~\ref{t:dullnessII} adds nothing to the discussion,
+adds nothing to our understanding of our place in the cosmos, but it
+\emph{does} contribute slightly to the heat-death of the universe (can
+you work out how many deuterium nuclei decayed during the typing of
+this table?).
+\end{solution}
+\end{question}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/cosmo2.tex b/macros/latex/contrib/exam-n/sample/cosmo2.tex
new file mode 100644
index 0000000000..bb6c512b9d
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/cosmo2.tex
@@ -0,0 +1,60 @@
+\documentclass[compose]{exam-n}
+\begin{document}
+
+\begin{question}{30} \comment{by John Brown}
+Show by considering the Newtonian rules of vector and velocity
+addition that in Newtonian cosmology the cosmological principle
+demands Hubble's Law $v_r\propto r$.\partmarks{10}
+
+Prove that, in Euclidean geometry, the number $N(F)$ of objects
+of identical luminosity $L$, and of space density $n(r)$ at
+distance $r$, observed with radiation flux $\ge F$ is (neglecting
+other selection and redshift effects)
+\begin{equation*}
+N(F)=4\pi\int_0^{(\frac{L}{4\pi F})^{1/2}} n(r) r^2\ddd r.
+\end{equation*}
+\partmarks*{5}
+
+Use this to show that for $n=n_1=$constant at $r<r_1$ and
+$n=n_2=$constant at $r>r_1$,
+\begin{equation*}
+N(F) = N_1\left(\frac{F}{F_1}\right)^{-3/2}\qquad \text{for
+$F>F_1$},
+\end{equation*}
+and
+\ifbigfont
+ \begin{multline*}
+ N(F) =
+ N_1\left\{1+\frac{n_2}{n_1}\left[\left(\frac{F}{F_1}\right)^{-3/2}-1\right]
+ \right\}\\\text{for $F<F_1$},
+ \end{multline*}
+\else
+ \begin{equation*}
+ N(F) =
+ N_1\left\{1+\frac{n_2}{n_1}\left[\left(\frac{F}{F_1}\right)^{-3/2}-1\right]
+ \right\} \qquad \text{for $F<F_1$},
+ \end{equation*}
+\fi
+where $F_1=L/4\pi r_1^2$, $N_1=N(F_1)=\frac{4}{3}\pi r_1^3 n_1$.
+\partmarks{9}
+
+Reduce these two expressions to the result for a completely
+uniform density universe with $n_1=n_2=n_0$.
+\partmarks{3}
+
+% An itemized list followed by partmarks*
+Sketch how $n(F)$ would look in universes which are
+\begin{itemize}
+\item flat,
+\item open,
+\item and closed.
+\end{itemize}
+\partmarks*{3}
+
+\begin{solution}
+A sufficiently heavy weight will reduce expressions to completely
+uniform sheets of paper if it is placed on top of them.\partmarks3
+In a flat universe, $n(F)$ will look like n(F).\partmarks*3
+\end{solution}
+\end{question}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/cosmo3.tex b/macros/latex/contrib/exam-n/sample/cosmo3.tex
new file mode 100644
index 0000000000..b7b74c0107
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/cosmo3.tex
@@ -0,0 +1,50 @@
+\documentclass[compose]{exam-n}
+\begin{document}
+
+\begin{question}{30} \comment{by Andrew Davies}
+
+The Friedmann equations are written, in a standard notation,
+\begin{gather*}
+H^2 = \frac{8\pi G\rho}{3}-\frac{kc^2}{R^2}+\frac{\Lambda}{3},\\
+\Diffl {}t (\rho c^2R^3)=-p\Diffl {R^3}t,
+\end{gather*}
+Discuss briefly the meaning of each of $H$, $\rho$ , $k$ and
+$\Lambda$. \partmarks{4}
+
+Suppose the Universe consists of a single substance with equation
+of state $p=w\rho c^2$, where $ w=$constant. Consider the
+following cases, with $k=\Lambda=0$:
+
+\part For $w = 0$, find the relation between $R$ and $\rho$. Hence
+show that $H=\frac{2}{3t}$. What is the physical interpretation of
+this case?
+\partmarks{8}
+
+\part In the case $w=-1$ , show that $H = $constant and $R = A \exp(Ht)$,
+with $A$ constant.
+\partmarks{4}
+
+\part Explain how the case, $w=-1$, $k=\Lambda=0$, $\rho=0$ is
+equivalent to an empty, flat, Universe with a non-zero $\Lambda$.
+\partmarks{2}
+
+\part Consider a model Universe which contained matter with equation
+of state with $w = 0$ for $0 < t < t_0$, but which changes to
+$W=0$ for $t\ge t_0$ without any discontinuity in $H(t)$.
+Regarding this second stage as driven by a non-zero $\Lambda$ what
+is the value of $\Lambda$ if $t_0 = 10^{24}$\units{\mu s}? Define the
+dimensionless deceleration parameter, $q$, and find its value
+before and after $t_0$.
+\shout{Shout it loud: I'm a geek and I'm proud}
+\partmarks{8}
+
+Note: that's
+\[
+t_0=10^{24}\units{\mu s}\qquad\text{with a letter mu: $\mu$}.
+\]
+
+\part To what extent does this idealized model resemble the currently
+accepted picture of the development of our Universe?
+\partmarks{4}
+\end{question}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/dynamical1.tex b/macros/latex/contrib/exam-n/sample/dynamical1.tex
new file mode 100644
index 0000000000..e3a51a803b
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/dynamical1.tex
@@ -0,0 +1,96 @@
+\documentclass[compose]{exam-n}
+
+\begin{document}
+
+\begin{question}{20} \author{John Brown and Declan Diver}
+\part An earth satellite in a highly eccentric orbit of (constant)
+perigee distance $q$ undergoes a targential velocity impulse
+$-\Delta V$ at each perigee passage. By considering the mean rate
+of change of velocity at perigee, show that the mean rate of
+change of the semi-major axis $a$ ($\gg q$) satisfies
+\begin{equation*}
+\frac{1}{a^2} \Diffl at =
+\left(\frac{8}{GMq}\right)^{1/2}\frac{\Delta V}{T},
+\end{equation*}
+where $M$ is the Earth's mass and $T$ the orbital period.
+\partmarks{3}
+\begin{questiondata}
+You may assume $\displaystyle v^2(r)=GM\left(\frac{2}{r}-\frac{1}{a}\right)$.
+\end{questiondata}
+
+Using $T=2\pi(a^3/GM)^{1/2}$ show that with $a_0=a(0)$, (where
+$a(t)$ is the semimajor axis at time $t$)
+\begin{equation*}
+\frac{a(t)}{a_0}=\left[1-\frac{t\Delta V}{2^{1/2}\pi
+a_0(1-e_0)^{1/2}}\right]^2
+\end{equation*}
+\partmarks*{2}
+and
+\begin{equation*}
+\frac{T(t)}{T_0}=\left[1-\frac{t\Delta V}{2^{1/2}\pi
+a_0(1-e_0)^{1/2}}\right]^3
+\end{equation*}
+\partmarks*{1}
+and the eccentricity satisfies (with $e_0=e(0)$)
+\begin{equation*}
+e(t)=1-\frac{1-e_0}{\left[1-\frac{t\Delta V}{2^{1/2}\pi
+a_0(1-e_0)^{1/2}}\right]^2}.
+\end{equation*}
+\partmarks*{2}
+
+Show that, once the orbit is circular, its radius decays
+exponentially with time on timescale $m_0/2\dot{m}$ where $m_0$
+is the satellite mass and $\dot{m}$ the mass of atmosphere
+`stopped' by it per second. \partmarks{2}
+
+\part What is meant by (a) the sphere of influence of a star, and
+(b) the passage distance?
+\partmarks{2}
+
+Consider a system of $N$ identical stars, each of mass $m$.
+
+\part Given that the change $\delta u$ in the speed of one such star
+due to the cumulative effect over time $t$ of many gravitational
+encounters with other stars in the system can be approximated by
+\begin{equation*}
+(\delta u)^2 \propto [\nu tm^2\log(p_{\rm max}/p_{\rm
+min})]/\bar{u},
+\end{equation*}
+where $\bar{u}$ is the rms mutual speed, $\nu$ is the stellar
+number density, and $p_{\rm max, min}$ are the maximum, minimum
+passage distances for the system, show that this leads to a natural
+time $T$ for the system, where
+\begin{equation*}
+T\propto\frac{\bar{u}u^2}{m^2\nu\log N}.
+\end{equation*}
+\partmarks*{5}
+
+\begin{questiondata}
+You may assume that the sphere of influence radius of a star is
+approximated by $(m/M)^{2/5}R$ where $R$ and $M$ are the radius
+and mass of the whole system respectively.
+\end{questiondata}
+
+\part Deduce that $T$ is the disintegration timescale for the system,
+by showing that a star with initial speed $u_0$ in a stable circular
+orbit reaches escape speed after time $T$.
+\partmarks{3}
+
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+Dummy text, to lengthen the question to the extent that it spreads across three pages.
+\end{question}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/dynamical2.tex b/macros/latex/contrib/exam-n/sample/dynamical2.tex
new file mode 100644
index 0000000000..517ae84920
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/dynamical2.tex
@@ -0,0 +1,24 @@
+\documentclass[final]{exam-n}
+\begin{document}
+
+\begin{question}{30} \comment{by John Brown}
+Give the equations of motion for $i=1,\ldots, N$ particles of
+masses $m_i$ and positions $r_i(t)$ under the action of mutual
+gravity alone in an arbitrary inertial frame.
+\partmarks{4}
+
+Use these to derive the following conservation laws of the system:
+
+\part Constancy of linear momentum -- i.e., centre of mass fixed in a
+suitable inertial frame. \partmarks{4}
+ \part Constancy of angular momentum. \partmarks{6}
+ \part Constancy of total energy. \partmarks{8}
+
+How many integrals of motion exist in total?
+\partmarks{2}
+
+Derive the moment of inertia of the system and demonstrate its
+relevance to criteria for escape of particles from the system.
+\partmarks{6}
+\end{question}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/dynamical3.tex b/macros/latex/contrib/exam-n/sample/dynamical3.tex
new file mode 100644
index 0000000000..abc51017ea
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/dynamical3.tex
@@ -0,0 +1,59 @@
+\documentclass[compose]{exam-n}
+\begin{document}
+
+\begin{question}{30} \comment{by Declan Diver}
+For a system of $N$ objects, each having mass $m_i$ and position
+vector $\mathbf{R}_i$ with respect to a fixed co-ordinate system,
+use the moment of inertia
+\[
+I=\sum_{i=1}^N m_i R_i^2
+\]
+to deduce the virial theorem in the forms
+\[
+\ddot{I}=4E_k+2E_G=2E_k+2E
+\]
+where $E_k$ and $E_G$ are respectively the total kinetic and
+gravitational potential energy, and $E$ is the total energy of
+the system.
+\partmarks{8}
+
+Given the inequality
+\ifbigfont
+ \begin{multline*}
+ \left(\sum_{i=1}^N
+ a_i^2\right) \left(\sum_{i=1}^N b_i^2\right) \\
+\ge \left(\sum_{i=1}^N \mathbf{a}_i\cdot\mathbf{b}_i\right)^2 \\
++ \left(\sum_{i=1}^N \mathbf{a}_i\times\mathbf{b}_i\right)^2
+ \end{multline*}
+\else
+ \begin{equation*}
+ \left(\sum_{i=1}^N
+ a_i^2\right) \left(\sum_{i=1}^N b_i^2\right) \ge \left(\sum_{i=1}^N
+ \mathbf{a}_i\cdot\mathbf{b}_i\right)^2 + \left(\sum_{i=1}^N
+ \mathbf{a}_i\times\mathbf{b}_i\right)^2
+ \end{equation*}
+\fi
+for arbitrary vectors $\mathbf{a}_i$, $\mathbf{b}_i$,
+$i=1,\ldots,N$, deduce the following relationship for the $N$-body
+system
+\begin{equation*}
+\frac{1}{4}\dot{I}^2+J^2\le 2IE_k,
+\end{equation*}
+where $\mathbf{J}$ is the total angular momentum of the system.
+\partmarks{8}
+
+Assuming the system is isolated, use the virial theorem to deduce
+further the generalised Sundman inequality
+\begin{equation*}
+\frac{\dot{\sigma}}{\dot{\rho}}\ge 0,
+\end{equation*}
+in which $\rho^2=I$ and
+$\displaystyle\sigma=\rho\dot{\rho}^2+\frac{J^2}{\rho}-2\rho E $.
+\partmarks{8}
+
+Why does this inequality preclude the possibility of an
+$N$-fold collision for a system with finite angular momentum?
+\partmarks{6}
+
+\end{question}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/excos1.tex b/macros/latex/contrib/exam-n/sample/excos1.tex
new file mode 100644
index 0000000000..511902dc1a
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/excos1.tex
@@ -0,0 +1,46 @@
+\documentclass[compose]{exam-n}
+
+\multiplechoiceanswers{4}
+
+\begin{document}
+
+\begin{mcq}
+In 1908, where was there an airburst `impact'?
+\answer Tunguska
+\item Arizona
+\item Off the Mexican coast
+\item Swindon
+\begin{solution}
+The evidence for this is a dirty big hole in the ground in Siberia.
+\end{solution}
+\end{mcq}
+
+\begin{mcq}
+The fossil record suggests that mass extinction events occur once every how many years?
+\item 2.6 Billion Years
+\item 260 Million Years
+\item 26 Million Years % not marked as correct
+\item 4 Thousand Years after the dominant lifeform invents fire
+\end{mcq}
+
+\begin{mcq}
+The habitable zone of our Solar system extends over what distances from the Sun?
+\answer 0.6--1.5 AU
+\item 6--15 AU
+\item 60--150 AU
+\item 600--1500 AU
+% excess item, and a second \answer...
+\answer From the little bear's bed all the way through to daddy bear's
+ bed. This is known as the `Goldilocks zone'.
+\end{mcq}
+
+\begin{mcq}
+If the temperature of the Sun were to increase by 10\%, how would the
+position of the solar habitable zone change?
+\item It would move closer to the Sun.
+\answer It would move further from the Sun.
+\item It would move to Stornoway.
+%\item There would no longer be a habitable zone.
+\end{mcq}
+
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/fig/spiral.eps b/macros/latex/contrib/exam-n/sample/fig/spiral.eps
new file mode 100644
index 0000000000..fcf91bb97d
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/fig/spiral.eps
@@ -0,0 +1,22 @@
+%!PS-Adobe-3.0 EPSF-3.0
+% Shrinking squares, cgl Feb 97
+% Adapted from http://www.ntg.nl/maps/pdf/19_12.pdf
+% this version...
+%%Creator: norman@astro.gla.ac.uk
+%%BoundingBox: 0 0 200 125
+/b 0.6180339887 def % (\sqrt5-1)/2
+/x 200 def
+/y x b mul def
+/square {
+ 0 y lineto y y lineto y 0 lineto
+ y 0 y 180 90 arcn y y translate
+} def
+0.35 setlinewidth
+16 {
+ 0 0 moveto square -90 rotate
+ /x y def /y x b mul def
+} repeat
+stroke
+
+%showpage
+
diff --git a/macros/latex/contrib/exam-n/sample/fig/spiral.pdf b/macros/latex/contrib/exam-n/sample/fig/spiral.pdf
new file mode 100644
index 0000000000..0119b77d38
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/fig/spiral.pdf
Binary files differ
diff --git a/macros/latex/contrib/exam-n/sample/numerical1-solution.tex b/macros/latex/contrib/exam-n/sample/numerical1-solution.tex
new file mode 100644
index 0000000000..b8862899a1
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/numerical1-solution.tex
@@ -0,0 +1,21 @@
+\documentclass{article}
+\usepackage{color}
+\begin{document}
+\color{red}
+\noindent This page and the following two should appear on separate pages (as
+opposed to superimposed on each other), and disappear when the
+noshowsolutions option is present.
+
+(In the real situation, the corresponding PDF would be a scan of a hand-written
+solution.)
+
+\fontsize{72}{72}\selectfont
+\centering
+Numerical 1 solution, page one
+\newpage
+\null\vskip\baselineskip
+Numerical 1 solution, page two
+\newpage
+\null\vskip2\baselineskip
+Numerical 1 solution, page three
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/numerical1.tex b/macros/latex/contrib/exam-n/sample/numerical1.tex
new file mode 100644
index 0000000000..98157ebf68
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/numerical1.tex
@@ -0,0 +1,58 @@
+\documentclass[compose]{exam-n}
+\begin{document}
+
+\begin{question}{20} \author{Graham Woan}
+
+\part The recently-launched \emph{Swift} Gamma Ray Burst telescope is
+expected to detect about 200 bursts of gamma rays during its
+2-year lifespan. Explain why the Poisson distribution,
+\begin{equation*}
+P(n|\lambda)=\exp(-\lambda)\lambda^n /n!
+\end{equation*}
+is appropriate to describe the probability of detecting $n$
+bursts, and carefully explain the significance of the parameter
+$\lambda$. Table~\ref{t:excess} has absolutely nothing to do with
+this question, and its presence here is proof positive of the existence of
+aliens who wish to do us typographical harm.\partmarks{4}
+
+% This table is here to check that the table in the _solution_ to the
+% previous question doesn't cause the table counter to be
+% incremented. This should be Table 2, whether or not solutions are
+% being shown.
+\begin{table}
+\begin{centering}
+\begin{tabular}{r|l}
+\hline
+left&right\\
+\hline
+\end{tabular}
+\caption{\label{t:excess}This is a table}
+\end{centering}
+\end{table}
+
+Given the above, estimate the probability that \emph{Swift} will
+detect more than three bursts on any particular calendar day.
+% Fill up the line, so that we check that (default) \partmarks doesn't
+% include \@partmarksspace, since (default) \partmarks is now fully in
+% the margin.
+Blah. Blah. Blaah. Fill the line.\partmarks{6}
+
+\part Explain how Bayesian inference uses the observed number of
+bursts to infer the true burst rate at the sensitivity limit of
+\emph{Swift}, and explain the significance of the posterior
+probability distribution for $\lambda$. \partmarks{5}
+\begin{solution}
+\includepdf[pages=-]{numerical1-solution.pdf}
+\end{solution}
+
+Assuming that the posterior, $p$, for $\lambda$ can be
+approximated as a gaussian, show that, quite generally, the
+uncertainty in $\lambda$ inferred from \emph{Swift} will be
+\begin{equation*}
+\sigma \simeq \left( -\frac{\partial^2\ln p}{\partial
+\lambda^2}\Big|_{\lambda_0} \right)^{-1/2},
+\end{equation*}
+where $\lambda_0$ is the most probable value of $\lambda$.
+\partmarks{5}
+\end{question}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/numerical2.tex b/macros/latex/contrib/exam-n/sample/numerical2.tex
new file mode 100644
index 0000000000..0843f1bc6e
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/numerical2.tex
@@ -0,0 +1,44 @@
+\documentclass[compose]{exam-n}
+\begin{document}
+
+\begin{question}{30} \comment{by Graham Woan}
+Two variables, $A$ and $B$, have a joint Gaussian probability
+distribution function (pdf) with a negative correlation
+coefficient. Sketch the form of this function as a contour plot
+in the $AB$ plane, and use it to distinguish between the most
+probable joint values of $(A,B)$ and the most probable value of
+$A$ given (a different) $B$. \partmarks{5}
+
+\label{q:numerical2}
+Note that this is question \ref{q:numerical2} on p.\pageref{q:numerical2}.
+
+Explain what is meant by \emph{marginalisation} in Bayesian
+inference and how it can be interpreted in terms the above plot.
+\partmarks{5}
+
+Doppler observations of stars with extrasolar planets give us data
+on $m\sin i$ of the planet, where $m$ is the planet's mass and
+$i$ the angle between the normal to the planetary orbit and the
+line of sight to Earth (i.e. the orbital inclination), which can
+take a value between 0 and $\pi/2$ .
+
+Assuming that planets can orbit stars in any plane, show that the
+probability distribution for $i$ is $p(i) = \sin i$.
+\partmarks{5}
+
+A paper reports a value for $m\sin i$ of $x$, subject to a Gaussian
+error of variance $\sigma^2$. Assuming the mass has a uniform
+prior, show that the posterior probability distribution for the mass
+of the planet is
+\begin{equation*}
+p(m|x)\propto\int_0^1\exp\left[-\frac{\left(x-m\sqrt{1-\mu^2}\right)^2}{2\sigma^2}\right]
+\ddd \mu,
+\end{equation*}
+where $\mu=\cos i$.
+\partmarks{9}
+
+Determine the corresponding expression for the posterior pdf of
+$\mu$, and explain how both are normalised.
+\partmarks{6}
+\end{question}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/numerical3.tex b/macros/latex/contrib/exam-n/sample/numerical3.tex
new file mode 100644
index 0000000000..2354c5db6f
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/numerical3.tex
@@ -0,0 +1,46 @@
+\documentclass[compose]{exam-n}
+\begin{document}
+
+\begin{question}{30} \comment{by Graham Woan}
+Distinguish between frequentist and Bayesian definitions of
+probability, and explain carefully how parameter estimation is
+performed in each regime.\partmarks{10}
+
+\label{q:numerical3}
+Note that this is question \ref{q:numerical3} on
+p.\pageref{q:numerical3}. It's the one after question~\ref{q:numerical2}.
+
+A square ccd with $M\times M$ pixels takes a dark frame for
+calibration purposes, registering a small number of electrons in
+each pixel from thermal noise. The probability of there being $n_i$
+electrons in the $i$th pixel follows a Poisson distribution, i.e.
+\begin{equation*}
+ P(n_i|\lambda) = \exp(-\lambda)\lambda^{n_i}/n_i!,
+\end{equation*}
+where $\lambda$ is the same constant for all pixels. Show that the
+expectation value of is $\langle n_i \rangle = \lambda$.
+\partmarks{5} [You may assume the relation $\sum_0^\infty \frac{x^n}{n!}=\exp(x)$.]
+
+Show similarly that
+\begin{equation*}
+ \langle n_i(n_i-1) \rangle = \lambda^2.
+\end{equation*}
+and hence, or otherwise, that the variance of $n_i$ is also
+$\lambda$.
+\partmarks{5}
+
+The pixels values are summed in columns. Show that these sums,
+$S_j$, will be drawn from a parent probability distribution that is
+approximately
+\begin{equation*} p(S_j|\lambda)=\frac{1}{\sqrt{2\pi
+M\lambda}}\exp\left[-\frac{(S_j-M\lambda)^2}{2M\lambda}\right],
+\end{equation*}
+clearly stating any theorems you use.
+\partmarks{5}
+
+Given the set of $M$ values $\{S_j\}$, and interpreting the above
+as a Bayesian likelihood, express the posterior probability for
+$\lambda$, justifying any assumptions you make.
+\partmarks{5}
+\end{question}
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/sample_exam.tex b/macros/latex/contrib/exam-n/sample/sample_exam.tex
new file mode 100644
index 0000000000..98031e6091
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/sample_exam.tex
@@ -0,0 +1,65 @@
+\documentclass{exam-n}
+%\documentclass[largefont]{exam-n}
+%\documentclass[hugefont,sansserif]{exam-n}
+%\documentclass[mtpro2,showsolutions]{exam-n}
+%\documentclass[mtpro2,showsolutions,sansserif]{exam-n}
+%\documentclass[draft,showsolutions,sansserif]{exam-n}
+
+% Note: this sample question dates from an earlier phase, in which
+% `paper n' would contain a bundle of questions from various courses.
+% That's why the \coursetitle doesn't match the broad range of
+% subjects being 'examined'.
+%
+% Several of the questions are gibberish.
+%
+% This collection of questions has in part turned into an informal
+% regression test for the class file.
+
+\examdate{Wednesday, 23 May 2007}
+\examtime{9:30 -- 10:45 (1 course)\\9:30 -- 12:00 (2 courses)}
+
+\exambanner{Examination for the degrees of \BSc\,
+ \MSci\ and \MA\ on the honours standard }
+
+\degreedescriptions{Physics 3\\Chemical Physics 3\\Physics with
+ Astrophysics 3\\Theoretical Physics 3M\\Joint Physics 3}
+\schoolcoursecode{P304D and P304H}
+\universitycoursecode{PHYS3031 and PHYS4025}
+\coursetitle{Quantum Mechanics}
+
+\usepackage{pdfpages}
+
+\rubric{Candidates should answer Questions 1 and 2 (10~marks each),
+ \linebreak\textbf{and either} Question 3 \textbf{or} Question 4 (30~marks).
+ \linebreak The content of this sample exam derives from real
+ questions, but the result is in many cases test gibberish.}
+%\norubric
+
+\numquestions{13}
+
+\usepackage{graphicx} % for graphic in dynamical1
+
+\begin{document}
+\maketitle
+
+\section{I}
+\includequestion{cosmo1}
+\includequestion{numerical1}
+\includequestion{dynamical1}
+
+\section{II}
+\includequestion{cosmo2}
+\subsection{Cosmology question number 3}
+\includequestion{cosmo3}
+\includequestion{excos1} % four multiple-choice questions
+
+\section{III}
+% Override the question number, to test/demo this
+\includequestion[99]{numerical2}
+\includequestion{numerical3}
+
+\section{IV}
+\includequestion{dynamical2}
+\includequestion{dynamical3}
+
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/sample_exam_solution.tex b/macros/latex/contrib/exam-n/sample/sample_exam_solution.tex
new file mode 100644
index 0000000000..853bccbce9
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/sample_exam_solution.tex
@@ -0,0 +1,65 @@
+\documentclass[showsolutions]{exam-n}
+%\documentclass[largefont]{exam-n}
+%\documentclass[hugefont,sansserif]{exam-n}
+%\documentclass[mtpro2,showsolutions]{exam-n}
+%\documentclass[mtpro2,showsolutions,sansserif]{exam-n}
+%\documentclass[draft,showsolutions,sansserif]{exam-n}
+
+% Note: this sample question dates from an earlier phase, in which
+% `paper n' would contain a bundle of questions from various courses.
+% That's why the \coursetitle doesn't match the broad range of
+% subjects being 'examined'.
+%
+% Several of the questions are gibberish.
+%
+% This collection of questions has in part turned into an informal
+% regression test for the class file.
+
+\examdate{Wednesday, 23 May 2007}
+\examtime{9:30 -- 10:45 (1 course)\\9:30 -- 12:00 (2 courses)}
+
+\exambanner{Examination for the degrees of \BSc\,
+ \MSci\ and \MA\ on the honours standard }
+
+\degreedescriptions{Physics 3\\Chemical Physics 3\\Physics with
+ Astrophysics 3\\Theoretical Physics 3M\\Joint Physics 3}
+\schoolcoursecode{P304D and P304H}
+\universitycoursecode{PHYS3031 and PHYS4025}
+\coursetitle{Quantum Mechanics}
+
+\usepackage{pdfpages}
+
+\rubric{Candidates should answer Questions 1 and 2 (10~marks each),
+ \linebreak\textbf{and either} Question 3 \textbf{or} Question 4 (30~marks).
+ \linebreak The content of this sample exam derives from real
+ questions, but the result is in many cases test gibberish.}
+%\norubric
+
+\numquestions{13}
+
+\usepackage{graphicx} % for graphic in dynamical1
+
+\begin{document}
+\maketitle
+
+\section{I}
+\includequestion{cosmo1}
+\includequestion{numerical1}
+\includequestion{dynamical1}
+
+\section{II}
+\includequestion{cosmo2}
+\subsection{Cosmology question number 3}
+\includequestion{cosmo3}
+\includequestion{excos1} % four multiple-choice questions
+
+\section{III}
+% Override the question number, to test/demo this
+\includequestion[99]{numerical2}
+\includequestion{numerical3}
+
+\section{IV}
+\includequestion{dynamical2}
+\includequestion{dynamical3}
+
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample/sample_mcq.tex b/macros/latex/contrib/exam-n/sample/sample_mcq.tex
new file mode 100644
index 0000000000..268417ff7d
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample/sample_mcq.tex
@@ -0,0 +1,87 @@
+\documentclass[draft]{exam-n}
+
+\examdate{Today}
+\examtime{Now! -- \emph{you're late!}}
+
+\exambanner{Multiple-choice exam}
+
+\degreedescriptions{Various degrees}
+\schoolcoursecode{MCQ123}
+\universitycoursecode{AssDes101}
+\coursetitle{Assessment Design Strategies}
+
+\rubric{Candidates should choose answers randomly where they feel
+ unable to speculate wildly.}
+
+\multiplechoiceanswers{4}
+
+\begin{document}
+\maketitle
+
+\begin{mcq}
+Which is the first answer in this list?
+\answer Answer one
+\item Answer two
+\item Answer three
+\item Answer four
+\end{mcq}
+
+\begin{mcq}
+How many answers are in this list?
+\item one
+\item two
+\item three
+\answer four
+\end{mcq}
+
+\begin{mcq}
+Which is the incorrect answer in this list?
+\item Correct answer
+\item Another correct answer
+\answer The wrong answer
+\item A final correct answer
+\end{mcq}
+
+\begin{mcq}
+What is the nature of existence?
+\item All good things come to those who wait
+\item The universe makes sense
+\answer Error is inevitable
+\item Om
+\end{mcq}
+
+\begin{mcq}
+How many roads must a man walk down?
+\item Three
+\answer Oooh, I wouldn't walk down there -- it's terribly windy.
+\item Can I introduce you to the notion of the tuning fork?
+\item Third left, then second right, and the nature of existence is
+ available from the leprechaun in the little lane just after the bend
+ in the road.
+\end{mcq}
+
+\begin{mcq}
+How many questions are there in this test?
+\item Six
+\answer Eight
+\item Ten
+\item Twelve
+\end{mcq}
+
+\begin{mcq}
+Is this a reasonable question?
+\item no
+\item yes
+\item is this an answer?
+\answer if you say so
+\end{mcq}
+
+\begin{mcq}
+What is the most important thing about examinations?
+\item They are an accurate measure of understanding
+\item They are repeatable and reliable
+\answer They are nicely formatted
+\item They are stress-free occasions which everyone enjoys.
+\end{mcq}
+
+\end{document}
diff --git a/macros/latex/contrib/exam-n/sample_exam.pdf b/macros/latex/contrib/exam-n/sample_exam.pdf
new file mode 100644
index 0000000000..db389f7e34
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample_exam.pdf
Binary files differ
diff --git a/macros/latex/contrib/exam-n/sample_exam_solution.pdf b/macros/latex/contrib/exam-n/sample_exam_solution.pdf
new file mode 100644
index 0000000000..994205d6e9
--- /dev/null
+++ b/macros/latex/contrib/exam-n/sample_exam_solution.pdf
Binary files differ
diff --git a/macros/latex/contrib/exam-n/style.css b/macros/latex/contrib/exam-n/style.css
new file mode 100644
index 0000000000..c7be40749a
--- /dev/null
+++ b/macros/latex/contrib/exam-n/style.css
@@ -0,0 +1,230 @@
+body {
+ color: #333;
+ background: white;
+ margin-left: +30%;
+ width: 50%; /* body is 50% of screen width */
+ margin-right: auto; /* ie, 20% */
+ padding: 0.5em; /* this will make a difference if I decide to
+ have the background a different colour */
+ /* I can't decide on font: Optima's always nice, but Gill looks
+ agreeably intense. Helvetica's a decent fallback. */
+ font-family: "Helvetica Neue", Helvetica, "Gill Sans", gill, sans-serif;
+ /* font-family: Optima, "Gill Sans", gill, Helvetica, sans-serif; */
+ /* font-family: "Gill Sans", gill, Helvetica, sans-serif; */
+ /* I seem to have used 11pt at some point in the past, but this
+ is far too big -- did I ever have a reason for that, or is it
+ just due to browser changes? */
+ font-size: 10pt;
+ line-height: 150%;
+}
+
+div.topsidebar {
+ float: right;
+ width: 50%; /* ...of the body width (ie, 50% x 50% of screen) */
+ font-size: smaller;
+ margin-left: 1em;
+ padding-left: 1em;
+ border-left: solid thin #AAA;
+}
+
+/* On wider screens, move the sidebar out to the right hand side */
+/* This uses CSS3 media queries: http://www.w3.org/TR/css3-mediaqueries/ */
+@media screen and (min-width: 700pt) and (max-width: 850pt) {
+ body {
+ margin-left: 210pt;
+ width: 350pt; /* 50% of 700pt */
+ margin-right: auto;
+ }
+ div.topsidebar {
+ position: absolute;
+ /* I feel this size should be 595pt (350 + 210 + 0.05*700),
+ but that's clearly not right -- I don't think I understand what the -5%
+ in the h1 spec below is actually 5% of! */
+ left: 570pt;
+ width: auto;
+ margin-left: 0pt;
+ padding-left: 0pt;
+ border: none;
+ }
+}
+/* On still-wider screens, expand the left-margin, keeping the sidebar attached to the right-hand edge.
+ When the screen is 850pt wide (expanding from the @media case above),
+ the left margin will be 210pt, the width 350pt, and the right margin therefore 290pt.*/
+@media screen and (min-width: 850pt) {
+ body {
+ margin-right: 290pt; /* 290 = 850-(210+350) */
+ width: 350pt;
+ margin-left: auto; /* ...takes up the slack */
+ }
+ div.topsidebar {
+ position: absolute;
+ width: 290pt; /* same 290pt as above */
+ left: auto;
+ right: 0%;
+ padding-left: 0pt;
+ border: none;
+ }
+}
+
+
+code, pre {
+ font-family: Monaco, fixed;
+ font-size: 9pt;
+}
+
+a { text-decoration: none; }
+a:link { color: #66C; }
+a:visited { color: #669; }
+a[href]:hover { background: #EEE; }
+
+div.abstract {
+ font-style: oblique;
+ text-align: left;
+}
+div.abstract em { font-style: normal; }
+div.abstract code {
+ font-style: normal;
+ font-size: 80%;
+}
+
+/* a span/div style for attracting attention */
+.attention {
+ color: #822;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ color: #822;
+ font-weight: 100; /* few fonts have ultra-light weights */
+ line-height: 100%; /* no need to spread out titles */
+}
+h1 {
+ margin-left: -40%;
+ margin-right: -5%;
+ padding: 0.5em;
+ border: solid thin #666;
+ text-align: right;
+}
+h2 {
+ margin-left: -40%;
+ margin-right: -5%;
+ padding: 0.2em;
+ border-top: solid thin #666;
+ clear: both;
+}
+
+h2.appendices {
+ margin-top: 10ex;
+ border-top: double medium #666;
+}
+h3 {
+ margin-left: -30%;
+ float: left;
+ width: 25%;
+ display: block;
+ text-align: right;
+ vertical-align: bottom;
+ padding-top: 0pt;
+ padding-right: 0.5em;
+ margin-top: 0pt;
+ line-height: 100%;
+}
+
+/*
+h4 {
+ color: #C66;
+}
+*/
+
+pre, table { background: #dde; }
+
+pre {
+ padding: 1em;
+ line-height: 130%;
+}
+
+table {
+ font-size: smaller;
+}
+td {
+ padding: 0.5ex;
+}
+
+Q:before { content: "“"; }
+Q:after { content: "”"; }
+
+img.smallimage {
+ float: right;
+ margin: 24pt;
+ margin-right: -30%;
+}
+
+div.signature {
+ margin-left: -40%;
+ margin-right: -5%;
+ margin-top: 4ex;
+ text-align: right;
+ border: solid thin #666;
+ padding: 0.3em;
+ clear: both;
+}
+
+/* ============================================================
+ * Some other curiosities of my one-time formatting for web pages
+ */
+.doc-history {
+ font-size: xx-small;
+ background: #eee;
+ line-height: 100%;
+}
+
+div.subtoc, div.subsubtoc { display: none; }
+
+/* ============================================================
+ * Special formatting for ToC
+ */
+
+/*
+ If there's significant amount of text in front of the first subsection,
+ then the following are good to put in the per-document stylesheet:
+ width: 25%;
+ float: right;
+*/
+div#toc {
+ color: #888;
+ padding: 0;
+ font-size: smaller;
+ text-align: right;
+}
+div#toc a:link { color: #888; }
+div#toc > ul {
+ padding: 0pt;
+ margin: 0pt;
+ list-style: none;
+}
+div#toc li {
+ padding: 0pt;
+ display: inline-block;
+}
+div#toc li:before {
+ content: "§ ";
+ margin-left: 1em;
+}
+/* the following elements aren't currently generated by structure.lx */
+div#toc li ul {
+ padding-left: 1em;
+ margin-left: 0;
+ font-style: italic;
+ display: inline;
+}
+div#toc li ul:before {
+ content: "( ";
+}
+div#toc li ul:after {
+ content: " ) ";
+}
+div#toc li li {
+ padding-left: 0pt;
+}
+div#toc li li:after {
+ content: "; ";
+}