Lists in LaTeX
LaTeX has three list environments: itemize for bullets, enumerate for numbers and description for terms. The enumitem package handles everything else: labels, spacing and lists inside a sentence.
Bullets: itemize
\begin{itemize}
\item First point
\item Second point
\item Third point
\end{itemize}Each entry starts with \item. To change the marker of a single item, put it in brackets: \item[-] or \item[$\star$].
Numbers: enumerate
\begin{enumerate}
\item Collect the requirements
\item Design the architecture
\item Implement and test
\end{enumerate}LaTeX numbers the items for you. Nested levels use 1, 2, 3, then (a), (b), (c), then i, ii, iii, then A, B, C.
Terms: description
\begin{description}
\item[API] The interface other services call.
\item[JWT] A signed token that proves who the user is.
\item[SSE] A one-way stream of events from server to browser.
\end{description}The term in brackets comes out in bold, followed by its explanation. It works well for a glossary or a list of acronyms.
Nested lists
Put a list inside an \item to nest it, up to four levels. You can mix list types:
\begin{enumerate}
\item Backend
\begin{itemize}
\item REST API
\item Database
\end{itemize}
\item Frontend
\end{enumerate}Changing the bullets everywhere
To change the marker for every list in the document, redefine the label of each level in the preamble. \labelitemi is the first level, \labelitemii the second, and so on to \labelitemiv.
\renewcommand{\labelitemi}{\textendash}
\renewcommand{\labelitemii}{$\circ$}With enumitem loaded you can also do it per list: \begin{itemize}[label=\textendash].
Custom numbering with enumitem
\usepackage{enumitem} % preamble
\begin{enumerate}[label=(\alph*)] % (a) (b) (c)
\item ...
\end{enumerate}
\begin{enumerate}[label=Step \arabic*:] % Step 1: Step 2:
\item ...
\end{enumerate}
\begin{enumerate}[resume] % carries on from the last list
\item ...
\end{enumerate}| In the label | Gives |
|---|---|
\arabic* | 1, 2, 3 |
\alph* | a, b, c |
\Alph* | A, B, C |
\roman* | i, ii, iii |
\Roman* | I, II, III |
Anything around the token is printed as is, so label=\Roman*. gives I., II., III. Add start=5 to begin counting at 5.
Tighter spacing
LaTeX leaves space between items, which suits a few long items but looks loose for many short ones. With enumitem:
\begin{itemize}[nosep] % no space anywhere
\begin{itemize}[noitemsep] % no space between items, normal space around the list
% For every list in the document:
\setlist{noitemsep}For finer control, set itemsep (between items), topsep (above and below the list) and leftmargin (the indent) yourself, for example [itemsep=2pt, leftmargin=1.5em].
Lists inside a sentence
\usepackage[inline]{enumitem} % preamble
The system has three parts:
\begin{enumerate*}[label=(\arabic*)]
\item an API,
\item a worker, and
\item a web client.
\end{enumerate*}Load enumitem with [inline] to get enumerate*, itemize* and description*. This prints "(1) an API, (2) a worker, and (3) a web client." within the paragraph.
Lists in columns
\usepackage{multicol} % preamble
\begin{multicols}{2}
\begin{itemize}[nosep]
\item Python
\item TypeScript
\item Rust
\item SQL
\end{itemize}
\end{multicols}Where to go next
- Bold, italics and underline for the text inside your items
- Tables, when a list is really a comparison
- Writing your PFE report in LaTeX