Revision History
Revision 0.120 November 2005AJS
This tutorial was written in 2001, at that time I had little LaTeX experience. Please bear this in mind, and please do not consider this revision as an indicator of the quality of the entire tutorial set. Since 2001 I have written many documents in LaTeX and so if time permits I will update this tutorial.

Table of Contents

1. Introduction
2. LaTeX Installation
2.1. Install A TeX Distribution
2.2. Install GhostView and GhostScript
3. Latex ToolUse
3.1. Conversion To DVI
3.2. Converting DVI to PostScript
4. LaTeX2e article Template
5. LaTeX Examples
5.1. Environments
5.2. Inserting Images
5.2.1. Getting XFig
5.3. Tables
6. Advanced Template
7. References and links you may find useful

LaTeX (pronounced Lay-Tex) is a macro package originally created by Leslie Lamport for the document generation language TeX (pronounced like the tech in technology). TeX was created by Donald E. Knuth around 1970 in order to provide him with the necessary tools to produce his legendary The Art Of Computer Programming series of books (which are still being written) and various other books. A more comprehensive description of TeX can be found at and the TeX FAQ can be found at TeX is famous for it's excellent mathematical and scientific typesetting capabilities. TeX is also Turing complete.

TeX is a program which manipulates the TeX language used to describe the structure of a document. A TeX document be processed in order to generate printable output, this is achieved using TeX the program. Other tools such as dvips are then used to convert the DVI(Device Independent) output produced by the TeX tools to a device dependent Postscript format.

LaTeX is a layer on top of TeX t abstract functionality and more. Author-friendly development is coupled with an emphasis in generating high quality output. LaTeX2e (pronounced Lay-Tech-Two-E), is the latest development of LaTeX available at the time of writing. You can find a lot more about LaTeX and LaTeX2e at This tutorial will focus on LaTeX2e, the reason for the weird capitalization in TeX, LaTeX and LaTeX2e is because the ASCII characters are representing Greek letters. Images of how these words should actually look are shown below:

Leslie Lamports Book LaTeX: A Document Preparation System, Second Edition is still regarded as a very worthwhile reference, any serious LaTeX user should consider obtaining it.

It is assumed that you know how to setup environment variables and install software on your operating system, for a comprehensive guide to doing so for Windows see Configuring A Windows Working Environment, for Unix see Configuring A Unix Working Environment Follow these instructions to install JDOM:

Installing a TeX distribution should suffice here as it is more likely than not that any TeX distribution you care to install will install the LaTeX2e macro extensions by default.

If you need extra packages for your TeX distribution, it is extremely likely that these can be obtained from CTAN (Comprehensive TeX Archive Network). The UK mirror of this file tree is hosted by Cambridge University and can be found here

A basic knowledge of operating system concepts, such as changing environment variables, is assumed. Detail pertaining to this topic can be found in the documents: Configuring A Windows Working Environment and Configuring A Unix Working Environment.

For the Windows user, TeXLive ( is an excellent all-in-one TeX package that this tutorial will be using. Download it and follow the installation instructions, change the installation directory to something suitable; C:\tools\TeXLive\. Install the Generic recommend TeXLive scheme but check the box that says “I want to customize the selected scheme”. The next screen presents the user with a list of all possible packages on offer. Make sure you select the LaTeX package if it is not already selected.


During the TeXLive setup, when on the Root of installation page I advise you only to change the “Root directory” field (the others will update automatically, leave the Extra TeXMF tree and Home TeXMF Tree fields alone. In other words, do not check the box that says “You can change the default configuration for the main directories.”.

If you are using Unix there are a number of schools of thought on which is the best TeX distribution to install on your system, a good one is TeXLive. The Unix distribution of TeXLive is available to download off ftp at or is available on CDROM. The CDROM is available free and can be downloaded as an ISO-Image to be burned or you can order it from a UK based supplier. If you don't want to install TeXLive you may want to consider teTeX which is available from ftp. Your Unix distribution may have came pre-installed with TeX/LaTeX, perform this test to check. This test can also be used to check if you have installed a distribution correctly. Create the document test.tex:

blah blah blah

Process this with the command:

latex test.tex

If all goes well, the following will be output:

This is TeX, Version 3.14159 (Web2c 7.3.7x)
LaTeX2e <2001/06/01>
(c:/Program Files/TeXLive/texmf/tex/latex/base/article.cls
Document Class: article 2001/04/21 v1.4e Standard LaTeX document class
(c:/Program Files/TeXLive/texmf/tex/latex/base/size12.clo)) (./test.aux)
[1] (./test.aux) )
Output written on test.dvi (1 page, 232 bytes).
Transcript written on test.log.

In order to view and print PostScript files it is necessary to install GhostScript and GhostView.

If you are using Windows, download GhostScript from and GhostView from Run the executables to install the software.

GhostScript doesn't add the lib or bin directories to your path when you install it on Windows (because it expects you to be using the GUI). Which means that you cannot access the 31 auxiliary tools from the command line. To be able to use them, add the lib and bin directories to your PATH environment variable (prefix lib and bin with the base directory where GhostScript was installed).

If you are using Unix, Download GhostScript from: and GhostView from: you may also find this resource page useful:

Notice that you can download either the sources or the rpms, choose whichever method you feel most comfortable with. Install the software.

To convert a tex file to DVI:

latex blah.tex

Which outputs:

blah blah blah...
Output written on blah.dvi (1 page, 676 bytes).
Transcript written on template.log.

You may have to execute the command several times to ensure that yourfile.aux is correctly updated with page numbers and file references etc, the recommendation is "at least twice". This will generate blah.dvi, which as explained, is a device independent format, you will need to convert it to something else in order to print it (well actually, you can print it from DVI if your tools/printer support it). If errors are encountered, you will be presented with a prompt in the form of a question mark, type another question mark and hit enter and the following options will be displayed:

Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, E to edit your file,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.

Generally you should try S or R to suppress errors and let TeX handle them as it sees best, or you could learn TeX inside out and deal with the errors yourself, you will probably have to deal with errors some day. Thankfully the error-output specifies the line the error occurred on and you have the option to edit the file there or insert something. For more information about dealing with errors see the section entitled The joy of TeX errors in the TeX FAQ:

You can view the DVI file with WinDVI in Windows, assuming a TeXLive installation, this can be done by double clicking on the file or typing:

windvi in.dvi

If you do not have WinDVI, obtain it. If you are using Unix then you can use XDVI:

xdvi in.dvi

If you do not have XDVI, obtain it from

Here is an extremely simple LaTeX2e article template to get you started:

%This is a comment
\documentclass[a4paper,12pt]{article} 1
\usepackage{fullpage} 2

\begin{document}  3

\title{A latex Template}
\author{Jimmy Riddles}
\date{\today}   4

  This is an abstract  5

\tableofcontents  6

\section[Optional TOC Title]{Otherwise this is used}
This is a section

\subsection[Optional TOC Title]{Otherwise this is used}
This is a sub-section 7

\subsubsection[Optional TOC Title]{Otherwise this is used}
This is a sub-sub-section

\end{document} 8


Three types of document class are available as standard in LaTeX2e:

  1. article, articles, essays and other short pieces of text.

  2. report, reports, theses and other medium length pieces of text.

  3. book, for actual books.

The document class defines the structure of the document and the set of elements that are allowed in it and how certain elements should be displayed. A document class element takes the generic form:


In this template the options a4paper and 12pt are used to specify a4 sized paper and a font size of 12pt, 10pt is the default font size. A particular document class can have options which are unique to it.



Packages provide extra functionality to the production of LaTeX documents. In this template example the package fullpage has been imported which changes the default margins to 1inch each side. The generic form of usepackage is:


More than one package may be specified, either separated by commas in a single usepackage statement or by using multiple usepackage statements. The options provided are relative to the packages imported. Options declared in the documentclass(described above), will effect any packages that are imported that can use the options declared.



The actual document is opened with a \begin{document} element, this is an example of an environment.


\title{A latex Template}
\author{Jimmy Riddles}

To create a title one must define at least the title and author elements, date is optional and is sometimes included by default anyway, even if not specified here, defaulting to the current date. \maketitle is then called to produce the title at this point in the document.


This is an abstract

An optional abstract section may be defined.



\tableofcontents will generate a table of contents at the point it is used based on the titles given for the sections defined in the document body.


\subsection[Optional TOC Title]{Otherwise this is used}
This is a sub-section

Sections and sub-sections add structure to a document and assist in the generation of tables of content(TOC). One may specify the title to be used for the section in the TOC in the options section ([ ... ]). If this section is not included, the section title will be used, which is the title that will appear at this point in the document for this section.



Just as the document was opened with a \begin{document}, it is terminated with a \end{document}.

When the above document is processed with LaTeX, the resulting DVI file looks like this:

It is recommended that you read A not very short introduction to LaTeX2e, available from, you will probably want the PDF file at the bottom. This provides many examples of how to get things done with LaTeX2e, it is an excellent document written by Tobi Oetiker, Hubert Partl, Irene Hyna and Elisabeth Schlegl. I am not going to replicate that document here. It covers almost everything you could possibly want to do with LaTeX. You can even download the source code to see how the document was produced.

One of the most common ways to use images within LaTeX is to use eps(encapsulated PostScript) images. In order to convert your files to this format you will have to install some kind of image manipulation program, The GIMP(GNU Image Manipulation Program) is a free image manipulation program with the capability to do this conversion (it would probably be overkill to install this program just to do this but the program is very good so you should install it anyway). It is available for both Unix and Windows, the Unix version can be obtained from the GIMP homepage: The windows version can be obtained from here:

The basic template for inserting an image is shown below:

\usepackage{fullpage, graphicx}

There are many other options that can go with this, but the key points are the epsfig package import and the \epsfbox directive, which is centered.

A better way to include images within LaTeX is to use the eepic package. epic is an extension to LaTeX's own picture format pic (extended pic) and provides a simpler and more powerful interface, it inherits many of the limitations of LaTeX, to overcome these limitations one generally uses eepic (extended epic). The extensions provide the ability to draw lines in any slopes, draw discs and circles with any diameter that TeX supports and various other enhancements. The main bonus of using eepic is it's ability to include LaTeX mathematical symbols and special commands so that figures may contain mathematical formula which are consistent with the rest of the document.

The eepic image not a bitmapped image but a LaTeX document containing the relevant markup required to produce the desired effect, for example:


It is not necessary for one to understand this kind of markup in order to use eepic. Instead, one uses a program such as xfig to create the image, xfig is loaded up like this:

xfig -specialtext

The -specialtext option is required so that inserted text is treated as special and the LaTeX escaped commands can be used. A screenshot of xfig showing a created image can be seen below:

A screenshot of xfig showing an image that has been created

The image is exported, using xfig, as LaTeX picture + eepic macros:

Using xfig to export an image to LaTeX picture + eepic macros format

The LaTeX picture + eepic macros file generated is included in the LaTeX document like this:

\usepackage{fullpage, epic, eepic}

Notice the inclusion of the packages epic and eepic. The eepic file generated is imported into the document verbatim by using the \input command. When output as PDF the LaTeX generated from the xfig screenshot shown above looks like this:

PDF output from the LaTeX and eepic generated using xfig, as shown in the screenshot above.

Xfig is only available for Unix or unix emulators such as Cygwin for Windows. Instructions on obtaining and installing xfig can be found at Information about using fig with Microsoft windows can be found at

Windows users will probably have to install jfig, available for download at, fig2dev must also be available so that jfig can export as eepic, this can be obtained from the same place as jfig, mentioned above. A screenshot of jfig showing an eepic export in progress is shown below:

A screenshot of jfig showing an eepic export in progress

If one wants to include LaTeX escaped commands within jfig text insert, for instance to include a mathematical formula one should set the text type to special via the drop-down menu box at the bottom of the jfig screen:

To make sure that LaTeX escaped commands are expanded set the text type to special

Tables are a common document inclusion, here is a simple example:

NAME       & MAKE     & HP & YEAR & PRICE \\
  \hline \hline
GSX250     & Honda    & 26 & 1981 & œ300  \\
GS250T     & Honda    & 26 & 1982 & œ250  \\
NSR250R    & Honda    & 60 & 1993 & œ1340 \\ 
NSR250R-SP & Honda    & 65 & 1994 & œ2000 \\
KR1S       & Kawasaki & 60 & 1989 & œ1250 \\
RGV250     & Suzuki   & 60 & 1993 & œ1400 \\
RGV250-SP  & Suzuki   & 65 & 1994 & œ2400 \\

The table is opened with \begin{tabular} after that the parameters are specified, the parameters indicate how each column should be displayed. A pipe symbol ('|') is used to designate a vertical line so one is placed at the start so that the table will have a left edge, the next character is an 'l', this specifies that we would like this column to be left justified, the choices are (l - left, r - right, c - centre). So you can see how the column justification has been specified for each column and the columns have been separated by vertical lines and the there is a vertical line after the last column to close off the right edge of the table. Each line is terminated with a double backslash.

Next comes the table data itself, well actually, first we draw a horizontal line with the \hline directive to indicate that the table should have a top to it. Then comes the table headings, the '&' character is used as a column separator and each row is terminated with a double backslash (\\). Finally, we end the table with a horizontal line so it has a bottom to it and then close of the tabular directive and our center directive. The finished table will look like this when output:

A more advanced template created by Alan P Sexton is shown below:

% for information about the packages, look in Lamport's book and in "The
% Latex Companion" by Goosens et al. For definitive info, the package
% files themselves are self documenting so you can download and read
% them from (here at Bham CS, we mostly only have
% the style files installed that have had the documention stripped from them

\input{prooftree}             % Paul Taylor's natural deduction
                              % prooftree package
\usepackage{amsmath}          % These three lines are only for heavy maths
\usepackage{stmaryrd}         % extra symbols
% \usepackage{longtable}        % for tables that go over multiple pages
% Use xfig for figures and export them as eepic macros

% The following is to set up margins and paper size
%% the args to setmarginsrb are as follows (note that the distance from
%% the top of the page to the first line of (non-header) text is
%% topmargin+headheight+headsep:
%% \setmarginsrb{leftmargin}{topmargin}{rightmargin}{bottommargin}%
%%              {headheight}{headsep}{footheight}{footskip}

% The following is to set up headers and footers conveniently

% The following allows putting comments in the margin: "\marginpar{comment}"

%\input{abbr}  %This should be a list of user specific abbreviations and macros


School of Computer Science\\
University of Birmingham\\[.5ex]}


\input{XXXXX}    % use a separate file for each section of your document


Well, that concludes the brief introduction to LaTeX. By searching the references and links in this page you should be able to find anything you need to know about LaTeX.

These are just a few of the tutorials available on the Internet, there are a lot more, just try your favourite search engine.