Reference Undefined (Missing Label)
LaTeX Warning: Reference 'XXX' on page N undefined.
What this error means
A \ref{key} or \pageref{key} command references a label that doesn't exist yet, or LaTeX needs to be run twice to resolve cross-references. The output shows ?? instead of the reference number.
Common causes
- The \label{key} command is missing from the document
- LaTeX was only compiled once — cross-references need two passes
- Typo in the \ref{} key that doesn't match any \label{}
- The label is in an \include{}d file that was excluded with \includeonly{}
How to fix it
Compile the document twice: the first pass writes labels to the .aux file, and the second pass reads them. If ?? still appears, check that the \label{key} exists and matches the \ref{key} exactly (case-sensitive).
Code examples
\documentclass{article}
\begin{document}
\section{Introduction}
% Forgot \label here
See Section~\ref{sec:intro} for more.
\end{document}\documentclass{article}
\begin{document}
\section{Introduction}\label{sec:intro}
See Section~\ref{sec:intro} for more.
\end{document}Related errors
File Not Found
! LaTeX Error: File 'XXX' not found.
Unknown Graphics Extension
! LaTeX Error: Unknown graphics extension: .XXX.
Unicode Character Not Supported (pdfLaTeX)
! Package inputenc Error: Unicode char U+XXXX not set up for use with LaTeX.
Cannot Determine Size of Graphic (No BoundingBox)
! LaTeX Error: Cannot determine size of graphic (no BoundingBox).
Test the fix live
Paste your LaTeX into the playground and compile instantly.

