Getting started with LaTeX

LaTeX is a TeX macro package, originally written by Leslie Lamport, that provides a document processing system. LaTeX allows markup to describe the structure of a document, so that the user need not think about presentation. By using document classes and add-on packages, the same document can be produced in a variety of different layouts. [LaTeX FAQ]

Probably one of the best ways to start a new LaTeX document is by using an already existing template. This downloadable archive contains the basic structure of a master’s thesis. Within this archive, you find different files:

  • thesis.tex is the main file containing the content.
  • thesis.bib contains the references (to literature) used in thesis.tex. To add new entries, you might be interested in the following overview of BibTeX entry types
  • Makefile allows you to produce a PDF out of your sources by calling “make pdf”
  • images is a directory which contains one figure included in thesis.tex

Instead of using the make utility with the included Makefile, you can also use the “latexmk” for compiling your document. latexmk runs commands such as pdflatex or bibtex (also contained in the Makefile) to build the LaTeX document. As latexmk is a perl script, it requires perl to be installed on your computer. This should be the case if you run Linux. For Windows, you might want to use ActivePerl or install perl under cygwin. Of course, you can also manually type: pdflatex mydoc; bibtex mydoc; pdflatex mydoc; pdflatex mydoc; … This neither requires a Makefile nor Perl for the latexmk command, but I guess you can see the disadvantage 😉

latex or pdflatex?

To compile the LaTeX sources into a document, you can use different backends, primarily latex or pdflatex. The question at the beginning is: “What is the difference?”

  • latex: This is the “old” way of compiling a LaTeX document. It produces a DVI-file that can be converted to a PS-file via dvips or a PDF file via dvipdfm, for example.
  • pdflatex: The pdflatex command directly produces a PDF file as output. Some options such as bookmarks in the PDF file can only be produced by this command.

Unfortunately, the there are incompatibilities between the two commands. Besides some commands that are only applicable to pdflatex, there are differences in the file formats you can use for images: You have to use encapsulated postscript (EPS) files for latex. Depending on your installation, non-EPS files such as TIF, GIF, or JPEG may have to be converted to EPS files before inclusion, but your installation may support them natively as well. pdflatex natively supports inclusion of graphics as PDF, JPEG, and PNG. This is a common source why something might compile with latex, but not with pdflatex—or the other way around.

To use latexmk with pdflatex, call it with the “-pdf” parameter.

LaTeX on Linux

Linux distributions already provide everything you need to start writing with LaTeX. The packages you need to install are called something like tetex, tetex-doc, tetex-latex, etc. – and of course “make” to use the Makefile provided with the LaTeX example. You can write your LaTeX document with any text editor – preferrably with Vim ;-). Kile is a more integrated environment, specifically targeted at LaTeX.

LaTeX on Windows

To produce PDFs or PostScript files from LaTeX sources on Windows, you can install MiKTeX. While you still can also use any text editor (preferrably Vim 😉 ) to edit LaTeX files, the free TeXnicCenter might be good solution if you look for a more integrated solution. You can also have a look at the WinEdt shareware program.

Alternatively, you can also use Cygwin. In this case, you can use LaTeX the same way as under Linux.

Online Editors

Meanwhile, it is possible to create your LaTeX documents online – even with collaborative writing support. You may want to try Overleaf if you are interested in getting started with LaTeX quickly without any setup.

Further resources