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