5 cool reasons to use LaTeX

TexPad on OSX

One of the differences between undergraduate level study and masters level study is the amount of report writing you do. I can only think of two times in my bachelors degree that I wrote a significantly sized report — and one of those was my dissertation. So far in my MSc I am yet to have handed in a coursework without a report.

During he early stages of my third year I discovered a tool (language?) called \LaTeX, however it would be yet another thing to learn alongside my 4 large modules and everything I needed to learn to do my dissertation, so I gave it a miss. This year I decided I would finally give it a go, see what all the fuss was about and see whether it could really replace a Microsoft Word shaped hole in my life.

It did. LaTeX offers a lot of advantages over Microsoft Word, LibreOffice and many other Word Processors, some of the more interesting ones I’ll talk about here. (Note: this isn’t a tutorial, just some observations — so if you don’t know anything about LaTeX I recommend you look it up online first)

1 – Better Source Control

\LaTeX produces full PDF output, including tables images and other complex objects, from declarations made in plain text. If you’re not quite sure how to think about \LaTeX sometimes it’s best to think of it like a Markup language — such as HTML — in which you tell it what you want in plain text and it creates the graphical representation.

Git Diff of LaTeX

Git Diff of LaTeX

Because all of the declarations are in plain text it makes source control really easy. Above you can see an image of a git diff in the Github application on OS X. Showing the difference between binary (.doc) word files is impossible, showing differences between Open Office XML files is difficult to decipher at best.

2 – Include code and automatically Syntax Highlight it

Using the listings package you can pull it code from other files on your system and automatically syntax highlight it using colours of your choice. No more copy and pasting code into your report over and over when you make changes.

First use the listings package, and load the programming language(s) you would like to include in your document. Optionally include the XColour package for some more interesting colours to use to syntax highlight your code.

% In your preamble

Then set up the colours you want keywords, comments and strings etc to appear as, as well as some basic settings such as line wrapping. You can redefine these at any point in your document if you need to change the colours for different bits of code for any reason:

commentstyle = \ttfamily\color{Gray},

Now you can just include any code files…


or any inline code snippets you like

//This is a comment in Java
System.out.println("I love printing to stdio");

I personally prefer to include from files, so that I can edit the code that is being displayed in my preferred editor for that language. Additionally, if you are required to dump all of your source code in a report, as was required of me recently, this is a nice way to ensure any updates to that source code are displayed in your final document without any work on your behalf.

3 – Run a Script from inside your documents

If you run a Unix-like operating system with a bash shall, such as Linux or OS X, then you can compile your \LaTeX documents with the --shell-escape flag which allows you to embed bash scripts inside your document that get run when the document gets compiled.

I recently used this to run a bash script which counted the number of words inside the document that was being compiled, meaning I could have an always accurate word count printed inside the document. Handy.

I could also envisage this being useful to generate pretty PDF reports of services on a server or other systems. An guide on how to achieve something like this is available at CTAN.

4 – Easily cite other peoples work and change reference style

Using the Bibtex bibliography subsystem for \LaTeX you can write your references in a simple, almost JSON like, syntax — as shown below:

	author = {Vesselin K. Vassilev and Julian F. Miller and Terence C. Fogarty},
	title = {The Evolution of Computation in Co-evolving Demes of Non-uniform Cellular Automata for Global Synchronisation},
	year = 2007,
	url = {http://citeseerx.ist.psu.edu/viewdoc/download?doi=},
	urldate = {2015-01-25}

When you come to cite this article in the body of your document you can just write \cite{demes} and it will print out the correct citation style as specified in your documents preamble, and print the full information about the article in the correct style in your bibliography. At York we use the IEEE citation system, and so the above is output like so:

Inline citation IEEE

Inline citation IEEE

Bibliography IEEE

Bibliography IEEE

However, if I change this one line in my preamble from:

\usepackage[backend=biber, style=harvard]{biblatex}


\usepackage[backend=biber, style=authoryear-ibid]{biblatex}

Then my references and citations show up in the Harvard style, as I used in my final year project at Hull. No retyping citations.

Harvard Style Reference

Harvard Style Reference

5 – Write and Read Anywhere

Because the ‘source files’ for \LaTeX are just plain text, and the output files are PDF files everyone, on any operating system, can make changes to and read the output of your documents. No more worrying about what version of word someone has, or whether or not they’ll have Calibri in their font library. Furthermore there is a LaTeX compiler available for almost any machine.

There is an abundance of editors for  \LaTeX including features such as syntax highlighting, autocomplete, automatic packing including and simplification of the PDF generation process. My personal favourite is TexPad.


I hope I will have convinced at least a few of you to try out LaTeX when you’re next writing a report for university of work. Let me know how it goes if you do!



Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s