The very short guide to typesetting with L^{A}TEX

Silmaril Consultants Textual Therapy Division

                                                                    latex.silmaril.ie

October 2009

What’s this all about? What’s L^{A}TEX?

L^{A}TEX is a document preparation system for the TEX typesetting program. It enables you to produce publication-quality output with great accuracy and consistency. L^{A}TEX works on any computer and produces industry-standard PS or PDF documents. It is available both in free (open-source) and commercial implementations. L^{A}TEX can be used for any kind of document, but it is especially suited to those with a complex structure, repetitive formatting, or notations like mathematics^{1}; or where technical stability, dimensional accuracy, or a persistent and non-proprietary file format are needed.

Syntax (how to type L^{A}TEX commands — these are the rules)

All L^{A}TEX commands begin with a backslash.

Example: \tableofcontents

If a command needs text to work with, it goes in curly braces.

Example: \title{Irisches Tagebuch}\author{Heinrich Böll}

If options are used, they go in square brackets first.

Example: \documentclass[a4paper,11pt]{book}

Space after commands without braces gets suppressed.

Example: Copyright \copyright 2009  Copyright ©2009

To prevent this, put empty curly braces after the command.

Example: Copyright \copyright{} 2009  Copyright © 2009

Curly braces are also used to restrict the scope of effects inside them. Example: Some {\tiny little} word Some little word

Creating and typesetting your document

1. Create your document using any suitable plain-text editor with L^{A}TEX controls, eg TEXshop (Mac), TEXnicCenter (Win), Kile (Linux), Emacs (all);

2. Save the file with a name ending in .tex (never use spaces in filenames!);

3. Use the toolbar buttons or menu items in your editor to typeset and display the document;

4. Make any changes needed in your original document and repeat step 3.

Note. This guide shows only a tiny fraction of L^{A}TEX’s power. For information, visit the TEX Users Group site (www.tug.org). For help, see the FAQ (www.tex.ac.uk/faq) and the Usenet newsgroup comp.text.tex. For packages, use the Comprehensive TEX Archive Network (www.ctan.org). For documentation, use the sources in the References [2].

1For reasons of space this guide does not cover details of mathematics typesetting.

Basic document structure

Here’s the skeleton of a L^{A}TEX document. These three lines are compulsory: your document will not work without them:

\documentclass{article}

your preamble goes here (extra setups, if any)

\begin{document}

your document text goes here

\end{document}

The document class name must be

one of book, article, or report, or an

extra one you have downloaded and installed (eg thesis, memoir, etc).

There are paper size options a4paper (210 mm×297 mm) and letterpaper (8½′′×11′′) and others (eg a5paper).

There are base type size options 10pt (the default), 11pt, and 12pt.

Front matter

The preamble is where you specify any extra packages (L^{A}TEX plugins) such as typefaces or special formatting requirements, and where you put any changes to standard features.

\documentclass[a4paper,11pt]{book}
\usepackage{charter,graphicx}
\setlength{\parindent}{1em}
\begin{document}

\title{your document title}

\author{your name}

\date{date of publication}

\maketitle
\begin{abstract}

the paragraphs of the abstract go here

\end{abstract}
\tableofcontents

rest of the document goes here

\end{document}

In a typical report or article, the title, author, date, abstract (summary), and table of contents (optional) all go at the start, followed by your text.

Leave a blank line between paragraphs as you type. This means ‘start a new paragraph’, not ‘leave a blank line’. You can control spacing and indentation by setting

\parskip and \parindent (see examples),

or with the parskip package.

Sections and cross-references

Sections get numbered automatically in bold type, and get included in the Table of Contents (if any). Numbering can be turned off selectively. Section heading layout can be modified with the sectsty, titlesec, and other packages. Use the babel package for other languages.

(Preamble, titling, and abstract as above)

 \tableofcontents

\section{heading of a section}

text for the section goes here

 ...as shown in section \ref{blah}.

\subsubsection{heading of a subsection} text for the subsection goes here \section{heading of a new section} \label{blah} make up name for the label text for the section goes here

 \end{document}

For cross-references, use \label{...} to label the target and \ref{...} and/or \pageref{...} to refer to it. Make up the label values: L^{A}TEX will use them to work out the right numbers to print.

Example: ...section \ref{blah} on p.

\pageref{blah}. ...section 3 on p.9.

Typefaces

L^{A}TEX’s default typeface is Computer Modern. There is a selection of other typeface packages (use them in your Preamble):

 Times  mathptmx  Courier     courier

Palatino mathpazo Avant Garde avant
Bookman bookman Helvetica  helvet
Charter  charter Zapf Chancerychancery

 Utopia  utopia  �������  pandora

New Century Schoolbook  newcent

Dozens of others are available, including mathematical and decorative fonts. To switch to a sans-serif type family (eg Helvetica, Avant Garde), use \sffamily in your text. To change font for a word or phrase, use these commands (they can be nested— see below):

 Italics  \textit{Hello}  Hello
 Boldface  \textbf{Hello}  Hello
 Smallcaps \textsc{Hello}  Hello

Sans-serif \textsf{Hello}  Hello

 Monospace \texttt{Hello}     Hello

Example:  \textit{\textbf{\textsf
{bold ital sans}}}  bold ital sans

Font sizing is automatic for titles, headings, and footnotes. There are some named step-size commands (in points, relative to the base size):

 \normalsize  10 11 12
 \tiny  5 6 7
 \scriptsize  6 7 8
 \footnotesize 7 8 9
 \small  9 10 11
 \large  11 12 14

\Large  12 14 17*
\LARGE  14 17* 20*
\huge  17* 20* 24*
\Huge  20* 24* 28*

* sizes rounded here to save space

but you can specify an exact size with the fix-cm package and the command

\fontsize{pp}{bb}\selectfont for any

point-size (pp) on any baseline (bb). Group (enclose) the command with its applicable text in curly braces to prevent it affecting the rest of the document. For wider line-spacing (eg in theses) use the setspace package. You can also use colour with the xcolor package and Google

the \color{name} command.

Lists

There are three basic kinds: itemized lists (bulleted); enumerated lists (numbered or lettered); and descriptive lists (topic-and-explanation format). Others can be defined, or downloaded from CTAN [5].

                                                                       \begin{itemize} \item 1lb Sugar \item ½pt Cream \item Chocolate \end{itemize} \begin{enumerate} \item Mix together \item Boil to 112°C \item Stir and cool \end{enumerate} \begin{description} \item[Fudge] is fun... \item[Broccoli] sucks... \item[Exercise] is good \end{description} _{• 1lb Sugar • ½pt Cream • Chocolate  1. Mix together 2. Boil to 112°C 3. Stir and cool  Fudge is fun but not if made too often. Broccoli sucks, period. Exercise is good for you if taken daily and not to extremes.}

You can nest lists inside each other. See packages like paralist and mdwlist to control list formatting.

Tables and figures

Formal tables and figures float (change position to fill available space) so they may not be printed where you typed them.

                                            \begin{table}
                                            \caption{Mean growth rate and intakes
                                            of supplement, milk, and water for 4
                                            diets.}
                                            \label{dietgrowth}\centering
                                            \begin{tabular}{|l|r|r|r|r|}\hline
                                            &Growth&Supplement&Milk&Water\\
                                            Supplement&rate&intake&intake&intake\\
                                            &(g/day)&(g/day)&(ml/kg$^{0.75}$)&
                                            (ml/kg$^{0.75}$)\\\hline
                                            Lucerne &145&450&10.5&144\\\hline
                                            Sesbania&132&476& 9.2&128\\\hline
                                            Leucaena&128&364& 8.9&121\\\hline
                                            None    & 89&  0& 9.8&108\\\hline
                                            \end{tabular}
                                            \end{table}

Table 2: Mean growth rate and intakes of supplement, milk, and water for four diets (after Sherington, J, undated)

Growth Supplement  Milk  Water
Supplement  rate  intake  intake  intake
(g/day)  (g/day) (ml/kg^{0.75}) (ml/kg^{0.75})
Lucerne  145  450  10.5  144
Sesbania  132  476  9.2  128
Leucaena  128  364  8.9  121
None  89  0  9.8  108

Packages like longtable and array can help with more complex table formats.

For help, see the links on the front and back pages. There is a summary of common commands at

                                                   www.stdout.org/~winston/latex/latexsheet.pdf

and a comprehensive list at computing.ee.ethz.ch/

                                                   .soft/latex/green/ltx-2.html.

Tables and Figures, continued

\begin{figure}
\caption{Swiss and Dutch Mennonite migrations of the 1700s and 1800s}\label{lmig}

\centering (graphics must be EPS files for standard L^{A}TEX; but JPG, PNG, or PDF for pdfL^{A}TEX)

\includegraphics[width=.8\columnwidth]{menno-a}
\\\scriptsize Courtesy of Paul C. Adams, Department of Geography and the
Environment, University of Texas at Austin. \cite{adams}\end{figure}

Figure 1: Swiss and Dutch Mennonite migrations of the 1700s and 1800s

Courtesy of Paul C. Adams, Department of Geography and the Environment, University of Texas at Austin. [1]

Footnotes, citations, references, and indexes (back matter)

You do footnotes with a simple command,^{2} see below. Citations using BIBTEX (Patashnik, 1988) are also easy (see [2], §7.4.2) and there are packages for more complex formats for journals and publishers. You can add indexes with the \index command and the makeindex program.

You do footnotes with a simple command,\footnote{Like this.} see below. Citations
using BIB\TeX{} \citeauthoryear{oren} are also easy (see \cite[§7.4.2]{flynn} and
there are packages for more complex formats for journals and publishers. You can
add  indexes with the \verb`\index` command and the \textsf{makeindex} program.

add the following at the end of your document and create myrefs.bib (see BIBTEX manual [3])

\bibliography{myrefs}\bibliographystyle{apalike}

References

1. Adams, Paul C. Linguistic Chaos in Montreal, www.utexas.edu/depts/grg/adams/chaos.ppt, 2/59, Oct 2006.

 2. Flynn, P. Formatting Information, 2005, at latex.silmaril.ie/formattinginformation/

3. Patashnik, O. BIBTEXing, TEX Users Group, 1988 (distributed with all copies of L^{A}TEX).

4. Sherington, J. example table in ‘Informative Presentation of Tables, Graphs and Statistics’, 4.2, Statistical Services Centre, University of Reading, www.reading.ac.uk/ssc/publications/

   guides/toptgs.html

5. TEX Users Group, for TEX Live (www.tug.org/texlive/) and CTAN (Comprehensive TEX Archive Network) for downloads (www.ctan.org).

Note. Commercial implementations of TEX with business support are available from Personal TEX, Inc (PCTEX); Blue Sky Research (Textures [Mac]); MacKichan Software, Inc (Scientific Word); Micropress, Inc (VTEX), TrueTEX Software (TrueTEX), and others.

2Like this.