Site icon texblog

Cross-referencing list items

List items of numbered lists (enumerate) can be cross-referenced using the standard \label{} and \ref{} command pair. Cross-referencing description items is not supported by default, but can be done with a few additional lines of code in the preamble.

Enumerate
Ordered or numbered lists are cross-referenced with the label-ref command pair similar to figures, tables or chapters. The label can either be place right after \item or after the item’s text. The cross-reference \ref{} works within and outside the list as shown in the example below.

\documentclass[11pt]{article}
\usepackage{hyperref}
\begin{document}
\begin{enumerate}
	\item \label{itm:first} This is a numbered item
	\item Another numbered item \label{itm:second}
	\item \label{itm:third} Same as \ref{itm:first}
\end{enumerate}
Cross-referencing items \ref{itm:second} and \ref{itm:third}.
\end{document}

Cross-referencing numbered items in lists (enumerate).

Loading the hyperref package, automatically adds links to cross-references and allows navigation to list items by clicking the reference.

Description
By default, items in a description can’t be cross-referenced. LaTeX would just use the number of the section/chapter. SX has a solution with a few lines of additional code in the preamble.

\documentclass[11pt]{article}
\usepackage{enumitem, hyperref}
\makeatletter
\def\namedlabel#1#2{\begingroup
	#2%
	\def\@currentlabel{#2}%
	\phantomsection\label{#1}\endgroup
}
\makeatother
\begin{document}
\begin{description}[style=multiline, labelwidth=1.5cm]
	\item[\namedlabel{itm:rule1}{Rule 1}] Everything is easy with \LaTeX
	\item[\namedlabel{itm:rule2}{Rule 2}] Sometimes it is not that easy\\
		$\to$ \ref{itm:rule1} applies
\end{description}
\end{document}

Cross-referencing description items

The code in the preamble defines a new command namedlabel which produces the name when cross-referencing the item. In the example, the enumitem package is loaded for a correct alignment of multiline items (see documentation for details)

Itemize
Cross-referencing items in unordered lists (bullet items) is not supported and wouldn’t make sense anyway, since individual items don’t have an unique identifier.

Exit mobile version