Getting Started With LaTeX

Created On:

A lot of people have asked me recently on how they can get started with LaTeX. Unfortunately Googling “getting started with LaTeX” results in outdated information, or information targeted for users who are living in the terminal era. None of the results are helpful for a person who wants to install LaTeX and produce their first document. This post will show you how to get LaTeX on your computer and how to produce your first document.

Installing LaTeX

The first thing any user of LaTeX must understand is that there are many decades of legacy software and backwards compatibility associated with LaTeX. As a result installing LaTeX requires at least 2.5 GB of disk space. This is because LaTeX is bundled as distributions which contain almost every single LaTeX related tool, font, package, etc that you might need ever. Trying to fight this will require more knowledge about LaTeX, which is something you don’t have if you are reading this post.

The best LaTeX distributions are maintained by the TeX Users Group. They have two distributions: TeX Live for Linux and Windows users and MacTeX for Mac OS X users. Linux users simply have to download a tarball and run the install-tl script. Windows users have to download a zipfile and run the install-tl.bat script. OS X users have to download 2.1 GB package and execute it.

The installation involves downloading everything you will need to ensure you have a good internet connection. Once the installation is complete you need to ensure that LaTeX binaries are in your $PATH. If you open a command prompt and you cannot run latex or latexmk you will need to add /usr/texbin or similar to your $PATH.

There are two important things to note when after installing TeXLive or MacTeX. The first is that the tlmgr tool is provided which will enable you to update the current installation with newer packages. This is incredibly handy if you run into a bug with any package you are using. It is very likely that the bug has already been fixed upstream and updating will fix your problem. Secondly, each installation will be updated until the next version of the distribution is released. Therefore if you install TeXLive 2012 now you will receive updates via tlmgr until TeXLive 2013 is released. When TeXLive 2013 is released you will need to install it over your TeXLive 2012 installation to continue to have the latest packages.

Writing Your First Document

One LaTeX is installed you can write your first document. The typical first document looks as follows:

\documentclass[11pt]{report}

\begin{document}

This is my first LaTeX document.

\end{document}

If you copy and paste the above into its own file doc.tex. You will be able to compile it into a PDF by running latexmk -pdf doc.tex. If you have successfully installed LaTeX you will a doc.pdf in the same directory which contains the text “This is my first LaTeX document.” Note that the compilation process will produce many temporary files in the same directory. You can safely ignore these temporary files.

You should be always compiling your LaTeX documents with latexmk -pdf and not latex, biber, pdftex or whatever else you read on the internet. The reason is that more complex LaTeX documents will involve multiple compilation runs or other horribly confusing steps. Fortunately latexmk deals with all of that work for you and the -pdf flag will ensure a PDF is produced.

Next Steps

The next step would be to read the wikibook to understand how to do common tasks in LaTeX such as sectioning, tables, bibliographies, etc. For more exotic tasks you should be searching and asking questions on the TeX.SE.


Note: Disqus has been removed from this blog, but below is a copy of some of the comments on this post for posterity.


Ming-Ho Yee

Excellent post! I actually started with the The not so Short Introduction to LaTeX2e, but that guide is more about using LaTeX and less about setting it up. However, it is something I'd recommend for "Next Steps," even before the wikibook (which I mostly use as a reference).

Zameer Manji

I think that "The not so Short Introduction to LaTeX2e" is a great reference book but not suitable for the next steps of a person who just installed LaTeX. The document covers far too many things in too much depth to be useful in writing a first useful document.