Skip to content

fancyvrb's \Verb keeps the code it is given - #224

Merged
tannevaled merged 1 commit into
mainfrom
fancyvrb-verb
Sep 4, 2026
Merged

fancyvrb's \Verb keeps the code it is given#224
tannevaled merged 1 commit into
mainfrom
fancyvrb-verb

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

\Verb was undefined, so a hundred fragments of code went out with it: one paper
writes \newcommand{\jl}[1]{\small\Verb{#1}} and uses \jl a hundred times, and
every one of them was skipped along with its text.

The braced form is the one that has to be read from tokens rather than from the
character buffer — by the time \Verb runs inside that macro, its argument is a
parameter and the file is long past. The delimited form still reads the buffer, as
\verb does.

A trap worth naming: peeking for the optional [options] with a token read
moves the buffer cursor past the delimiter and leaves the token on the list, so
\Verb|autre_code()| came out as utre_code()|| — the character after the bar had
become the delimiter. While the argument is still in the file, everything is peeked
raw.

Measured

Page error over the 157 arXiv papers: 517 → 516, within 2 pages 102 → 103, and
+580 drawn glyphs — the restored code fragments. The gain is content, not
pagination, which is why the glyph census is the evidence.

Four cases are tested (braced, delimited, through a macro, with options) plus the
first-character regression.

🤖 Generated with Claude Code

\Verb was undefined, so a hundred fragments of code went out with it: one paper
writes \newcommand{\jl}[1]{\small\Verb{#1}} and uses \jl a hundred times, and every
one was skipped along with its text.

The braced form has to be read from TOKENS rather than from the character buffer:
by the time \Verb runs inside that macro its argument is a parameter and the file is
long past. The delimited form still reads the buffer, as \verb does.

Peeking for the optional [options] with a TOKEN read moves the buffer cursor past
the delimiter and leaves the token on the list, so \Verb|autre_code()| came out as
"utre_code()||" — the character after the bar had become the delimiter. While the
argument is still in the file, everything is peeked raw.

Measured over the 157 arXiv papers: page error 517 → 516, within 2 pages 102 → 103,
and +580 drawn glyphs — the restored fragments. The gain is content, not pagination.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 081d962 into main Sep 4, 2026
18 checks passed
@tannevaled
tannevaled deleted the fancyvrb-verb branch September 4, 2026 16:58
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