Skip to content

render-pipeline: microtype's verbatim patch, and \frenchspacing inside \verb (15/17) - #271

Closed
GoKubar wants to merge 3 commits into
agent/kabir-claude/verbatim-trivlist-in-listfrom
agent/kabir-claude/verbatim-microtype-frenchspacing
Closed

GoKubar wants to merge 3 commits into
agent/kabir-claude/verbatim-trivlist-in-listfrom
agent/kabir-claude/verbatim-microtype-frenchspacing

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #268, which is stacked on #262. This PR's own diff is the last commit: 3 files, +27/−9. crates/render-pipeline only.

Fixture 32-verbatim-microtype matches 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:

  • the default expansion set is alltext-nott, which does exclude tt* — so expansion needed no rule;
  • the default protrusion set is alltext, which is encoding-only and includes typewriter. And microtype.cfg's OT1-tt-default list has load = OT1-default, which has load = 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:

Package microtype Info: Applying patch `verbatim' on input line 3.

patch=verbatim is on by default and switches protrusion off inside \verb and \@verbatim. It is the construct, not the family — a three-line probe under pdflatex TL2025, all three lines starting with the same two hyphens:

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. without_microtype_lines_match_pdflatex and the microtype_fixtures suite are unchanged, which is the check that matters here: no ordinary text lost anything.

2. \verb and verbatim are \frenchspacing, so nothing raises the space factor — including for the space after the construct

latex.ltx:15514  \def\@verb{\@vobeyspaces \frenchspacing \@sverb}
latex.ltx:15459  \def\verbatim{\@verbatim \frenchspacing\@vobeyspaces \@xverbatim}

\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 an inline\verbending in.` is followed by an ordinary interword space.

Measured under \raggedright, so the spaces are natural and directly 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 (1.11084 pt). The pipeline was running space_factor over 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:

  3 's'    ref  145.0598 ours  145.0593 diff  +0.0005
  4 'a'    ref  152.4516 ours  152.3825 diff  +0.0691   <- each space 0.0685 narrower
  9 'o'    ref  180.0979 ours  179.9005 diff  +0.1974
 14 'p'    ref  209.1659 ours  208.8300 diff  +0.3359
 19 'I'    ref  236.9159 ours  236.4024 diff  +0.5135   <- the sentence space after "page."
 34 '.'    ref  317.7247 ours  317.1433 diff  +0.5814   <- end of \verb|code, here.|
 35 'e'    ref  326.3360 ours  326.7995 diff  -0.4635   <- step -1.0449: the one real error
 63 'd'    ref  471.8344 ours  471.8340 diff  +0.0004   <- and the line ends level again

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

main moved 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 a git archive control of current main, built the same way with the same bundled fonts configured.

gate control this branch
crates/render-pipeline cargo test --release --no-fail-fast 213 / 0 / 1 217 / 0 / 1
amsmath oracle corpus — 59 / 59 within 0.5 bp
real-world corpus: status and page count, every fixture and producer identical identical
real-world corpus total diagnostics 739 724
real-world corpus font-substitution diagnostics 0 0
HW1 / HW2 render pages 3 / 3 3 / 3, 0 errors, 0 overfull
verbatim fixtures matching pdfLaTeX 14 of 17 15 of 17

Corpus re-measured against today's main, and the two fixtures that moved

main has grown since this stack's base, including a listings-manual fixture, so the corpus was re-run on both sides against a git archive control of current main. 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 the render producer:

twelvept-plain — 19 → 8 diagnostics: nine unsupported_block limitations 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: seven unsupported_block gone (four \verb, three verbatim bodies), and three new overfull_hbox at 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):

Configuration keys may also be overridden on the command line, for example
\lstinline|ftxc build --set watch.debounce_ms=50|. Command-line overrides
always take precedence over the values found in \texttt{ftxc.toml}.

pdflatex TL2025 says:

Overfull \hbox (113.38303pt too wide) in paragraph at lines 6--9
[]\T1/cmr/m/n/10.95 Configuration keys may also be over-rid-den on the com-mand
 line, for ex-am-ple [][][][][][][][][][][].

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} — which listings-manual does set — and pdflatex's overfull disappears entirely: listings breaks inside \lstinline when breaklines is 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. main reported 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/compiler re-pin, which this lane must not do. So I exported #261's crates/compiler into vendor/compiler uncommitted, measured, and restored the tree (git status clean, committed pin untouched). The second commit here records what that showed.

Four pipeline arms are needed for the new style field on Inline::Verbatim/Block::Verbatim: two patterns, one initializer threading 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 gaining 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. → 16 of 17.
  • 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, all of 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 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_YET so the re-pinning lane starts from them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 3 commits September 13, 2026 21:41
…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
@GoKubar

GoKubar commented Sep 30, 2026

Copy link
Copy Markdown
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

@GoKubar GoKubar closed this Sep 30, 2026
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