Skip to content

Reset all verbatim-related catcodes in output routine (OR) #2056

@muzimuzhi

Description

@muzimuzhi

Brief outline of the enhancement

The ltnews41 entry for fixing #600 says

This has been fixed and LaTeX now explicitly resets
the \catcode values to their default settings when
entering the output routine. Furthermore, packages
that make changes to the tokenization beyond what is
done by verbatim
can use the newly introduced hook
build/page/reset to add their own resets to the output
routine processing.

It seems to me, this reads as "all verbatim-related catcode changes are automatically restored by LaTeX". But this is not true.

For example, the catcode of comma (,) which is set active by verbatim in \@noligs, is not restored. This makes the first example in #600 still reproducible.

Minimal example showing the current behaviour

A simplified version of the first example in #600.

\RequirePackage{latexbug}       % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}

\protected\def\checkcomma{\wlog{catcode of commat here is \the\catcode`\,\relax}}

\pagestyle{headings}
\markboth{\checkcomma}{\checkcomma}

% \AddToHook{build/page/reset}{\catcode`\,=12}

\begin{document}
\vspace*{0.8\textheight}

\begin{verbatim}
x
x
x
x
x
x
x
x
x
x
x
\end{verbatim}
\end{document}

in log

catcode of commat here is 13\relax 
 [1{/usr/local/texlive/2026basic/texmf-var/fonts/map/pdftex/updmap/pdftex.map}

]
catcode of commat here is 12\relax

Minimal example showing the desired new behaviour

Uncomment the line

% \AddToHook{build/page/reset}{\catcode`\,=12}

then in log

catcode of commat here is 12\relax 
 [1{/usr/local/texlive/2026basic/texmf-var/fonts/map/pdftex/updmap/pdftex.map}

]
catcode of commat here is 12\relax

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions