# Typesetting Tripos exam questions

A discussion paper for the Computer Laboratory Admin Support Panel

## Background

Since 1993, Christine Northeast has typeset all Computer Science Tripos exam questions using a TeX macro setup by Frank King. The macros and question files of the past years can be seen at /home/chn2/tripos/.

These macros are for Plain TeX, Knuth’s original TeX configuration, which is hardly used today any more and has long been superseded by LaTeX. Few in the department today know Plain TeX, whereas most use LaTeX routinely for scientific publishing.

For several years, question setters have been encouraged to write and submit their exam questions and solutions in LaTeX, using a “LaTeX question template” at /home/chn2/tripos/docs/sample*.tex. This has encouraged some question setters to make full use of LaTeX's facilities for mathematical typesetting. But as much of that is not available under Plain TeX, Christine had to become an expert in transcribing LaTeX into Plain TeX, and question setters had to be careful to restrict themselves to the LaTeX subset that can be easily transcribed that way. This is clearly a cumbersome, time-consuming, and error-prone workflow.

We should replace the existing Plain TeX macros with a new LaTeX-based solution. Redesigning the setup also gives us the opportunity to fix a number of other shortcomings of the current system, namely to have

• automatic numbering of question parts (to simplify rearranging them);
• support for missing text between the start of a question part and a subpart (which currently causes an ugly line break);
• support for multiple paragraphs in question parts and subparts (which currently causes indentation to go wrong);
• support for keeping solution notes stored directly adjacent to the corresponding part of the question in the source file;
• typesetting solution notes for supervisors in a variety of formats (questions and solutions combined or separate, multi-year PDFs, etc.);
• more options to include figures;
• standard inclusion of certain application-specific LaTeX packages that some question setters currently each include seperately with their solution notes;
• a more robust way for automatically extracting metadata for online archiving;
• a filename concept that makes it easy to select with regular-expressions useful subsets of questions (include course code and year, leading digits, author);
• a script that auto-generates templates for each question for question setters (perhaps controlled by the same data source that is used to generate the Structure of Papers document).

## Requirements

Goal of the proposed project is to develop a LaTeX document class and associated tools and documentation for typesetting, archiving and disseminating University of Cambridge Tripos questions and their solution notes. This "tripos" document class is primarily meant to replace the existing Plain TeX setup used in the Computer Laboratory, but it would be nice if other departments could equally easily use it, should it meet their requirements (e.g., course name etc. should be configurable).

The system should allow us to keep in a single *.tex file all the information related to a single question that may be needed (assuming that a “question” is a unit normally authored by a single person):

• Question heading (usually to match a course title)
• Question text (can be split into parts and subparts)
• Number of marks per question part
• Solution notes text
• Metadata: tripos, year, paper number, question number, author

The system design may choose to encode some of this information in the file name.

[In the past (Diploma), the same question could appear with different numbers in different papers that happened on the same day. Do we still need this?]

The per-question files should be compilable on their own under LaTeX, such that the question setter can easily and immediately verify their typographic appearance in the exam already at the time of drafting, without any infrastructure needed beyond a simple, single style file. They should also be compilable via inclusion into larger documents that bundle several questions together, to produce the actual exam papers, practice exams, or course-specific question and/or solution collections.

When complied individually, options should allow the user to choose between at least two layouts:

1. Typeset all question parts on their own, laid out as closely as possible to how they will appear on the actual exam paper, followed on a separate page by all the associated solution notes and additional metadata. This form is to help a question setter to proof-read their question on its own.
2. Typeset all question parts immediately followed by the respective solution notes. This form is to help question setters to proof-read their solution notes.

Beyond the above two output formats, the exact same file should also be formatable in a number of other fashions:

• As a sign-off sheet, where the question setter approves the final edited version of the question;
• As a complete exam paper, as printed for the examination hall;
• As a mock exam paper, prepared by Director of Studies or supervisors to prepare their students (e.g., college January tests);
• As a single PDF per question, showing only the question plus associated metadata, like we do on our past exam papers web pages;
• As a single PDF per question, showing questions and solution notes interleaved (or optionally separated by a pagebreak) plus associated metadata, for the benefit of supervisors and students;
• PDFs of multiple questions (e.g., the last 10 years of a course), for compacter and more comfortable printing of topic-specific question collections.

Other potentially desirable features:

• It should not be necessary to modify the per-question source file to include it into any of these formatting products. In particular, the person compiling a bundle of questions into a single PDF may want to use question files from an archival directory to which they do not have write access. The source file should be includable by files that define larger bundles.
• Formatting options should be specifiable and possible to override in the bundle file that includes others.
• Formatting options should also be specifiable on the latex command line, such that multiple versions of the same question of paper (signoff-sheet version, solution-note version) can all be produced without requiring additional source files.
• Formatting options should ideally include the possibility to select only parts of a question (e.g., to exclude from practice exams subquestions that are no longer covered by the latest syllabus).
• While we have used Computer Modern fonts so far, there might be demand in future for a sans-serif font variant (allegedly for the benefit of users with dyslexia).
• Easy and safe automatic extraction of metadata from the question files (for the system generating the archival web pages); a simple Perl/Python module to extract it and a command-line tool to verify that the metadata is formatted correctly could be useful.

Some compliance tests could be implemented in either LaTeX or by additional script tools:

• A warning if the number of marks per question do not add up to the required sum (default: 20, has varied over the years)
• An error if a question author tries to include a non-supported LaTeX package with \usepackage (to discourage proliferation of exotic packages and ensure a manageable compile environment)
• A warning if a question is too long

The system might in future be used in a version-control environment (see ExamOS proposal), so nothing in the design should hinder that.

Some packages that might be useful to the envisioned architecture:

• docmute.sty – allows inclusion of self-contained question files that also typeset on their own, by skipping subsequenct \documentclass and preamble lines.
• pgfkeys.sty – currently the probably best available LaTeX package for dealing with key=value options

## Use cases

A question file (as prepared and submitted by a question setter) might be named 2009-p07-q04-ijw.tex and contain text such as:

\documentclass{tripos}
\begin{document}
\begin{question}[CSTpartII,year=2009,paper=7,question=4,author=IJW]{Digital Electronics}

\begin{itemize}

\item How many are there in the \emph{Universe}? \fullmarks{4}

\item Consider electrons.

\begin{itemize}

\item Why are they so negative? \fullmarks{4}

Nobody knows yet.

\item Why did they recently change colour from red to brown? \fullmarks{8}

Just to keep electricians on their toes, Amendment No 2, 2004 of BS
7671:2001 to the IET Wiring regulations changed the colours to match
those they use in flexible cables.

\end{question}
\end{document}


An exam paper would be a file such as 2009-p07.tex that includes several files like the above:

\documentclass{tripos}
\begin{document}
\begin{paper}[CSTpartII,year=2009,day=Monday 5 June,paper=7]
\maketitle
\section
\input{2009-p07-q01-pes.tex}
\input{2009-p07-q02-mgk.tex}
\input{2009-p07-q03-jac.tex}
\section
\input{2009-p07-q04-ijw.tex}
\input{2009-p07-q05-rja.tex}
\input{2009-p07-q06-jjd.tex}
\end{paper}
\end{document}


## Original project outline

Suggested project team:

• Robin Fairbairns – implementation and documentation of LaTeX class
• Martyn Johnson – generation of archival web pages
• Markus Kuhn – requirements analysis, additional documentation, testing
• Christine Northeast – testing
• Alastair Beresford – testing

Suggested project timeline:

• Kickoff meeting: 23 March 2010, 10:00, room GE16 (rf, chn, mgk)
• Completion of requirements analysis: ~March 2010
• Beta release of implementation: ~June 2010
• Testing and incorporation of feedback: by August 2010
• Production use and maintenance: from January 2011

Risks:

• If this project fails, we may end up with Microsoft Word in the long term.

## Project status and outcome

Markus Kuhn started implementing tripos.cls in January 2012. An alpha test version was used for the first time in February 2012 by Markus Kuhn (Part IA/IB) and Mike Gordon (Part II) to typeset all 2012 CST papers. Markus released a functionally complete beta test version of the tripos document class with full documentation in November 2012, in time for the 2013 CST papers. The project was largely completed by April 2013, although there is ongoing work regarding documentation, use for MPhil test cover pages, and automatic management of the online archives of past papers and solution notes.