Computer Laboratory

Preparing Tripos exam questions in LaTeX

The Computer Science Tripos examiners greatly appreciate if any exam questions submitted by assessors are provided not only on paper, but also as LaTeX source files.

LaTeX templates

We have prepared for each question setter (assessor) an individual exam pack, which is a directory filled with the necessary LaTeX class and style files, an individual Makefile, and a template file for each of the Tripos questions that have been assigned to a question setter. These packs are available both unpacked, as well as *.tar.gz and *.zip packages:

If you have GNU Make available (e.g., on Linux), download the *.tar.gz file, otherwise use the *.zip file (which contains *-solutions.tex wrapper files that the Makefile makes redundant).

Please read the documentation for the tripos document class, at least the brief section “Use by Tripos question setters”.

When you hand in your questions on a USB stick, please include only

  • the question files (20??-p??-q??-*.{tex,pdf})
  • associated figures (see below for details)
  • the solution PDFs (20??-p??-q??-*-solutions.pdf)

Do not modify the provided tripos.cls file.

Each question has an individual LaTeX source file following the naming convention

2015-p04-q08-mgk.tex = 2015 Paper 4 Question 8 by MGK

Do not forget to include marks (using the “\fullmarks” macro), solution notes (using the “answer” environment), and associated syllabus keywords (using the “\topics” macro). See the tripos class documentation for details.

Image filenames: If your question file loads any image files, please give each image file the same name prefix as your question file has. For example, the image files that come with 2015-p04-q08-mgk.tex might be called


The idea is that all question and image files can nicely coexist in a single directory with all others, and will appear there in a useful sorting order.

For examiners: there is also exampack-20??_papers, with all files needed for formatting papers and signoff sheets.


You obviously need LaTeX installed on your computer, preferably in form of a common TeX distribution such as such as TeX Live for Linux, MacTeX for MacOS, or MikTeX for Windows. TeX Live comes included with many Linux distributions.

On some distributions, the TeX environment comes modularized into many different subpackages that can be installed optionally, and you may have to install a few additional ones to have available all prerequisite files to the tripos class.

On Ubuntu Linux:

sudo apt-get install pgf texlive-latex-extra texlive-math-extra

Including graphics files

If you want to include some graphics file into a question or its solution notes:

  • Please prepare your figure in one of the graphics formats that "pdflatex" can include: PDF, PNG or JPEG.
  • Please make sure that the names of your graphics files start with the same prefix as the question file in which you include them (see above).
  • The tripos class loads by default the graphicx package for you, so you can use its facilities to include images, e.g.

    (You may want to place that into the “center” or “quote” environment.)

  • Please also provide to the examiners any human-editable source files that you used to produce your graphics. This way, they get archived along with the question and are available if you ever want to modify a figure.


A popular choice of drawing program for use with pdflatex is xfig, as its “pdftex” export format provides an easy means to generate graphics that use LaTeX for any text labels, leading to a consistent use of fonts.

On Ubuntu Linux, you can install xfig with the command

sudo apt-get install xfig transfig

Any graphics package (pgf, xy, etc.)

You can use any LaTeX graphics package that you like to produce your figure, but you cannot load additional packages inside your question file. Instead, if you want to use a package not already included by default, you can produce your figure as a separate PDF file from a separate LaTeX source file, and then merely include the resulting PDF from your question file. This way, the examiners will usually not have to learn how to install whatever exotic drawing package you fancy this year.

The preview package provides a convenient way to produce PDF figures with a correct bounding box for easy embedding.

Example: create for each of your figures a separate LaTeX file (say 2015-p04-q08-mgk-fig1.tex) of the following form:

... your figure ...

Then include the resulting PDF in your question file with


Security considerations

The University's examiner's guide has some guidance on security requirements for exam questions and papers:

You should observe absolute confidentiality in the drafting of question papers. Word processors and printers used for the preparation of question papers must be secure from unauthorised access and if at all possible should not be connected to a network. Copies of draft or final question papers and marking schemes should be stored in a secure, locked filing cabinet and preferably in a room that is not accessed by students.

In the Computer Laboratory, we certainly advise strongly against storing plaintext exam questions and their drafts on the departmental filer.

The encfs encrypted filesystem package for Linux allows you to work comfortably with files that are only stored in encrypted form on disks or file servers. More information ...

On Ubuntu Linux, you can install encfs with the command

sudo apt-get install encfs

The tripos document class

The tripos document class file was developed by Markus Kuhn in 2012 to help with typesetting Computer Science Tripos papers at the Computer Laboratory using pdflatex:

It is also used by some lecturers to typeset their MPhil test papers at the Computer Laboratory. This document class was carefully designed to maintain visual compatibility with how Computer Science Tripos papers have been typeset since the early 1990s at the Computer Laboratory. (Should other departments be interested in using it as well, its design was meant to be flexible enough to easily accommodate this.)

There are two packages that the tripos class uses, and of which you may want to copy the latest version into your working directory, as any pre-2012 version installed on your computer contains known bugs that have caused (minor) trouble in the past:


Example files showing how to typeset an individual question and associated solution notes:


The department maintains an online archive of all past exam questions since 1993. Easy read-only access to the archived sources of all past exam questions is available on the departmental filer under


After the exams, pagemaster will archive the source code of all exam questions and solution notes on the departmental filer in a Subversion repository located under


The README.txt file there explains the detailed repository arrangements and provides instructions on how to add the archive of another year.

You can use one of the following Subversion commands to checkout your own working copy of the full archive:

svn checkout svn+ssh:// exams
write access for authorized users
svn checkout svn+ssh:// exams
remote read-only access
svn checkout file:///usr/groups/wwwsvn/repositories/tripos-papers/all exams
local read-only access

If you are only interested in a particular year, replace in the above URLs “all” with the year, e.g.

svn checkout svn+ssh:// exams-2014

Formatting practice papers

Some Directors of Studies prepare practice papers for their students, using selected exam questions from past years. The tripos.cls package makes this very easy for post-2011 questions. Just prepare a paper file that inputs the question files that you would like to use. The following example-practicepaper.tex file shows this:

              day=Wednesday 13 May,time=4.30,endtime=6.00,
              subtitle={Practice paper for John Doe}]

Setting the option renumberquestions=true makes sure that questions are renumbered continuously, rather than appear under their original number. You can also use the options day, time, endtime, and subtitle to adjust what appears on the cover page of your paper. See the tripos.cls documentation for more information on how to format entire papers.

Place tripos.cls into the same directory.

On a CL-managed Linux machine, you can set the following environment variable in the shell, to make sure pdflatex automatically finds the listed questions in the exam question archive:

export TEXINPUTS=.::/anfs/www/tripospapers//


Why does my exampack not compile on

The server you tried has an ancient version of TeX installed. Try instead "" (aka ""), which has a contemporary version of TeXLive and all the packages required by tripos.cls installed.

But keep in mind that, for security reasons, you should avoid using any such timesharing machines for drafting future exam questions.

Why do {\it italics} and {\bf bold} not work?

The commands \it, \bf, \rm, \sl, \sc, \sf, \tt, \cal are plainTeX font-selection commands that are not part of LaTeX. While article.cls does still contain a backwards-compatibility hack to make some of these old commands work, they are not widely documented, do not fit in well with the modern LaTeX font mechanics, do not give access to all available font styles, and admin staff handling your exam files may not have seen them in their LaTeX course or textbook.

LaTeX equivalents include

{\it italics}\emph{italics}, \textit{italics} or {\itshape italics}
{\bf bold}\textbf{bold} or {\bfseries bold}
{\tt code}\texttt{code}, \verb+code+ or {\ttfamily code}
{\sl text}\textsl{text} or {\slshape text}
{\sc text}\textsc{text} or {\scshape text}
{\sf text}\textsf{text} or {\slfamily text}
${\rm max}$$\mathrm{max}$ or $\text{max}$
${\bf max}$$\mathbf{max}$
${\tt max}$$\mathtt{max}$
${\cal Z}$$\mathcal{Z}$

See Lamport's LaTeX reference manual, section C.7.8 (p. 191) and section C.15.1 (p. 225–226) for other font-style commands, and page 228 for an explanation of why not to use the old ones any more.

Can we include listings.sty?

The listings.sty package is not loaded by tripos.cls because it has caused font problems. It also is a rather huge and complex package that seems no longer maintained. An external pretty-printer that outputs LaTeX source might be a safer option (e.g., Pygments?). See also the section above on how to use any graphics package.

Can I use LyX with tripos.cls?

Using LyX is neither recommended nor supported. But if you are very determined to do so, the following information might help:

  • In LyX, go to Document > Settings > Language > Encoding and select there “Other: "Language Default (no inputenc)"”. Otherwise tripos.cls will complain about LyX having added “\usepackage[latin9]{inputenc}” at the start of the file.
  • There is an experimental LyX layout file at /homes/mgk25/.lyx/layouts/tripos.layout, which adjusts some of the visual appearance of the question in LyX towards what it will look like when typeset. It is far from perfect, due to limitations of LyX.