Home » Services and Admin » ICT Service » Software » LaTeX

Introduction to LaTeX

This page is maintained by the software tutors. For errors and/or amendments please contact the current tutor supporting the program.



LaTeX is a free document preparation system, well suited for, but not restricted to, scientific articles, books, presentations and reports. The software is especially helpful for authors that extensively use figures, mathematical expressions and tables in their text. Also a number of packages exists that integrate the output from statistical software, such as R and STATA, with LaTeX. One of the main advantages of working in LaTeX is the extremely helpful user community that helps user to resolve their queries ( http://tex.stackexchange.com/). LaTeX runs on macOS, Linux and Windows.


LaTex provides endless opportunities for its users, and it is therefore difficult to provide a comprehensive introduction of the software. Therefore, this page only provides a very basic introduction of LaTex, the user is instead encouraged to visit CTAN for a comprehensive introduction to all the packages and possibilities out there ( https://www.ctan.org/pkg).




To install LaTex on your mac follow the instructions in the following video:



Linux and Windows

To install LaTex on your Linux or Windows computer you should follow the steps in the video:




There are numerous IDEs designed to make writing in LaTeX simpler, many of which are free and other that can be bought. For the interested, see:



Setting up a LaTex document

To typeset a LaTeX document consider the following lines of code:




Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut in dui efficitur, feugiat dolor vitae, suscipit lorem. Vivamus pharetra egestas velit vel tempus. Mauris ex justo, lacinia vel nunc et, congue suscipit ex. Proin congue imperdiet pharetra. Fusce magna velit, sagittis eu finibus ultrices, faucibus ac magna. Donec dictum ex at elit feugiat placerat. Sed vestibulum nec erat eget molestie. Nulla pulvinar lectus in tortor eleifend, eu mattis sapien vestibulum.

Integer nec dui blandit, dignissim lectus sit amet, efficitur quam. Donec facilisis nunc at risus suscipit, sit amet venenatis nisi volutpat. Nunc a enim sem. Nulla facilisi. Sed eu efficitur ipsum. Duis convallis eros sit amet lectus elementum hendrerit. Praesent egestas consectetur dui, vitae dapibus neque scelerisque et. Cras posuere vulputate neque non tristique. Sed convallis tellus at mollis dapibus. Morbi tempor eu est sit amet iaculis. Etiam sed volutpat libero. Praesent placerat imperdiet ligula, ut pulvinar dui finibus ac. Phasellus rutrum leo in pulvinar sagittis. Suspendisse consequat molestie massa sed porta.



The first line of code specifies the document class that will be used to produce the output.  A number of different document classes exist, the most commonly used are:

  • article
    • for articles in scientific journals, shorter reports, program invitations.
  • report
    • for longer reports containing several chapters
  • book
    • for books
  • beamer
    • for presentations


The text is written as plain text in LaTeX. Nevertheless, when typeset to PDF LaTeX will remove all unnecessary blank spaces, i.e., “This is a document produced in LaTeX” and “This               is           a           document              produced        in          LaTeX” will produce the same outcome. 


There are two ways to separate paragraphs in latex either by inserting a blank space between two paragraphs or by using the command “\\”, i.e.,


“This is a document produced in LaTeX.


It is a very good document.”




“This is a document produced in LaTeX. \\ It is a very good document.” produce the same outcome.


Adding author, title and abstract



% Preamble

\author{Name Surname}

\title{Here is the title}


% Content


\maketitle % prints the preamble on to the PDF

\begin{abstract} % begins the abstract environment

Here you write your abstract


Here is the main body of text.



The article document class provides the preamble functions author, title and abstract. The purpose behind using these preamble functions is that they already modified by the article class in such a way that they are different from the body of the text.


Adding sections and subsections





\section{First section}

The text of the first section goes here

\subsection{First subsection}

The text of the first subsection goes here

\subsubsection{First sub-subsection}

The text of the first sub-subsection goes here

\section{Second section}

The text of the second section goes here

\subsection{Second subsection}

The text of the second subsection goes here



Create a table structure







             Column 1 & Column 2 & Column 3 \\

             10 & 20 & 30 \\





A table in LaTeX is defined in the tabular environment in LaTeX. The curly brackets after the \begin{tabular} specifies the number of columns and if they should be left, centre or right justified. In the example the table will have three columns, the first left, the second centre and the third right justified. In the tabular environment you then fill in text for each columns separated by a & sign, and you end each row with a \\ sign. The example above creates the most simple table with three columns and two rows. For more advanced tables a good place to start is: https://www.sharelatex.com/learn/Tables


Include figures


\usepackage{graphicx} % This allows for the inculsion of figures



\begin{figure}[h] % !=overides latex, h=here, t=top, b=bottom, p=special page.


            \caption{This is an example figure}




This is a reference to the figure just included \ref{fig:test}




To include a figure in a latex document  you first have to load the package "graphicx". This is done by adding \usepackage{graphicx} to the preamble. The figure is then included through the figure environment. The square brackets indicates the placement of the figure in the text. After having called the figure environment you have the call the command \includegraphics, which takes one mandatory argument, and one or more optional arguments. The mandatory argument is specified within the curly brackets and specify the file name and the file path. If the figure is in the same folder as the .tex document you only have to call the file name. The optional argument(s) are called in the squared brackets, e.g., [width=.8\textwidth] tells latex to make the figure that has the width of 80% of the text width. Height and width arguments can also be specified in inches and centimeters.


The \caption command specifies the caption of the figure, it can be added below or above the \includegraphics command. To reference a figure in the text it is necessary to include a \label command within the figure environment. It is then possible to reference the figure in the text by using  the \ref command. By specifying the same argument as in the \label command the reference will be updates every time the text is typeset, even if new figures have been added before.


For more information on how to include figures, see: https://www.sharelatex.com/learn/Inserting_Images.




Page last updated on 21 September 2017