gotex: wire go-tex/pdfrender behind GOTEX_PDFRENDER for real PDF-figure height - #191
Merged
Conversation
…t real height The engine core exposes a RasterizePDF seam (image.go) but leaves it nil, so a \includegraphics of a vector .pdf — the commonest figure on arXiv — frames a placeholder with no real height. This wires the seam in the CLI to go-tex/pdfrender v0.1.0 (Rasterize matches the hook signature), fenced against a panic in the third-party renderer so a bad figure costs the figure, not the document. It is GATED behind GOTEX_PDFRENDER and OFF by default: with the variable clear the seam stays nil, exactly as on the engine core, so the default CLI output is byte-for-byte identical to current main (verified cmp-identical on 2201.04865, 2206.00339, 2201.02101 with flags off). Wiring it gives figures their real HEIGHT, a deliberate pagination change; its intended companion is GOTEX_FLOATS, so a real-height figure floats to a page top as TeXLive does — the faithful mode is GOTEX_PDFRENDER=1 GOTEX_FLOATS=1. Measured (page count vs tectonic reference): 2201.04865 — figures named with an explicit .pdf and no width override rasterise (10 real rasters embedded), 17 -> 19 pages toward tectonic's 22 (delta -5 -> -3). Where a figure carries a width=X\linewidth (collapsed to X pt by the documented one-column raw-text dimen read) or is referenced without a file extension (loadImage does no graphicx extension search), it does not rasterise and the count is unchanged — those are upstream gaps, not this seam. No regression: combined page count >= baseline in every case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tannevaled
added a commit
that referenced
this pull request
Sep 2, 2026
…193) loadImage read the reference name verbatim, so a figure written without its extension — \includegraphics{fig}, the form real papers use — never found fig.pdf/fig.png on disk and collapsed to a placeholder. This was the dominant reason figures did not load even after a PDF rasteriser was wired (#191). Resolve the reference the way graphicx does: an exact hit wins; otherwise, when the name carries no known graphics extension, each extension is appended in turn — pdf first, matching pdftex's \Gin@extensions, both cases for a case-sensitive filesystem — and the first that exists is used. Existing-file resolution is unchanged (os.Stat of the exact name still wins), so papers that already loaded their figures are unaffected; only previously-failing extension-less references now resolve. Effect (GOTEX_PDFRENDER=1 GOTEX_FLOATS=1): 2206.00339's \includegraphics skips fall 10 -> 0 and its page count reaches 34, exactly tectonic; 2201.02101's fall 11 -> 0. Where figures now load oversized (no \linewidth scaling yet) the page count overshoots — a separate, isolated residual — but every figure that should render now does. Tests cover exact hit, extension search, pdf-first ordering, an honoured explicit extension, no-match, and a directory not counting as a file. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Wires the engine's existing
RasterizePDFseam (image.go) togo-tex/pdfrenderv0.1.0 incmd/gotex, so\includegraphicsof a vector.pdf— the commonest figure on arXiv — rasterises to a real raster with its true height instead of a placeholder box. The renderer call is fenced against a panic so a bad figure costs the figure, not the document (the engine already answers the error with a placeholder that keeps the figure's aspect).Gating — default is byte-identical
The wiring is OFF by default, behind
GOTEX_PDFRENDER. With the variable clear the seam staysnil, exactly as on the engine core, so a PDF figure frames the same placeholder and the CLI output is byte-for-byte unchanged frommain. Verifiedcmp-identical (SVG output, flags off) on 2201.04865, 2206.00339, 2201.02101 (17/30/25 pages, matching SHA-256 vs amainbuild).Real figure height is a deliberate pagination change; its intended companion is
GOTEX_FLOATS, so a real-height figure floats to a page top as TeXLive does. The faithful mode isGOTEX_PDFRENDER=1 GOTEX_FLOATS=1.Honest measured result (page count vs tectonic reference)
{x.pdf}, no width override.pdf/ extension-less refs) — 0 rasters{fig1}) never load; floats add +1Partial convergence win. Where figures both (a) resolve on disk under their exact referenced name and (b) carry no
width=X\linewidth-style override, real-height rasterisation converges toward tectonic (2201.04865: delta −5 → −3, ten real rasters). No regression: combined page count ≥ baseline everywhere.The dominant residual is upstream of this PR, not the seam:
loadImagedoes no graphicx extension search, so extension-less refs ({fig1}) never load — the whole reason 2201.02101 and much of 2206.00339 don't move;\linewidth-relative width collapse (the documented legacy raw-text dimen read) binds a figure's height regardless of real pixels;GOTEX_FLOATS).Verification
go build ./cmd/gotex/,go vet ./...,gofmt -lcleango test -count=1 .andgo test -count=1 ./cmd/gotex/green🤖 Generated with Claude Code