[University of Glasgow]
[Mechanical Engineering]
[Donald Ballance]
[Talks]
[Centre for Systems and Control]

An Introduction to LaTeX
Donald Ballance
Centre for Systems and Control
University of Glasgow
Email: D.Ballance@eng.gla.ac.uk
WWW: http://www.mech.gla.ac.uk/~donald/

Abstract
LaTeX is a Document Preparation System which is useful for the
preparation of all kinds of reports. It is particularly suited, but
not limited to, scientific and mathematical papers and reports. In
association with various of support packages it is possible to
produce high quality output which can be electronically submitted to
a number of Journals. In addition, the separation of form and
content allows the same text to be formatted to different
specifications with only a few simple changes.
The aim of this talk is to introduce the LaTeX Document Preparation
System, to explain its capabilities, its limitations, how it works
within the UNIX environment of the Faculty of Engineering, and to
introduce some of the support programs which are used in conjunction
with LaTeX.

Overview
- LaTeX
- What is LaTeX?
- Capabilities, Limitations and Comparisons
- LaTeX Documents and LaTeX commands
- Support Programs
- BibTeX, dvips, Graphics, Converters and other programmes
- Some LaTeX Classes and Packages
- Getting Started
- Further Information

LaTeX
- LaTeX is a document processing system in which you specify
the content and layout(style) separately
- Many powerful features: Mathematics, Labels, Refs,
Equation Numbers, Section Numbers, Table of Contents, List of
Figures, List of Tables, Glossaries, Indexes, etc.
- Style Features: Multi-column, Paper Size, Headers, Footers,
Page Numbering, Reference Style, etc.
- Available on many systems
- Limitations: Tables, not WYSIWYG, learning threshold,
typesetting conventions

Why ``Document Processing''?
- Documents communicate ideas (journal articles, class material,
books, reports, memos), in multiple formats
- Need cross-platform means for converting formats as
well as presentation
- LaTeX is a high quality, inexpensive, typesetting system.
- Can easily handle PostScript files
- Can easily handle bibliography databases.
- Conversion to HTML, PDF, DVI, and Postscript formats is simple
- LaTeX is Structured

Documents for communication
- articles (expository, research, informative)
- letters
- books
- bibliographies

Forms for dissemination
- Hardcopy
- Electronic Forms (PostScript, dvi, pdf, html)

Why LaTeX2e and not Word Processors?
- good cross-platform compatibility.
- Inexpensive or free.
- Better quality typesetting.
- WYSIWYG wastes time better spent on content (forget about how
it looks until it contains what you want to discuss!)

Why not LaTeX209
- LaTeX209 isn't supported.
- LeTeX2e is better packaged with a more natural programming flow.

A Comparison of LaTeX and Word
| | LaTeX | Word |
| WYSIWYG | No | Yes |
| Figures | Yes | Yes |
| Mathematics | Yes | (Yes) |
| Style Changes | Yes | (Yes) |
| Cross References | Yes | No |
| Citations & References | Yes | No |
| Multi-platform | Yes | No |
| Free | Yes | No |

What are all these TeX things?
- TeX
- the basic system (a low level programming language for documents).
- LaTeX
- a set of macros defining document styles (higher level language).
- LaTeX209
- the old version of LaTeX.
- LaTeX2e
- the current version of LaTeX.
- AMS-TeX or AMS-LaTeX
- set of macros, which can be used instead of LaTeX.
This talk will concentrate on LaTeX2e.

Content and Format
- Document contains Description of contents
rather than detailed Format of contents, e.g.,
\section{Introduction}
rather than ``Bold 14pt''
1. Introduction
- LaTeX uses style sheets or document classes

Understanding LaTeX Documents
-
\ is used to start command names
-
% is used to start a comment
-
& $ # _ ^ { } and ~ are
special characters
- Words are separated by one or more spaces.
- Paragraphs are separated by one or more blank lines.
- The output is not affected by adding extra spaces or extra
blank lines to the input file.
-
` and ' create `Quotes' or ``Double Quotes''
-
-- and --- produce en dashes and em dashes
- Bold and emphasised text are easy.

General Form of a LaTeX2e document
% This is a comment
\documentclass[options]{type} % Must be in document
\usepackage{package name} % Multiple packages
<Header: options and configuation>
.
.
\begin{document} % Must be in document
.
<document content>
.
\end{document} % Must be in document

Header Content
The Header consists of items such as:
\title{ Document Title }
\author{ Document Author }
\date{ Date for paper } %% this is optional
and then, in the document content use \maketitle.
Also in the header are definitions of new commands,
\usepackage commands and suchlike.

Document Content
Documents consist of
- Tables of Contents, Lists of Figures, etc.
- Sectional Units
- Text
- Mathematics
- Lists
- Tables and Figures (graphics)
- Bibliographies

Tables of Contents etc.
Tables of Contents, Lists of Figures, Lists of Tables
are produced by the following commands:
-
\tableofcontents
-
\listoffigures
-
\listoftables

Sectional Commands
The sectional units in an article are produced by the following commands:
-
\section{title}
-
\subsection{title}
-
\subsubsection{title}
-
\paragraph{title}
Books and reports also have \chapter{title} and can have
different parts defined by \part{title}.
The \appendix command changes the numbering scheme for sections
to letters.

Mathematics
TeX was originally designed to presentation mathematics well.
LaTeX basically uses the same commands with a few modifications.
The equation:
is created using the commands
\[
\Theta(s) = \int_0^\infty \theta(t)e^{-st}\,dt
= \mathcal{L} \{\theta(t)\}
\]
Many symbols and operators are available.

List Environments
- enumerate: Numbered lists
- itemize: Bulletted lists
For example, use the list environment:
\begin{enumerate}
\item This is a two item list
\item This is the second item
\end{enumerate}
to produce:
- This is a single item list
- This is the second item

Tables and Figures
The Table
| | 9.00-10.00 |
10.00-11.00 | 11.00-12.00 |
| Monday | Applicable Mathematics I |
Basic Engineering I | Engineering Design I |
| Tuesday | Applicable Mathematics I |
Basic Engineering I | Engineering Practice I |
Table 1: First Year Timetable
is produced by:
\begin{table}
\begin{tabular}{|l|c|c|c|}
\hline
& 9.00 -- 10.00 & 10.00 -- 11.00 & 11.00 -- 12.00 \\ \hline
Monday & Applicable Mathematics I & Basic Engineering I
& Engineering Design I \\ \hline
Tuesday & Applicable Mathematics I & Basic Engineering I
& Engineering Practive I \\ \hline
\end{tabular}
\caption{First Year Timetable}
\end{table}

Including Postscript Files
When using LaTeX2e it is better to use
\usepackage[dvips]{graphicx}, rather than the old
LaTeX method of including graphics. Then use:
\begin{figure}[htbp]
\begin{center}
\includegraphics[height=3in,width=4in,angle=270]
{figure.ps}
\caption{This is the Caption}
\label{fig:label}
\end{center}
\end{figure}
It is easy to include figures!

Bibliographies and BibTeX
- use list or itemize environments.
- use thebibliography environment
- use BibTeX: Use the
\cite command in the text
to cite the required references and let BibTeX create the
bibliography at the end of the document

Support Programs
- BibTeX
- References database and citation
- (X)Emacs
- Context sentitive editor
- latex2html
- Convert LaTeX source to HTML
- rtf2latex
- Convert RTF to LaTeX
- xdvi
- Show output on screen
- dvips
- Convert output suitable for printing on a PostScript printer.
- ghostview
- Show PostScript on screen
- xfig
- Useful for diagrams
- Others
- Many programs exist which can be used in conjunction
with LaTeX.

BibTeX
Idea: you probably use the same reference in numerous papers, so why
bother typing them in multiple times?
Need to construct a bibliography file (use a .bib suffix).
This will be the database for all your references!
However, (X)Emacs will do much of the formatting for you (you simply
fill in the blanks for the bibliography file).
\cite{GawBal97}
.
.
\bibliography{/home/mech/group/references/common}
\bibliographystyle{IFAC}

Editing Documents: Emacs
LaTeX files can be edited using any text editor. Under Unix, one
approach is to use Emacs in combination with Auc-TeX; this
allows for the whole development of your document to occur without
needing to leave your editor, except perhaps to construct figures
using XFig or other programs.

Printing
To print a standard file:
dvips filename.dvi -Pprinter
where printer should be replaced with the name of the printer on
which you wish to print. If it different from you PRINTER
environment variable. If you are doing 2-up, then you need to specify
the orientation:
dvips filename.dvi -Pprinter -t landscape

Graphical Overview
LaTeX uses many files to store and transfer information. This diagram
gives a graphical over view of some of the files and operations.

Standard Classes
The following classes are distributed with LaTeX:
- article
-
The article class described in LaTeX: A Document Preparation System.
- book
-
The book class described in LaTeX: A Document Preparation System.
- report
-
The report class described in LaTeX: A Document Preparation System.
- letter
-
The letter class described in LaTeX: A Document Preparation System.
- slides
-
The slides class described in LaTeX: A Document Preparation
System, formerly SLiTeX.
- proc
-
A document class for proceedings, based on article. Formerly
the proc package.
- ltxdoc
-
The document class for documenting the LaTeX program, based on article.
- ltxguide
-
The document class for LaTeX2e for Authors and LaTeX2e for
Class and Package Writers, based on article. The document you
are reading now uses the ltxguide class. The layout for this
class is likely to change in future releases of LaTeX.
- ltnews
-
The document class for the LaTeX News information sheet,
based on article. The layout for this class is likely to change
in future releases of LaTeX.

Standard Packages
The following packages are distributed with LaTeX:
- doc
-
Allows the documentation of LaTeX programs.
Described in doc.dtx and in The LaTeX Companion.
- exscale
-
Provides scaled versions of the math extension font.
Described in ltexscale.dtx.
- fontenc
-
Specifies which font encoding LaTeX should use.
Described in ltoutenc.dtx.
- ifthen
-
Provides commands of the form `if...then do...otherwise do...'.
Described in ifthen.dtx and The LaTeX Companion.
- latexsym
-
Loads the LaTeX symbol font (Not loaded by default).
Described in latexsym.dtx and in The LaTeX Companion.
- makeidx
-
Provides commands for producing indexes. Described in LaTeX: A
Document Preparation System and in The LaTeX Companion.
- newlfont
-
Emulates the font commands of LaTeX 2.09 with the New Font
Selection Scheme. Described in The LaTeX Companion.
- oldlfont
-
Emulates the font commands of LaTeX 2.09.
Described in The LaTeX Companion.
- syntonly
-
Processes a document without typesetting it.
Described in syntonly.dtx and in The LaTeX Companion.
- tracefnt
-
Allows you to control how much information about LaTeX's font
loading is displayed. Described in The LaTeX Companion.

Related Software
In addition, the following software should be available.
- amslatex
-
Advanced mathematical typesetting from the American Mathematical Society
- babel
-
Supports typesetting in many languages.
- color
-
Provides support for colour.
- psnfss
-
Typesetting with Type 1 (PostScript) fonts.
- tools
-
Miscellaneous packages written by the LaTeX3 project team.
These packages come with documentation and each of them is also
described in at least one of the books The LaTeX Companion and LaTeX:
A Document Preparation System.

Tools
This collection of packages includes, at least, the following (some
files may have slightly different names on certain systems):
- array
-
Extended versions of the environments array, tabular and
tabular*, with many extra features.
- dcolumn
-
Alignment on `decimal points' in tabular entries. Requires the
array package.
- delarray
-
Adds `large delimiters' around arrays. Requires array.
- hhline
-
Finer control over horizontal rules in tables. Requires array.
- longtable
-
Multi-page tables. (Does not require array, but it uses the
extended features if both are loaded.)
- tabularx
-
Defines a tabularx environment that is similar to tabular* but
it modifies the column widths, rather than the inter-column
space, to achieve the desired table width.
- afterpage
-
Place text after the current page.
- enumerate
-
Extended version of the enumerate environment.
- fontsmpl
-
Package and test file for producing `font samples'.
- ftnright
-
Place all footnotes in the right-hand column in two-column mode.
- indentfirst
-
Indent The first paragraph of sections, etc.
- multicol
-
Typeset text in columns, with the length of the columns `balanced'.
- rawfonts
-
Preload fonts using the old internal font names of LaTeX2.09.
- somedefs
-
Selective handling of package options. (Used by the rawfonts package.)
- showkeys
-
Prints the `keys' used by
\label, \ref, \cite
etc.; useful whilst drafting.
- theorem
-
Flexible declaration of `theorem-like' environments.
- varioref
-
`Smart' handling of page references.
- verbatim
-
Flexible extension of the verbatim environment.
- xspace
-
`Smart space' command that helps you to avoid the common
mistake of missing spaces after command names.

Getting Started
A typical session might look like the following:
host:project > use tetex
New Latex
host:project > use gnu
GNU Utilities for Solaris 2
host:project > use x11
X Window System (Openwindows + MIT X11R5)
host:project > textedit <filename>.tex
host:project > latex <filename> % run latex to create .aux file
This is TeX, Version 3.14159 (C version 6.1)
(slides.tex
LaTeX2e <1996/06/01>
.
host:project > bibtex <filename> % run bibtex to process references
host:project > latex <filename> % run latex to include references
host:project > latex <filename> % run latex to get cross-references
The commands to view and print the output would be:
host:project > xdvi <filename> % view on screen
host:project > dvips -o <filename>.ps <filename> % create PostScript file
host:project > ghostview <filename> % view on screen
host:project > dvips <filename> % print to standard printer
host:project > dvips -P<printer> <filename> % print to printer
host:project > dvips -p 4 -n 2 <filename> % print pages 4 and 5

Further Information
- Example Documents
-
/local/tetex/texmf/tex/latex/base/small2e.tex
-
/local/tetex/texmf/tex/latex/base/sample2e.tex
- The Not So Short Guide to LaTeX2e
- Essential LaTeX ++
- On-line Help via
-
http://www.mech.gla.ac.uk/Control/Facilities.html
- Books
- LaTeX A Document Preparation System
- The LaTeX Companion
- LaTeX Notes: Practical Tips for Preparing Technical Documents
- many other files in the hierarchy under
/local/tetex

Summary
- System is not WYSIWYG, more a programming language
- Powerful
- Relatively easy to use, although not that ``friendly''
- Good for mathematics and technical papers
- Multi-platform: DOS, Windows, Mac, UNIX, Vax, ...
- FREE

Comments, errors & suggestions to:
D.Ballance@mech.gla.ac.uk
Last modified
Tuesday, 23-Dec-2003 13:13:03 GMT, by
Donald Ballance