Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bogus para/end hook error messages in special circumstances #605

Closed
FrankMittelbach opened this issue Jun 28, 2021 · 1 comment
Closed

Comments

@FrankMittelbach
Copy link
Member

Brief outline of the bug

The new definition for \par starts out with a conditional testing the current mode and if hmode do certain things.
This fails in a curious scenario which is really wrong coding elsewhere, but nevertheless we should safeguard for it:
Consider the following input

 text  \vskip \z@ \par

The scan for the glue actually "expands" \par here because \z@is a dimen and there could be some plus or minus component following. The correct coding according to the TeXbook would be to use \z@skipinstead for precisely that reason.
Nevertheless most of the time that would be harmless even now with \parchecking the mode. However, the listings package redefines \vskip as follows:

             \let\@@vskip\vskip
             \def\vskip{\afterassignment\lst@vskip \@tempskipa}%
             \def\lst@vskip{\nobreak\@@vskip\@tempskipa\nobreak}%

With that it is suddenly no longer harmless because now the \afterassignment is injected into the middle of the conditional
and only then it hits the original \vskip which switches to vertical mode. As a result the code in \par complains about a mode change in the para/endhook because that is supposedly the only code execuded in the middle of that conditional.

Rather a strange combination of circumstances but with listingsbeing used rather widely this needs a first aid which we will provide asap.

A bit of a surprising fact: the new definition for \par is defined as \protected\def, however, that doesn't stop the glue scanner to look into the definition.

Minimal example showing the bug

\RequirePackage{latexbug}       % we accept warnings about external packages here htis time!
\documentclass{article}

\usepackage{scrlayer-scrpage}

\usepackage{listings}

\begin{document}

abc\\[44\baselineskip] abc 


\begin{lstlisting}[caption={abc blub}]
code
\end{lstlisting}

\end{document}

Log file (required) and possibly PDF file

As a result we get:

./parahook-error.tex:13: LaTeX hooks Error: Illegal mode change in hook 'para/end'.
(hooks)              Hook code did not remain in horizontal mode.

For immediate help type H <return>.
 ...                                              
                                                  
l.13 \begin{lstlisting}[caption={abc blub}]

which is obviously bogus.

@FrankMittelbach
Copy link
Member Author

should be on ctan

yamadharma added a commit to yamadharma/ceurart that referenced this issue Jul 30, 2021
With fix for issue 605 <latex3/latex2e#605> pdfx doesn't seem to work
correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

1 participant