%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Contents: Typesetting Part of LaTeX2e Introduction
% $Id: typeset.tex,v 1.2 1996/01/25 14:01:06 oetiker Exp oetiker $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
\chapter{Typesetting Text}

\begin{intro}
  After reading the previous chapter you should know about the basic
  stuff from which a \LaTeXe{} document is made. In this chapter I
  will fill in the remaining structure you will need to know in order
  to produce real world material.
\end{intro}

\section{Linebreaking and Pagebreaking}
 
\subsection{Justified Paragraphs}

Often books are typeset with each line having the same length.
\LaTeX{} inserts the necessary \wi{linebreak}s and spaces between words
by optimising the contents of a whole paragraph. If necessary it
also hyphenates words that would not fit comfortably on a line.
How the paragraphs are typeset depends on the document class.
Normally the first line of a paragraph is indented and there is no
additional space between two paragraphs. Refer to section~\ref{parsp}
for more information.

In special cases it might be necessary to order \LaTeX{} to break a
line: 
\begin{command}
\ci{\bs} or \ci{newline} 
\end{command}
\noindent start a new line without starting a new paragraph. 

\begin{command}
\ci{\bs*}
\end{command}
\noindent additionally prohibits a pagebreak after the forced
linebreak. 

\begin{command}
\ci{newpage}
\end{command}
\noindent starts a new page. 
\pagebreak

\begin{command}
\ci{linebreak}\verb|[|\emph{n}\verb|]|,
\ci{nolinebreak}\verb|[|\emph{n}\verb|]|, 
\ci{pagebreak}\verb|[|\emph{n}\verb|]| and
\ci{nopagebreak}\verb|[|\emph{n}\verb|]|
\end{command}
\noindent do what their names say. They enable the author to influence their
actions, with the optional argument \emph{n}. It can be set to a
number between zero to four. By setting \emph{n} to a value below 4
you leave \LaTeX{} the option of ignoring your command if the result
would look very bad.

\LaTeX{} always tries to produce the best linebreaks possible. If it
cannot find a way to break the lines in a manner which meets its high
standards, it lets one line stick out on the right of the
paragraph.  \LaTeX{} then complains (``\wi{overfull hbox}'') while
processing the input file. This happens most often when \LaTeX{}
cannot find a suitable place to hyphenate a word. By giving the
\ci{sloppy} command you can instruct \LaTeX{} to lower its standards a
little. It then prevents such over-long lines by increasing the
inter-word spacing --- even if the final output is not optimal.  In
this case a warning (``\wi{underfull hbox}'') is given to the user. In
most cases the result does not look too bad. The command \ci{fussy}
acts in the opposite direction. Just in case you want to see \LaTeX{}
complaining all over the place. 

\subsection{Hyphenation} \label{hyph}

\LaTeX{} hyphenates words whenever necessary. If the hyphenation
algorithm does not find the correct hyphenation points you can
remedy the situation by using the following commands, to tell \TeX{}
about the exception.

The command
\begin{command}
\ci{hyphenation}\verb|{|\emph{word list}\verb|}|
\end{command}
\noindent causes the words listed in the argument to be hyphenated only at the
points marked by ``\verb|-|''.  This command should be given in the
preamble of the input file and should only contain words built from
normal letters. The case of the letters is ignored. The example below
will allow ``hyphenation'' to be hyphenated as well as ``Hyphenation''
and it prevents ``FORTRAN'', ``Fortran'' and ``fortran'' from being
hyphenated at all.  No special characters or symbols are allowed in
the argument.

Example:
\begin{code}
\verb|\hyphenation{FORTRAN Hy-phen-a-tion}|
\end{code}

The command \ci{-} inserts a discretionary hyphen into a word. This
also becomes the only point hyphenation is allowed in this word. This
command is especially useful for words containing special characters
(e.g.\ accented characters), because \LaTeX{} does not automatically
hyphenate words containing special characters.
%\footnote{Unless you are using the new
%\wi{DC fonts}.}.
\begin{example}
I think this is: su\-per\-cal\-%
i\-frag\-i\-lis\-tic\-ex\-pi\-%
al\-i\-do\-cious
\end{example}

Several words can be kept together on one line with the command
\begin{command}
\ci{mbox}\verb|{|\emph{text}\verb|}|
\end{command}
It causes its argument be kept together under all circumstances.

\begin{example}
My phone number will change soon.
It will be \mbox{0116 291 2319}.

The parameter 
\mbox{\emph{filename}} should 
contain the name of the file.
\end{example}
 
\section{Special Characters and Symbols}
%
% Rewrite Section to be more logical.
%
 
\subsection{Quotation Marks}

For \wi{quotation marks} you should \emph{not} use the \verb|"|
\index{""@\texttt{""}} as on a typewriter.  In publishing there are
special opening and closing quotation marks.  In \LaTeX{}, use
two~\verb|`|s on for opening quotation marks and two~\verb|'|s for closing
quotation marks.

\begin{example}
``Please press the `x' key.''
\end{example}
 
\subsection{Dashes and Hyphens}

\LaTeX{} knows four kinds of \wi{dash}es. You can access three of
these with different numbers of consecutive dashes. The fourth sign
is actually no dash at all: It is the mathematical minus sign: \index{-}
\index{--} \index{---} \index{-@$-$} \index{mathematical!minus}

\begin{example}
daughter-in-law, X-rated\\
pages 13--67\\
yes---or no? \\
$0$, $1$ and $-1$
\end{example}
The names for these dashes are: 
\texttt{-} \wi{hyphen}, \texttt{--} \wi{en-dash}, \texttt{---} \wi{em-dash} and
\verb|$-$| \wi{minus sign}.

\subsection{Ellipsis ( \ldots )}

On a typewriter a \wi{comma} or a \wi{period} takes the same amount of
space as any other letter. In book printing these characters occupy
only a little space and are set very close to the preceding letter.
Therefore you cannot enter ``\wi{ellipsis}'' by just typing three
dots, as the spacing would be wrong. Instead there is a special
command for these dots. It is called
\begin{command}
\ci{ldots}
\end{command}
\index{...@\ldots}
\begin{example}
Not like that ... but like that:\\
New York, Tokyo, Budapest, \ldots
\end{example}
 
\subsection{Ligatures}

Some letter combinations are typeset not just by setting the
different letters one after the other, but actually by using special
symbols.
\begin{code}
{\large ff fi fl ffi\ldots}\quad
instead of\quad {\large f{}f f{}i f{}l f{}f{}i \ldots}
\end{code}
These so-called \wi{ligature}s can be prohibited by inserting a \ci{mbox}\verb|{}|
between the two letters in question. This might be necessary with
words built from two words.
\begin{example}
Not shelfful\\
but shelf\mbox{}ful
\end{example}
 
\subsection{Accents and Special Characters}
 
\LaTeX{} supports the use of \wi{accent}s and \wi{special character}s
from many languages. Table~\ref{accents} shows all sorts of accents
being applied to the letter o. Naturally other letters work too.

To place an accent on top of an i or a j, their dots have to be
removed. This is accomplished by typing \verb|\i| and \verb|\j|.
\begin{example}
H\^otel, na\"\i ve, \'el\`eve,\\ 
sm\o rrebr\o d, !`Se\~norita!,\\
Sch\"onbrunner Schlo\ss{} 
Stra\ss e
\end{example}
\begin{table}[!hbp]
\caption{Accents and Special Characters} \label{accents}
\begin{lined}{10cm}
\begin{tabular}{*4{cl}}
\A{\`o} & \A{\'o} & \A{\^o} & \A{\~o} \\
\A{\=o} & \A{\.o} & \A{\"o} \\[6pt]
\B{\u}{o} & \B{\v}{o} & \B{\H}{o} & \B{\c}{o} \\
\B{\d}{o} & \B{\b}{o} & \B{\t}{oo} \\[6pt]
\A{\oe}  &  \A{\OE} & \A{\ae} & \A{\AE} \\
\A{\aa} &  \A{\AA} \\[6pt]
\A{\o}  & \A{\O} & \A{\l} & \A{\L} \\
\A{\i}  & \A{\j} & !` & \verb|!`| & ?` & \verb|?`| 
\end{tabular}
\index{dotless \i and \j}\index{Scandinavian letters}
\index{ae@\ae}\index{umlaut}\index{grave}\index{acute}
\index{oe@\oe}

\bigskip
\end{lined}
\end{table}
 
\section{International Language Support}
\index{international} If you need to write documents in \wi{language}s
other than English, \LaTeX{} must apply different \wi{hyphenation
  rules} in order to produce correct output.

For many languages, these changes can be accomplished by using the
\pai{babel} package by Johannes Braams. To use this package, your
\LaTeX{} system has to be specially configured. Your \guide{} should
give more information on this.

If your system is already appropriately configured, you can activate
the \pai{babel} package by adding the command
\begin{command}
\ci{usepackage}\verb|[|\emph{language}\verb|]{babel}| 
\end{command}
\noindent after the \verb|\documentclass| command. Which \emph{language}s your
system supports should also be listed in the Local Guide.

For some languages \textsf{babel} also specifies new commands, which
simplify the input of special characters. The \wi{German} language for
example, contains a lot of umlauts (\"a\"o\"u).  With \textsf{babel}
you can enter an \"o by typing \verb|"o| instead of~\verb|\"o|.

Some computer systems allow you to input special characters directly
from the keyboard. \LaTeX{} can handle such characters. Since the
December 1994 release of \LaTeXe{}, support for several input
encodings is included in the basic distribution of \LaTeXe. Check the
\pai{inputenc} package. When using this package you should consider
that other people might not be able to display your input files on
their computer, because they use a different encoding. For example,
the German umlaut \"a on a PC is encoded as 132 and on some Unix
systems using ISO-LATIN~1 it is encoded as 228. Therefore, use this
feature with care.
  
\section{The Space between Words}

To get a straight right margin in the output, \LaTeX{} inserts varying
amounts of space between the words. At the end of a sentence it
inserts slightly more space, as this makes the text more readable.
\LaTeX{} assumes that sentences end with periods, question marks or
exclamation marks. If a period follows an uppercase letter this is not
taken as a sentence ending since periods after uppercase letters are
normally for abbreviations.

Any exception from these assumptions has to be specified by the
author. A backslash in front of a space generates a space which will
not be enlarged. A tilde~`\verb|~|' character generates a space which cannot be
enlarged and which additionally prohibits a linebreak. The command
\verb|\@| in front of a period specifies, that this period terminates a
sentence even when it follows a uppercase letter.
\cih{"@} \index{~@ \verb.~.} \index{tilde@tilde ( \verb.~.)}
\index{., space after}

\begin{example}
Mr.~Smith was happy to see her\\
cf.~Fig.~5\\
I like BASIC\@. What about you?
\end{example}

The additional space after periods can be disabled with the command
\begin{command}
\ci{frenchspacing}
\end{command}
\noindent which tells \LaTeX{} \emph{not} to insert any more space after a
period than after ordinary character. This is very common in
non-English languages, except for bibliographies. If you use
\ci{frenchspacing}, the command \verb|\@| is not necessary.
    
\section{Titles, Chapters, and Sections}

To help the reader find his or her way through your work, you should
divide it into chapters, sections, and subsections.  \LaTeX{} supports
this with special commands which take the section title as their
argument.  It is up to you to use them in the correct order.

For the \texttt{article} class the following sectioning commands are
available:
\nopagebreak
\begin{code}
\ci{section}\verb|{...}           |\ci{paragraph}\verb|{...}|\\
\ci{subsection}\verb|{...}        |\ci{subparagraph}\verb|{...} |\\
\ci{subsubsection}\verb|{...}     |\ci{appendix}
\end{code}

For the \texttt{report} and the \texttt{book} class you can use two additional 
sectioning commands:
\begin{code}
\ci{part}\verb|{...}              |\ci{chapter}\verb|{...}|
\end{code}

As the \texttt{article} class does not know about chapters, it is quite easy
to add articles as chapters to a book.
The spacing between sections, the numbering and the font size of the
titles will be set automatically by \LaTeX. 

\pagebreak[3]
Two of the sectioning commands are a bit special: 
\begin{itemize}
\item The \ci{part} command does
  not influence the numbering sequence of chapters.  
\item The \ci{appendix} command does not take an argument. It just
  changes the chapter\footnote{For the article style it changes the section
    numbering} numbering to letters.
\end{itemize}



\LaTeX{} creates a table of contents by taking the section headings
and page numbers from the previous run of the document. The command
\begin{command}
\ci{tableofcontents}
\end{command}
\noindent expands to a table of contents at the place where it is issued. A new
document has to be processed (``\LaTeX ed'') twice to get a
correct \wi{table of contents}. In some circumstances it might be
necessary to compile the document a third time. \LaTeX{} will tell you
when this is necessary.

All sectioning commands listed above also exist as ``starred''
versions.  A ``starred'' version of a command is built by adding a
star \verb|*| after the command name.  They generate section headings which
will not show up in the table of contents and which will not get
numbered. The command \verb|\section{Help}| for example would become
 \verb|\section*{Help}|.

Normally the section headings show up in the table of contents exactly
as they were entered in the text. Sometimes this is not possible,
because the heading is too long to fit into the table of contents. The
entry for the table of contents can therefore be specified as an
optional argument before the actual heading.
\begin{code}
\verb|\chapter[Read it! It's Exciting]{This is a very long|\\
\verb|                 and especially boring title}|
\end{code} 

The \wi{title} of the whole document is generated by issuing a 
\begin{command}
\ci{maketitle}
\end{command}
\noindent command. The contents of the title has to be defined by the commands
\begin{command}
\ci{title}\verb|{...}|, \ci{author}\verb|{...}| 
and optionally \ci{date}\verb|{...}| 
\end{command}
\noindent before calling \verb|\maketitle|. In the argument of \ci{authors} you can
supply several names separated by \ci{and} commands. 

An example of some of the above mentioned commands can be found in
Figure~\ref{document} on page~\pageref{document}.

Apart from the sectioning commands explained above, \LaTeXe{}
introduced 3 additional commands, for use with the \verb|book| class. 
\begin{command}
\ci{frontmatter}, \ci{mainmatter} and \ci{backmatter}
\end{command}
They are useful for dividing your publication. The commands alter
chapter headings, and page numbering to work as you would expect it in
a book.

\section{Cross References}

In books, reports and articles there are often 
\wi{cross references} to figures, tables and special segments of text.
\LaTeX{} provides the following commands for cross referencing
\begin{command}
\ci{label}\verb|{|\emph{marker}\verb|}|, \ci{ref}\verb|{|\emph{marker}\verb|}| 
and \ci{pageref}\verb|{|\emph{marker}\verb|}|
\end{command}
\noindent Where \emph{marker} is an identifier chosen by the user. \LaTeX{}
replaces \verb|\ref| by the number of the section, subsection, figure,
table, or theorem  where the corresponding
\verb|\label| command was issued. \verb|\pageref| prints the page number of the
corresponding \verb|\label| command. Here also the numbers from the
previous run are used.

\begin{example}
A reference to this subsection
\label{sec:this} looks like:
``see section~\ref{sec:this} on 
page~\pageref{sec:this}.''
\end{example}
 
\section{Footnotes}
With the command
\begin{command}
\ci{footnote}\verb|{|\emph{footnote text}\verb|}|
\end{command}
\noindent a footnote will be printed at the foot of the current page.

\begin{example}
Footnotes\footnote{This 
  is a footnote} are often used
by people using \LaTeX.
\end{example}
 

\section{Emphasized Words}

In manuscripts produced by typewriter, important words get
$\underline{\mathrm{underlined}}$. In printed books these words are
\emph{emphasised}. The command to switch to an \emph{emphasised} font
is called
\begin{command}
\ci{emph}\verb|{|\emph{text}\verb|}|
\end{command}
\noindent Its argument is the text to be \wi{emphasise}d.

\begin{example}
\emph{If you use 
  \emph{emphasising} in an
  already emphasised text, then
  \LaTeX{} uses an 
  \emph{upright} font for 
  emphasising.}
\end{example}
 
\section{Environments} \label{env}

To typeset special purpose text, \LaTeX{} defines many different
\wi{environment}s for all sorts of formatting:
\begin{command}
\ci{begin}\verb|{|\emph{name}\verb|}|\quad
   \emph{text}\quad
\ci{end}\verb|{|\emph{name}\verb|}|
\end{command}
\noindent Where \emph{name} is the name of the environment. Environments can be
called several times within each other as long as the calling order is
maintained.
\begin{code}
\verb|\begin{aaa}...\begin{bbb}...\end{bbb}...\end{aaa}|
\end{code}

\noindent In the following sections all important environments are explained.

\subsection{Itemise, Enumerate, and Description}

The \ei{itemize} environment is suitable for simple lists, the
\ei{enumerate} environment for enumerated lists, and the
\ei{description} environment for descriptions.
\cih{item}

\begin{example}
\begin{enumerate}
\item You can mix the list
environments to your taste:
\begin{itemize}
\item But it might start to
look silly. 
\item[-] With a dash.
\end{itemize}
\item Therefore remember:
\begin{description}
\item[Stupid] things will not
become smart because they are
in a list.
\item[Smart] things though, can be
presented beautifully in a list.
\end{description}
\end{enumerate}
\end{example}
 
\subsection{Flushleft, Flushright, and Center}

The environments \ei{flushleft} and \ei{flushright} generate
paragraphs which are either left or \wi{right aligned}. \index{left
  aligned} The \ei{center} environment generates centred text. If you
do not issue \ci{\bs} to specify linebreaks, \LaTeX{} will
automatically determine linebreaks.

\begin{example}
\begin{flushleft}
This text is\\ left aligned. 
\LaTeX{} is not trying to make 
each line the same length.
\end{flushleft}
\end{example}

\begin{example}
\begin{flushright}
This text is right\\ aligned. 
\LaTeX{} is not trying to make
each line the same length.
\end{flushright}
\end{example}

\begin{example}
\begin{center}
At the centre\\of the earth
\end{center}
\end{example}

\subsection{Quote, Quotation, and Verse}

The \ei{quote} environment is useful for quotes, important phrases and
examples.
\begin{example}
A typographical rule of thumb
for the line length is:
\begin{quote}
No line should contain more than
66~characters.

This is why \LaTeX pages have 
such large borders by default.
\end{quote}
That's why multicolumn print is
often used in newspapers.
\end{example}

There are two similar environments: the \ei{quotation} and the
\ei{verse} environments. The \texttt{quotation} environment is useful
for longer quotes going over several paragraphs, because it does
indent paragraphs. The \texttt{verse} environment is useful for poems
where the line breaks are important. The lines are separated by
issuing a \ci{\bs} at the end of a line and a empty line after each
verse.


\begin{example}
I know only one English poem by 
heart. It is about Humpty Dumpty.
\begin{flushleft}
\begin{verse}
Humpty Dumpty sat on a wall:\\
Humpty Dumpty had a great fall.\\ 
All the King's horses and all
the King's men\\
Couldn't put Humpty together
again.
\end{verse}
\end{flushleft}
\end{example}

\subsection{Printing Verbatim}

Text which is enclosed between \verb|\begin{|\ei{verbatim}\verb|}| and
\verb|\end{verbatim}| will be directly printed, as if it was typed on a
typewriter, with all linebreaks and spaces, without any \LaTeX{}
command being executed.

Within a paragraph, similar functionality can be accessed with
\begin{command}
\ci{verb}\verb|+|\emph{text}\verb|+|
\end{command}
\noindent The \verb|+| is just an example delimiter character. You can use any
character except letters, \verb|*| or blank. Many \LaTeX{} examples in this
booklet are typeset with this command.

\begin{example}
The \verb|\ldots| command \ldots

\begin{verbatim}
10 PRINT "HELLO WORLD ";
20 GOTO 10
\end{verbatim}
\end{example}

\begin{example}
\begin{verbatim*}
the starred version of
the      verbatim   
environment emphasises
the spaces   in the text
\end{verbatim*}
\end{example}

The \ci{verb} command can be used in a similar fashion with a star:
\begin{example}
\verb*|like   this :-) |
\end{example}

The \texttt{verbatim} environment and the \verb|\verb| command may not be used
within parameters of other commands.


\subsection{Tabular}

The \ei{tabular} environment can be used to typeset beautiful
\wi{table}s with optional horizontal and vertical lines. \LaTeX{}
determines the width of the columns automatically.

The \emph{table spec} argument of the 
\begin{command}
\verb|\begin{tabular}{|\emph{table spec}\verb|}|
\end{command} 
\noindent command defines the format of the table. Use an \texttt{l} for a column of
left aligned text, \texttt{r} for right aligned text and \texttt{c} for
centred text, \verb|p{|\emph{width}\verb|}| for a column containing justified
text with linebreaks, and \verb.|. for a vertical line.
 
Within a \texttt{tabular} environment \verb|&| jumps to the next column, \ci{\bs}
starts a new line and \ci{hline} inserts an horizontal line.
\index{"|@ \verb."|.}
\begin{example}
\begin{tabular}{|r|l|}
\hline
7C0 & hexadecimal \\
3700 & octal \\
11111000000 & binary \\
\hline \hline
1984 & decimal \\
\hline
\end{tabular}
\end{example}

\begin{example}
\begin{tabular}{|p{4.7cm}|}
\hline
Welcome to Boxy's paragraph.
We sincerely hope you'll 
all enjoy the show.\\
\hline 
\end{tabular}

\end{example}

With the \verb|@{...}| construct it is possible to specify the column
separator. This command kills the intercolumn space and
replaces it with whatever is included in the curly braces. 
One common use for this command is explained below in the decimal
alignment problem. Another possible usage is to suppress leading space
in a table with \verb|@{}|.

\begin{example}
\begin{tabular}{@{} l @{}}
\hline 
no leading space\\\hline
\end{tabular}
\end{example}
\begin{example}
\begin{tabular}{l}
\hline
leading space left and right\\
\hline
\end{tabular}
\end{example}

%
% This part by Mike Ressler
%

\index{decimal alignment} Since there is no built-in way to align
numeric columns on a decimal point\footnote{If the `tools' bundle is
  installed on your system, have a look at the \pai{dcolumn} package},
we can ``cheat'' and do it by using two columns: a right-aligned
integer and a left-aligned fraction. The \verb|@{}| command in the
\verb|\begin{tabular}| line replaces the normal intercolumn spacing with
just a ``.'', giving the appearance of a single,
decimal-point-justified column.  Don't forget to replace the decimal
point in your numbers with a column separator (\verb|&|)! A column label
can be placed above our numeric ``column'' by using the
\ci{multicolumn} command.
 
\begin{example}
\begin{tabular}{c r @{.} l}
Pi expression       &
\multicolumn{2}{c}{Value} \\
\hline
$\pi$               & 3&1416  \\
$\pi^{\pi}$         & 36&46   \\
$(\pi^{\pi})^{\pi}$ & 80662&7 \\
\end{tabular}
\end{example}

\section{Floating Bodies}
Today most publications contain a lot of figures and tables. These
elements need special treatment because they cannot be broken across
pages.  One method would be to start a new page every time a figure or
a table is too large to fit on the present page. This approach would
leave pages partially empty which looks very bad.

The solution to this problem is to `float' any figure or table, which
does not fit on the current page, to a later page while filling the
current page with body text. \LaTeX{} offers two environments for
\wi{floating bodies}. One for tables and  one for figures.  To
take full advantage of these two environments it is important to
understand approximately how \LaTeX{} handles floats internally.
Otherwise floats may become a major source of frustration because
\LaTeX{} never puts them where you want them to be.

\bigskip
Let's first have a look at the commands \LaTeX{} supplies
for floats:

Any material enclosed in a \ei{figure} or \ei{table} environment will
be treated as floating matter. Both float environments support an optional
parameter
\begin{command}
\verb|\begin{figure}[|\emph{placement specifier}\verb|]| or
\verb|\begin{table}[|\emph{placement specifier}\verb|]|
\end{command}
\noindent called the \emph{placement specifier}. This parameter
is used to tell \LaTeX{} about the locations the float is allowed to
be moved to.  A \emph{placement specifier} is constructed by building a string
of \emph{float placing permissions}. See Table~\ref{tab:permiss}.

\begin{table}[!bp]
\caption{Float Placing Permissions}\label{tab:permiss}
\noindent \begin{minipage}{\textwidth}
\medskip
\begin{center}
\begin{tabular}{@{}cp{10cm}@{}}
Spec&Permission to place the float \ldots\\
\hline
\rule{0pt}{1.05em}\texttt{h} & \emph{here} at the very place in the text
  where it occurred.  This is useful mainly for small floats.\\[0.3ex]
\texttt{t} & at the \emph{top} of a page\\[0.3ex]
\texttt{b} & at the \emph{bottom} of a page\\[0.3ex]
\texttt{p} & on a special \emph{page} containing only floats.\\[0.3ex]
\texttt{!} & without considering most of the  internal parameters\footnote{Such as the
    maximum number of floats allowed  on one page} which could stop this
  float from being placed.
\end{tabular}
\end{center}
\end{minipage}
\end{table}

\pagebreak[3]
A table could be started with the following line e.g.
\begin{code}
\verb|\begin{table}[!hbp]|
\end{code}
\noindent The \wi{placement specifier} \verb|[!hbp]| allows \LaTeX{} to 
place the table right here (\texttt{h}) or at the bottom (\texttt{b}) 
of some page
or on a special floats page (\texttt{p}) and all that even if it does not
look that good (\texttt{!}). If no placement specifier is given, the standard
classes assume \verb|[tbp]|.

\LaTeX{} will place every float it encounters, according to the
placement specifier supplied by the author. If a float cannot be
placed on the current page it is deferred either to the
\emph{figures} or the \emph{tables} queue\footnote{These are fifo -
  `first in first out' queues!}.  When a new page is started,
\LaTeX{} first checks if it is possible to fill a special `float'
page with floats from the queues. If this is not possible, the first
float on each queue is treated as if they had just occurred in the
text: \LaTeX{} tries again to place them according to their
respective placement specifiers (except `h' which is no longer
possible).  Any new floats occurring in the text get placed into the
appropriate queues. \LaTeX{} strictly maintains the original order of
appearance for each type of float. That's why a figure which cannot
be placed, pushes all the further figures to the end of the document.
Therefore:

\begin{quote}
If \LaTeX{} is not placing the floats as you expected,
it is often only one float jamming one of the two float queues.
\end{quote}                 

\bigskip
\noindent Having explained the difficult bit, there are some more things to
mention about the \ei{table} and \ei{figure} environments.
With the 
\begin{command}
\ci{caption}\verb|{|\emph{caption text}\verb|}|
\end{command}
\noindent command you can define a caption for the float. A running number and
the string ``Figure'' or ``Table'' will be added by \LaTeX.

The two commands
\begin{command}
\ci{listoffigures} and \ci{listoftables} 
\end{command}
\noindent operate analogously to the \verb|\tableofcontents| command,
printing a list of figures or tables respectively.  In these lists,
the whole caption will be repeated. If you tend to use long captions,
you must have a shorter version of the caption going into the lists.
This is accomplished by entering the short version in brackets after
the \verb|\caption| command.
\begin{code}
\verb|\caption[Short]{LLLLLoooooonnnnnggggg}| 
\end{code}

With \verb|\label| and \verb|\ref| you can create a reference to a float 
within your text.

The following example draws a square and inserts it into the
document. You could use this if you wanted to reserve space for images
you are going to paste into the finished document.

\begin{code}
\begin{verbatim}
Figure~\ref{white} is an example of Pop-Art.
\begin{figure}[!hbp]
\makebox[\textwidth]{\framebox[5cm]{\rule{0pt}{5cm}}}
\caption{Five by Five in Centimetres} \label{white}
\end{figure}
\end{verbatim}
\end{code}

\noindent In the example above\footnote{assuming the figure queue is empty} 
\LaTeX{} will try \emph{really hard}~(\texttt{!}) to
place the figure right \emph{here}~(\texttt{h}). If this is not possible,
it tries to place the figure at the \emph{bottom}~(\texttt{b}) of the page. 
Failing to place the figure on the current page, it determines if it
is possible to create a float page containing this figure and maybe
some tables from the tables queue. If there is not enough material for
a special float page, \LaTeX{} starts a new page and once more treats the
figure as if it had just occurred in the text.

Under certain circumstances it might be necessary to use the 
\begin{command}
\ci{clearpage} or even the \ci{cleardoublepage} 
\end{command}
\noindent command. It orders \LaTeX{} to immediately place all 
floats remaining in the queues and then start a new
page. \ci{cleardoublepage} goes to a new lefthand page on top of that.


Later in this introduction you will learn how to include PostScript
drawings into your \LaTeXe{} documents. 

\section{Adding New Commands and Environments}
In the first chapter, I explained that \LaTeX{} needs
information about the logical structure of the text to pick the right
layout. This is a neat idea, but in practice you often get to the
limits of this, because \LaTeX{} just does not have a specialised
environment or command for your exact purpose. 

One solution is to use several \LaTeX{} commands to produce the layout
you have in mind. If you have to do this once, then there is no
problem, but if it occurs repeatedly, it takes a lot of time. If
you ever want to change the layout you have to work 
through the whole input file and edit all the items in question.

To solve this problem, \LaTeX{} allows you to define your own commands
and environments to the language.

\subsection{New Commands}

To add your own commands, use the
\begin{command}
\ci{newcommand}\verb|{|%
       \emph{name}\verb|}[|\emph{num}\verb|]{|\emph{definition}\verb|}|
\end{command}
\noindent command. 
Basically, the command requires two arguments. The \emph{name} of the
command you want to create and the \emph{definition} of the command.
The \emph{num} argument in square brackets is
optional.  You can use it to create new commands which themselves
take up to 9 arguments. 

The following two examples should help you to get the idea.
The first example defines a new command called \verb|\tnss| this is
short for ``The Not So Short Introduction to \LaTeXe''. Such a command
could come in handy if you have to write the title of this book over 
and over again. 

\begin{example}
\newcommand{\tnss}
    {The not so Short Introduction 
        to \LaTeXe}
% in the document body :
``\tnss'' \ldots{} ``\tnss''
\end{example}

The next example illustrates how to use the \emph{num} argument.
The \verb|#1| sequence gets replace by the argument you specify.
If you wanted to use more than one argument, use \verb|#2| and
so on.

\begin{example}
\newcommand{\txsit}[1]
    {The \emph{#1} Short 
      Introduction to \LaTeXe}
% in the document body: 
\begin{itemize}
\item \txsit{not so}
\item \txsit{very}
\end{itemize}
\end{example}

\LaTeX{} will not allow you  to create a new command which already
exists. If you explicitly want to override an existing command you
have to use the \ci{renewcommand}.  Apart from its name, it uses the
same syntax as the \verb|\newcommand| command. In certain cases you
might also want to use the \ci{providecommand} command. It works like
\ci{newcommand}, but if the new command is already defined, \LaTeXe{} just
ignores it. 

\subsection{New Environments}
Analogously to the \verb|\newcommand| command there is a command to create your
own environments. When writing this introduction, I have created
special environments for the structures I used repeatedly through
out the introduction: ``examples'', ``bits of code'' and ``command
definition boxes''. The \ci{newenvironment} command uses the following
syntax:

\begin{command}
\ci{newenvironment}\verb|{|%
       \emph{name}\verb|}[|\emph{num}\verb|]{|%
       \emph{before}\verb|}{|\emph{after}\verb|}|
\end{command}

Like the \verb|\newcommand| command, you can use \ci{newenvironment}
with an optional argument and without. The material specified
in the \emph{before} argument is processed before the text in the 
environment gets processed. The material in the \emph{after} argument gets
processed when the \verb|\end{|\emph{name}\verb|}| command is encountered.

The example below illustrates the usage of the \ci{newenvironment}
command. 

\begin{example}
\newenvironment{king}
    {\begin{quote}}{\end{quote}}
% use this in the body part
\begin{king}
My humble subjects \ldots
\end{king}
\end{example}

The \emph{num} argument is used the same way as in the
\verb|\newcommand| command. \LaTeX{} makes sure that you do not define
an environment which already exists. If you ever want to change an
existing command, you can use the \ci{renewenvironment} command. It
uses the same syntax as the \ci{newenvironment} command.


\endinput


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "lshort2e"
%%% En










