11.5.2009

A LaTeX template for my dissertation

In the recent weeks I have spent a lot of time to polish the draft of my dissertation with the help of LaTeX. In this article, I would like to share the packages I used. This list of packages comes close to a template, but you must still decide which package you need.

In general, I wanted to have a pdfTeX-compliant document.

KOMA Script

\documentclass[DIV=calc, 11pt, parskip=half]{scrreprt}

The basis for my dissertation is the report class of KOMA Script. I will change this to book once I come close to printing, but for reviewing report is fine. It is intended for European formats (A4 is the default paper size).

I let LaTeX compute the page margins (DIV=calc). This is the easiest way to guarantee good readability for different font sizes. The basic idea is that a certain number of letters per line is optimal for reading. This leads to rather large margins but good readability. The font size is specified with 11pt and parskip=half makes LaTeX separate paragraphs with space between them (indenting is the default).

Language-specific packages

\usepackage[english]{babel}

The babel package allows you to set the language(s) of the document. This effects a lot of things, hyphenation for instance, but also section headings like Table of contents or References, which are changed according to the language specified. You can even have multiple languages in one document.

\usepackage[utf8]{inputenc}

Almost everybody outside of English-speaking countries runs into problems with special characters like the German Umlauts (äöüäöü). To make LaTeX process and display these special characters correctly, you need the inputenc package. It takes the document’s character encoding as argument.

\usepackage[T1]{fontenc}

This package makes LaTeX load a new, extended fonts with all these European accented characters. So they are displayed nicely.

Graphics

\usepackage{graphicx}

If you want to include graphics in your document, you will need one package for this. I use the graphicx package, which provides the command includegraphics.

\usepackage[small, bf, up, hang]{caption}

The default captions of LaTeX do not look very appealing, since they use the exact same font as the normal text. The caption package lets you choose a different layout for captions, as given in the package options. small means that a smaller font size is used, bf refers to the caption label which is made bold faced, up means regular upright font and hang refers to the way how multiple lines are dealt with.

\usepackage[percent]{overpic}

Another problem is using text with graphs. If you design graphs with a program, you will almost certainly have a different font and — depending on the figure size — a different font size compared to the rest of your document. One solution for this is the PSfrag package, with the big disadvantage that it does not work for pdfTeX. The overpic package is compatible with pdfTeX, you have to specify the coordinates where LaTeX constructs are inserted. I prefer the percent option, where relative coordinates are used, in case of image scaling.

Maths

My dissertation does not contain a lot of mathematical formula. But there are some elements to consider.

\usepackage{amsmath}

The amsmath package provides a lot of commands and environments for maths. Just loading the package makes mathematic terms look nicer.

\usepackage{nicefrac}

The normal way to typeset fractions is with a horizontal fraction line. This uses a lot of space. The nicefrac package provides the nicefrac command, which creates a fraction with diagonal fraction line.

\usepackage{units}

Most documents use either a full space between number and unit (2.3 N) or no space at all (2.3N). Both looks nasty, a half space is the optically pleasing distance (2.3 N). The units package provides the commands unit[2.3]{N} and unitfrac[4.3]{Nm}{s} for nicely set units.

Tables

Setting large tables with LaTeX is a pain and one area where WYSIWYG typesetting programs offer a much more intuitive approach. But it works with LaTeX as well, if you know the tricks.

\usepackage{booktabs}

Most people tend to draw all conceivable lines in tables. But this is not necessary, as the elements of a table are already aligned. In books, you will therefore find only three horizontal lines per table, one above the heading, one below, and a last one at the bottom of the table. The booktabs package provides these three lines or rules (British English) as toprule, midrule, bottomrule.

\usepackage{multirow}
\usepackage{rotating}

Sometimes, you will need text which spans multiple rows. Since space is precious, I have used rotated text in these cases, requiring the packages rotating and multirow. The rotating package provides the sideways environment for the task I described, but you can also easily rotate a whole table by using the sidewaystable instead of the table environment.

Bibliography

One of the big strengths of LaTeX is the handling of bibliographic data with BibTeX. The prerequisite for using BibTeX is to organize your bibliography in a database. There are numerous options available, I used CiteULike, an online solution. It takes some effort to post all your read articles, books, and conference proceedings in there, but the merit is a database which you can easily integrate in any of your publications. All you need to know is a key for each publication, e.g. AuthorYear. But BibTeX has also some drawbacks, therefore, a lot of LaTeX packages exist to provide an easier interface to BibTeX.

\usepackage[style=apa, noremoteinfo,
  hyperref=auto,
  bibencoding=inputenc,
  refsection=chapter]{biblatex}

One of the more recent developments is the biblatex package, which aims to provide a full LaTeX interface to the bibliography. It is compatible with the hyperref package, allows section bibliographies and everything else you could ever want. I use the APA style for citations and the bibliography (style=apa), the option noremoteinfo prevents LaTeX from printing DOI links and other nasty stuff in the bibliography, bibencoding=inputenc sets the character encoding of the bibliography to the same value as specified in the package inputenc, and refsection=chapter automatically creates section-wise bibliographies on the chapter level of the document.

In the document, I use parencite{key} for citations in parenthesis and textcite{key} for citations that are part of the text. And printbibliography prints the bibliography exactly at this place.

Miscallenious

\usepackage{microtype}

Without understanding the details of microtypography, just using this package improves certain typographic features of your document (ever heard of character protrusion or font expansion?)

\usepackage{xspace}

Whenever you define a text macro with newcommand, e.g. for typesetting special terms, you will encounter the problem of a missing space after the macro. Therefore, you need an intelligent space (xspace) in the macro definition, which occurs in normal text but not at the end of the sentence.