Closed wehro closed 3 years ago
This is more complicated, and I'm not sure if it's entirely ‘legal’, because these macros are for temporary changes. But the following is clearly legal and also fails:
\section{^c}
\shorthandoff*{^}
Blah
\newpage
\shorthandon{^}
Blah
I have to deal with the output routine, which is not always easy.
I have no idea if this is useful, but perhaps you can use the fact that TeX is in "no mode" when TeX processes \write inside a shipped out page. (It is also in "no mode" inside \immediate\write.)
\ifmmode\else\ifhmode\else\ifvmode\else _we_are_now_inside_a_write \fi\fi\fi
Error message:
It works without problems with the unstarred form
\shorthandoff{^}
, so I think it should also work with the starred form.