diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/plautopatch/pxesopic.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/plautopatch/pxesopic.sty | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/plautopatch/pxesopic.sty b/Master/texmf-dist/tex/latex/plautopatch/pxesopic.sty new file mode 100644 index 00000000000..f020501e947 --- /dev/null +++ b/Master/texmf-dist/tex/latex/plautopatch/pxesopic.sty @@ -0,0 +1,177 @@ +% +% pxesopic.sty +% written by Hironobu Yamashita (@aminophen) +% +% This package is part of the plautopatch bundle. +% https://github.com/aminophen/plautopatch +% +% This package is expected to be compatible with +% * eso-pic.sty +% ????/??/?? v?.? -- 2018/04/12 v2.0h +% +% -------------------------------------------------------------- +% [Note] +% The package ``pxesopic.sty'' relies heavily on internals +% of ``plautopatch.sty'' +% -------------------------------------------------------------- +% + +%% package declaration +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{pxesopic} + [2020/09/27 v0.2a Patch to eso-pic for tombow] + +%% preparations +\def\pxesop@pkgname{pxesopic} +\def\pxesop@error{\PackageError\pxesop@pkgname} +\def\pxesop@warn{\PackageWarningNoLine\pxesop@pkgname} +\let\pxesop@debug\@gobble +\def\pxesop@debug#1{\typeout{\pxesop@pkgname: [DEBUG] #1}}% for debug + +%% hooks +\ifx\declare@file@substitution\@undefined + % LaTeX2e 2020-02-02 PL5 or older + \RequirePackage{filehook} + \let\pxesop@ExecuteAfterPackage=\AtEndOfPackageFile + \let\pxesop@ExecuteBeforePackage=\AtBeginOfPackageFile +\else + % LaTeX2e 2020-10-01 or newer + \def\pxesop@ExecuteAfterPackage#1{\AddToHook{package/after/#1}} + \def\pxesop@ExecuteBeforePackage#1{\AddToHook{package/before/#1}} +\fi + +%% the contents of \AtBeginShipout is dependent on \iftombow; +%% delay execution of \AtBeginShipout inside ``eso-pic.sty'' +%% until \AtBeginDocument, to support both (u)pLaTeX kernel +%% and ``gentombow.sty'' +\RequirePackage{atbegshi}% eso-pic requires atbegshi +\pxesop@ExecuteBeforePackage{eso-pic}{\pxesop@before} +\pxesop@ExecuteAfterPackage{eso-pic}{\pxesop@after} +% +\def\pxesop@before{% + \let\pxesop@AtBeginShipout\AtBeginShipout + \def\AtBeginShipout##1{\def\pxesop@hook{##1}}% hide it + \pxesop@debug{\noexpand\AtBeginShipout disabled}% + \let\pxesop@before\relax +} +\def\pxesop@after{% + \let\AtBeginShipout\pxesop@AtBeginShipout % restore + \let\pxesop@AtBeginShipout\relax + \pxesop@debug{\noexpand\AtBeginShipout restored}% + \let\@unknownoptionerror\relax %% avoid an error + \pxesop@debug{\noexpand\@unknownoptionerror disabled}% + \let\pxesop@after\relax +} +%% + +%% load it; be careful not to cause unknown option error! +\expandafter\ifx\csname @unknownoptionerror\endcsname + \pxesop@error{Failed to save \noexpand\@unknownoptionerror}\@ehc +\fi +\let\pxesop@unknownoptionerror\@unknownoptionerror +% +\chardef\pxesop@status\z@ +\@ifpackageloaded{plautopatch}{% + \expandafter\ifx\csname platpc@begin@eso-pic\endcsname\relax + % ``plautopatch.sty'' is loaded but the macro is \relax + % => means that ``pxesopic.sty'' is automatically loaded + \chardef\pxesop@status\@ne + \fi +}{} +% +%% pass all options to keyval-style ``eso-pic.sty'' +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{eso-pic}} +\ProcessOptions\relax +\RequirePackage{eso-pic} +% +%% recover the error +\ifnum\pxesop@status>\z@ % auto + \def\pxesop@pkgtohook{eso-pic}% + % note that ``plautopatch.sty'' discards the hook + % on LaTeX2e 2020-02-02 PL5 or older + \ifx\declare@file@substitution\@undefined + \let\pxesop@pkgtohook\pxesop@pkgname + % throw an error for unsupported usage + % [FIXME] the error below is actually unnecessary when + % none of ``eso-pic.sty'' options is used; how to detect that? + \pxesop@error{Try loading \pxesop@pkgname\space by hand}\@ehc + \fi +\else + \let\pxesop@pkgtohook\pxesop@pkgname +\fi +\pxesop@ExecuteAfterPackage\pxesop@pkgtohook{% + \let\@unknownoptionerror\pxesop@unknownoptionerror + \pxesop@debug{\noexpand\@unknownoptionerror restored}% +} +%% + +%% delayed to detect \iftombow status +\AtBeginDocument{% + \ifx\tombowtrue\@undefined + \pxesop@warn{Tombow feature unavailable, aborting}% + \fi + \iftombow \pxesop@new \else \pxesop@orig \fi}% +% +%% for \iftombow is FALSE => restore from ``eso-pic.sty'' +\expandafter\def\expandafter\pxesop@orig\expandafter{% + \expandafter\AtBeginShipout\expandafter{\pxesop@hook}} +% +%% for \iftombow is TRUE => redefine by ``pxesopic.sty'' +\def\pxesop@new{% + %% \AtStockLowerLeft: based on TRUE of \ESO@isMEMOIR + \renewcommand\AtStockLowerLeft[1]{% + \begingroup + \@tempdima=-\stockwidth + \advance\@tempdima\paperwidth + \@tempdimb=-\stockheight + \advance\@tempdimb\paperheight + %% specific BEGIN + \advance\@tempdima 1in\relax + \advance\@tempdimb 1in\relax + %% specific END + \AtPageLowerLeft{% + \put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimb}){##1}% + }% + \endgroup + }% === + %% \AtStockUpperLeft: based on TRUE of \ESO@isMEMOIR + \renewcommand\AtStockUpperLeft[1]{% + \AtStockLowerLeft{% + \put(0,\LenToUnit{\stockheight}){##1}% + }% + }% === + %% \AtStockCenter: based on TRUE of \ESO@isMEMOIR + \renewcommand\AtStockCenter[1]{% + \AtStockLowerLeft{% + \put(\LenToUnit{.5\stockwidth},\LenToUnit{.5\stockheight}){##1}% + }% + }% + %% \AtTextUpperLeft: same as FALSE of \ESO@isMEMOIR + % (no change) + % + %% \AtBeginShipout: based on TRUE of \ESO@isMEMOIR + \AtBeginShipout{% + \@tempdima=\dimexpr(\stockwidth-\paperwidth)/2\relax + \@tempdimb=-\dimexpr(\stockheight+\paperheight)/2\relax + \ifESO@texcoord + \advance\@tempdimb\paperheight % [FIXME] not sure! + \fi + \nointerlineskip + \AtBeginShipoutUpperLeft{% + \put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimb}){% + \ESO@HookIIIBG\ESO@HookIBG\ESO@HookIIBG + \global\let\ESO@HookIIBG\@empty + }% + }% + \AtBeginShipoutUpperLeftForeground{% + \put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimb}){% + \ESO@HookIFG\ESO@HookIIFG\ESO@HookIIIFG + \global\let\ESO@HookIIFG\@empty + }% + }% + }% === +} +%% + +\endinput +%% EOF |