Dealing with a bizarre error due to single-quote characters

Ulrike Fischer news3 at nililand.de
Sun Sep 19 14:18:55 CEST 2021


Am Fri, 17 Sep 2021 00:24:50 -0400 schrieb Kirill Elagin:

> Hi Paul,
> 
> Wow, thank you, that’s such a good catch! Now it all makes sense.
> 
> Experimenting with this a bit, I also noticed that if I use your
> example and put `hello % world` in the input file, somehow the first
> page will literally contain “hello % world” in the header, while the
> second one will correctly have only “hello”.

Sure the catcode of % is 12 in verbatim, and at the moment when the
header is processed this is still the case. 

You can reset it in the header:


\begin{filecontents*}{input.latex}
%'
\end{filecontents*}

\documentclass{article}
\usepackage{scrlayer-scrpage}

\ohead{\catcode`\%=14 \input{input.latex}} %change catcode of % 

\begin{document}
\vspace*{\dimexpr\textheight-\baselineskip\relax}
\begin{verbatim}
x
\end{verbatim}
\end{document}


-- 
Ulrike Fischer 
https://www.troubleshooting-tex.de/



More information about the texhax mailing list.