Skip to content

engine: the end-of-line character, and \ifcat on a \let character - #15

Merged
tannevaled merged 1 commit into
mainfrom
feat/shipout
Aug 17, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/shipout

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Two mouth-level pieces of TeX that beamer's own machinery stands on. Both were
found by pointing the real beamer.cls at the engine and asking what it did with
the document body: it commented ALL of it out.

  • \endlinechar. TeX reads its input one LINE at a time and appends the
    character \endlinechar (13 = ^^M) to each line; from then on that character
    acts on its CATCODE like any other. This engine keeps the source in one
    buffer with \n as the separator and produced a hardwired end-of-line token,
    so \endlinechar and \catcode\^^M were settable but inert. The mouth now presents the line separator AS \endlinechar (mouthChar): with the defaults that is exactly the token it produced before, and a package that changes either one now gets what TeX gives it. beamer reads a line verbatim with \catcode^^M=12 and a macro DELIMITED by ^^M; against a hardwired token
    that delimiter can never match and the macro runs away with the file.

  • \if and \ifcat on a control sequence \let to a CHARACTER. Such a cs behaves
    exactly as that character (TeX §506) — that is the whole point of
    \futurelet, which \let's a lookahead cs to the token it peeked at and then
    asks \ifcat what it was. The engine treated EVERY control sequence as "not a
    character", so \ifcat\next a was false for a \next \let to a letter.

    beamer decides whether a \mode<…> spec is a MODE NAME or an overlay range
    with exactly that test. It always answered "overlay", so every
    \mode concluded the mode did not apply and started beamer's
    line-by-line comment skipper — which then ate the rest of the class AND the
    document. That is why a talk came out blank.

    A \chardef'd constant is NOT a character token: real TeX answers OTHER for
    \ifcat\chardefd a and DIFF for \if\chardefd A, and so does this. Checked.

Also the kernel names those two fixes exposed next: \maxdimen (package code uses
it as "no limit", so its absence means the assignment does not happen), @COns,
@onelevel@sanitize / \strip@prefix, and xcolor's \ifglobalcolors /
\ifXC@keepwhite switches that xxcolor toggles around every colour it sets.

Where the beamer bring-up stands after this: the class loads and its modes now
resolve, the document reaches the page builder, and a two-page talk comes out
with the right page COUNT. The content is still wrong — xxcolor's pale-colour
layer leaks text ("pale") into the page — with, again, no undefined control
sequence. That is the next thread.

Proof: all tests pass under -race; the conformance ratchet gains three rows;
scripts/fidelity.sh --check is OK. Against a binary built from main BEFORE the
previous merge, the ten TikZ documents and all ten pages of the arXiv paper
(2608.14117) render PIXEL-IDENTICAL — these changes move nothing that worked.

🤖 Generated with Claude Code

Two mouth-level pieces of TeX that beamer's own machinery stands on. Both were
found by pointing the real beamer.cls at the engine and asking what it did with
the document body: it commented ALL of it out.

  * \endlinechar. TeX reads its input one LINE at a time and appends the
    character \endlinechar (13 = ^^M) to each line; from then on that character
    acts on its CATCODE like any other. This engine keeps the source in one
    buffer with \n as the separator and produced a hardwired end-of-line token,
    so \endlinechar and \catcode`\^^M were settable but inert. The mouth now
    presents the line separator AS \endlinechar (mouthChar): with the defaults
    that is exactly the token it produced before, and a package that changes
    either one now gets what TeX gives it. beamer reads a line verbatim with
    \catcode`\^^M=12 and a macro DELIMITED by ^^M; against a hardwired token
    that delimiter can never match and the macro runs away with the file.

  * \if and \ifcat on a control sequence \let to a CHARACTER. Such a cs behaves
    exactly as that character (TeX §506) — that is the whole point of
    \futurelet, which \let's a lookahead cs to the token it peeked at and then
    asks \ifcat what it was. The engine treated EVERY control sequence as "not a
    character", so \ifcat\next a was false for a \next \let to a letter.

    beamer decides whether a \mode<…> spec is a MODE NAME or an overlay range
    with exactly that test. It always answered "overlay", so every
    \mode<presentation> concluded the mode did not apply and started beamer's
    line-by-line comment skipper — which then ate the rest of the class AND the
    document. That is why a talk came out blank.

    A \chardef'd constant is NOT a character token: real TeX answers OTHER for
    \ifcat\chardefd a and DIFF for \if\chardefd A, and so does this. Checked.

Also the kernel names those two fixes exposed next: \maxdimen (package code uses
it as "no limit", so its absence means the assignment does not happen), \@COns,
\@onelevel@sanitize / \strip@prefix, and xcolor's \ifglobalcolors /
\ifXC@keepwhite switches that xxcolor toggles around every colour it sets.

Where the beamer bring-up stands after this: the class loads and its modes now
resolve, the document reaches the page builder, and a two-page talk comes out
with the right page COUNT. The content is still wrong — xxcolor's pale-colour
layer leaks text ("pale") into the page — with, again, no undefined control
sequence. That is the next thread.

Proof: all tests pass under -race; the conformance ratchet gains three rows;
scripts/fidelity.sh --check is OK. Against a binary built from main BEFORE the
previous merge, the ten TikZ documents and all ten pages of the arXiv paper
(2608.14117) render PIXEL-IDENTICAL — these changes move nothing that worked.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@tannevaled
tannevaled merged commit 280ab7b into main Aug 17, 2026
18 checks passed
@tannevaled
tannevaled deleted the feat/shipout branch August 17, 2026 14:35
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