Skip to content

render-pipeline: compile a float body's tikzpicture from the unmasked source (#884) - #890

Merged
jay3332 merged 1 commit into
mainfrom
render/float-tikzpicture-884
Sep 18, 2026
Merged

jay3332 merged 1 commit into
mainfrom
render/float-tikzpicture-884

Conversation

@jay3332

@jay3332 jay3332 commented Sep 18, 2026

Copy link
Copy Markdown
Member

Fixes #884.

Cause

Float environments are blanked to spaces before the compiler parses the document (floats::mask), and the typeset Context only ever held those masked texts. A float body's tikzpicture reaches typeset::picture_block as a Block::Picture with the right span (the float-body re-parse in floats::body_blocks finds it in the isolated run), but picture_block compiled the picture from self.texts[document] — i.e. from the spaces — so TikZ produced an empty picture: no nodes, no paths, zero height. The caption then moved up by the picture's height. \includegraphics in a float never re-reads bytes (its box comes from floats::prepare), which is why #868's float case was byte-identical.

Fix

typeset::Context gets a sources slice (the documents as read, before the float and multicol masks), set by render_windowed through Context::set_sources and propagated to the three sub-contexts (top_material_box, floatpage::build_wide_box, multicol::paginate). picture_block compiles from sources. Nothing else reads sources; texts is unchanged for everything else (fence recovery, \left/\right, package detection).

Measured (bp from page top, tools/visual-oracle/pdftext.py; oracle /Library/TeX/texbin/pdflatex, pdfTeX 1.40.29 / TeX Live 2026, measurement only)

Issue repro (float + a second tikzpicture in the following paragraph):

word pdflatex x, y before x, y after x, y
NODEA 258.94, 160.93 absent 258.94, 157.10
NODEB 315.84, 160.93 absent 315.84, 157.10
Figure 1: Cap 274.96, 207.99 274.96, 168.64 274.96, 204.14
INLINEC 217.18, 135.13 137.29, 193.91 137.29, 229.41
Before. 148.71, 138.65 148.71, 134.77 148.71, 134.77
page number 303.13, 702.64 303.13, 702.64 303.13, 702.64

The remaining 3.85 bp on every line from Before. down is the INLINEC row (#866, not this PR): pdflatex keeps that picture in the first paragraph's line, which raises the line by the node's height above \topskip, shifting the float and everything after it by the same amount. FlashTeX still starts a new line for it; that behaviour is untouched here.

Same document without the trailing INLINEC picture, so the float is measured on its own:

word pdflatex x, y after x, y delta
Before. 148.712, 134.765 148.712, 134.765 0, 0
NODEA 258.939, 157.047 258.939, 157.103 0, +0.056
NODEB 315.840, 157.047 315.840, 157.103 0, +0.056
Figure 1: Cap 274.961, 204.107 274.961, 204.135 0, +0.028
page number 303.133, 702.635 303.133, 702.635 0, 0

Node text and the caption are within 0.06 bp of pdflatex (tolerance 0.5 bp). The \centering is honoured (x exact). The tikz_display_list_only warning is unchanged (paths are display-list-v2 items only).

Tests

  • New crates/render-pipeline/tests/float_tikzpicture.rs: the node glyph runs are present at the oracle's x/baseline (±0.5 bp), the caption sits below them by more than a line, the \draw and node border are path items, and the same picture outside a float still renders. The first test fails on main (no glyph run "NODEA", caption at 168.64).
  • cd crates/render-pipeline && cargo test: green (see report).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn

… source (#884)

A `tikzpicture` inside a `figure`/`table` rendered nothing: the float
environments are blanked to spaces before the compiler parses the
document (`floats::mask`), and `typeset::picture_block` compiled the
picture from those masked `texts`, so TikZ saw only spaces -- no nodes,
no paths, zero height -- and the caption moved up by the picture's height.

`typeset::Context` now carries the documents as read (`sources`, set by
`render_windowed` through `Context::set_sources` and handed to the three
sub-contexts); `picture_block` compiles from them. `texts` is unchanged
for everything else.

Measured against pdflatex (pdfTeX 1.40.29, TeX Live 2026; bp from page
top) on the issue's repro without its trailing inline picture: NODEA
258.939/157.103 vs 258.939/157.047, caption 274.961/204.135 vs
274.961/204.107 -- within 0.06 bp. With the inline `INLINEC` picture the
whole page below the first line is 3.85 bp high, which is that
picture's paragraph-mode line height (#866), untouched here.

New test `tests/float_tikzpicture.rs` (fails on main: no NODEA glyph run,
caption at 168.64); `cargo test` in crates/render-pipeline: 636 passed.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
@jay3332

jay3332 commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Release evidence: cargo test --release --test float_tikzpicture at 532ab256 → 2/2 (debug full suite 636/0 in the PR body).

@jay3332
jay3332 merged commit c885ae9 into main Sep 18, 2026
22 checks passed
jay3332 added a commit that referenced this pull request Sep 18, 2026
…#890

The previous re-record took tikz-heavy's digest from a run of the
pre-rebase commit; #866 (paragraph-initial tikz indent) and #890
(tikz inside floats) changed that case's output. 685eaf426bbefc9b is
what three local runs and CI's own run of e667cae produce.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
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.

render-pipeline: a tikzpicture inside a figure float is dropped — no node text, no height

1 participant