page-imp.mkiv /size: 49 Kb    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=page-imp, % was: core-pag,
3
%D version=1998.01.15,
4
%D title=\CONTEXT\ Page Macros,
5
%D subtitle=Pagebody Building (Imposition),
6
%D author=Hans Hagen & Willi Egger,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
% much of this can more to run time loading !
15 16
\writestatus
{
loading
}
{
ConTeXt
Page
Macros
/
Pagebody
Building
}
17 18
\unprotect
19 20
%D \macros
21
%D {starttextdata}
22
%D
23
%D This is a user macro (appending to every last shipout is not
24
%D really user friendly).
25 26
\newtoks
\t_page_text_data
27 28
\unexpanded
\def
\starttextdata
#
1
\stoptextdata
29
{
\glet
\page_shipouts_flush_text_data
\page_shipouts_flush_text_data_indeed
30
\globaladdtotoks
\t_page_text_data
{
#
1
}
}
31 32
\let
\stoptextdata
\relax
33 34
\def
\page_shipouts_flush_text_data_indeed
35
{
\vsmashed
{
\the
\t_page_text_data
}
%
36
\global
\t_page_text_data
\emptytoks
37
\glet
\page_shipouts_flush_text_data
\relax
}
38 39
\let
\page_shipouts_flush_text_data
\relax
40 41
\prependtoks
42
\page_shipouts_flush_text_data
43
\to
\everylastshipout
44 45
% Problem: we need to apply the finalizers to a to be shipped out page (as
46
% we can have positioning involved). However, we can also add stuff in the
47
% imposition, like cropmarks. Fortunately we do that with metapost so
48
% colors etc are dealt with at that end.
49 50
% \starttypen
51
% \def\pagestoshipout{1,3,5}
52
% \stoptypen
53 54
\installcorenamespace
{
shipoutmethod
}
55
\installcorenamespace
{
layoutarranger
}
56
\installcorenamespace
{
layoutarrangeoption
}
57 58
\newcount
\shippedoutpages
59
\newcount
\combinedpagescounter
60 61
\let
\pagestoshipout
\empty
% {1,3,6}
62
\newconstant
\whichpagetoshipout
% 0=all 1=odd 2=even
63 64
\newbox
\shipoutscratchbox
65 66
\setnewconstant
\shipoutfinalizemethod
\plusone
67 68
\unexpanded
\def
\shipoutrange
#
1
#
2
%
69
{
\begingroup
70
\scratchtoks
\emptytoks
71
\dostepwiserecurse
{
#
1
}
{
\numexpr
#
2
-
\plusone
\relax
}
\plusone
{
\etoksapp
\scratchtoks
{
#
#
1
,
}
}
%
72
\xdef
\pagestoshipout
{
\the
\scratchtoks
,
\number
#
2
}
%
73
\doglobal
\appendtoks
74
\ifnum
\realpageno
>
\numexpr
#
2
+
\plusone
\relax
75
\global
\everypar
{
\normalend
}
%
76
\fi
77
\to
\everyaftershipout
78
\endgroup
}
79 80
\unexpanded
\def
\installshipoutmethod
#
1
#
2
% % a handler takes one argument: something to be boxed
81
{
\setgvalue
{
\??shipoutmethod
#
1
}
#
#
1
{
#
2
{
#
#
1
}
}
}
% and shipped out (don't depend on the exact package)
82 83
\let
\installpagehandler
\installshipoutmethod
% will go
84 85
\unexpanded
\def
\invokepagehandler
#
1
%
86
{
\expandnamespacevalue
\??shipoutmethod
{
#
1
}
\v!normal
}
87 88
\def
\page_shipouts_handle
89
{
\ifcsname
\??shipoutmethod
\v_page_target_method
\endcsname
90
\expandafter
\lastnamedcs
91
\else
92
\expandafter
\page_shipouts_ignore
93
\fi
}
94 95
\installshipoutmethod
\v!normal
96
{
\ifarrangingpages
97
\expandafter
\page_shipouts_arrange
98
\else
99
\expandafter
\page_shipouts_normal
100
\fi
}
101 102
\installshipoutmethod
\v!none
103
{
\page_shipouts_ignore
}
104 105
% \setuppaper[method=rotate,rotation=15] \showframe
106
% \starttext \dorecurse{10}{\input knuth\endgraf} \stoptext
107 108
\installshipoutmethod
\v!rotate
109
{
\page_shipouts_rotate
}
110 111
\protected
\def
\page_shipouts_rotate
#
1
%
112
{
\invokepagehandler
\v!normal
{
\rotate
[
\c!rotation
=
\rootlayouttargetparameter
\c!rotation
]
{
#
1
}
}
}
113 114
% extension mechanism
115 116
\newcount
\c_page_boxes_flush_n
% set at the lua end
117 118
\let
\page_boxes_flush_before
\relax
119
\let
\page_boxes_flush_after
\relax
120 121
% used here:
122 123
\def
\page_boxes_shipout
#
1
% or: \page_shipouts_apply
124
{
\dontcomplain
% redundant
125
\ifcase
\c_page_boxes_flush_n
\else
126
\page_boxes_flush_before
127
\fi
128
\the
\everybeforeshipout
129
\ifcase
\shipoutfinalizemethod
% not nice ... needs thinking
130
\page_shipouts_handle
{
#
1
}
%
131
\else
132
\setbox
\shipoutscratchbox
\hpack
133
{
#
1
}
% just in case there are objects there, hook for testing (will go away)
134
\page_shipouts_handle
135
{
\finalizeshipoutbox
\shipoutscratchbox
136
\box
\shipoutscratchbox
}
%
137
\fi
138
\setnextrealpageno
% so this comes before \everyaftershipout so in fact:
139
\the
\everyaftershipout
% at this point we're already on the next realpage
140
\ifcase
\c_page_boxes_flush_n
\else
141
\page_boxes_flush_after
142
\fi
}
143 144
\def
\page_shipouts_ignore
#
1
%
145
{
\begingroup
146
\writestatus
\m!system
147
{
\ifarrangingpages
arranged
\fi
page
148
\ifarrangingpages
\the
\arrangeno
\else
\the
\realpageno
\fi
\normalspace
149
not
flushed
}
%
150
% \setbox\scratchbox\hpack
151
% {#1}% no finalize
152
\deadcycles
\zerocount
153
\endgroup
}
154 155
\def
\page_otr_flush_every_stuff
156
{
\begingroup
157
\setbox
\scratchbox
\hpack
158
{
% before the main one !
159
\ifcase
\realfolio
\or
160
\the
\everyfirstshipout
161
\global
\everyfirstshipout
\emptytoks
162
\fi
163
% the main one
164
\the
\everyshipout
\relax
165
% always last (and after the main one)
166
\ifnum
\realpageno
=
\lastpage
\relax
167
\the
\everylastshipout
168
\global
\everylastshipout
\emptytoks
169
\fi
}
%
170
\smashbox
\scratchbox
171
\box
\scratchbox
172
\endgroup
}
173 174
%D Also in normal \MKIV\ we nos use the indirect way so that we benefit from timing and
175
%D tracing.
176 177
% \def\page_shipout_box#1{\normalshipout\box#1\relax} % takes a number
178 179
\def
\page_shipout_show_box
{
\scratchcounter
}
180 181
\unexpanded
\def
\page_shipout_box
#
1
%
182
{
\ifcase
\tracingoutput
\else
183
\page_shipout_show_box
#
1
\relax
184
\fi
185
\clf_shipoutpage
#
1
\relax
186
\global
\setbox
#
1
\emptybox
187
\global
\deadcycles
\zerocount
}
188 189
\def
\page_shipouts_normal
#
1
%
190
{
\global
\advance
\shippedoutpages
\plusone
191
% this is not resource safe!
192
\ifx
\pagestoshipout
\empty
193
\ifcase
\whichpagetoshipout
\relax
194
\donetrue
195
\or
% 1
196
\ifodd
\shippedoutpages
\relax
\donetrue
\else
\donefalse
\fi
197
\or
% 2
198
\ifodd
\shippedoutpages
\relax
\donefalse
\else
\donetrue
\fi
199
\else
200
\donetrue
201
\fi
202
\else
% testen, aangepast / expanded nodig ?
203
\normalexpanded
{
\doifelseinset
{
\the
\shippedoutpages
}
{
\pagestoshipout
}
}
\donetrue
\donefalse
204
\fi
205
\ifdone
206
\setbox
\shipoutscratchbox
\hpack
207
{
#
1
}
% finalizes
208
\ifcase
\shipoutfinalizemethod
209
\finalizeshipoutbox
\shipoutscratchbox
210
\fi
211
\setbox
\shipoutscratchbox
\vpack
212
{
\scratchdimen
\clf_shipoutoffset
\relax
213
\ifdim
\scratchdimen
=
\zeropoint
\else
214
\offinterlineskip
215
\vkern
\scratchdimen
216
\hkern
\scratchdimen
217
\fi
218
\hpack
219
{
\page_otr_flush_every_stuff
220
\page_otr_flush_special_content
221
\box
\shipoutscratchbox
}
}
%
222
\page_shipout_box
\shipoutscratchbox
% takes a box number!
223
\else
224
\page_shipouts_ignore
{
#
1
}
%
225
\fi
}
226 227
\newconditional
\c_page_shipouts_use_objects
\settrue
\c_page_shipouts_use_objects
228 229
\installcorenamespace
{
arrangedpage
}
230 231
\def
\page_shipouts_arrange
#
1
%
232
{
\begingroup
233
\setbox
\shipoutscratchbox
\hpack
234
{
#
1
}
% finalizes
235
\setbox
\shipoutscratchbox
\hpack
236
{
\page_otr_flush_every_stuff
237
\page_otr_flush_special_content
238
\box
\shipoutscratchbox
}
%
239
%
240
\ifconditional
\c_page_shipouts_use_objects
241
\setobject
\??arrangedpage
{
\the
\realpageno
}
\hpack
{
\box
\shipoutscratchbox
}
%
242
\setbox
\shipoutscratchbox
\hpack
{
\getobject
\??arrangedpage
{
\the
\realpageno
}
}
%
243
\fi
244
%
245
\pusharrangedpage
\shipoutscratchbox
246
\deadcycles
\zerocount
247
\endgroup
}
248 249
%D We need a couple of boxes for duplex printing \unknown
250 251
\newbox
\arrangedpageA
\newbox
\arrangedpageB
252
\newbox
\arrangedpageC
\newbox
\arrangedpageD
253
\newbox
\arrangedpageE
\newbox
\arrangedpageF
254
\newbox
\arrangedpageG
\newbox
\arrangedpageH
255 256
\newconditional
\arrangedswapstate
257
\newconditional
\arrangednegatestate
258
\newconditional
\arrangedmirrorstate
259
\newconditional
\arrangeddoublestate
260
\newconditional
\arrangingdisabledstate
261
\newconditional
\arrangedbackgroundstate
262 263
\def
\arrangedrotationO
{
0
}
264
\def
\arrangedrotationE
{
0
}
265 266
\newcount
\arrangedpageN
267
\newcount
\arrangedpageM
268 269
\newcount
\arrangedpageT
\arrangedpageT
\plusone
270
\newcount
\arrangedpageX
\arrangedpageX
\plusone
271
\newcount
\arrangedpageY
\arrangedpageY
\plusone
272 273
\def
\page_paper_set_offsets
274
{
\global
\paperoffset
\v_page_target_offset
275
\global
\advance
\paperwidth
-
2
\dimexpr
\paperoffset
/
\arrangedpageX
\relax
276
\global
\advance
\paperheight
-
2
\dimexpr
\paperoffset
/
\arrangedpageY
\relax
}
277 278
\def
\doinstallarrangedoption
#
1
#
2
%
279
{
\setvalue
{
\??layoutarrangeoption
#
1
}
{
#
2
}
}
280 281
\def
\doinstalledarrangedoption
#
1
%
282
{
\ifcsname
\??layoutarrangeoption
#
1
\endcsname
283
\csname
\??layoutarrangeoption
#
1
\endcsname
284
\else
285
\checkinstalledpagearrangement
{
#
1
}
% this installs the arranger
286
\fi
}
287 288
\doinstallarrangedoption
\empty
289
{
}
% no default and check if empty, we can have ,,,
290 291
\doinstallarrangedoption
\v!disable
292
{
\global
\settrue
\arrangingdisabledstate
}
293 294
\doinstallarrangedoption
\v!mirrored
295
{
\global
\settrue
\arrangedmirrorstate
}
296 297
\doinstallarrangedoption
\v!doublesided
298
{
\global
\settrue
\arrangeddoublestate
}
299 300
\doinstallarrangedoption
\v!negative
301
{
\global
\settrue
\arrangednegatestate
}
302 303
\doinstallarrangedoption
\v!rotated
304
{
\gdef
\arrangedrotationO
{
9
0
}
%
305
\gdef
\arrangedrotationE
{
2
7
0
}
%
306
\swapcounts
\c_page_marks_nx
\c_page_marks_ny
}
307 308
\doinstallarrangedoption
{
9
0
}
309
{
\gdef
\arrangedrotationO
{
9
0
}
%
310
\gdef
\arrangedrotationE
{
2
7
0
}
%
311
\swapcounts
\c_page_marks_nx
\c_page_marks_ny
}
312 313
\doinstallarrangedoption
{
1
8
0
}
314
{
\gdef
\arrangedrotationO
{
1
8
0
}
%
315
\gdef
\arrangedrotationE
{
0
}
}
316 317
\doinstallarrangedoption
{
2
7
0
}
318
{
\gdef
\arrangedrotationO
{
2
7
0
}
%
319
\gdef
\arrangedrotationE
{
9
0
}
%
320
\swapcounts
\c_page_marks_nx
\c_page_marks_ny
}
321 322
\doinstallarrangedoption
\s!reset
323
{
\global
\arrangingpagesfalse
}
324 325
\doinstallarrangedoption
\v!background
326
{
\global
\settrue
\arrangedbackgroundstate
}
327 328
\unexpanded
\def
\setuparranging
[
#
1
]
%
329
{
\ifconditional
\arrangingdisabledstate
\else
330
%global\setfalse\arrangingdisabledstate
331
\global
\arrangingpagestrue
% will be conditional
332
\global
\setfalse
\arrangednegatestate
333
\global
\setfalse
\arrangedmirrorstate
334
\global
\setfalse
\arrangeddoublestate
335
\global
\setfalse
\arrangedswapstate
336
\gdef
\arrangedrotationO
{
0
}
%
337
\gdef
\arrangedrotationE
{
1
8
0
}
%
338
\processcommalist
[
#
1
]
\doinstalledarrangedoption
339
\ifdefined
\handlearrangedpage
\else
340
\global
\arrangingpagesfalse
341
\fi
342
\setuppapersize
343
\ifarrangingpages
344
\ifconditional
\c_page_shipouts_use_objects
\else
345
\clf_disablejobsave
346
\clf_synctexdisable
347
%\disabledirective[job.save]%
348
\fi
349
\fi
350
\fi
}
351 352
\def
\installpagearrangement
#
1
% will change, no space
353
{
\setgvalue
{
\??layoutarranger
#
1
}
}
354 355
\def
\checkinstalledpagearrangement
#
1
% can be empty: aaa,,bbb
356
{
\begincsname
\??layoutarranger
#
1
\endcsname
}
357 358
\let
\poparrangedpages
\relax
359
\let
\pusharrangedpage
\relax
360 361
\def
\dosetuparrangement
#
1
#
2
#
3
#
4
#
5
#
6
#
7
#
8
%
362
{
\global
\arrangedpageX
#
1
%
363
\global
\arrangedpageY
#
2
%
364
\global
\arrangedpageT
#
3
%
365
\global
\c_page_marks_nx
#
4
%
366
\global
\c_page_marks_ny
#
5
%
367
\glet
\pusharrangedpage
#
6
%
368
\glet
\poparrangedpages
#
7
%
369
\glet
\handlearrangedpage
#
8
}
370 371
\installpagearrangement
{
\v!normal
}
372
{
\global
\arrangingpagesfalse
}
373 374
%D (WS:) Watch out with 2UP and A4/A5:
375
%D
376
%D \definepapersize [A4] [width=210mm,height=297mm]
377
%D \definepapersize [A5] [width=148mm,height=210mm]
378
%D
379
%D 297 mm - 2 * 148 mm = 1 mm
380
%D
381
%D This is only visible when we have a full background.
382 383
\installpagearrangement
2
*
1
6
384
{
\dosetuparrangement
{
4
}
{
4
}
{
1
6
}
{
5
}
{
5
}
%
385
\pusharrangedpageTHIRTYTWO
\poparrangedpagesAB
\relax
}
386 387
\installpagearrangement
2
*
8
388
{
\dosetuparrangement
{
4
}
{
2
}
{
8
}
{
5
}
{
3
}
%
389
\pusharrangedpageSIXTEEN
\poparrangedpagesAB
\relax
}
390 391
\installpagearrangement
2
*
4
392
{
\dosetuparrangement
{
2
}
{
2
}
{
4
}
{
3
}
{
3
}
%
393
\pusharrangedpageEIGHT
\poparrangedpagesAB
\relax
}
394 395
\installpagearrangement
2
*
2
396
{
\dosetuparrangement
{
2
}
{
1
}
{
2
}
{
3
}
{
2
}
%
397
\pusharrangedpageFOURA
\poparrangedpagesAB
\relax
}
398 399
\installpagearrangement
2
*
*
2
400
{
\dosetuparrangement
{
2
}
{
1
}
{
2
}
{
3
}
{
2
}
%
401
\pusharrangedpageFOURB
\poparrangedpagesAB
\relax
}
402 403
\installpagearrangement
2
SIDE
404
{
\dosetuparrangement
{
2
}
{
1
}
{
2
}
{
3
}
{
2
}
%
405
\pusharrangedpageSIDETOP
\poparrangedpagesTWO
\handlearrangedpageSIDE
}
406 407
\installpagearrangement
2
TOP
408
{
\dosetuparrangement
{
1
}
{
2
}
{
2
}
{
2
}
{
3
}
%
409
\pusharrangedpageSIDETOP
\poparrangedpagesTWO
\handlearrangedpageTOP
}
410 411
\installpagearrangement
2
UP
412
{
\dosetuparrangement
{
2
}
{
1
}
{
4
}
{
3
}
{
2
}
%
413
\pusharrangedpageTWO
\poparrangedpagesTWO
\handlearrangedpageTWOUP
}
414 415
\installpagearrangement
2
DOWN
416
{
\dosetuparrangement
{
1
}
{
2
}
{
4
}
{
2
}
{
3
}
%
417
\pusharrangedpageTWO
\poparrangedpagesTWO
\handlearrangedpageTWODOWN
}
418 419
\installpagearrangement
2
*
4
*
2
% one defined by Willy Egger:
420
{
\dosetuparrangement
{
2
}
{
2
}
{
4
}
{
3
}
{
3
}
%
421
\pusharrangedpageSIXTEENTWO
\poparrangedpagesAtoD
\relax
}
422 423
\installpagearrangement
2
*
2
*
4
% another one of Willy Egger
424
{
\dosetuparrangement
{
2
}
{
1
}
{
8
}
{
3
}
{
2
}
%
425
\pusharrangedpageSIXTEENFOUR
\poparrangedpagesAtoH
\relax
}
426 427
\installpagearrangement
2
TOPSIDE
428
{
\dosetuparrangement
{
1
}
{
2
}
{
4
}
{
2
}
{
3
}
%
429
\pusharrangedpageTWOTOPSIDE
\poparrangedpagesTWOTOPSIDE
\handlearrangedpageTOP
}
430 431
\def
\filluparrangedpages
% beware: \realpageno is 1 ahead
432
{
\ifarrangingpages
433
\scratchcounter
\numexpr
\realpageno
-
\plusone
\relax
434
\dosetmodulo
\scratchcounter
\arrangedpageT
\scratchcounter
435
\ifcase
\scratchcounter
\else
436
\advance
\scratchcounter
\plusone
437
\dostepwiserecurse
\scratchcounter
\arrangedpageT
\plusone
438
{
\noheaderandfooterlines
\page_otr_insert_dummy_page
}
%
439
\fi
440
\fi
}
441 442
\def
\handlearrangedpageXandY
#
1
#
2
#
3
#
4
#
5
%
443
{
\global
\setbox
#
5
\hpack
to
\arrangedpageX
\paperwidth
444
{
\setbox
\scratchbox
\vpack
to
\arrangedpageY
\paperheight
445
{
\offinterlineskip
446
\vskip
#
4
\paperheight
447
\hskip
#
3
\paperwidth
448
\dorotatebox
{
\ifcase
#
2
0
\else
1
8
0
\fi
}
\hpack
{
\box
#
1
}
%
449
\vfill
}
%
450
\wd
\scratchbox
\zeropoint
451
\box
\scratchbox
\box
#
5
\hss
}
}
452 453
\def
\gotonextarrangepage
454
{
\global
\advance
\arrangeno
\plusone
455
\def
\pagecutmarksymbol
{
\the
\arrangeno
}
}
456 457
\def
\outputarrangedbox
#
1
%
458
{
\begingroup
459
\forgetall
% somehow we're back and need to redo this
460
\dontcomplain
461
\gotonextarrangepage
462
\ifnum
\arrangedrotationO
\arrangedrotationE
>
\zerocount
463
\setbox
#
1
\vpack
464
{
\ifconditional
\arrangeddoublestate
465
\ifodd
\arrangeno
466
\dorotatebox
\arrangedrotationO
\hpack
{
\box
#
1
}
%
467
\else
468
\dorotatebox
\arrangedrotationE
\hpack
{
\box
#
1
}
%
469
\fi
470
\else
471
\dorotatebox
\arrangedrotationO
\hpack
{
\box
#
1
}
%
472
\fi
}
%
473
\fi
474
\ifconditional
\arrangedmirrorstate
475
\page_boxes_apply_mirror
{
#
1
}
%
476
\fi
477
\ifconditional
\arrangednegatestate
478
\page_boxes_apply_negate
{
#
1
}
%
479
\fi
480
\page_marks_add_more
#
1
%
481
\page_boxes_apply_center
#
1
%
482
\page_boxes_apply_mirror_print
#
1
%
483
\page_boxes_apply_orientate_print
#
1
%
484
\page_boxes_apply_offset
#
1
%
485
\page_boxes_apply_negate_print
#
1
%
486
%
487
\ifconditional
\arrangedbackgroundstate
488
\page_backgrounds_add_to_print
#
1
%
489
\fi
490
%
491
\page_shipouts_normal
{
\box
#
1
}
%
492
\endgroup
}
493 494
%D The format file can be 16K smaller when we postpone the
495
%D real arrangments. Some day ...
496 497
\def
\reportarrangedpage
#
1
%
498
{
\showmessage
\m!system
{
2
3
}
{
\the
\realpageno
.
\the
\pageno
\ifnum
\subpageno
>
0
.
\the
\subpageno
\fi
,
\number
#
1
}
}
499 500
\def
\advancearrangedpageN
501
{
\global
\advance
\arrangedpageN
\plusone
}
502 503
% TOP
504 505
% 32/16/8/4/SIDE
506 507
\def
\poparrangedpagesAB
508
{
\ifnum
\arrangedpageN
>
\zerocount
509
\paperwidth
\arrangedpageX
\paperwidth
510
\paperheight
\arrangedpageY
\paperheight
511
\outputarrangedbox
\arrangedpageA
512
\outputarrangedbox
\arrangedpageB
513
\global
\arrangedpageN
\zerocount
514
\fi
}
515 516
\def
\pusharrangedpageTHIRTYTWO
#
1
% taco's challenge
517
{
\advancearrangedpageN
518
\reportarrangedpage
\arrangedpageN
519
\ifcase
\arrangedpageN
520
\or
\handlearrangedpageXandY
{
#
1
}
0
3
3
\arrangedpageA
% 1
521
\or
\handlearrangedpageXandY
{
#
1
}
0
0
3
\arrangedpageB
% 2
522
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageB
% 3
523
\or
\handlearrangedpageXandY
{
#
1
}
1
3
0
\arrangedpageA
% 4
524
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageA
% 5
525
\or
\handlearrangedpageXandY
{
#
1
}
1
3
0
\arrangedpageB
% 6
526
\or
\handlearrangedpageXandY
{
#
1
}
0
3
3
\arrangedpageB
% 7
527
\or
\handlearrangedpageXandY
{
#
1
}
0
0
3
\arrangedpageA
% 8
528
\or
\handlearrangedpageXandY
{
#
1
}
1
0
2
\arrangedpageA
% 9
529
\or
\handlearrangedpageXandY
{
#
1
}
1
3
2
\arrangedpageB
% 10
530
\or
\handlearrangedpageXandY
{
#
1
}
0
3
1
\arrangedpageB
% 11
531
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageA
% 12
532
\or
\handlearrangedpageXandY
{
#
1
}
0
3
1
\arrangedpageA
% 13
533
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageB
% 14
534
\or
\handlearrangedpageXandY
{
#
1
}
1
0
2
\arrangedpageB
% 15
535
\or
\handlearrangedpageXandY
{
#
1
}
1
3
2
\arrangedpageA
% 16
536
\or
\handlearrangedpageXandY
{
#
1
}
1
2
2
\arrangedpageA
% 17
537
\or
\handlearrangedpageXandY
{
#
1
}
1
1
2
\arrangedpageB
% 18
538
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageB
% 19
539
\or
\handlearrangedpageXandY
{
#
1
}
0
2
1
\arrangedpageA
% 20
540
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageA
% 21
541
\or
\handlearrangedpageXandY
{
#
1
}
0
2
1
\arrangedpageB
% 22
542
\or
\handlearrangedpageXandY
{
#
1
}
1
2
2
\arrangedpageB
% 23
543
\or
\handlearrangedpageXandY
{
#
1
}
1
1
2
\arrangedpageA
% 24
544
\or
\handlearrangedpageXandY
{
#
1
}
0
1
3
\arrangedpageA
% 25
545
\or
\handlearrangedpageXandY
{
#
1
}
0
2
3
\arrangedpageB
% 26
546
\or
\handlearrangedpageXandY
{
#
1
}
1
2
0
\arrangedpageB
% 27
547
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageA
% 28
548
\or
\handlearrangedpageXandY
{
#
1
}
1
2
0
\arrangedpageA
% 29
549
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageB
% 30
550
\or
\handlearrangedpageXandY
{
#
1
}
0
1
3
\arrangedpageB
% 31
551
\or
\handlearrangedpageXandY
{
#
1
}
0
2
3
\arrangedpageA
% 32
552
\poparrangedpages
553
\fi
}
554 555
\def
\pusharrangedpageSIXTEEN
#
1
% changed to match the official way of doing
556
{
\advancearrangedpageN
557
\reportarrangedpage
\arrangedpageN
558
\ifcase
\arrangedpageN
559
\or
\handlearrangedpageXandY
{
#
1
}
0
3
1
\arrangedpageA
% 1
560
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageB
% 2
561
\or
\handlearrangedpageXandY
{
#
1
}
0
3
1
\arrangedpageB
% 3
562
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageA
% 4
563
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageA
% 5
564
\or
\handlearrangedpageXandY
{
#
1
}
1
3
0
\arrangedpageB
% 6
565
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageB
% 7
566
\or
\handlearrangedpageXandY
{
#
1
}
1
3
0
\arrangedpageA
% 8
567
\or
\handlearrangedpageXandY
{
#
1
}
1
2
0
\arrangedpageA
% 9
568
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageB
% 10
569
\or
\handlearrangedpageXandY
{
#
1
}
1
2
0
\arrangedpageB
% 11
570
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageA
% 12
571
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageA
% 13
572
\or
\handlearrangedpageXandY
{
#
1
}
0
2
1
\arrangedpageB
% 14
573
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageB
% 15
574
\or
\handlearrangedpageXandY
{
#
1
}
0
2
1
\arrangedpageA
% 16
575
\poparrangedpages
576
\fi
}
577 578
\def
\pusharrangedpageEIGHT
#
1
% changed to match the official way of doing
579
{
\advancearrangedpageN
580
\reportarrangedpage
\arrangedpageN
581
\ifcase
\arrangedpageN
582
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageA
% 1
583
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageB
% 2
584
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageB
% 3
585
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageA
% 4
586
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageA
% 5
587
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageB
% 6
588
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageB
% 7
589
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageA
% 8
590
\poparrangedpages
591
\fi
}
592 593
\def
\pusharrangedpageFOURA
{
\pusharrangedpageFOURdo
0
1
}
594
\def
\pusharrangedpageFOURB
{
\pusharrangedpageFOURdo
1
0
}
595 596
\def
\pusharrangedpageFOURdo
#
1
#
2
#
3
%
597
{
\advancearrangedpageN
598
\reportarrangedpage
\arrangedpageN
599
\ifcase
\arrangedpageN
600
\or
\handlearrangedpageXandY
{
#
3
}
0
1
0
\arrangedpageA
% 1
601
\or
\handlearrangedpageXandY
{
#
3
}
0
{
#
1
}
0
\arrangedpageB
% 2/3 not {1}
602
\or
\handlearrangedpageXandY
{
#
3
}
0
{
#
2
}
0
\arrangedpageB
% 3/2 not {1}
603
\or
\handlearrangedpageXandY
{
#
3
}
0
0
0
\arrangedpageA
% 4
604
\poparrangedpages
605
\fi
}
606 607
\def
\pusharrangedpageSIDETOP
#
1
%
608
{
\advancearrangedpageN
609
\reportarrangedpage
\arrangedpageN
610
\ifcase
\arrangedpageN
611
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 1
612
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
613
\poparrangedpages
614
\fi
}
615 616
\def
\handlearrangedpageSIDE
617
{
\wd
\arrangedpageA
\paperwidth
618
\wd
\arrangedpageB
\paperwidth
619
\global
\setbox
\arrangedpageA
\hpack
620
{
\box
\arrangedpageA
\box
\arrangedpageB
}
%
621
\ht
\arrangedpageA
\paperheight
}
622 623
\def
\handlearrangedpageTOP
624
{
\ht
\arrangedpageA
\paperheight
625
\ht
\arrangedpageB
\paperheight
626
\global
\setbox
\arrangedpageA
\vpack
627
{
\offinterlineskip
\vskip
\paperheight
628
\box
\arrangedpageA
\box
\arrangedpageB
}
%
629
\global
\setbox
\arrangedpageB
\box
\scratchbox
}
% ?
630 631
% 2UP/2DOWN / 1pt prevents overflow
632 633
\def
\splitoffarrangedpagesTWO
634
{
\splittopskip
\zeropoint
635
\global
\setbox
\arrangedpageA
\vsplit
\arrangedpageB
to
\onepoint
636
\scratchdimen
\dimexpr
\ht
\arrangedpageB
-
\onepoint
\relax
637
\ifdim
\scratchdimen
>
\onepoint
638
\setbox
\scratchbox
\vsplit
\arrangedpageB
to
\scratchdimen
639
\fi
}
640 641
\def
\handlearrangedpageTWOUP
642
{
\splitoffarrangedpagesTWO
643
\ht
\arrangedpageA
\paperheight
644
\ht
\arrangedpageB
\paperheight
645
\ifconditional
\arrangedswapstate
646
\global
\setbox
\arrangedpageA
\hpack
647
{
\page_boxes_apply_clip_print_left
\arrangedpageA
648
\box
\arrangedpageA
649
\page_boxes_apply_clip_print_right
\arrangedpageB
650
\box
\arrangedpageB
}
%
651
\setfalse
\arrangedswapstate
652
\else
653
\global
\setbox
\arrangedpageA
\hpack
654
{
\page_boxes_apply_clip_print_left
\arrangedpageB
655
\box
\arrangedpageB
656
\page_boxes_apply_clip_print_right
\arrangedpageA
657
\box
\arrangedpageA
}
%
658
\settrue
\arrangedswapstate
659
\fi
660
\global
\setbox
\arrangedpageB
\box
\scratchbox
}
661 662
\def
\handlearrangedpageTWODOWN
663
{
\splitoffarrangedpagesTWO
664
\ht
\arrangedpageA
\paperheight
665
\ht
\arrangedpageB
\paperheight
666
\ifconditional
\arrangedswapstate
667
\global
\setbox
\arrangedpageA
\vpack
668
{
\offinterlineskip
669
\vskip
\paperheight
670
\box
\arrangedpageA
671
\box
\arrangedpageB
}
%
672
\setfalse
\arrangedswapstate
673
\else
674
\global
\setbox
\arrangedpageA
\vpack
675
{
\offinterlineskip
676
\vskip
\paperheight
677
\box
\arrangedpageB
678
\box
\arrangedpageA
}
%
679
\settrue
\arrangedswapstate
680
\fi
681
\global
\setbox
\arrangedpageB
\box
\scratchbox
}
682 683
\def
\poparrangedpagesTWO
684
{
\ifnum
\arrangedpageN
>
\zerocount
685
\setfalse
\arrangedswapstate
686
\doloop
687
{
\handlearrangedpage
688
\bgroup
689
\paperwidth
\arrangedpageX
\paperwidth
690
\paperheight
\arrangedpageY
\paperheight
691
\ht
\arrangedpageA
\paperheight
692
\wd
\arrangedpageA
\paperwidth
693
\outputarrangedbox
\arrangedpageA
694
\egroup
695
\ifdim
\ht
\arrangedpageB
=
\zeropoint
696
\exitloop
697
\fi
}
%
698
\global
\arrangedpageN
\zerocount
699
\fi
}
700 701
\def
\pusharrangedpageTWO
#
1
%
702
{
\advancearrangedpageN
703
\reportarrangedpage
\arrangedpageN
704
\global
\setbox
\arrangedpageB
\vpack
705
{
\offinterlineskip
706
\unvbox
\arrangedpageB
707
\allowbreak
708
\setbox
#
1
\vpack
{
\box
#
1
}
% really needed in order to keep real dimensions
709
\ht
#
1
\onepoint
710
\dp
#
1
\zeropoint
711
\vpack
{
\box
#
1
}
}
}
712 713
\def
\poparrangedpagesTWOTOPSIDE
714
{
\ifnum
\arrangedpageN
>
\zerocount
715
\bgroup
716
\global
\arrangedpageN
\plustwo
717
\poparrangedpagesTWO
718
\let
\arrangedpageA
\arrangedpageC
719
\let
\arrangedpageB
\arrangedpageD
720
\global
\arrangedpageN
\plustwo
721
\poparrangedpagesTWO
722
\global
\arrangedpageN
\zerocount
723
\egroup
724
\fi
}
725 726
\def
\pusharrangedpageTWOTOPSIDE
#
1
%
727
{
\advancearrangedpageN
728
\reportarrangedpage
\arrangedpageN
729
\ifcase
\arrangedpageN
730
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 1
731
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageC
% 2
732
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 1
733
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageD
% 2
734
\poparrangedpages
735
\fi
}
736 737
%D Willy Egger's sheet simulations:
738 739
\def
\poparrangedpagesAtoH
740
{
\ifnum
\arrangedpageN
>
\zerocount
741
\paperwidth
\arrangedpageX
\paperwidth
742
\paperheight
\arrangedpageY
\paperheight
743
\outputarrangedbox
\arrangedpageA
744
\outputarrangedbox
\arrangedpageB
745
\outputarrangedbox
\arrangedpageC
746
\outputarrangedbox
\arrangedpageD
747
\outputarrangedbox
\arrangedpageE
748
\outputarrangedbox
\arrangedpageF
749
\outputarrangedbox
\arrangedpageG
750
\outputarrangedbox
\arrangedpageH
751
\global
\arrangedpageN
\zerocount
752
\fi
}
753 754
% to arrange 16 pages on 2 sheets to form one booklet
755 756
\def
\poparrangedpagesAtoD
757
{
\ifnum
\arrangedpageN
>
\zerocount
758
\paperwidth
\arrangedpageX
\paperwidth
759
\paperheight
\arrangedpageY
\paperheight
760
\outputarrangedbox
\arrangedpageA
761
\outputarrangedbox
\arrangedpageB
762
\outputarrangedbox
\arrangedpageC
763
\outputarrangedbox
\arrangedpageD
764
\global
\arrangedpageN
\zerocount
765
\fi
}
766 767
% to arrange 16 pages on 4 sheets to form one booklet
768 769
\def
\pusharrangedpageSIXTEENFOUR
#
1
%
770
{
\advancearrangedpageN
771
\reportarrangedpage
\arrangedpageN
772
\ifcase
\arrangedpageN
773
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 1
774
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
775
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageC
% 3
776
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageD
% 4
777
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageE
% 5
778
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageF
% 6
779
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageG
% 7
780
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageH
% 8
781
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageH
% 9
782
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageG
% 10
783
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageF
% 11
784
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageE
% 12
785
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageD
% 13
786
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageC
% 14
787
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 15
788
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 16
789
\poparrangedpages
790
\fi
}
791 792
% to arrange 16 pages on 2 sheets to form one booklet
793 794
\def
\pusharrangedpageSIXTEENTWO
#
1
%
795
{
\advancearrangedpageN
796
\reportarrangedpage
\arrangedpageN
797
\ifcase
\arrangedpageN
798
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageA
% 1
799
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageB
% 2
800
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageC
% 3
801
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageD
% 4
802
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageD
% 5
803
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageC
% 6
804
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageB
% 7
805
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageA
% 8
806
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageA
% 9
807
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageB
% 10
808
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageC
% 11
809
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageD
% 12
810
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageD
% 13
811
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageC
% 14
812
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageB
% 15
813
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageA
% 16
814
\poparrangedpages
815
\fi
}
816 817
%D Might be used if a printer is printing from a roll or creating mini-books from A4:
818
%D This section has 16 pages. The folding scheme is first a Z-fold and at the end
819
%D a final fold in the spine.
820
%D Coding: [2*8*Z]
821 822
\installpagearrangement
2
*
8
*
Z
823
{
\dosetuparrangement
{
2
}
{
4
}
{
8
}
{
3
}
{
5
}
% X,Y,Total,hcutmarks,vcutmarks
824
\pusharrangedpageSIXTEENZ
\poparrangedpagesAB
\relax
}
825 826
\def
\pusharrangedpageSIXTEENZ
#
1
%
827
{
\advancearrangedpageN
828
\reportarrangedpage
\arrangedpageN
829
\ifcase
\arrangedpageN
830
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 1
831
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
832
\or
\handlearrangedpageXandY
{
#
1
}
1
0
1
\arrangedpageB
% 3
833
\or
\handlearrangedpageXandY
{
#
1
}
1
1
1
\arrangedpageA
% 4
834
\or
\handlearrangedpageXandY
{
#
1
}
0
1
2
\arrangedpageA
% 5
835
\or
\handlearrangedpageXandY
{
#
1
}
0
0
2
\arrangedpageB
% 6
836
\or
\handlearrangedpageXandY
{
#
1
}
1
0
3
\arrangedpageB
% 7
837
\or
\handlearrangedpageXandY
{
#
1
}
1
1
3
\arrangedpageA
% 8
838
\or
\handlearrangedpageXandY
{
#
1
}
1
0
3
\arrangedpageA
% 9
839
\or
\handlearrangedpageXandY
{
#
1
}
1
1
3
\arrangedpageB
% 10
840
\or
\handlearrangedpageXandY
{
#
1
}
0
1
2
\arrangedpageB
% 11
841
\or
\handlearrangedpageXandY
{
#
1
}
0
0
2
\arrangedpageA
% 12
842
\or
\handlearrangedpageXandY
{
#
1
}
1
0
1
\arrangedpageA
% 13
843
\or
\handlearrangedpageXandY
{
#
1
}
1
1
1
\arrangedpageB
% 14
844
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 15
845
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 16
846
\poparrangedpages
847
\fi
}
848 849
%D Another Z-folded section with 12 pages
850
%D Coding: [2*6*Z]
851 852
\installpagearrangement
2
*
6
*
Z
853
{
\dosetuparrangement
{
2
}
{
3
}
{
6
}
{
3
}
{
4
}
% X,Y,Total,hcutmarks,vcutmarks
854
\pusharrangedpageTWELVEZ
\poparrangedpagesAB
\relax
}
855 856
\def
\pusharrangedpageTWELVEZ
#
1
%
857
{
\advancearrangedpageN
858
\reportarrangedpage
\arrangedpageN
859
\ifcase
\arrangedpageN
860
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 1: rotation (0=upright),x (0=first column),y (0=first row)
861
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
862
\or
\handlearrangedpageXandY
{
#
1
}
1
0
1
\arrangedpageB
% 3
863
\or
\handlearrangedpageXandY
{
#
1
}
1
1
1
\arrangedpageA
% 4
864
\or
\handlearrangedpageXandY
{
#
1
}
0
1
2
\arrangedpageA
% 5
865
\or
\handlearrangedpageXandY
{
#
1
}
0
0
2
\arrangedpageB
% 6
866
\or
\handlearrangedpageXandY
{
#
1
}
0
1
2
\arrangedpageB
% 7
867
\or
\handlearrangedpageXandY
{
#
1
}
0
0
2
\arrangedpageA
% 8
868
\or
\handlearrangedpageXandY
{
#
1
}
1
0
1
\arrangedpageA
% 9
869
\or
\handlearrangedpageXandY
{
#
1
}
1
1
1
\arrangedpageB
% 10
870
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 11
871
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 12
872
\poparrangedpages
873
\fi
}
874 875
%D For Heinz' special greeting cards folding. This scheme is also used for the PocketDiary (module):
876
%D Coding: [1*8]
877 878
\installpagearrangement
1
*
8
879
{
\dosetuparrangement
{
4
}
{
2
}
{
8
}
{
5
}
{
3
}
% X,Y,Total,hcutmarks,vcutmarks
880
\pusharrangedpageEIGHTSINGLESIDEDFOLDED
\poparrangedpagesTWO
\relax
}
881 882
\def
\pusharrangedpageEIGHTSINGLESIDEDFOLDED
#
1
%
883
{
\advancearrangedpageN
884
\reportarrangedpage
\arrangedpageN
885
\ifcase
\arrangedpageN
886
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 1 rot,hskip,vskip
887
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageA
% 2
888
\or
\handlearrangedpageXandY
{
#
1
}
0
3
0
\arrangedpageA
% 3
889
\or
\handlearrangedpageXandY
{
#
1
}
1
3
1
\arrangedpageA
% 4
890
\or
\handlearrangedpageXandY
{
#
1
}
1
2
1
\arrangedpageA
% 5
891
\or
\handlearrangedpageXandY
{
#
1
}
1
1
1
\arrangedpageA
% 6
892
\or
\handlearrangedpageXandY
{
#
1
}
1
0
1
\arrangedpageA
% 7
893
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 8
894
\poparrangedpages
895
\fi
}
896 897
%D This is not a section. \CONTEXT\ places 4 pages on a sheet of paper, singlesided
898
%D Coding: [1*4]
899 900
\installpagearrangement
1
*
4
901
{
\dosetuparrangement
{
2
}
{
2
}
{
4
}
{
3
}
{
3
}
% X,Y,Total,hcutmarks,vcutmarks
902
\pusharrangedpageFOURSINGLESIDEDFOLDED
\poparrangedpagesTWO
\relax
}
903 904
\def
\pusharrangedpageFOURSINGLESIDEDFOLDED
#
1
%
905
{
\advancearrangedpageN
906
\reportarrangedpage
\arrangedpageN
907
\ifcase
\arrangedpageN
908
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageA
% 1 rot,hskip,vskip
909
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageA
% 2
910
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageA
% 3
911
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageA
% 4
912
\poparrangedpages
913
\fi
}
914 915
%D This imposition scheme was requested by Hraban Ramm, by Willi Egger 21-07-2003
916
%D Coding: [3SIDE]
917 918
\installpagearrangement
3
SIDE
919
{
\dosetuparrangement
{
3
}
{
1
}
{
3
}
{
4
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
920
\pusharrangedpageTHREESIDE
\poparrangedpagesAB
\relax
}
921 922
\def
\pusharrangedpageTHREESIDE
#
1
% Willi's approach
923
{
\advancearrangedpageN
924
\reportarrangedpage
\arrangedpageN
925
\ifcase
\arrangedpageN
926
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 1 rot,hskip,vskip
927
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 2
928
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageA
% 3
929
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 4
930
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 5
931
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageB
% 6
932
\poparrangedpages
933
\fi
}
934 935
%D FLYER in three parts and 6 pages 22-10-2010
936
%D Coding: [TRYPTICHON]
937 938
\installpagearrangement
TRYPTICHON
939
{
\dosetuparrangement
{
3
}
{
1
}
{
3
}
{
4
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
940
\pusharrangedpageFLYERSIX
\poparrangedpagesAB
\relax
}
941 942
\def
\pusharrangedpageFLYERSIX
#
1
% Willi's approach
943
{
\advancearrangedpageN
944
\reportarrangedpage
\arrangedpageN
945
\ifcase
\arrangedpageN
946
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageA
% 1 rot,hskip,vskip
947
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
948
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 3
949
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageB
% 4
950
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 5
951
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 6
952
\poparrangedpages
953
\fi
}
954 955
%D FLYER in Z-fold with 8 pages 22-01-2010
956
%D Coding: [ZFLYER-8]
957 958
\installpagearrangement
ZFLYER
-
8
959
{
\dosetuparrangement
{
4
}
{
1
}
{
4
}
{
5
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
960
\pusharrangedpageZFLYEREIGHT
\poparrangedpagesAB
\relax
}
961 962
\def
\pusharrangedpageZFLYEREIGHT
#
1
% Willi's approach
963
{
\advancearrangedpageN
964
\reportarrangedpage
\arrangedpageN
965
\ifcase
\arrangedpageN
966
\or
\handlearrangedpageXandY
{
#
1
}
0
3
0
\arrangedpageA
% 1 rot,hskip,vskip
967
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
968
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 3
969
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageB
% 4
970
\or
\handlearrangedpageXandY
{
#
1
}
0
3
0
\arrangedpageB
% 5
971
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 6
972
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 7
973
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageA
% 8
974
\poparrangedpages
975
\fi
}
976 977
%D FLYER in Z-fold with 10 pages 04-08-2010
978
%D Coding: [ZFLYER-10]
979 980
\installpagearrangement
ZFLYER
-
1
0
981
{
\dosetuparrangement
{
5
}
{
1
}
{
5
}
{
6
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
982
\pusharrangedpageZFLYERTEN
\poparrangedpagesAB
\relax
}
983 984
\def
\pusharrangedpageZFLYERTEN
#
1
% Willi's approach
985
{
\advancearrangedpageN
986
\reportarrangedpage
\arrangedpageN
987
\ifcase
\arrangedpageN
988
\or
\handlearrangedpageXandY
{
#
1
}
0
4
0
\arrangedpageA
% 1 rot,hskip,vskip
989
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
990
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 3
991
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageB
% 4
992
\or
\handlearrangedpageXandY
{
#
1
}
0
3
0
\arrangedpageB
% 5
993
\or
\handlearrangedpageXandY
{
#
1
}
0
4
0
\arrangedpageB
% 6
994
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 7
995
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 8
996
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageA
% 9
997
\or
\handlearrangedpageXandY
{
#
1
}
0
3
0
\arrangedpageA
% 10
998
\poparrangedpages
999
\fi
}
1000 1001
%D FLYER in Z-fold with 12 pages 04-08-2010
1002
%D Coding: [ZFLYER-12]
1003 1004
\installpagearrangement
ZFLYER
-
1
2
1005
{
\dosetuparrangement
{
6
}
{
1
}
{
6
}
{
7
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
1006
\pusharrangedpageZFLYERTWELVE
\poparrangedpagesAB
\relax
}
1007 1008
\def
\pusharrangedpageZFLYERTWELVE
#
1
% Willi's approach
1009
{
\advancearrangedpageN
1010
\reportarrangedpage
\arrangedpageN
1011
\ifcase
\arrangedpageN
1012
\or
\handlearrangedpageXandY
{
#
1
}
0
5
0
\arrangedpageA
% 1 rot,hskip,vskip
1013
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
1014
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 3
1015
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageB
% 4
1016
\or
\handlearrangedpageXandY
{
#
1
}
0
3
0
\arrangedpageB
% 5
1017
\or
\handlearrangedpageXandY
{
#
1
}
0
4
0
\arrangedpageB
% 6
1018
\or
\handlearrangedpageXandY
{
#
1
}
0
5
0
\arrangedpageB
% 7
1019
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 8
1020
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 9
1021
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageA
% 10
1022
\or
\handlearrangedpageXandY
{
#
1
}
0
3
0
\arrangedpageA
% 11
1023
\or
\handlearrangedpageXandY
{
#
1
}
0
4
0
\arrangedpageA
% 12
1024
\poparrangedpages
1025
\fi
}
1026 1027
%D FLYER folded as a map with 6 pages per side.
1028
%D Coding: [MAPFLYER-12]
1029 1030
\installpagearrangement
MAPFLYER
-
1
2
1031
{
\dosetuparrangement
{
3
}
{
2
}
{
6
}
{
4
}
{
3
}
% X,Y,Total,hcutmarks,vcutmarks
1032
\pusharrangedpageMFLYERTWELVE
\poparrangedpagesAB
\relax
}
1033 1034
\def
\pusharrangedpageMFLYERTWELVE
#
1
% Willi's approach
1035
{
\advancearrangedpageN
1036
\reportarrangedpage
\arrangedpageN
1037
\ifcase
\arrangedpageN
1038
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageA
% 1 rot,hskip,vskip
1039
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
1040
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageB
% 3
1041
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 4
1042
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageB
% 5
1043
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageB
% 6
1044
\or
\handlearrangedpageXandY
{
#
1
}
0
2
1
\arrangedpageB
% 7
1045
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 8
1046
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageA
% 9
1047
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 10
1048
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageA
% 11
1049
\or
\handlearrangedpageXandY
{
#
1
}
0
2
1
\arrangedpageA
% 12
1050
\poparrangedpages
1051
\fi
}
1052 1053
%D FLYER folded as double window with 4 pages per side.
1054
%D Coding: [DOUBLEWINDOW]
1055 1056
\installpagearrangement
DOUBLEWINDOW
1057
{
\dosetuparrangement
{
4
}
{
1
}
{
4
}
{
5
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
1058
\pusharrangedpageDOUBLEWINDOWEIGHT
\poparrangedpagesAB
\relax
}
1059 1060
\def
\pusharrangedpageDOUBLEWINDOWEIGHT
#
1
% Willi's approach
1061
{
\advancearrangedpageN
1062
\reportarrangedpage
\arrangedpageN
1063
\ifcase
\arrangedpageN
1064
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageA
% 1 rot,hskip,vskip
1065
\or
\handlearrangedpageXandY
{
#
1
}
0
3
0
\arrangedpageA
% 2
1066
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 3
1067
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 4
1068
\or
\handlearrangedpageXandY
{
#
1
}
0
2
0
\arrangedpageB
% 5
1069
\or
\handlearrangedpageXandY
{
#
1
}
0
3
0
\arrangedpageB
% 6
1070
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 7
1071
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 8
1072
\poparrangedpages
1073
\fi
}
1074 1075
%D Imposition as requested by Jan Pohanka 26-08-2010, 4 pages, two verso, two recto,
1076
%D uneven pages upright and down, even pages top and rotated 180.
1077
%D Implementation with 2 pages for conference-name-display
1078
%D Coding: [1*2-Conference]
1079 1080
\installpagearrangement
1
*
2
-
Conference
1081
{
\dosetuparrangement
{
1
}
{
2
}
{
4
}
{
3
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
1082
\pusharrangedpageCONFERENCETWO
\poparrangedpagesAB
\relax
}
1083 1084
\def
\pusharrangedpageCONFERENCETWO
#
1
%
1085
{
\advancearrangedpageN
1086
\reportarrangedpage
\arrangedpageN
1087
\ifcase
\arrangedpageN
1088
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageA
% 1 rot,hskip,vskip
1089
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageA
% 2
1090
\poparrangedpages
1091
\fi
}
1092 1093
%D Implementation with 4 pages for conference-name-display
1094
%D Coding: [1*4-Conference]
1095 1096
\installpagearrangement
1
*
4
-
Conference
1097
{
\dosetuparrangement
{
1
}
{
2
}
{
4
}
{
3
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
1098
\pusharrangedpageCONFERENCEFOUR
\poparrangedpagesAB
\relax
}
1099 1100
\def
\pusharrangedpageCONFERENCEFOUR
#
1
%
1101
{
\advancearrangedpageN
1102
\reportarrangedpage
\arrangedpageN
1103
\ifcase
\arrangedpageN
1104
\or
\handlearrangedpageXandY
{
#
1
}
0
0
1
\arrangedpageA
% 1 rot,hskip,vskip
1105
\or
\handlearrangedpageXandY
{
#
1
}
1
0
0
\arrangedpageA
% 2
1106
\or
\handlearrangedpageXandY
{
#
1
}
0
1
1
\arrangedpageB
% 3
1107
\or
\handlearrangedpageXandY
{
#
1
}
1
1
0
\arrangedpageB
% 4
1108
\poparrangedpages
1109
\fi
}
1110 1111
%D There should be arrangements for sections made of heavy and thick paper. i.e. the heavier the paper
1112
%D the fewer pages per section:
1113
%D Section with 8 pages put on two sheets of paper. Each sheet carries recto 2 and verso 2 pages.
1114
%D Coding: [2*2*2]
1115 1116
\installpagearrangement
2
*
2
*
2
1117
{
\dosetuparrangement
{
2
}
{
1
}
{
2
}
{
3
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
1118
\pusharrangedpageEIGHTTWO
\poparrangedpagesAtoD
\relax
}
1119 1120
\def
\pusharrangedpageEIGHTTWO
#
1
%
1121
{
\advancearrangedpageN
1122
\reportarrangedpage
\arrangedpageN
1123
\ifcase
\arrangedpageN
1124
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 1 rot,hskip,vskip
1125
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
1126
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageC
% 3
1127
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageD
% 4
1128
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageD
% 5
1129
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageC
% 6
1130
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 7
1131
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 8
1132
\poparrangedpages
1133
\fi
}
1134 1135
%D Section with 12 pages, built from three sheets of paper.
1136
%D Each sheet carries 2 pages recto and verso.
1137
%D Coding: [2*2*3]
1138 1139
\def
\poparrangedpagesAtoF
1140
{
\ifnum
\arrangedpageN
>
\zerocount
1141
\paperwidth
\arrangedpageX
\paperwidth
1142
\paperheight
\arrangedpageY
\paperheight
1143
\outputarrangedbox
\arrangedpageA
1144
\outputarrangedbox
\arrangedpageB
1145
\outputarrangedbox
\arrangedpageC
1146
\outputarrangedbox
\arrangedpageD
1147
\outputarrangedbox
\arrangedpageE
1148
\outputarrangedbox
\arrangedpageF
1149
\global
\arrangedpageN
\zerocount
1150
\fi
}
1151 1152
\installpagearrangement
2
*
2
*
3
1153
{
\dosetuparrangement
{
2
}
{
1
}
{
2
}
{
3
}
{
2
}
% X,Y,Total,hcutmarks,vcutmarks
1154
\pusharrangedpageTWELVETWO
\poparrangedpagesAtoF
\relax
}
1155 1156
\def
\pusharrangedpageTWELVETWO
#
1
%
1157
{
\advancearrangedpageN
1158
\reportarrangedpage
\arrangedpageN
1159
\ifcase
\arrangedpageN
1160
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageA
% 1 rot,hskip,vskip
1161
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageB
% 2
1162
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageC
% 3
1163
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageD
% 4
1164
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageE
% 5
1165
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageF
% 6
1166
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageF
% 7
1167
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageE
% 8
1168
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageD
% 9
1169
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageC
% 10
1170
\or
\handlearrangedpageXandY
{
#
1
}
0
1
0
\arrangedpageB
% 11
1171
\or
\handlearrangedpageXandY
{
#
1
}
0
0
0
\arrangedpageA
% 12
1172
\poparrangedpages
1173
\fi
}
1174 1175
% % From Wolfgang for Mari (mail on list) ... yes or no in core .. time for
1176
% % delayed loading ...
1177
% %
1178
% % http://stamphenge.wordpress.com/minibooks/meander-accordion-folded-book/
1179
%
1180
% \installpagearrangement MEANDER16
1181
% {\dosetuparrangement{4}{4}{16}{5}{5}%
1182
% \pusharrangedpageMEANDERSIXTEEN\poparrangedpagesXY\relax}
1183
%
1184
% \def\pusharrangedpageMEANDERSIXTEEN#1%
1185
% {\advancearrangedpageN
1186
% \reportarrangedpage\arrangedpageN
1187
% \ifcase\arrangedpageN
1188
% \or \handlearrangedpageXandY{#1}000\arrangedpageA
1189
% \or \handlearrangedpageXandY{#1}010\arrangedpageA
1190
% \or \handlearrangedpageXandY{#1}020\arrangedpageA
1191
% \or \handlearrangedpageXandY{#1}030\arrangedpageA
1192
% \or \handlearrangedpageXandY{#1}131\arrangedpageA
1193
% \or \handlearrangedpageXandY{#1}121\arrangedpageA
1194
% \or \handlearrangedpageXandY{#1}111\arrangedpageA
1195
% \or \handlearrangedpageXandY{#1}101\arrangedpageA
1196
% \or \handlearrangedpageXandY{#1}002\arrangedpageA
1197
% \or \handlearrangedpageXandY{#1}012\arrangedpageA
1198
% \or \handlearrangedpageXandY{#1}022\arrangedpageA
1199
% \or \handlearrangedpageXandY{#1}032\arrangedpageA
1200
% \or \handlearrangedpageXandY{#1}133\arrangedpageA
1201
% \or \handlearrangedpageXandY{#1}123\arrangedpageA
1202
% \or \handlearrangedpageXandY{#1}113\arrangedpageA
1203
% \or \handlearrangedpageXandY{#1}103\arrangedpageA
1204
% \poparrangedpages
1205
% \fi}
1206
%
1207
% % \definepapersize[small][width=6cm,height=6cm]
1208
% % \definepapersize[big][width=30cm,height=30cm]
1209
% % \setuppapersize[small][big]
1210
% % \setuppagenumbering[location=]
1211
% % \setuparranging[MEANDER16]
1212
% % \setuplayout
1213
% % [location=middle,
1214
% % marking=on]
1215
% % \starttext
1216
% % \dorecurse{32}{\centerbox{\ssd\recurselevel}}
1217
% % \stoptext
1218
%
1219
% % By Willi:
1220
%
1221
% \installpagearrangement MEANDER9
1222
% {\dosetuparrangement{3}{3}{9}{4}{4}%
1223
% \pusharrangedpageMEANDERNINE\poparrangedpagesXY\relax}
1224
%
1225
% \def\pusharrangedpageMEANDERNINE#1%
1226
% {\advancearrangedpageN
1227
% \reportarrangedpage\arrangedpageN
1228
% \ifcase\arrangedpageN
1229
% \or \handlearrangedpageXandY{#1}000\arrangedpageA
1230
% \or \handlearrangedpageXandY{#1}010\arrangedpageA
1231
% \or \handlearrangedpageXandY{#1}020\arrangedpageA
1232
% \or \handlearrangedpageXandY{#1}121\arrangedpageA
1233
% \or \handlearrangedpageXandY{#1}111\arrangedpageA
1234
% \or \handlearrangedpageXandY{#1}101\arrangedpageA
1235
% \or \handlearrangedpageXandY{#1}002\arrangedpageA
1236
% \or \handlearrangedpageXandY{#1}012\arrangedpageA
1237
% \or \handlearrangedpageXandY{#1}022\arrangedpageA
1238
% \poparrangedpages
1239
% \fi}
1240 1241
% % handy for stickers etc, this way we can treat them as page
1242
%
1243
% \setuppapersize [XY][A4]
1244
% \setuppaper [topspace=5mm,backspace=5mm,dx=1mm,dy=1mm,nx=2,ny=6]
1245
% \setuplayout [page] [topspace=5mm,backspace=5mm]
1246
% \setuplayout [page]
1247
% \setuplayout [location=middle]
1248
% \setuparranging [XY]
1249
% \showframe
1250
%
1251
% \starttext \dorecurse{30}{test \recurselevel \page} \stoptext
1252 1253
\unexpanded
\def
\pusharrangedpageXY
#
1
%
1254
{
\advancearrangedpageN
1255
\global
\advance
\arrangedpageM
\plusone
1256
\reportarrangedpage
\arrangedpageN
1257
\global
\setbox
\arrangedpageB
\hpack
\ifdim
\v_page_target_width
>
\zeropoint
to
\v_page_target_width
\fi
1258
{
\ifvoid
\arrangedpageB
\else
1259
\unhbox
\arrangedpageB
1260
\ifdim
\v_page_target_dx
>
\zeropoint
1261
\hskip
\v_page_target_dx
1262
\else
1263
\hss
1264
\hskip
\v_page_target_dx
1265
\hss
1266
\fi
1267
\fi
1268
\box
#
1
}
%
1269
\ifnum
\arrangedpageM
<
\arrangedpageX
\else
1270
\global
\setbox
\arrangedpageA
\vpack
\ifdim
\v_page_target_height
>
\zeropoint
to
\v_page_target_height
\fi
1271
{
\offinterlineskip
1272
\ifvoid
\arrangedpageA
\else
1273
\unvbox
\arrangedpageA
1274
\ifdim
\v_page_target_dy
>
\zeropoint
1275
\vskip
\v_page_target_dy
1276
\else
1277
\vss
1278
\vskip
\v_page_target_dy
1279
\vss
1280
\fi
1281
\fi
1282
\box
\arrangedpageB
}
%
1283
\global
\arrangedpageM
\zerocount
1284
\fi
1285
\ifnum
\arrangedpageN
<
\arrangedpageT
\else
1286
\poparrangedpages
1287
\fi
}
1288 1289
\unexpanded
\def
\poparrangedpagesXY
1290
{
\ifnum
\arrangedpageN
>
\zerocount
1291
\paperwidth
\arrangedpageX
\paperwidth
1292
\paperheight
\arrangedpageY
\paperheight
1293
\outputarrangedbox
\arrangedpageA
1294
\global
\arrangedpageN
\zerocount
1295
\global
\arrangedpageM
\zerocount
1296
\fi
}
1297 1298
\installpagearrangement
XY
1299
{
\dosetuparrangement
1300
\v_page_target_nx
1301
\v_page_target_ny
1302
\v_page_target_xy
1303
\zerocount
1304
\zerocount
1305
\pusharrangedpageXY
\poparrangedpagesXY
\relax
}
1306 1307
%D A crazy definition, don't guess who pushed me for the landscape option.
1308 1309
\def
\page_imposition_xy_height
1310
{
\dimexpr
1311
\dimexpr
1312
\v_page_target_height
1313
-
\numexpr
\v_page_target_ny
-
1
\relax
\v_page_target_dy
1314
\relax
1315
/
\v_page_target_ny
1316
\relax
}
1317 1318
\def
\page_imposition_xy_width
1319
{
\dimexpr
1320
\dimexpr
1321
\v_page_target_width
1322
-
\numexpr
\v_page_target_nx
-
1
\relax
\v_page_target_dx
1323
\relax
1324
/
\v_page_target_nx
1325
\relax
}
1326 1327
\definepapersize
1328
[
XY
]
1329
[
\c!height
=
\page_imposition_xy_height
,
1330
\c!width
=
\page_imposition_xy_width
]
1331 1332
\setuppaper
1333
[
\c!width
=
\dimexpr
\printpaperwidth
-
2
\v_page_target_backspace
\relax
,
1334
\c!height
=
\dimexpr
\printpaperheight
-
2
\v_page_target_topspace
\relax
]
1335 1336
% \definepageshift[test][horizontal][10pt,20pt,30pt,40pt,50pt]
1337
% \definepageshift[test][vertical] [10pt,20pt,30pt,40pt,50pt]
1338
%
1339
% \setuppageshift[test]
1340
% \setuppageshift[test][test]
1341
% \setuppageshift[test][none]
1342
% \setuppageshift[none][test]
1343
% \setuppageshift[paper][test][test] % arrange only
1344
% \setuppageshift[paper][test] % arrange only
1345
% \setuppageshift[print][test][test]
1346
%
1347
% \showframe \dorecurse{100}{\input tufte \par}
1348 1349
% #1=name #2=horizontal|vertical #3=shiftlist
1350 1351
% this will move to lua
1352 1353
\installcorenamespace
{
pageshift
}
1354 1355
\unexpanded
\def
\definepageshift
1356
{
\dotripleargument
\page_boxes_define_shift
}
1357 1358
\def
\page_boxes_define_shift
[
#
1
]
[
#
2
]
[
#
3
]
%
1359
{
\setvalue
{
\??pageshift
#
2
:
#
1
}
{
#
3
}
}
1360 1361
\let
\page_boxes_h_shifts
\empty
1362
\let
\page_boxes_v_shifts
\empty
1363 1364
\newcount
\c_page_boxes_h_shifts
1365
\newcount
\c_page_boxes_v_shifts
1366 1367
\newdimen
\d_page_boxes_h_shifts
1368
\newdimen
\d_page_boxes_v_shifts
1369 1370
\let
\page_boxes_apply_shift_print
\gobbleoneargument
1371
\let
\page_boxes_apply_shift_paper
\gobbleoneargument
1372 1373
\def
\page_boxes_filter_shift
#
1
#
2
#
3
% #1=\dimenx #2=\xpageshifts #3=\nofxpageshifts
1374
{
#
1
\zeropoint
1375
\ifx
#
2
\empty
\else
1376
\global
\advance
#
3
\plusone
1377
\getfromcommacommand
[
#
2
]
[
#
3
]
%
1378
\ifx
\commalistelement
\empty
1379
\global
#
3
\plusone
% we cycle
1380
\getfromcommacommand
[
#
2
]
[
#
3
]
%
1381
\fi
1382
\ifx
\commalistelement
\empty
\else
1383
#
1
\commalistelement
\relax
% the relax is really needed as there is an \if later on
1384
\fi
1385
\fi
}
1386 1387
\def
\page_boxes_apply_shift
#
1
%
1388
{
\page_boxes_filter_shift
\d_page_boxes_h_shifts
\page_boxes_h_shifts
\c_page_boxes_h_shifts
1389
\page_boxes_filter_shift
\d_page_boxes_v_shifts
\page_boxes_v_shifts
\c_page_boxes_v_shifts
1390
\ifzeropt
\d_page_boxes_h_shifts
1391
\ifzeropt
\d_page_boxes_v_shifts
1392
% nothing to shift
1393
\else
1394
\page_boxes_apply_shift_indeed
#
1
%
1395
\fi
1396
\else
1397
\page_boxes_apply_shift_indeed
#
1
%
1398
\fi
}
1399 1400
\def
\page_boxes_apply_shift_indeed
#
1
%
1401
{
\edef
\next
{
\wd
#
1
\the
\wd
#
1
\ht
#
1
\the
\ht
#
1
\dp
#
1
\the
\dp
#
1
}
%
1402
\setbox
#
1
\vpack
1403
{
\offinterlineskip
1404
\vskip
\d_page_boxes_v_shifts
1405
\hskip
\d_page_boxes_h_shifts
1406
\box
#
1
}
%
1407
\next
}
1408 1409
\unexpanded
\def
\setuppageshift
1410
{
\dotripleempty
\page_boxes_setup_shift
}
1411 1412
\def
\page_boxes_setup_shift
[
#
1
]
[
#
2
]
[
#
3
]
% page|paper horizontal vertical
1413
{
\ifthirdargument
% paper=arrange
1414
%edef\page_boxes_h_shifts{\ifcsname\??pageshift\v!horizontal:#2\endcsname\csname\??pageshift\v!horizontal:#2\endcsname\fi}%
1415
%edef\page_boxes_v_shifts{\ifcsname\??pageshift\v!vertical :#3\endcsname\csname\??pageshift\v!vertical :#3\endcsname\fi}%
1416
\edef
\page_boxes_h_shifts
{
\begincsname
\??pageshift
\v!horizontal
:
#
2
\endcsname
}
%
1417
\edef
\page_boxes_v_shifts
{
\begincsname
\??pageshift
\v!vertical
:
#
3
\endcsname
}
%
1418
\doifelse
{
#
1
}
\v!page
{
\let
\page_boxes_apply_shift_print
\page_boxes_apply_shift
}
{
\let
\page_boxes_apply_shift_print
\gobbleoneargument
}
%
1419
\doifelse
{
#
1
}
\v!paper
{
\let
\page_boxes_apply_shift_paper
\page_boxes_apply_shift
}
{
\let
\page_boxes_apply_shift_paper
\gobbleoneargument
}
%
1420
\else
\ifsecondargument
1421
\doifelseinset
{
#
1
}
{
\v!page
,
\v!paper
}
1422
{
\setuppageshift
[
#
1
]
[
#
2
]
[
#
2
]
}
1423
{
\setuppageshift
[
\v!page
]
[
#
1
]
[
#
2
]
}
%
1424
\else
\iffirstargument
1425
\setuppageshift
[
\v!page
]
[
#
1
]
[
#
1
]
%
1426
\fi
\fi
\fi
}
1427 1428
\protect
\endinput
1429