-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
At begin document material from package B may end up before or after at begin document from package A requiring B #1226
Comments
This is what the hooks mechanism is for ... |
It's by-design - you can just scroll past the message if you know it's not important. |
If you need ordering of material in hooks, you need to use the hook rules to request a particular sort. |
Is such situation documented? I mean by that, naturally, the ordering of hook rules is documented, but has the impact on existing legacy usage been illustrated with examples such as this one? I am surprised the full-fledged changes of the \AtBeginDocument mechanisms did not cause more breakage in usages of legacy packages hence in legacy documents. Probably this is because the volume of LaTeX packages and their uses in real world is not as diverse as one could think. Probably old documents which get recompiled often are for example mathematical articles using amsart, hence very controlled and limited context. Most old documents do never get recompiled, hence one never realizes they would break with contemporary LaTeX. |
Hook chunks are labelled, by default by your package name, and if you add to a hook then if there already exists code under the ⟨label⟩ then the new ⟨code⟩ is appended to the existing one.
It is only counter-intuitive if you view the hook code as unsorted, anonymous pieces of code, once you view them as labeled code chunks the logic is quite clear. It helps a lot to use
There were a small number of cases, where order was wrong, (mostly related to the top-level label), but your case is imho rather rare as most packages load subpackages first before doing something else. |
@u-fischer |
The "dozens of pages" bit was unnecessarily worded, and to be honest We could have a situation like this in the past. Package C needs to load Package A and Package B. For some reason Package B needs to be loaded after Package A. All three packages add material to be executed at begin document. It is important for Package C that some of its at begin document alteration are executed before package A. But this would create problems with Package B. So Package C needs to re-do some document alteration after Package A at begin document code is done. So in legacy situation you could have inside Packge C some code like this:
This legacy situation is broken by the 2020 LaTeX alterations to
and I have a doubt here if the order for the last two lines is certain. Inside the docs I see an example like this
but this is not enough for the above. PackageC has to use specific labels to get the desired ordering. Perhaps And I propose that it should explicitly state that PackageC author1 will need to update the code and use the modern syntax, as there was a breaking change done in 2020. Footnotes
|
This issue has been automatically marked as stale because it has not had recent activity. |
Not really sure what is wanted here: we covered the updates in |
Brief outline of the bug
See comments. An error arises because a package A requires a package B. Package B does "at begin document" some action "B" (
\mathchardef
). Package A after loading package B uses\AtBeginDocument
to do some action "A" (turns some character mathematically active). The author of Package A (jfbu) expects action "A" to be done after action "B". But actually action "A" is done before action "B" (I believe I will be told this is by design since the 2020 (?) modifications of at begin document) and this here causes a build error. But wait, there is more. This only happens if package A did also some innocuous\AtBeginDocument{\empty}
before requiring package B! This instability where you can't trust the logical order of your own code is the problem I want to report.This originates in real life and I went through a mind-boggling process to isolate the mechanism to some minimals as here, because this is so counter-intuitive that my brain was near collapse at more than one occasion.
Minimal example showing the bug
Log file (required) and possibly PDF file
testABD.log
A secondary issue is that I did not see in latexbug any option to tell it to accept without raising an error the packages which are part of the demonstration. Maybe some "warn" option would help the build raise an error only where it is significant. i thus recommend you comment out if testing my issue the
\RequirePackage{latexbug}
line.The text was updated successfully, but these errors were encountered: