## LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

 Options: Use Forum View Use Monospaced Font Show Text Part by Default Show All Mail Headers Message: [<< First] [< Prev] [Next >] [Last >>] Topic: [<< First] [< Prev] [Next >] [Last >>] Author: [<< First] [< Prev] [Next >] [Last >>]

 Subject: Re: Guidelines on the new hook management From: Michal Hoftich <[log in to unmask]> Reply To: Mailing list for the LaTeX3 project <[log in to unmask]> Date: Thu, 23 Jul 2020 14:37:09 +0200 Content-Type: text/plain Parts/Attachments: text/plain (76 lines)
Hello Joseph,

> # \shipout
>
> There are very few packages that actually modify the \shipout primitive:
> almost everyone uses either everyshi or atbegshi, and we have arranged
> for those to be emulated. As such, the only packages that need to be
> modified here are those that *directly*, which is limited as far as we
> know to pgf, crop and a few other packages. There are then a number of
> hooks one can use
>
> - shipout/before
> - shipout/foreground
> - shipout/background
> - shipout/firstpage
> - shipout/lastpage
>
> as described in "texdoc ltshipout".

We patch \shipout on one occasion:

\let\:shipout=\shipout
\def\shipout{\vfil\break\let\shipout=\:shipout \shipout}

If I understand correctly, it is executed only in the first use of
\shipout  and it doesn't seem to do anything useful, although I am
sure there was a use case at some point for that.

Is this code OK? It should work even in Plain.

> # \document
>
> Many more packages patch \document. Those adding code using
> \AtBeginDocument will have no issues: this kernel-level hook will
> continue to be available, although it is now a wrapper around
> \AddToHook. Many others will be using etoolbox's hooks: they are already
> aware of the new kernel hooks and again will need no work from package
> authors.
>

Yes, we use \AtBeginDocument a lot. It is good that this will continue to work.

> For people directly altering \document, the need to take action will
> depend on the exact nature of the changes. For example, I have had to
> adjust beamer, but siunitx, which also patches \document, continues to
> work with no action. (I will update to use 'best practice', but that is
> not a *requirement*.) Basically, anything that starts messing with the
> detail of \document needs action, whereas simply adding a macro to the
> end of \document works out OK.
>
> Where you do need to take action, there are now a number of hooks
>
> - env/document/before: Occurs as soon as \begin{document} is seen,
>      before the group is opened
> - env/document/begin: Occurs just after environment group is opened:
>     for \document this is not really different from the above due to
>     the special nature of \document
> - begindocument: Replaces \AtBeginDocument, occurring after the .aux
> - begindocument/end: Occurs right at the end of \document, followed
>      only by \ignorespaces: where many people add 'last minute' stuff to
>      \document
>

This seems really useful, thanks.

BTW, I was able to find the main clashes between TeX4ht and new LaTeX
code, so it works for the test file. I hope it will work also for real
world documents.

Best regards,
Michal