1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Page Macros Layout Specification}
15
16
17
18
19
20
21
22
23\unprotect
24
25
26
27\newdimen\paperheight \paperheight = 297mm
28\newdimen\paperwidth \paperwidth = 210mm
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
37\newdimen\makeupwidth
38
39\newdimen\textheight
40\newdimen\textwidth
41
42\newdimen\topspace \topspace = 2cm
43\newdimen\backspace \backspace = \topspace
44\newdimen\cutspace \cutspace = \zeropoint
45\newdimen\bottomspace \bottomspace = \zeropoint
46
47\newdimen\headerheight \headerheight = 2cm
48\newdimen\footerheight \footerheight = \headerheight
49
50\newdimen\topoffset \topoffset = \zeropoint
51\newdimen\backoffset \backoffset = \topoffset
52
53\newdimen\leftmarginwidth \leftmarginwidth = 3cm
54\newdimen\rightmarginwidth \rightmarginwidth = \leftmarginwidth
55
56\newdimen\leftedgewidth \leftedgewidth = 3cm
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
70
71\newdimen\margindistance
72\newdimen\edgedistance
73\newdimen\marginwidth
74\newdimen\edgewidth
75
76
77
78
79
80
81\newdimen\leftedgedistance
82\newdimen\rightedgedistance
83\newdimen\leftmargindistance
84\newdimen\rightmargindistance
85
86
87
88\newdimen\topdistance
89\newdimen\headerdistance
90\newdimen\textdistance
91\newdimen\footerdistance
92\newdimen\bottomdistance
93
94\newdimen\textovershoot
95
96
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
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
129 \or
130 \ifx\previouslayout\currentlayout
131 \letlayoutparameter\c!state\v!normal
132 \let\currentlayout\currentlayout
133 \page_layouts_synchronize
134 \page_layouts_check_next
135 \fi
136 \or
137
138 \letlayoutparameter\c!state\v!normal
139 \let\currentlayout\previouslayout
140 \page_layouts_synchronize
141 \page_layouts_check_next
142 \or
143 \ifx\currentlayout\v!reset
144 \let\currentlayout\empty
145 \fi
146 \letlayoutparameter\c!state\v!normal
147 \glet\currentlayout\currentlayout
148 \page_layouts_synchronize
149 \page_layouts_check_next
150 \or
151 \letlayoutparameter\c!state\v!normal
152 \glet\currentlayout\empty
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
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
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
202 {\headerdistance\layoutdistance\headerheight\naturalheaderdistance
203 \footerdistance\layoutdistance\footerheight\naturalfooterdistance}
204
205
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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287\installcorenamespace{layouttarget}
288\installcorenamespace{layoutpaper}
289\installcorenamespace{layoutprint}
290\installcorenamespace{layoutcurrent}
291
292\installcommandhandler \??layouttarget {layouttarget} \??layouttarget
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
334
335
336\setuplayouttarget
337 [
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
362
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
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
387
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
393
394
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]
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
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
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
514
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\newdimen\d_page_minimum_paper_size \d_page_minimum_paper_size\luaexpr{math.pi}\onebasepoint
525
526\unexpanded\def\page_paper_set_current_indeed[#1][#2]
527 {\edef\m_page_asked_paper{#1}
528 \edef\m_page_asked_print{#2}
529
530 \page_paper_set_restore\m_page_asked_paper\m_page_asked_print
531
532
533 \let\currentlayouttarget\empty
534 \page_paper_reset_paper
535 \processcommacommand[\m_page_asked_paper]\page_paper_identify_target
536 \ifx\currentlayouttarget\empty
537 \let\currentlayouttarget\currentpage
538 \fi
539 \glet\papersize\currentlayouttarget
540 \page_paper_reset_paper
541 \processcommacommand[\m_page_asked_paper]\page_paper_handle_page_option
542 \global\paperwidth \layouttargetparameter\c!width \relax
543 \global\paperheight\layouttargetparameter\c!height\relax
544 \ifdim\paperwidth<\d_page_minimum_paper_size
545 \global\paperwidth\d_page_minimum_paper_size
546 \fi
547 \ifdim\paperheight<\d_page_minimum_paper_size
548 \global\paperheight\d_page_minimum_paper_size
549 \fi
550 \ifconditional\c_page_target_paper_landscape
551 \doglobal\swapdimens\paperwidth\paperheight
552 \fi
553 \ifinpagebody
554 \normalexpanded{\setlayouttargetparameter\c!height{\the\paperheight}}
555 \normalexpanded{\setlayouttargetparameter\c!width {\the\paperwidth }}
556 \fi
557
558 \page_paper_set_offsets
559
560 \page_paper_reset_print
561 \processcommacommand[\m_page_asked_print]\page_paper_identify_target
562 \glet\printpapersize\currentlayouttarget
563 \page_paper_reset_print
564 \processcommacommand[\m_page_asked_print]\page_paper_handle_print_option
565 \global\printpaperwidth \layouttargetparameter\c!width \relax
566 \global\printpaperheight\layouttargetparameter\c!height\relax
567 \ifdim\printpaperwidth<\onepoint
568 \global\printpaperwidth\paperwidth
569 \fi
570 \ifdim\printpaperheight<\onepoint
571 \global\printpaperheight\paperheight
572 \fi
573 \ifconditional\c_page_target_print_landscape
574 \globalswapdimens\printpaperwidth\printpaperheight
575 \fi
576
577
578 \edef\m_page_asked_option{\rootlayouttargetparameter\c!option}
579 \ifx\m_page_asked_option\v!max
580 \begingroup
581
582 \ifnum\c_page_target_paper_orientation=\rightrotationangle
583 \swapdimens\paperwidth\paperheight
584 \else\ifnum\c_page_target_paper_orientation=\leftrotationangle
585 \swapdimens\paperwidth\paperheight
586 \fi\fi
587 \ifnum\c_page_target_print_orientation=\rightrotationangle
588 \swapdimens\printpaperwidth\printpaperheight
589 \else\ifnum\c_page_target_print_orientation=\leftrotationangle
590 \swapdimens\printpaperwidth\printpaperheight
591 \fi\fi
592 \ifdim\paperheight>\printpaperheight
593 \global\printpaperheight\paperheight
594 \writestatus\m!system{print height forced to paper height}
595 \fi
596 \ifdim\paperwidth>\printpaperwidth
597 \global\printpaperwidth\paperwidth
598 \writestatus\m!system{print width forced to paper width}
599 \fi
600 \endgroup
601 \fi
602
603 \page_layouts_synchronize
604
605 \scrn_canvas_synchronize_only}
606
607\ifdefined\scrn_canvas_synchronize_only \else
608 \let\scrn_canvas_synchronize_only\relax
609\fi
610
611\ifdefined\page_paper_set_offsets \else
612
613 \def\page_paper_set_offsets
614 {\global\paperoffset\v_page_target_offset
615 \global\advance\paperwidth 2\paperoffset
616 \global\advance\paperheight2\paperoffset}
617
618\fi
619
620\ifdefined\synchronizegridsnapping \else
621 \let\synchronizegridsnapping\relax
622\fi
623
624\let\p_page_layouts_width \empty
625\let\p_page_layouts_height\empty
626
627\def\page_layouts_synchronize
628 {\setups[\layoutparameter\c!preset]\relax
629 \global\leftmarginwidth \layoutparameter\c!leftmargin
630 \global\rightmarginwidth\layoutparameter\c!rightmargin
631 \global\leftedgewidth \layoutparameter\c!leftedge
632 \global\rightedgewidth \layoutparameter\c!rightedge
633 \global\headerheight \layoutparameter\c!header
634 \global\footerheight \layoutparameter\c!footer
635 \global\bottomheight \layoutparameter\c!bottom
636 \global\topheight \layoutparameter\c!top
637 \global\backspace \layoutparameter\c!backspace
638 \global\topspace \layoutparameter\c!topspace
639 \page_layouts_set_dimensions
640 \synchronizegridsnapping
641 \usesetupsparameter\layoutparameter
642 \synchronizewhitespace
643 \synchronizeblank
644 \setupinterlinespace[\v!reset]
645 \global\cutspace\layoutparameter\c!cutspace\relax
646 \edef\p_page_layouts_width{\layoutparameter\c!width}
647 \ifx\p_page_layouts_width\v!middle
648 \ifzeropt\cutspace
649 \global\cutspace\backspace
650 \fi
651 \global\makeupwidth\dimexpr\paperwidth\backspace\cutspace\relax
652 \else\ifx\p_page_layouts_width\v!fit
653 \ifzeropt\cutspace
654 \global\cutspace\backspace
655 \fi
656 \global\makeupwidth\dimexpr\paperwidth\cutspace\relax
657 \scratchdimen\dimexpr\backspace
658 \leftedgewidth \leftedgedistance
659 \leftmarginwidth\leftmargindistance\relax
660 \ifdim\scratchdimen<\zeropoint
661 \scratchdimen\zeropoint
662 \fi
663 \global\advance\makeupwidth\dimexpr
664 \rightmargindistance\rightmarginwidth
665 \rightedgedistance \rightedgewidth
666 \scratchdimen\relax
667 \else
668 \global\makeupwidth\p_page_layouts_width\relax
669 \ifzeropt\cutspace
670 \global\cutspace\dimexpr\paperwidth\makeupwidth\backspace\relax
671
672
673
674
675
676 \fi
677 \fi\fi
678 \scratchdimen\layoutparameter\c!bottomspace\relax
679
680
681
682 \global\bottomspace\layoutparameter\c!bottomspace\relax
683 \global\layoutlines0\number\layoutparameter\c!lines\relax
684 \ifcase\layoutlines
685 \edef\p_page_layouts_height{\layoutparameter\c!height}
686 \ifx\p_page_layouts_height\v!middle
687 \ifzeropt\bottomspace
688 \global\bottomspace\topspace
689 \fi
690 \global\makeupheight\dimexpr\paperheight\topspace\bottomspace\relax
691 \else\ifx\p_page_layouts_height\v!fit
692 \ifzeropt\bottomspace
693 \global\bottomspace\topspace
694 \fi
695 \global\makeupheight\dimexpr\paperheight\bottomspace\relax
696 \scratchdimen\dimexpr\topspace\topheight\topdistance\relax
697 \ifdim\scratchdimen<\zeropoint
698 \scratchdimen\zeropoint
699 \fi
700 \global\advance\makeupheight\dimexpr\bottomdistance\bottomheight\scratchdimen\relax
701 \else
702 \global\makeupheight\layoutparameter\c!height\relax
703 \ifzeropt\bottomspace
704 \global\bottomspace\dimexpr\paperheight\makeupheight\topspace\relax
705
706
707 \fi
708 \fi\fi
709 \else
710
711
712
713
714 \global\makeupheight\dimexpr
715 \layoutparameter\c!lines\lineheight\strutheight\topskip
716 \headerdistance\headerheight\footerdistance\footerheight\relax
717 \fi
718 \backoffset\layoutparameter\c!horoffset\relax
719 \topoffset \layoutparameter\c!veroffset\relax
720 \ifdim\makeupwidth<\onepoint
721 \global\makeupwidth\onepoint
722 \fi
723 \ifdim\makeupheight<\onepoint
724 \global\makeupheight\onepoint
725 \fi
726
727 \global\totaltextwidth\dimexpr
728 \leftedgetotal
729 \leftmargintotal
730 \makeupwidth
731 \rightmargintotal
732 \rightedgetotal
733 \relax
734
735 \page_layouts_check_direction
736 \page_layouts_calculate_extras
737 \page_target_check_centering
738 \calculatehsizes
739 \calculatevsizes
740 \page_layouts_check_pseudo_columns
741 \page_backgrounds_recalculate}
742
743\def\page_layouts_check_direction
744 {\edef\p_direction{\layoutparameter\c!direction}
745 \ifx\p_direction\v!reverse
746 \globalswapdimens\naturalleftedgedistance \naturalrightedgedistance
747 \globalswapdimens\naturalleftmargindistance\naturalrightmargindistance
748 \globalswapdimens\leftedgedistance \rightedgedistance
749 \globalswapdimens\leftmargindistance \rightmargindistance
750 \globalswapdimens\leftmarginwidth \rightmarginwidth
751 \globalswapdimens\leftedgewidth \rightedgewidth
752 \globalswapdimens\backspace \cutspace
753 \expandafter\setsystemmode
754 \else
755 \expandafter\resetsystemmode
756 \fi{reverselayout}}
757
758\def\page_layouts_check_pseudo_columns
759 {\global\layoutcolumns\layoutparameter\c!columns
760 \global\layoutcolumndistance\layoutparameter\c!columndistance
761 \global\layoutcolumnwidth\dimexpr\makeupwidth\layoutcolumns\layoutcolumndistance\layoutcolumndistance\relax
762 \ifnum\layoutcolumns>\plusone
763 \global\divide\layoutcolumnwidth\layoutcolumns
764 \dorecurse\layoutcolumns\page_layouts_check_pseudo_column
765 \fi}
766
767\def\page_layouts_check_pseudo_column
768 {\setxvalue{\??layoutcolumn\recurselevel}
769 {\the\numexpr\recurselevel\plusone\relax\dimexpr\layoutcolumnwidth\layoutcolumndistance\relax}}
770
771\letvalue{\??layoutcolumn0}\zeropoint
772
773\def\layoutcolumnoffset#1
774 {\csname\??layoutcolumn\ifcsname\??layoutcolumn#1\endcsname#1\else0\fi\endcsname}
775
776\def\page_layouts_synchronize_at_start
777 {\ifdim\makeupheight=\layoutlines\lineheight \else
778 \page_layouts_synchronize
779 \fi}
780
781\appendtoks
782 \page_layouts_synchronize_at_start
783\to \everystarttext
784
785
786
787
788
789
790
791\ifdefined\lastpage \else \let\lastpage\!!plusone \fi
792
793\def\page_layouts_change#1
794 {
795 \xdef\currentlayout{#1}
796 \page_layouts_synchronize}
797
798\let\changetolayout\page_layouts_change
799
800\def\v_real_page_normal {\the\realpageno}
801\def\v_real_page_reverse{\the\numexpr\lastpage\realpageno\relax}
802
803\def\v_real_page_odd_or_even
804 {\ifodd\pagenoshift
805 \ifodd\realpageno\v!even\else\v!odd \fi
806 \else
807 \ifodd\realpageno\v!odd \else\v!even\fi
808 \fi}
809
810\let\v_real_page_current\v!current
811
812\def\v_real_page_named
813 {\ifnum\lastpage=\realpageno
814 \v!last
815 \else\ifnum\plusone=\realpageno
816 \v!first
817 \else
818 \__unknown__
819 \fi\fi}
820
821\let\v_page_layouts_pre_check\relax
822
823\def\page_layouts_check_default_indeed#1
824 {\edef\m_page_check{#1}
825 \edef\m_page_state{\namedlayoutparameter\m_page_check\c!state}
826 \ifx\m_page_state\v!start
827 \glet\v_page_layouts_pre_check\currentlayout
828 \glet\currentlayout\m_page_check
829 \page_layouts_synchronize
830 \else\ifx\m_page_state\v!repeat
831 \glet\v_page_layouts_pre_check\relax
832 \glet\currentlayout\m_page_check
833 \page_layouts_synchronize
834 \fi\fi}
835
836\def\page_layouts_check_revert
837 {\glet\currentlayout\v_page_layouts_pre_check
838 \glet\v_page_layouts_pre_check\relax
839 \page_layouts_synchronize}
840
841\def\page_layouts_check_default
842 {\ifcsname\namedlayouthash\v_real_page_normal\c!state\endcsname
843 \page_layouts_check_default_indeed\v_real_page_normal
844 \else\ifcsname\namedlayouthash\v_real_page_reverse\c!state\endcsname
845 \page_layouts_check_default_indeed\v_real_page_reverse
846 \else\ifcsname\namedlayouthash\v_real_page_named\c!state\endcsname
847 \page_layouts_check_default_indeed\v_real_page_named
848 \else\ifcsname\namedlayouthash\v_real_page_current\c!state\endcsname
849 \page_layouts_check_default_indeed\v_real_page_current
850 \else\ifcsname\namedlayouthash\v_real_page_odd_or_even\c!state\endcsname
851 \page_layouts_check_default_indeed\v_real_page_odd_or_even
852 \else\ifx\v_page_layouts_pre_check\relax
853
854 \else
855 \page_layouts_check_revert
856 \fi\fi\fi\fi\fi\fi}
857
858\unexpanded\def\installlayoutmethod#1#2
859 {\setgvalue{\??layoutmethod#1}{#2}}
860
861\installlayoutmethod\v!default{\page_layouts_check_default}
862\installlayoutmethod\v!normal {\page_layouts_check_default}
863
864
865
866
867
868
869
870
871\def\page_layouts_check_next
872 {\ifcsname\??layoutmethod\layoutparameter\c!method\endcsname
873 \lastnamedcs
874 \else
875 \page_layouts_check_default
876 \fi}
877
878\let\checkcurrentlayout\page_layouts_check_next
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914\appendtoks \page_layouts_check_next \to \everystarttext
915\appendtoks \page_layouts_check_next \to \everyaftershipout
916
917\newconditional\c_page_layouts_location_is_set
918\newconditional\c_page_layouts_location_is_middle
919
920\def\page_layouts_location_reset
921 {\setfalse\c_page_layouts_location_is_set
922 \setfalse\c_page_layouts_location_is_middle
923 \let\v_page_target_left_fill \relax
924 \let\v_page_target_right_fill \hss
925 \let\v_page_target_top_fill \relax
926 \let\v_page_target_bottom_fill\vss}
927
928\setvalue{\??layoutlocation\v!right }{\settrue\c_page_layouts_location_is_set
929 \setfalse\c_page_layouts_location_is_middle
930 \let\v_page_target_left_fill \hss
931 \let\v_page_target_right_fill \relax}
932\setvalue{\??layoutlocation\v!left }{\settrue\c_page_layouts_location_is_set
933 \setfalse\c_page_layouts_location_is_middle
934 \let\v_page_target_left_fill \relax
935 \let\v_page_target_right_fill \hss}
936\setvalue{\??layoutlocation\v!bottom }{\settrue\c_page_layouts_location_is_set
937 \setfalse\c_page_layouts_location_is_middle
938 \let\v_page_target_top_fill \vss
939 \let\v_page_target_bottom_fill\relax}
940\setvalue{\??layoutlocation\v!top }{\settrue\c_page_layouts_location_is_set
941 \setfalse\c_page_layouts_location_is_middle
942 \let\v_page_target_top_fill \relax
943 \let\v_page_target_bottom_fill\vss}
944\setvalue{\??layoutlocation\v!middle }{\settrue\c_page_layouts_location_is_set
945 \settrue\c_page_layouts_location_is_middle
946 \let\v_page_target_left_fill \hss
947 \let\v_page_target_right_fill \hss
948 \let\v_page_target_top_fill \vss
949 \let\v_page_target_bottom_fill\vss}
950\setvalue{\??layoutlocation\empty }{\setfalse\c_page_layouts_location_is_set
951 \setfalse\c_page_layouts_location_is_middle
952 \let\v_page_target_right_fill \hss
953 \let\v_page_target_bottom_fill\hss}
954\setvalue{\??layoutlocation\v!doublesided}{\settrue \c_page_target_print_doublesided}
955\setvalue{\??layoutlocation\v!singlesided}{\setfalse\c_page_target_print_doublesided}
956
957\def\page_target_check_centering_indeed#1
958
959 {\begincsname\??layoutlocation#1\endcsname}
960
961\unexpanded\def\page_target_check_centering
962 {\setfalse\c_page_target_print_doublesided
963 \page_layouts_location_reset
964 \processcommacommand[\layoutparameter\c!location]\page_target_check_centering_indeed}
965
966
967
968\def\installlayoutalternative#1#2
969 {\setgvalue{\??layoutalternative#1}{#2}}
970
971\def\page_boxes_construct_content_default#1#2#3
972 {\setbox#1\vpack
973 {\offinterlineskip
974 \begingroup
975 \uselayoutstyleandcolor\c!style\c!color
976 \offinterlineskip
977 \page_layouts_insert_elements
978 \endgroup
979 \page_insert_body#2#3}}
980
981\installlayoutalternative\v!default{\page_boxes_construct_content_default}
982\installlayoutalternative\v!normal {\page_boxes_construct_content_default}
983
984
985
986
987
988
989
990
991\def\page_boxes_construct_content
992 {\ifcsname\??layoutalternative\layoutparameter\c!alternative\endcsname
993 \expandafter\lastnamedcs
994 \else
995 \expandafter\page_boxes_construct_content_default
996 \fi}
997
998
999
1000
1001\installcorenamespace{adaptlayout}
1002\installcorenamespace{pageadaptations}
1003
1004\installsetuponlycommandhandler \??adaptlayout {adaptlayout}
1005
1006\newdimen\d_page_adepts_pushed_text_height
1007\newdimen\d_page_adepts_pushed_footer_height
1008\newdimen\d_page_adepts_height
1009\newdimen\d_page_adapts_delta
1010
1011\unexpanded\def\adaptlayout
1012 {\dodoubleempty\page_adapts_layout}
1013
1014\def\page_adapts_layout[#1][#2]
1015 {\ifsecondargument
1016 \processcommalist[#1]{\page_adapts_layout_register{#2}}
1017 \page_adapts_check
1018 \else
1019 \page_adapts_layout_indeed{#1}
1020 \fi}
1021
1022\def\page_adapts_layout_register#1#2
1023 {\setgvalue{\??pageadaptations#2}{\page_adapts_layout_indeed{#1}}}
1024
1025\let\p_adapts_height\zeropoint
1026\let\p_adapts_lines \zerocount
1027
1028\def\page_adapts_layout_indeed#1
1029 {\setupcurrentadaptlayout[\c!height=\zeropoint,\c!lines=\zerocount,#1]
1030 \page_adepts_push
1031 \edef\p_adapts_height{\adaptlayoutparameter\c!height}
1032 \edef\p_adapts_lines {\adaptlayoutparameter\c!lines}
1033 \ifx\p_adapts_height\v!max
1034 \global\d_page_adepts_height\footerheight
1035 \else
1036 \global\d_page_adepts_height\dimexpr
1037 \ifnum\p_adapts_lines=\zerocount
1038 \p_adapts_height
1039 \else
1040 \p_adapts_lines\openlineheight
1041 \fi
1042 \relax
1043 \ifdim\d_page_adepts_height>\footerheight
1044 \global\d_page_adepts_height\footerheight
1045 \fi
1046 \fi
1047 \global\advance\textheight \d_page_adepts_height
1048 \global\advance\footerheight\d_page_adepts_height
1049 \showmessage\m!layouts1{\the\d_page_adepts_height,\the\realpageno}
1050
1051 \page_otr_command_set_vsize
1052
1053 \page_backgrounds_recalculate
1054 \glet\page_adepts_push\relax
1055 \glet\page_adepts_pop\page_adepts_pop_indeed}
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065\def\page_adapts_check
1066 {\begincsname\??pageadaptations\the\realpageno\endcsname}
1067
1068\def\page_adapts_reset
1069 {\ifcsname\??pageadaptations\the\realpageno\endcsname
1070 \expandafter\glet\csname\??pageadaptations\the\realpageno\endcsname\relax
1071 \fi}
1072
1073\def\page_adepts_push_indeed
1074 {\global\d_page_adepts_pushed_text_height \textheight
1075 \global\d_page_adepts_pushed_footer_height\footerheight}
1076
1077\def\page_adepts_pop_indeed
1078 {\global\textheight \d_page_adepts_pushed_text_height
1079 \global\footerheight\d_page_adepts_pushed_footer_height
1080 \page_layouts_synchronize
1081 \glet\page_adepts_push\page_adepts_push_indeed
1082 \glet\page_adepts_pop\relax}
1083
1084\appendtoks \page_adapts_check \to \everystarttext
1085\appendtoks \page_adapts_reset \to \everyshipout
1086
1087\let\page_adepts_pop \relax
1088\let\page_adepts_push\page_adepts_push_indeed
1089
1090\unexpanded\def\page_adapts_synchronize
1091 {\page_adepts_pop
1092 \page_adapts_check}
1093
1094\def\page_adapts_status_info
1095 {\ifx\page_adepts_pop\relax \else
1096 \space(adept: \the\d_page_adepts_height)\space
1097 \fi
1098 \the\realpageno}
1099
1100
1101
1102
1103\unexpanded\def\startlayout[#1]
1104 {\page
1105 \globalpushmacro\currentlayout
1106 \doifelselayoutdefined{#1}{\setuplayout[#1]}\donothing}
1107
1108\unexpanded\def\stoplayout
1109 {\page
1110 \globalpopmacro\currentlayout
1111 \setuplayout[\currentlayout]}
1112
1113
1114
1115\ifx\doifelselayoutsomeline\undefined
1116 \let\doifelselayoutsomeline\secondofthreearguments
1117\fi
1118
1119\def\compensatevsizeheader {\advance\textheight\dimexpr\headerheight\headerdistance\relax}
1120\def\compensatevsizefooter {\advance\textheight\dimexpr\footerheight\footerdistance\relax}
1121\def\globalcompensatevsizeheader{\global\advance\textheight\dimexpr\headerheight\headerdistance\relax}
1122\def\globalcompensatevsizefooter{\global\advance\textheight\dimexpr\footerheight\footerdistance\relax}
1123
1124\def\compensatevsizeheaderzero{\headerheight\zeropoint\page_layouts_set_distances}
1125\def\compensatevsizefooterzero{\footerheight\zeropoint\page_layouts_set_distances}
1126
1127\def\page_layouts_set_modes
1128 {\ifzeropt\headerheight
1129 \resetsystemmode\v!header
1130 \else
1131 \setsystemmode\v!header
1132 \fi
1133 \ifzeropt\footerheight
1134 \resetsystemmode\v!footer
1135 \else
1136 \setsystemmode\v!footer
1137 \fi}
1138
1139\unexpanded\def\calculatevsizes
1140 {\textheight\makeupheight
1141 \doifelselayoutsomeline\v!header\compensatevsizeheader\donothing
1142 \doifelselayoutsomeline\v!footer\compensatevsizefooter\donothing
1143 \page_layouts_set_modes
1144 \resetglobal
1145 \page_otr_command_set_vsize}
1146
1147\unexpanded\def\calculateglobalvsizes
1148 {\global\textheight\makeupheight
1149 \doifelselayoutsomeline\v!header\globalcompensatevsizeheader\donothing
1150 \doifelselayoutsomeline\v!footer\globalcompensatevsizefooter\donothing
1151 \page_layouts_set_modes
1152 \page_otr_command_set_vsize}
1153
1154\unexpanded\def\calculatereducedvsizes
1155 {\textheight\makeupheight
1156 \doifelselayoutsomeline\v!header\compensatevsizeheader\compensatevsizeheaderzero
1157 \doifelselayoutsomeline\v!footer\compensatevsizefooter\compensatevsizefooterzero}
1158
1159\newdimen\innermakeupwidth
1160\newdimen\innermakeupmargin
1161
1162\newconditional\innermakeupcompensation \settrue\innermakeupcompensation
1163
1164\def\compensatedinnermakeupmargin
1165 {\dimexpr\ifconditional\innermakeupcompensation\innermakeupmargin\else\zeropoint\fi\relax}
1166
1167\unexpanded\def\freezetextwidth
1168 {\textwidth\makeupwidth
1169 \edef\m_currentlayout_text_width {\layoutparameter\c!textwidth }
1170 \edef\m_currentlayout_text_margin{\layoutparameter\c!textmargin}
1171 \ifx\m_currentlayout_text_width\empty \else
1172 \textwidth\m_currentlayout_text_width
1173 \fi
1174 \global\innermakeupwidth\textwidth
1175 \ifx\m_currentlayout_text_margin\empty
1176 \global\innermakeupmargin\zeropoint
1177 \else
1178 \global\innermakeupmargin\m_currentlayout_text_margin\relax
1179 \fi
1180 \scratchdimen\dimexpr\innermakeupmargin\innermakeupmargin\relax
1181 \global\advance\innermakeupwidth\scratchdimen
1182 \advance\textwidth\scratchdimen}
1183
1184\unexpanded\def\calculatehsizes
1185 {\freezetextwidth
1186 \page_otr_command_set_hsize}
1187
1188
1189
1190
1191
1192
1193
1194\def\doifelseoddpage
1195 {\ifodd\pagenoshift
1196 \expandafter\page_layouts_if_odd_else_yes
1197 \else
1198 \expandafter\page_layouts_if_odd_else_nop
1199 \fi}
1200
1201\let\doifoddpageelse\doifelseoddpage
1202
1203\def\page_layouts_if_odd_else_yes
1204 {\ifodd\realpageno
1205 \expandafter\secondoftwoarguments
1206 \else
1207 \expandafter\firstoftwoarguments
1208 \fi}
1209
1210\def\page_layouts_if_odd_else_nop
1211 {\ifodd\realpageno
1212 \expandafter\firstoftwoarguments
1213 \else
1214 \expandafter\secondoftwoarguments
1215 \fi}
1216
1217\def\page_layouts_if_odd_else_again#1{\doifelseoddpage}
1218
1219\def\doifbothsidesoverruled
1220 {\ifdoublesided
1221 \expandafter\page_layouts_if_odd_else_again
1222 \else
1223 \expandafter\firstofthreearguments
1224 \fi}
1225
1226\def\doifbothsides
1227 {\ifdoublesided
1228 \expandafter\page_layouts_if_both_sides
1229 \else
1230 \expandafter\firstofthreearguments
1231 \fi}
1232
1233\def\page_layouts_if_both_sides
1234 {\ifsinglesided
1235 \expandafter\firstofthreearguments
1236 \else
1237 \expandafter\page_layouts_if_odd_else_again
1238 \fi}
1239
1240\newdimen\texthoffset
1241
1242\def\settexthoffset
1243 {\texthoffset\doifbothsides\backspace\backspace{\dimexpr\paperwidth\backspace\makeupwidth\relax}}
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269\def\goleftonpage
1270 {\hkern\dimexpr\leftmargindistance\leftmarginwidth\leftedgedistance\leftedgewidth\relax}
1271
1272\def\doifelsemarginswap#1#2
1273 {\doifbothsides{#1}{#1}{#2}}
1274
1275\let\doifmarginswapelse\doifelsemarginswap
1276
1277\def\swapmargins
1278 {\doifelsemarginswap\relax\doswapmargins}
1279
1280\def\doswapmargins
1281 {\let\swapmargins \relax
1282 \let\doswapmargins\relax
1283 \the\everyswapmargins}
1284
1285\def\rightorleftpageaction
1286 {\ifdoublesided
1287 \expandafter\page_layouts_right_or_left_page_action
1288 \else
1289 \expandafter\firstoftwoarguments
1290 \fi}
1291
1292\def\page_layouts_right_or_left_page_action
1293 {\ifsinglesided
1294 \expandafter\firstoftwoarguments
1295 \else
1296 \expandafter\doifelseoddpage
1297 \fi}
1298
1299\def\outermarginwidth {\rightorleftpageaction\rightmarginwidth \leftmarginwidth }
1300\def\innermarginwidth {\rightorleftpageaction\leftmarginwidth \rightmarginwidth}
1301\def\outermargindistance{\rightorleftpageaction\rightmargindistance\leftmargindistance }
1302\def\innermargindistance{\rightorleftpageaction\leftmargindistance \rightmargindistance}
1303
1304\def\outeredgewidth {\rightorleftpageaction\rightedgewidth \leftedgewidth }
1305\def\inneredgewidth {\rightorleftpageaction\leftedgewidth \rightedgewidth}
1306\def\outeredgedistance {\rightorleftpageaction\rightedgedistance\leftedgedistance }
1307\def\inneredgedistance {\rightorleftpageaction\leftedgedistance \rightedgedistance}
1308
1309\def\outerspacewidth {\rightorleftpageaction\cutspace \backspace}
1310\def\innerspacewidth {\rightorleftpageaction\backspace\cutspace }
1311
1312\def\leftmargintotal {\dimexpr\leftmarginwidth \leftmargindistance \relax}
1313\def\rightmargintotal {\dimexpr\rightmarginwidth\rightmargindistance\relax}
1314\def\leftedgetotal {\dimexpr\leftedgewidth \leftedgedistance \relax}
1315\def\rightedgetotal {\dimexpr\rightedgewidth \rightedgedistance \relax}
1316
1317\def\leftsidetotal {\dimexpr\leftmarginwidth \leftedgetotal \relax}
1318\def\rightsidetotal {\dimexpr\rightmarginwidth\rightedgetotal\relax}
1319\def\leftcombitotal {\dimexpr\leftmargintotal \leftedgetotal \relax}
1320\def\rightcombitotal {\dimexpr\rightmargintotal\rightedgetotal\relax}
1321
1322\def\innermargintotal {\dimexpr\innermarginwidth\innermargindistance\relax}
1323\def\outermargintotal {\dimexpr\outermarginwidth\outermargindistance\relax}
1324\def\inneredgetotal {\dimexpr\inneredgewidth \inneredgedistance \relax}
1325\def\outeredgetotal {\dimexpr\outeredgewidth \outeredgedistance \relax}
1326
1327\def\innercombitotal {\dimexpr\innermargintotal\inneredgetotal\relax}
1328\def\outercombitotal {\dimexpr\outermargintotal\outeredgetotal\relax}
1329\def\innersidetotal {\dimexpr\innermarginwidth\inneredgetotal\relax}
1330\def\outersidetotal {\dimexpr\outermarginwidth\outeredgetotal\relax}
1331
1332
1333
1334
1335
1336
1337
1338
1339\unexpanded\def\startlocallayout
1340 {\globalpushmacro\page_paper_restore
1341 \globalpushmacro\currentlayout}
1342
1343\unexpanded\def\stoplocallayout
1344 {\globalpopmacro\currentlayout
1345 \globalpopmacro\page_paper_restore
1346 \page_paper_restore
1347 \setuplayout[\currentlayout]\relax}
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362\fetchruntimecommand \showprint \f!page_run
1363\fetchruntimecommand \showframe \f!page_run
1364\fetchruntimecommand \showlayout \f!page_run
1365\fetchruntimecommand \showsetups \f!page_run
1366\fetchruntimecommand \showmargins \f!page_run
1367\fetchruntimecommand \showgrid \f!page_run
1368
1369\glet\page_grids_add_to_box\gobbleoneargument
1370\glet\page_grids_add_to_one\gobbleoneargument
1371\glet\page_grids_add_to_mix\gobbleoneargument
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384\setuplayout
1385 [ \c!topspace=.08417508418\paperheight,
1386 \c!top=\zeropoint,
1387 \c!topdistance=\zeropoint,
1388 \c!header=.06734006734\paperheight,
1389 \c!headerdistance=\zeropoint,
1390 \c!height=.84175084175\paperheight,
1391 \c!footerdistance=\layoutparameter\c!headerdistance,
1392 \c!footer=.06734006734\paperheight,
1393 \c!bottomdistance=\layoutparameter\c!topdistance,
1394 \c!bottom=\zeropoint,
1395 \c!backspace=.11904761905\paperwidth,
1396 \c!edge=\zeropoint,
1397 \c!edgedistance=\layoutparameter\c!margindistance,
1398 \c!margin=.12649983170\paperwidth,
1399 \c!margindistance=.02008341748\paperwidth,
1400 \c!leftedge=\layoutparameter\c!edge,
1401 \c!leftedgedistance=\layoutparameter\c!edgedistance,
1402 \c!leftmargin=\layoutparameter\c!margin,
1403 \c!leftmargindistance=\layoutparameter\c!margindistance,
1404 \c!width=.71428571429\paperwidth,
1405 \c!rightmargindistance=\layoutparameter\c!margindistance,
1406 \c!rightmargin=\layoutparameter\c!margin,
1407 \c!rightedgedistance=\layoutparameter\c!edgedistance,
1408 \c!rightedge=\layoutparameter\c!edge,
1409 \c!veroffset=\zeropoint,
1410 \c!bottomspace=\zeropoint,
1411 \c!horoffset=\zeropoint,
1412 \c!cutspace=\zeropoint,
1413 \c!textwidth=,
1414 \c!textmargin=,
1415 \c!textdistance=\zeropoint,
1416 \c!style=,
1417 \c!color=,
1418 \c!marking=\v!off,
1419 \c!location=,
1420 \c!state=\v!start,
1421 \c!scale=1,
1422 \c!sx=1,
1423 \c!sy=1,
1424 \c!nx=1,
1425 \c!ny=1,
1426 \c!dx=\zeropoint,
1427 \c!dy=\zeropoint,
1428 \c!grid=\v!no,
1429 \c!direction=\v!normal,
1430 \c!preset=,
1431 \c!setups=\systemsetupsprefix\s!default,
1432 \c!clipoffset=\zeropoint,
1433 \c!lines=0,
1434 \c!paper=,
1435 \c!page=,
1436 \c!columns=\plusone,
1437 \c!columndistance=\zeropoint]
1438
1439
1440
1441
1442\definepapersize [A0] [\c!width=841mm,\c!height=1189mm]
1443\definepapersize [A1] [\c!width=594mm,\c!height=841mm]
1444\definepapersize [A2] [\c!width=420mm,\c!height=594mm]
1445\definepapersize [A3] [\c!width=297mm,\c!height=420mm]
1446\definepapersize [A4] [\c!width=210mm,\c!height=297mm]
1447\definepapersize [A5] [\c!width=148mm,\c!height=210mm]
1448\definepapersize [A6] [\c!width=105mm,\c!height=148mm]
1449\definepapersize [A7] [\c!width=74mm,\c!height=105mm]
1450\definepapersize [A8] [\c!width=52mm,\c!height=74mm]
1451\definepapersize [A9] [\c!width=37mm,\c!height=52mm]
1452\definepapersize [A10] [\c!width=26mm,\c!height=37mm]
1453
1454\definepapersize [A42][\c!width=\dimexpr297mm2\relax,\c!height=210mm]
1455
1456
1457\definepapersize [B0] [\c!width=1000mm,\c!height=1414mm]
1458\definepapersize [B1] [\c!width=707mm,\c!height=1000mm]
1459\definepapersize [B2] [\c!width=500mm,\c!height=707mm]
1460\definepapersize [B3] [\c!width=353mm,\c!height=500mm]
1461\definepapersize [B4] [\c!width=250mm,\c!height=353mm]
1462\definepapersize [B5] [\c!width=176mm,\c!height=250mm]
1463\definepapersize [B6] [\c!width=125mm,\c!height=176mm]
1464\definepapersize [B7] [\c!width=88mm,\c!height=125mm]
1465\definepapersize [B8] [\c!width=62mm,\c!height=88mm]
1466\definepapersize [B9] [\c!width=44mm,\c!height=62mm]
1467\definepapersize [B10] [\c!width=31mm,\c!height=44mm]
1468
1469\definepapersize [C0] [\c!width=917mm,\c!height=1297mm]
1470\definepapersize [C1] [\c!width=648mm,\c!height=917mm]
1471\definepapersize [C2] [\c!width=458mm,\c!height=648mm]
1472\definepapersize [C3] [\c!width=324mm,\c!height=458mm]
1473\definepapersize [C4] [\c!width=229mm,\c!height=324mm]
1474\definepapersize [C5] [\c!width=162mm,\c!height=229mm]
1475\definepapersize [C6] [\c!width=114mm,\c!height=162mm]
1476\definepapersize [C7] [\c!width=81mm,\c!height=114mm]
1477\definepapersize [C8] [\c!width=57mm,\c!height=81mm]
1478\definepapersize [C9] [\c!width=40mm,\c!height=57mm]
1479\definepapersize [C10] [\c!width=28mm,\c!height=40mm]
1480
1481
1482
1483
1484
1485\definepapersize [4 A0] [\c!width=1682mm,\c!height=2378mm]
1486\definepapersize [2 A0] [\c!width=1189mm,\c!height=1682mm]
1487\definepapersize [C6C5] [\c!width=114mm,\c!height=229mm]
1488
1489
1490
1491
1492
1493\definepapersize [S3] [\c!width=300pt,\c!height=225pt]
1494\definepapersize [S4] [\c!width=400pt,\c!height=300pt]
1495\definepapersize [S5] [\c!width=500pt,\c!height=375pt]
1496\definepapersize [S6] [\c!width=600pt,\c!height=450pt]
1497\definepapersize [S8] [\c!width=800pt,\c!height=600pt]
1498\definepapersize [SL] [\c!width=640pt,\c!height=400pt]
1499\definepapersize [SM] [\c!width=720pt,\c!height=450pt]
1500\definepapersize [SW] [\c!width=800pt,\c!height=450pt]
1501\definepapersize [HD] [\c!width=1920pt,\c!height=1080pt]
1502\definepapersize [HD] [\c!width=1920pt,\c!height=1200pt]
1503\definepapersize [HD] [\c!width=960pt,\c!height=540pt]
1504
1505
1506
1507\definepapersize [S33] [\c!width=300pt,\c!height=300pt]
1508\definepapersize [S44] [\c!width=400pt,\c!height=400pt]
1509\definepapersize [S55] [\c!width=500pt,\c!height=500pt]
1510\definepapersize [S66] [\c!width=600pt,\c!height=600pt]
1511
1512
1513
1514
1515\definepapersize [CD] [\c!width=120mm,\c!height=120mm]
1516
1517
1518
1519
1520\definepapersize [letter] [\c!width=8.5in,\c!height=11in]
1521\definepapersize [ledger] [\c!width=11in,\c!height=17in]
1522\definepapersize [tabloid] [\c!width=17in,\c!height=11in]
1523
1524\definepapersize [legal] [\c!width=8.5in,\c!height=14in]
1525\definepapersize [folio] [\c!width=8.5in,\c!height=13in]
1526\definepapersize [executive] [\c!width=7.25in,\c!height=10.5in]
1527
1528\definepapersize [A] [\c!width=8.5in,\c!height=11in]
1529\definepapersize [B] [\c!width=11in,\c!height=17in]
1530\definepapersize [C] [\c!width=17in,\c!height=22in]
1531
1532
1533
1534\definepapersize [envelope 9] [\c!width=8.88in,\c!height=3.88in]
1535\definepapersize [envelope 10] [\c!width=9.5in,\c!height=4.13in]
1536\definepapersize [envelope 11] [\c!width=10.38in,\c!height=4.5in]
1537\definepapersize [envelope 12] [\c!width=11.0in,\c!height=4.75in]
1538\definepapersize [envelope 14] [\c!width=11.5in,\c!height=5.0in]
1539\definepapersize [monarch] [\c!width=7.5in,\c!height=3.88in]
1540\definepapersize [check] [\c!width=8.58in,\c!height=3.88in]
1541\definepapersize [DL] [\c!width=110mm,\c!height=220mm]
1542\definepapersize [E4] [\c!width=280mm,\c!height=400mm]
1543
1544
1545
1546\definepapersize [RA0] [\c!width=860mm,\c!height=1220mm]
1547\definepapersize [RA1] [\c!width=610mm,\c!height=860mm]
1548\definepapersize [RA2] [\c!width=430mm,\c!height=610mm]
1549\definepapersize [RA3] [\c!width=305mm,\c!height=430mm]
1550\definepapersize [RA4] [\c!width=215mm,\c!height=305mm]
1551
1552
1553
1554\definepapersize [SRA0] [\c!width=900mm,\c!height=1280mm]
1555\definepapersize [SRA1] [\c!width=640mm,\c!height=900mm]
1556\definepapersize [SRA2] [\c!width=450mm,\c!height=640mm]
1557\definepapersize [SRA3] [\c!width=320mm,\c!height=450mm]
1558\definepapersize [SRA4] [\c!width=225mm,\c!height=320mm]
1559
1560
1561
1562\definepapersize [G5] [\c!width=169mm,\c!height=239mm]
1563\definepapersize [E5] [\c!width=155mm,\c!height=220mm]
1564
1565
1566
1567\definepapersize [A3plus] [\c!width=329mm,\c!height=483mm]
1568
1569
1570
1571\definepapersize [business] [\c!width=85mm,\c!height=55mm]
1572\definepapersize [businessUS] [\c!width=3.5in,\c!height=2in]
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588\setuppapersize
1589 [\c!distance=1.5cm]
1590
1591\definepapersize
1592 [oversized]
1593 [ \c!width=\dimexpr\paperwidth \layouttargetparameter\c!distance\relax,
1594 \c!height=\dimexpr\paperheight\layouttargetparameter\c!distance\relax]
1595
1596\definepapersize
1597 [undersized]
1598 [ \c!width=\dimexpr\paperwidth \layouttargetparameter\c!distance\relax,
1599 \c!height=\dimexpr\paperheight\layouttargetparameter\c!distance\relax]
1600
1601\definepapersize
1602 [doublesized]
1603 [ \c!width=\dimexpr \paperwidth \relax,
1604 \c!height=\dimexpr2\paperheight\relax]
1605
1606\definepapersize
1607 [doubleoversized]
1608 [ \c!width=\dimexpr \paperwidth \layouttargetparameter\c!distance\relax,
1609 \c!height=\dimexpr2\paperheight\layouttargetparameter\c!distance\relax]
1610
1611\definepapersize
1612 [doublewide]
1613 [ \c!width=\dimexpr2\paperwidth \relax,
1614 \c!height=\dimexpr \paperheight\relax]
1615
1616
1617
1618
1619\setuppapersize
1620 [A4]
1621
1622
1623
1624\definelayout
1625 [\v!page]
1626
1627\setuplayout
1628 [\v!page]
1629 [\c!backspace=\zeropoint,
1630 \c!cutspace=\zeropoint,
1631 \c!topspace=\zeropoint,
1632 \c!bottomspace=\zeropoint,
1633 \c!margin=\zeropoint,
1634 \c!edge=\zeropoint,
1635 \c!header=\zeropoint,
1636 \c!footer=\zeropoint,
1637 \c!top=\zeropoint,
1638 \c!bottom=\zeropoint,
1639 \c!leftmargin=\zeropoint,
1640 \c!rightmargin=\zeropoint,
1641 \c!leftedge=\zeropoint,
1642 \c!rightedge=\zeropoint,
1643 \c!textdistance=\zeropoint,
1644 \c!width=\v!middle,
1645 \c!height=\v!middle,
1646 \c!lines=0,
1647 \c!grid=\v!no]
1648
1649
1650
1651\definelayout
1652 [\v!middle]
1653 [\c!width=\v!middle,
1654 \c!height=\v!middle]
1655
1656
1657
1658\definelayout
1659 [\v!tight]
1660
1661\definelayout
1662 [\v!tight]
1663 [\v!page]
1664 [\c!backspace=5mm,
1665 \c!cutspace=5mm,
1666 \c!topspace=5mm,
1667 \c!bottomspace=5mm]
1668
1669\protect \endinput
1670 |