Robin's Blog

My LaTeX preamble

Since I started my PhD I have forced myself to use LaTeX for all of the documents that I write (yes, absolutely everything), and this has really helped me get to grips with how to do things in LaTeX. Overall I have been very impressed – my documents now look really professional, and LaTeX actually works really well and isn’t that hard to get to grips with.

I thought I’d write this post to explain the various packages that I always load in my LaTeX preamble. I’ve often been meaning to put all of my preamble into a style file so that I can load it in one line, but I’ve never quite got round to it. Maybe I’ll write another blog post about this when I get round to doing it…

Anyway, without further ado, below is my standard LaTeX preamble, with brief comments explaining the packages I’ve loaded. Below the code I go into further detail about the packages I use most.


% Pretty much all of the ams maths packages

% Allows you to manipulate the page a bit

% Pulls the page out a bit - makes it look better (in my opinion)

% Removes paragraph indentation (not needed most of the time now)

% Allows inclusion of graphics easily and configurably

% Provides ways to make nice looking tables

% Allows you to rotate tables and figures

% Allows shading of table cells
% Define a simple command to use at the start of a table row to make it have a shaded background


% Provides commands to make subfigures (figures with (a), (b) and (c))

% Typesets URLs sensibly - with tt font, clickable in PDFs, and not breaking across lines

% Makes references hyperlinks in PDF output

% Provides ways to include syntax-highlighted source code
\lstset{frame=single, basicstyle=\ttfamily}

% Provides Harvard-style referencing

% Provides good access to colours

% Simple command I defined to allow me to mark TODO items in red
\newcommand{\todo}[1] {\textbf{\textcolor{red}{#1}}}

% Allows fancy stuff in the page header

% Vastly improves the standard formatting of captions
\usepackage[margin=10pt,font=small,labelfont=bf, labelsep=endash]{caption}

% Standard title, author etc.
\title{COMP6024\\Model Specification based on \citet{Telfer:2010}}
\author{Robin Wilson\\ID: 21985588}
% Put text on the left-hand and right-hand side of the header
\rhead{Robin Wilson}

So, which of those are most important, and why do I use them:

  • amsmath – This is a package by the American Mathematical Society for typesetting mathematics sensibly. I’m not a mathematician, but I often have to include maths in my documents. Nearly all of the tutorials you read on the internet for doing maths in LaTeX will be for amsmath, and it generally gives very good results (and every possibly mathematical symbol/feature you will ever need).
  • parskip – I hate indented paragraphs in wordprocessed documents – I’m sure there are various typsetting rules against doing it. Anyway, this removes all paragraph indentation without screwing anything else up!
  • booktabs, rotating and colortbl – These provide everything I need to produce good quality tables. Booktabs gives me a number of different options for alignment, as well as providing \toprule and \bottomrule which give thicker lines for the top and bottom of tables. Rotating allows you to produce sideways tables and figures when they won’t fit properly on a portrait page, and. Colortbl allows shading of tables cells. I’ve defined my own command here because I often want to shade a table cell with a light gray. This command (\gray) is simply replaced with \rowcolor[gray]{.9}.
  • subfigure – This gives a really simple way to include various image files as one figure, labelling each one as (a), (b), (c), with different captions. Simple, but works really well.
  • url – Again, this does one very simple thing very well: it typsets URLs sensibly. Simply wrap the url in \url{} and it typesets it in typewriter font, makes it into a clickable link (in PDF files) and stops it breaking over lines
  • caption – This is one of the most important packages in my list. It allows you to style the captions produced for tables and figures to make them actually look different from the rest of the text. This is very important to help guide the reader around the page. The way I call the package is \usepackage[margin=10pt,font=small,labelfont=bf, labelsep=endash]{caption}, and this makes the caption indented, in a smaller font, with the label (eg. Figure 10) in bold and separated from the rest of the caption by a dash. Again, this really tidies up the appearance of documents.
  • fancyhdr – This lets you put useful things in the header of the document. For example, for my university work I put my name on the right-hand side of the header, and the course code on the left-hand side of the header. The simple \lhead and \rhead commands do that for me easily.

I haven’t been through all of my packages above, but the rest of them are fairly easily understandable. In my view, they are the really key packages for almost any type of LaTeX document.

If you found this post useful, please consider buying me a coffee.
This post originally appeared on Robin's Blog.

Categorised as: Academic, LaTeX


  1. You don’t need the url package; hyperref provides the same functionality (except with a link, which url doesn’t do on its own), and since it’s loaded after url, it’s overwriting what url does anyway.

  2. Oh, and you only need xcolor, not both color and xcolor.

  3. Stéphane Péchard says:

    Nice stuff! For my own PhD thesis, I used this header:

    The result is (in my opinion) very nice, mostly thanks to the wonderful Garamond font family. You can see it here:

    Stéphane Péchard

  4. Ben says:

    This is very useful — thanks! When I started my Masters program, I also forced myself to learn LaTeX. It was tricky at first, but I soon found my flow and feel very much how you feel, that my documents are better and more beautiful than before.

    It is nice to see an explanation with the packages used. I grabbed a template early on from the internet and have been using it ever since. I think you have motivated me to go back and see what the packages are and learn more about what they do.

    Also, if you use emacs, I can recommend the orgtbl-mode as an excellent way to quickly make a table in LaTeX.

  5. Robin Wilson says:

    Thanks for the comments – I didn’t realise that. One of the benefits of posting these things is that you get comments, ideas and feedback from the community. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *