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

SIMON EVESON

1. Introduction

ymexam.cls is a L^{A}TEX 2ε class file for producing examination papers in the style required for the York Mathematics department. It replaces exam.cls which was in use up to academic year 2005/06; the name has changed partly because this version is very slightly incompatible with the older version, and partly because most L^{A}TEX intallations now come with an unrelated file called exam.cls.

The class provides:

• a front page, with the examination’s title, module number, duration and rubric, set in the approved format;

• a numbered question environment, which does not allow questions to be broken across pages without specific instructions from the user;

• automatic handling of page footers like turn over and continued on next page;

• facilities for displaying and totalling marking schemes;

• a numbered solution environment.

2. Installation

The current version of ymexam.cls, some supporting files and the old exam.cls are all available on the Department’s web-server: from Staff Home, go to Examinations, then LaTeX Class File for Examinations. The URL at time of writing is

http://maths.york.ac.uk/moodle/mod/book/view.php?id=25405&chapterid=470

You should put the class file ymexam.cls either in the same directory (folder) as the document you are working on, or in a global inputs directory. ^{1} The following places should work:

    central Unix: ~/texmf/tex/latex
    supported Windows: h:\texmf\tex\latex\
    other miktex installation: c:\localtexmf\tex\latex\

If you use Miktex, you’ll need to register the file’s existence. Click on Start, Run, type mo, press Return, select the Roots tab, click on the root corresponding to where you put ymexam.cls (e.g. h:\texmf or c:\localtexmf), click on Refresh FNDB, click on OK. If you want to use both central Unix and a Miktex installation in parallel, sharing a local tree, you can create a new root at m:\texmf.

Date: October 2009.

1If you’re using the old exam.cls, 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.

There are various sample files available; take a look at them to see the way the system works, or use one as the basis for your own file.

3. Class Declaration

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

\documentclass{ymexam}

By default, this class uses 12pt type on A4 paper and produces output suitable for doublesided duplication. There is rarely any need to change this, but any option understood by the extarticle class, and therefore any option understood by the standard article class, is also understood by ymexam. In particular, the font sizes 14pt, 17pt and 20pt can be used to make large-font copies for students with visual impairments (sizes other than 12pt should only be used in consultation with the University Examinations Office and Disability Support). ^{2}

4. Packages

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

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

5. Topmatter

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

%\resit
\codenumber{0500010}
\year{2006}
\title{Analysis I}
\duration{$1\half$ hours}
\begin{rubric}
  Answer \underline{all} parts of Question~1 and \underline{two}
  of the remaining three questions. \\
  Question~1 carries 40~marks; questions~2, 3~and~4 carry
  25~marks each. \\
  Standard calculators will be provided. \\
  The marking scheme shown on each question is indicative only.
\end{rubric}
\maketitle

2Prior to Summer 2009, ymexam’s base class was article, not extarticle, so the large font sizes were not available.

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 IV third year courses, fourth year courses and masters courses), use some combination of the

macros \BABSc, \noBABSc, \MMath, \noMMath, \MSc, noMSc, \MRes and \noMRes.^{3}

If the paper is a resit paper, put \resit at the beginning of the topmatter. This automatically inserts the word ‘Resit’ before ‘Examinations’ in the heading, and prefixes the module number with the letter R.^{4}

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.

As of October 2007, in accord with guidance from the Examinations Office, the class default is that nothing is printed on the first page except the topmatter. This can be changed (against University policy!) by using \questionfrontpage before the \maketitle command, in which case the first question goes on the front page (if it will fit without breaking; see the next section for information about page-breaks within questions).

6. 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. In the default layout, paragraphs are separated by some vertical space but not indented. If you want to change this, you need to change \qparskip and \qparindent; see Section 11. Do not change \parindent or \parskip.

As you would expect from L^{A}TEX, questions are automatically numbered. By default, the total number of questions is also presented: numbers look like “1 (of 4)”. The \noquestioncount command gives plain numbering. As with all L^{A}TEX cross-referencing, if the number of questions changes then L^{A}TEX will have to be run twice before the (of n) part of the question numbers is correct.

3There is an extensive array of synonyms for these for compatibility with existing documents; if it worked in an earier version, it still works now.

4For compatibility with existing documents, you can supply the R yourself, e.g. \codenumber{R0500010} will work correctly.

If you want separate parts within a question, use the enumerate environment as usual. Parts will be numbered (a), (b), (c), …. Second-level enumerated lists (i.e. an enumerate environment inside another enumerate environment) have items numbered (i), (ii), (iii), …. If you want your first order lists to be roman and your second-order lists to be alphabetic, enter \romanfirst; to revert to alphabetical first, enter \alphafirst. ^{5}

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 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 ‘Continued on next page’ and repeat the question number as ‘x Cont.’ on the next page.

7. Parts

If the paper contains multiple parts, begin each one with the \part command,^{6}. 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 one of the standard pagebreaking commands (e.g. \clearpage) before the \part{} command (but after the preceding \end{question}) if you want your section to start on a new page.

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. The Lebesgue Integral at the top of the paper, begin with

\skippart
\part{The Lebesgue Integral}

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 \skipsolution, which step the question and solution counters. Like \skippart, they default to skipping one question, but take an optional argument to skip more.

5Compatibility with existing documents: \romantrue and \romanfalse are synonyms for \romanfirst and \alphafirst.

6For compatibility with existing documents, \nextpart is a synonym for \part{}

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 between the last question and first solution

\skipsolution[6]

The \partinquestion command makes the part number appear within each question number, so questions might be numbered A1, A2, A3, B4, B5, etc. ^{7} If you use this, you probably want \noquestioncount as well, otherwise you’ll end up with numbers like “A1 (of 5).”

8. Solutions

You can 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

analogue of \questionbreak.

One extra environment is 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. You can suppress the printing of remarks by entering \noremarks and reinstate it with

\showremarks.

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.

9. Marks and Totals

In both the question and solution environments, you can use \marks{n} to indicate how many marks are assigned to part of the question. The number is printed flush right, and can be used either in text or inside displayed mathematics. In displayed mathematics (including the AMSL^{A}TEX primary environments such as align, gather and multline) the number of marks appears where the equation number would normally go, so don’t use it in combination with equation numbers! For example,

7The \numberwithinpart command causes the question number to reset to 1 at the beginning of each part, so the numbering sequence might be A1, A2, A3, B1, B2, B3, etc. This is best avoided: it only makes sense if \partinquestion is switched on, it’s incompatible with \questioncount and I think it’s against the University layout rules.

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

might produce (depending on the current style, see below)

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

If you don’t want the number of marks to be right-aligned, use \marks*{} instead; the format is the same, but the resulting box is set inline. There are some circumstances in which \marks{} returns an error, and \marks*{} has to be used^{8}; in particular, \marks{} does not work in AMS subsidiary mathematics environments such as aligned, gathered and split.^{9}

The command \noquestionwordmarks suppresses the word “Marks” in the output with question environments (this is the default), and the command \questionwordmarks restores

it; \solutionwordmarks (the default) and \nosolutionwordmarks work in the same

way for solutions.

The format can be changed with a command of the form \questionmarkstyle{style} or \solutionmarkstyle{style} in the preamble^{10}: Predefied styles are box, oval, bracket and boldbracket, which produce results like 5 marks , [figure: 5 Marks](default for solutions), [5 Marks] and [5 Marks] (default for questions) respectively. If you want to define a new style x, define a macro \markx which takes one argument and supplies the framing or whatever; e.g. the definition of \markbracket is simply

\newcommand{\markbracket}[1]{\mbox{[#1]}}

To typeset marks which do not contribute to the question total (e.g. in presenting marks for an either/or question, or marking schemes for alternative solution strategies), use \suspendtotal and \resumetotal: any \marks command between these display in the usual way, but do not change the question total. Note that \begin{question} and \begin{solution} implicitly execute \resumetotal.

At the end of each question or solution, the total number of marks can be printed. For questions, the default is not to print totals; you can change this with \questiontotals in the preamble. For solutions, the defaults is to print the total; you can suppress it with

\nosolutiontotals. \noquestiontotals and \solutiontotals work as expected,

but are unnecessary unless you want totals on some, but not all, questions or solutions.

For example, to reproduce the default state where marks appear in the form [5] in the questions, without totals, and in the form [figure: 5 Marks]in the solutions, with totals, you would enter in the preamble:

8In versions of exam.cls prior to 4/4/2004, \marks{} “worked” in these contexts, in the sense that it did not produce an error but failed to align properly. Documents written for these classes might therefore need to be updated to work with the new class.

9This is because, within these environments, TEX is in text-style mathematics mode, not display-style.

10For even finer control, you can use \markstyle, \wordmarks and \nowordmarks which override the current settings; this can be used to give different layouts in different questions, or even different parts of the same question, which is almost certainly not a good idea!

\questionmarkstyle{boldbracket}
\noquestionwordmarks
\noquestiontotals
\solutionmarkstyle{oval}
\solutionwordmarks
\solutiontotals

10. Headers and Footers

The page headers all contain the module number, right-aligned. Headers of solution pages also contain the word “SOLUTIONS”, centred.

The page footers all contain the page number, centred. On solution pages, this is a simple arabic number; but the page number on question pages is printed in the form “Page x (of y)”. The final page number, of course, is the last question page, not the last page in the document. This formatting feature can be switched off with \nopagecount (but don’t do this for new papers). The last page is recorded with a L^{A}TEX \label called lastqpage so, the first time L^{A}TEX is run, there will be an “undefined label” error associated with this name. As with all L^{A}TEX cross-referencing, if the number of pages changes then L^{A}TEX will have to be run twice before the footers are correct. ^{11}

When a question is broken across pages by the \questionbreak command, the footer of the page before the break contains “continued on next page” and the header of the page after the break contains “continued from previous page”.

The last footer of the last question page contains “End of examination.”

11. Adjustable Lengths

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 5em).

(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).

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}{5em}
\setlength{\qlabelsep}{1em}
\setlength{\qskip}{4ex}

11In versions earlier than Summer 2009, all page numbers were simple arabic numbers.

\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.

12. 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 October 2009

  Added \suspendtotal and \resumtotal.

Changes made May 2009

(1) Changed base class to extarticle to gain easy access to large font sizes.

(2) Changed page number format to “Page x (of y)”. Can be switched off (against University

      policy) with \nopagetotal.

(3) Now imports fullpage package to reduce margin widths.

Changes made October 2007

Added default pagebreak after \maketitle. Can be switched off (against University policy)

with \questionfrontpage.

Changes made October/November 2006

(1) Minor bugfix: literal \markstyle echoed into text under some circumstances.

(2) Minor bugfix to \marks: literal #1 echoed into text under some circumstances.

Changes made 23/8/2006

(1) Added missing \global on several definitions and conditional switches.

(2) Added and documented \marks*

Changes made 14/8/2006

(1) Renamed to ymexam.cls to stop confusion with exam.cls in standard distributions.

(2) Added automatic addition of R to code number if not present on resit papers.

(3) Added \questionmarkstyle, \solutionmarkstyle, the lower level \markstyle,

several conditionals to control mark display and generally reworked mark display code.

(4) Added L^{A}TEX-style aliases for all the plain TEX conditionals.

(5) Separated \nomarks and \noremarks.

(6) Added End of examination.” as final-page footer.

(7) Wrote up various undocumented features.

Changes made at some point in 2005

(1) Changed question numbering to “1 (of 4)” format, added option to number questions within sections.

(2) Fixed eTeX incompatibility (\marks is an eTeX primitive).

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 syn-

onyms 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 in-

tended 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.