summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/plautopatch
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-08-21 21:51:42 +0000
committerKarl Berry <karl@freefriends.org>2018-08-21 21:51:42 +0000
commitb63c18aafd706947f78fc4b084b82dbcc2e7e4a9 (patch)
treebdb1a6e8be30c804b35f8fa8f7484db2650927e2 /Master/texmf-dist/tex/latex/plautopatch
parent264fd35aafd09737359fce67fd7a048a44221303 (diff)
plautopatch (21aug18)
git-svn-id: svn://tug.org/texlive/trunk@48447 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/plautopatch')
-rw-r--r--Master/texmf-dist/tex/latex/plautopatch/plautopatch.sty147
-rw-r--r--Master/texmf-dist/tex/latex/plautopatch/pxpdfpages.sty49
2 files changed, 196 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/plautopatch/plautopatch.sty b/Master/texmf-dist/tex/latex/plautopatch/plautopatch.sty
new file mode 100644
index 00000000000..dbc40429c32
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/plautopatch/plautopatch.sty
@@ -0,0 +1,147 @@
+%
+% plautopatch.sty
+% written by Hironobu Yamashita (@aminophen)
+%
+% This package is part of the plautopatch bundle.
+% https://github.com/aminophen/plautopatch
+%
+
+\NeedsTeXFormat{pLaTeX2e}
+\ProvidesPackage{plautopatch}
+ [2018/08/21 v0.2 Automated patches for pLaTeX/upLaTeX]
+\def\platpc@pkgname{plautopatch}
+\def\platpc@warn{\PackageWarningNoLine\platpc@pkgname}
+\def\platpc@info{\PackageInfo\platpc@pkgname}
+
+\RequirePackage{filehook}
+
+% low-level helpers
+
+%% \platpc@req@add{<package>}
+% = if not loaded yet, \RequirePackage{<package>}
+% and add to list.
+\def\platpc@req@add#1{%
+ \@ifpackageloaded{#1}{}{\RequirePackage{#1}\platpc@addtolist{#1}}%
+}
+
+%% \platpc@addtolist{<package>}
+% = add <package> to list named \platpc@list.
+\def\platpc@addtolist#1{\xdef\platpc@list{\platpc@list, #1}}
+\def\platpc@list{}% initialize
+
+% high-level helpers
+
+%% \platpc@patch@after{<orig>}{<patch>}
+% = Load <patch> after <orig>.
+\def\platpc@patch@after#1#2{%
+ \expandafter\def\csname platpc@end@#1\endcsname{%
+ \expandafter\ifx\csname platpc@disable@#1\endcsname\relax
+ \platpc@req@add{#2}%
+ \fi
+ }%
+ \AtEndOfPackageFile{#1}{\csname platpc@end@#1\endcsname}%
+}
+\@onlypreamble\platpc@patch@after
+
+%% \platpc@patch@after@both{<orig 1>}{<orig 2>}{<patch>}
+% = Load <patch> after both <orig 1> & <orig 2>.
+\def\platpc@patch@after@both#1#2#3{%
+ % for order #2 => #1
+ \expandafter\def\csname platpc@end@#1+#2\endcsname{%
+ \expandafter\ifx\csname platpc@disable@#1\endcsname\relax
+ \expandafter\ifx\csname platpc@disable@#2\endcsname\relax
+ \@ifpackageloaded{#2}{\platpc@req@add{#3}}{}%
+ \fi
+ \fi
+ }%
+ \AtEndOfPackageFile{#1}{\csname platpc@end@#1+#2\endcsname}%
+ % for order #1 => #2
+ \expandafter\def\csname platpc@end@#2+#1\endcsname{%
+ \expandafter\ifx\csname platpc@disable@#2\endcsname\relax
+ \expandafter\ifx\csname platpc@disable@#1\endcsname\relax
+ \@ifpackageloaded{#1}{\platpc@req@add{#3}}{}%
+ \fi
+ \fi
+ }%
+ \AtEndOfPackageFile{#2}{\csname platpc@end@#2+#1\endcsname}%
+}
+\@onlypreamble\platpc@patch@after@both
+
+%% \platpc@patch@before{<orig>}{<patch>}
+% = Load <patch> before <orig>.
+% used when both conditions are met:
+% - <patch> must be loaded *before* <orig>
+% - <patch> contains \RequirePackage{<orig>}
+\def\platpc@patch@before#1#2{%
+ \expandafter\def\csname platpc@begin@#1\endcsname{%
+ % if <patch> is already loaded, nothing to do
+ \@ifpackageloaded{#2}{}{% else
+ \expandafter\ifx\csname platpc@disable@#1\endcsname\relax
+ % the code (*!) should be used only once,
+ % remove it immediately when this macro is executed
+ \expandafter\let\csname platpc@begin@#1\endcsname\relax
+ % pretend as if <orig> not loaded
+ \expandafter\let\csname ver@#1.sty\endcsname\relax
+ % load the <patch> package
+ \RequirePackage{#2}\platpc@addtolist{#2}%
+ % avoid loading <orig> twice by discarding "\@@input <orig>" (*!)
+ \let\platpc@filehook@@atbegin\filehook@@atbegin
+ \def\filehook@@atbegin\@@input####1\filehook@atend{%
+ \let\filehook@@atbegin\platpc@filehook@@atbegin
+ % avoid infinite loop even when \AtEndOfPackageFile used
+ \expandafter\let\csname filehook@atend@#1.sty\endcsname\relax
+ \filehook@@atbegin
+ \filehook@atend}%
+ % all done
+ \fi
+ }%
+ }%
+ \AtBeginOfPackageFile{#1}{\csname platpc@begin@#1\endcsname}%
+}
+\@onlypreamble\platpc@patch@before
+
+% interface for users who want don't patches
+
+%% \plautopatchdisable{<orig 1>,<orig 2>,...}
+% = Disable patches triggered by <orig 1>, <orig 2>, ...
+\newcommand{\plautopatchdisable}[1]{%
+ \edef\@tempa{\zap@space#1 \@empty}%
+ \@for\@tempa:=\@tempa\do{%
+ \expandafter\let\csname platpc@disable@\@tempa\endcsname\@empty
+ }%
+}
+\@onlypreamble\plautopatchdisable
+
+% show list of loaded patches
+
+\AtEndDocument{\platpc@showlist}
+\def\platpc@showlist{%
+ \ifx\platpc@list\@empty
+ \platpc@info{No additional packages loaded}
+ \else
+ % the first token of \platpc@list should be ','
+ \typeout{%
+ ***** List of packages loaded by `\platpc@pkgname': *****^^J%
+ \expandafter\@gobble\platpc@list.^^J%
+ *****************************************************}%
+ \fi
+}
+
+% register patches
+
+\ifx\enablecjktoken\@undefined
+ \platpc@patch@after{tracefnt}{ptrace}% platex
+\else
+ \platpc@patch@after{tracefnt}{uptrace}% uplatex
+\fi
+\platpc@patch@after{fltrace}{pfltrace}% platex
+\platpc@patch@after{array}{plarray}% platex-tools
+\platpc@patch@after@both{array}{plext}{plextarray}% platex-tools
+\platpc@patch@after@both{delarray}{plext}{plextdelarray}% platex-tools
+\platpc@patch@after{everysel}{pxeverysel}% platex-tools
+\platpc@patch@after{everyshi}{pxeveryshi}% platex-tools
+\platpc@patch@after{atbegshi}{pxatbegshi}% platex-tools
+\platpc@patch@before{ftnright}{pxftnright}% platex-tools
+\platpc@patch@after{pdfpages}{pxpdfpages}% (maintained here!)
+
+\endinput
diff --git a/Master/texmf-dist/tex/latex/plautopatch/pxpdfpages.sty b/Master/texmf-dist/tex/latex/plautopatch/pxpdfpages.sty
new file mode 100644
index 00000000000..3eb6ef13f34
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/plautopatch/pxpdfpages.sty
@@ -0,0 +1,49 @@
+%
+% pxpdfpages.sty
+% written by Hironobu Yamashita (@aminophen)
+%
+% This package is part of the plautopatch bundle.
+% https://github.com/aminophen/plautopatch
+%
+% This package `pxpdfpages.sty' is based on:
+% * pdfpages.sty (2017/10/31 v0.5l)
+% * plcore.ltx in platex (2018/05/13 v1.2z)
+%
+
+%% package declaration
+\NeedsTeXFormat{pLaTeX2e}
+\ProvidesPackage{pxpdfpages}
+ [2018/08/20 v0.1 Patch to pdfpages for (u)pLaTeX]
+
+%% preparations
+\def\pxpdpg@pkgname{pxpdfpages}
+\def\pxpdpg@warn{\PackageWarningNoLine\pxpdpg@pkgname}
+\def\pxpdpg@info{\PackageInfo\pxpdpg@pkgname}
+
+%% load it
+\RequirePackageWithOptions{pdfpages}
+\RequirePackage{pxatbegshi}% pdfpages requires atbegshi
+
+%% patch internal for pdfpages to work with tombow
+%% Note: this code should be copied to gentombow.sty!
+\def\pxpdpg@patch@pdfpages{%
+ \RequirePackage{etoolbox}
+ \patchcmd{\AM@output}{%
+ \setlength{\@tempdima}{\AM@xmargin}%
+ \edef\AM@xmargin{\the\@tempdima}%
+ \setlength{\@tempdima}{\AM@ymargin}%
+ \edef\AM@ymargin{\the\@tempdima}%
+ }{%
+ \setlength{\@tempdima}{\AM@xmargin\iftombow+1in\fi}%
+ \edef\AM@xmargin{\the\@tempdima}%
+ \setlength{\@tempdima}{\AM@ymargin\iftombow-1in\fi}%
+ \edef\AM@ymargin{\the\@tempdima}%
+ }
+ {\pxpdpg@info{Patch for pdfpages applied}}
+ {\pxpdpg@warn{Patch for pdfpages failed}}%
+ }
+\AtBeginDocument{\@ifpackageloaded{pdfpages}{\pxpdpg@patch@pdfpages}{}}
+
+%% all done
+
+\endinput