skip to primary navigationskip to content

Department of Computer Science and Technology

Typographic resources

 

Preparing Tripos exam questions in LaTeX

The Computer Science Tripos examiners greatly appreciate if any exam questions submitted by assessors are provided as LaTeX source files.

The exampacks with LaTeX templates for the June 2024 CST papers are now ready.

For the 2024 Tripos, you again have direct access to the Subversion repository where the papers are edited to obtain your exampack and submit your questions. Preferably use Subversion to submit your questions, track how they get edited, resubmit any updates, and retrieve them for reviewing. Question setters and checkers will see a filtered view of the repository, showing only files of questions assigned to them. Detailed instructions ...

LaTeX templates

We have prepared for each question setter (assessor) an individual exam pack, which contains the necessary LaTeX class file, a Makefile, and a template file for each of the Tripos questions that have been assigned to a question setter.

These files are available via Subversion, which is now the preferred way to access, edit, submit and review them.

[The packs are also still available as unpacked files, as well as *.tar.gz packages (aimed at Unix/Linux/macOS users) and *.zip packages (aimed at Windows users). Windows users who do not use Make might still find the *-solutions.tex wrapper files in their *.zip package useful, as these are not in Subversion.]

There is also a

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

When you submit your questions (via “svn commit”), please include only

  • the question files (20??-p??-q??.tex)
  • associated figures (20??-p??-q??-*.*, see below for details) and their source files

Do not modify the provided tripos.cls file.

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

2024-p04-q08.tex = 2024 Paper 4 Question 8

Do not forget to include marks (using the “\fullmarks” macro), solution notes (using the “answer” environment), and associated syllabus keywords (using the “\topics” macro). Follow each “\fullmarks{...}” immediately with “\begin{answer}” to show how to get these marks. See the tripos class documentation for details.

Image filenames: If your question file loads any image files, each image file must have the same name prefix as your question file. For example, the image files that come with 2024-p04-q08.tex might be called

  2024-p04-q08-fig1.fig
  2024-p04-q08-fig1.pdf
  2024-p04-q08-fig1.pdftex
  2024-p04-q08-fig2.fig
  2024-p04-q08-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.

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 Unix/Linux systems, you should also find a version of GNU Make. On macOS, if you don't have “make” available, you can run “xcode-select --install” to install it.

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 16.04:

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

On Ubuntu Linux 18.04 and 20.04:

sudo apt-get install texlive-latex-extra texlive-science

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 (for vector drawings), PNG (for screenshots or pixel drawings) or JPEG (for photos).
  • 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.
    \includegraphics[width=0.8\linewidth]{2024-p04-q08-fig1.pdf}
    

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

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

Use 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 2024-p04-q08-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{2024-p04-q08-fig1.pdf}

The standalone class does something similar:

\documentclass[class=tripos,ownpackages]{standalone}
\usepackage{your-favourite-graphics-package}
\begin{document}
... your figure ...
\end{document}

Security considerations

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

The initial preparation, editing and copying of question papers needs to be undertaken under strict confidentiality. All versions of draft and final copy must be typed, copied and stored securely.

Try to avoid storing your draft questions on shared filespaces or network/cloud drives that might make your draft questions available on more devices than absolutely necessary. Preferably use an encrypted local filesystem of a single-user device to edit questions.

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

Examples

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

Archive

We maintain a departmental 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

/anfs/www/tripospapers

Since the LaTeX source files also contain solution notes, access to them is restricted for exam questions younger than two years, which is the embargo period for solution notes set by the Teaching Management Committee.

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

/usr/groups/wwwsvn/repositories/tripos-papers/

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:[Javascript required]/tripos-papers/all exams
write access for authorized users
svn checkout svn+ssh://slogin.cl.cam.ac.uk/usr/groups/wwwsvn/repositories/tripos-papers/all exams
remote read-only access (requires a valid Kerberos ticket-granting ticket on slogin)
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://slogin.cl.cam.ac.uk/usr/groups/wwwsvn/repositories/tripos-papers/2014 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 practicepaper.tex file shows this:

\documentclass{tripos}
\begin{document}
\begin{paper}[CSTpartIB,year=2024,paper=3,renumberquestions=true,
              day=Wednesday 15 May,time=4.30,endtime=6.00,
              subtitle={Practice paper for John Doe}]
\maketitle
\input{2021-p03-q03}
\input{2022-p03-q08}
\input{2019-p03-q01}
\input{2018-p03-q02-tgg}
\input{2013-p03-q04-tgg}
\input{2014-p03-q04-tgg}
\input{2012-p03-q08-de}
\input{2013-p03-q09-rja}
\end{paper}
\end{document}

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

Formatting MPhil/Part III module tests

The tripos class can also be used to typeset papers or cover sheets for tests in masters modules.

Download the following files:

Read section “Use in Part III and MPhil tests” in the tripos.cls documentation for more information.

FAQs

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. Most question setters who include source code use the “verbatim” or “alltt” environments. The latter permits the use of mathematical notation, e.g. \(a\sp{2}\sb{i}\).

An external pretty-printer that outputs LaTeX source might also be an option (e.g., LGrind, 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.

Can the layout be modified for visually-impaired students?

The class option "crop" reduces the margins, resulting in a 170 x 250 mm page size. Magnifying such a page to A4 (e.g., using the Adobe Reader function “Fit to printable area”) enlarges the text by a factor of 297/250 = 1.188, effectively changing the font size from 12 to 14.3 points. Beyond that, printing onto A3 paper instead of A4, results in another 1.41 magnification and a 20.1-point font size. (There is no option to change the font size directly, as that would often cause significant reformatting problems with longer equations and source-code lines.)

The class option "sans" switches the main Type 1 font used from Computer Modern Roman 12 point (CMR12) to Helvetica 12 point. As a sans-serif font, Helvetica has far less stroke-width variation.

See also