• 沒有找到結果。

\begin{environment } text \end{environment }

Where environment is the name of the environment. Environments can be nested within each other as long as the correct nesting order is maintained.

\begin{aaa}...\begin{bbb}...\end{bbb}...\end{aaa}

In the following sections all important environments are explained.

2.11 Environments 39

2.11.1 Itemize, Enumerate, and Description

The itemize environment is suitable for simple lists, the enumerate envi-ronment for enumerated lists, and the description envienvi-ronment for descrip-tions.

\flushleft

\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}

1. You can mix the list environments to your taste:

• But it might start to look silly.

- With a dash.

2. Therefore remember:

Stupid things will not become smart because they are in a list.

Smart things, though, can be presented beautifully in a list.

2.11.2 Flushleft, Flushright, and Center

The environments flushleft and flushright generate paragraphs that are either left- or right-aligned. The center environment generates centred text.

If you do not issue \\ to specify line breaks, LATEX will automatically deter-mine line breaks.

\begin{flushleft}

This text is\\ left-aligned.

\LaTeX{} is not trying to make each line the same length.

\end{flushleft}

This text is

left-aligned. LATEX is not trying to make each line the same length.

\begin{flushright}

This text is right-\\aligned.

\LaTeX{} is not trying to make each line the same length.

\end{flushright}

This text is right-aligned. LATEX is not trying to make each line the same length.

\begin{center}

At the centre\\of the earth

\end{center}

At the centre of the earth

2.11.3 Quote, Quotation, and Verse

The quote environment is useful for quotes, important phrases and examples.

A typographical rule of thumb for the line length is:

\begin{quote}

On average, no line should be longer than 66 characters.

\end{quote}

This is why \LaTeX{} pages have such large borders by default and also why multicolumn print is used in newspapers.

A typographical rule of thumb for the line length is:

On average, no line should be longer than 66 characters.

This is why LATEX pages have such large bor-ders by default and also why multicolumn print is used in newspapers.

There are two similar environments: the quotation and the verse envi-ronments. The quotation environment is useful for longer quotes going over several paragraphs, because it indents the first line of each paragraph. The verse environment is useful for poems where the line breaks are important.

The lines are separated by issuing a \\ at the end of a line and an empty line after each verse.

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}

I know only one English poem by heart. It is about Humpty Dumpty.

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.

2.11.4 Abstract

In scientific publications it is customary to start with an abstract which gives the reader a quick overview of what to expect. LATEX provides the abstract environment for this purpose. Normally abstract is used in documents typeset with the article document class.

\begin{abstract}

The abstract abstract.

\end{abstract}

The abstract abstract.

2.11 Environments 41

2.11.5 Printing Verbatim

Text that is enclosed between \begin{verbatim} and \end{verbatim} will be directly printed, as if typed on a typewriter, with all line breaks and spaces, without any LATEX command being executed.

Within a paragraph, similar behavior can be accessed with

\verb+text +

The + is just an example of a delimiter character. You can use any character except letters, * or space. Many LATEX examples in this booklet are typeset with this command.

The \verb|\ldots| command \ldots

\begin{verbatim}

10 PRINT "HELLO WORLD ";

20 GOTO 10

\end{verbatim}

The \ldots command . . .

10 PRINT "HELLO WORLD ";

20 GOTO 10

\begin{verbatim*}

the starred version of the verbatim environment emphasizes the spaces in the text

\end{verbatim*}

the␣starred␣version␣of the␣␣␣␣␣␣verbatim environment␣emphasizes the␣spaces␣␣␣in␣the␣text

The \verb command can be used in a similar fashion with a star:

\verb*|like this :-) | like␣␣␣this␣:-)␣

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

2.11.6 Tabular

The tabular environment can be used to typeset beautiful tables with optional horizontal and vertical lines. LATEX determines the width of the columns automatically.

The table spec argument of the

\begin{tabular}[pos]{table spec}

command defines the format of the table. Use an l for a column of left-aligned text, r for right-left-aligned text, and c for centred text; p{width }

for a column containing justified text with line breaks, and | for a vertical line.

If the text in a column is too wide for the page, LATEX won’t automatically wrap it. Using p{width } you can define a special type of column which will wrap-around the text as in a normal paragraph.

The pos argument specifies the vertical position of the table relative to the baseline of the surrounding text. Use either of the letters t , b and c to specify table alignment at the top, bottom or center.

Within a tabular environment, & jumps to the next column, \\ starts a new line and \hline inserts a horizontal line. You can add partial lines by using the \cline{j -i }, where j and i are the column numbers the line should extend over.

\begin{tabular}{|r|l|}

\hline

7C0 & hexadecimal \\

3700 & octal \\ \cline{2-2}

11111000000 & binary \\

\hline \hline 1984 & decimal \\

\hline

\end{tabular}

7C0 hexadecimal 3700 octal 11111000000 binary

1984 decimal

\begin{tabular}{|p{4.7cm}|}

\hline

Welcome to Boxy’s paragraph.

We sincerely hope you’ll all enjoy the show.\\

\hline

\end{tabular}

Welcome to Boxy’s paragraph.

We sincerely hope you’ll all en-joy the show.

The column separator can be specified with the @{...} construct. This command kills the inter-column space and replaces it with whatever is be-tween the curly braces. One common use for this command is explained below in the decimal alignment problem. Another possible application is to suppress leading space in a table with @{} .

\begin{tabular}{@{} l @{}}

\hline

no leading space\\

\hline

\end{tabular}

no leading space