Environments
Alignments
In these environments \\
starts a new line.
\begin{flushleft} Some people like to stay firmly\\ on the left whereas others \end{flushleft} \begin{flushright} feel more at home on the right.\\ \end{flushright} \begin{center} but most of us prefer to stay dead in the center. \end{center}
on the left whereas others
on the right.
Listing Items
The items can be marked in one of three way:
\begin{itemize} \item just by a bullet, using \texttt{itemize} \item numbered, using \texttt{enumerate} \begin{enumerate} \item one \item two \item three \end{enumerate} \item or with a label, using \texttt{description} \begin{description} \item[itemize] bullets \item[enumerate] automatic numbering \item[description] labelling \end{description} \end{itemize}
- just by a bullet, using itemize
- numbered, using enumerate
- 1.
- one
- 2.
- two
- 3.
- three
- or with a label, using description
- itemize
- bullets
- enumerate
- automatic numbering
- description
- labelling
The pifont package includes a variant of the itemize command that will replace the usual 'bullet' by a Zapf Dingbat symbol of your choice
\begin{dinglist}{43} \item First \item Second \end{dinglist}
and a variant of the enumerate command that given an initial Zapf Dingbat symbol will increment the symbol for each item.
\begin{dingautolist}{172} \item First \item Second \end{dingautolist}
Tabular
Tabular output is supported. When you create the environment you specify how
many columns to have and how the contents are to be aligned (use l, c
or r to represent each column with either left, center or right
alignment) and where you want vertical lines (use |
). The contents of
the columns are separated by a `&' and rows by \\
. Here's a simple
example
\begin{tabular}{l|c|r} left & centre & right\\ more left & more centre & more right\\ \end{tabular}
left | centre | right |
more left | more centre | more right |
To draw a full
horizontal line, use \hline
otherwise draw a line across selected
columns using \cline
. The \multicolumn
command allows items to
span columns. It takes as its first argument the number of columns to span.
The following, more complicated example shows how to use these
facilities.
\begin{tabular}{||l|lr||} \hline \textbf{Veg} & \multicolumn{2}{|c||}{\textbf{Detail}}\\\hline carrots & per pound & \pounds 0.75 \\ \cline{2-3} & each & 20p \\ \hline mushrooms & dozen & 86p \\ \cline{1-1} \cline{3-3} toadstools & pick your own & free \\ \hline \end{tabular}
(n.b. the HTML representation below is inaccurate - too many lines)
Veg | Detail | |
---|---|---|
carrots | per pound | £0.75 |
each | 20p | |
mushrooms | dozen | 86p |
toadstools | pick your own | free |
Tables won't continue on the next page if they're too long. The longtable or supertabular commands are needed to do this. See the Supertabular documentation for details and examples.
If the text in a column is too wide for the page, LATEX won't
automatically text-wrap. Using p{5cm}
instead of c
,
l
or r
in the tabular line will wrap-around
the text in a 5 cm wide column.
There are various packages to assist with table creation. The array package adds some helpful features, including the ability to add formatting commands that control a whole column at a time, like so
\begin{tabular}{>{\ttfamily}l>{\scshape}c>{\Large}r} Text & More Text & Large Text\\ Left & Centred & Right \end{tabular}
Text | MORE TEXT | Large Text |
Left | CENTRED | Right |
The rotating
package is useful if you have a wide table that you
want to display in landscape mode. You need to put your table inside
\begin{sidewaystable}
and \end{sidewaystable}
.
If you want the table to have a caption and float (float up the page if it's started right near the foot of a page, for example), use
\begin{table}[htbp] \begin{tabular}... ... \end{tabular} \caption{...} \end{table}See section 4.7 for details.
Array
The array environment (not to be confused with the array package) is similar to the tabular but must be within a math environment. This
\begin{math} \left( \begin{array}{clrr} a+b+c & uv & x-y & 27 \\ x+y & w & +z & 363 \end{array} \right) \end{math}
produces
Pictures
LATEX has some graphics capabilities. It's much better to import an encapsulated postscript file. See the LATEX Maths and Graphics document for more details.
\newcounter{cms} \setlength{\unitlength}{1mm} \begin{picture}(50,39) \put(0,7){\makebox(0,0)[bl]{cm}} \multiput(10,7)(10,0){5}{\addtocounter {cms}{1}\makebox(0,0)[b]{\arabic{cms}}} \put(15,20){\circle{6}} \put(30,20){\circle{6}} \put(15,20){\circle*{2}} \put(30,20){\circle*{2}} \put(10,24){\framebox(25,8){a box}} \put(10,32){\vector(-2,1){10}} \multiput(1,0)(1,0){49}{\line(0,1){2,5}} \multiput(5,0)(10,0){5}{\line(0,1){3,5}} \thicklines \put(0,0){\line(1,0){50}} \multiput(0,0)(10,0){6}{\line(0,1){5}} \end{picture}
Maths
Maths is dealt with in the LATEX Maths and Graphics document. Here are some examples
\begin{math} \lim_{n \rightarrow \infty}x = 0 \\ x^{2y} \\ x_{2y} \\ x^{2y}_{1} \\ \frac{x+y}{1 + \frac{1}{n+1}} \\ \end{math}produces
Figures
To include graphics, use the \includegraphics
command
(provided by the graphicx package) inside figure environment.
The arguments to
figure specify where the space will be made, preferentially
h | here |
t | top of page |
b | bottom of page |
p | on a page with no text |
\begin{figure}[htbp] \vspace{1cm} \caption{1 cm of space} \end{figure}
Putting ! as the first argument in the square brackets will encourage LATEX to do what you say, even if the result's sub-optimal.
If you have a label defined in the caption, LATEX may
give an error message. \label
is a fragile command (see the
LATEX book for details) so you'll need to do something like
... \caption{1 cm of space\protect\label{EMPTY}}
or simply put the \label
command after the caption. Note that
if you put the \label
before the caption, the resulting reference will be the
section number and not the figure number. See the
LATEX Maths and Graphics
document for more details.
Tabbing
Within this environment tabs can be set by \=
and the next tab
moved to by using \>
.
\begin{tabbing} if \= it's raining\\ % set tab here, after the 'if' \> get an umbrella \=\\ % go to the defined tab and set a new one else\\ \> get wet \> * next tab is here\\ endif \end{tabbing}
if it's raining
get an umbrella
else
get wet * next tab is here
endif
Verbatim
Within this environment things come out unformatted. It's useful for showing examples of typed input and provides a way of printing characters that have a special meaning for LATEX.
\begin{verbatim}
caret is ^, tilde is ~ and backslash is \
\end{verbatim}
produces
caret is ^, tilde is ~ and backslash is \
If you just want to quote a few characters, use \verb|
quoted text|
.
The characters delimiting the quote can be anything as long as they are the same.
Quote, abstract
These widen the margins and change the font. The abstract environment also adds a title.
Letter
See letter.tex in /export/Examples/LaTeX
Curriculum Vitae
See cv.tex in /export/Examples/LaTeX