1 Listings & Enumerations
A short overview about listings & enumerations in
LATEX.
1.1 description
The description environment is a listing variant in
LATEX that can be used for a glossary, among other things.
Example 1
Input:
\begin{description}
\item[A key point]
There must be something here to see the effect.
\item[Another key point] and text behind it
\end{description}
Output:
- A key point There must be something here to see the effect.
- Another key point and text behind it
Example 2 How not to do it
Input:
\begin{description}
\item[A key point] \\
A line break is not enough to bring the text
\item[Another key point] \\ down.
\end{description}
Output:
- A key point A line break is not enough to bring the text
- Another key point down.
Example 3 almost correct
Input:
\begin{description}
\item A key point \\
If the key point is not in the option
\item Another key point\\
the key point is not bold
but the line break works.
\end{description}
Output:
- A key point
If the key point is not in the option
- Another key point
the key point is not bold
but the line break works.
Example 4 How it works
Input:
\begin{description}
\item[A key point]\hfill \\
There must be something here to see the effect.
\item[Another key point]\hfill \\ and text behind it
\end{description}
Output:
- A key point
-
There must be something here to see the effect.
- Another key point
- and text behind it
Advertisement
1.2 itemize
The itemize environment in
LATEX provides an unnumbered listing.
Input:
\begin{itemize}
\item first key point
\item second key point
\end{itemize}
Output:
- first key point
- second key point
The itemize environment can be nested up to four levels deep within itself.
Input:
\begin{itemize}
\item first level
\begin{itemize}
\item second level
\begin{itemize}
\item third level
\begin{itemize}
\item fourth level
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
Output:
level | symbol / label | Example |
1. level | bullet | • |
2. level | dash | - |
3. level | asterisk | * |
4. level | period | · |
Input:
\begin{itemize}
\item first level
\begin{itemize}
\item second level
\begin{itemize}
\item third level
\begin{itemize}
\item fourth level
\end{itemize}
\item back to the third level
\item another entry
\end{itemize}
\item here second level
\end{itemize}
\item and here first level
\end{itemize}
Output:
* back to the third level
* another entry
- here second level
• and here first level
1.2.1 change label output
The output of the labels can be changed. At the beginning an example for using the option of the item command.
\item[Option] Here a label can be set as an option.
Example 1 Mixing characters
Input:
\begin{itemize}
\item[a)] A key point
\item[*)] Another key point
\item[?)] key point three
\end{itemize}
Output:
a) A key point
*) Another key point
?) key point three
Example 2 uniform characters
Input:
\begin{itemize}
\item[a] A key point
\item[b] Another key point
\item[c] key point three
\end{itemize}
Output:
a A key point
b Another key point
c key point three
Example 3 no / without characters
Input:
\begin{itemize}
\item[] A key point
\item[] Another key point
\item[] key point three
\end{itemize}
Output:
A key point
Another key point
key point three
Instead of using the option, the label fields could be changed.
level | label field |
1. level | \labelitemi |
2. level | \labelitemii |
3. level | \labelitemiii |
4. level | \labelitemiv |
Suppose you want to mark all layers with
•:
\renewcommand{\labelitemi}{$\bullet$}
\renewcommand{\labelitemii}{$\bullet$}
\renewcommand{\labelitemiii}{$\bullet$}
\renewcommand{\labelitemiv}{$\bullet$}
Then the example changes to:
Input:
\begin{itemize}
\item first level as usual with $\bullet$
\begin{itemize}
\item now also second level has a $\bullet$
\begin{itemize}
\item as third level
\begin{itemize}
\item and also fourth level has a $\bullet$
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
Output:
- first level as usual with •
• now also second level has a•
• as third level
• and also fourth level has a •
Advertisement
1.3 enumerate
The enumerate environment in
LATEX provides a numbered listing.
Input:
\begin{enumerate}
\item first
\item second
\end{enumerate}
Output:
- first
- second
The enumerate environment (like the itemize environment) can be nested up to four levels deep within itself.
Note: If five or more levels are used, you will get this error message
! LaTeX Error: Too deeply nested. |
By default, the numbering is on the first level with
arabic numerals, on the second level with
(small Latin letter), on the third level with
small roman numerals and on the fourth level with
large latin letters.
level | symbol / label | example |
1. level | arabic numerals. | 1. |
2. level | (small latin letter) | (b) |
3. level | small roman numerals. | iii. |
4. level | large latin letters. | D. |
Note: At level 1, 3 and 4 period
. and at level 2 parentheses
( ) are part of the numbering.
Input:
\begin{enumerate}
\item first level
\begin{enumerate}
\item second level
\begin{enumerate}
\item third level
\begin{enumerate}
\item fourth level
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
Output:
- first level
(a) second level
i. third level
A. fourth level
Input:
\begin{enumerate}
\item first level
\begin{enumerate}
\item second level
\begin{enumerate}
\item third level
\begin{enumerate}
\item fourth level
\end{enumerate}
\item back to the third level
\item another entry
\end{enumerate}
\item here second level
\end{enumerate}
\item and here first level
\end{enumerate}
Output:
- first level
(a) second level
- third level
- fourth level
- back to the third level
- another entry
(b) here second level
and here first level
1.3.1 change label output
The output of the labels and label fields could be changed.
level | counter | counter value | label field |
1. level | enumi | \theenumi | \labelenumi |
2. level | enumii | \theenumii | \labelenumii |
3. level | enumiii | \theenumiii | \labelenumiii |
4. level | enumiv | \theenumiv | \labelenumiv |
Suppose you want to remove periods and parentheses, you have to renewcommand the label fields in this way:
\renewcommand{\labelenumi}{\theenumi}
\renewcommand{\labelenumii}{\theenumii}
\renewcommand{\labelenumiii}{\theenumiii}
\renewcommand{\labelenumiv}{\theenumiv}
Accordingly, the output also changes to:
Input:
\begin{enumerate}
\item first level
\begin{enumerate}
\item second level
\begin{enumerate}
\item third level
\begin{enumerate}
\item fourth level
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
Output:
1 first level
a second level
i third level
A fourth level
If you want to change the numbers, it works in a similar way. To do this, the display symbol (label field) of the enumeration is changed.
Example 1 abc enumeration
Input:
\renewcommand{\labelenumi}{\alph{enumi}}
\begin{enumerate}
\item one
\item two
\item three
\end{enumerate}
Output:
a one
b two
c three
Example 2 abc enumeration with parentheses
Input:
\renewcommand{\labelenumi}{\alph{enumi})}
\begin{enumerate}
\item one
\item two
\item three
\end{enumerate}
Output:
a) one
b) two
c) three
Example 3 roman numerals enumeration
Input:
\renewcommand{\labelenumi}{\roman{enumi}}
\begin{enumerate}
\item one
\item two
\item three
\end{enumerate}
Output:
i one
ii two
iii three
Example 4 roman numerals with period
Input:
\renewcommand{\labelenumi}{\roman{enumi}.}
\begin{enumerate}
\item one
\item two
\item three
\end{enumerate}
Output:
i. one
ii. two
iii. three
Example 5 roman numerals with parentheses
Input:
\renewcommand{\labelenumi}{\roman{enumi})}
\begin{enumerate}
\item one
\item two
\item three
\end{enumerate}
Output:
i) one
ii) two
iii) three
The outputs of the other levels can also be changed in the same way. In the following example, all four levels have different variants.
\renewcommand{\labelenumi}{\Roman{enumi}}
\renewcommand{\labelenumii}{\roman{enumii}}
\renewcommand{\labelenumiii}{\Roman{enumiii}.}
\renewcommand{\labelenumiv}{(\roman{enumiv})}
Input:
\begin{enumerate}
\item first level
\begin{enumerate}
\item second level
\begin{enumerate}
\item third level
\begin{enumerate}
\item fourth level
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
Output:
I first level
i second level
I. third level
(i) fourth level
Note: With the use of the paralist package or others, changing is much more easier.
Advertisement
1.4 typical error messages
These are the error messages for the itemize environment, but in principle the error messages are also usable for the enumerate environment.
error message:
! LaTeX Error: Too deeply nested.
cause: The nesting is too deep, i.e. five or more levels have been defined.
solution: Use fewer levels, maximum 4.
error message:
! LaTeX Error: Something's wrong--perhaps a missing \item.
cause: The environment was used without the
\item command.
solution: Insert the
\item command.
error message:
! LaTeX Error: \begin{document} ended by \end{itemize}.
cause: Too much \end{itemize} has been used.
solution: Remove the unnecessary
\end{itemize}.
error message:
! LaTeX Error: \begin{itemize} on input line 100 ended by \end{document}.
cause: The
\end{itemize} is missing.
solution: Insert the
\end{itemize}.
error message:
! LaTeX Error: Lonely \item--perhaps a missing list environment.
cause: The beginning of the environment
\begin{itemize} is missing or the whole environment was forgotten and only the
\item command was used.
solution: Either remove the
\item or start the environment
\begin{itemize} or insert the whole missing environment
error message:
! Missing \endcsname inserted.
cause: \begin{itemize} was replaced by \begin{\itemize} and/or \end{itemize} was replaced by \end{\itemize}.
solution: Change \begin{\itemize} to \begin{itemize} and/or \end{\itemize} to \end{itemize}.
error message:
! LaTeX Error: Command \end{itemize} invalid in math mode.
cause: Within the itemize environment the math environment was started but not finished.
solution: Quit the math environment correctly.