The list environment
15.6.2 The list environment
Custom lists are created with the list environment, which is invoked as follows: \begin{list}{default_label }{declarations }
\item item1 \item item2 ...
\end{list} The arguments are
default label, the label for any items that do not specify their own, similar to the optional argument of the \item command
declarations, the vertical and horizontal length commands and any other required parameters for the list
Here is a very simple example:
Here are the most important L A TEX rules about spaces in text, sentences, and paragraphs:
♦ Rule 1: Two or more spaces in text are the same as one. ♦ Rule 2: A blank line (that is, two end-of-line characters sepa-
rated only by blanks and tabs) indicates the end of a paragraph. Rules 1 and 2 make typing and copying very convenient.
I have used the ♦ math symbol ($\diamondsuit$) as a default label, and I set the item box 0.5 inch from either margin. So this example is typed as follows:
\noindent Here are the most important \LaTeX\ rules about spaces in text, sentences, and paragraphs: \begin{list}{$\diamondsuit$}{\setlength{\leftmargin}%
{.5in}\setlength{\rightmargin}{.5in}}
\item \textbf{Rule 1:} Two or more spaces in text are the same as one. \item \textbf{Rule 2:} A blank line (that is, two end-of-line characters separated only by blanks and tabs) indicates the end of a paragraph. \end{list} Rules 1 and~2 make typing and copying very convenient.
Here is a second variant:
410 Chapter 15 Customizing L A TEX
Here are the most important L A TEX rules about spaces in text, sentences, and paragraphs:
Rule 1: Two or more consecutive spaces in text are the same as one. Rule 2:
A blank line (that is, two end-of-line characters separated only by blanks and tabs) indicates the end of a paragraph.
Rules 1 and 2 make typing and copying very convenient. In this example, I dropped the optional default label and typed Rule 1: and Rule 2:
as (optional) arguments of the \item commands: \noindent Here are the most important \LaTeX\ rules about
spaces in text, sentences, and paragraphs: \begin{list}{}{\setlength{\leftmargin}{.5in}%
\setlength{\rightmargin}{.5in}} \item[\textbf{Rule 1:}] Two or more consecutive spaces in text are the same as one. \item[\textbf{Rule 2:}] A blank line (that is, two end-of-line characters separated only by blanks and tabs) indicates the end of a paragraph. \end{list} Rules 1 and~2 make typing and copying very convenient.
For further simple examples, you can look at various document class files to see how standard environments such as verse, quote, and so on, are defined.
Using counters It is not very L A TEX-like to provide the numbers for the rules in the examples above.
It would be more logical for L A TEX to do the numbering. The following is a more L A TEX-like coding of the second example:
\noindent Here are the most important \LaTeX\ rules about spaces in text, sentences, and paragraphs: \newcounter{spacerule} \begin{list}{\textbf{Rule \arabic{spacerule}:}}
{\setlength{\leftmargin}{.5in} \setlength{\rightmargin}{.5in} \usecounter{spacerule}}
\item Two or more consecutive spaces in text are the same as one.\label{Li:Twoor} \item A blank line (that is, two end-of-line
15.6 Custom lists 411
characters separated only by blanks and tabs) indicates the end of a paragraph.\label{Li:blankline}
\end{list} Rules \ref{Li:Twoor} and~\ref{Li:blankline} make typing and copying very convenient.
Note that
1. I declared the counter before the list environment with the line \newcounter{spacerule}
2. I defined the default label as \textbf{Rule \arabic{spacerule}:} item In the declarations, I specified
that the list should use the spacerule counter with the command \usecounter{spacerule}