latex-skript/content/lists.tex

24 lines
1.9 KiB
TeX

\chapter{Lists}
\label{sec:lists}
Inherently, \LaTeX{} supports three types of lists: unordered, ordered, and description lists.
For each of these types, there are dedicated environments whose structure is very similar.
\example{lst:unordered-list}{lists/nested-list}{Examplary unordered list}
In \cref{lst:unordered-list-code}, different list items (\mintinline{latex}{\item}) are framed by an \mintinline{latex}{itemize} environment.
Within a list item, we can open a new list environment to create a nested list.
If we replace \mintinline{latex}{itemize} by \mintinline{latex}{enumerate}, the list becomes ordered without changing the source code any further.
To make use of the less common description lists, we have to specify the environment \mintinline{latex}{description}.
Moreover, the items need to be extended by the term to be defined, put in brackets (\cref{lst:description-list}).
\Example{lst:description-list}{lists/description-list}{lists/description-list_crop}{Exemplary description list}
The exuberant spacing between list items can be reduced by utilizing the \mintinline{latex}{paralist}\footnote{\url{https://www.ctan.org/pkg/paralist}} package.
To do so, we simply adjust the environment name: \mintinline{latex}{compactitem} replaces \mintinline{latex}{itemize}, \mintinline{latex}{compactenum} replaces \mintinline{latex}{enumerate}, and \mintinline{latex}{compactdesc} replaces \mintinline{latex}{description}.
If the list ought to appear within a text body, \mintinline{latex}{paralist} provides the extra environments \mintinline{latex}{inparaenum} and \mintinline{latex}{inparaitem}.
We can customize bullet and list numbering styles via the \mintinline{latex}{enumitem}\footnote{\url{https://www.ctan.org/pkg/enumitem}} package.
\mintinline{latex}{\begin{enumerate}[label=\roman*]} produces a list with Roman numerals.
The parameter \mintinline{latex}{[label=\alph*]} inserts alphabetical numbering.