A rule and combinations
6.2.4 A rule and combinations
There is only one rule you must remember.
Rule
List environments An \item command must immediately follow \begin{enumerate}, \begin{itemize}, or \begin{description}.
Of course, spaces and line breaks can separate them. If you break this rule, you get an error message. For instance,
\begin{description} This is wrong!
\item[Chopped lattice] a reduced lattice; gives the error message
! LaTeX Error: Something’s wrong--perhaps a missing \item. l.105
\item[Chopped lattice]
a reduced lattice;
6.2 List environments 121
If you see this error message, remember the rule for list environments and check for text preceding the first \item.
You can nest up to four list environments; for instance,
which is typed as \begin{enumerate}
\item First item of Level 1. \begin{enumerate}
\item First item of Level 2. \begin{enumerate}
\item First item of Level 3. \begin{enumerate}
\item First item of Level 4. \item Second item of Level 4.\label{level4}
\end{enumerate} \item Second item of Level 3.
\end{enumerate} \item Second item of Level 2.
\end{enumerate} \item Second item of Level 1.
\end{enumerate} Referencing the second item of Level 4: \ref{level4}
Note that the label level4 collected all four of the counters (see Section 10.4.2).
You can also mix list environments:
122 Chapter 6 Text environments
which is typed as \begin{enumerate}
\item First item of Level 1. \begin{itemize}
\item First item of Level 2. \begin{enumerate}
\item First item of Level 3. \begin{itemize}
\item First item of Level 4. \item Second item of Level 4.\label{enums}
\end{itemize} \item Second item of Level 3.
\end{enumerate} \item Second item of Level 2.
\end{itemize} \item Second item of Level 1.
\end{enumerate} Referencing the second item of Level 4: \ref{enums}
Now the label enums collects only the two enumerate counters (see Section 10.4.2). The indentations are, of course, not needed. I use them to keep track of the level of nesting. In all three types of list environment, the \item command may be followed by an optional argument, which is displayed at the beginning of the typeset item:
\item[label ] Note that for enumerate and itemize the resulting typography may leave something
to be desired.
6.3 Style and size environments 123
Tip If the text following an \item command starts with an opening square bracket, [, then L A TEX thinks that \item has an optional argument. To prevent this problem from occurring, type [ as {[}. Similarly, a closing square bracket, ], inside the optional argument should be typed as {]}.
Tip You may want to use a list environment solely for the way the items are displayed, without any labels. You can achieve this effect by using \item[].
You can change the style of the numbers in an enumerate environment by re- defining the counter as suggested in Section 15.5.1:
\renewcommand{\labelenumi}{{\normalfont (\roman{enumi})}} The labels then are displayed as (i), (ii), and so on. This modification only works if you
do not want to reference these items. If you want the \ref command to work properly, use David Carlisle’s enumerate package (see Section 12.3.1). For an example of how to use Carlisle’s environment, see Section 15.2.1.
Section 3.3 of The L A TEX Companion, 2nd edition [46] explains how to customize the three list environments and discusses Bernd Schandl’s paralist package, which provides a number of new list environments and makes customizing the three legacy list environments much easier. For custom lists, see Section 15.6.