page-lay.mkiv /size: 62 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=page-lay,
3
%D version=2000.10.20, % copied from main-001
4
%D title=\CONTEXT\ Page Macros,
5
%D subtitle=Layout Specification,
6
%D author=Hans Hagen,
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
\writestatus
{
loading
}{
ConTeXt
Page
Macros
/
Layout
Specification
}
15 16
%D Before you start wondering why some of the page related modules skip upward or
17
%D left in order to place elements, you must realize that the reference point is the
18
%D top left corner of the main typesetting area. One reason for this choice is that
19
%D it suited some viewers that displayed page areas. Another reason is that margins,
20
%D edges and top and bottom areas are kind of virtual, while the header, text and
21
%D footer areas normally determine the text flow.
22 23
\unprotect
24 25
%D The dimensions related to layout areas are represented by real dimensions.
26 27
\newdimen
\paperheight
\paperheight
=
2
9
7
mm
28
\newdimen
\paperwidth
\paperwidth
=
2
1
0
mm
29
\newdimen
\paperoffset
\paperoffset
=
\zeropoint
30
\newdimen
\paperbleed
\paperbleed
=
\zeropoint
31
\newdimen
\spinewidth
\spinewidth
=
\zeropoint
32 33
\newdimen
\printpaperheight
\printpaperheight
=
\paperheight
34
\newdimen
\printpaperwidth
\printpaperwidth
=
\paperwidth
35 36
\newdimen
\makeupheight
% calculated
37
\newdimen
\makeupwidth
% calculated
38 39
\newdimen
\textheight
% calculated
40
\newdimen
\textwidth
% calculated
41 42
\newdimen
\topspace
\topspace
=
2
cm
43
\newdimen
\backspace
\backspace
=
\topspace
44
\newdimen
\cutspace
\cutspace
=
\zeropoint
45
\newdimen
\bottomspace
\bottomspace
=
\zeropoint
46 47
\newdimen
\headerheight
\headerheight
=
2
cm
48
\newdimen
\footerheight
\footerheight
=
\headerheight
49 50
\newdimen
\topoffset
\topoffset
=
\zeropoint
51
\newdimen
\backoffset
\backoffset
=
\topoffset
52 53
\newdimen
\leftmarginwidth
\leftmarginwidth
=
3
cm
54
\newdimen
\rightmarginwidth
\rightmarginwidth
=
\leftmarginwidth
55 56
\newdimen
\leftedgewidth
\leftedgewidth
=
3
cm
57
\newdimen
\rightedgewidth
\rightedgewidth
=
\leftedgewidth
58 59
\newdimen
\topheight
\topheight
=
\zeropoint
60
\newdimen
\bottomheight
\bottomheight
=
\topheight
61 62
\newcount
\layoutlines
\layoutlines
=
\zerocount
63
\newcount
\layoutcolumns
\layoutcolumns
=
\zerocount
64
\newdimen
\layoutcolumndistance
\layoutcolumndistance
=
\zeropoint
65
\newdimen
\layoutcolumnwidth
\layoutcolumnwidth
=
\zeropoint
66 67
\newdimen
\totaltextwidth
68 69
%D The next series of dimensions are complemented by left and rights ones.
70 71
\newdimen
\margindistance
72
\newdimen
\edgedistance
73
\newdimen
\marginwidth
74
\newdimen
\edgewidth
75 76
%D Because a distance does not really makes sense when there is no area, we use a
77
%D zero distance in case there is no area.
78 79
%D The horizontal distances are:
80 81
\newdimen
\leftedgedistance
82
\newdimen
\rightedgedistance
83
\newdimen
\leftmargindistance
84
\newdimen
\rightmargindistance
85 86
%D The vertical distances are:
87 88
\newdimen
\topdistance
89
\newdimen
\headerdistance
90
\newdimen
\textdistance
91
\newdimen
\footerdistance
92
\newdimen
\bottomdistance
93 94
\newdimen
\textovershoot
% available in pagebuilder
95 96
%D We need to calculate the extra distances:
97 98
\newdimen
\naturalmarginwidth
99
\newdimen
\naturaledgewidth
100
\newdimen
\naturalmargindistance
101
\newdimen
\naturaledgedistance
102
\newdimen
\naturalleftedgedistance
103
\newdimen
\naturalrightedgedistance
104
\newdimen
\naturalleftmargindistance
105
\newdimen
\naturalrightmargindistance
106
\newdimen
\naturaltopdistance
107
\newdimen
\naturalheaderdistance
108
\newdimen
\naturaltextdistance
109
\newdimen
\naturalfooterdistance
110
\newdimen
\naturalbottomdistance
111 112
%D Now we've come to the setup and definition commands.
113 114
\installcorenamespace
{
layout
}
115
\installcorenamespace
{
layoutlocation
}
116
\installcorenamespace
{
layoutalternative
}
117
\installcorenamespace
{
layoutcolumn
}
118
\installcorenamespace
{
layoutmethod
}
119 120
\installswitchcommandhandler
\??layout
{
layout
}
\??layout
121 122
\appendtoks
123
\doifnothing
{
\directlayoutparameter
\c!state
}{
\letlayoutparameter
\c!state\v!start
}
%
124
\to
\everydefinelayout
125 126
\appendtoks
127
\ifcase
\layoutsetupmode
128
% can't happen
129
\or
% \setuplayout[name][key=value]
130
\ifx
\previouslayout
\currentlayout
131
\letlayoutparameter
\c!state\v!normal
% global ? still needed ?
132
\let
\currentlayout
\currentlayout
133
\page_layouts_synchronize
134
\page_layouts_check_next
135
\fi
136
\or
% \setuplayout[key=value]
137
% we can inherit so we always synchronize
138
\letlayoutparameter
\c!state\v!normal
% global ? still needed ?
139
\let
\currentlayout
\previouslayout
140
\page_layouts_synchronize
141
\page_layouts_check_next
142
\or
% \setuplayout[name]
143
\ifx
\currentlayout
\v!reset
144
\let
\currentlayout
\empty
145
\fi
146
\letlayoutparameter
\c!state\v!normal
% global ? still needed ?
147
\glet
\currentlayout
\currentlayout
% global
148
\page_layouts_synchronize
149
\page_layouts_check_next
150
\or
% \setuplayout (reverts to main layout)
151
\letlayoutparameter
\c!state\v!normal
% global ? still needed ?
152
\glet
\currentlayout
\empty
% global
153
\page_layouts_synchronize
154
\page_layouts_check_next
155
\fi
156
\to
\everysetuplayout
157 158
\def
\doifelselayoutdefined
#
1
%
159
{
\ifcsname
\namedlayouthash
{
#
1
}
\c!state
\endcsname
% maybe a helper
160
\expandafter
\firstoftwoarguments
161
\else
162
\expandafter
\secondoftwoarguments
163
\fi
}
164 165
\let
\doiflayoutdefinedelse\doifelselayoutdefined
166 167
\def
\layoutdistance
#
1
#
2
{
\ifdim
\zeropoint
<#
1
#
2
\else
\zeropoint
\fi
}
168 169
% \newconditional\reverselayout
170 171
\def
\page_layouts_set_dimensions
172
{
\global
\naturalmarginwidth
\layoutparameter
\c!margin
173
\global
\naturaledgewidth
\layoutparameter
\c!edge
174
\global
\naturalmargindistance
\layoutparameter
\c!margindistance
175
\global
\naturaledgedistance
\layoutparameter
\c!edgedistance
176
\global
\naturalleftedgedistance
\layoutparameter
\c!leftedgedistance
177
\global
\naturalrightedgedistance
\layoutparameter
\c!rightedgedistance
178
\global
\naturalleftmargindistance
\layoutparameter
\c!leftmargindistance
179
\global
\naturalrightmargindistance
\layoutparameter
\c!rightmargindistance
180
\global
\naturaltopdistance
\layoutparameter
\c!topdistance
181
\global
\naturalheaderdistance
\layoutparameter
\c!headerdistance
182
\global
\naturaltextdistance
\layoutparameter
\c!textdistance
183
\global
\naturalfooterdistance
\layoutparameter
\c!footerdistance
184
\global
\naturalbottomdistance
\layoutparameter
\c!bottomdistance
185
%
186
\global
\marginwidth
\naturalmarginwidth
187
\global
\edgewidth
\naturaledgewidth
188
\global
\margindistance
\naturalmargindistance
189
\global
\edgedistance
\naturaledgedistance
190
%
191
\global
\leftedgedistance
\layoutdistance
\leftedgewidth
\naturalleftedgedistance
192
\global
\rightedgedistance
\layoutdistance
\rightedgewidth
\naturalrightedgedistance
193
\global
\leftmargindistance
\layoutdistance
\leftmarginwidth
\naturalleftmargindistance
194
\global
\rightmargindistance
\layoutdistance
\rightmarginwidth
\naturalrightmargindistance
195
\global
\topdistance
\layoutdistance
\topheight
\naturaltopdistance
196
\global
\headerdistance
\layoutdistance
\headerheight
\naturalheaderdistance
197
\global
\textdistance
\naturaltextdistance
198
\global
\footerdistance
\layoutdistance
\footerheight
\naturalfooterdistance
199
\global
\bottomdistance
\layoutdistance
\bottomheight
\naturalbottomdistance
}
200 201
\def
\page_layouts_set_distances
% local in \setreducedvsize
202
{
\headerdistance
\layoutdistance
\headerheight
\naturalheaderdistance
203
\footerdistance
\layoutdistance
\footerheight
\naturalfooterdistance
}
204 205
% these are wrong in the running text, assumes some swapping, needs a cleanup
206 207
\def
\outermarginwidth
{
\rightorleftpageaction
\rightmarginwidth
\leftmarginwidth
}
208
\def
\innermarginwidth
{
\rightorleftpageaction
\leftmarginwidth
\rightmarginwidth
}
209
\def
\outermargindistance
{
\rightorleftpageaction
\rightmargindistance
\leftmargindistance
}
210
\def
\innermargindistance
{
\rightorleftpageaction
\leftmargindistance
\rightmargindistance
}
211 212
\def
\outeredgewidth
{
\rightorleftpageaction
\rightedgewidth
\leftedgewidth
}
213
\def
\inneredgewidth
{
\rightorleftpageaction
\leftedgewidth
\rightedgewidth
}
214
\def
\outeredgedistance
{
\rightorleftpageaction
\rightedgedistance
\leftedgedistance
}
215
\def
\inneredgedistance
{
\rightorleftpageaction
\leftedgedistance
\rightedgedistance
}
216 217
\def
\outerspacewidth
{
\rightorleftpageaction
\cutspace
\backspace
}
218
\def
\innerspacewidth
{
\rightorleftpageaction
\backspace
\cutspace
}
219 220
\newtoks
\extralayoutcalculations
221 222
\def
\page_layouts_calculate_extras
223
{
\the
\extralayoutcalculations
}
224 225
\newtoks
\everyswapmargins
% watch the order !
226 227
\appendtoks
228
\swapdimens
\leftmargindistance
\rightmargindistance
229
\swapdimens
\leftedgedistance
\rightedgedistance
230
\swapdimens
\leftmarginwidth
\rightmarginwidth
231
\swapdimens
\leftedgewidth
\rightedgewidth
232
%
233
\swapmacros
\leftmargintotal
\rightmargintotal
234
\swapmacros
\leftedgetotal
\rightedgetotal
235
\swapmacros
\leftsidetotal
\rightsidetotal
236
\swapmacros
\leftcombitotal
\rightcombitotal
237
\swapmacros
\innermargintotal
\outermargintotal
238
\swapmacros
\inneredgetotal
\outeredgetotal
239
\swapmacros
\innercombitotal
\outercombitotal
240
\swapmacros
\innersidetotal
\outersidetotal
241
\to
\everyswapmargins
242 243
%D The papersize macros have a long history and we don't want to change the commands
244
%D so they keep looking a bit complex.
245 246
%D \macros
247
%D {definepapersize}
248
%D
249
%D Before we start calculating layout dimensions, we will first take care of paper
250
%D sizes. The first argument can be either an assignment (for defaults) or an
251
%D identifier, in which case the second argument is an assignment.
252
%D
253
%D \showsetup{definepapersize}
254
%D
255
%D Yet undocumented, let's see if it gets noticed.
256
%D
257
%D \starttyping
258
%D \definepapersize[main] [A4] [A4]
259
%D \definepapersize[extra][A4,landscape][A4,landscape]
260
%D
261
%D \starttext
262
%D \setuppapersize[main]
263
%D Page 1. \page
264
%D Page 2. \page
265
%D \setuppapersize[extra]
266
%D Page 2 \page
267
%D \setuppapersize[main]
268
%D Page 3. \page
269
%D Page 4. \page
270
%D \adaptpapersize[extra]
271
%D Page 5. \page
272
%D Page 6. \page
273
%D \stoptext
274
%D \stoptyping
275
%D
276
%D \macros
277
%D {setuppaper,setuppapersize}
278
%D
279
%D When setting up the papersize on which to typeset and print, we can also
280
%D determine some more characteristics.
281
%D
282
%D \showsetup{setuppapersize}
283
%D
284
%D We keep track of these features with the following
285
%D variables.
286 287
\installcorenamespace
{
layouttarget
}
288
\installcorenamespace
{
layoutpaper
}
289
\installcorenamespace
{
layoutprint
}
290
\installcorenamespace
{
layoutcurrent
}
291 292
\installcommandhandler
\??layouttarget
{
layouttarget
}
\??layouttarget
% so this is a sort of mix, not really a user command / maybe switch handler
293 294
\newconditional
\c_page_target_paper_mirror
295
\newconstant
\c_page_target_paper_orientation
296
\newconstant
\c_page_target_paper_reverse
297
\newconditional
\c_page_target_paper_landscape
298
\newconditional
\c_page_target_paper_negate
299 300
\newconditional
\c_page_target_print_mirror
301
\newconstant
\c_page_target_print_orientation
302
\newconstant
\c_page_target_print_reverse
303
\newconditional
\c_page_target_print_landscape
304
\newconditional
\c_page_target_print_negate
305
\newconditional
\c_page_target_print_doublesided
306 307
\let
\v_page_target_left_fill
\relax
308
\let
\v_page_target_right_fill
\relax
309
\let
\v_page_target_top_fill
\relax
310
\let
\v_page_target_bottom_fill
\relax
311 312
\let
\papersize
\empty
313
\let
\printpapersize
\empty
314 315
\def
\v_page_target_top
{
\namedlayouttargetparameter
\papersize
\c!top
}
316
\def
\v_page_target_bottom
{
\namedlayouttargetparameter
\papersize
\c!bottom
}
317
\def
\v_page_target_left
{
\namedlayouttargetparameter
\papersize
\c!left
}
318
\def
\v_page_target_right
{
\namedlayouttargetparameter
\papersize
\c!right
}
319
\def
\v_page_target_method
{
\rootlayouttargetparameter
\c!method
}
320
\def
\v_page_target_scale
{
\rootlayouttargetparameter
\c!scale
}
321
\def
\v_page_target_nx
{
\numexpr
\rootlayouttargetparameter
\c!nx
\relax
}
322
\def
\v_page_target_ny
{
\numexpr
\rootlayouttargetparameter
\c!ny
\relax
}
323
\def
\v_page_target_dx
{
\dimexpr
\rootlayouttargetparameter
\c!dx
\relax
}
324
\def
\v_page_target_dy
{
\dimexpr
\rootlayouttargetparameter
\c!dy
\relax
}
325
\def
\v_page_target_width
{
\dimexpr
\rootlayouttargetparameter
\c!width
\relax
}
326
\def
\v_page_target_height
{
\dimexpr
\rootlayouttargetparameter
\c!height
\relax
}
327
\def
\v_page_target_topspace
{
\dimexpr
\rootlayouttargetparameter
\c!topspace
\relax
}
328
\def
\v_page_target_backspace
{
\dimexpr
\rootlayouttargetparameter
\c!backspace
\relax
}
329
\def
\v_page_target_offset
{
\dimexpr
\rootlayouttargetparameter
\c!offset
\relax
}
330 331
\def
\v_page_target_xy
{
\numexpr
\v_page_target_nx
*
\v_page_target_ny
\relax
}
332 333
%D Normally we will not use this command directly but for now it works out okay. In
334
%D the future we might use more of the related commands.
335 336
\setuplayouttarget
337
[
% these are rather special
338
\c!nx
=
1
,
339
\c!ny
=
1
,
340
\c!dx
=
\zeropoint
,
341
\c!dy
=
\zeropoint
,
342
\c!topspace
=
\zeropoint
,
343
\c!backspace
=
\zeropoint
,
344
\c!width
=
\zeropoint
,
345
\c!height
=
\zeropoint
,
346
%
347
\c!method
=
\v!normal
,
348
\c!option
=
\v!max
,
349
\c!alternative
=
\v!normal
,
350
%
351
\c!scale
=
1
,
352
\c!offset
=
\zeropoint
,
353
%
354
\c!top
=
,
355
\c!bottom
=
,
356
\c!left
=
,
357
\c!right
=
,
358
%
359
\c!location
=]
360 361
% \definepapersize[name][A4][A3]
362
% \definepapersize[name][settings]
363 364
\unexpanded
\def
\definepapersize
365
{
\dotripleempty
\page_paper_define_size
}
366 367
\def
\page_paper_define_size
[#
1
][#
2
][#
3
]
%
368
{
\edef
\currentlayouttarget
{
#
1
}
%
369
\ifx
\currentlayouttarget
\empty
370
% invalid target
371
\else\ifcondition
\validassignment
{
#
2
}
%
372
\definelayouttarget
[#
1
][#
2
]
%
373
\else
374
\setevalue
{
\??layoutpaper
#
1
}{
#
2
}
%
375
\ifthirdargument
376
\setevalue
{
\??layoutprint
#
1
}{
#
3
}
%
377
\else
378
\setevalue
{
\??layoutprint
#
1
}{
#
2
}
%
379
\fi
380
\fi\fi
}
381 382
\appendtoks
383
\letvalue
{
\??layoutcurrent
\currentlayouttarget
}
\relax
384
\to
\everydefinelayouttarget
385 386
%def\page_paper_the_paper_size#1{\ifcsname\??layoutpaper#1\endcsname\csname\??layoutpaper#1\endcsname\else#1\fi}
387
%def\page_paper_the_print_size#1{\ifcsname\??layoutprint#1\endcsname\csname\??layoutprint#1\endcsname\else#1\fi}
388 389
\def
\page_paper_the_paper_size
#
1
{
\ifcsname
\??layoutpaper
#
1
\endcsname\lastnamedcs\else
#
1
\fi
}
390
\def
\page_paper_the_print_size
#
1
{
\ifcsname
\??layoutprint
#
1
\endcsname\lastnamedcs\else
#
1
\fi
}
391 392
% \setuppaper [page=A4,paper=A3] % the k/v variant, changes the current page mapping
393
% \setuppapersize[A4][a=b,c=d] % the k/v variant, changes nothing, just settings
394
% \setuppapersize[A4][A3] % changes the current page mapping
395 396
\let
\page_paper_reinstate
\relax
397
\let
\page_paper_restore
\relax
398 399
\unexpanded
\def
\setuppapersize
400
{
\dodoubleempty
\page_paper_setup_size
}
401 402
\unexpanded
\def
\page_paper_setup_size
[#
1
][#
2
]
%
403
{
\iffirstargument
404
\ifcondition
\validassignment
{
#
1
}
%
405
\page_paper_setup_size_settings
[#
1
]
%
406
\else\ifcondition
\validassignment
{
#
2
}
%
407
\page_paper_setup_size_settings_by_name
[#
1
][#
2
]
%
408
\else
409
\page_paper_setup_size_change_size
[#
1
][#
2
]
%
410
\fi\fi
411
\else
412
\page_paper_restore
413
\fi
}
414 415
\unexpanded
\def
\page_paper_setup_size_settings
[#
1
]
% sometimes used to set paper/print size
416
{
\let
\currentlayouttarget
\empty
417
\edef
\m_layouttarget_paper_saved
{
\page_paper_the_paper_size
{
\layouttargetparameter
\c!page
}}
%
418
\edef
\m_layouttarget_print_saved
{
\page_paper_the_print_size
{
\layouttargetparameter
\c!paper
}}
%
419
\setupcurrentlayouttarget
[#
1
]
%
420
\edef
\m_layouttarget_paper
{
\page_paper_the_paper_size
{
\layouttargetparameter
\c!page
}}
%
421
\edef
\m_layouttarget_print
{
\page_paper_the_print_size
{
\layouttargetparameter
\c!paper
}}
%
422
\ifx
\m_layouttarget_paper_saved
\m_layouttarget_paper
423
\ifx
\m_layouttarget_print_saved
\m_layouttarget_print
424
% we didn't change the size, maybe only sx or sy or so
425
\else
426
\page_paper_setup_size_settings_recalibrate
427
\fi
428
\else
429
\page_paper_setup_size_settings_recalibrate
430
\fi
}
431 432
\def
\page_paper_setup_size_settings_recalibrate
433
{
\ifx
\m_layouttarget_paper
\empty
434
% forget about it
435
\else
436
\ifx
\m_layouttarget_print
\empty
437
\let
\m_layouttarget_print
\m_layouttarget_paper
438
\fi
439
\page_paper_set_current
[
\m_layouttarget_paper
][
\m_layouttarget_print
]
%
440
\fi
441
\letlayouttargetparameter
\c!page
\papersize
442
\letlayouttargetparameter
\c!paper
\printpapersize
}
443 444
\unexpanded
\def
\page_paper_setup_size_settings_by_name
[#
1
][#
2
]
%
445
{
\def
\currentlayouttarget
{
\page_paper_the_paper_size
{
#
1
}}
%
446
\setuplayouttarget
[#
2
]
}
447 448
\unexpanded
\def
\page_paper_setup_size_change_size
[#
1
][#
2
]
%
449
{
\doifelsenothing
{
#
2
}
450
{
\page_paper_set_current
[#
1
][#
1
]
}
451
{
\page_paper_set_current
[#
1
][#
2
]
}}
452 453
\let
\setuppaper
\page_paper_setup_size_settings
454 455
\unexpanded
\def
\adaptpapersize
456
{
\glet
\page_paper_reinstate
\page_paper_restore
457
\setuppapersize
}
458 459
\appendtoks
460
\page_paper_reinstate
461
\glet
\page_paper_reinstate
\relax
462
\to
\everyaftershipout
463 464
\unexpanded
\def
\page_paper_set_restore
#
1
#
2
%
465
{
\xdef
\page_paper_restore
{
\page_paper_set_current_indeed
[#
1
][#
2
]
}}
466 467
\unexpanded
\def
\page_paper_set_current
[#
1
][#
2
]
%
468
{
\normalexpanded
{
\page_paper_set_current_indeed
469
[
\page_paper_the_paper_size
{
#
1
}
]
%
470
[
\page_paper_the_print_size
{
#
2
}
]
}}
471 472
\unexpanded
\def
\page_paper_reset_paper
473
{
\global
\setfalse
\c_page_target_paper_landscape
474
\global
\setfalse
\c_page_target_paper_mirror
475
\global
\setfalse
\c_page_target_paper_negate
476
\global
\c_page_target_paper_orientation
\uprotationangle
477
\global
\c_page_target_paper_reverse
\uprotationangle
}
478 479
\unexpanded
\def
\page_paper_reset_print
480
{
\global
\setfalse
\c_page_target_print_landscape
481
\global
\setfalse
\c_page_target_print_mirror
482
\global
\setfalse
\c_page_target_print_negate
483
\global
\c_page_target_print_orientation
\uprotationangle
484
\global
\c_page_target_print_reverse
\uprotationangle
}
485 486
\letvalue
{
\??layoutpaper\v!reset
}
\page_paper_reset_paper
487
\letvalue
{
\??layoutprint\v!reset
}
\page_paper_reset_print
488 489
\setvalue
{
\??layoutpaper\v!landscape
}{
\global
\settrue
\c_page_target_paper_landscape
}
490
\setvalue
{
\??layoutpaper\v!mirrored
}{
\global
\settrue
\c_page_target_paper_mirror
}
491
\setvalue
{
\??layoutpaper\v!negative
}{
\global
\settrue
\c_page_target_paper_negate
}
492
\setvalue
{
\??layoutpaper\v!rotated
}{
\global
\c_page_target_paper_orientation
\rightrotationangle
493
\global
\c_page_target_paper_reverse
\leftrotationangle
}
494
\setvalue
{
\??layoutpaper
\number
\rightrotationangle
}{
\global
\c_page_target_paper_orientation
\rightrotationangle
495
\global
\c_page_target_paper_reverse
\leftrotationangle
}
496
\setvalue
{
\??layoutpaper
\number
\downrotationangle
}{
\global
\c_page_target_paper_orientation
\downrotationangle
497
\global
\c_page_target_paper_reverse
\zerocount
}
498
\setvalue
{
\??layoutpaper
\number
\leftrotationangle
}{
\global
\c_page_target_paper_orientation
\leftrotationangle
499
\global
\c_page_target_paper_reverse
\rightrotationangle
}
500 501
\setvalue
{
\??layoutprint\v!landscape
}{
\global
\settrue
\c_page_target_print_landscape
}
502
\setvalue
{
\??layoutprint\v!mirrored
}{
\global
\settrue
\c_page_target_print_mirror
}
503
\setvalue
{
\??layoutprint\v!negative
}{
\global
\settrue
\c_page_target_print_negate
}
504
\setvalue
{
\??layoutprint\v!rotated
}{
\global
\c_page_target_print_orientation
\rightrotationangle
505
\global
\c_page_target_print_reverse
\leftrotationangle
}
506
\setvalue
{
\??layoutprint
\number
\rightrotationangle
}{
\global
\c_page_target_print_orientation
\rightrotationangle
507
\global
\c_page_target_print_reverse
\leftrotationangle
}
508
\setvalue
{
\??layoutprint
\number
\downrotationangle
}{
\global
\c_page_target_print_orientation
\downrotationangle
509
\global
\c_page_target_print_reverse
\zerocount
}
510
\setvalue
{
\??layoutprint
\number
\leftrotationangle
}{
\global
\c_page_target_print_orientation
\leftrotationangle
511
\global
\c_page_target_print_reverse
\rightrotationangle
}
512 513
%def\page_paper_handle_page_option #1{\ifcsname\??layoutpaper#1\endcsname\csname\??layoutpaper#1\endcsname\fi}
514
%def\page_paper_handle_print_option#1{\ifcsname\??layoutprint#1\endcsname\csname\??layoutprint#1\endcsname\fi}
515 516
\def
\page_paper_handle_page_option
#
1
{
\begincsname
\??layoutpaper
#
1
\endcsname
}
517
\def
\page_paper_handle_print_option
#
1
{
\begincsname
\??layoutprint
#
1
\endcsname
}
518 519
\unexpanded
\def
\page_paper_identify_target
#
1
%
520
{
\ifcsname
\??layoutcurrent
#
1
\endcsname
521
\edef
\currentlayouttarget
{
#
1
}
%
522
\fi
}
523 524
\unexpanded
\def
\page_paper_set_current_indeed
[#
1
][#
2
]
%
525
{
\edef
\m_page_asked_paper
{
#
1
}
% can be the restores
526
\edef
\m_page_asked_print
{
#
2
}
%
527
%
528
\page_paper_set_restore
\m_page_asked_paper
\m_page_asked_print
529
%
530
% locate page target
531
\let
\currentlayouttarget
\empty
532
\page_paper_reset_paper
533
\processcommacommand
[
\m_page_asked_paper
]
\page_paper_identify_target
534
\ifx
\currentlayouttarget
\empty
535
\let
\currentlayouttarget
\currentpage
536
\fi
537
\glet
\papersize
\currentlayouttarget
538
\page_paper_reset_paper
539
\processcommacommand
[
\m_page_asked_paper
]
\page_paper_handle_page_option
540
\global
\paperwidth
\layouttargetparameter
\c!width
\relax
541
\global
\paperheight
\layouttargetparameter
\c!height
\relax
542
\ifdim
\paperwidth
<
\onepoint
543
\global
\paperwidth
\onepoint
544
\fi
545
\ifdim
\paperheight
<
\onepoint
546
\global
\paperheight
\onepoint
547
\fi
548
\ifconditional
\c_page_target_paper_landscape
549
\doglobal
\swapdimens
\paperwidth
\paperheight
550
\fi
551
\ifinpagebody
% local freeze
552
\normalexpanded
{
\setlayouttargetparemeter
\c!height
{
\the
\paperheight
}}
%
553
\normalexpanded
{
\setlayouttargetparemeter
\c!width
{
\the
\paperwidth
}}
%
554
\fi
555
%
556
\page_paper_set_offsets
557
% locate paper target
558
\page_paper_reset_print
559
\processcommacommand
[
\m_page_asked_print
]
\page_paper_identify_target
560
\glet
\printpapersize
\currentlayouttarget
561
\page_paper_reset_print
562
\processcommacommand
[
\m_page_asked_print
]
\page_paper_handle_print_option
563
\global
\printpaperwidth
\layouttargetparameter
\c!width
\relax
564
\global
\printpaperheight
\layouttargetparameter
\c!height
\relax
565
\ifdim
\printpaperwidth
<
\onepoint
566
\global
\printpaperwidth
\paperwidth
567
\fi
568
\ifdim
\printpaperheight
<
\onepoint
569
\global
\printpaperheight
\paperheight
570
\fi
571
\ifconditional
\c_page_target_print_landscape
572
\globalswapdimens
\printpaperwidth
\printpaperheight
573
\fi
574
% this check can be confusing, so we've added the possibility
575
% to bypass this test: \setuppapersize[option=fit]
576
\edef
\m_page_asked_option
{
\rootlayouttargetparameter
\c!option
}
%
577
\ifx
\m_page_asked_option
\v!max
% \v!fit is
578
\begingroup
579
% we need to pre-swap else we get the wrong paper size
580
\ifnum
\c_page_target_paper_orientation
=
\rightrotationangle
581
\swapdimens
\paperwidth
\paperheight
582
\else\ifnum
\c_page_target_paper_orientation
=
\leftrotationangle
583
\swapdimens
\paperwidth
\paperheight
584
\fi\fi
585
\ifnum
\c_page_target_print_orientation
=
\rightrotationangle
586
\swapdimens
\printpaperwidth
\printpaperheight
587
\else\ifnum
\c_page_target_print_orientation
=
\leftrotationangle
588
\swapdimens
\printpaperwidth
\printpaperheight
589
\fi\fi
590
\ifdim
\paperheight
>
\printpaperheight
591
\global
\printpaperheight
\paperheight
592
\writestatus
\m!system
{
print
height
forced
to
paper
height
}
%
593
\fi
594
\ifdim
\paperwidth
>
\printpaperwidth
595
\global
\printpaperwidth
\paperwidth
596
\writestatus
\m!system
{
print
width
forced
to
paper
width
}
%
597
\fi
598
\endgroup
599
\fi
600
%\writestatus{layout target}{(\the\paperwidth,\the\paperheight) -> (\the\printpaperwidth,\the\printpaperheight)}%
601
\page_layouts_synchronize
602
% new but we assume \setuplayout
603
\scrn_canvas_synchronize_only
}
604 605
\ifdefined
\scrn_canvas_synchronize_only
\else
606
\let
\scrn_canvas_synchronize_only
\relax
607
\fi
608 609
\ifdefined
\page_paper_set_offsets
\else
610 611
\def
\page_paper_set_offsets
% will move
612
{
\global
\paperoffset
\v_page_target_offset
613
\global\advance
\paperwidth
-
2
\paperoffset
614
\global\advance
\paperheight
-
2
\paperoffset
}
615 616
\fi
617 618
\ifdefined
\synchronizegridsnapping
\else
619
\let
\synchronizegridsnapping
\relax
620
\fi
621 622
\let
\p_page_layouts_width
\empty
623
\let
\p_page_layouts_height
\empty
624 625
\def
\page_layouts_synchronize
626
{
\setups
[
\layoutparameter
\c!preset
]
\relax
627
\global
\leftmarginwidth
\layoutparameter
\c!leftmargin
628
\global
\rightmarginwidth
\layoutparameter
\c!rightmargin
629
\global
\leftedgewidth
\layoutparameter
\c!leftedge
630
\global
\rightedgewidth
\layoutparameter
\c!rightedge
631
\global
\headerheight
\layoutparameter
\c!header
632
\global
\footerheight
\layoutparameter
\c!footer
633
\global
\bottomheight
\layoutparameter
\c!bottom
634
\global
\topheight
\layoutparameter
\c!top
635
\global
\backspace
\layoutparameter
\c!backspace
636
\global
\topspace
\layoutparameter
\c!topspace
637
\page_layouts_set_dimensions
638
\synchronizegridsnapping
639
\usesetupsparameter
\layoutparameter
% depends on gridsnapping !
640
\synchronizewhitespace
641
\synchronizeblank
642
\setupinterlinespace
[
\v!reset
]
% \synchronizegloballinespecs
643
\global
\cutspace
\layoutparameter
\c!cutspace
\relax
644
\edef
\p_page_layouts_width
{
\layoutparameter
\c!width
}
%
645
\ifx
\p_page_layouts_width
\v!middle
646
\ifzeropt
\cutspace
647
\global
\cutspace
\backspace
648
\fi
649
\global
\makeupwidth
\dimexpr
\paperwidth
-
\backspace
-
\cutspace
\relax
650
\else\ifx
\p_page_layouts_width
\v!fit
651
\ifzeropt
\cutspace
652
\global
\cutspace
\backspace
653
\fi
654
\global
\makeupwidth
\dimexpr
\paperwidth
-
\cutspace
\relax
655
\scratchdimen
\dimexpr
\backspace
656
-
\leftedgewidth
-
\leftedgedistance
657
-
\leftmarginwidth
-
\leftmargindistance
\relax
658
\ifdim
\scratchdimen
<
\zeropoint
659
\scratchdimen
\zeropoint
660
\fi
661
\global\advance
\makeupwidth
\dimexpr
662
-
\rightmargindistance
-
\rightmarginwidth
663
-
\rightedgedistance
-
\rightedgewidth
664
-
\scratchdimen
\relax
665
\else
666
\global
\makeupwidth
\p_page_layouts_width
\relax
667
\ifzeropt
\cutspace
668
\global
\cutspace
\dimexpr
\paperwidth
-
\makeupwidth
-
\backspace
\relax
669
% \else
670
% A kind of inconsistent specification, but used
671
% in for instance s-pre-19.tex; the cutspace is
672
% used only for determining some kind of right
673
% margin; don't use this in doublesided mode
674
\fi
675
\fi\fi
676
\scratchdimen
\layoutparameter
\c!bottomspace
\relax
677
%\ifzeropt\scratchdimen
678
% \scratchdimen\topspace
679
%\fi
680
\global
\bottomspace
\layoutparameter
\c!bottomspace
\relax
681
\global
\layoutlines
0
\number
\layoutparameter
\c!lines
\relax
% may be empty
682
\ifcase
\layoutlines
683
\edef
\p_page_layouts_height
{
\layoutparameter
\c!height
}
%
684
\ifx
\p_page_layouts_height
\v!middle
685
\ifzeropt
\bottomspace
686
\global
\bottomspace
\topspace
687
\fi
688
\global
\makeupheight
\dimexpr
\paperheight
-
\topspace
-
\bottomspace
\relax
689
\else\ifx
\p_page_layouts_height
\v!fit
690
\ifzeropt
\bottomspace
691
\global
\bottomspace
\topspace
692
\fi
693
\global
\makeupheight
\dimexpr
\paperheight
-
\bottomspace
\relax
694
\scratchdimen
\dimexpr
\topspace
-
\topheight
-
\topdistance
\relax
695
\ifdim
\scratchdimen
<
\zeropoint
696
\scratchdimen
\zeropoint
697
\fi
698
\global\advance
\makeupheight
\dimexpr
-
\bottomdistance
-
\bottomheight
-
\scratchdimen
\relax
699
\else
700
\global
\makeupheight
\layoutparameter
\c!height
\relax
701
\ifzeropt
\bottomspace
702
\global
\bottomspace
\dimexpr
\paperheight
-
\makeupheight
-
\topspace
\relax
703
% \else
704
% inconsistent specification
705
\fi
706
\fi\fi
707
\else
708
% beware, when the bodyfont changes (switched) this will change as well; implementing
709
% a global lineheight is tricky: should we take the bodyfont interlinespace or the one set
710
% independent of the bodyfont (before or after a layout spec); way too fuzzy, so we
711
% stick to the current method (after a night of experimenting ...2003/10/13)
712
\global
\makeupheight
\dimexpr
713
\layoutparameter
\c!lines
\lineheight
-
\strutheight
+
\topskip
+
714
\headerdistance
+
\headerheight
+
\footerdistance
+
\footerheight
\relax
715
\fi
716
\backoffset
\layoutparameter
\c!horoffset
\relax
717
\topoffset
\layoutparameter
\c!veroffset
\relax
718
\ifdim
\makeupwidth
<
\onepoint
719
\global
\makeupwidth
\onepoint
720
\fi
721
\ifdim
\makeupheight
<
\onepoint
722
\global
\makeupheight
\onepoint
723
\fi
724
% handy in page builder
725
\global
\totaltextwidth
\dimexpr
726
\leftedgetotal
727
+
\leftmargintotal
728
+
\makeupwidth
729
+
\rightmargintotal
730
+
\rightedgetotal
731
\relax
732
% \page_layouts_check_next % here ?
733
\page_layouts_check_direction
734
\page_layouts_calculate_extras
735
\page_target_check_centering
736
\calculatehsizes
737
\calculatevsizes
738
\page_layouts_check_pseudo_columns
739
\page_backgrounds_recalculate
}
740 741
\def
\page_layouts_check_direction
742
{
\edef
\p_direction
{
\layoutparameter
\c!direction
}
%
743
\ifx
\p_direction
\v!reverse
744
\globalswapdimens
\naturalleftedgedistance
\naturalrightedgedistance
745
\globalswapdimens
\naturalleftmargindistance
\naturalrightmargindistance
746
\globalswapdimens
\leftedgedistance
\rightedgedistance
747
\globalswapdimens
\leftmargindistance
\rightmargindistance
748
\globalswapdimens
\leftmarginwidth
\rightmarginwidth
749
\globalswapdimens
\leftedgewidth
\rightedgewidth
750
\globalswapdimens
\backspace
\cutspace
751
\expandafter
\setsystemmode
752
\else
753
\expandafter
\resetsystemmode
754
\fi
{
reverselayout
}}
755 756
\def
\page_layouts_check_pseudo_columns
757
{
\global
\layoutcolumns
\layoutparameter
\c!columns
758
\global
\layoutcolumndistance
\layoutparameter
\c!columndistance
759
\global
\layoutcolumnwidth
\dimexpr
\makeupwidth
-
\layoutcolumns
\layoutcolumndistance
+
\layoutcolumndistance
\relax
760
\ifnum
\layoutcolumns
>
\plusone
761
\global\divide
\layoutcolumnwidth
\layoutcolumns
762
\dorecurse
\layoutcolumns
\page_layouts_check_pseudo_column
763
\fi
}
764 765
\def
\page_layouts_check_pseudo_column
766
{
\setxvalue
{
\??layoutcolumn
\recurselevel
}
%
767
{
\the\numexpr
\recurselevel
-
\plusone
\relax\dimexpr
\layoutcolumnwidth
+
\layoutcolumndistance
\relax
}}
768 769
\letvalue
{
\??layoutcolumn
0
}
\zeropoint
770 771
\def
\layoutcolumnoffset
#
1
% can travel around so we can't use \lastnamedcs
772
{
\csname
\??layoutcolumn
\ifcsname
\??layoutcolumn
#
1
\endcsname
#
1
\else
0
\fi\endcsname
}
773 774
\def
\page_layouts_synchronize_at_start
775
{
\ifdim
\makeupheight
=
\layoutlines
\lineheight
\else
% weird check
776
\page_layouts_synchronize
777
\fi
}
778 779
\appendtoks
780
\page_layouts_synchronize_at_start
% still needed?
781
\to
\everystarttext
782 783
% document:
784
%
785
% \setuplayout[odd][state=stop] \setuplayout[even][state=stop] \setuplayout[page]
786
%
787
% \startstandardmakeup[page=blank] ... \stopstandardmakeup
788 789
\ifdefined
\lastpage
\else
\let
\lastpage
\!!plusone
\fi
790 791
\def
\page_layouts_change
#
1
%
792
{
%\writestatus\m!layouts{changing to layout #1}%
793
\xdef
\currentlayout
{
#
1
}
%
794
\page_layouts_synchronize
}
795 796
\let
\changetolayout
\page_layouts_change
% also public
797 798
\def
\v_real_page_normal
{
\the
\realpageno
}
799
\def
\v_real_page_reverse
{
-
\the\numexpr
\lastpage
-
\realpageno
\relax
}
800 801
\def
\v_real_page_odd_or_even
802
{
\ifodd
\pagenoshift
803
\ifodd
\realpageno
\v!even
\else
\v!odd
\fi
804
\else
805
\ifodd
\realpageno
\v!odd
\else
\v!even
\fi
806
\fi
}
807 808
\let
\v_real_page_current
\v!current
809 810
\def
\v_real_page_named
811
{
\ifnum
\lastpage
=
\realpageno
812
\v!last
813
\else\ifnum
\plusone
=
\realpageno
814
\v!first
815
\else
816
\__unknown__
817
\fi\fi
}
818 819
\let
\v_page_layouts_pre_check
\relax
820 821
\def
\page_layouts_check_default_indeed
#
1
%
822
{
\edef
\m_page_check
{
#
1
}
823
\edef
\m_page_state
{
\namedlayoutparameter
\m_page_check
\c!state
}
%
824
\ifx
\m_page_state
\v!start
825
\glet
\v_page_layouts_pre_check
\currentlayout
826
\glet
\currentlayout
\m_page_check
827
\page_layouts_synchronize
828
\else\ifx
\m_page_state
\v!repeat
829
\glet
\v_page_layouts_pre_check
\relax
830
\glet
\currentlayout
\m_page_check
831
\page_layouts_synchronize
832
\fi\fi
}
833 834
\def
\page_layouts_check_revert
835
{
\glet
\currentlayout
\v_page_layouts_pre_check
836
\glet
\v_page_layouts_pre_check
\relax
837
\page_layouts_synchronize
}
838 839
\def
\page_layouts_check_default
840
{
\ifcsname
\namedlayouthash
\v_real_page_normal
\c!state
\endcsname
841
\page_layouts_check_default_indeed
\v_real_page_normal
842
\else\ifcsname
\namedlayouthash
\v_real_page_reverse
\c!state
\endcsname
843
\page_layouts_check_default_indeed
\v_real_page_reverse
844
\else\ifcsname
\namedlayouthash
\v_real_page_named
\c!state
\endcsname
845
\page_layouts_check_default_indeed
\v_real_page_named
846
\else\ifcsname
\namedlayouthash
\v_real_page_current
\c!state
\endcsname
847
\page_layouts_check_default_indeed
\v_real_page_current
848
\else\ifcsname
\namedlayouthash
\v_real_page_odd_or_even
\c!state
\endcsname
849
\page_layouts_check_default_indeed
\v_real_page_odd_or_even
850
\else\ifx
\v_page_layouts_pre_check
\relax
851
% okay
852
\else
853
\page_layouts_check_revert
854
\fi\fi\fi\fi\fi\fi
}
855 856
\unexpanded
\def
\installlayoutmethod
#
1
#
2
%
857
{
\setgvalue
{
\??layoutmethod
#
1
}{
#
2
}}
858 859
\installlayoutmethod
\v!default
{
\page_layouts_check_default
}
860
\installlayoutmethod
\v!normal
{
\page_layouts_check_default
}
861 862
% \def\page_layouts_check_next
863
% {\csname\??layoutmethod\ifcsname\??layoutmethod\layoutparameter\c!method\endcsname
864
% \layoutparameter\c!method
865
% \else
866
% \v!normal
867
% \fi\endcsname}
868 869
\def
\page_layouts_check_next
870
{
\ifcsname
\??layoutmethod
\layoutparameter
\c!method
\endcsname
871
\lastnamedcs
872
\else
873
\page_layouts_check_default
874
\fi
}
875 876
\let
\checkcurrentlayout
\page_layouts_check_next
% public and used in naw, so this synonym will stay
877 878
% inheritance
879
%
880
% \definelayout
881
% [test]
882
% [width=12cm,
883
% height=10cm]
884
%
885
% \definelayout
886
% [more]
887
% [test]
888
% [height=12cm]
889
%
890
% testcase
891
%
892
% \setuppagenumbering[alternative=doublesided]
893
%
894
% \setuplayout [width=11cm]
895
% \definelayout [odd] [backspace=1cm]
896
% \definelayout [even] [backspace=4cm]
897
% \definelayout [5] [backspace=5cm]
898
% \definelayout [6] [backspace=5cm]
899
% \definelayout [-2] [backspace=0cm,cutspace=0cm]
900
% \definelayout [last] [backspace=0cm,cutspace=0cm]
901
%
902
% \checkcurrentlayout \showframe
903
%
904
% \starttext
905
% \dorecurse{20} {\input knuth \endgraf \input tufte \endgraf}
906
% \stoptext
907 908
% Because we want to keep the set parameters as they are we use some
909
% helpers to communicate between the several page building related
910
% mechanism.
911 912
\appendtoks
\page_layouts_check_next
\to
\everystarttext
913
\appendtoks
\page_layouts_check_next
\to
\everyaftershipout
914 915
\newconditional
\c_page_layouts_location_is_set
916
\newconditional
\c_page_layouts_location_is_middle
917 918
\def
\page_layouts_location_reset
% we start in the left top and mirror right pages
919
{
\setfalse
\c_page_layouts_location_is_set
920
\setfalse
\c_page_layouts_location_is_middle
921
\let
\v_page_target_left_fill
\relax
922
\let
\v_page_target_right_fill
\hss
% ? \relax
923
\let
\v_page_target_top_fill
\relax
924
\let
\v_page_target_bottom_fill
\vss
}
% \relax}
925 926
\setvalue
{
\??layoutlocation\v!right
}{
\settrue
\c_page_layouts_location_is_set
927
\setfalse
\c_page_layouts_location_is_middle
928
\let
\v_page_target_left_fill
\hss
929
\let
\v_page_target_right_fill
\relax
}
930
\setvalue
{
\??layoutlocation\v!left
}{
\settrue
\c_page_layouts_location_is_set
931
\setfalse
\c_page_layouts_location_is_middle
932
\let
\v_page_target_left_fill
\relax
933
\let
\v_page_target_right_fill
\hss
}
934
\setvalue
{
\??layoutlocation\v!bottom
}{
\settrue
\c_page_layouts_location_is_set
935
\setfalse
\c_page_layouts_location_is_middle
936
\let
\v_page_target_top_fill
\vss
937
\let
\v_page_target_bottom_fill
\relax
}
938
\setvalue
{
\??layoutlocation\v!top
}{
\settrue
\c_page_layouts_location_is_set
939
\setfalse
\c_page_layouts_location_is_middle
940
\let
\v_page_target_top_fill
\relax
941
\let
\v_page_target_bottom_fill
\vss
}
942
\setvalue
{
\??layoutlocation\v!middle
}{
\settrue
\c_page_layouts_location_is_set
943
\settrue
\c_page_layouts_location_is_middle
944
\let
\v_page_target_left_fill
\hss
945
\let
\v_page_target_right_fill
\hss
946
\let
\v_page_target_top_fill
\vss
947
\let
\v_page_target_bottom_fill
\vss
}
948
\setvalue
{
\??layoutlocation
\empty
}{
\setfalse
\c_page_layouts_location_is_set
% default also signal to scrn_
949
\setfalse
\c_page_layouts_location_is_middle
950
\let
\v_page_target_right_fill
\hss
951
\let
\v_page_target_bottom_fill
\hss
}
952
\setvalue
{
\??layoutlocation\v!doublesided
}{
\settrue
\c_page_target_print_doublesided
}
953
\setvalue
{
\??layoutlocation\v!singlesided
}{
\setfalse
\c_page_target_print_doublesided
}
954 955
\def
\page_target_check_centering_indeed
#
1
%
956
% {\ifcsname\??layoutlocation#1\endcsname\csname\??layoutlocation#1\endcsname\fi}
957
{
\begincsname
\??layoutlocation
#
1
\endcsname
}
958 959
\unexpanded
\def
\page_target_check_centering
960
{
\setfalse
\c_page_target_print_doublesided
961
\page_layouts_location_reset
962
\processcommacommand
[
\layoutparameter
\c!location
]
\page_target_check_centering_indeed
}
963 964
% installers
965 966
\def
\installlayoutalternative
#
1
#
2
%
967
{
\setgvalue
{
\??layoutalternative
#
1
}{
#
2
}}
968 969
\def
\page_boxes_construct_content_default
#
1
#
2
#
3
% targetbox flusher box
970
{
\setbox
#
1
\vpack
% was \vbox
971
{
\offinterlineskip
972
\begingroup
% needed ?
973
\uselayoutstyleandcolor
\c!style\c!color
974
\offinterlineskip
975
\page_layouts_insert_elements
% zero size
976
\endgroup
977
\page_insert_body
#
2
#
3
}}
% including footnotes
978 979
\installlayoutalternative
\v!default
{
\page_boxes_construct_content_default
}
980
\installlayoutalternative
\v!normal
{
\page_boxes_construct_content_default
}
981 982
% \def\page_boxes_construct_content % targetbox flusher box
983
% {\csname\??layoutalternative\ifcsname\??layoutalternative\layoutparameter\c!alternative\endcsname
984
% \layoutparameter\c!alternative
985
% \else
986
% \v!normal
987
% \fi\endcsname}
988 989
\def
\page_boxes_construct_content
% targetbox flusher box
990
{
\ifcsname
\??layoutalternative
\layoutparameter
\c!alternative
\endcsname
991
\expandafter\lastnamedcs
992
\else
993
\expandafter
\page_boxes_construct_content_default
994
\fi
}
995 996
%D \macros
997
%D {adaptlayout}
998 999
\installcorenamespace
{
adaptlayout
}
1000
\installcorenamespace
{
pageadaptations
}
1001 1002
\installsetuponlycommandhandler
\??adaptlayout
{
adaptlayout
}
1003 1004
\newdimen
\d_page_adepts_pushed_text_height
1005
\newdimen
\d_page_adepts_pushed_footer_height
1006
\newdimen
\d_page_adepts_height
1007
\newdimen
\d_page_adapts_delta
1008 1009
\unexpanded
\def
\adaptlayout
1010
{
\dodoubleempty
\page_adapts_layout
}
1011 1012
\def
\page_adapts_layout
[#
1
][#
2
]
%
1013
{
\ifsecondargument
1014
\processcommalist
[#
1
]
{
\page_adapts_layout_register
{
#
2
}}
%
1015
\page_adapts_check
1016
\else
1017
\page_adapts_layout_indeed
{
#
1
}
%
1018
\fi
}
1019 1020
\def
\page_adapts_layout_register
#
1
#
2
%
1021
{
\setgvalue
{
\??pageadaptations
#
2
}{
\page_adapts_layout_indeed
{
#
1
}}}
1022 1023
\let
\p_adapts_height
\zeropoint
1024
\let
\p_adapts_lines
\zerocount
1025 1026
\def
\page_adapts_layout_indeed
#
1
%
1027
{
\setupcurrentadaptlayout
[
\c!height
=
\zeropoint
,
\c!lines
=
\zerocount
,
#
1
]
%
1028
\page_adepts_push
1029
\edef
\p_adapts_height
{
\adaptlayoutparameter
\c!height
}
%
1030
\edef
\p_adapts_lines
{
\adaptlayoutparameter
\c!lines
}
%
1031
\ifx
\p_adapts_height
\v!max
1032
\global
\d_page_adepts_height
\footerheight
1033
\else
1034
\global
\d_page_adepts_height
\dimexpr
1035
\ifnum
\p_adapts_lines
=
\zerocount
1036
\p_adapts_height
1037
\else
1038
\p_adapts_lines
\openlineheight
1039
\fi
1040
\relax
1041
\ifdim
\d_page_adepts_height
>
\footerheight
1042
\global
\d_page_adepts_height
\footerheight
1043
\fi
1044
\fi
1045
\global\advance
\textheight
\d_page_adepts_height
1046
\global\advance
\footerheight
-
\d_page_adepts_height
1047
\showmessage
\m!layouts
1
{
\the
\d_page_adepts_height
,
\the
\realpageno
}
%
1048
% this will become a better one (do we need insert correction?)
1049
\page_otr_command_set_vsize
1050
%
1051
\page_backgrounds_recalculate
1052
\glet
\page_adepts_push
\relax
1053
\glet
\page_adepts_pop
\page_adepts_pop_indeed
}
1054 1055
% \def\page_adapts_check
1056
% {\csname\??pageadaptations\the\ifcsname\??pageadaptations\the\realpageno\endcsname\realpageno\else\zerocount\fi\endcsname}
1057
%
1058
% \def\page_adapts_reset
1059
% {\ifcsname\??pageadaptations\the\realpageno\endcsname
1060
% \global\undefinevalue{\??pageadaptations\the\realpageno}%
1061
% \fi}
1062 1063
\def
\page_adapts_check
1064
{
\begincsname
\??pageadaptations
\the
\realpageno
\endcsname
}
1065 1066
\def
\page_adapts_reset
1067
{
\ifcsname
\??pageadaptations
\the
\realpageno
\endcsname
1068
\expandafter
\glet
\csname
\??pageadaptations
\the
\realpageno
\endcsname\relax
1069
\fi
}
1070 1071
\def
\page_adepts_push_indeed
1072
{
\global
\d_page_adepts_pushed_text_height
\textheight
1073
\global
\d_page_adepts_pushed_footer_height
\footerheight
}
1074 1075
\def
\page_adepts_pop_indeed
1076
{
\global
\textheight
\d_page_adepts_pushed_text_height
1077
\global
\footerheight
\d_page_adepts_pushed_footer_height
1078
\page_layouts_synchronize
1079
\glet
\page_adepts_push
\page_adepts_push_indeed
1080
\glet
\page_adepts_pop
\relax
}
1081 1082
\appendtoks
\page_adapts_check
\to
\everystarttext
1083
\appendtoks
\page_adapts_reset
\to
\everyshipout
1084 1085
\let
\page_adepts_pop
\relax
1086
\let
\page_adepts_push
\page_adepts_push_indeed
1087 1088
\unexpanded
\def
\page_adapts_synchronize
% used elsewhere
1089
{
\page_adepts_pop
1090
\page_adapts_check
}
1091 1092
\def
\page_adapts_status_info
% used elsewhere
1093
{
\ifx
\page_adepts_pop
\relax
\else
1094
\space
(
adept
:
\the
\d_page_adepts_height
)
\space
1095
\fi
1096
\the
\realpageno
}
1097 1098
%D \macros
1099
%D {startlayout,stoplayout}
1100 1101
\unexpanded
\def
\startlayout
[#
1
]
%
1102
{
\page
1103
\globalpushmacro
\currentlayout
1104
\doifelselayoutdefined
{
#
1
}{
\setuplayout
[#
1
]
}
\donothing
}
% {\setuplayout[\currentlayout]}}
1105 1106
\unexpanded
\def
\stoplayout
1107
{
\page
1108
\globalpopmacro
\currentlayout
1109
\setuplayout
[
\currentlayout
]
}
1110 1111
% NOG EENS NAGAAN WANNEER NU GLOBAL EN WANNEER NIET
1112 1113
\ifx
\doifelselayoutsomeline
\undefined
% defined in page-txt
1114
\let
\doifelselayoutsomeline\secondofthreearguments
1115
\fi
1116 1117
\def
\compensatevsizeheader
{
\advance
\textheight
-
\dimexpr
\headerheight
+
\headerdistance
\relax
}
1118
\def
\compensatevsizefooter
{
\advance
\textheight
-
\dimexpr
\footerheight
+
\footerdistance
\relax
}
1119
\def
\globalcompensatevsizeheader
{
\global\advance
\textheight
-
\dimexpr
\headerheight
+
\headerdistance
\relax
}
1120
\def
\globalcompensatevsizefooter
{
\global\advance
\textheight
-
\dimexpr
\footerheight
+
\footerdistance
\relax
}
1121 1122
\def
\compensatevsizeheaderzero
{
\headerheight
\zeropoint
\page_layouts_set_distances
}
1123
\def
\compensatevsizefooterzero
{
\footerheight
\zeropoint
\page_layouts_set_distances
}
1124 1125
\def
\page_layouts_set_modes
1126
{
\ifzeropt
\headerheight
1127
\resetsystemmode
\v!header
1128
\else
1129
\setsystemmode
\v!header
1130
\fi
1131
\ifzeropt
\footerheight
1132
\resetsystemmode
\v!footer
1133
\else
1134
\setsystemmode
\v!footer
1135
\fi
}
1136 1137
\unexpanded
\def
\calculatevsizes
% name will change
1138
{
\textheight
\makeupheight
1139
\doifelselayoutsomeline
\v!header
\compensatevsizeheader
\donothing
1140
\doifelselayoutsomeline
\v!footer
\compensatevsizefooter
\donothing
1141
\page_layouts_set_modes
1142
\resetglobal
1143
\page_otr_command_set_vsize
}
1144 1145
\unexpanded
\def
\calculateglobalvsizes
% name will change
1146
{
\global
\textheight
\makeupheight
1147
\doifelselayoutsomeline
\v!header
\globalcompensatevsizeheader
\donothing
1148
\doifelselayoutsomeline
\v!footer
\globalcompensatevsizefooter
\donothing
1149
\page_layouts_set_modes
1150
\page_otr_command_set_vsize
}
1151 1152
\unexpanded
\def
\calculatereducedvsizes
% name will change
1153
{
\textheight
\makeupheight
1154
\doifelselayoutsomeline
\v!header
\compensatevsizeheader
\compensatevsizeheaderzero
1155
\doifelselayoutsomeline
\v!footer
\compensatevsizefooter
\compensatevsizefooterzero
}
1156 1157
\newdimen
\innermakeupwidth
% special purpose
1158
\newdimen
\innermakeupmargin
% special purpose
1159 1160
\newconditional
\innermakeupcompensation
\settrue
\innermakeupcompensation
1161 1162
\def
\compensatedinnermakeupmargin
1163
{
\dimexpr
\ifconditional
\innermakeupcompensation
+
\innermakeupmargin
\else
\zeropoint
\fi\relax
}
1164 1165
\unexpanded
\def
\freezetextwidth
% name will change % \makeupwidth may be set to \textwidth
1166
{
\textwidth
\makeupwidth
% which is a tricky but valid value
1167
\edef
\m_currentlayout_text_width
{
\layoutparameter
\c!textwidth
}
%
1168
\edef
\m_currentlayout_text_margin
{
\layoutparameter
\c!textmargin
}
%
1169
\ifx
\m_currentlayout_text_width
\empty
\else
1170
\textwidth
\m_currentlayout_text_width
% local
1171
\fi
1172
\global
\innermakeupwidth
\textwidth
1173
\ifx
\m_currentlayout_text_margin
\empty
1174
\global
\innermakeupmargin
\zeropoint
1175
\else
1176
\global
\innermakeupmargin
\m_currentlayout_text_margin
\relax
1177
\fi
1178
\scratchdimen
\dimexpr
\innermakeupmargin
+
\innermakeupmargin
\relax
1179
\global\advance
\innermakeupwidth
-
\scratchdimen
1180
\advance
\textwidth
-
\scratchdimen
}
% local
1181 1182
\unexpanded
\def
\calculatehsizes
% name will change
1183
{
\freezetextwidth
1184
\page_otr_command_set_hsize
}
1185 1186
%D When we start at an even page, we need to swap the layout differently. We cannot
1187
%D adapt the real page number, since it is used in cross referencing. The next
1188
%D switch is set when we start at an even page.
1189 1190
% #single #left #right
1191 1192
\def
\doifelseoddpage
1193
{
\ifodd
\pagenoshift
1194
\expandafter
\page_layouts_if_odd_else_yes
1195
\else
1196
\expandafter
\page_layouts_if_odd_else_nop
1197
\fi
}
1198 1199
\let
\doifoddpageelse\doifelseoddpage
1200 1201
\def
\page_layouts_if_odd_else_yes
1202
{
\ifodd
\realpageno
1203
\expandafter
\secondoftwoarguments
1204
\else
1205
\expandafter
\firstoftwoarguments
1206
\fi
}
1207 1208
\def
\page_layouts_if_odd_else_nop
1209
{
\ifodd
\realpageno
1210
\expandafter
\firstoftwoarguments
1211
\else
1212
\expandafter
\secondoftwoarguments
1213
\fi
}
1214 1215
\def
\page_layouts_if_odd_else_again
#
1
{
\doifelseoddpage
}
1216 1217
\def
\doifbothsidesoverruled
1218
{
\ifdoublesided
1219
\expandafter
\page_layouts_if_odd_else_again
1220
\else
1221
\expandafter
\firstofthreearguments
1222
\fi
}
1223 1224
\def
\doifbothsides
% #1 #2 #3
1225
{
\ifdoublesided
1226
\expandafter
\page_layouts_if_both_sides
1227
\else
1228
\expandafter
\firstofthreearguments
1229
\fi
}
1230 1231
\def
\page_layouts_if_both_sides
1232
{
\ifsinglesided
1233
\expandafter
\firstofthreearguments
1234
\else
1235
\expandafter
\page_layouts_if_odd_else_again
1236
\fi
}
1237 1238
\newdimen
\texthoffset
1239 1240
\def
\settexthoffset
% name will change
1241
{
\texthoffset
\doifbothsides
\backspace
\backspace
{
\dimexpr
\paperwidth
-
\backspace
-
\makeupwidth
\relax
}}
1242 1243
% The next hack is too tricky as we may shipout more pages:
1244
%
1245
% \def\freezepagestatechecks
1246
% {\the\everyfreezepagestatechecks}
1247
%
1248
% \newtoks \everyfreezepagestatechecks
1249
%
1250
% \appendtoks
1251
% \doifbothsides
1252
% {\let\doifbothsides\firstofthreearguments}%
1253
% {\let\doifbothsides\secondofthreearguments}%
1254
% {\let\doifbothsides\thirdofthreearguments}%
1255
% \rightorleftpageaction
1256
% {\let\rightorleftpageaction\firstoftwoarguments}%
1257
% {\let\rightorleftpageaction\secondoftwoarguments}%
1258
% \doifmarginswapelse
1259
% {\let\doifmarginswapelse\firstoftwoarguments}%
1260
% {\let\doifmarginswapelse\secondoftwoarguments}%
1261
% \to \everyfreezepagestatechecks
1262
%
1263
% \prependtoks
1264
% \freezepagestatechecks
1265
% \to \everybeforeshipout
1266 1267
\def
\goleftonpage
% name will change (we could cache)
1268
{
\hkern
-
\dimexpr
\leftmargindistance
+
\leftmarginwidth
+
\leftedgedistance
+
\leftedgewidth
\relax
}
1269 1270
\def
\doifelsemarginswap
#
1
#
2
%
1271
{
\doifbothsides
{
#
1
}{
#
1
}{
#
2
}}
1272 1273
\let
\doifmarginswapelse
\doifelsemarginswap
1274 1275
\def
\swapmargins
% name will change
1276
{
\doifelsemarginswap
\relax
\doswapmargins
}
1277 1278
\def
\doswapmargins
% name will change
1279
{
\let
\swapmargins
\relax
% to prevent local swapping
1280
\let
\doswapmargins
\relax
% to prevent local swapping
1281
\the
\everyswapmargins
}
1282 1283
\def
\rightorleftpageaction
1284
{
\ifdoublesided
1285
\expandafter
\page_layouts_right_or_left_page_action
1286
\else
1287
\expandafter
\firstoftwoarguments
1288
\fi
}
1289 1290
\def
\page_layouts_right_or_left_page_action
1291
{
\ifsinglesided
1292
\expandafter
\firstoftwoarguments
1293
\else
1294
\expandafter
\doifelseoddpage
1295
\fi
}
1296 1297
\def
\outermarginwidth
{
\rightorleftpageaction
\rightmarginwidth
\leftmarginwidth
}
1298
\def
\innermarginwidth
{
\rightorleftpageaction
\leftmarginwidth
\rightmarginwidth
}
1299
\def
\outermargindistance
{
\rightorleftpageaction
\rightmargindistance
\leftmargindistance
}
1300
\def
\innermargindistance
{
\rightorleftpageaction
\leftmargindistance
\rightmargindistance
}
1301 1302
\def
\outeredgewidth
{
\rightorleftpageaction
\rightedgewidth
\leftedgewidth
}
1303
\def
\inneredgewidth
{
\rightorleftpageaction
\leftedgewidth
\rightedgewidth
}
1304
\def
\outeredgedistance
{
\rightorleftpageaction
\rightedgedistance
\leftedgedistance
}
1305
\def
\inneredgedistance
{
\rightorleftpageaction
\leftedgedistance
\rightedgedistance
}
1306 1307
\def
\outerspacewidth
{
\rightorleftpageaction
\cutspace
\backspace
}
1308
\def
\innerspacewidth
{
\rightorleftpageaction
\backspace
\cutspace
}
1309 1310
\def
\leftmargintotal
{
\dimexpr
\leftmarginwidth
+
\leftmargindistance
\relax
}
1311
\def
\rightmargintotal
{
\dimexpr
\rightmarginwidth
+
\rightmargindistance
\relax
}
1312
\def
\leftedgetotal
{
\dimexpr
\leftedgewidth
+
\leftedgedistance
\relax
}
1313
\def
\rightedgetotal
{
\dimexpr
\rightedgewidth
+
\rightedgedistance
\relax
}
1314 1315
\def
\leftsidetotal
{
\dimexpr
\leftmarginwidth
+
\leftedgetotal
\relax
}
1316
\def
\rightsidetotal
{
\dimexpr
\rightmarginwidth
+
\rightedgetotal
\relax
}
1317
\def
\leftcombitotal
{
\dimexpr
\leftmargintotal
+
\leftedgetotal
\relax
}
1318
\def
\rightcombitotal
{
\dimexpr
\rightmargintotal
+
\rightedgetotal
\relax
}
1319 1320
\def
\innermargintotal
{
\dimexpr
\innermarginwidth
+
\innermargindistance
\relax
}
1321
\def
\outermargintotal
{
\dimexpr
\outermarginwidth
+
\outermargindistance
\relax
}
1322
\def
\inneredgetotal
{
\dimexpr
\inneredgewidth
+
\inneredgedistance
\relax
}
1323
\def
\outeredgetotal
{
\dimexpr
\outeredgewidth
+
\outeredgedistance
\relax
}
1324 1325
\def
\innercombitotal
{
\dimexpr
\innermargintotal
+
\inneredgetotal
\relax
}
1326
\def
\outercombitotal
{
\dimexpr
\outermargintotal
+
\outeredgetotal
\relax
}
1327
\def
\innersidetotal
{
\dimexpr
\innermarginwidth
+
\inneredgetotal
\relax
}
1328
\def
\outersidetotal
{
\dimexpr
\outermarginwidth
+
\outeredgetotal
\relax
}
1329 1330
%D \macros
1331
%D {startlocallayout}
1332
%D
1333
%D These macros should be used with care. They permit local layouts (as used in
1334
%D fitting pages, see \type {page-app.tex}). This is kind of obsolete now that we
1335
%D have \type {\definelayout}, so this hack will disappear in future versions.
1336 1337
\unexpanded
\def
\startlocallayout
1338
{
\globalpushmacro
\page_paper_restore
1339
\globalpushmacro
\currentlayout
}
1340 1341
\unexpanded
\def
\stoplocallayout
1342
{
\globalpopmacro
\currentlayout
1343
\globalpopmacro
\page_paper_restore
1344
\page_paper_restore
1345
\setuplayout
[
\currentlayout
]
\relax
}
% explicit !
1346 1347
%D \macros
1348
%D {showprint, showframe, showlayout, showsetups}
1349
%D
1350
%D We predefine a couple of tracing macros.
1351
%D
1352
%D \showsetup{showprint}
1353
%D \showsetup{showframe}
1354
%D \showsetup{showlayout}
1355
%D \showsetup{showsetups}
1356
%D %showsetup{showmargins}
1357
%D %showsetup{showgrid}
1358
%D %showsetup{showusage}
1359 1360
\fetchruntimecommand
\showprint
\f!page_run
1361
\fetchruntimecommand
\showframe
\f!page_run
1362
\fetchruntimecommand
\showlayout
\f!page_run
1363
\fetchruntimecommand
\showsetups
\f!page_run
1364
\fetchruntimecommand
\showmargins
\f!page_run
1365
\fetchruntimecommand
\showgrid
\f!page_run
1366
\fetchruntimecommand
\showusage
\f!page_run
1367 1368
\glet
\page_grids_add_to_box
\gobbleoneargument
1369
\glet
\page_grids_add_to_one
\gobbleoneargument
1370
\glet
\page_grids_add_to_mix
\gobbleoneargument
1371 1372
%D The default dimensions are quite old and will not change. The funny fractions
1373
%D were introduced when we went from fixed dimensions to relative ones. Since
1374
%D \CONTEXT\ is a dutch package, the dimensions are based on the metric system. The
1375
%D asymmetrical layout is kind of handy for short quick||and||dirty stapled
1376
%D documents.
1377
%D
1378
%D Although valid, it is not a real good idea to use dimensions based on the \type
1379
%D {em} unit. First of all, since there are no fonts loaded yet, this dimension
1380
%D makes no sense, and second, you would loose track of values, since they could
1381
%D change while going to a new page, depending on the current font setting.
1382 1383
\setuplayout
1384
[
\c!topspace
=
.
0
8
4
1
7
5
0
8
4
1
8
\paperheight
,
% 2.5cm
1385
\c!top
=
\zeropoint
,
1386
\c!topdistance
=
\zeropoint
,
1387
\c!header
=
.
0
6
7
3
4
0
0
6
7
3
4
\paperheight
,
% 2.0cm
1388
\c!headerdistance
=
\zeropoint
,
1389
\c!height
=
.
8
4
1
7
5
0
8
4
1
7
5
\paperheight
,
% 25.0cm
1390
\c!footerdistance
=
\layoutparameter
\c!headerdistance
,
1391
\c!footer
=
.
0
6
7
3
4
0
0
6
7
3
4
\paperheight
,
% 2.0cm
1392
\c!bottomdistance
=
\layoutparameter
\c!topdistance
,
1393
\c!bottom
=
\zeropoint
,
1394
\c!backspace
=
.
1
1
9
0
4
7
6
1
9
0
5
\paperwidth
,
% 2.5cm
1395
\c!edge
=
\zeropoint
,
1396
\c!edgedistance
=
\layoutparameter
\c!margindistance
,
1397
\c!margin
=
.
1
2
6
4
9
9
8
3
1
7
0
\paperwidth
,
% snijwit-2*afstand
1398
\c!margindistance
=
.
0
2
0
0
8
3
4
1
7
4
8
\paperwidth
,
% 12.0pt
1399
\c!leftedge
=
\layoutparameter
\c!edge
,
1400
\c!leftedgedistance
=
\layoutparameter
\c!edgedistance
,
1401
\c!leftmargin
=
\layoutparameter
\c!margin
,
1402
\c!leftmargindistance
=
\layoutparameter
\c!margindistance
,
1403
\c!width
=
.
7
1
4
2
8
5
7
1
4
2
9
\paperwidth
,
% 15.0cm \dimexpr\
1404
\c!rightmargindistance
=
\layoutparameter
\c!margindistance
,
1405
\c!rightmargin
=
\layoutparameter
\c!margin
,
1406
\c!rightedgedistance
=
\layoutparameter
\c!edgedistance
,
1407
\c!rightedge
=
\layoutparameter
\c!edge
,
1408
\c!veroffset
=
\zeropoint
,
1409
\c!bottomspace
=
\zeropoint
,
1410
\c!horoffset
=
\zeropoint
,
1411
\c!cutspace
=
\zeropoint
,
1412
\c!textwidth
=
,
% dangerous option -> centered / local
1413
\c!textmargin
=
,
% dangerous option -> both sides
1414
\c!textdistance
=
\zeropoint
,
% shift down on grid
1415
\c!style
=
,
1416
\c!color
=
,
1417
\c!marking
=
\v!off
,
1418
\c!location
=
,
% \v!singlesided, but unset is signal (no other default, spoils arrange)
1419
\c!state
=
\v!start
,
1420
\c!scale
=
1
,
1421
\c!sx
=
1
,
1422
\c!sy
=
1
,
1423
\c!nx
=
1
,
1424
\c!ny
=
1
,
1425
\c!dx
=
\zeropoint
,
1426
\c!dy
=
\zeropoint
,
1427
\c!grid
=
\v!no
,
1428
\c!direction
=
\v!normal
,
1429
\c!preset
=
,
1430
\c!setups
=
\systemsetupsprefix
\s!default
,
1431
\c!clipoffset
=
\zeropoint
,
1432
\c!lines
=
0
,
1433
\c!paper
=
,
% for foxet
1434
\c!page
=
,
% for foxet
1435
\c!columns
=
\plusone
,
1436
\c!columndistance
=
\zeropoint
]
1437 1438
%D First we define a whole range of (DIN) papersizes, of which the A-series makes
1439
%D most sense. We enable checking.
1440 1441
\definepapersize
[
A
0
]
[
\c!width
=
8
4
1
mm
,
\c!height
=
1
1
8
9
mm
]
1442
\definepapersize
[
A
1
]
[
\c!width
=
5
9
4
mm
,
\c!height
=
8
4
1
mm
]
1443
\definepapersize
[
A
2
]
[
\c!width
=
4
2
0
mm
,
\c!height
=
5
9
4
mm
]
1444
\definepapersize
[
A
3
]
[
\c!width
=
2
9
7
mm
,
\c!height
=
4
2
0
mm
]
1445
\definepapersize
[
A
4
]
[
\c!width
=
2
1
0
mm
,
\c!height
=
2
9
7
mm
]
1446
\definepapersize
[
A
5
]
[
\c!width
=
1
4
8
mm
,
\c!height
=
2
1
0
mm
]
1447
\definepapersize
[
A
6
]
[
\c!width
=
1
0
5
mm
,
\c!height
=
1
4
8
mm
]
1448
\definepapersize
[
A
7
]
[
\c!width
=
7
4
mm
,
\c!height
=
1
0
5
mm
]
1449
\definepapersize
[
A
8
]
[
\c!width
=
5
2
mm
,
\c!height
=
7
4
mm
]
1450
\definepapersize
[
A
9
]
[
\c!width
=
3
7
mm
,
\c!height
=
5
2
mm
]
1451
\definepapersize
[
A
1
0
]
[
\c!width
=
2
6
mm
,
\c!height
=
3
7
mm
]
1452 1453
\definepapersize
[
A
4
/
2
][
\c!width
=
\dimexpr
2
9
7
mm
/
2
\relax
,
\c!height
=
2
1
0
mm
]
% 148.5mm
1454
%definepapersize [2A5] [\c!width=296mm,\c!height=210mm] % doublewide
1455 1456
\definepapersize
[
B
0
]
[
\c!width
=
1
0
0
0
mm
,
\c!height
=
1
4
1
4
mm
]
1457
\definepapersize
[
B
1
]
[
\c!width
=
7
0
7
mm
,
\c!height
=
1
0
0
0
mm
]
1458
\definepapersize
[
B
2
]
[
\c!width
=
5
0
0
mm
,
\c!height
=
7
0
7
mm
]
1459
\definepapersize
[
B
3
]
[
\c!width
=
3
5
3
mm
,
\c!height
=
5
0
0
mm
]
% [\c!width=354mm,\c!height=500mm]
1460
\definepapersize
[
B
4
]
[
\c!width
=
2
5
0
mm
,
\c!height
=
3
5
3
mm
]
% [\c!width=250mm,\c!height=354mm]
1461
\definepapersize
[
B
5
]
[
\c!width
=
1
7
6
mm
,
\c!height
=
2
5
0
mm
]
% [\c!width=177mm,\c!height=250mm]
1462
\definepapersize
[
B
6
]
[
\c!width
=
1
2
5
mm
,
\c!height
=
1
7
6
mm
]
% [\c!width=125mm,\c!height=177mm]
1463
\definepapersize
[
B
7
]
[
\c!width
=
8
8
mm
,
\c!height
=
1
2
5
mm
]
1464
\definepapersize
[
B
8
]
[
\c!width
=
6
2
mm
,
\c!height
=
8
8
mm
]
% [\c!width=63mm,\c!height=88mm]
1465
\definepapersize
[
B
9
]
[
\c!width
=
4
4
mm
,
\c!height
=
6
2
mm
]
% [\c!width=44mm,\c!height=63mm]
1466
\definepapersize
[
B
1
0
]
[
\c!width
=
3
1
mm
,
\c!height
=
4
4
mm
]
1467 1468
\definepapersize
[
C
0
]
[
\c!width
=
9
1
7
mm
,
\c!height
=
1
2
9
7
mm
]
1469
\definepapersize
[
C
1
]
[
\c!width
=
6
4
8
mm
,
\c!height
=
9
1
7
mm
]
% [\c!width=649mm,\c!height=917mm]
1470
\definepapersize
[
C
2
]
[
\c!width
=
4
5
8
mm
,
\c!height
=
6
4
8
mm
]
% [\c!width=459mm,\c!height=649mm]
1471
\definepapersize
[
C
3
]
[
\c!width
=
3
2
4
mm
,
\c!height
=
4
5
8
mm
]
% [\c!width=324mm,\c!height=459mm]
1472
\definepapersize
[
C
4
]
[
\c!width
=
2
2
9
mm
,
\c!height
=
3
2
4
mm
]
1473
\definepapersize
[
C
5
]
[
\c!width
=
1
6
2
mm
,
\c!height
=
2
2
9
mm
]
1474
\definepapersize
[
C
6
]
[
\c!width
=
1
1
4
mm
,
\c!height
=
1
6
2
mm
]
% [\c!width=115mm,\c!height=162mm]
1475
\definepapersize
[
C
7
]
[
\c!width
=
8
1
mm
,
\c!height
=
1
1
4
mm
]
% [\c!width=81mm,\c!height=115mm]
1476
\definepapersize
[
C
8
]
[
\c!width
=
5
7
mm
,
\c!height
=
8
1
mm
]
1477
\definepapersize
[
C
9
]
[
\c!width
=
4
0
mm
,
\c!height
=
5
7
mm
]
1478
\definepapersize
[
C
1
0
]
[
\c!width
=
2
8
mm
,
\c!height
=
4
0
mm
]
1479 1480
%D Per August 2004 the rounding of some (seldom used) sizes were corrected top the
1481
%D latest DIN specifications. Peter Rolf came up with these and a few more missing
1482
%D sizes. Watch out: spaces and slashes!
1483 1484
\definepapersize
[
4
A
0
]
[
\c!width
=
1
6
8
2
mm
,
\c!height
=
2
3
7
8
mm
]
1485
\definepapersize
[
2
A
0
]
[
\c!width
=
1
1
8
9
mm
,
\c!height
=
1
6
8
2
mm
]
1486
\definepapersize
[
C
6
/
C
5
]
[
\c!width
=
1
1
4
mm
,
\c!height
=
2
2
9
mm
]
1487 1488
%D Because there are no standardized screen sizes, we define a bunch of sizes with
1489
%D $4:3$ ratios. The \type {S6} size is nearly as wide as a sheet of \type {A4}
1490
%D paper.
1491 1492
\definepapersize
[
S
3
]
[
\c!width
=
3
0
0
pt
,
\c!height
=
2
2
5
pt
]
1493
\definepapersize
[
S
4
]
[
\c!width
=
4
0
0
pt
,
\c!height
=
3
0
0
pt
]
1494
\definepapersize
[
S
5
]
[
\c!width
=
5
0
0
pt
,
\c!height
=
3
7
5
pt
]
1495
\definepapersize
[
S
6
]
[
\c!width
=
6
0
0
pt
,
\c!height
=
4
5
0
pt
]
1496
\definepapersize
[
S
8
]
[
\c!width
=
8
0
0
pt
,
\c!height
=
6
0
0
pt
]
1497
\definepapersize
[
SL
]
[
\c!width
=
6
4
0
pt
,
\c!height
=
4
0
0
pt
]
% low
1498
\definepapersize
[
SM
]
[
\c!width
=
7
2
0
pt
,
\c!height
=
4
5
0
pt
]
% medium
1499
\definepapersize
[
SW
]
[
\c!width
=
8
0
0
pt
,
\c!height
=
4
5
0
pt
]
% wide
1500
\definepapersize
[
HD
]
[
\c!width
=
1
9
2
0
pt
,
\c!height
=
1
0
8
0
pt
]
1501
\definepapersize
[
HD
+
]
[
\c!width
=
1
9
2
0
pt
,
\c!height
=
1
2
0
0
pt
]
1502
\definepapersize
[
HD
-
]
[
\c!width
=
9
6
0
pt
,
\c!height
=
5
4
0
pt
]
1503 1504
%D These are handy too:
1505 1506
\definepapersize
[
S
3
3
]
[
\c!width
=
3
0
0
pt
,
\c!height
=
3
0
0
pt
]
1507
\definepapersize
[
S
4
4
]
[
\c!width
=
4
0
0
pt
,
\c!height
=
4
0
0
pt
]
1508
\definepapersize
[
S
5
5
]
[
\c!width
=
5
0
0
pt
,
\c!height
=
5
0
0
pt
]
1509
\definepapersize
[
S
6
6
]
[
\c!width
=
6
0
0
pt
,
\c!height
=
6
0
0
pt
]
1510 1511
%D One may wonder if \TEX\ should be used for typesetting \CDROM\ covers, but it
1512
%D does not hurt to have the paper size ready.
1513 1514
\definepapersize
[
CD
]
[
\c!width
=
1
2
0
mm
,
\c!height
=
1
2
0
mm
]
1515 1516
%D The next series is for our English speaking friends who decided to stick to non
1517
%D metric values. Thanks to Nelson Beebe for completing the inch based list.
1518 1519
\definepapersize
[
letter
]
[
\c!width
=
8
.
5
in
,
\c!height
=
1
1
in
]
1520
\definepapersize
[
ledger
]
[
\c!width
=
1
1
in
,
\c!height
=
1
7
in
]
1521
\definepapersize
[
tabloid
]
[
\c!width
=
1
7
in
,
\c!height
=
1
1
in
]
1522 1523
\definepapersize
[
legal
]
[
\c!width
=
8
.
5
in
,
\c!height
=
1
4
in
]
1524
\definepapersize
[
folio
]
[
\c!width
=
8
.
5
in
,
\c!height
=
1
3
in
]
1525
\definepapersize
[
executive
]
[
\c!width
=
7
.
2
5
in
,
\c!height
=
1
0
.
5
in
]
1526 1527
\definepapersize
[
A
]
[
\c!width
=
8
.
5
in
,
\c!height
=
1
1
in
]
% 1 sheet
1528
\definepapersize
[
B
]
[
\c!width
=
1
1
in
,
\c!height
=
1
7
in
]
% 2 sheets
1529
\definepapersize
[
C
]
[
\c!width
=
1
7
in
,
\c!height
=
2
2
in
]
% 4 sheets
1530 1531
%D The next set is for Tobias Burnus, who gave me the sizes.
1532 1533
\definepapersize
[
envelope
9
]
[
\c!width
=
8
.
8
8
in
,
\c!height
=
3
.
8
8
in
]
1534
\definepapersize
[
envelope
1
0
]
[
\c!width
=
9
.
5
in
,
\c!height
=
4
.
1
3
in
]
1535
\definepapersize
[
envelope
1
1
]
[
\c!width
=
1
0
.
3
8
in
,
\c!height
=
4
.
5
in
]
1536
\definepapersize
[
envelope
1
2
]
[
\c!width
=
1
1
.
0
in
,
\c!height
=
4
.
7
5
in
]
1537
\definepapersize
[
envelope
1
4
]
[
\c!width
=
1
1
.
5
in
,
\c!height
=
5
.
0
in
]
1538
\definepapersize
[
monarch
]
[
\c!width
=
7
.
5
in
,
\c!height
=
3
.
8
8
in
]
1539
\definepapersize
[
check
]
[
\c!width
=
8
.
5
8
in
,
\c!height
=
3
.
8
8
in
]
1540
\definepapersize
[
DL
]
[
\c!width
=
1
1
0
mm
,
\c!height
=
2
2
0
mm
]
% [\c!width=220mm,\c!height=110mm]
1541
\definepapersize
[
E
4
]
[
\c!width
=
2
8
0
mm
,
\c!height
=
4
0
0
mm
]
1542 1543
%D The next three sets are supplied by Taco:
1544 1545
\definepapersize
[
RA
0
]
[
\c!width
=
8
6
0
mm
,
\c!height
=
1
2
2
0
mm
]
1546
\definepapersize
[
RA
1
]
[
\c!width
=
6
1
0
mm
,
\c!height
=
8
6
0
mm
]
1547
\definepapersize
[
RA
2
]
[
\c!width
=
4
3
0
mm
,
\c!height
=
6
1
0
mm
]
1548
\definepapersize
[
RA
3
]
[
\c!width
=
3
0
5
mm
,
\c!height
=
4
3
0
mm
]
1549
\definepapersize
[
RA
4
]
[
\c!width
=
2
1
5
mm
,
\c!height
=
3
0
5
mm
]
1550 1551
%D ISO SRA (supplementary raw A) sizes:
1552 1553
\definepapersize
[
SRA
0
]
[
\c!width
=
9
0
0
mm
,
\c!height
=
1
2
8
0
mm
]
1554
\definepapersize
[
SRA
1
]
[
\c!width
=
6
4
0
mm
,
\c!height
=
9
0
0
mm
]
1555
\definepapersize
[
SRA
2
]
[
\c!width
=
4
5
0
mm
,
\c!height
=
6
4
0
mm
]
1556
\definepapersize
[
SRA
3
]
[
\c!width
=
3
2
0
mm
,
\c!height
=
4
5
0
mm
]
1557
\definepapersize
[
SRA
4
]
[
\c!width
=
2
2
5
mm
,
\c!height
=
3
2
0
mm
]
1558 1559
%D Swedish thesis formats:
1560 1561
\definepapersize
[
G
5
]
[
\c!width
=
1
6
9
mm
,
\c!height
=
2
3
9
mm
]
1562
\definepapersize
[
E
5
]
[
\c!width
=
1
5
5
mm
,
\c!height
=
2
2
0
mm
]
1563 1564
%D Industry invention:
1565 1566
\definepapersize
[
A
3
plus
]
[
\c!width
=
3
2
9
mm
,
\c!height
=
4
8
3
mm
]
1567 1568
%D For Alan:
1569 1570
\definepapersize
[
business
]
[
\c!width
=
8
5
mm
,
\c!height
=
5
5
mm
]
1571
\definepapersize
[
businessUS
]
[
\c!width
=
3
.
5
in
,
\c!height
=
2
in
]
1572 1573
%D We can now default to a reasonable size. We match the print paper size with the
1574
%D typeset paper size. This setting should come after the first layout specification
1575
%D (already done).
1576 1577
% \definepapersize
1578
% [\v!default]
1579
% [ \c!width=\paperwidth,
1580
% \c!height=\paperheight]
1581 1582
% \definepapersize
1583
% [samesized]
1584
% [ \c!width=\paperwidth,
1585
% \c!height=\paperheight]
1586 1587
\setuppapersize
1588
[
\c!distance
=
1
.
5
cm
]
% offset is already taken
1589 1590
\definepapersize
1591
[
oversized
]
1592
[
\c!width
=
\dimexpr
\paperwidth
+
\layouttargetparameter
\c!distance
\relax
,
1593
\c!height
=
\dimexpr
\paperheight
+
\layouttargetparameter
\c!distance
\relax
]
1594 1595
\definepapersize
1596
[
undersized
]
1597
[
\c!width
=
\dimexpr
\paperwidth
-
\layouttargetparameter
\c!distance
\relax
,
1598
\c!height
=
\dimexpr
\paperheight
-
\layouttargetparameter
\c!distance
\relax
]
1599 1600
\definepapersize
1601
[
doublesized
]
1602
[
\c!width
=
\dimexpr
\paperwidth
\relax
,
1603
\c!height
=
\dimexpr
2
\paperheight
\relax
]
1604 1605
\definepapersize
1606
[
doubleoversized
]
1607
[
\c!width
=
\dimexpr
\paperwidth
+
\layouttargetparameter
\c!distance
\relax
,
1608
\c!height
=
\dimexpr
2
\paperheight
+
\layouttargetparameter
\c!distance
\relax
]
1609 1610
\definepapersize
1611
[
doublewide
]
1612
[
\c!width
=
\dimexpr
2
\paperwidth
\relax
,
1613
\c!height
=
\dimexpr
\paperheight
\relax
]
1614 1615
% \setuppapersize
1616
% [A4][A4]
1617 1618
\setuppapersize
1619
[
A
4
]
% [samesized]
1620 1621
%D A few goodies, first a full page layout:
1622 1623
\definelayout
1624
[
\v!page
]
1625 1626
\setuplayout
1627
[
\v!page
]
1628
[
\c!backspace
=
\zeropoint
,
1629
\c!cutspace
=
\zeropoint
,
1630
\c!topspace
=
\zeropoint
,
1631
\c!bottomspace
=
\zeropoint
,
1632
\c!margin
=
\zeropoint
,
1633
\c!edge
=
\zeropoint
,
1634
\c!header
=
\zeropoint
,
1635
\c!footer
=
\zeropoint
,
1636
\c!top
=
\zeropoint
,
1637
\c!bottom
=
\zeropoint
,
1638
\c!leftmargin
=
\zeropoint
,
1639
\c!rightmargin
=
\zeropoint
,
1640
\c!leftedge
=
\zeropoint
,
1641
\c!rightedge
=
\zeropoint
,
1642
\c!textdistance
=
\zeropoint
,
1643
\c!width
=
\v!middle
,
1644
\c!height
=
\v!middle
,
1645
\c!lines
=
0
,
1646
\c!grid
=
\v!no
]
1647 1648
%D A quick and dirty one:
1649 1650
\definelayout
1651
[
\v!middle
]
1652
[
\c!width
=
\v!middle
,
1653
\c!height
=
\v!middle
]
1654 1655
%D One for testing examples (5mm is often the non printable area):
1656 1657
\definelayout
1658
[
\v!tight
]
1659 1660
\definelayout
1661
[
\v!tight
]
1662
[
\v!page
]
1663
[
\c!backspace
=
5
mm
,
1664
\c!cutspace
=
5
mm
,
1665
\c!topspace
=
5
mm
,
1666
\c!bottomspace
=
5
mm
]
1667 1668
\protect
\endinput
1669