summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/platex-tools/pxatbegshi.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/platex-tools/pxatbegshi.sty')
-rw-r--r--Master/texmf-dist/tex/latex/platex-tools/pxatbegshi.sty66
1 files changed, 45 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/latex/platex-tools/pxatbegshi.sty b/Master/texmf-dist/tex/latex/platex-tools/pxatbegshi.sty
index 91e107dc790..577bfed6370 100644
--- a/Master/texmf-dist/tex/latex/platex-tools/pxatbegshi.sty
+++ b/Master/texmf-dist/tex/latex/platex-tools/pxatbegshi.sty
@@ -1,17 +1,19 @@
%
% pxatbegshi.sty
-% based on H. Kitagawa's code on GitHub:texjporg/tex-jp-build#21
-% and modified by Hironobu Yamashita
+% written by Hironobu Yamashita (@aminophen)
%
-% This package is distributed as part of the platex-tools bundle
-% maintained by Hironobu Yamashita
+% This package is part of the platex-tools bundle.
% https://github.com/aminophen/platex-tools
%
+% Largely based on bxpapersize.sty by T. Yato.
+% Previous versions were largely based on H. Kitagawa's
+% code on GitHub:texjporg/tex-jp-build#21.
+%
%% package declaration
\NeedsTeXFormat{pLaTeX2e}
\ProvidesPackage{pxatbegshi}
- [2017/11/04 v0.2 Patch to atbegshi for (u)pLaTeX]
+ [2018/09/21 v0.4 Patch to atbegshi for (u)pLaTeX]
%% preparations
\def\pxabgs@pkgname{pxatbegshi}
@@ -43,34 +45,56 @@
%---------------------------------------
-% concept: execute all hooks inside yoko direction \vbox
-
+%% patch \AtBegShi@Output
+% concept: execute all hooks in temporary yoko direction,
+% by prepending \yoko and switching back to the original
+%
% prepare
\let\pxabgs@AtBegShi@Output\AtBegShi@Output
-% try first patch
+% first, check hooks inserted by bxpapersize.sty
+% -> if detected, nothing to do
\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
- {\let\AtBegShi@OrgProtect\protect}%
- {\setbox8\vbox\bgroup\yoko\let\AtBegShi@OrgProtect\protect}
-\ifx\pxabgs@fragment\relax % failure
- \let\pxabgs@AtBegShi@Output\relax
-\else % success, try second patch
+ {\bxpr@ABS@prehook}{\bxpr@ABS@prehook}%
+\ifx\pxabgs@fragment\relax\else % found
\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
- {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox}%
- {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox\egroup}
- \ifx\pxabgs@fragment\relax % failure
+ {\bxpr@ABS@posthook}{\bxpr@ABS@posthook}%
+ \ifx\pxabgs@fragment\relax\else % found
\let\pxabgs@AtBegShi@Output\relax
\fi
\fi
-% commit the change only when successful
-\ifx\pxabgs@AtBegShi@Output\relax
- \pxabgs@warn{Failed in patching \string\AtBegShi@Output}
-\else
+% -> if not detected, prepend/append hooks
+\ifx\pxabgs@AtBegShi@Output\relax\else
+ \expandafter\def\expandafter\pxabgs@AtBegShi@Output\expandafter{%
+ \expandafter\pxabgs@ABS@prehook
+ \pxabgs@AtBegShi@Output
+ \pxabgs@ABS@posthook
+ }
+ % adjust for atbegshi.sty on non-e-TeX ...
+ % (for e-TeX, this patch should fail but does nothing!)
+ \pxabgs@patch@cmd\pxabgs@AtBegShi@Output
+ {\pxabgs@ABS@prehook\egroup\endgroup}
+ {\egroup\endgroup\pxabgs@ABS@prehook}%
+ % commit the change
\global\let\AtBegShi@Output\pxabgs@AtBegShi@Output
\fi
+%
+%% done
+
+%--------------------------------------- done
\endgroup
%% internal macros are no longer effective
-%--------------------------------------- done
+%% hooks
+\let\pxabgs@restore@dir\relax
+\def\pxabgs@ABS@prehook{%
+ \iftdir
+ \yoko
+ \let\pxabgs@restore@dir\tate
+ \else
+ \let\pxabgs@restore@dir\relax
+ \fi}
+\def\pxabgs@ABS@posthook{\pxabgs@restore@dir}
+
\endinput
%% EOF