Errors & Debugging
Fix: Equation References Show ??? in LaTeX
If your LaTeX document shows ??? where equation numbers should appear — for example, 'see Equation ???' — you have an undefined reference. This is almost always caused by a missing or misplaced \label, a typo in your \ref command, or not running enough compilation passes. It's a harmless but frustrating issue that Bibby AI catches and fixes automatically by tracking all your labels and references in real time.
Understanding Labels and References
The \label and \ref system requires labels to be placed correctly inside numbered environments:
% CORRECT label placement (inside the environment):
\begin{equation}
E = mc^2
\label{eq:einstein}
\end{equation}
As shown in Equation~\ref{eq:einstein}, ...
% WRONG: label outside the environment
\begin{equation}
E = mc^2
\end{equation}
\label{eq:einstein} % TOO LATE - not inside equation!
% WRONG: label before the equation
\label{eq:einstein} % TOO EARLY
\begin{equation}
E = mc^2
\end{equation}
% For align environments, label each line:
\begin{align}
f(x) &= x^2 + 2x + 1 \label{eq:quadratic} \\
g(x) &= x^3 - 1 \label{eq:cubic}
\end{align}
Equation~\ref{eq:quadratic} and
Equation~\ref{eq:cubic} show...Diagnosing the Problem
Check the LaTeX log file and your labels systematically to find the issue:
% LaTeX log will show warnings like:
% LaTeX Warning: Reference `eq:einsten' on page 2
% undefined on input line 47.
% Common cause 1: Typo in label or ref
\label{eq:einstein} % defined
\ref{eq:einsten} % TYPO! Missing 'i'
% Common cause 2: Duplicate labels
\begin{equation}
a^2 + b^2 = c^2
\label{eq:theorem} % first use
\end{equation}
\begin{equation}
x + y = z
\label{eq:theorem} % DUPLICATE! Same label
\end{equation}
% LaTeX uses the last one; the first \ref
% may point to the wrong equation.
% Common cause 3: Not enough compilations
% Forward references (referencing an equation
% that appears later in the document) need
% TWO compilation passes:
% Run: pdflatex main.tex && pdflatex main.texUsing hyperref and cleveref for Better References
Modern packages like cleveref automatically format references and reduce typo risk:
% Add to preamble (hyperref BEFORE cleveref):
\usepackage{hyperref}
\usepackage{cleveref}
% Instead of manual "Equation~\ref{eq:energy}":
\begin{equation}
E = mc^2
\label{eq:energy}
\end{equation}
% cleveref automatically adds the type name:
\cref{eq:energy} % Output: "eq. (1)"
\Cref{eq:energy} % Output: "Equation (1)"
% Works for multiple references too:
\cref{eq:energy,eq:momentum,eq:force}
% Output: "eqs. (1) to (3)"
% Also works across reference types:
\cref{eq:energy,fig:plot,tab:data}
% Output: "eq. (1), fig. 2, and table 1"💡 Tips
- •Always compile at least twice after adding or changing labels — the first pass writes labels to the .aux file, the second reads them.
- •Use a consistent naming convention for labels: eq: for equations, fig: for figures, tab: for tables, sec: for sections.
- •Bibby AI highlights undefined references in real time as you type, so you catch ??? problems before compiling.
- •The cleveref package eliminates 'Equation~\ref{}' boilerplate and automatically handles pluralization.
Try This in Bibby AI
Write LaTeX faster with AI auto-complete and instant compilation.
Start Writing Free