diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/page-imp.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/page-imp.mkiv | 502 |
1 files changed, 267 insertions, 235 deletions
diff --git a/Master/texmf-dist/tex/context/base/page-imp.mkiv b/Master/texmf-dist/tex/context/base/page-imp.mkiv index b6fa75c8ba6..71c30a7e19e 100644 --- a/Master/texmf-dist/tex/context/base/page-imp.mkiv +++ b/Master/texmf-dist/tex/context/base/page-imp.mkiv @@ -5,7 +5,7 @@ %D subtitle=Pagebody Building (Imposition), %D author=Hans Hagen & Willi Egger, %D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for @@ -17,144 +17,124 @@ \unprotect -% sizing bug: -% -% \setuppapersize[A4][A4,landscape] \setuparranging[2UP] \showframe -% -% \starttext \dorecurse{10}{\input tufte \par} \stoptext - -\newif\ifclipprintbox \clipprintboxtrue % todo: conditional -%newif\ifclippagebox \clippageboxtrue - -\def\clippedprintbox#1#2% can be made more efficient, see other clipper - {\ifclipprintbox - \!!widthc \pagebackgroundoffset - \!!widtha \dimexpr\paperwidth + \!!widthc\relax - \!!heighta\dimexpr\paperheight+2\!!widthc\relax - \setbox#2\vbox to \paperheight{\vfill\box#2}% - \ht#2\paperheight - \wd#2\paperwidth - \setbox#2\vbox - {\framed - [\c!offset=\!!widthc,\c!strut=\v!no,\c!frame=\v!off] - {\box#2}}% - \setbox#2\hbox to \paperwidth - {\ifcase#1\relax - \!!widthb\zeropoint - \hskip-\!!widthc - \else - \!!widthb\!!widthc - \fi - \lower\!!widthc\hbox - {\clip - [\c!width=\!!widtha,\c!height=\!!heighta, - \c!hoffset=\!!widthb,\c!voffset=\zeropoint] - {\box#2}}}% - \wd#2\paperwidth - \ht#2\paperheight - \fi - \box#2\relax} - -\let\clippagebox \gobbleoneargument -\let\clipprintbox\gobbleoneargument - -% \setuppagenumbering[alternative=doublesided] -% \setupcolors[state=start] -% \setuppapersize[A4][A4,oversized] -% \setuplayout[location=middle,clipoffset=5mm] -% \setupbackgrounds -% [page] -% [frame=on,rulethickness=1mm, -% backgroundoffset=10mm,background=color,backgroundcolor=red] -% \starttext \dorecurse{10}{\input tufte \par} \stoptext - -\def\clippagebox % skip fast over false - {\ifdim\@@lyclipoffset>\zeropoint - \expandafter\doclippagebox - \else - \expandafter\gobbleoneargument - \fi} - -\def\doclippagebox#1% - {\!!widtha \wd#1% - \!!heighta\ht#1% - \!!deptha \dp#1% - \setbox#1\hbox - {\!!widthb \@@lyclipoffset - \advance\!!heighta\dimexpr\!!deptha+2\!!widthb\relax - \advance\!!widtha \!!widthb - \doifbothsides - {\advance\!!widtha\!!widthb \!!widthc-\!!widthb \hskip\!!widthc}% - {\!!widthc\zeropoint} - {\!!widthc-\!!widthb \hskip\!!widthc}% - \lower\!!widthb\hbox - {\clip - [\c!hoffset=\!!widthc, - \c!voffset=-\!!widthb, - \c!width=\!!widtha, - \c!height=\!!heighta]% - {\box#1}}}% - \wd#1\!!widtha - \ht#1\!!heighta - \dp#1\!!deptha} - %D \macros %D {starttextdata} %D %D This is a user macro (appending to every last shipout is not -%D really user friendly. +%D really user friendly). + +\newtoks\t_page_text_data -\newtoks\collectedtextdata +\unexpanded\def\starttextdata#1\stoptextdata + {\global\let\page_shipouts_flush_text_data\page_shipouts_flush_text_data_indeed + \globaladdtotoks\t_page_text_data{#1}} -\long\unexpanded\def\starttextdata#1\stoptextdata - {\doglobal\appendtoks#1\to\collectedtextdata} +\let\stoptextdata\relax -\def\flushtextdata - {\vsmashed{\the\collectedtextdata}% all dimensions zero - \global\collectedtextdata\emptytoks - \globallet\flushtextdata\donothing} +\def\page_shipouts_flush_text_data_indeed + {\vsmashed{\the\t_page_text_data}% + \global\t_page_text_data\emptytoks + \global\let\page_shipouts_flush_text_data\relax} -\prependtoks \flushtextdata \to \everylastshipout +\let\page_shipouts_flush_text_data\relax + +\prependtoks + \page_shipouts_flush_text_data +\to \everylastshipout -\def\installpagehandler#1#2% % a handler takes one argument: something to be boxed - {\setgvalue{\??pp:\c!method:#1}##1{#2{##1}}} % and shipped out (don't depend on the exact package) - -\installpagehandler\v!normal - {\ifarrangingpages\expandafter\actualarrange\else\expandafter\actualshipout\fi} - -\def\myshipout#1% - {\beforeshipout % voor de pagebody dus ! - \dontshowcomposition - \dontcomplain - \executeifdefined{\??pp:\c!method:\@@ppmethod}\gobbleoneargument{#1}% - \setnextrealpageno - \aftershipout} - -\newbox\postponedcontent - -\def\flushatshipout - {\dowithnextbox - {\global\setbox\postponedcontent\hbox to \zeropoint - {%\hskip-\maxdimen % niet hier, gaat mis in acrobat (clipt) - \unhbox\postponedcontent\unhbox\nextbox}% was \box - \global\ht\postponedcontent\zeropoint - \global\dp\postponedcontent\zeropoint - \global\wd\postponedcontent\zeropoint}% - \hbox} +% Problem: we need to apply the finalizers to a to be shipped out page (as +% we can have positioning involved). However, we can also add stuff in the +% imposition, like cropmarks. Fortunately we do that with metapost so +% colors etc are dealt with at that end. % \starttypen % \def\pagestoshipout{1,3,5} % \stoptypen -\newcount\shippedoutpages -\newcount\combinedpagescounter +\installcorenamespace{shipoutmethod} +\installcorenamespace{layoutarranger} +\installcorenamespace{layoutarrangeoption} + +\newcount \shippedoutpages +\newcount \combinedpagescounter -\let\pagestoshipout\empty % {1,3,6} -\newconstant\whichpagetoshipout % 0=all 1=odd 2=even +\let \pagestoshipout\empty % {1,3,6} +\newconstant \whichpagetoshipout % 0=all 1=odd 2=even -\newbox\shipoutscratchbox +\newbox \shipoutscratchbox -\def\actualshipout#1% todo: less callbacks +\setnewconstant\shipoutfinalizemethod\plusone % this will be default (we will have two finalizers) + +\unexpanded\def\installshipoutmethod#1#2% % a handler takes one argument: something to be boxed + {\setgvalue{\??shipoutmethod#1}##1{#2{##1}}} % and shipped out (don't depend on the exact package) + +\let\installpagehandler\installshipoutmethod % will go + +\unexpanded\def\invokepagehandler#1% + {\expandcheckedcsname{\??shipoutmethod}{#1}\v!normal} + +\def\page_shipouts_handle + {\csname\??shipoutmethod\ifcsname\??shipoutmethod\v_page_target_method\endcsname + \v_page_target_method + \else + \v!none + \fi\endcsname} + +\installshipoutmethod \v!normal + {\ifarrangingpages + \expandafter\page_shipouts_arrange + \else + \expandafter\page_shipouts_normal + \fi} + +\installshipoutmethod \v!none + {\page_shipouts_ignore} + +\def\page_boxes_shipout#1% or: \page_shipouts_apply + {\dontcomplain % redundant + \the\everybeforeshipout + \ifcase\shipoutfinalizemethod + \page_shipouts_handle{#1}% + \else + \setbox\shipoutscratchbox\hbox{#1}% just in case there are objects there, hook for testing (will go away) + \finalizeshipoutbox\shipoutscratchbox + \page_shipouts_handle{\box\shipoutscratchbox}% + \fi + \setnextrealpageno % so this comes before \everyaftershipout so in fact: + \the\everyaftershipout} % at this point we're already on the next realpage + +\def\page_shipouts_ignore#1% + {\begingroup + \message + {[\ifarrangingpages arranged \fi page + \ifarrangingpages\the\arrangeno\else\the\realpageno\fi\normalspace + not flushed]}% + \setbox\scratchbox\hbox{#1}% + \deadcycles\zerocount + \endgroup} + +\def\page_otr_flush_every_stuff + {\begingroup + \setbox\scratchbox\hbox + {% before the main one ! + \ifcase\realfolio \or + \the\everyfirstshipout + \global\everyfirstshipout\emptytoks + \fi + % the main one + \the\everyshipout\relax + % always last (and after the main one) + \ifnum\realpageno=\lastpage\relax + \the\everylastshipout + \global\everylastshipout\emptytoks + \fi}% + \smashbox\scratchbox + \box\scratchbox + \endgroup} + +\newdimen\d_page_shipouts_offset \d_page_shipouts_offset=-1in + +\def\page_shipouts_normal#1% {\global\advance\shippedoutpages\plusone % this is not resource safe! \ifx\pagestoshipout\empty @@ -168,50 +148,36 @@ \donetrue \fi \else % testen, aangepast / expanded nodig ? - \normalexpanded{\noexpand\doifinsetelse{\the\shippedoutpages}{\pagestoshipout}}% + \normalexpanded{\doifinsetelse{\the\shippedoutpages}{\pagestoshipout}}% \donetrue\donefalse \fi \ifdone - \begingroup - \setbox\shipoutscratchbox\hbox{#1}% just in case there are objects there, hook for testing - \finalizeshipoutbox\shipoutscratchbox - \setbox\scratchbox\hbox - {% before the main one ! - \ifcase\realfolio \or - \the\everyfirstshipout - \global\everyfirstshipout\emptytoks - \fi - % the main one - \the\everyshipout\relax - % always last (and after the main one) - \ifnum\realpageno=\lastpage\relax - \the\everylastshipout - \global\everylastshipout\emptytoks - \fi}% - \smashbox\scratchbox - \shipout\vbox + \setbox\shipoutscratchbox\hbox{#1}% + \ifcase\shipoutfinalizemethod + \finalizeshipoutbox\shipoutscratchbox + \fi + \normalshipout\vbox {\offinterlineskip - \scratchdimen-1in % to be done in luatex: zero that one - \vskip\scratchdimen - \hskip\scratchdimen - \hbox % \setbox0=\box.. is nicer - {\box\scratchbox - \ifvoid\postponedcontent\else\box\postponedcontent\fi % evt ver naar links ! + \vskip\d_page_shipouts_offset + \hskip\d_page_shipouts_offset + \hbox + {\page_otr_flush_every_stuff + \page_otr_flush_special_content \box\shipoutscratchbox}}% - \endgroup \else - \message - {[\ifarrangingpages arranged \fi page - \ifarrangingpages\the\arrangeno\else\the\realpageno\fi\normalspace - not flushed]}% - \setbox0\hbox{#1}% - \deadcycles\zerocount + \page_shipouts_ignore{#1}% \fi} -\def\actualarrange#1% - {\setbox0\hbox{#1}% - \pusharrangedpage0% - \deadcycles\zerocount} +\def\page_shipouts_arrange#1% + {% \global\advance\shippedoutpages\plusone + \begingroup + \setbox\scratchbox\hbox + {\page_otr_flush_every_stuff + \page_otr_flush_special_content + \box\shipoutscratchbox}% + \pusharrangedpage\scratchbox + \deadcycles\zerocount + \endgroup} %D We need a couple of boxes for duplex printing \unknown @@ -237,17 +203,17 @@ \newcount\arrangedpageX \arrangedpageX\plusone \newcount\arrangedpageY \arrangedpageY\plusone -\def\calculatepaperoffsets#1% - {\global\paperoffset\getvalue{\??pp#1\c!offset}% +\def\page_paper_set_offsets + {\global\paperoffset\v_page_target_offset \global\advance\paperwidth -2\dimexpr\paperoffset/\arrangedpageX\relax \global\advance\paperheight-2\dimexpr\paperoffset/\arrangedpageY\relax} \def\doinstallarrangedoption#1#2% - {\setvalue{\??pp=>#1}{#2}} + {\setvalue{\??layoutarrangeoption#1}{#2}} \def\doinstalledarrangedoption#1% - {\ifcsname\??pp=>#1\endcsname - \csname\??pp=>#1\endcsname + {\ifcsname\??layoutarrangeoption#1\endcsname + \csname\??layoutarrangeoption#1\endcsname \else \checkinstalledpagearrangement{#1}% this installs the arranger \fi} @@ -270,12 +236,12 @@ \doinstallarrangedoption\v!rotated {\gdef\arrangedrotationO {90}% \gdef\arrangedrotationE{270}% - \swapcounts\horizontalcutmarks\verticalcutmarks} + \swapcounts\c_page_marks_nx\c_page_marks_ny} \doinstallarrangedoption{90} {\gdef\arrangedrotationO {90}% \gdef\arrangedrotationE{270}% - \swapcounts\horizontalcutmarks\verticalcutmarks} + \swapcounts\c_page_marks_nx\c_page_marks_ny} \doinstallarrangedoption{180} {\gdef\arrangedrotationO{180}% @@ -284,7 +250,7 @@ \doinstallarrangedoption{270} {\gdef\arrangedrotationO{270}% \gdef\arrangedrotationE {90}% - \swapcounts\horizontalcutmarks\verticalcutmarks} + \swapcounts\c_page_marks_nx\c_page_marks_ny} \doinstallarrangedoption\s!reset {\global\arrangingpagesfalse} @@ -307,20 +273,27 @@ \global\arrangingpagesfalse \fi \setuppapersize + \ifarrangingpages + \ctxlua{job.disablesave()}% + %\disabledirective[job.save]% + \fi \fi} \def\installpagearrangement #1 % will lchange, no space - {\setgvalue{\??pp\??pp#1}} + {\setgvalue{\??layoutarranger#1}} \def\checkinstalledpagearrangement#1% can be empty: aaa,,bbb - {\executeifdefined{\??pp\??pp#1}\donothing} + {\executeifdefined{\??layoutarranger#1}\donothing} + +\let\poparrangedpages\relax +\let\pusharrangedpage\relax \def\dosetuparrangement#1#2#3#4#5#6#7#8% {\global\arrangedpageX #1% \global\arrangedpageY #2% \global\arrangedpageT #3% - \global\horizontalcutmarks #4% - \global\verticalcutmarks #5% + \global\c_page_marks_nx #4% + \global\c_page_marks_ny #5% \global\let\pusharrangedpage #6% \global\let\poparrangedpages #7% \global\let\handlearrangedpage#8} @@ -383,7 +356,7 @@ \ifcase\scratchcounter\else \advance\scratchcounter \plusone \dostepwiserecurse\scratchcounter\arrangedpageT\plusone - {\noheaderandfooterlines\ejectdummypage}% + {\noheaderandfooterlines\page_otr_insert_dummy_page}% \fi \fi} @@ -403,7 +376,7 @@ \def\pagecutmarksymbol{\the\arrangeno}} \def\outputarrangedbox#1% - {\bgroup + {\begingroup \forgetall % somehow we're back and need to redo this \gotonextarrangepage \ifnum\arrangedrotationO\arrangedrotationE>\zerocount @@ -419,15 +392,24 @@ \fi}% \fi \ifconditional\arrangedmirrorstate - \setbox#1\vbox{\domirrorbox\vbox{\box#1}}% + \page_boxes_apply_mirror{#1}% \fi \ifconditional\arrangednegatestate - \negatecolorbox{#1}% + \page_boxes_apply_negate{#1}% \fi - \finishpagebox#1% - \ifconditional\arrangedbackgroundstate\addprintbackground#1\fi - \actualshipout{\box#1}% - \egroup} + \page_marks_add_more #1% + \page_boxes_apply_center #1% + \page_boxes_apply_mirror_print #1% + \page_boxes_apply_orientate_print#1% + \page_boxes_apply_offset #1% + \page_boxes_apply_negate_print #1% + % + \ifconditional\arrangedbackgroundstate + \page_backgrounds_add_to_print#1% + \fi + % + \page_shipouts_normal{\box#1}% + \endgroup} %D The format file can be 16K smaller when we postpone the %D real arrangments. Some day ... @@ -552,15 +534,15 @@ \fi} \def\handlearrangedpageSIDE - {\global\wd\arrangedpageA\paperwidth - \global\wd\arrangedpageB\paperwidth + {\wd\arrangedpageA\paperwidth + \wd\arrangedpageB\paperwidth \global\setbox\arrangedpageA\hbox {\box\arrangedpageA\box\arrangedpageB}% - \global\ht\arrangedpageA\paperheight} + \ht\arrangedpageA\paperheight} \def\handlearrangedpageTOP - {\global\ht\arrangedpageA\paperheight - \global\ht\arrangedpageB\paperheight + {\ht\arrangedpageA\paperheight + \ht\arrangedpageB\paperheight \global\setbox\arrangedpageA\vbox {\offinterlineskip\vskip\paperheight \box\arrangedpageA\box\arrangedpageB}% @@ -580,22 +562,22 @@ {\splitoffarrangedpagesTWO \ifconditional\arrangedswapstate \global\setbox\arrangedpageA\hbox - {\clippedprintbox\zerocount\arrangedpageA - \clippedprintbox\plusone \arrangedpageB}% + {\page_boxes_apply_clip_print_left \arrangedpageA\box\arrangedpageA + \page_boxes_apply_clip_print_right\arrangedpageB\box\arrangedpageB}% \setfalse\arrangedswapstate \else \global\setbox\arrangedpageA\hbox - {\clippedprintbox\zerocount\arrangedpageB - \clippedprintbox\plusone \arrangedpageA}% + {\page_boxes_apply_clip_print_left \arrangedpageB\box\arrangedpageB + \page_boxes_apply_clip_print_right\arrangedpageA\box\arrangedpageA}% \settrue\arrangedswapstate \fi - \global\ht\arrangedpageA\paperheight + \ht\arrangedpageA\paperheight \global\setbox\arrangedpageB\box\scratchbox} \def\handlearrangedpageTWODOWN {\splitoffarrangedpagesTWO - \global\ht\arrangedpageA\paperheight - \global\ht\arrangedpageB\paperheight + \ht\arrangedpageA\paperheight + \ht\arrangedpageB\paperheight \ifconditional\arrangedswapstate \global\setbox\arrangedpageA\vbox {\offinterlineskip\vskip\paperheight @@ -1117,22 +1099,30 @@ {\advancearrangedpageN \global\advance\arrangedpageM\plusone \reportarrangedpage\arrangedpageN - \global\setbox\arrangedpageB\hbox \ifdim\@@ppwidth>\zeropoint to \@@ppwidth \fi + \global\setbox\arrangedpageB\hbox \ifdim\v_page_target_width>\zeropoint to \v_page_target_width \fi {\ifvoid\arrangedpageB\else \unhbox\arrangedpageB - \ifdim\@@ppdx>\zeropoint \else \hss\fi - \hskip\@@ppdx - \ifdim\@@ppdx>\zeropoint \else \hss\fi + \ifdim\v_page_target_dx>\zeropoint + \hskip\v_page_target_dx + \else + \hss + \hskip\v_page_target_dx + \hss + \fi \fi \box#1}% \ifnum\arrangedpageM<\arrangedpageX\else - \global\setbox\arrangedpageA\vbox \ifdim\@@ppheight>\zeropoint to \@@ppheight \fi + \global\setbox\arrangedpageA\vbox \ifdim\v_page_target_height>\zeropoint to \v_page_target_height \fi {\offinterlineskip \ifvoid\arrangedpageA\else \unvbox\arrangedpageA - \ifdim\@@ppdy>\zeropoint \else \vss\fi - \vskip\@@ppdy - \ifdim\@@ppdy>\zeropoint \else \vss\fi + \ifdim\v_page_target_dy>\zeropoint + \vskip\v_page_target_dy + \else + \vss + \vskip\v_page_target_dy + \vss + \fi \fi \box\arrangedpageB}% \global\arrangedpageM\zerocount @@ -1151,19 +1141,42 @@ \fi} \installpagearrangement XY - {\dosetuparrangement\@@ppnx\@@ppny\@@ppxy\!!zerocount\!!zerocount + {\dosetuparrangement + \v_page_target_nx + \v_page_target_ny + \v_page_target_xy + \zerocount + \zerocount \pusharrangedpageXY\poparrangedpagesXY\relax} %D A crazy definition, don't guess who pushed me for the landscape option. +\def\page_imposition_xy_height + {\dimexpr + \dimexpr + \v_page_target_height + -\numexpr\v_page_target_ny-1\relax\v_page_target_dy + \relax + /\v_page_target_ny + \relax} + +\def\page_imposition_xy_width + {\dimexpr + \dimexpr + \v_page_target_width + -\numexpr\v_page_target_nx-1\relax\v_page_target_dx + \relax + /\v_page_target_nx + \relax} + \definepapersize [XY] - [\c!height=\dimexpr\dimexpr\@@ppheight-\numexpr\@@ppny-1\relax\dimexpr\@@ppdy\relax\relax/\@@ppny\relax, - \c!width =\dimexpr\dimexpr\@@ppwidth -\numexpr\@@ppnx-1\relax\dimexpr\@@ppdx\relax\relax/\@@ppnx\relax] + [\c!height=\page_imposition_xy_height, + \c!width =\page_imposition_xy_width] \setuppaper - [\c!width =\dimexpr\printpaperwidth -2\dimexpr\@@ppbackspace\relax\relax, - \c!height=\dimexpr\printpaperheight-2\dimexpr\@@pptopspace \relax\relax] + [\c!width =\dimexpr\printpaperwidth -2\v_page_target_backspace\relax, + \c!height=\dimexpr\printpaperheight-2\v_page_target_topspace \relax] % \definepageshift[test][horizontal][10pt,20pt,30pt,40pt,50pt] % \definepageshift[test][vertical] [10pt,20pt,30pt,40pt,50pt] @@ -1180,53 +1193,73 @@ % #1=name #2=horizontal|vertical #3=shiftlist +% this will move to lua + +\installcorenamespace {pageshift} + \unexpanded\def\definepageshift - {\dotripleargument\dodefinepageshift} + {\dotripleargument\page_boxes_define_shift} -\def\dodefinepageshift[#1][#2][#3]% - {\setvalue{\??pt#2:#1}{#3}} +\def\page_boxes_define_shift[#1][#2][#3]% + {\setvalue{\??pageshift#2:#1}{#3}} -\letempty\hpageshifts \newcount\nofhpageshifts -\letempty\vpageshifts \newcount\nofvpageshifts +\let\page_boxes_h_shifts\empty +\let\page_boxes_v_shifts\empty -\def\dogetpageshift#1#2#3% #1=\dimenx #2=\xpageshifts #3=\nofxpageshifts - {\ifx#2\empty % we could do this in lua - #1\zeropoint - \else +\newcount\c_page_boxes_h_shifts +\newcount\c_page_boxes_v_shifts + +\newdimen\d_page_boxes_h_shifts +\newdimen\d_page_boxes_v_shifts + +\let\page_boxes_apply_shift_print\gobbleoneargument +\let\page_boxes_apply_shift_paper\gobbleoneargument + +\def\page_boxes_filter_shift#1#2#3% #1=\dimenx #2=\xpageshifts #3=\nofxpageshifts + {#1\zeropoint + \ifx#2\empty \else \global\advance#3\plusone \getfromcommacommand[#2][#3]% \ifx\commalistelement\empty \global#3\plusone % we cycle \getfromcommacommand[#2][#3]% \fi - \ifx\commalistelement\empty - #1\zeropoint - \else - #1=\commalistelement - \donetrue + \ifx\commalistelement\empty \else + #1\commalistelement\relax % the relax is really needed as there is an \if later on \fi \fi} -\def\shiftpagebox#1% - {\donefalse - \dogetpageshift{\dimen0}\hpageshifts\nofhpageshifts - \dogetpageshift{\dimen2}\vpageshifts\nofvpageshifts - \ifdone % see also layout offsets, maybe \movebox - \edef\next{\wd#1\the\wd#1\ht#1\the\ht#1\dp#1\the\dp#1}% - \setbox#1\vbox - {\offinterlineskip\vskip\dimen2\hskip\dimen0\box#1}% - \next +\def\page_boxes_apply_shift#1% + {\page_boxes_filter_shift\d_page_boxes_h_shifts\page_boxes_h_shifts\c_page_boxes_h_shifts + \page_boxes_filter_shift\d_page_boxes_v_shifts\page_boxes_v_shifts\c_page_boxes_v_shifts + \ifzeropt\d_page_boxes_h_shifts + \ifzeropt\d_page_boxes_v_shifts + % nothing to shift + \else + \page_boxes_apply_shift_indeed#1% + \fi + \else + \page_boxes_apply_shift_indeed#1% \fi} +\def\page_boxes_apply_shift_indeed#1% + {\edef\next{\wd#1\the\wd#1\ht#1\the\ht#1\dp#1\the\dp#1}% + \setbox#1\vbox + {\offinterlineskip + \vskip\d_page_boxes_v_shifts + \hskip\d_page_boxes_h_shifts + \box#1}% + \next} + \unexpanded\def\setuppageshift - {\dotripleempty\dosetuppageshift} - -\def\dosetuppageshift[#1][#2][#3]% page|paper horizontal vertical - {\ifthirdargument % paper=arrange - \edef\hpageshifts{\ifcsname\??pt\v!horizontal:#2\endcsname\csname\??pt\v!horizontal:#2\endcsname\fi}% - \edef\vpageshifts{\ifcsname\??pt\v!vertical :#3\endcsname\csname\??pt\v!vertical :#3\endcsname\fi}% - \doifelse{#1}\v!page {\let\shiftprintpagebox\shiftpagebox}{\let\shiftprintpagebox\gobbleoneargument}% - \doifelse{#1}\v!paper{\let\shiftpaperpagebox\shiftpagebox}{\let\shiftpaperpagebox\gobbleoneargument}% + {\dotripleempty\page_boxes_setup_shift} + +\def\page_boxes_setup_shift[#1][#2][#3]% page|paper horizontal vertical + {\ifthirdargument % paper=arrange + \edef\page_boxes_h_shifts{\ifcsname\??pageshift\v!horizontal:#2\endcsname\csname\??pageshift\v!horizontal:#2\endcsname\fi}% + \edef\page_boxes_v_shifts{\ifcsname\??pageshift\v!vertical :#3\endcsname\csname\??pageshift\v!vertical :#3\endcsname\fi}% + \doifelse{#1}\v!page {\let\page_boxes_apply_shift_print\page_boxes_apply_shift}{\let\page_boxes_apply_shift_print\gobbleoneargument}% + \doifelse{#1}\v!paper{\let\page_boxes_apply_shift_paper\page_boxes_apply_shift}{\let\page_boxes_apply_shift_paper\gobbleoneargument}% \else\ifsecondargument \doifinsetelse{#1}{\v!page,\v!paper} {\setuppageshift[#1][#2][#2]} @@ -1235,5 +1268,4 @@ \setuppageshift[\v!page][#1][#1]% \fi\fi\fi} - \protect \endinput |