Number-safe references in LaTeX: \label, \ref, \pageref, \eqref, autoref and cleveref, naming conventions, why references print as ?? and how Coauthor's compile resolves them.

Cross-References and Labels

Never type "see Section 3" by hand. Attach a \label to the thing you want to point at and let \ref insert the number; when you add or move a section, figure, or equation, every reference updates on the next compile. This page covers the reference commands, how to name labels, and the "??" you see when references are not yet resolved.

Label and Reference

\section{Method}\label{sec:method}

\begin{figure}[t]
  \centering
  \includegraphics[width=.7\linewidth]{pipeline}
  \caption{Overview of the pipeline.}
  \label{fig:pipeline}
\end{figure}

\begin{equation}
  y = Wx + b \label{eq:linear}
\end{equation}

As shown in Figure~\ref{fig:pipeline} and Section~\ref{sec:method},
the model in \eqref{eq:linear} is linear (see page~\pageref{fig:pipeline}).
CommandPrintsNotes
\label{key}nothingRecords the current number. Place it right after \section{...}, after \caption, or inside the math environment
\ref{key}3, 2, 1The bare number
\eqref{key}(1)Equation number in parentheses (from amsmath)
\pageref{key}7The page where the label was set
\autoref{key}Figure 2From hyperref; adds the right word automatically
\cref{key} / \Cref{key}figure 2 / Figure 2From cleveref; handles ranges and lists

Use ~ (non-breaking space) between the word and the reference so "Figure" and "2" never end up on different lines.

Naming Labels

Prefixes make labels self-documenting and prevent collisions:

PrefixFor
sec:Sections, subsections, chapters (ch: is also common)
fig:Figures and subfigures
tab:Tables
eq:Equations
thm:, lem:, def:Theorem-like environments
alg:Algorithms
app:Appendices

Labels are case-sensitive and must be unique in the whole project, including files pulled in with \input. Duplicates trigger LaTeX Warning: Label 'x' multiply defined. Use Ctrl+F to search a file for a label before reusing it, or ask the AI coauthor to list the labels defined across your project.

Where the Label Goes

The label records the most recently incremented counter. Getting it wrong is the classic cause of a figure reference that prints a section number:

  • Figures and tables: \label after \caption (the caption increments the counter).
  • Sections: directly after the \section{...} command, same line or next line.
  • Equations: anywhere inside equation, or on the specific line of an align you want to refer to.
  • Theorems: right after \begin{theorem}.
  • Items in enumerate: after \item, then \ref prints the item number.

cleveref: Smarter References

\usepackage{hyperref}
\usepackage[capitalize,nameinlink]{cleveref}   % load AFTER hyperref
...
\cref{fig:pipeline}              % Fig. 2
\Cref{sec:method}                % Section 3
\cref{eq:linear,eq:loss}         % Eqs. (1) and (2)
\crefrange{fig:a}{fig:d}         % Figs. 2 to 5

cleveref must be one of the last packages in the preamble. Some venue style files already load hyperref and set link colors; adding cleveref after them is fine, but do not load hyperref a second time (you would get Option clash for package hyperref). See Packages and the Preamble.

Why You See "??"

LaTeX resolves references in two steps. During a pass it writes every \label and its number into the .aux file; on the next pass it reads that file to fill in the \ref commands. That is why a freshly added reference prints as ?? with a LaTeX Warning: Reference 'x' on page 1 undefined in the log, and why, after a change that shifts numbering, the log says Label(s) may have changed. Rerun to get cross-references right.

Coauthor's compiler runs latexmk, which repeats pdfLaTeX (and BibTeX) automatically until these warnings disappear, so a single Compile normally produces a fully resolved PDF. If you still see ??:

  1. Check the spelling and case of the key in \ref against the \label; this is the cause in nearly every case.
  2. Make sure the file containing the \label is actually included from the main file (\input{sections/method}) and is not commented out.
  3. Confirm the label is not inside an environment that never ran, such as a \begin{comment} block or an \iffalse ... \fi region.
  4. Compile once more. The Compilation Results panel lists remaining Reference undefined warnings; see Compiling and PDF Preview.

With \usepackage{hyperref} every \ref, \cite, and table-of-contents entry becomes a clickable link in the PDF. Set the appearance in the preamble:

\usepackage[colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref}

For a camera-ready version many venues require hidelinks or black links; check the template's instructions. See Writing for a Venue with Conference and Journal Templates.

Related articles

Mathematics
Figures and Images
Tables
Document Structure: Sections, Chapters, and the Table of Contents
Compiling and PDF Preview

Prefer to ask?

Inside Coauthor, ask the AI coauthor how any feature works — it answers from these same help articles. For anything else, use the ? button in the top-right corner of the app.

Ready to Write Better Research Papers?

Let Coauthor help you with your next manuscript

7 days free, with €2.50 of AI usage on your own paper