summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/plautopatch/pxpdfpages.sty
blob: 3eb6ef13f345027064219e39c6c0835788ac1933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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