Skip to content

\newminted defines its environment, and minted stays emulated - #227

Merged
tannevaled merged 1 commit into
mainfrom
newminted
Sep 5, 2026
Merged

\newminted defines its environment, and minted stays emulated#227
tannevaled merged 1 commit into
mainfrom
newminted

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

minted's \newminted{lang}{opts} is how a paper gets a code environment of its own —
\newminted{jl}{…} defines jlcode — and the engine had no such command. A paper
that ships minted.sty therefore got the real package, whose environments are
built through fancyvrb's capture: their bodies reached the page as tokens with
the ordinary category codes, so a lone $ in a code line opened maths and the scan
ran past the environment's own \end, eating the rest of the document.

That is #225, and this closes it. 2405.10478 writes \newminted{jl}{…} and then 28
jlcode blocks, exactly one of which holds

path = "$write_dir/therm_comp_MPI/"
2405.10478 pages drawn glyphs share of the reference
before 15 36 152 0.48
after 24 69 606 0.93
tectonic 27 75 018 characters

What changed

minted joins the packages the engine does not load for real, beside listings.
Its own implementation is minted's draft-mode behaviour — verbatim, no Pygments,
no shell escape — and it now covers \newminted, \newmintinline and \newmint.
The derived environment takes the language's name plus code, or the optional
argument when the paper names it (\newminted[julia]{jl}{…}).

Measured over the 157 arXiv papers with a tectonic reference

before after
page error 516 493
exact 24 26
within 1 page 66 68
within 2 pages 103 105

Three tests: the derived environment and its lone $, the optional name, and the
inline sibling.

Closes #225.

🤖 Generated with Claude Code

minted's \newminted{lang}{opts} is how a paper gets a code environment of its own —
\newminted{jl}{…} defines jlcode — and the engine had no such command. A paper that
ships minted.sty got the REAL package instead, whose environments are built through
fancyvrb's capture: their bodies then reached the page as TOKENS with the ordinary
category codes, so a lone $ in a code line opened maths and the scan ran past the
environment's own \end, eating the rest of the document.

Measured on 2405.10478, which writes \newminted{jl}{…} and then 28 jlcode blocks —
exactly one of them holding "path = \"$write_dir/therm_comp_MPI/\"":

	before   15 pages, 36152 glyphs   (0.48 of the reference's characters)
	after    24 pages, 69606 glyphs   (0.93)
	tectonic 27 pages, 75018 characters

So minted joins the packages the engine does not load for real, next to listings:
its own implementation IS minted's draft-mode behaviour (verbatim, no Pygments, no
shell escape), and now covers \newminted, \newmintinline and \newmint — the derived
environment takes the language's name plus "code", or the optional argument when the
paper names it.

Over the 157 arXiv papers with a tectonic reference: page error 516 → 493, exact
24 → 26, within 1 page 66 → 68, within 2 pages 103 → 105.

Closes #225.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 114f391 into main Sep 5, 2026
18 checks passed
@tannevaled
tannevaled deleted the newminted branch September 5, 2026 06:30
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.

2405.10478 (sn-jnl) perd la moitié de son contenu, par blocs entrelacés

1 participant