Skip to content

engine: search graphics extensions so \includegraphics{fig} resolves - #193

Merged
tannevaled merged 1 commit into
mainfrom
graphicx-extension-search
Sep 2, 2026
Merged

engine: search graphics extensions so \includegraphics{fig} resolves#193
tannevaled merged 1 commit into
mainfrom
graphicx-extension-search

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

What

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 the PDF rasteriser was wired (#191) — the residual that PR flagged.

How

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 (measured, GOTEX_PDFRENDER=1 GOTEX_FLOATS=1)

paper \includegraphics skips pages tectonic
2206.00339 10 → 0 30 → 34 34 (exact)
2201.02101 11 → 0 26 → 31 27 (overshoots +4)

Every figure that should render now does; 2206.00339 reaches exact tectonic page count. Where figures load oversized (no \linewidth scaling yet) the count overshoots — a separate, now-isolated residual (the next lever), not a regression.

Tests cover exact hit, extension search, pdf-first ordering, an honoured explicit extension, no-match, and a directory not counting as a file. Full suite, vet, gofmt green.

🤖 Generated with Claude Code

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>
@tannevaled
tannevaled merged commit a4c6e61 into main Sep 2, 2026
18 checks passed
@tannevaled
tannevaled deleted the graphicx-extension-search branch September 2, 2026 19:04
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.

1 participant