EXAM, A L^{A}TEX 2ε CLASS FOR EXAMINATION PAPERS

SIMON EVESON

Introduction

exam.cls is a L^{A}TEX 2ε class file for producing examination papers. It provides an automatically-numbered question environment, which does not allow questions to be broken across pages without specific instructions from the user, and an optional solution environment if you want to type solutions into the same file. The front page, with the examination’s title, module number, duration and rubric is automatically set in the approved format and page footers like turn over and continued on next page are automatically generated. If you wish, you can add a marking scheme to the solutions and the system will total the marks for each question.

Installation

The current version of exam.cls and some supporting files are available from

http://www-users.york.ac.uk~spe1/examclass/

You should put the class file examclass.cls either in the same directory (folder) as the document you are working on, or in a global inputs directory. If you use the networked version of TEX, you can use

~/tex/inputs under Unix or h:\texmf\tex\latex\ under Windows

(note that there is another file called exam.cls which ships with current versions of L^{A}TEX, and it is important to put the local class ahead of this in the search order).

The file examsamp.tex is a complete examination paper, including solutions, produced in exam class. Take a look at it to see the way the system works, or use its skeleton as the basis for your own file.

Class Declaration

exam is a L^{A}TEX 2ε class file, so your document should begin

\documentclass{exam}

By default, this class uses 12pt type on A4 paper and produces output suitable for double-sided duplication. There should be no need to change this, but you can if required: any option understood by the standard article class is also understood by exam.

Date: March 2002.

Packages

The exam class automatically loads the AMS packages amsmath, amsfonts and the extended vaerbatim environments from verbatim.

Any other packages required can be loaded with a \usepackage{} declaration, as usual.

Topmatter

Unlike most classes, topmatter is mandatory in the exam class. After the \begin{document} command, you must specify the paper’s title, number, duration and year and provide a rubric. When specifying the duration, the macro \half is provided as a convenient way to produce \frac{1}{2}. For example,

\codenumber{12345}
\year{1996}
\title{Functional Analysis Sample Paper}
\duration{$1\half$ hours}
\begin{rubric}
  Answer not more than \underline{three} questions. \\
  Calculators may be used but should be unnecessary.
\end{rubric}
\maketitle

Note the \maketitle command, which actually prints the topmatter. In the rubric environment, indicate line breaks with \\ where required. The rubric is printed in flush left italic type.

By default, the paper is headed ‘BA, BSc and MMath Examinations.’ To change this (for type III or IV third year courses, fourth year courses and masters courses), use some combination of the macros

\babscfalse, \mmathfalse, \msctrue and \mrestrue. The synonyms
\MMathfalse, \BABScfalse, MSctrue and MRestrue are available for

those who like Capital Letters. The opposite switches are also available, e.g. babsctrue, but you’re unlikely to want them.

If the paper is a resit paper, put \resittrue in the topmatter. This insert the word ‘Resit’ before ‘Examinations’ in the heading. You should also prefix the module number with R, e.g. R12345.

The rubric environment can contain most L^{A}TEX constructs. The only exceptions are those relating to page layout: you cannot use footnotes or marginal notes and you cannot split the rubric across a page.

The other topmatter commands can contain any L^{A}TEX macros you need, but for L^{A}TEXnical reasons cannot contain environments. I can’t imagine this being a problem, but let me know if it is.

Questions

Questions are entered in the question environment. For example,

\begin{question}
  Show that $1/n\to 0$ as $n\to\infty$.
\end{question}

You can put any L^{A}TEX instructions you like inside the question environment, except those relating to page breaking. In practice, this means that you should not attempt to use \newpage, \pagebreak or

\clearpage inside a question, but use the \questionbreak macro

described below. Unlike earlier versions of exam.cls, footnotes and marginal notes will now work within questions. Whether one would ever want to use such things in a question is, of course, another matter.

As you would expect from L^{A}TEX, questions are automatically numbered. If you want separate parts within a question, use the enumerate environment as usual. Parts will be numbered (a), (b), (c), …. Secondlevel enumerated lists (i.e. an enumerate environment inside another enumerate environment) have items numbered (i), (ii), (iii), …. (see ‘Tweaking Things’ below if you want your first order lists to be roman and your second-order lists to be alphabetic). I haven’t specified the numbering of any higher-level enumerations: if you really need one, let me know and I can add it.

Questions are never broken across pages without specific instructions. If you need to break a question (typically because it is too long to fit on a single page even on its own), you can put a \questionbreak command where you want the break to occur. The break occurs exactly at this point, so you should normally put it between paragraphs or between a paragraph and a displayed equation: if you put a \questionbreak command inside a paragraph, the last line on the page will not be justified.

If you want to force a page break in between questions, as opposed to inside a question, use \pagebreak or \newpage in the usual way; for example

\end{question}
\pagebreak
\begin{question}

The reason for the separate commands is that a pagebreak inside a question prints ‘x Cont.’ on the next page, where x is the page number (earlier versions also did a good deal of housekeeping to do with the continued on next page footers and continued from previous page headers, but this is now fully handled by the page style).

Parts

If the paper contains multiple parts, begin each one with the \part command, e.g. \part{Hilbert Spaces.}. This prints a bold heading on the lines of Part A. Hilbert Spaces. Note that \part does not cause a pagebreak. Use \newpage or \pagebreak before the \nextpart command (but after the preceding \end{question}) if you want your section to start on a new page. For backward compatibility, the \nextpart command is a synonym for \part{}.

If you are writing just one part of the paper and want to generate the correct heading without earlier parts being present, you can use \skippart. For example, to put a heading Part B. at the top of the

paper, begin with \skippart\nextpart. The \skippart macro can

take an optional argument: to skip two parts, use \skippart[2] (note square brackets; \skippart{2} does not work).

If you use \skippart, you probably also need to use \skipquestion and possibly \skipsolution, which step the question and solution counters. Like \skippart, they default to skipping one question, but take an optional argument to skip more.

For example, if parts A and B have three questions each and you are just writing part C, you might begin (imediately after \begin{document}) with

\skippart[2]
\skipquestion[6]

and, if you are typing solutions (see next section),

\skipsolution[6]

between the last question and first solution.

Solutions

You can (if you want to) put solutions into the same document as the questions, using the solution environment. You can put anything you like inside a solution environment, including footnotes and marginal notes. Solutions are subject to L^{A}TEX’s normal page-breaking algorithm: there is no \questionbreak or similar command.

One extra environment and one extra command are provided for convenience in typing solutions. The remarks environment, intended for remarks to the checker or external examiner, typesets its contents as a separate paragraph, in italics, with a bold heading Remarks. For example,

\begin{remarks}
  This question lifted verbatim from last year's paper.
\end{remarks}

produces Remarks. This question lifted verbatim from last year’s paper.

The \marks{n} command prints ‘n Marks.’ in a framed, rightaligned box. For example, \marks{5} produces 5 Marks. If there is not enough room on the current line, a new line will be created (blank except for the number of marks). The \marks{} command can be used inside displayed mathematics, in which case it puts the number of marks where the equation number would normally go (so don’t use it in combination with equation numbers!) For example,

$$\sum_{n=1}^\infty\frac{1}{n^2}=\frac{\pi^2}{6}\marks{5}$$

produces

∑_{n=1}^{∞} \frac{1}{n^{2}} = \frac{π^{2}}{6}  5 Marks

If you use any \marks{} commands in a question or solution, the total is printed at the end of the solution.

To supress the printing of marks and remarks, put the command \nomarks in your preamble. This might be useful if you want to distribute solutions to last year’s paper, but not distribute the marking scheme or any comments to the external examiner.

To entirely suppress the printing of solutions (when you print the final copy for duplication, for example) put the command \nosolutions in your preamble.

Note that you cannot intersperse questions and solutions: you must have all of the questions in order, followed by all of the solutions in order. I might be able to allow them to be interspersed, if anyone really desperately wants it, but it won’t be easy.

If you don’t want to type solutions, there is no need to: the solution environments are entirely optional.

Tweaking things

There are a few tweakable parameters in the system.

By default, the enumerate environment numbers its items (a), (b), (c), … and second-level enumerations are numbered (i), (ii), (iii), …. To swap these, so first-level enumerations are numbered in roman and second-level in alphabetic, put the command \romantrue in the document preamble.

There are five lengths you can change. Recall that (approximately) 1ex is the height of a lowercase ‘x’ in the current font and 1em is the width of a capital ‘M.’

(1) \qksip is the vertical space left between questions (default 4ex).

(2) \qindent is the distance from the left margin of the paper and the left margin of the question (default 3em). It must be at least wide enough to contain the question number and the word cont.

(3) \qlabelsep is the space between the label and the item in secondary list environments (e.g. enumerate, itemize and description).

Default is currently 1em, which is quite wide; I might reduce this at some point.

(4) \qparindent is the extra paragraph indentation used inside a question (default 0pt).

(5) \qparskip is the space between paragraphs inside a question (default 1ex).

Note that \footheight is no longer available (did anyone ever use it?). Use the standard L^{A}TEX 2ε length \footskip instead (default length 6ex in this class).

You can change these using \setlength in the preamble of your document (that is, between the \documentclass declaration and the \begin{document}). For example, the default values are generated by

\setlength{\qindent}{4em}
\setlength{\qlabelsep}{1em}
\setlength{\qskip}{4ex}
\setlength{\qparindent}{0pt}
\setlength{\qparskip}{1ex}

Note that the usual approach of changing \parindent and \parskip will not affect the layout of paragraphs within a question, but will wreak havoc on the layout of questions within the paper. Use \qparindent and \qparskip instead.

Security

There are obvious security implications in keeping examination-related material on networked file systems. The best solution is simply not to do this: use your own local hard disk, or a floppy disk.

If you really must keep material like this on the network, the minimum level of security is to make the files and the directory containing them accessible only to you. To do this, at the Unix shell prompt or DOS prompt type

chmod go-rx <name>

where <name> is the name of the file or directory to protect. You can use wildcards: e.g. * under Unix or *.* under DOS to mean ‘all files in the current directory.’ It is especially important to protect the directory containing the files, since the protection on the .dvi and .ps files produced by TEX and dvips is somewhat hard to predict.

It is also possible to encrypt files, which is probably the best security of all. Unfortunately this is not really practical when it comes to TEX since one would need to encrypt the TEX source, the .dvi file and the PostScript file. See the manual entry for crypt on the Unix systems, or the MicroEMACS documentation for its CRYPT mode.

Bugs, Problems, Limitations

This class does some fairly complicated stuff with page headers and footers and with TEX penalties. Although I think it all works OK, there might well be bugs lurking which I haven’t spotted. Some limitations have been pointed out above; let me know if they cause any major problems and I’ll try to fix them.

I haven’t really attempted to make the class entirely bomb-proof: there are some things which you can do which will upset it in a big way, such as making a \pagestyle or \thispagestyle declaration, using any sectioning commands other than \part, using a third level of enumeration, using \pagebreak, etc. Be gentle!

Changes made 27/4/2004

Rewrote the page header and footer mechanism using \mark to make the header and footer changes associated with \questionbreak more robust.

Changes made 4/4/2004

Rewrote \marks{} so it works inside display math.

Changes made 1/3/2002

(1) Added \msctrue, \mrestrue and friends, completely rewriting the title generator in the process.

(2) Added \part macro for giving titles to parts.

Changes Made 25/1/2000

(1) Added \resittrue and \resitfalse to control use of ‘Examinations’ v. ‘Resit Examinations’ in header.

   (2) Added \MMathfalse, \BABScfalse, \MMathtrue and \BABSctrue

as synonyms of their uncapitalised forms.

Changes Made 10/12/98

  Commands \babscfalseand \babsctrue added to go with \mmathfalse
and \mmathtrue.

Changes Made 1/7/97

Minor enhancements (I hope):

(1) \nomarks command suppresses the printing of marks and totals, and also of the contents of remarks environments. This is intended for printing papers with solutions for the library, without revealing the marking scheme or any remarks to the external examiner.

(2) \nosolutions suppresses the contents of the solution environments. This is intended for printing the final copy for duplication.

Note that these commands are irreversible: you can’t switch the marking scheme back on again having switched it off with \nomarks. Note also that \marksfalse still works the way it used to, suppressing marks and totals but not remarks environments, but that \nomarks is now the preferred way to do this. I might withdraw \marksfalse at some point, as this would simplify the code.

Changes Made 3/3/97

(1) Page-breaking algorithm completely recoded so \questionbreak can be used anywhere you like, even within an item of a secondary or tertiary list.

(2) \marks now works, and also keeps track of totals for each question.

(3) There is now some space (\qlabelsep) between labels and items in labelled lists inside the solution environment. This also controls such spacing in the question environment, which was previously left at the article.cls default, so you might notice a slight difference in questions.

(4) The rubric environment is now much more flexible. You can put almost anything you like inside it, including labelled lists and aligned mathematics.