latex-skript/content/lists.tex
2023-11-08 22:06:59 +01:00

24 lines
1.7 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 (\code{latex}{\textbackslash item}) are framed by an \mono{itemize} environment.
Within a list item, we can open a new list environment to create a nested list.
If we replace \mono{itemize} by \mono{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 \mono{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 \mono{paralist}\footnote{\url{https://www.ctan.org/pkg/paralist}} package.
To do so, we simply adjust the environment name: \sh{compactitem} replaces \sh{itemize}, \sh{compactenum} replaces \sh{enumerate}, and \sh{compactdesc} replaces \sh{description}.
If the list ought to appear within a text body, \pkg{paralist} provides the extra environments \mono{inparaenum} and \mono{inparaitem}.
We can customize bullet and list numbering styles via the \pkg{enumitem}\footnote{\url{https://www.ctan.org/pkg/enumitem}} package.
\code{latex}{\textbackslash begin\{enumerate\}[label=\textbackslash roman*]} produces a list with Roman numerals.
The parameter \code{latex}{[label=\textbackslash alph*]} inserts alphabetical numbering.