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