Three ways to modify the PDF output

Although this template provides a basic skeleton for a UvA thesis, at some point you’re bound to run into its limitations. Maybe you’re in a field that has some specific formatting requirements, or you simply want to make it more your own. There are a few things you can do1:

1. Modifying the template

After you drafted the template, there should be a template.tex file in the folder (check it out on GitHub here). This file holds all of the LaTeX formatting commands that determine the look of the thesis, and can be changed at your will.

2. The includes option

If you just want to add a few LaTeX commands, you might not have to change the template itself. Instead, you could create a new file and include it so that the commands will be executed. For example, you could include the LaTeX caption package to customize the look of your figure/table captions. You would then save the command \usepackage{caption} (along with any other commands) in a file (typically called preamble.tex) in the thesis template folder. Then, to include the file, specify the following YAML options in your index.Rmd file:

output:
  bookdown::pdf_book:
    includes:
      in_header: preamble.tex

For more, see this section of the bookdown manual, and check out the preamble.tex file I used in my own thesis.

3. Raw LaTeX commands

Sometimes you’re after a small local fix, not a general change to the format of the thesis. In that case you can simply insert the raw LaTeX code in your .Rmd file, and it should be automatically interpreted. If this ever goes wrong (i.e. the raw TeX is still included the output), or if you want to write a more extensive section of LaTeX, try explicitly indicating that it should be interpreted as LaTeX code, by enclosing your code within a LaTex code block:

```{=latex}
Your TeX here
```

You’ll find examples of raw TeX strewn throughout the template. For example, you can quickly insert some white space with \bigskip, or change the font size to small with \small.

Typical modifications

LaTeX document class

One of the easiest ways to change the overall look of your thesis is to change the document class. By default, the template use one of the standard classes: book (others include e.g. article or report, which are less suitable for a PhD thesis). Many universities have written their own document class for PhD theses, according to their own formatting guidelines, but as far as I know, the UvA has not. However, there are other LaTeX packages that provide custom classes which are easier to customize than the standard book class.

For my thesis, I used the memoir class from the memoir package. Memoir provides multiple good-looking default styles that are very easy to apply. For example, to change the chapter style (the look of your chapter headings) to that of the LaTeX Companion book, all you’d have to do is include \chapterstyle{companion} (e.g. in your preamble.tex file). Tweaking these styles or making your own is also comparatively easy with Memoir, as the package provides lots of useful commands to do so. Memoir also has an incredibly detailed manual, that even provides some general advice on typesetting and the like.

To change the document class, simply change the YAML option in index.Rmd to one of your choosing, e.g.:

documentclass: memoir # the default is book

Note that there are also other good options for the document class than book or memoir, such as the classes from the koma-script package.

Fonts

The surest way to change the font of your thesis is to pick one of the freely available fonts from the LaTeX Font Catalogue. For example, to change the font to (EB) Garamond, just add the \usepackage{ebgaramond} command (e.g. in your preamble.tex file).

But you can in principle use any font you have installed on your system. To do that, you will have to switch the LaTeX engine from the default (pdflatex) to xelatex for instance. This also gives you access to the mainfont yaml option (as well as a few others; see the pandoc documentation), where you can specify the name of the font you want to use, e.g.:

output:
  bookdown::pdf_book:
    latex_engine: xelatex
mainfont: Times New Roman

  1. Note that all of these concern changes to the PDF outputs only. The bookdown html template is basically fixed and cannot be customized much (but see this package for an easy way to make some customizations by changing the underlying css).↩︎