summaryrefslogtreecommitdiff
path: root/macros/latex-dev/base/ltshipout.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-05-20 03:01:51 +0000
committerNorbert Preining <norbert@preining.info>2022-05-20 03:01:51 +0000
commit33fe673e1a4a678f76e23a91da0f449998af9c47 (patch)
tree54a9486c6ec7621c31e33af6e6f111666585b56a /macros/latex-dev/base/ltshipout.dtx
parent049d8c10a2be69e330d26efa5116b5ec451b8eab (diff)
CTAN sync 202205200301
Diffstat (limited to 'macros/latex-dev/base/ltshipout.dtx')
-rw-r--r--macros/latex-dev/base/ltshipout.dtx36
1 files changed, 31 insertions, 5 deletions
diff --git a/macros/latex-dev/base/ltshipout.dtx b/macros/latex-dev/base/ltshipout.dtx
index 09495dde9a..83fab820a9 100644
--- a/macros/latex-dev/base/ltshipout.dtx
+++ b/macros/latex-dev/base/ltshipout.dtx
@@ -32,8 +32,8 @@
%%% From File: ltshipout.dtx
%
% \begin{macrocode}
-\providecommand\ltshipoutversion{v1.0l}
-\providecommand\ltshipoutdate{2022/01/06}
+\providecommand\ltshipoutversion{v1.0m}
+\providecommand\ltshipoutdate{2022/05/08}
% \end{macrocode}
%
%<*driver>
@@ -1014,8 +1014,14 @@
\_@@_add_foreground_box:n
{ \UseHook{shipout/lastpage}
\@kernel@after@shipout@lastpage }
+ \bool_gset_true:N \g_@@_lastpage_handled_bool
+% \end{macrocode}
+% We record that we have handled the \hook{shipout/lastpage} hook
+% but only if we really did.
+% \changes{v1.0m}{2022/05/08}{Handle case where shipout/lastpage is
+% run too early (gh/813)}
+% \begin{macrocode}
}
- \bool_gset_true:N \g_@@_lastpage_handled_bool
}
\@@_finalize_box:
% \end{macrocode}
@@ -1723,15 +1729,35 @@
\gdef\string\@abspage@last {\int_use:N \g_shipout_readonly_int}}
\fi
% \end{macrocode}
-% But we may have guessed wrongly earlier and we still have to run the
+% But we may have guessed wrongly earlier and have run it too early
+% or we still have to run the
% \hook{shipout/lastpage} even though there is no page to place
% it into. If that is the case we make a trivial extra page and put
% it there. This temporary page will then vanish again on the next
% run but helps to keep pdf viewers happy.
+% In either case we should put out an appropriate ``rerun'' warning.
+% \changes{v1.0m}{2022/05/08}{Handle case where shipout/lastpage is
+% run too early (gh/813)}
% \begin{macrocode}
- \bool_if:NF \g_@@_lastpage_handled_bool
+ \bool_if:NTF \g_@@_lastpage_handled_bool
+ {
+% \end{macrocode}
+% If the hook was already executed, we have to test if that total
+% shipouts match the shipouts from last run (because that
+% corresponds to the page it was executed). If not we output a warning.
+% \begin{macrocode}
+ \int_compare:nNnF \@abspage@last = \g_shipout_readonly_int
+ {
+ \@latex@warning@no@line{Hook~ 'shipout/lastpage'~ executed~
+ on~ wrong~ page~ (\@abspage@last\space not~
+ \int_use:N\g_shipout_readonly_int).\MessageBreak
+ Rerun~ to~ correct~ this}%
+ }
+ }
{
% \end{macrocode}
+% If the hook was not run, we need to add an extra page and place
+% it there.
% However, making this extra page in case the hook is actually
% empty would be forcing a rerun without any reason, so we check
% that condition and also check if