summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pdfxup
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/pdfxup')
-rw-r--r--Master/texmf-dist/tex/latex/pdfxup/pdfxup-template.tex250
1 files changed, 158 insertions, 92 deletions
diff --git a/Master/texmf-dist/tex/latex/pdfxup/pdfxup-template.tex b/Master/texmf-dist/tex/latex/pdfxup/pdfxup-template.tex
index f5b6839f312..5f7bea843f2 100644
--- a/Master/texmf-dist/tex/latex/pdfxup/pdfxup-template.tex
+++ b/Master/texmf-dist/tex/latex/pdfxup/pdfxup-template.tex
@@ -1,6 +1,25 @@
+%
+% pdfxup template file
+%
+%% (c) 2021/04/25 Nicolas Markey <pdfxup at markey dot fr>
+%%
+%% This work may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3 of this license
+%% or (at your option) any later version. The latest version of this
+%% license is in
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3 or later is part of all distributions of LaTeX version
+%% 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%% The Current Maintainer of this work is Nicolas Markey.
+
+
\expandafter\ifx\csname pdfxupfile\endcsname\relax
\PackageError{pdfxup}{This file should not be compiled alone}
- {File pdfxup-template.pdf is not meant to be compiled alone.
+ {File pdfxup-template.tex is not meant to be compiled alone.
\MessageBreak
It should only be used via the 'pdfxup' script.}
\fi
@@ -20,17 +39,17 @@
\newcounter{result}%
\newif\iffound
\def\@parserange#1-#2-#3\@end#4\@end{%
- \setcounter{result}{#4}%
- \ifnum\value{result}=1\relax
+ \c@result=#4\relax%
+ \ifnum\c@result=1\relax
\foundtrue
- \setcounter{result}{#1}%
+ \c@result=#1\relax%
\else
- \addtocounter{result}{-1}%
+ \advance\c@result by -1\relax%
\ifx\relax#3\relax%% means that range contains no -
\else
- \addtocounter{result}{#1}%
- \ifnum#2<\value{result}\relax
- \addtocounter{result}{-#2}%
+ \advance\c@result by #1\relax%
+ \ifnum#2<\c@result\relax
+ \advance\c@result by -#2\relax%
\else
\foundtrue
\fi
@@ -40,48 +59,45 @@
\def\@parsecsl#1,#2\@end#3\@end{%
\parserange{#3}{#1}%
\iffound\else
- \ifx\relax#2\relax\else\@parsecsl#2\@end\value{result}\@end\fi\fi}
+ \ifx\relax#2\relax\else\@parsecsl#2\@end\c@result\@end\fi\fi}
%% \nthvalue#1#2 looks for #1-th value in list of intervals #2
\def\nthvalue#1#2{\foundfalse\expandafter\@parsecsl#2,\@end#1\@end}
- %%
-
%% perform various computations:
%% - width and height of image (\hresult and \vresult)
%% - width and height of frame containing image (\hboxsize and \vboxsize)
\newcounter{lastpage}
- \newcounter{outpage}
- \setcounter{outpage}{\pdfxupnbpages}
- \addtocounter{outpage}{-1}
+ \newcounter{outpage}%%% nr of pages of output document
+ \c@outpage=\pdfxupnbpages\relax
+ \advance\c@outpage by -1\relax
\divide\c@outpage by \pdfxupnbhoriz
\divide\c@outpage by \pdfxupnbvert
\ifbooklet
- \divide\c@outpage by 2
+ \divide\c@outpage by 2\relax
\fi
- \stepcounter{outpage}
+ \advance\c@outpage by 1\relax
\ifbooklet
- \multiply\c@outpage by 2
+ \multiply\c@outpage by 2\relax
\fi
- \setcounter{lastpage}{\value{outpage}}
+ \c@lastpage=\c@outpage\relax
\multiply\c@lastpage by \pdfxupnbhoriz
\multiply\c@lastpage by \pdfxupnbvert
- \makeatother
%
\newlength\outputvmargin
\newlength\outputhmargin
- \setlength\outputvmargin{\pdfxupvmargin}
- \setlength\outputhmargin{\pdfxuphmargin}
+ \outputvmargin=\pdfxupvmargin\relax
+ \outputhmargin=\pdfxuphmargin\relax
\newlength\innervmargin
\newlength\innerhmargin
- \setlength\innervmargin{\pdfxupinnervmargin}
- \setlength\innerhmargin{\pdfxupinnerhmargin}
+ \innervmargin=\pdfxupinnervmargin\relax
+ \innerhmargin=\pdfxupinnerhmargin\relax
\newlength\outputindivvmargin
\newlength\outputindivhmargin
- \setlength\outputindivvmargin{\pdfxupintermvspace}
- \setlength\outputindivhmargin{\pdfxupintermhspace}
+ \outputindivvmargin=\pdfxupintermvspace\relax
+ \outputindivhmargin=\pdfxupintermhspace\relax
%
- \fboxsep=0pt%
- \setlength\fboxrule{\pdfxupframewidth}
+ \fboxrule=\pdfxupframewidth\relax
+ \fboxsep=-\fboxrule
\newlength\hresult
\newlength\vresult
\newlength\vboxsize
@@ -94,8 +110,8 @@
\vresult=\paperheight
\advance\vresult by -\pdfxupnbvert\fboxrule
\advance\vresult by -\pdfxupnbvert\fboxrule
- \advance\vresult by -\pdfxupnbvert\innerhmargin
- \advance\vresult by -\pdfxupnbvert\innerhmargin
+ \advance\vresult by -\pdfxupnbvert\innervmargin
+ \advance\vresult by -\pdfxupnbvert\innervmargin
%
\advance\hresult by -2\outputhmargin
\advance\vresult by -2\outputvmargin
@@ -116,14 +132,26 @@
\advance\hboxsize by 2\innerhmargin
- %% compute actual scale by which PDF is shrunk (or extended)
+ \let\pdfxupnblines\pdfxupnbvert
+ \let\pdfxupnbcols\pdfxupnbhoriz
+ \ifnum\columnmode=0\relax
+ %% "row-mode"
+ \def\horizincr{\pdfxupnbhoriz}
+ \def\vertincr{1}
+ \else
+ %% "column-mode"
+ \def\horizincr{1}
+ \def\vertincr{\pdfxupnbvert}%
+ \fi
+
+%% compute actual scale by which PDF is shrunk (or extended)
\ifnum\pdfxupemptybb=0\relax
\newcounter{origx}
- \setcounter{origx}{\pdfxupw}
- \addtocounter{origx}{-\pdfxupx}
+ \c@origx=\pdfxupw\relax
+ \advance\c@origx by -\pdfxupx\relax
\newcounter{origy}
- \setcounter{origy}{\pdfxuph}
- \addtocounter{origy}{-\pdfxupy}
+ \c@origy=\pdfxuph\relax
+ \advance\c@origy by -\pdfxupy\relax
\newlength\finalx
\newlength\finaly
\finalx=\hresult
@@ -148,56 +176,94 @@
%\tracingoutput=1
%\tracingpages=1
%\tracingparagraphs=1
- \makeatletter
- \newcounter{curroutpage}
- \setcounter{curroutpage}{1}
- \addtocounter{curroutpage}{-1}
- \newcounter{currpage}
- \newcounter{currcol}
- \newcounter{currline}
- \newcounter{realout}
- \newcounter{wmout}
- \newcounter{wmoutaux}
- \@whilenum \value{outpage}>\value{curroutpage} \do%
- {\stepcounter{curroutpage}%
- \setcounter{currpage}{\value{curroutpage}}%
- \advance\c@currpage by -1%
- \multiply\c@currpage by \pdfxupnbhoriz%
- \multiply\c@currpage by \pdfxupnbvert%
+ \newcounter{curroutpage}%%%% counts pages nr of output document
+ \c@curroutpage=0\relax
+ \newcounter{currpage}%%%%%%% page nr of input document
+ \newcounter{linecurrpage}%%% currpage at beginning of line
+ \newcounter{currcol}%
+ \newcounter{currline}%
+ \newcounter{realout}%
+ \newcounter{wmout}%
+ \newcounter{wmoutaux}%
+ \@whilenum \c@outpage>\c@curroutpage \do%
+ {\advance\c@curroutpage by 1\relax%
+ %% check if we are on last page, and if so, possibly balance last page
+ \if0\balancelast\relax\else
+ \c@currpage=\c@curroutpage\relax%
+ \multiply\c@currpage by \pdfxupnbhoriz\relax%
+ \multiply\c@currpage by \pdfxupnbvert\relax%
+ \ifnum\c@currpage>\pdfxupnbpages\relax
+ \c@currpage=-\c@curroutpage\relax%
+ \advance\c@currpage by 1 %
+ \multiply\c@currpage by \pdfxupnbhoriz\relax%
+ \multiply\c@currpage by \pdfxupnbvert\relax%
+ \advance\c@currpage by \pdfxupnbpages\relax
+ \ifnum\columnmode=0\relax
+ \advance\c@currpage by -1\relax
+ \divide\c@currpage by \pdfxupnbvert\relax%
+ \advance\c@currpage by 1\relax
+ \edef\horizincr{\thecurrpage}%
+ \edef\pdfxupnbcols{\thecurrpage}%
+ \else
+ \advance\c@currpage by -1\relax
+ \divide\c@currpage by \pdfxupnbhoriz\relax%
+ \advance\c@currpage by 1\relax
+ %\showthe\value{currpage}
+ \edef\vertincr{\thecurrpage}%
+ \edef\pdfxupnblines{\thecurrpage}%
+ %\show\vertincr
+ %\show\horizincr
+ \fi
+ \fi
+ \fi
+ %% start producing page
+ \c@currpage=\c@curroutpage%
+ \advance\c@currpage by -1\relax%
+ \multiply\c@currpage by \pdfxupnbhoriz\relax%
+ \multiply\c@currpage by \pdfxupnbvert\relax%
+ \c@linecurrpage=\c@currpage%
\hrule \@height\z@%
- \setcounter{currline}{0}%
- \vskip \outputvmargin%
- \@whilenum\value{currline}<\pdfxupnbvert \do%
- {\hrule \@height\z@\vskip \outputindivvmargin%
- \ifnum\value{currline}>0\vskip \outputindivvmargin\fi%
- \global\stepcounter{currline}%
- \setcounter{currcol}{0}%
+ \c@currline=0\relax%
+ \vskip\outputvmargin%
+ \@whilenum\c@currline<\pdfxupnblines \do%
+ {\hrule \@height\z@%
+ \ifnum\value{currline}>0\relax%
+ \vskip \outputindivvmargin%
+ \advance\c@linecurrpage by \horizincr\relax%
+ \else%
+ \advance\c@linecurrpage by 1\relax%
+ \fi%
+ \advance\c@currline by 1\relax%
+ \c@currpage=\c@linecurrpage\relax%
+ \c@currcol=0\relax%
\hskip \outputhmargin%
- \@whilenum\value{currcol}<\pdfxupnbhoriz \do%
- {\ifnum\value{currcol}>0\hskip\outputindivhmargin\fi%
- \global\stepcounter{currcol}%
- \global\stepcounter{currpage}%
- \ifnum\value{currpage}>\value{lastpage}\else
+ \@whilenum\c@currcol<\pdfxupnbcols \do%
+ {\ifnum\c@currcol>0\relax%
+ \hskip\outputindivhmargin%
+ \advance\c@currpage by \vertincr\relax%
+ \fi%
+ \advance\c@currcol by 1\relax%
+ \ifnum\c@currpage>\c@lastpage\else
%% computing page number corresponding to \currline and \currcol
- \setcounter{realout}{\value{currpage}}%
+ \c@realout=\c@currpage%
\def\ang{0}%
\ifbooklet
\iflongedge
%% long edge:
%% 1->n, 2->1, 3->n-1 (rotated), 4->2(rotated)...
- \ifodd\value{realout}% -> 1 or 3
- \addtocounter{realout}{-1}%
+ \ifodd\c@realout\relax% -> 1 or 3
+ \advance\c@realout by -1\relax%
\divide\c@realout by 2\relax
- \ifodd\value{realout}% -> 3
+ \ifodd\c@realout\relax% -> 3
\def\ang{180}%
\else% -> 1
\fi
- \setcounter{realout}{-\value{realout}}%
- \addtocounter{realout}{\value{outpage}}%
- \addtocounter{realout}{\value{outpage}}%
+ \c@realout=-\value{realout}\relax%
+ \advance\c@realout by \c@outpage\relax%
+ \advance\c@realout by \c@outpage\relax%
\else% -> 2 or 4
\divide\c@realout by 2\relax
- \ifodd\value{realout}% -> 2
+ \ifodd\c@realout% -> 2
\else% -> 4
\def\ang{180}%
\fi
@@ -205,51 +271,51 @@
\else
%% short edge:
%% 1->n, 2->1, 3->2, 4->n-1, 5->n-2, 6->3, 7->4, 8->n-3
- \ifodd\value{realout}% -> 1 or 3
- \addtocounter{realout}{-1}%
+ \ifodd\c@realout\relax% -> 1 or 3
+ \advance\c@realout by -1\relax%
\divide\c@realout by 2\relax
- \ifodd\value{realout}% -> 3
- \stepcounter{realout}
+ \ifodd\c@realout% -> 3
+ \advance\c@realout by 1\relax
\else% -> 1
- \setcounter{realout}{-\value{realout}}%
- \addtocounter{realout}{\value{outpage}}%
- \addtocounter{realout}{\value{outpage}}%
+ \c@realout=-\c@realout%
+ \advance\c@realout by \c@outpage\relax%
+ \advance\c@realout by \c@outpage\relax%
\fi
\else% -> 2 or 4
\divide\c@realout by 2\relax
- \ifodd\value{realout}% -> 2
+ \ifodd\c@realout\relax% -> 2
\else% -> 4
- \setcounter{realout}{-\value{realout}}%
- \stepcounter{realout}
- \addtocounter{realout}{\value{outpage}}%
- \addtocounter{realout}{\value{outpage}}%
+ \c@realout=-\c@realout\relax%
+ \advance\c@realout by 1\relax
+ \advance\c@realout by \c@outpage\relax%
+ \advance\c@realout by \c@outpage\relax%
\fi
\fi
\fi %% \iflongedge...\else
\fi %% \ifbooklet
- \ifnum\value{realout}>\pdfxupnbpages\relax
+ \ifnum\c@realout>\pdfxupnbpages\relax
%% if page above nb of pages, output blank page
%\hskip\hresult\hskip2\fboxrule
\hskip\hboxsize
\else
%% otherwise compute corresponding page to display
%% first keep realout for watermarking...
- \setcounter{wmoutaux}{\value{realout}}%
- \setcounter{wmout}{\value{realout}}%
- \nthvalue{\value{realout}}{\pdfxuppagelist}%
- \iffound\setcounter{realout}{\value{result}}%
+ \c@wmoutaux=\c@realout\relax%
+ \c@wmout=\c@realout\relax%
+ \nthvalue{\c@realout}{\pdfxuppagelist}%
+ \iffound\c@realout=\c@result\relax%
\else %% hmmm... problem
\message{I'm messed up counting pages...}%
\fi
%% compute watermarking page and display
\ifx\pdfxupwatermark\@empty\else
- \ifnum\pdfxupnbwp<\value{wmoutaux}\relax
- \addtocounter{wmoutaux}{-\pdfxupnbwp}%
- \addtocounter{wmoutaux}{-1}%
+ \ifnum\pdfxupnbwp<\c@wmoutaux\relax
+ \advance\c@wmoutaux by -\pdfxupnbwp\relax%
+ \advance\c@wmoutaux by -1\relax%
\divide\c@wmoutaux by \pdfxupwperiod\relax
- \stepcounter{wmoutaux}%
+ \advance\c@wmoutaux by 1\relax%
\multiply\c@wmoutaux by \pdfxupwperiod\relax
- \addtocounter{wmout}{-\value{wmoutaux}}%
+ \advance\c@wmout by -\c@wmoutaux%
\fi
\vbox to \vboxsize{\vfill
\hbox to \hboxsize{\hfill