How to write your thesis in LaTeX

A thesis is the longest document most people ever write, and LaTeX is good at long documents: it numbers chapters, figures and references for you and keeps the layout consistent from the first page to the last. This guide goes through the work in order, from the template to the final PDF, with TexWaller as the editor.

Start for free

TexWaller is a free online LaTeX editor: nothing to install and no compile timeout.

1. Start from a thesis template

Don't start from an empty file. Check first whether your university or department has an official template: it already has the title page, the margins and the bibliography style the committee expects. If it has none, start from a general thesis template built on the book, report or KOMA-Script scrbook class.

  • Use book or scrbook for a thesis with chapters, a front matter and a bibliography; report is enough for a shorter dissertation.
  • Set the paper, the font size and one-sided or two-sided printing once, in the options of the class.
  • Keep the packages and your own macros in one settings file, so the main file stays readable.

2. Split the thesis into files

Keep one file per chapter and a short main file that puts them in order. The main file reads like the table of contents of the thesis, and two people can work on two chapters without getting in each other's way.

main.tex
\documentclass[12pt,a4paper,oneside]{book} \input{settings} % packages and macros \begin{document} \frontmatter \input{frontmatter/titlepage} \input{frontmatter/abstract} \tableofcontents \listoffigures \listoftables \mainmatter \include{chapters/introduction} \include{chapters/background} \include{chapters/method} \include{chapters/results} \include{chapters/conclusions} \appendix \include{chapters/appendix} \backmatter \printbibliography \end{document}
  • \include starts a new page and is meant for chapters; \input pastes a file where it is, and suits the title page, the abstract and the settings.
  • \frontmatter numbers the pages in Roman numerals, \mainmatter restarts in Arabic numerals, \backmatter stops numbering the chapters.
  • Put the images in one folder and the chapters in another: paths stay short and predictable.
A thesis in TexWaller: the Figures and Include folders and the main file on the left, with the document outline of chapters and sections below them

3. Figures, tables and cross-references

Give every figure and table a caption and a label, and refer to them with \ref instead of typing the number. LaTeX renumbers everything when you move a figure or add a chapter.

A figure and a reference to it
\begin{figure}[htbp] \centering \includegraphics[width=0.8\textwidth]{images/pipeline} \caption{The steps of the pipeline.} \label{fig:pipeline} \end{figure} Figure~\ref{fig:pipeline} shows the steps of the pipeline.
  • Choose a prefix for each kind of label, such as fig:, tab:, sec: and eq:, and keep to it.
  • Put \label after \caption, or the reference will point to the section instead of the figure.
  • Use vector images (PDF) for plots and diagrams, so they stay sharp in print.
  • In tables, the booktabs rules (\toprule, \midrule, \bottomrule) are the standard in scientific writing.

4. The bibliography

Keep the references in a .bib file and let LaTeX format them. With biblatex and Biber you choose the style in one line and change it later without touching the entries.

biblatex in two places
% settings.tex \usepackage[backend=biber,style=numeric]{biblatex} \addbibresource{references.bib} % in a chapter Transformers were introduced by \textcite{vaswani2017}.
  • Use keys you can remember, such as the first author and the year.
  • Take the entries from the publisher or from a database such as dblp instead of typing them: fewer mistakes in authors and page numbers.
  • Check which citation style your department requires before you choose between numeric and author-year.
The dblp search in the TexWaller toolbar, which finds an article and gives its BibTeX entry without leaving the editor

5. Compile a long document

A thesis with a few hundred pages, many figures and a large bibliography takes longer to compile than an article, and it needs several passes before the table of contents and the references settle.

  • Compile often: an error is easy to find when you have just written the line that caused it.
  • Read the first error first. The ones that follow are often its consequences.
  • When the PDF seems stuck on an error you already fixed, rebuild everything from scratch.
  • Use LuaLaTeX if you need OpenType fonts with fontspec; otherwise pdfLaTeX is the default.

6. Work with your supervisor

A thesis goes back and forth many times. Decide early how your supervisor will read each draft and how you will collect the comments, so that nothing is lost in email attachments.

Notes in the source, hidden in the final version
\todo{Update the table with the new values.} \question[from=Marco]{Can we also cite the 2021 paper?} As shown by earlier work \citemissing[Rossi 2021?]. % in the main file, before the final version \usepackage[hide]{chato-notes}
The Project versions panel of TexWaller comparing two versions of a thesis: the list of versions and the changed lines of the abstract in red and green

Save a version every time you send a draft, with a title such as First submission to the supervisor. For the next draft you can then show exactly what changed.

A PDF built by latexdiff in TexWaller: the text added to the abstract is blue and underlined

7. Before you submit

Go through this list on the final version, a few days before the deadline.

  1. Compile from scratch and check that no error is left.
  2. Read the warnings: undefined references and citations show as ?? or as a key in bold in the PDF.
  3. Hide the notes and replace every placeholder with the real citation or reference.
  4. Check the title page against the rules of your university: names, academic year, logo.
  5. Look at the table of contents and the lists of figures and tables for titles that are too long or missing.
  6. Run the spell check on every chapter.
  7. Save a version, download the PDF and download the project as a zip.

Questions about writing a thesis in LaTeX

Which LaTeX editor is good for a thesis?
One that handles a project with many files, compiles long documents without a time limit and lets your supervisor read and comment. TexWaller does the three, in the browser and for free.
Which document class should I use for a thesis?
The one your university provides, if there is one. Otherwise book or the KOMA-Script class scrbook for a thesis with chapters, and report for a shorter dissertation.
Can my supervisor read the thesis without knowing LaTeX?
Yes. Invite them as a viewer or send a read-only link, or send the PDF. A latexdiff PDF shows them what changed since the previous draft.
Does a long thesis hit a compile timeout?
Not in TexWaller: the document compiles on your computer and there is no time limit.
Can I use the template of my university?
Yes. Import the zip file of the template as a new project, or upload its .cls and .sty files to a project. The engines are pdfLaTeX and LuaLaTeX; a template that requires XeLaTeX has to be adapted to LuaLaTeX.
How do I keep a backup of my thesis?
Save versions as you go, link the project to a private GitHub repository and download a zip of the project from time to time.

Keep reading

Start your thesis today

Create a free account and open a thesis template.

Start for free