How to write a thesis using LateX

Dhananjay Muddappa
7 min readMar 19, 2019

--

This is my first blog post. This is also the first time I have ever written a thesis. It’s also the first time I’ve used LateX (pronounced LAY-tech). The point of this post is to get my thought process down in a systematic fashion and hopefully help students in my place in the future. Without further ado, let’s get into it.

Motivations to use LateX

Using MS Word can be a very frustrating experience. Picture this: you are a student trying to write a report about pollution. You add your figures and label each of them painstakingly as figure 1, figure 2 etc. Each time you insert an image Word decides to move the text around and you have to fiddle with the document to make it look consistent. Then twenty figure insertions later you realize that you need to add an image in between figure 3 and 4. You know have to relabel every single figure from 4 to 20. This is just one annoying experience in a myriad of annoyances that Word brings to an author. This is where LateX comes in.

LateX is a document preparation system that is used mainly by academics to write scientific papers. This is because it has many useful features such as the ability to automatically generate an index, bibliography and references with just a couple of lines of LateX code. The more I read about it and use it the more I think everyone should be using it over word processors such as Word. It allows an author to make great looking documents with just a few lines of very simple code. It does this by separating the presentation of the document from the content. This allows an author to focus on the content and let LateX worry about the headers, formatting, the page numbers, figure numbers and more!

So if LateX is such a godsend — why doesn’t everyone use it? Well firstly, it can be a bit of a pain to set up. Here’s where I come in to make it easier for everyone.

Setting up LateX

  1. Install LateX on your operating system using this link: https://www.latex-project.org/get/. This may take some time but the process is very simple.
  2. Install Atom: Atom is a gorgeous text editor that I use to program in Python and in our case to write LateX code. Atom has the capability to install packages to enable different tasks which is what we will do in the next steps.
  3. Install the latex packages: Go to the preferences section of Atom and click on Install in the sidebar. Search for “latex” and then hit the install button on the first package you see. This is the compiler for the latex file.
  4. Install the pdf-view package: Follow the same process as above. This package is used to display a generated pdf for the corresponding LateX code.
  5. Install the language-latex package: This package will highlight syntax in the code that you write and make it much easier for you.
  6. To test if everything has been set up properly- create a folder and save a file called “main.tex” using Atom. Copy and paste the following code snippet:
\documentclass{article}
\title{Title}
\author{Your Name}
\begin{document}
\maketitle{}
\section{Introduction}
This is where you will write your content.
\end{document}

Now go to Packages > Latex > Build or hit cmd-alt-b/ctrl-alt-b to run the code in this LateX file and a pdf will be generated in the folder that you created that looks something like this:

Let me know in the comments if you have any trouble with these steps or if anything is unclear!

Generating the title page for our thesis

Create a folder for your thesis with an exciting name like “Thesis”. This folder is going to host many files such as tables, figures and chapters of your thesis. Create a new file in Atom and save it as something wildly creative like “main.tex”.

I used these links to format my thesis, learn about LateX and make decisions such as the document class for the LateX file.

  1. https://tug.org/pracjourn/2008-1/mori/mori.pdf
  2. https://www.overleaf.com/learn/latex/How_to_Write_a_Thesis_in_LaTeX_(Part_1):_Basic_Structure

The first thing we have to consider is the document class. I selected the book class as it is very customizable and optimized for a long document such as a thesis.

\documentclass[12pt]{book}

Add this line to the starting of the main.tex file. Then to design the title we simply add the following lines:

\title{Thesis Title}
\author{Dhananjay Muddappa}
\maketitle{}
\begin{document}
\end{document}

So with these 6 small lines we just created our first title page and it should look like this:

Wasn’t that easy? Now let’s jump to creating sections for Acknowledgement, Abstract and future chapters of your thesis. All the following code needs to be placed between \begin and \end unless mentioned otherwise.

\chapter*{Acknowledgement}
Acknowledgement goes here
\chapter*{Abstract}
Abstract goes here

This code will create the pages without a chapter number. After these sections, we can insert a table of contents which will be followed by each of the chapters of our thesis. To generate a table of contents you need to first create a table, then painstakingly paste each chapter title into each row and ensure the page number is correct and keep moving around the table lines to ensure it looks consistent. Oh wait no, that’s if you’re using Word. To do it on LateX all you have to do is type in:

\tableofcontents

The tableofcontents command works like magic and automatically generates the chapter number, titles and page numbers. In future if you need to move around chapters or add more pages to a chapter, this table of contents will automatically update itself which is so useful!

Chapters

It’s considered good practice to separate your chapters from the main file. This ensures the main file will not be messy with all the content of our thesis chapters. To separate the files, first create a folder called chapters in the thesis folder. This folder will house all the chapters of your thesis for example “intro.tex”. To add the chapter to your main.tex file use the following code:

\chapter{Introduction}
\input{chapters/intro.tex}

The \input command will handle adding the contents of intro.tex to the main.tex file when we build it. The lack of asterix after the chapter command will number the chapters.

Open the file intro.tex and type in:

\section{Section 1}

When we build the main file (not the intro file) LateX will generate a pdf with this introduction automatically populating the table of contents as well as creating a chapter which will look like this:

Table of contents generated by \tableofcontents

Adding Figures

Let’s now add some figures to our introduction. To do this first for organizational purposes create a folder — images which will store all images for the thesis. Now to add images to our thesis we need to load the graphicx package and inform LateX where the images are stored using:

\usepackage{graphicx}
\graphicspath{{images/}}

Ensure these lines are put in before the \begin command for this to work. Now in the intro.tex file, after the text for section here’s how we can add an image:

\section{Section 1}
This is a lion.
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{lion}
\caption{A majestic lion}
\label{fig:lion}
\end{figure}

All the commands are pretty self-explanatory and the only thing you have to ensure is that the image is present in the images folder. Here’s how my introduction looks now:

The image has been automatically numbered according to the chapter and section that is part of and the caption is nice and centered. It’s important to label each figure so that we can easily refer to the image later on like so:

A nice image of a lion running can be found see \ref{fig:lion}

LateX will automatically fill in that \ref code with the reference section. Again, this is amazing! We no longer need to worry about the exact figure numbers as LateX will just take care of it.

To create a list of figures, after the line \tableofcontents in the main file, add the line:

\listoffigures

It’s just that easy!

Adding Tables

Tables are a great way to display a bunch of data that everyone skips over. Here’s how you can add them to your thesis:

\begin{table}[h]
\centering
\begin{tabular}{l|l|l}
Name & Status \\
\hline
Cecil & Dead\\
Simba & King
\end{tabular}
\caption{Famous Lions}
\label{tab:famous_lions}
\end{table}

The command {l | l | l} draws the vertical lines.

\hline is used to draw a horizontal line to separate the title from the values.

Remember to add a label so you can refer to the table later if needed!

Here’s how the table looks:

Future Releases

I just started writing my thesis and I think this is a good foundation to get the bulk of it done. In future blogs I will post about how to make a bibliography, references to sources, customize the title page further and more!

Thanks for reading! Please comment with any feedback!

--

--