Skip to content

Fixing the figure references#186

Open
rogelj wants to merge 3 commits intoTufte-LaTeX:masterfrom
rogelj:figure-number-fix
Open

Fixing the figure references#186
rogelj wants to merge 3 commits intoTufte-LaTeX:masterfrom
rogelj:figure-number-fix

Conversation

@rogelj
Copy link

@rogelj rogelj commented Jan 14, 2026

This fixed issue #131

This patch fixes broken figure references (\ref, \autoref) in figure, figure*, and marginfigure under recent TeX Live releases (notably with amsmath + hyperref).

Problem

tufte-common.def defers caption and label processing by storing \caption and \label and applying them later inside a boxed minipage.

At label application time, the figure counter has not been ref-stepped, so:

  • \label does not capture the figure counter
  • hyperref sees no valid anchor
  • References resolve to ??, empty links, or section numbers

This regression is exposed by newer amsmath versions but reflects a long-standing ordering issue.

Fix: When applying the stored label, explicitly ref-step the figure counter:

\addtocounter{figure}{-1}
\refstepcounter{figure}
\@tufte@orig@label{<label>}

This:

  • restores the correct figure number
  • creates a proper hyperlink anchor
  • preserves existing numbering and layout

Standard LaTeX captions use \refstepcounter so that labels placed after captions reliably bind to the float.
This patch restores that invariant in Tufte’s delayed-caption architecture.

Result

  • \label after \caption works as documented
  • \ref, \autoref, and hyperref links resolve correctly
  • Compatible with current TeX Live (2025+) and earlier releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants