Cross-references in LaTeX
Use \label and \ref to create automatically-updated cross-references to sections, figures, and equations.
Quick answer
latex
\section{Methods}\label{sec:methods}
% Later:
As described in Section~\ref{sec:methods}, ...Labeling different elements
latex
% Sections:
\section{Introduction}\label{sec:intro}
\subsection{Background}\label{sec:background}
% Equations:
\begin{equation}
E = mc^2 \label{eq:einstein}
\end{equation}
% Figures:
\begin{figure}[htbp]
\includegraphics[width=\linewidth]{plot.pdf}
\caption{Results}\label{fig:results}
\end{figure}
% Tables:
\begin{table}[htbp]
\caption{Summary}\label{tab:summary}
...
\end{table}Referencing
latex
% Basic ref (number only):
see Section~\ref{sec:intro} % → "see Section 1"
see Figure~\ref{fig:results} % → "see Figure 3"
see Equation~\eqref{eq:einstein} % → "see Equation (1)"
see Table~\ref{tab:summary} % → "see Table 2"
% Page reference:
see page~\pageref{sec:intro}
% Note: ~ is a non-breaking space — keeps "Figure" and "3" togetherautoref (smart references)
With hyperref, use \autoref to automatically include the element type name.
latex
\usepackage{hyperref}
\autoref{sec:intro} % → "Section 1"
\autoref{fig:results} % → "Figure 3"
\autoref{eq:einstein} % → "Equation (1)"
\autoref{tab:summary} % → "Table 2"
% Customize the type names:
\renewcommand{\sectionautorefname}{Section}
\renewcommand{\figureautorefname}{Figure}Label naming conventions
Use prefixes to keep labels organized. There's no enforced convention — choose one and be consistent.
| Element | Convention | Example |
|---|---|---|
| Section | sec: | sec:intro |
| Figure | fig: | fig:results |
| Table | tab: | tab:summary |
| Equation | eq: | eq:einstein |
| Chapter | ch: | ch:methods |
| Appendix | app: | app:data |
Compile twice
Labels are written to a .aux file on the first compile and read on the second. Always compile twice (or use latexmk) to resolve all references. ?? in the output means unresolved references.
