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
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 •