Introduction to LaTeX

Last updated:

A workshop for doctoral students at the University of Malta

License: CC BY-NC 4.0

This is the webpage for a workshop offered at the University of Malta to all doctoral students, given by myself and Dr. Jean-Paul Ebejer. Here is the corresponding course description webpage. If you find any errors or typos in these notes, please let me know by email.

  • Installing LaTeX on your machine (below) [PDF]
  • Lecture 1: Basics [PDF Slides]
  • Lecture 2: Maths and Templates

Installing $\rm\LaTeX$ on your machine

$\rm\LaTeX$, pronounced lay-tek or lah-tek (but not lay-teks!), is a programming language. Thus like any other programming language, when we speak of “installing” the language, what we actually mean is installing a piece of software called a compiler for that language. A compiler translates the code we write in the $\rm\LaTeX$ language into a page description language, such as PDF or postscript, which can then be viewed in PDF readers such as Adobe Acrobat.

image/svg+xml

The compiler we will be using to produce PDF documents from $\rm\LaTeX$ source code is called $\rm pdf\LaTeX$. There are different ways to get $\rm pdf\LaTeX$, and these differ from one operating system to another.

In truth, the situation is not as simple as we have made it out to be. $\rm\LaTeX$ is a document preparation system which runs on top of Donald Knuth’s $\rm\TeX$ typesetting system, and thus we actually need a $\rm\TeX$ compiler too, among other things. Luckily, programs called $\rm\it\TeX$ distributions exist which bundle together all necessary parts needed for a working $\rm\TeX$ system, and nowadays these all contain $\rm pdf\LaTeX$.

So now we will describe how to go about obtaining a $\rm\TeX$ distribution for different operating systems.

For Linux Users

For Linux, the best option is to install the texlive distribution. This distribution comes in various forms, but the best for a beginner is one of the following:

  • texlive-latex-extra (404MB)
  • texlive-full (4.7GB)

The former will download most of the things we need, the latter will download practically all commonly used $\rm\LaTeX$ packages onto your system (including edgy things like Japanese language packs, etc.). The choice is mainly a matter of disk space on your machine.

If you use a Debian based Linux distribution (such as Ubuntu), then open a terminal (Ctrl + Alt + T), enter the command

    sudo apt-get install texlive-latex-extra

(or texlive-full, based on your choice) and hit enter. (If you use other versions of Linux, such as Arch, then look at the ArchWiki for more information.) This will download the relevant packages and install the distribution. When you’re done, run

    pdflatex

in a new terminal, and you should get an output like

   This is pdfTeX, Version xx (TeX Live 20xx/Linux Distro)

Hit Ctrl + C to exit.

If this method of installing texlive isn’t working for you, there are other options available.

Next, you’ll need an editor. Any ordinary text editor such as vim will do, but to keep compilation simple, a $\rm\TeX$ IDE is preferable. You can download $\rm\TeX Studio$ on Debian based distributions by running the following commands in order (hit enter after each one).

   sudo add-apt-repository ppa:sunderme/texstudio
   sudo apt-get update
   sudo apt-get install texstudio

Once this is done, you should be able to find the program $\rm\TeX{}Studio$ installed on your system. Open it up, create a new $\rm\TeX{}$ file (Ctrl + N) and enter the following code:

\documentclass{article}
\begin{document}
    Aw dinja!
\end{document}

and hit F5 on your keyboard. You should see a document output with the text “Aw dinja!”.

For Windows Users

On Windows, there are two main contenders for the choice of $\rm\TeX{}$ distribution, namely, texlive and $\rm Mik\TeX$. The latter has the advantage that it downloads packages which are needed on the fly (over internet) rather than downloading thousands of packages which you may never use upfront, like texlive does. For the sake of simplicity, we suggest you download texlive for now, but you can take a look at $\rm Mik\TeX{}$ if you like.

texlive comes in various forms, but the best for a beginner is one of the following:

  • texlive-latex-extra (404MB)
  • texlive-full (4.7GB)

The former will download most of the things we need, the latter will download practically all commonly used $\rm\LaTeX$ packages onto your system (including edgy things like Japanese language packs, etc.). The choice is mainly a matter of disk space on your machine.

You can install texlive by downloading the install-tl-windows.exe file from this webpage. Run the installer, and it should guide you step-by-step on the installation (the usual Next, Accept, Next, Finish procedure). At some point you will be asked which of the two versions (extra vs. full) you prefer.

Once you’ve installed texlive, you’ll need an editor. Any ordinary editor such as vim or notepad++ will do, but to keep compilation simple, a $\rm\TeX{}$ IDE is preferable. You can download $\rm\TeX Studio$ from here. Run the installer, and it should guide you step-by-step on the installation (the usual Next, Accept, Next, Finish procedure). Once this is done, you should be able to find the program $\rm\TeX{}Studio$ installed on your system. Open it up, create a new $\rm\TeX{}$ file (Ctrl + N) and enter the following code:

\documentclass{article}
\begin{document}
    Aw dinja!
\end{document}

and hit F5 on your keyboard. You should see a document output with the text “Aw dinja!”.

For Macintosh Users

The $\rm\TeX{}$ distribution for Macintosh is called $\rm Mac\TeX$. You can download it by clicking on macTeX.pkg on this webpage. After downloading, move the file MacTeX.pkg to the desktop or another convenient spot, and double click it to install. Follow the straightforward instructions. Installation on a recent Macintosh takes about ten minutes.

At the end of installation, the installer will report “Success.” But sometimes, the installer puts up a dialogue saying “Verifying…” and then the install hangs. In most cases, rebooting the Macintosh fixes this problem. After the reboot, install again.

Once you’ve installed $\rm Mac\TeX$, you’ll need an editor. Any ordinary text editor such as vim will do, but to keep compilation simple, a $\rm\TeX$ IDE is preferable. You can download $\rm\TeX Studio$ by clicking “Download” on this webpage, and scrolling down to the “Mac OS” section. Run the installer, and it should guide you step-by-step on the installation (the usual Next, Accept, Next, Finish procedure). Once this is done, you should be able to find the program $\rm\TeX{}Studio$ installed on your system. Open it up, create a new $\rm\TeX{}$ file ( + N) and enter the following code:

\documentclass{article}
\begin{document}
    Aw dinja!
\end{document}

and go to and ToolsBuild & View from the menu. You should see a document output with the text “Aw dinja!”.

If you got stuck: An Online $\rm\bf\TeX{}$ IDE

Alternatively, you can make use of Overleaf, an in-browser IDE for $\rm\LaTeX{}$ which requires an active internet connection. Once you register for an account, create a blank project, (call it anything you like), and enter the IDE. Delete the code in the middle column, type

\documentclass{article}
\begin{document}
    Aw dinja!
\end{document}

and hit Recompile.