Web Historical Disclaimer:

This is a historical page and is no longer maintained. Read our Web history statement for more information.

                                                       

  " "
   | UT Home | Graduate School Home |
" "

" "
 

LaTeX: from quick and dirty to style and finesse

Environments
by Tony Roberts

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

Contents of this section

Quotation & verse

An environment is established by a \begin{}...\end{} pair. For example, a quotation may be typeset using the quote environment

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

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

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

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

Observe that the "66" and "99" quote marks around the quote (and elsewhere) are obtained by using:

  • two back quote characters for the "66" at the start of a quote,
  • and two single quote characters for the "99" at the end of the quote.

Note that 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 and their surnames. 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 in other circumstances such as Figure~2, equation~(3), etc.

Abstract

The abstract environment does a little more for you in that

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

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

Itemize & 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 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
... & ... & ... \\
\hline
... & ... & ... \\
\hline
\end{tabular}

for a table of four rows and three columns.

  • 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.

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 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 (\tt). See 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 fractals16.tex and observe the mathematics in section 2 when typeset. Note the different font used for mathematical letters (called math italic); it is imperative that all mathematics be 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. "Do as I say, and not as I do": avoid these because 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 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 have 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. This is achieved 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 fractals18.tex.

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



3 August 1998

Professor A J Roberts
Department of Mathematics and Computing
University of Southern Queensland
Toowoomba 4350, Australia
E-mail: aroberts@usq.edu.au
 
" "
Graduate School, Main Building 101, Austin, TX 78712
(512) 471-4511, FAX: (512) 471-7620
Privacy statement