Master LaTeX cross-referencing system. Learn to reference figures, tables, equations, sections with labels, and use advanced packages like cleveref.
Learn to create professional cross-references in LaTeX documents. This guide covers the complete referencing system from basic labels to advanced automated references.
Why cross-references matter: They maintain consistency automatically, update numbering when you reorganize content, and provide clickable navigation in PDF documents.
\documentclass{article}\begin{document}\section{Introduction}\label{sec:intro}This is the introduction section.\section{Methods}\label{sec:methods}As mentioned in Section~\ref{sec:intro}, we will now discuss methods.\subsection{Data Collection}\label{subsec:data}Data collection procedures are described here.\section{Results}According to the methods in Section~\ref{sec:methods} and specifically the data collection in Section~\ref{subsec:data}, our results show...\end{document}
% Step 1: Add labels to elements you want to reference\section{Literature Review}\label{sec:literature}\begin{figure}[htbp] \centering \includegraphics[width=0.8\textwidth]{diagram.png} \caption{System architecture} \label{fig:architecture}\end{figure}\begin{equation}E = mc^2\label{eq:einstein}\end{equation}% Step 2: Reference them in textAs shown in Figure~\ref{fig:architecture}, the system...Einstein's equation (Equation~\ref{eq:einstein}) demonstrates...The literature review in Section~\ref{sec:literature} covers...
% Sections and chapters\chapter{Introduction}\label{chap:intro}\section{Background}\label{sec:background}\subsection{Previous Work}\label{subsec:previous}% Figures and tables\begin{figure} \caption{Results overview} \label{fig:results}\end{figure}\begin{table} \caption{Performance comparison} \label{tab:performance}\end{table}% Equations\begin{equation} y = mx + b \label{eq:linear}\end{equation}% Algorithms and listings\begin{algorithm} \caption{Sorting algorithm} \label{alg:sort}\end{algorithm}% Appendices\appendix\section{Additional Data}\label{app:data}% Examples and theorems\begin{theorem} \label{thm:main} Statement of theorem...\end{theorem}\begin{example} \label{ex:basic} Example content...\end{example}
% Basic page referenceSee the discussion on page~\pageref{sec:methods}.% Combined referencesFigure~\ref{fig:results} on page~\pageref{fig:results} shows...% Reference with both number and pageEquation~\ref{eq:main} (page~\pageref{eq:main}) demonstrates...% Checking if reference is on current page\ifthenelse{\equal{\pageref{fig:test}}{\thepage}}{% Figure~\ref{fig:test} above shows...}{% Figure~\ref{fig:test} on page~\pageref{fig:test} shows...}
\usepackage{amsmath}% Numbered equation with reference\begin{equation} \label{eq:quadratic} x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\end{equation}% Reference equation in textThe quadratic formula (Equation~\ref{eq:quadratic}) provides...% Using \eqref for automatic parenthesesThe solution is given by~\eqref{eq:quadratic}.% Multiple equations with sub-references\begin{subequations}\label{eq:system}\begin{align} x + y &= 5 \label{eq:system-a} \\ 2x - y &= 1 \label{eq:system-b}\end{align}\end{subequations}% Referencing the system and individual equationsThe system~\eqref{eq:system} consists of equations~\eqref{eq:system-a} and~\eqref{eq:system-b}.
% In main document\usepackage{xr}\externaldocument{chapter1} % References chapter1.tex\externaldocument{chapter2} % References chapter2.tex% Can now reference labels from external documentsAs shown in \cref{fig:external-result} (from Chapter 1)...\Cref{tab:comparison} in Chapter 2 demonstrates...% Avoiding label conflicts\externaldocument[ch1-]{chapter1} % Prefix all labels with "ch1-"\externaldocument[ch2-]{chapter2} % Prefix all labels with "ch2-"% References now need prefixes\cref{ch1-fig:result}\cref{ch2-tab:data}
% Main document structure% main.tex\documentclass{book}\usepackage{hyperref}\usepackage{cleveref}% Include chapters\include{chapters/introduction} % \input doesn't work with xr\include{chapters/literature}\include{chapters/methodology}\include{chapters/results}\include{chapters/conclusion}% Each chapter file can reference others% chapters/results.tex\chapter{Results}\label{chap:results}As discussed in \cref{chap:introduction}, our methodology (\cref{chap:methodology}) leads to the following results...\section{Experimental Setup}\label{sec:setup}The setup described here builds on \cref{sec:literature-review}...
\usepackage{ifthen}% Check if reference exists\newcommand{\safecref}[1]{% \ifthenelse{\equal{\ref{#1}}{??}}{% [Reference not found]% }{% \cref{#1}% }%}% Check if on same page\newcommand{\smartref}[1]{% \ifthenelse{\equal{\pageref{#1}}{\thepage}}{% \cref{#1} above% }{% \cref{#1} on page~\pageref{#1}% }%}% Usage\smartref{fig:test} % → "figure 1 above" or "figure 1 on page 5"
# Standard compilation for referencespdflatex document.texpdflatex document.tex# With bibliographypdflatex document.texbiber document # or bibtex documentpdflatex document.texpdflatex document.tex
Next: Learn about Package management to understand how to find, install, and use LaTeX packages effectively.