How I used LaTeX to typeset my dissertation

One of my personal goals for this year was to learn enough LaTeX to be able to typeset my undergraduate dissertation, such that it conforms with the fairly strict and idiosyncratic style guide that our department enforces for submitted work. Suffice to say that I’ve learned more about LaTeX and its plethora of packages in the two weeks before submission than I have done in the last few years that I have known of its existence.

Drafting

The first (and scariest) step is generating content. At first I thought I’d go all hardcore and use vim from the start to draft, but without extensive modifications, I find it to be non-intuitive for the prose typist. For the brief period during which I used vim, I used Markdown to impose sections and subsections (very important for the later organisation of the dissertation) and to emphasise text. I then used a custom alias (see below) for the infinitely-handy pandoc to generate previews. I found that a lot of time was spent switching between the editing environment and the shell in order to generate the previews. I now realise that I could have linked a custom ‘compiler’ in vim to generate the preview without leaving the editor. Without a fancy terminal that can integrate graphics, though, this still entailed leaving the command-line environment. I switched to the excellent and free Mou. Mou offers instant preview in a dual-pane interface, rendering the Markdown of the left pane in HTML according to CSS styles that are easily customised. The default styles look good, though, and don’t require much modification to look great. One major caveat: Mou does not support the dialect of Markdown which implements footnotes (key to academic drafting). That aside, images look good in the preview and are implemented with a very unobtrusive syntax. Organising graphics is a topic for another post, though.

function md2pdf(){ pandoc -s $1 -o $1.pdf --variable mainfont='Times' --variable fontsize=12pt --latex-engine=xelatex open $1.pdf; }

Typesetting

Both Mou and vim spit out .md (Markdown) files for conversion in to LaTeX using pandoc. I used one .md file per section, and converted them in batch to .tex files using pandoc. **Use the –no-wrap switch! **Pandoc’s automatic wrapping of text was a source of frustration while editing the .tex files in TeXShop (my TeX IDE of choice). At this point, you ought to have a bunch of .tex files corresponding to chapters or sections or what-have-you sitting in your working directory. You should create a master file for your dissertation and use the \input{} directive to reference the chapter or section files, keeping the main dissertation file (which should include the documentclass directive etc.) relatively content free. Use the \frontmatter directive to demarcate the start of ToCs etc., and the \mainmatter directive to demarcate the start of the body. There are loads of documentclasses (including a thesis.cls) which can help you write a thesis with fewer package calls than I required, but I used the book class and found Lapo F. Mori’s guide (here) to be an excellent guide to layout. While we are on the topic of package calls, try and keep them out of the preamble of your main document file. You can easily create a once-off style (.sty extension) which includes all the usepackages that are required across your document by creating a file with the following as the first line: \ProvidesPackage{somename}, and calling it in the main document with the \usepackage{somename} in the preamble. While you are editing the includes, it’s always good to keep an eye on word count and the command

texcount main.tex -inc

gives a summary (broken down by include and a total) of your real-word count (not including control sequences as wc would.). As a music student, musical examples are critical and I used the Export Graphics… command in Sibelius to export as .eps (which is a vector file format which scales losslessly). **Do not use .png or .jpg! **The compression artifacts impact the quality of your examples greatly, and if you use a laser-printer, the definition of vector-drawing examples is unparallelled.

Conclusion

This is only a selection of the many things I learned by tackling this LaTeX beast, and there were many pitfalls before I arrived at a production with which I was satisfied. Links to the tools I mention here are included below:

Links

Mou pandoc (available via Homebrew)