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

Loading .sta file before \AtBeginDocument #3

Open
muzimuzhi opened this issue Jan 5, 2023 · 1 comment
Open

Loading .sta file before \AtBeginDocument #3

muzimuzhi opened this issue Jan 5, 2023 · 1 comment

Comments

@muzimuzhi
Copy link

Currently, .sta file, which (if exists) contains the collected sub-preambles, is read at begin of document (\AtBeginDocument). Since theses preambles may load packages by themselves, loading .sta in \AtBeginDocument maybe too late. See discussions in latex3/hyperref#242 and question 670638 on TeX-SX.

In LaTeX2e 2020-10-01, a hook management system is introduced hence \AtBeginDocument becomes a thin wrapper of \AddToHook{begindocument}. This hook system also provides a better position to load packages at the end of preamble: hook begindocument/before. In older LaTeX2e, this hook can be emulated by \AtEndPreamble from etoolbox package.

A proposal that only makes code changes (comment are not adapted):

diff --git a/standalone.sty b/standalone.sty
index 557f254..497a571 100644
--- a/standalone.sty
+++ b/standalone.sty
@@ -933,7 +933,11 @@
 % The |standalone| macros are defined to be without effect. If `sorting' is enabled \cs{usepackage} is temporarily
 % redefined to ignore any given options, which where already passed (\cs{PassOptionsToPackage}) beforehand.
 %    \begin{macrocode}
-\AtBeginDocument{%
+\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
+\IfFormatAtLeastTF{2020-10-01}
+  {\AddToHook{begindocument/before}}
+  {\RequirePackage{etoolbox}\AtEndPreamble}
+{%
   \let\subpreamble\@gobble
   \let\endsubpreamble\relax
   \let\standalonepreambles\relax
@dbitouze
Copy link

Any news about this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants