LaTeX (pronounced LAY-tek or LAH-tek) is a tool for creating professional-looking documents, reports, books, CVs, and presentations.
In LaTeX the document and the output are separated. This means you only focus on the contents of the document, and your computer will handle the formatting, which saves a lot of work.
The main advantages of using LaTeX are that it is great at handling complex formatting such as mathematical formulas, table of contents, figure positions, bibliographies and more. Another advantage is once you’ve written the content of your document, you can change your documents appearance without any weird formatting consequences (I’m looking at you Microsoft Word).
The obvious disadvantage is that you have to do some coding to use it, which has a learning curve!
By the end of this workshop you will:
It might feel like there is a lot to explore. However, we split it into separate sections to make it easier for you to work through. We hope you enjoy it!
LaTeX has been around a while, and therefore there are lots of options available to write and make LaTeX documents. The easiest way to get started with is Overleaf (formally ShareLaTeX), which has a clear user interface and will spare you from software and package installation. Overleaf is an online interface to write LaTeX code and produce documents; the syntax used is the same as any other LaTeX editor.
To get started you will need to make an overleaf account.
The environment you will see when you open a project in Overleaf. This is the ‘Example Project’ template. Key things to note are the top right with the main.tex and frog.jpg which are your files. Middle is your tex file where you do all your writing. Right is the output.
A friend sent you a really cool article on the gender pay gap in the UK and you want to edit it to add some of your own ideas or research. You remember that you can do this with Adobe, but they are asking you to pay for the software, we can’t afford that!
You think of a creative solution…you’ve been meaning to learn LaTeX so how about we write the document into LaTeX so we can edit and change what we like?
You’ve emailed the author to ask them about the images and if you can use their article. They respond enthusiastically giving you a link to the files that has the following resources that will help you make your document:
Click link to access the files
Once uploaded, Overleaf will present you with a split-screen. On the left side you will see LaTeX code. On the right side you will see the result of running the code, i.e., the way you report will look like. As you can tell, it requires some work…
Now you have the document open in Overleaf we can take a quick de-tour for a run through of the general ideas and rules of LaTeX.
LaTeX documents have a two part structure. The first section is
called the preamble, and the section section is where your
document starts (look for the \begin{document} syntax).
The preamble is the set up, where you specify:
\documentclass[11pt]{article} syntax which tells you what
you are working on\usepackage{}
syntax. How many packages are we using in our template?Where your document starts, after \begin{document}, is
where all your writing, figures, tables, sections and so on will go.
The syntax of LaTeX has a few specific rules which are outlined below:
\newpage\title{Joe Bloggs}\documentclass[11pt]{article} where 11pt is the argument
for the size of the text25\%Now we have the a basic document we need to build up that title page!
In Overleaf take a look on the left panel where the code is. Can you spot any code that would define a title, the authors, the date, and an abstract?
Using the gender_pay_gap.pdf file as your example:
Hint: Looking at the command \title{your title here}
what is the output of this code? Check the panel in the left and look at
your title. How would you change the text of the title?
We have the nice looking title page, which is a great start!
Next we set up the contents page which should include a table of contents, list of figures, and list of tables. We might not have added tables or figures yet, but we will soon.
You are very particular and notice in our document we have numbers next to our sections but the document we are copying doesn’t, how annoying! You do a quick online search and find this answer in a stack exchange thread which seems to solve your problem, yay! The simplified version of this is as follows:
\section*{Introduction}
\addcontentsline{toc}{section}{Introduction}
For the next tasks we will need to upload the resources the author sent us into Overleaf. Using the upload button (on the upper left hand side of Oveleaf, just under menu) add the following files to your Overleaf project:
Once uploaded, you’ll be able to see the files in your project (on the left to your code). Try clicking on them to view them.
Note that once you recompile your document you will get the following
error: Package natbib Warning: Empty ‘thebibliography’
environment on input line 3. We will be adding our references
later which will fix the issue, but if you want to solve this now add
\nocite{*} before
\bibliography{references.bib}.
Great, we have a title page and a contents page. We are in a good place to start adding the content to our document.
The introduction we are copying has links and an image, exciting!
pay_gap_bot.png image file
in your projectNote that to make the image the same as the example something like
this will work:
\includegraphics[width=0.7\linewidth]{pay_gap_bot}
You might notice when you Recompile the gender pay gap bot figure now appears in your list of figures, cool!
Next up, the methods section which has more new elements in equations and citations.
Equation hint 1: The easiest way to replicate this
equation is to use math like:
\begin{math} your equation \end{math}
Equation hint 2: LaTeX has shortcuts for common
mathematics symbols like plus and divide. Plus is \sum and
divide is \div. What do you think multiplication would
be?
If you added \nocite{*} on task 3, you can remove it now
if your references are not appearing.
Reference hint 1: there are two ways to cite in
LaTeX using either \cite{} or \citep{}. It
looks like our example has used \citep{}.
Reference hint 2: each reference in the
references.bib file has a label which you use within the cite
command like \cite{ggtext}.
Reference hint 3: if you are interested in having
numbered references you can add in \setcitestyle{numbers}
above \bibliographystyle{apalike}. This useful Stack Exchange thread has more
information.
The LSE Library team offers a lot of support and advice on citing and referencing your own work. Information on this support can be found on the library web page.
This template, rather helpfully, has been set up to handle citations
and references, following the bibliography guides on Overleaf. If you are starting
off from nothing, first you’ll need these two lines somewhere before
\begin{document}:
% this is for the bibliography
\usepackage[]{natbib}
\bibliographystyle{apalike}
Note that the command \bibliographystyle{apalike} tells
LaTeX what referencing style to use, which in this case is the
American Psychological Association style. There are many
possibilities, so before choosing a style for your own work, you should
check with your department or librarian. A full list of bibliography
styles is available on this
website.
And later in the document you’ll need the code below which builds the
reference list at the end of your document. This should go just before
your \end{document}.
% end with the bibliography
\newpage
\bibliography{references.bib}
Note that for this workshop we are using the natbib bibliography referencing package. There are two other options, biblatex and bibtex. The natbib or biblatex options are the easiest to use and what we would recommend.
Now when you Recompile you’ll have a reference page, very exciting!
However, you notice the colour of the citations, url links, and the contents page look different to our pdf document we are copying, we can’t have that!
LaTeX comes to the rescue again. We can change these with the
\hypersetup{} command! At the beginning of your
main.tex file you’ll see this command. Change the colours of
hyperlinks as follows:
While you are looking in the preamble section of the document you may have noticed the following LaTeX code:
% change font to Roboto light
\usepackage[sfdefault,light]{roboto}
\usepackage[T1]{fontenc}
In this code we are essentially changing the default LaTeX font to use Roboto, which is the standard font used around LSE. To change the font we used this font resource. Through this we found Roboto, picked the light style and followed the usage example it detailed.
We finally get to the good stuff, our results page! Some new features you notice are a table, footnotes, and figure referencing.
paygap.png image file. Be
sure to pay attention to the positioning of the figure, you might need
to try different positions till it looks rightHint: You might need to edit the table to make it look the same as
the pdf. Some things you can try are adding or removing
\hline arguments or removing the lines in the in the begin
tabular command like the examples below:
% line between columns
\begin{tabular}{l | c}
% no line between columns
\begin{tabular}{l c}
We are almost there, just the discussion left. Two new features here are a quote and a list.
\begin{quote} `` your quote '' \end{quote}Wow, we’ve just taken a pdf document and converted it to LaTeX!
Download a copy for yourself to your computer (download to pdf button is next to recompile button).
Please complete the survey which helps us improve our training
The Digital Skills Lab will be running a follow up workshop about report writing with Markdown, using a next generation software called Quarto. Quarto is a tool for making dynamic documents with R/Python/Julia/JavaScript which combines markdown, a lightweight markup language that is an easy-to-write plain text format, YAML, and sections or chunks of embedded R/Python/Julia/JavaScript code. This is powerful as it allows you to write reports or presentations that contain your code, as well as the documents being easy to write due to the simplicity of markdown, and being well formatted by default like LaTeX.
LaTeX has a great open-source community, and their are thousands of great templates, packages, and extensions out there which you can use depending on your needs. Two good places to start looking for templates are the LaTeX Templates page and the Overleaf Templates.
It is important to note you can also collaborate with others using Overleaf, which is detailed in this webpage.
Write your CV using LaTeX! LaTeX is a great tool to write your CV due to its control over formatting and all the many templates available.