Repository navigation
render-pipeline: microtype's verbatim patch, and \frenchspacing inside \verb (15/17) - #271
Closed
GoKubar wants to merge 3 commits into
Conversation
…e \verb Fixture `32-verbatim-microtype` matches pdfLaTeX exactly; 14 of 17 verbatim fixtures become **15 of 17**. The two left are both blocked on a compiler change plus a vendor re-pin, which this crate cannot do. Two independent mismatches, each measured against pdflatex TeX Live 2025. ## 1. microtype turns protrusion off inside verbatim PR #187 recorded "protrusion and expansion need no new rule: microtype's default sets are `rm*`/`sf*`". Half right: the default *expansion* set is `alltext-nott`, which does exclude `tt*` -- but the default *protrusion* set is `alltext`, which is encoding-only and includes typewriter, and `microtype.cfg`'s `OT1-tt-default` list loads `default`, where `-` carries `{500,500}`. So the pipeline protruded the leading `--` of the verbatim line by 2.615 bp and pdfTeX did not. The reason pdfTeX does not is in its own log: ``` Package microtype Info: Applying patch `verbatim' on input line 3. ``` `patch=verbatim` is on by default and turns protrusion off inside `\verb` and `\@verbatim`. It is the *construct*, not the family -- a three-line probe under pdflatex TL2025, one line each: | line | first glyph x | |---|---| | `--` inside `verbatim` | **133.7680** (the text margin; no protrusion) | | `\texttt{-- ...}` | **131.1530** (protruded 2.615) | | `-- ...` in roman | **131.7760** (protruded 1.992) | So `micro_run` refuses a run whose style is `literal`, and `\texttt` keeps its protrusion. ## 2. `\verb` and `verbatim` are `\frenchspacing`, so nothing raises the space factor -- including for the space *after* the construct `\@verb` is `\@vobeyspaces \frenchspacing \@sverb` and `\verbatim` is `\@verbatim \frenchspacing \@vobeyspaces \@xverbatim` (latex.ltx 15514 and 15459). `\frenchspacing` sets `\sfcode`.'` to 1000, so no character inside either construct raises the space factor -- and the factor is not restored by the closing group, so the space *after* a `\verb` ending in `.` is an ordinary interword space. Measured, `\raggedright` so the spaces are natural and comparable: | source | x of the final `B` | space before it | |---|---|---| | `A \verb\|xy.\| B` | 163.5761 | 3.3275 (ordinary) | | `A \verb\|xyz\| B` | 163.5761 | 3.3275 | | `A \texttt{xy.} B` | **164.6819** | 4.4333 (sentence) | | `A \texttt{xyz} B` | 163.5761 | 3.3275 | | `A xy. B` roman | — | 4.4234 (sentence) | `\verb|xy.|` and `\verb|xyz|` are identical; `\texttt{xy.}` is 1.106 bp wider, which is cmr10's `\fontdimen7`. The pipeline was running `space_factor` over literal characters too, so an inline `\verb` ending in `.`, `?` or `!` was followed by a sentence space. In fixture 32 that one space was 1.045 bp too wide, and because the line is justified the error was redistributed over all thirteen of its interword spaces -- every glyph between "fills" and the `\verb` sat up to 0.34 bp left of pdfTeX, with the line's two ends matching exactly. That is why it reads as a microtype problem and is not one. ## Gates, control-compared Control is a `git archive` checkout of `eea975c3` measured the same way. | gate | control | this branch | |---|---|---| | `crates/render-pipeline` `cargo test --release --no-fail-fast` | 202 / 0 / 1 | 206 / 0 / 1 | | amsmath oracle corpus | — | 59/59 within 0.5 bp | | real-world corpus: status, pages, diagnostics per fixture/producer | — | identical, entry for entry | | real-world corpus total / font-substitution diagnostics | 203 / 0 | 203 / 0 | | HW1 / HW2 render pages, errors, overfull | — | 3 / 3, 0, 0 | | verbatim fixtures matching pdfLaTeX | 14 of 17 | **15 of 17** | `without_microtype_lines_match_pdflatex` and the `microtype_fixtures` suite are unchanged, which is the check that matters for change 1: no ordinary text lost its protrusion. Implementation-Agent: engine-engineer (linux-primary, NixOS PC) Commit-Executor: engine-engineer via git (Cursor usage limit fallback) Co-authored-by: GoKubar <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…guessed Both remaining `NOT_YET` entries were checked against PR #261's compiler rather than reasoned about: its `crates/compiler` was exported into `vendor/compiler` **uncommitted**, measured, and the tree restored (`git status` clean; the committed pin is untouched, and re-pinning is not this lane's to do). Four pipeline arms are needed for the new `style` field on `Inline::Verbatim`/`Block::Verbatim` — two patterns, one initializer that threads the block's style down to each line, and the lowered `Inline::Text` taking `..*vstyle` instead of `CStyle::default()`. (A fifth, unrelated error comes from `text_builtins::text_kern` having gained an `amsmath` argument on main since the pin; a re-pin carries that too.) With that in place: * **28-lstinline matches**: 115 glyphs, worst 0.005 bp. The 11 stray `basicstyle=` characters are gone. * **15-verbatim-small is left exactly 1.0 pt low, and nothing else.** Its horizontal geometry becomes exact — the body sets in CMTT9 and the line's last glyph lands at 194.964 against pdfTeX's 194.964. `\showoutput` names the residue: pdfTeX's skip above the block is `\glue 10.0 plus 4.0 minus 5.0` (`\topsep` 8+2−4, `\partopsep` 2+1−1, `\parskip` 0+1 — which this pipeline already computes), and its `\glue(\baselineskip) 3.55557` is `\small`'s **11 pt** baselineskip minus the previous line's depth 1.94444 and this line's height 5.49998. The pipeline sets the block at the body's 12 pt. That one difference is the whole remaining pound, and it is the block's baselineskip following its size declaration — the same field the re-pin delivers. Recorded in `NOT_YET` so the lane that does the re-pin starts from the numbers instead of rediscovering them. Implementation-Agent: engine-engineer (linux-primary, NixOS PC) Commit-Executor: engine-engineer via git (Cursor usage limit fallback) Co-authored-by: GoKubar <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…t/kabir-claude/verbatim-microtype-frenchspacing
GoKubar
added a commit
that referenced
this pull request
Sep 14, 2026
The listings engine branched from PR #262 and so did not carry #268 (`\@verbatim`'s `\trivlist` inside a list) or #271 (microtype's verbatim patch, and `\frenchspacing` inside `\verb`). Merging them makes the stack linear -- #262 -> #268 -> #271 -> this -- and moves both of their fixtures into `GATED` alongside the seventeen listings ones. The only conflict is `tests/verbatim_oracle.rs`'s three lists, resolved by taking every name both sides gate: * `GATED` 32 = the 15 verbatim/`\verb` fixtures (`10-verbatim-itemize` and `32-verbatim-microtype` from this merge) plus the 17 listings ones. * `NOT_YET` 2: `15-verbatim-small` keeps the `\showoutput` measurement from #271, `25-lst-java-roman` keeps the OT1-slot measurement from the listings lane. * `LISTINGS_NOT_YET`, added in #262 so `main`'s freshly merged #248 fixtures were accounted for rather than failing the accounting test, is gone: every name in it is now either gated or in `NOT_YET`. One fixture got better from the merge rather than from either side alone. **`28-lstinline` goes from 0.062 bp to 0.005 bp**: #271 carries the fix for the interword space that was being dropped after an inline `\verb` or `\lstinline` (`after_control_word` stayed set even though `prev_end` had already advanced past the closing delimiter), and that space is in this fixture's first line. Gates, control-compared against a `git archive` checkout of the listings branch's own base `b7a1e530`, built and measured identically: | gate | control | merged | |---|---|---| | `crates/render-pipeline` `cargo test --release --no-fail-fast` | 217 / 0 / 1 | 229 / 0 / 1 | | amsmath oracle corpus | -- | 59/59 within 0.5 bp | | real-world corpus, 22 fixtures x 2 producers | 739 diagnostics | 724 | | real-world corpus status and page count | -- | identical, every entry | | real-world corpus font-substitution diagnostics | 0 | 0 | | HW1 / HW2 render | -- | 3 / 3 pages, 0 errors, 0 overfull | | verbatim + listings fixtures matching pdfLaTeX | 30 of 34 | **32 of 34** | The +12 are the listings lane's unit tests. The two corpus entries that differ are the ones #271 already documents (`twelvept-plain` and `listings-manual`, both losing `unsupported_block` limitations; the three `overfull_hbox` in `listings-manual` are pdfLaTeX's own behaviour minus `breaklines` inside `\lstinline`). The listings engine itself adds no corpus diagnostic in either direction. Implementation-Agent: engine-engineer (linux-primary, NixOS PC) Commit-Executor: engine-engineer via git (Cursor usage limit fallback) Co-authored-by: GoKubar <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 14, 2026
Contributor
Author
|
Closed under the old-engine freeze (DESIGN.md D13): this is old-path feature or hand-port work, and the old engine retires at the P5 switch-over. The branch is kept; reopen it if it turns out to be a critical user-facing fix. — kabir-claude (Commander), nightly review 2026-09-30 |
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.
Stacked on #268, which is stacked on #262. This PR's own diff is the last commit: 3 files, +27/−9.
crates/render-pipelineonly.Fixture
32-verbatim-microtypematches pdfLaTeX exactly. 14 of 17 → 15 of 17. The two that remain are both blocked on a compiler change plus a vendor re-pin, which this crate cannot do.Two independent mismatches were hiding in one fixture, and the second is the interesting one.
1. microtype turns protrusion off inside verbatim
PR #187 recorded "Protrusion and expansion need no new rule: microtype's default sets are
rm*/sf*." Half right:alltext-nott, which does excludett*— so expansion needed no rule;alltext, which is encoding-only and includes typewriter. Andmicrotype.cfg'sOT1-tt-defaultlist hasload = OT1-default, which hasload = default, where-carries{500,500}.So the pipeline protruded the verbatim line's leading
--by 2.615 bp and pdfTeX did not. The reason is in pdfTeX's own log:patch=verbatimis on by default and switches protrusion off inside\verband\@verbatim. It is the construct, not the family — a three-line probe under pdflatex TL2025, all three lines starting with the same two hyphens:--insideverbatim\texttt{-- …}-- …in romanSo
micro_runrefuses a run whose style isliteral, and\textttkeeps its protrusion.without_microtype_lines_match_pdflatexand themicrotype_fixturessuite are unchanged, which is the check that matters here: no ordinary text lost anything.2.
\verbandverbatimare\frenchspacing, so nothing raises the space factor — including for the space after the construct\frenchspacingsets\sfcode.'to 1000, so no character inside either construct raises the space factor — and the factor is not restored by the closing group, so an inline\verbending in.` is followed by an ordinary interword space.Measured under
\raggedright, so the spaces are natural and directly comparable:BA \verb|xy.| BA \verb|xyz| BA \texttt{xy.} BA \texttt{xyz} BA xy. B(roman)\verb|xy.|and\verb|xyz|are identical;\texttt{xy.}is 1.106 bp wider, which is cmr10's\fontdimen7(1.11084 pt). The pipeline was runningspace_factorover literal characters too.Why this looked like a microtype bug and was not
In fixture 32 exactly one space — the one after
\verb|code, here.|— was 1.045 bp too wide. The line is justified, so the error was redistributed over all thirteen of its interword spaces. Pairing our glyphs against the reference in order shows it cleanly:Both ends of the line agree to 0.0004 bp and 64 of 64 glyphs are present; only the interior drifts. That shape — ends level, middle wrong — is what a single mis-sized glue in a justified line looks like, and it is worth recognising on sight.
Gates — control-compared
mainmoved while this stack was in flight (it now carries #235's compiler tab fix and #248's listings fixtures), so the stack was merged with it and everything below was re-measured against agit archivecontrol of currentmain, built the same way with the same bundled fonts configured.crates/render-pipelinecargo test --release --no-fail-fastCorpus re-measured against today's
main, and the two fixtures that movedmainhas grown since this stack's base, including alistings-manualfixture, so the corpus was re-run on both sides against agit archivecontrol of currentmain. Status and page count are identical for every fixture and producer. Total diagnostics 739 → 724, zero font-substitution diagnostics on both sides. Two entries differ, both on therenderproducer:twelvept-plain— 19 → 8 diagnostics: nineunsupported_blocklimitations gone. They all read "\verb… set in the body face: the pipeline has no monospaced face", which is precisely what this stack removes.listings-manual— 19 → 15: sevenunsupported_blockgone (four\verb, threeverbatimbodies), and three newoverfull_hboxat 118.42, 52.24 and 9.82 pt. Those deserve an explanation rather than a shrug, so here is the measurement.Reduced to one paragraph with the fixture's own preamble (
[11pt],[margin=1in]{geometry},[T1]{fontenc},listings):pdflatex TL2025 says:
pdfLaTeX overfulls this line itself, by 113.38 pt. We overfull it by 118.42 — 5.04 pt more, one typewriter character. Our line runs to x 654.964 against the reference's 649.942, with the same two-line structure (97 and 71 glyphs) and the same second line to 0.003 bp.
Add
\lstset{breaklines=true}— whichlistings-manualdoes set — and pdflatex's overfull disappears entirely: listings breaks inside\lstinlinewhenbreaklinesis on. So the three new warnings are pdfLaTeX's own behaviour minus one listings feature, and that feature is exactly what the listings lane is building.What they are not is a new defect introduced here.
mainreported no overfull for that fixture because it set the material in the body face, which is narrower than the typewriter face pdfTeX uses, so the line fitted. Silence there was the bug.What is left, measured against the fix rather than reasoned about
Both remaining fixtures need PR #261's compiler plus a
vendor/compilerre-pin, which this lane must not do. So I exported #261'scrates/compilerintovendor/compileruncommitted, measured, and restored the tree (git statusclean, committed pin untouched). The second commit here records what that showed.Four pipeline arms are needed for the new
stylefield onInline::Verbatim/Block::Verbatim: two patterns, one initializer threading the block's style down to each line, and the loweredInline::Texttaking..*vstyleinstead ofCStyle::default(). (A fifth, unrelated error comes fromtext_builtins::text_kerngaining anamsmathargument on main since the pin — a re-pin carries that too.)With that in place:
\showoutputnames the residue — pdfTeX's skip above the block is\glue 10.0 plus 4.0 minus 5.0(\topsep8+2−4,\partopsep2+1−1,\parskip0+1, all of which this pipeline already computes), and its\glue(\baselineskip) 3.55557is\small's 11 pt baselineskip minus the previous line's depth 1.94444 and this line's height 5.49998. The pipeline sets the block at the body's 12 pt. That single difference is the whole remaining pound, and the fix is the block's baselineskip following its size declaration — the same field the re-pin delivers.Both numbers are in
NOT_YETso the re-pinning lane starts from them.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu