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

2014-p04-q08-mgk.tex = 2014 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 2014-p04-q08-mgk.tex might be called

  2014-p04-q08-mgk-fig1.fig
  2014-p04-q08-mgk-fig1.pdf
  2014-p04-q08-mgk-fig1.pdftex
  2014-p04-q08-mgk-fig2.fig
  2014-p04-q08-mgk-fig2.pdf

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.

Prerequisites

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 name of your graphics files starts 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.
    \includegraphics[width=0.8\linewidth]{2014-p04-q08-mgk-fig1.pdf}
    

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

  • Please also provide to the examiner any human-editable source files that you used to produce your graphics, in case they want to make modifications.

Xfig

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 2014-p04-q08-mgk-fig1.tex) of the following form:

\documentclass[ownpackages]{tripos}
\usepackage{your-favourite-graphics-package}
\usepackage[active,tightpage]{preview}
\begin{document}
\begin{preview}
... your figure ...
\end{preview}
\end{document}

Then include the resulting PDF in your question file with

\includegraphics{2014-p04-q08-mgk-fig1.pdf}

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 developped 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 accomodate 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 last year:

Examples

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

FAQs

Why does my exampack not compile on slogin-serv.cl.cam.ac.uk?

The TeX distribution on slogin-serv is currently (as of Jan 2013) still a local compilation of TeTeX 3.0, which is now rather dated (released 2006) and in particular lacks the pgfkeys.sty file required by tripos.cls. There is no easy-to-install TeX Live distribution available for the CentOS Linux distribution used on that server. Sys-admin are currently discussing to also offer an Ubuntu-based timesharing server in future, which should eventually solve that problem.

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

Why does {\it italics} not work?

The commands \it, \em, \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.

The LaTeX equivalents for \it are \emph{italics}, \textit{italics} or {\itshape italics}. 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.