Skip to main content
To reference a numbered equation in LaTeX with matching parentheses, load \usepackage{amsmath}, place \label{eq:name} inside the equation, and write \eqref{eq:name} in the text. For sections, figures, and tables, put \label{...} after the heading or \caption{...} and cite it with \ref{...} or \pageref{...}.

Referencing equations with \eqref

\eqref is defined by amsmath and prints the equation number inside upright parentheses—for example (1)—even inside italic text, matching the equation tag style. Base LaTeX’s \ref{eq:name} prints only the bare number (1) without parentheses. To reference several equations at once:
  • Write consecutive \eqref calls such as equations~\eqref{eq:system-a} and~\eqref{eq:system-b}.
  • Wrap an align or gather block in subequations (from amsmath) to label the whole group ((2)) as well as individual lines ((2a), (2b)).
  • Use cleveref (below) to compress lists of equation labels automatically into ranges such as eqs. (1) to (3).
eqref-equations.tex
Test this example live in your browser. Open a ready-to-compile LaTeX project with TeX Live 2026 preinstalled and zero local setup.Open starter article

Sections, figures, tables, and page numbers

LaTeX’s built-in cross-referencing system uses three commands that require no extra packages: Place a non-breaking space (~) between the word and \ref or \pageref (for example Section~\ref{sec:setup}) so LaTeX never breaks a line right before the number. Prefixing keys by type (sec:, fig:, tab:, eq:) is a naming convention for humans; LaTeX itself ignores the prefix and reads the counter that was active when \label ran. Where \label must stand in figures and tables: always put \label{...} after \caption{...} (or inside the caption argument). \caption is what increments the figure or table counter; if \label stands before \caption, \ref prints the enclosing section or subsection number instead of the figure or table number.
sections-figures-tables.tex

Automatic names with \autoref

When you load hyperref, every \ref, \eqref, and \pageref becomes a clickable link, and you gain \autoref{key}, which inserts the element type before the number automatically. In English defaults, hyperref prints lowercase section 1 and subsection 1.1, capitalized Figure 1 and Table 1, and Equation 1 without parentheses around the number.
autoref-example.tex
For link colors, hidelinks, external URLs, and PDF bookmarks, see Hyperlinks. For bibliography citations with \cite, see BibTeX bibliography management.

Automatic names and ranges with cleveref

The cleveref package provides \cref{...} (mid-sentence) and \Cref{...} (start of a sentence). By default, \cref abbreviates eq. (1) and fig. 1 while keeping section 1 and table 1, whereas \Cref capitalizes and spells out the full name (Equation (1), Figure 1, Section 1). Pass noabbrev or capitalize as package options if you prefer full words or capitalized names everywhere. Unlike \eqref and \autoref, \cref accepts comma-separated lists of labels, sorts them, and compresses consecutive numbers into a range. Always load cleveref after amsmath and hyperref.
cleveref-example.tex

Why references show ?? (the two-pass rule)

LaTeX reads your source file top to bottom in a single pass. On the first compile, it writes every \label and its number into the .aux file; any \ref, \eqref, or \pageref whose label has not been saved yet prints ?? in the PDF and writes these messages to the log:
  • LaTeX Warning: Reference `eq:quadratic' on page 1 undefined on input line ...
  • LaTeX Warning: There were undefined references.
  • LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
Running LaTeX a second time reads the .aux file and replaces ?? with the real numbers. A third pass may be needed if replacing ?? shifts text across a page break and changes a \pageref. If ?? remains after compiling twice, check that the key in \ref{...} matches \label{...} exactly (keys are case-sensitive) and that \label is not inside an unnumbered display environment that discards labels, such as align* (inside equation* or after \section*, \label silently binds to the previous numbered heading—or nothing—instead of printing ??). On a full compile in LaTeX Cloud Studio, latexmk runs the passes your document needs automatically, so cross-references resolve without running LaTeX twice by hand.

Try it in the editor

amsmath, hyperref, and cleveref are preinstalled in LaTeX Cloud Studio’s TeX Live 2026 (full distribution) environment. Start from the Basic Article template in LaTeX Cloud Studio and replace main.tex with the complete example.