Skip to main content

number_figures

Function number_figures 

Source
fn number_figures(document: &mut Document)
Expand description

Assign flat, document-order numbers to every figure ("1", "2", "3", …) and stamp a visible "Figure N: …" label onto each captioned figure. Figures are not hierarchical, so the counter never resets.

The label is baked into the caption text here: rather than rendered by the layout engine the way section numbers are, so a numbered figure shows its number with no backend changes; distinct label styling is left to the future float/caption pass. The supplement word comes from figure_supplement (the single localization seam) and is joined to the number with a non-breaking space (U+00A0). That space is semantic generated text, not layout policy in disguise: it encodes Figure and its counter as one cohesive label token: the same non-breaking space an author could type by hand, which the layout engine merely honors. The resolver makes no wrapping decision of its own; it just emits the token.

The pass is idempotent: the pre-label caption is preserved under a caption_source attribute and the visible text is always re-derived from it. Re-running the resolver: as the §6 stage 3 fixpoint and any future page-reference pass do: therefore re-stamps the same label instead of nesting "Figure 1: Figure 1: …", and stays correct when a figure is re-numbered, because the source never carries a stale counter.