Environments

LaTeX has a multitude of logical structures to work with, called 'environments.' Use them.

Quotation and verse

An environment is established by a \begin{}...\end{} pair. For example, a quotation may be typeset using the quote environment (Note: for such a displayed quote we do not use quote marks, quote marks are only used for short quotes typeset inline.)

\begin{quote} 
... 
\end{quote}

or a passage of verse may be typeset by the verse environment

\begin{verse} 
... 
\end{verse}

See Src/fractals11.tex and the use of \\ to specify line breaks in the verse environment.

LaTeX knows that it is good style to leave a wider space after a full-stop at the end of a sentence. However, this means that sometimes you have to tell LaTeX that some full-stop/space combinations are not at the end of a sentence, one example being between a person's initials. As in L.~F. Richardson and A.~J. Roberts, a tilde does two things:

  • it typesets a standard width space, and
  • it tells LaTeX never to break a line at that space.

The tilde is used to tie text in other circumstances such as Figure~2, equation~(3), and Section~3.1. Knuth describes fully where to use such ties.

Abstract

The abstract environment does a little more for you in that

\begin{abstract} 
... 
\end{abstract}

also typesets a natty little title. See Src/fractals12.tex.

Itemize and enumerate

Extremely useful are the list environments of which I describe two. Use them wherever you have a sequence of steps or a list of things. The format for a bulleted list is

\begin{itemize} 
\item ... 
\item ... 
... 
\end{itemize}

The format for a numbered list is

\begin{enumerate} 
\item ... 
\item ... 
... 
\end{enumerate}

See Src/fractals13.tex. Note that blank lines between items have no effect.

Lists may be embedded within lists to a maximum of four nested levels.

Tabular and center

Often we want to display information in a table; LaTeX has the tabular environment for this.

The tabular environment is a more sophisticated environment in that it has an argument as well as material in the body of the environment. The format of the environment is

\begin{tabular}{argument} 
\hline 
... & ... & ... \\
\hline 
... & ... & ... \\
... & ... & ... \\
... & ... & ... \\
\hline 
\end{tabular}

for a table of four rows and three columns (with horizontal lines around the heading line and also at the end of the table).

  • The special & character separates the different items in any one row.

  • The '\\' separates different rows.

  • The argument of the tabular environment is a string made up of a letter for each column of the table, either c, l or r denoting a centred, left-justified or right-justified column respectively---the letters optionally separated by a '|' if you desire vertical lines between columns.

  • The optional \hline's draw horizontal lines between the rows of the table. Use \hline's and |'s sparingly---let the table structure work for you at the lowest level.

The fractal document does not have a table at present, but we put one in at the end listing seven geometric objects and their fractal dimension, see Src/fractals14.tex. Note that the table is put inside a center environment:

\begin{center} 
... 
\end{center}

which centres the enclosed material across the width of the page (note the American spelling of center).

Verbatim

Computer code, no matter what special characters it has, may be listed with the verbatim environment:

\begin{verbatim} 
... 
\end{verbatim}

All characters and line breaks within the body of this environment are reproduced in the fixed width font. See Src/fractals15.tex where I typeset the LaTeX commands needed to typeset the table of dimensions!

(More powerful code listing environments are available in the moreverb package.)

Simple Mathematics

Mathematics is treated by LaTeX in a fashion completely different from ordinary text. The mathematics mode is invoked by specific environments.

math
Mathematics to be typeset inline with the text must be contained in the environment
\begin{math}...\end{math}

or

\(...\)

for short. See Src/fractals16.tex and observe the mathematics in section 2 when typeset. Note the different font used for mathematical letters (called math italic); all mathematics is typeset in a math environment (even if it is just a single letter), and not in the roman font that is the default for text.

A universal bad habit is to use matching dollar signs

$...$

to invoke the math environment for inline mathematics---an unmatched $-sign causes incomprehensible error messages, whereas an unmatched \( or \) is generally easier for LaTeX to detect and inform.

Also note that in any mathematics environment, blank characters are totally ignored.

scripts and symbols
Subscripts and superscripts are typeset in a mathematics environment using the underscore and the caret character respectively. For example,
d^{-1}

and

d^2

will typeset '-1' and '2' as superscripts to d, see Src/fractals17.tex. Similarly for subscripts indicted by "_". Single character scripts need no enclosing braces.

LaTeX has an enormously wide variety of symbols to help typeset mathematics. For example, in fractals17.tex I used:

  • \times to get a times sign;
  • \propto to get a proportional to symbol;
  • \pi to get the greek letter pi.

See the menus in Alpha, or the Essential Mathematics document, for an idea of the wide range of symbols available; note in particular the whole of the greek alphabet. The names of these symbols have to be followed by a non-alphabetic character, often a blank.

displaymath and frac
Many mathematical equations and expressions are so complicated or so important that they should not be typeset inline with the text, but they should be displayed on a line all by themselves. Achieve this with the environments:
\begin{displaymath} 
... 
\end{displaymath}
equivalent to the shorter
\[ 
... 
\]
or
\begin{equation} 
... 
\end{equation}

The difference being that the last also typesets an equation number to the right of the mathematics. See Src/fractals18.tex.

Also observe the use of the \frac command, with two arguments enclosed in braces, for producing fractions within mathematics.

Summary

The environments described are among the most common ones needed for all sorts of documents. Based upon hundreds of years of printers experience distilled by Knuth and Lamport, LaTeX knows the generic best way to typeset the different sorts of information.

For example, the LaTeX document-class refart typesets articles according to Wendy Priestly's best practice for instruction. After downloading Others/refart.cls, simply change the document-class of Src/fractals18.tex from article to refart to see the style (use Others/refrep.cls for long reports).

Before looking at more environments and commands, the next step is to use LaTeX to automatically provide us with cross-references such as a table of contents.