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\newdimension\paperheight \paperheight = 297mm
28\newdimension\paperwidth \paperwidth = 210mm
29\newdimension\paperoffset \paperoffset = \zeropoint
30\newdimension\paperbleed \paperbleed = \zeropoint
31\newdimension\spinewidth \spinewidth = \zeropoint
32
33\newdimension\printpaperheight \printpaperheight = \paperheight
34\newdimension\printpaperwidth \printpaperwidth = \paperwidth
35
36\newdimension\makeupheight
37\newdimension\makeupwidth
38
39\newdimension\textheight
40\newdimension\textwidth
41
42\newdimension\topspace \topspace = 2cm
43\newdimension\backspace \backspace = \topspace
44\newdimension\cutspace \cutspace = \zeropoint
45\newdimension\bottomspace \bottomspace = \zeropoint
46
47\newdimension\headerheight \headerheight = 2cm
48\newdimension\footerheight \footerheight = \headerheight
49
50\newdimension\topoffset \topoffset = \zeropoint
51\newdimension\backoffset \backoffset = \topoffset
52
53\newdimension\leftmarginwidth \leftmarginwidth = 3cm
54\newdimension\rightmarginwidth \rightmarginwidth = \leftmarginwidth
55
56\newdimension\leftedgewidth \leftedgewidth = 3cm
57\newdimension\rightedgewidth \rightedgewidth = \leftedgewidth
58
59\newdimension\topheight \topheight = \zeropoint
60\newdimension\bottomheight \bottomheight = \topheight
61
62\newinteger \layoutlines \layoutlines = \zerocount
63\newinteger \layoutcolumns \layoutcolumns = \zerocount
64\newdimension\layoutcolumndistance \layoutcolumndistance = \zeropoint
65\newdimension\layoutcolumnwidth \layoutcolumnwidth = \zeropoint
66
67\newdimension\totaltextwidth
68
69\newdimension\textadaptive
70
71
72
73\newdimension\margindistance
74\newdimension\edgedistance
75\newdimension\marginwidth
76\newdimension\edgewidth
77
78
79
80
81
82
83\newdimension\leftedgedistance
84\newdimension\rightedgedistance
85\newdimension\leftmargindistance
86\newdimension\rightmargindistance
87
88
89
90\newdimension\topdistance
91\newdimension\headerdistance
92\newdimension\textdistance
93\newdimension\footerdistance
94\newdimension\bottomdistance
95
96\newdimension\textovershoot
97
98
99
100\newdimension\naturalmarginwidth
101\newdimension\naturaledgewidth
102\newdimension\naturalmargindistance
103\newdimension\naturaledgedistance
104\newdimension\naturalleftedgedistance
105\newdimension\naturalrightedgedistance
106\newdimension\naturalleftmargindistance
107\newdimension\naturalrightmargindistance
108\newdimension\naturaltopdistance
109\newdimension\naturalheaderdistance
110\newdimension\naturaltextdistance
111\newdimension\naturalfooterdistance
112\newdimension\naturalbottomdistance
113
114
115
116\installcorenamespace{layout}
117\installcorenamespace{layoutlocation}
118\installcorenamespace{layoutalternative}
119\installcorenamespace{layoutcolumn}
120\installcorenamespace{layoutmethod}
121
122\installswitchcommandhandler \??layout {layout} \??layout
123
124\pushoverloadmode
125
126
127
128
129 \let\page_layouts_define\definelayout
130
131 \permanent\protected\def\definelayout[#1]
132 {\normalexpanded{\page_layouts_define[\ifhastoks{}{#1}\the\numexpr\realpageno#1\relax\else#1\fi]}}
133
134\popoverloadmode
135
136\appendtoks
137 \ifempty{\directlayoutparameter\c!state}
138 \letlayoutparameter\c!state\v!start
139 \fi
140\to \everydefinelayout
141
142\newinteger\c_page_layouts_changed
143
144\appendtoks
145 \ifcase\layoutsetupmode
146
147 \or
148 \ifx\previouslayout\currentlayout
149 \letlayoutparameter\c!state\v!normal
150 \let\currentlayout\currentlayout
151 \page_layouts_synchronize
152 \page_layouts_check_next
153 \fi
154 \or
155
156 \letlayoutparameter\c!state\v!normal
157 \let\currentlayout\previouslayout
158 \page_layouts_synchronize
159 \page_layouts_check_next
160 \or
161 \ifx\currentlayout\v!reset
162 \lettonothing\currentlayout
163 \fi
164 \letlayoutparameter\c!state\v!normal
165 \glet\currentlayout\currentlayout
166 \page_layouts_synchronize
167 \page_layouts_check_next
168 \or
169 \letlayoutparameter\c!state\v!normal
170 \glettonothing\currentlayout
171 \page_layouts_synchronize
172 \page_layouts_check_next
173 \fi
174 \global\c_page_layouts_changed\realpageno
175\to \everysetuplayout
176
177\permanent\def\doifelselayoutdefined#1
178 {\ifcsname\namedlayouthash{#1}\c!state\endcsname
179 \expandafter\firstoftwoarguments
180 \else
181 \expandafter\secondoftwoarguments
182 \fi}
183
184\aliased\let\doiflayoutdefinedelse\doifelselayoutdefined
185
186\permanent\def\layoutdistance#1#2{\ifdim\zeropoint<#1#2\else\zeropoint\fi}
187
188\appendtoks
189 \global\pageextragoal\zeropoint
190\to \everysetuplayout
191
192\appendtoks
193 \global\pageextragoal \zeropoint
194\to \everysetupoutputroutine
195
196\immutable\integerdef\lasttextadaptive\zerocount
197
198\prependtoks
199 \enforced\integerdef\lasttextadaptive\plusone
200\to \everybeforeoutput
201
202
203
204\def\page_layouts_set_dimensions
205 {\global\naturalmarginwidth \layoutparameter\c!margin
206 \global\naturaledgewidth \layoutparameter\c!edge
207 \global\naturalmargindistance \layoutparameter\c!margindistance
208 \global\naturaledgedistance \layoutparameter\c!edgedistance
209 \global\naturalleftedgedistance \layoutparameter\c!leftedgedistance
210 \global\naturalrightedgedistance \layoutparameter\c!rightedgedistance
211 \global\naturalleftmargindistance \layoutparameter\c!leftmargindistance
212 \global\naturalrightmargindistance\layoutparameter\c!rightmargindistance
213 \global\naturaltopdistance \layoutparameter\c!topdistance
214 \global\naturalheaderdistance \layoutparameter\c!headerdistance
215 \global\naturaltextdistance \layoutparameter\c!textdistance
216 \global\naturalfooterdistance \layoutparameter\c!footerdistance
217 \global\naturalbottomdistance \layoutparameter\c!bottomdistance
218
219 \global\marginwidth \naturalmarginwidth
220 \global\edgewidth \naturaledgewidth
221 \global\margindistance \naturalmargindistance
222 \global\edgedistance \naturaledgedistance
223
224 \global\leftedgedistance \layoutdistance\leftedgewidth \naturalleftedgedistance
225 \global\rightedgedistance \layoutdistance\rightedgewidth \naturalrightedgedistance
226 \global\leftmargindistance \layoutdistance\leftmarginwidth \naturalleftmargindistance
227 \global\rightmargindistance \layoutdistance\rightmarginwidth\naturalrightmargindistance
228 \global\topdistance \layoutdistance\topheight \naturaltopdistance
229 \global\headerdistance \layoutdistance\headerheight \naturalheaderdistance
230 \global\textdistance \naturaltextdistance
231 \global\footerdistance \layoutdistance\footerheight \naturalfooterdistance
232 \global\bottomdistance \layoutdistance\bottomheight \naturalbottomdistance}
233
234\def\page_layouts_set_distances
235 {\headerdistance\layoutdistance\headerheight\naturalheaderdistance
236 \footerdistance\layoutdistance\footerheight\naturalfooterdistance}
237
238
239
240\newtoks\extralayoutcalculations
241
242\def\page_layouts_calculate_extras
243 {\expand\extralayoutcalculations}
244
245\newtoks\everyswapmargins
246
247\newconditional\marginsareswapped
248
249\appendtoks
250 \ifconditional\marginsareswapped
251 \marginsareswapped\conditionalfalse
252 \else
253 \marginsareswapped\conditionaltrue
254 \fi
255
256 \enforced\swapcsvalues\leftmargindistance\rightmargindistance
257 \enforced\swapcsvalues\leftedgedistance \rightedgedistance
258 \enforced\swapcsvalues\leftmarginwidth \rightmarginwidth
259 \enforced\swapcsvalues\leftedgewidth \rightedgewidth
260
261 \enforced\swapcsvalues\backspace \cutspace
262
263 \enforced\swapcsvalues\leftmargintotal \rightmargintotal
264 \enforced\swapcsvalues\leftedgetotal \rightedgetotal
265 \enforced\swapcsvalues\leftsidetotal \rightsidetotal
266 \enforced\swapcsvalues\leftcombitotal \rightcombitotal
267 \enforced\swapcsvalues\innermargintotal \outermargintotal
268 \enforced\swapcsvalues\inneredgetotal \outeredgetotal
269 \enforced\swapcsvalues\innercombitotal \outercombitotal
270 \enforced\swapcsvalues\innersidetotal \outersidetotal
271\to \everyswapmargins
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317\installcorenamespace{layouttarget}
318\installcorenamespace{layoutpaper}
319\installcorenamespace{layoutprint}
320\installcorenamespace{layoutcurrent}
321
322\installcommandhandler \??layouttarget {layouttarget} \??layouttarget
323
324\newconditional\c_page_target_paper_mirror
325\newconstant \c_page_target_paper_orientation
326\newconstant \c_page_target_paper_reverse
327\newconditional\c_page_target_paper_landscape
328\newconditional\c_page_target_paper_negate
329
330\newconditional\c_page_target_print_mirror
331\newconstant \c_page_target_print_orientation
332\newconstant \c_page_target_print_reverse
333\newconditional\c_page_target_print_landscape
334\newconditional\c_page_target_print_negate
335\newconditional\c_page_target_print_doublesided
336
337\let\v_page_target_left_fill \relax
338\let\v_page_target_right_fill \relax
339\let\v_page_target_top_fill \relax
340\let\v_page_target_bottom_fill\relax
341
342\lettonothing\papersize
343\lettonothing\printpapersize
344
345\def\v_page_target_top {\namedlayouttargetparameter\papersize\c!top }
346\def\v_page_target_bottom {\namedlayouttargetparameter\papersize\c!bottom}
347\def\v_page_target_left {\namedlayouttargetparameter\papersize\c!left }
348\def\v_page_target_right {\namedlayouttargetparameter\papersize\c!right }
349\def\v_page_target_method {\rootlayouttargetparameter \c!method}
350\def\v_page_target_scale {\rootlayouttargetparameter \c!scale }
351\def\v_page_target_nx {\numexpr\rootlayouttargetparameter \c!nx \relax}
352\def\v_page_target_ny {\numexpr\rootlayouttargetparameter \c!ny \relax}
353\def\v_page_target_dx {\dimexpr\rootlayouttargetparameter \c!dx \relax}
354\def\v_page_target_dy {\dimexpr\rootlayouttargetparameter \c!dy \relax}
355\def\v_page_target_width {\dimexpr\rootlayouttargetparameter \c!width \relax}
356\def\v_page_target_height {\dimexpr\rootlayouttargetparameter \c!height \relax}
357\def\v_page_target_topspace {\dimexpr\rootlayouttargetparameter \c!topspace \relax}
358\def\v_page_target_backspace{\dimexpr\rootlayouttargetparameter \c!backspace\relax}
359\def\v_page_target_offset {\dimexpr\rootlayouttargetparameter \c!offset \relax}
360
361\def\v_page_target_xy {\numexpr\v_page_target_nx*\v_page_target_ny\relax}
362
363
364
365
366\setuplayouttarget
367 [
368 \c!nx=1,
369 \c!ny=1,
370 \c!dx=\zeropoint,
371 \c!dy=\zeropoint,
372 \c!topspace=\zeropoint,
373 \c!backspace=\zeropoint,
374 \c!width=\zeropoint,
375 \c!height=\zeropoint,
376
377 \c!method=\v!normal,
378 \c!option=\v!max,
379 \c!alternative=\v!normal,
380
381 \c!scale=1,
382 \c!offset=\zeropoint,
383
384 \c!top=,
385 \c!bottom=,
386 \c!left=,
387 \c!right=,
388
389 \c!location=]
390
391
392
393
394\permanent\tolerant\protected\def\definepapersize[#1]#*[#S#2]#*[#S#3]
395 {\cdef\currentlayouttarget{#1}
396 \ifempty\currentlayouttarget
397
398 \orelse\ifhastok={#2}
399 \definelayouttarget[#1][#2]
400 \else
401 \edefcsname\??layoutpaper#1\endcsname{#2}
402 \ifparameter#3\or
403 \edefcsname\??layoutprint#1\endcsname{#3}
404 \else
405 \edefcsname\??layoutprint#1\endcsname{#2}
406 \fi
407 \fi}
408
409\appendtoks
410 \letcsname\??layoutcurrent\currentlayouttarget\endcsname\relax
411\to \everydefinelayouttarget
412
413
414
415
416\def\page_paper_the_paper_size#1{\ifcsname\??layoutpaper#1\endcsname\lastnamedcs\else#1\fi}
417\def\page_paper_the_print_size#1{\ifcsname\??layoutprint#1\endcsname\lastnamedcs\else#1\fi}
418
419
420
421
422
423\let\page_paper_reinstate\relax
424\let\page_paper_restore \relax
425
426\permanent\tolerant\protected\def\setuppapersize[#S#1]#*[#S#2]
427 {\ifarguments
428 \page_paper_restore
429 \orelse\ifhastok={#1}
430 \page_paper_setup_size_settings[#1]
431 \orelse\ifhastok={#2}
432 \page_paper_setup_size_settings_by_name[#1][#2]
433 \else
434 \page_paper_setup_size_change_size[#1][#2]
435 \fi}
436
437\protected\def\page_paper_setup_size_settings[#S#1]
438 {\lettonothing\currentlayouttarget
439 \edef\m_layouttarget_paper_saved{\page_paper_the_paper_size{\layouttargetparameter\c!page }}
440 \edef\m_layouttarget_print_saved{\page_paper_the_print_size{\layouttargetparameter\c!paper}}
441 \setupcurrentlayouttarget[#1]
442 \edef\m_layouttarget_paper{\page_paper_the_paper_size{\layouttargetparameter\c!page }}
443 \edef\m_layouttarget_print{\page_paper_the_print_size{\layouttargetparameter\c!paper}}
444 \ifx\m_layouttarget_paper_saved\m_layouttarget_paper
445 \ifx\m_layouttarget_print_saved\m_layouttarget_print
446
447 \else
448 \page_paper_setup_size_settings_recalibrate
449 \fi
450 \else
451 \page_paper_setup_size_settings_recalibrate
452 \fi}
453
454\def\page_paper_setup_size_settings_recalibrate
455 {\ifempty\m_layouttarget_paper
456
457 \else
458 \ifempty\m_layouttarget_print
459 \let\m_layouttarget_print\m_layouttarget_paper
460 \fi
461 \page_paper_set_current[\m_layouttarget_paper][\m_layouttarget_print]
462 \fi
463 \letlayouttargetparameter\c!page \papersize
464 \letlayouttargetparameter\c!paper\printpapersize}
465
466\protected\def\page_paper_setup_size_settings_by_name[#1][#S#2]
467 {\cdef\currentlayouttarget{\page_paper_the_paper_size{#1}}
468 \setuplayouttarget[#2]}
469
470\protected\def\page_paper_setup_size_change_size[#1][#2]
471 {\ifempty{#2}
472 \page_paper_set_current[#1][#1]
473 \else
474 \page_paper_set_current[#1][#2]
475 \fi}
476
477\permanent\let\setuppaper\page_paper_setup_size_settings
478
479\permanent\protected\def\adaptpapersize
480 {\glet\page_paper_reinstate\page_paper_restore
481 \setuppapersize}
482
483\appendtoks
484 \page_paper_reinstate
485 \glet\page_paper_reinstate\relax
486\to \everyaftershipout
487
488\protected\def\page_paper_set_restore#1#2
489 {\xdef\page_paper_restore{\page_paper_set_current_indeed[#1][#2]}}
490
491\protected\def\page_paper_set_current[#1][#2]
492 {\normalexpanded{\page_paper_set_current_indeed
493 [\page_paper_the_paper_size{#1}]
494 [\page_paper_the_print_size{#2}]}}
495
496\protected\def\page_paper_reset_paper
497 {\global\c_page_target_paper_landscape\conditionalfalse
498 \global\c_page_target_paper_mirror\conditionalfalse
499 \global\c_page_target_paper_negate\conditionalfalse
500 \global\c_page_target_paper_orientation\uprotationangle
501 \global\c_page_target_paper_reverse \uprotationangle}
502
503\protected\def\page_paper_reset_print
504 {\global\c_page_target_print_landscape\conditionalfalse
505 \global\c_page_target_print_mirror\conditionalfalse
506 \global\c_page_target_print_negate\conditionalfalse
507 \global\c_page_target_print_orientation\uprotationangle
508 \global\c_page_target_print_reverse \uprotationangle}
509
510\letcsname\??layoutpaper\v!reset\endcsname\page_paper_reset_paper
511\letcsname\??layoutprint\v!reset\endcsname\page_paper_reset_print
512
513\defcsname\??layoutpaper\v!landscape\endcsname
514 {\global\c_page_target_paper_landscape\conditionaltrue}
515
516\defcsname\??layoutpaper\v!mirrored\endcsname
517 {\global\c_page_target_paper_mirror\conditionaltrue}
518
519\defcsname\??layoutpaper\v!negative\endcsname
520 {\global\c_page_target_paper_negate\conditionaltrue}
521
522\defcsname\??layoutpaper\v!rotated\endcsname
523 {\global\c_page_target_paper_orientation\rightrotationangle
524 \global\c_page_target_paper_reverse \leftrotationangle}
525
526\defcsname\??layoutpaper\the\rightrotationangle\endcsname
527 {\global\c_page_target_paper_orientation\rightrotationangle
528 \global\c_page_target_paper_reverse \leftrotationangle}
529
530\defcsname\??layoutpaper\the\downrotationangle\endcsname
531 {\global\c_page_target_paper_orientation\downrotationangle
532 \global\c_page_target_paper_reverse \zerocount}
533
534\defcsname\??layoutpaper\the\leftrotationangle\endcsname
535 {\global\c_page_target_paper_orientation\leftrotationangle
536 \global\c_page_target_paper_reverse \rightrotationangle}
537
538\defcsname\??layoutprint\v!landscape\endcsname
539 {\global\c_page_target_print_landscape\conditionaltrue}
540
541\defcsname\??layoutprint\v!mirrored\endcsname
542 {\global\c_page_target_print_mirror\conditionaltrue}
543
544\defcsname\??layoutprint\v!negative\endcsname
545 {\global\c_page_target_print_negate\conditionaltrue}
546
547\defcsname\??layoutprint\v!rotated\endcsname
548 {\global\c_page_target_print_orientation\rightrotationangle
549 \global\c_page_target_print_reverse \leftrotationangle}
550
551\defcsname\??layoutprint\the\rightrotationangle\endcsname
552 {\global\c_page_target_print_orientation\rightrotationangle
553 \global\c_page_target_print_reverse \leftrotationangle}
554
555\defcsname\??layoutprint\the\downrotationangle \endcsname
556 {\global\c_page_target_print_orientation\downrotationangle
557 \global\c_page_target_print_reverse \zerocount}
558
559\defcsname\??layoutprint\the\leftrotationangle \endcsname
560 {\global\c_page_target_print_orientation\leftrotationangle
561 \global\c_page_target_print_reverse \rightrotationangle}
562
563\def\page_paper_handle_page_option #1{\begincsname\??layoutpaper#1\endcsname}
564\def\page_paper_handle_print_option#1{\begincsname\??layoutprint#1\endcsname}
565
566\protected\def\page_paper_identify_target#1
567 {\ifcsname\??layoutcurrent#1\endcsname
568 \cdef\currentlayouttarget{#1}
569 \fi}
570
571\newdimension\d_page_minimum_paper_size \d_page_minimum_paper_size\luaexpr{math.pi}\onebasepoint
572
573\protected\def\page_paper_set_current_indeed[#1][#2]
574 {\edef\m_page_asked_paper{#1}
575 \edef\m_page_asked_print{#2}
576
577 \page_paper_set_restore\m_page_asked_paper\m_page_asked_print
578
579
580 \lettonothing\currentlayouttarget
581 \page_paper_reset_paper
582 \processcommacommand[\m_page_asked_paper]\page_paper_identify_target
583 \ifempty\currentlayouttarget
584 \let\currentlayouttarget\currentpage
585 \fi
586 \glet\papersize\currentlayouttarget
587 \page_paper_reset_paper
588 \processcommacommand[\m_page_asked_paper]\page_paper_handle_page_option
589 \global\paperwidth \layouttargetparameter\c!width \relax
590 \global\paperheight\layouttargetparameter\c!height\relax
591 \ifdim\paperwidth<\d_page_minimum_paper_size
592 \global\paperwidth\d_page_minimum_paper_size
593 \fi
594 \ifdim\paperheight<\d_page_minimum_paper_size
595 \global\paperheight\d_page_minimum_paper_size
596 \fi
597 \ifconditional\c_page_target_paper_landscape
598 \enforced\global\swapcsvalues\paperwidth\paperheight
599 \fi
600 \ifinpagebody
601 \normalexpanded{\setlayouttargetparameter\c!height{\the\paperheight}}
602 \normalexpanded{\setlayouttargetparameter\c!width {\the\paperwidth }}
603 \fi
604
605 \page_paper_set_offsets
606
607 \page_paper_reset_print
608 \processcommacommand[\m_page_asked_print]\page_paper_identify_target
609 \glet\printpapersize\currentlayouttarget
610 \page_paper_reset_print
611 \processcommacommand[\m_page_asked_print]\page_paper_handle_print_option
612 \global\printpaperwidth \layouttargetparameter\c!width \relax
613 \global\printpaperheight\layouttargetparameter\c!height\relax
614 \ifdim\printpaperwidth<\onepoint
615 \global\printpaperwidth\paperwidth
616 \fi
617 \ifdim\printpaperheight<\onepoint
618 \global\printpaperheight\paperheight
619 \fi
620 \ifconditional\c_page_target_print_landscape
621 \enforced\global\swapcsvalues\printpaperwidth\printpaperheight
622 \fi
623
624
625 \edef\m_page_asked_option{\rootlayouttargetparameter\c!option}
626 \ifx\m_page_asked_option\v!max
627 \begingroup
628
629 \ifnum\c_page_target_paper_orientation=\rightrotationangle
630 \enforced\swapcsvalues\paperwidth\paperheight
631 \orelse\ifnum\c_page_target_paper_orientation=\leftrotationangle
632 \enforced\swapcsvalues\paperwidth\paperheight
633 \fi
634 \ifnum\c_page_target_print_orientation=\rightrotationangle
635 \enforced\swapcsvalues\printpaperwidth\printpaperheight
636 \orelse\ifnum\c_page_target_print_orientation=\leftrotationangle
637 \enforced\swapcsvalues\printpaperwidth\printpaperheight
638 \fi
639 \ifdim\paperheight>\printpaperheight
640 \global\printpaperheight\paperheight
641 \writestatus\m!system{print height forced to paper height}
642 \fi
643 \ifdim\paperwidth>\printpaperwidth
644 \global\printpaperwidth\paperwidth
645 \writestatus\m!system{print width forced to paper width}
646 \fi
647 \endgroup
648 \fi
649
650 \page_layouts_synchronize
651
652 \scrn_canvas_synchronize_only}
653
654\ifdefined\scrn_canvas_synchronize_only \else
655 \let\scrn_canvas_synchronize_only\relax
656\fi
657
658\ifdefined\page_paper_set_offsets \else
659
660 \def\page_paper_set_offsets
661 {\global\paperoffset\v_page_target_offset
662 \global\advanceby\paperwidth 2\paperoffset
663 \global\advanceby\paperheight2\paperoffset}
664
665\fi
666
667\ifdefined\synchronizegridsnapping \else
668 \let\synchronizegridsnapping\relax
669\fi
670
671\lettonothing\p_page_layouts_width
672\lettonothing\p_page_layouts_height
673
674\def\page_layouts_synchronize
675 {\setups[\layoutparameter\c!preset]\relax
676 \global\leftmarginwidth \layoutparameter\c!leftmargin
677 \global\rightmarginwidth\layoutparameter\c!rightmargin
678 \global\leftedgewidth \layoutparameter\c!leftedge
679 \global\rightedgewidth \layoutparameter\c!rightedge
680 \global\headerheight \layoutparameter\c!header
681 \global\footerheight \layoutparameter\c!footer
682 \global\bottomheight \layoutparameter\c!bottom
683 \global\topheight \layoutparameter\c!top
684 \global\backspace \layoutparameter\c!backspace
685 \global\topspace \layoutparameter\c!topspace
686 \global\textadaptive \layoutparameter\c!adaptive
687 \page_layouts_set_dimensions
688 \synchronizegridsnapping
689 \usesetupsparameter\layoutparameter
690 \synchronizewhitespace
691 \synchronizeblank
692 \setupinterlinespace[\v!reset]
693 \global\cutspace\layoutparameter\c!cutspace\relax
694 \edef\p_page_layouts_width{\layoutparameter\c!width}
695 \ifx\p_page_layouts_width\v!middle
696 \ifzeropt\cutspace
697 \global\cutspace\backspace
698 \fi
699 \global\makeupwidth\dimexpr\paperwidth\backspace\cutspace\relax
700 \orelse\ifx\p_page_layouts_width\v!fit
701 \ifzeropt\cutspace
702 \global\cutspace\backspace
703 \fi
704 \global\makeupwidth\dimexpr\paperwidth\cutspace\relax
705 \scratchdimen\dimexpr\backspace
706 \leftedgewidth \leftedgedistance
707 \leftmarginwidth\leftmargindistance\relax
708 \ifdim\scratchdimen<\zeropoint
709 \scratchdimen\zeropoint
710 \fi
711 \global\advanceby\makeupwidth\dimexpr
712 \rightmargindistance\rightmarginwidth
713 \rightedgedistance \rightedgewidth
714 \scratchdimen\relax
715 \else
716 \global\makeupwidth\p_page_layouts_width\relax
717 \ifzeropt\cutspace
718 \global\cutspace\dimexpr\paperwidth\makeupwidth\backspace\relax
719
720
721
722
723
724 \fi
725 \fi
726 \scratchdimen\layoutparameter\c!bottomspace\relax
727
728
729
730 \global\bottomspace\layoutparameter\c!bottomspace\relax
731 \global\layoutlines0\number\layoutparameter\c!lines\relax
732 \ifcase\layoutlines
733 \edef\p_page_layouts_height{\layoutparameter\c!height}
734 \ifx\p_page_layouts_height\v!middle
735 \ifzeropt\bottomspace
736 \global\bottomspace\topspace
737 \fi
738 \global\makeupheight\dimexpr\paperheight\topspace\bottomspace\relax
739 \orelse\ifx\p_page_layouts_height\v!fit
740 \ifzeropt\bottomspace
741 \global\bottomspace\topspace
742 \fi
743 \global\makeupheight\dimexpr\paperheight\bottomspace\relax
744 \scratchdimen\dimexpr\topspace\topheight\topdistance\relax
745 \ifdim\scratchdimen<\zeropoint
746 \scratchdimen\zeropoint
747 \fi
748 \global\advanceby\makeupheight\dimexpr\bottomdistance\bottomheight\scratchdimen\relax
749 \else
750 \global\makeupheight\layoutparameter\c!height\relax
751 \ifzeropt\bottomspace
752 \global\bottomspace\dimexpr\paperheight\makeupheight\topspace\relax
753
754
755 \fi
756 \fi
757 \else
758
759
760
761
762
763 \global\makeupheight\dimexpr
764 \layoutparameter\c!lines\lineheight\strutheight\topskip
765 \headerdistance\headerheight\footerdistance\footerheight\relax
766 \fi
767 \backoffset\layoutparameter\c!horoffset\relax
768 \topoffset \layoutparameter\c!veroffset\relax
769 \ifdim\makeupwidth<\onepoint
770 \global\makeupwidth\onepoint
771 \fi
772 \ifdim\makeupheight<\onepoint
773 \global\makeupheight\onepoint
774 \fi
775
776 \global\totaltextwidth\dimexpr
777 \leftedgetotal
778 \leftmargintotal
779 \makeupwidth
780 \rightmargintotal
781 \rightedgetotal
782 \relax
783
784 \page_layouts_check_direction
785 \page_layouts_calculate_extras
786 \page_target_check_centering
787 \calculatehsizes
788 \calculatevsizes
789 \page_layouts_check_pseudo_columns
790 \page_backgrounds_recalculate}
791
792\def\page_layouts_check_direction
793 {\ifcstok{\layoutparameter\c!direction}\v!reverse
794 \enforced\global\swapcsvalues\naturalleftedgedistance \naturalrightedgedistance
795 \enforced\global\swapcsvalues\naturalleftmargindistance\naturalrightmargindistance
796 \enforced\global\swapcsvalues\leftmargindistance \rightmargindistance
797 \enforced\global\swapcsvalues\leftmarginwidth \rightmarginwidth
798 \enforced\global\swapcsvalues\leftedgedistance \rightedgedistance
799 \enforced\global\swapcsvalues\leftedgewidth \rightedgewidth
800 \enforced\global\swapcsvalues\backspace \cutspace
801 \expandafter\setsystemmode
802 \else
803 \expandafter\resetsystemmode
804 \fi{reverselayout}}
805
806\def\page_layouts_check_pseudo_columns
807 {\global\layoutcolumns\layoutparameter\c!columns
808 \global\layoutcolumndistance\layoutparameter\c!columndistance
809 \global\layoutcolumnwidth\dimexpr\makeupwidth\layoutcolumns\layoutcolumndistance\layoutcolumndistance\relax
810 \ifnum\layoutcolumns>\plusone
811 \global\divideby\layoutcolumnwidth\layoutcolumns
812 \dorecurse\layoutcolumns\page_layouts_check_pseudo_column
813 \fi}
814
815\def\page_layouts_check_pseudo_column
816 {\xdefcsname\??layoutcolumn\recurselevel\endcsname
817 {\the\numexpr\recurselevel\plusone\relax\dimexpr\layoutcolumnwidth\layoutcolumndistance\relax}}
818
819\aliased\letcsname\??layoutcolumn0\endcsname\zeropoint
820
821\permanent\def\layoutcolumnoffset#1
822 {\csname\??layoutcolumn\ifcsname\??layoutcolumn#1\endcsname#1\else0\fi\endcsname}
823
824\permanent\protected\def\layoutlineoffset#1
825 {\the\dimexpr\topskip\strutht#1\lineheight\lineheight\relax}
826
827\def\page_layouts_synchronize_at_start
828 {\ifdim\makeupheight=\layoutlines\lineheight \else
829 \page_layouts_synchronize
830 \fi}
831
832\appendtoks
833 \page_layouts_synchronize_at_start
834\to \everystarttext
835
836
837
838
839
840
841
842\ifdefined\lastpage \else \let\lastpage\!!plusone \fi
843
844\permanent\protected\def\page_layouts_change#1
845 {
846 \xdef\currentlayout{#1}
847 \page_layouts_synchronize}
848
849\aliased\let\changetolayout\page_layouts_change
850
851\def\v_real_page_normal {\the\realpageno}
852\def\v_real_page_reverse{\the\numexpr\lastpage\realpageno\relax}
853
854\def\v_real_page_odd_or_even
855 {\ifodd\pagenoshift
856 \ifodd\realpageno\v!even\else\v!odd \fi
857 \else
858 \ifodd\realpageno\v!odd \else\v!even\fi
859 \fi}
860
861\let\v_real_page_current\v!current
862
863\def\v_real_page_named
864 {\ifnum\lastpage=\realpageno
865 \v!last
866 \orelse\ifnum\plusone=\realpageno
867 \v!first
868 \else
869 \__unknown__
870 \fi}
871
872\let\v_page_layouts_pre_check\relax
873
874\def\page_layouts_check_default_indeed#1
875 {\edef\m_page_check{#1}
876 \edef\m_page_state{\namedlayoutparameter\m_page_check\c!state}
877 \ifx\m_page_state\v!start
878 \glet\v_page_layouts_pre_check\currentlayout
879 \glet\currentlayout\m_page_check
880 \page_layouts_synchronize
881 \orelse\ifx\m_page_state\v!repeat
882 \glet\v_page_layouts_pre_check\relax
883 \glet\currentlayout\m_page_check
884 \page_layouts_synchronize
885 \fi}
886
887\def\page_layouts_check_revert
888 {\glet\currentlayout\v_page_layouts_pre_check
889 \glet\v_page_layouts_pre_check\relax
890 \page_layouts_synchronize}
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921\def\page_layouts_check_default
922 {\ifrelax\v_page_layouts_pre_check\else
923 \page_layouts_check_revert
924 \fi
925 \ifcsname\namedlayouthash\v_real_page_normal\c!state\endcsname
926 \page_layouts_check_default_indeed\v_real_page_normal
927 \orelse\ifcsname\namedlayouthash\v_real_page_reverse\c!state\endcsname
928 \page_layouts_check_default_indeed\v_real_page_reverse
929 \orelse\ifcsname\namedlayouthash\v_real_page_named\c!state\endcsname
930 \page_layouts_check_default_indeed\v_real_page_named
931 \orelse\ifcsname\namedlayouthash\v_real_page_current\c!state\endcsname
932 \page_layouts_check_default_indeed\v_real_page_current
933 \orelse\ifcsname\namedlayouthash\v_real_page_odd_or_even\c!state\endcsname
934 \page_layouts_check_default_indeed\v_real_page_odd_or_even
935
936
937
938
939 \fi}
940
941\permanent\protected\def\installlayoutmethod#1#2
942 {\gdefcsname\??layoutmethod#1\endcsname{#2}}
943
944\installlayoutmethod\v!default{\page_layouts_check_default}
945\installlayoutmethod\v!normal {\page_layouts_check_default}
946
947\permanent\protected\def\page_layouts_check_next
948 {\ifcsname\??layoutmethod\layoutparameter\c!method\endcsname
949 \lastnamedcs
950 \else
951 \page_layouts_check_default
952 \fi}
953
954\aliased\let\checkcurrentlayout\page_layouts_check_next
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990\appendtoks \page_layouts_check_next \to \everystarttext
991\appendtoks \page_layouts_check_next \to \everyaftershipout
992
993\newconditional\c_page_layouts_location_is_set
994\newconditional\c_page_layouts_location_is_middle
995
996\def\page_layouts_location_reset
997 {\c_page_layouts_location_is_set\conditionalfalse
998 \c_page_layouts_location_is_middle\conditionalfalse
999 \let\v_page_target_left_fill \relax
1000 \let\v_page_target_right_fill \hss
1001 \let\v_page_target_top_fill \relax
1002 \let\v_page_target_bottom_fill\vss}
1003
1004\defcsname\??layoutlocation\v!right\endcsname
1005 {\c_page_layouts_location_is_set\conditionaltrue
1006 \c_page_layouts_location_is_middle\conditionalfalse
1007 \let\v_page_target_left_fill \hss
1008 \let\v_page_target_right_fill\relax}
1009
1010\defcsname\??layoutlocation\v!left\endcsname
1011 {\c_page_layouts_location_is_set\conditionaltrue
1012 \c_page_layouts_location_is_middle\conditionalfalse
1013 \let\v_page_target_left_fill \relax
1014 \let\v_page_target_right_fill\hss}
1015
1016\defcsname\??layoutlocation\v!bottom\endcsname
1017 {\c_page_layouts_location_is_set\conditionaltrue
1018 \c_page_layouts_location_is_middle\conditionalfalse
1019 \let\v_page_target_top_fill \vss
1020 \let\v_page_target_bottom_fill\relax}
1021
1022\defcsname\??layoutlocation\v!top\endcsname
1023 {\c_page_layouts_location_is_set\conditionaltrue
1024 \c_page_layouts_location_is_middle\conditionalfalse
1025 \let\v_page_target_top_fill \relax
1026 \let\v_page_target_bottom_fill\vss}
1027
1028\defcsname\??layoutlocation\v!middle\endcsname
1029 {\c_page_layouts_location_is_set\conditionaltrue
1030 \c_page_layouts_location_is_middle\conditionaltrue
1031 \let\v_page_target_left_fill \hss
1032 \let\v_page_target_right_fill \hss
1033 \let\v_page_target_top_fill \vss
1034 \let\v_page_target_bottom_fill\vss}
1035
1036\defcsname\??layoutlocation\empty\endcsname
1037 {\c_page_layouts_location_is_set\conditionalfalse
1038 \c_page_layouts_location_is_middle\conditionalfalse
1039 \let\v_page_target_right_fill \hss
1040 \let\v_page_target_bottom_fill\hss}
1041
1042\defcsname\??layoutlocation\v!doublesided\endcsname
1043 {\c_page_target_print_doublesided\conditionaltrue}
1044
1045\defcsname\??layoutlocation\v!singlesided\endcsname
1046 {\c_page_target_print_doublesided\conditionalfalse}
1047
1048\def\page_target_check_centering_indeed#1
1049 {\begincsname\??layoutlocation#1\endcsname}
1050
1051\protected\def\page_target_check_centering
1052 {\c_page_target_print_doublesided\conditionalfalse
1053 \page_layouts_location_reset
1054 \processcommacommand[\layoutparameter\c!location]\page_target_check_centering_indeed}
1055
1056
1057
1058\permanent\protected\def\installlayoutalternative#1#2
1059 {\gdefcsname\??layoutalternative#1\endcsname{#2}}
1060
1061\def\page_boxes_construct_content_default#1#2#3
1062 {\setbox#1\vpack
1063 {\offinterlineskip
1064 \begingroup
1065 \uselayoutstyleandcolor\c!style\c!color
1066 \offinterlineskip
1067 \page_layouts_insert_elements
1068 \endgroup
1069 \page_insert_body#2#3}}
1070
1071\installlayoutalternative\v!default{\page_boxes_construct_content_default}
1072\installlayoutalternative\v!normal {\page_boxes_construct_content_default}
1073
1074\def\page_boxes_construct_content
1075 {\ifcsname\??layoutalternative\layoutparameter\c!alternative\endcsname
1076 \expandafter\lastnamedcs
1077 \else
1078 \expandafter\page_boxes_construct_content_default
1079 \fi}
1080
1081
1082
1083
1084
1085
1086\installcorenamespace{adaptlayout}
1087\installcorenamespace{pageadaptations}
1088
1089\installsetuponlycommandhandler \??adaptlayout {adaptlayout}
1090
1091\newdimension\d_page_adapts_pushed_text_height
1092\newdimension\d_page_adapts_pushed_footer_height
1093\newdimension\d_page_adapts_height
1094\newdimension\d_page_adapts_delta
1095
1096\appendtoks \global\d_page_adapts_delta\zeropoint \to \everyshipout
1097
1098\permanent\protected\tolerant\def\adaptlayout[#1]#*[#S#2]
1099 {\ifparameter#2\or
1100 \processcommalist[#1]{\page_adapts_layout_register{#2}}
1101 \page_adapts_check
1102 \else
1103 \page_adapts_layout_indeed{#1}
1104 \fi}
1105
1106\def\page_adapts_layout_register#1#2
1107 {\gdefcsname\??pageadaptations#2\endcsname{\page_adapts_layout_indeed{#1}}}
1108
1109\let\p_adapts_height\zeropoint
1110\let\p_adapts_lines \zerocount
1111
1112\def\page_adapts_layout_indeed#1
1113 {\setupcurrentadaptlayout[\c!height=\zeropoint,\c!lines=\zerocount,\c!top=\zeropoint,#1]
1114 \page_adapts_push
1115 \edef\p_adapts_height{\adaptlayoutparameter\c!height}
1116 \edef\p_adapts_lines {\adaptlayoutparameter\c!lines}
1117 \ifx\p_adapts_height\v!max
1118 \global\d_page_adapts_height\footerheight
1119 \else
1120 \global\d_page_adapts_height\dimexpr
1121 \ifnum\p_adapts_lines=\zerocount
1122 \p_adapts_height
1123 \else
1124 \p_adapts_lines\openlineheight
1125 \fi
1126 \relax
1127 \ifdim\d_page_adapts_height>\footerheight
1128 \global\d_page_adapts_height\footerheight
1129 \fi
1130 \fi
1131
1132 \global\d_page_adapts_delta\dimexpr\adaptlayoutparameter\c!top\relax
1133
1134 \global\advanceby\textheight \d_page_adapts_height
1135 \global\advanceby\footerheight\d_page_adapts_height
1136 \showmessage\m!layouts1{\the\dimexpr\d_page_adapts_height,\the\realpageno}
1137
1138 \page_otr_command_set_vsize
1139
1140 \page_backgrounds_recalculate
1141 \glet\page_adapts_push\relax
1142 \glet\page_adapts_pop\page_adapts_pop_indeed}
1143
1144\def\page_adapts_check
1145 {\begincsname\??pageadaptations\the\realpageno\endcsname}
1146
1147\def\page_adapts_reset
1148 {\ifcsname\??pageadaptations\the\realpageno\endcsname
1149 \gletcsname\??pageadaptations\the\realpageno\endcsname\relax
1150 \fi}
1151
1152\def\page_adapts_push_indeed
1153 {\global\d_page_adapts_pushed_text_height \textheight
1154 \global\d_page_adapts_pushed_footer_height\footerheight}
1155
1156\def\page_adapts_pop_indeed
1157 {\global\textheight \d_page_adapts_pushed_text_height
1158 \global\footerheight\d_page_adapts_pushed_footer_height
1159 \page_layouts_synchronize
1160 \glet\page_adapts_push\page_adapts_push_indeed
1161 \glet\page_adapts_pop\relax}
1162
1163\appendtoks \page_adapts_check \to \everystarttext
1164\appendtoks \page_adapts_reset \to \everyshipout
1165
1166\let\page_adapts_pop \relax
1167\let\page_adapts_push\page_adapts_push_indeed
1168
1169\protected\def\page_adapts_synchronize
1170 {\page_adapts_pop
1171 \page_adapts_check}
1172
1173\def\page_adapts_status_info
1174 {\ifrelax\page_adapts_pop \else
1175 \space(adept: \the\d_page_adapts_height)\space
1176 \fi
1177 \the\realpageno}
1178
1179
1180
1181
1182\permanent\protected\def\startlayout[#S#1]
1183 {\page
1184 \globalpushmacro\currentlayout
1185 \doifelselayoutdefined{#1}{\setuplayout[#1]}\donothing}
1186
1187\permanent\protected\def\stoplayout
1188 {\page
1189 \globalpopmacro\currentlayout
1190 \setuplayout[\currentlayout]}
1191
1192
1193
1194\ifdefined\doifelselayoutsomeline \else
1195 \let\doifelselayoutsomeline\secondofthreearguments
1196\fi
1197
1198\permanent\def\compensatevsizeheader {\advanceby\textheight\dimexpr\headerheight\headerdistance\relax}
1199\permanent\def\compensatevsizefooter {\advanceby\textheight\dimexpr\footerheight\footerdistance\relax}
1200\permanent\def\globalcompensatevsizeheader{\global\advanceby\textheight\dimexpr\headerheight\headerdistance\relax}
1201\permanent\def\globalcompensatevsizefooter{\global\advanceby\textheight\dimexpr\footerheight\footerdistance\relax}
1202
1203\permanent\def\compensatevsizeheaderzero{\headerheight\zeropoint\page_layouts_set_distances}
1204\permanent\def\compensatevsizefooterzero{\footerheight\zeropoint\page_layouts_set_distances}
1205
1206\def\page_layouts_set_modes
1207 {\ifzeropt\headerheight
1208 \resetsystemmode\v!header
1209 \else
1210 \setsystemmode\v!header
1211 \fi
1212 \ifzeropt\footerheight
1213 \resetsystemmode\v!footer
1214 \else
1215 \setsystemmode\v!footer
1216 \fi}
1217
1218\permanent\protected\def\calculatevsizes
1219 {\textheight\makeupheight
1220 \doifelselayoutsomeline\v!header\compensatevsizeheader\donothing
1221 \doifelselayoutsomeline\v!footer\compensatevsizefooter\donothing
1222 \page_layouts_set_modes
1223 \resetglobal
1224 \page_otr_command_set_vsize}
1225
1226\permanent\protected\def\calculateglobalvsizes
1227 {\global\textheight\makeupheight
1228 \doifelselayoutsomeline\v!header\globalcompensatevsizeheader\donothing
1229 \doifelselayoutsomeline\v!footer\globalcompensatevsizefooter\donothing
1230 \page_layouts_set_modes
1231 \page_otr_command_set_vsize}
1232
1233\permanent\protected\def\calculatereducedvsizes
1234 {\textheight\makeupheight
1235 \doifelselayoutsomeline\v!header\compensatevsizeheader\compensatevsizeheaderzero
1236 \doifelselayoutsomeline\v!footer\compensatevsizefooter\compensatevsizefooterzero}
1237
1238\newdimension\innermakeupwidth
1239\newdimension\innermakeupmargin
1240
1241\newconditional\innermakeupcompensation \innermakeupcompensation\conditionaltrue
1242
1243\permanent\def\compensatedinnermakeupmargin
1244 {\dimexpr\ifconditional\innermakeupcompensation\innermakeupmargin\else\zeropoint\fi\relax}
1245
1246\permanent\protected\def\freezetextwidth
1247 {\textwidth\makeupwidth
1248 \edef\m_currentlayout_text_width {\layoutparameter\c!textwidth }
1249 \edef\m_currentlayout_text_margin{\layoutparameter\c!textmargin}
1250 \ifempty\m_currentlayout_text_width \else
1251 \textwidth\m_currentlayout_text_width
1252 \fi
1253 \global\innermakeupwidth\textwidth
1254 \ifempty\m_currentlayout_text_margin
1255 \global\innermakeupmargin\zeropoint
1256 \else
1257 \global\innermakeupmargin\m_currentlayout_text_margin\relax
1258 \fi
1259 \scratchdimen\dimexpr\innermakeupmargin\innermakeupmargin\relax
1260 \global\advanceby\innermakeupwidth\scratchdimen
1261 \advanceby\textwidth\scratchdimen}
1262
1263\permanent\protected\def\calculatehsizes
1264 {\freezetextwidth
1265 \page_otr_command_set_hsize}
1266
1267
1268
1269
1270
1271
1272
1273\permanent\def\doifelseoddpage
1274 {\ifodd\pagenoshift
1275 \expandafter\page_layouts_if_odd_else_yes
1276 \else
1277 \expandafter\page_layouts_if_odd_else_nop
1278 \fi}
1279
1280\aliased\let\doifoddpageelse\doifelseoddpage
1281
1282\def\page_layouts_if_odd_else_yes
1283 {\ifodd\realpageno
1284 \expandafter\secondoftwoarguments
1285 \else
1286 \expandafter\firstoftwoarguments
1287 \fi}
1288
1289\def\page_layouts_if_odd_else_nop
1290 {\ifodd\realpageno
1291 \expandafter\firstoftwoarguments
1292 \else
1293 \expandafter\secondoftwoarguments
1294 \fi}
1295
1296\def\page_layouts_if_odd_else_again#1{\doifelseoddpage}
1297
1298\permanent\def\doifbothsidesoverruled
1299 {\ifdoublesided
1300 \expandafter\page_layouts_if_odd_else_again
1301 \else
1302 \expandafter\firstofthreearguments
1303 \fi}
1304
1305\permanent\def\doifbothsides
1306 {\ifdoublesided
1307 \expandafter\page_layouts_if_both_sides
1308 \else
1309 \expandafter\firstofthreearguments
1310 \fi}
1311
1312\def\page_layouts_if_both_sides
1313 {\ifsinglesided
1314 \expandafter\firstofthreearguments
1315 \else
1316 \expandafter\page_layouts_if_odd_else_again
1317 \fi}
1318
1319\newdimension\texthoffset
1320
1321\permanent\protected\def\settexthoffset
1322 {\texthoffset\doifbothsides\backspace\backspace{\dimexpr\paperwidth\backspace\makeupwidth\relax}}
1323
1324\permanent\protected\def\goleftonpage
1325 {\hkern\dimexpr\leftmargindistance\leftmarginwidth\leftedgedistance\leftedgewidth\relax}
1326
1327\permanent\def\doifelsemarginswap#1#2
1328 {\doifbothsides{#1}{#1}{#2}}
1329
1330\aliased\let\doifmarginswapelse\doifelsemarginswap
1331
1332\protected\def\page_layouts_swap_margins
1333 {\doifelsemarginswap\gobbleoneargument\page_layouts_swap_margins_indeed}
1334
1335\protected\def\page_layouts_swap_margins_indeed#1
1336 {\let\page_layouts_swap_margins\gobbleoneargument
1337
1338 \expand\everyswapmargins}
1339
1340\permanent\protected\def\swapmargindimensions
1341 {\page_layouts_swap_margins\v!page}
1342
1343\permanent\def\rightorleftpageaction
1344 {\ifdoublesided
1345 \expandafter\page_layouts_right_or_left_page_action
1346 \else
1347 \expandafter\firstoftwoarguments
1348 \fi}
1349
1350\def\page_layouts_right_or_left_page_action
1351 {\ifsinglesided
1352 \expandafter\firstoftwoarguments
1353 \else
1354 \expandafter\doifelseoddpage
1355 \fi}
1356
1357
1358
1359\permanent\def\outermarginwidth {\rightorleftpageaction\rightmarginwidth \leftmarginwidth }
1360\permanent\def\innermarginwidth {\rightorleftpageaction\leftmarginwidth \rightmarginwidth}
1361\permanent\def\outermargindistance{\rightorleftpageaction\rightmargindistance\leftmargindistance }
1362\permanent\def\innermargindistance{\rightorleftpageaction\leftmargindistance \rightmargindistance}
1363
1364\permanent\def\outeredgewidth {\rightorleftpageaction\rightedgewidth \leftedgewidth }
1365\permanent\def\inneredgewidth {\rightorleftpageaction\leftedgewidth \rightedgewidth}
1366\permanent\def\outeredgedistance {\rightorleftpageaction\rightedgedistance\leftedgedistance }
1367\permanent\def\inneredgedistance {\rightorleftpageaction\leftedgedistance \rightedgedistance}
1368
1369\permanent\def\outerspacewidth {\rightorleftpageaction\cutspace \backspace}
1370\permanent\def\innerspacewidth {\rightorleftpageaction\backspace\cutspace }
1371
1372\permanent\def\leftmargintotal {\dimexpr\leftmarginwidth \leftmargindistance \relax}
1373\permanent\def\rightmargintotal {\dimexpr\rightmarginwidth\rightmargindistance\relax}
1374\permanent\def\leftedgetotal {\dimexpr\leftedgewidth \leftedgedistance \relax}
1375\permanent\def\rightedgetotal {\dimexpr\rightedgewidth \rightedgedistance \relax}
1376
1377\permanent\def\leftsidetotal {\dimexpr\leftmarginwidth \leftedgetotal \relax}
1378\permanent\def\rightsidetotal {\dimexpr\rightmarginwidth\rightedgetotal\relax}
1379\permanent\def\leftcombitotal {\dimexpr\leftmargintotal \leftedgetotal \relax}
1380\permanent\def\rightcombitotal {\dimexpr\rightmargintotal\rightedgetotal\relax}
1381
1382\permanent\def\innermargintotal {\dimexpr\innermarginwidth\innermargindistance\relax}
1383\permanent\def\outermargintotal {\dimexpr\outermarginwidth\outermargindistance\relax}
1384\permanent\def\inneredgetotal {\dimexpr\inneredgewidth \inneredgedistance \relax}
1385\permanent\def\outeredgetotal {\dimexpr\outeredgewidth \outeredgedistance \relax}
1386
1387\permanent\def\innercombitotal {\dimexpr\innermargintotal\inneredgetotal\relax}
1388\permanent\def\outercombitotal {\dimexpr\outermargintotal\outeredgetotal\relax}
1389\permanent\def\innersidetotal {\dimexpr\innermarginwidth\inneredgetotal\relax}
1390\permanent\def\outersidetotal {\dimexpr\outermarginwidth\outeredgetotal\relax}
1391
1392
1393
1394
1395
1396
1397
1398
1399\permanent\protected\def\startlocallayout
1400 {\globalpushmacro\page_paper_restore
1401 \globalpushmacro\currentlayout}
1402
1403\permanent\protected\def\stoplocallayout
1404 {\globalpopmacro\currentlayout
1405 \globalpopmacro\page_paper_restore
1406 \page_paper_restore
1407 \setuplayout[\currentlayout]\relax}
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422\fetchmodulecommand \showprint \f!page_run
1423\fetchmodulecommand \showframe \f!page_run
1424\fetchmodulecommand \showlayout \f!page_run
1425\fetchmodulecommand \showsetups \f!page_run
1426\fetchmodulecommand \showmargins \f!page_run
1427\fetchmodulecommand \showgrid \f!page_run
1428\fetchmodulecommand \showcentering\f!page_run
1429
1430\glet\page_grids_add_to_box\gobbleoneargument
1431\glet\page_grids_add_to_one\gobbleoneargument
1432\glet\page_grids_add_to_mix\gobbleoneargument
1433
1434
1435
1436\appendtoks
1437 \ifnum\realpageno>\plusone
1438 \page[\v!odd]
1439 \setuplayout
1440 \fi
1441\to \everysetuppagenumbering
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454\setuplayout
1455 [ \c!topspace=.08417508418\paperheight,
1456 \c!top=\zeropoint,
1457 \c!topdistance=\zeropoint,
1458 \c!header=.06734006734\paperheight,
1459 \c!headerdistance=\zeropoint,
1460 \c!height=.84175084175\paperheight,
1461 \c!footerdistance=\layoutparameter\c!headerdistance,
1462 \c!footer=.06734006734\paperheight,
1463 \c!bottomdistance=\layoutparameter\c!topdistance,
1464 \c!bottom=\zeropoint,
1465 \c!backspace=.11904761905\paperwidth,
1466 \c!edge=\zeropoint,
1467 \c!edgedistance=\layoutparameter\c!margindistance,
1468 \c!margin=.12649983170\paperwidth,
1469 \c!margindistance=.02008341748\paperwidth,
1470 \c!leftedge=\layoutparameter\c!edge,
1471 \c!leftedgedistance=\layoutparameter\c!edgedistance,
1472 \c!leftmargin=\layoutparameter\c!margin,
1473 \c!leftmargindistance=\layoutparameter\c!margindistance,
1474 \c!width=.71428571429\paperwidth,
1475 \c!rightmargindistance=\layoutparameter\c!margindistance,
1476 \c!rightmargin=\layoutparameter\c!margin,
1477 \c!rightedgedistance=\layoutparameter\c!edgedistance,
1478 \c!rightedge=\layoutparameter\c!edge,
1479 \c!veroffset=\zeropoint,
1480 \c!bottomspace=\zeropoint,
1481 \c!horoffset=\zeropoint,
1482 \c!cutspace=\zeropoint,
1483 \c!textwidth=,
1484 \c!textmargin=,
1485 \c!textdistance=\zeropoint,
1486 \c!style=,
1487 \c!color=,
1488 \c!marking=\v!off,
1489 \c!location=,
1490 \c!state=\v!start,
1491 \c!scale=1,
1492 \c!sx=1,
1493 \c!sy=1,
1494 \c!nx=1,
1495 \c!ny=1,
1496 \c!dx=\zeropoint,
1497 \c!dy=\zeropoint,
1498 \c!grid=\v!no,
1499 \c!direction=\v!normal,
1500 \c!preset=,
1501 \c!setups=\systemsetupsprefix\s!default,
1502 \c!clipoffset=\zeropoint,
1503 \c!lines=0,
1504 \c!paper=,
1505 \c!page=,
1506 \c!adaptive=\zeropoint,
1507 \c!limitstretch=\v!auto,
1508 \c!columns=\plusone,
1509 \c!columndistance=\zeropoint]
1510
1511\pushoverloadmode
1512 \newuserunit \textwidth tw
1513 \newuserunit \textheight th
1514 \newuserunit \hsize hs
1515 \newuserunit \vsize vs
1516\popoverloadmode
1517
1518
1519
1520
1521
1522
1523
1524
1525\definepapersize [A0] [\c!width=841mm,\c!height=1189mm]
1526\definepapersize [A1] [\c!width=594mm,\c!height=841mm]
1527\definepapersize [A2] [\c!width=420mm,\c!height=594mm]
1528\definepapersize [A3] [\c!width=297mm,\c!height=420mm]
1529\definepapersize [A4] [\c!width=210mm,\c!height=297mm]
1530\definepapersize [A5] [\c!width=148mm,\c!height=210mm]
1531\definepapersize [A6] [\c!width=105mm,\c!height=148mm]
1532\definepapersize [A7] [\c!width=74mm,\c!height=105mm]
1533\definepapersize [A8] [\c!width=52mm,\c!height=74mm]
1534\definepapersize [A9] [\c!width=37mm,\c!height=52mm]
1535\definepapersize [A10] [\c!width=26mm,\c!height=37mm]
1536
1537\definepapersize [A42][\c!width=\dimexpr297mm2\relax,\c!height=210mm]
1538
1539
1540\definepapersize [B0] [\c!width=1000mm,\c!height=1414mm]
1541\definepapersize [B1] [\c!width=707mm,\c!height=1000mm]
1542\definepapersize [B2] [\c!width=500mm,\c!height=707mm]
1543\definepapersize [B3] [\c!width=353mm,\c!height=500mm]
1544\definepapersize [B4] [\c!width=250mm,\c!height=353mm]
1545\definepapersize [B5] [\c!width=176mm,\c!height=250mm]
1546\definepapersize [B6] [\c!width=125mm,\c!height=176mm]
1547\definepapersize [B7] [\c!width=88mm,\c!height=125mm]
1548\definepapersize [B8] [\c!width=62mm,\c!height=88mm]
1549\definepapersize [B9] [\c!width=44mm,\c!height=62mm]
1550\definepapersize [B10] [\c!width=31mm,\c!height=44mm]
1551
1552\definepapersize [C0] [\c!width=917mm,\c!height=1297mm]
1553\definepapersize [C1] [\c!width=648mm,\c!height=917mm]
1554\definepapersize [C2] [\c!width=458mm,\c!height=648mm]
1555\definepapersize [C3] [\c!width=324mm,\c!height=458mm]
1556\definepapersize [C4] [\c!width=229mm,\c!height=324mm]
1557\definepapersize [C5] [\c!width=162mm,\c!height=229mm]
1558\definepapersize [C6] [\c!width=114mm,\c!height=162mm]
1559\definepapersize [C7] [\c!width=81mm,\c!height=114mm]
1560\definepapersize [C8] [\c!width=57mm,\c!height=81mm]
1561\definepapersize [C9] [\c!width=40mm,\c!height=57mm]
1562\definepapersize [C10] [\c!width=28mm,\c!height=40mm]
1563
1564
1565
1566
1567
1568\definepapersize [4 A0] [\c!width=1682mm,\c!height=2378mm]
1569\definepapersize [2 A0] [\c!width=1189mm,\c!height=1682mm]
1570\definepapersize [C6C5] [\c!width=114mm,\c!height=229mm]
1571
1572
1573
1574
1575
1576\definepapersize [S3] [\c!width=300pt,\c!height=225pt]
1577\definepapersize [S4] [\c!width=400pt,\c!height=300pt]
1578\definepapersize [S5] [\c!width=500pt,\c!height=375pt]
1579\definepapersize [S6] [\c!width=600pt,\c!height=450pt]
1580\definepapersize [S8] [\c!width=800pt,\c!height=600pt]
1581\definepapersize [SL] [\c!width=640pt,\c!height=400pt]
1582\definepapersize [SM] [\c!width=720pt,\c!height=450pt]
1583\definepapersize [SW] [\c!width=800pt,\c!height=450pt]
1584\definepapersize [HD] [\c!width=1920pt,\c!height=1080pt]
1585\definepapersize [HD] [\c!width=1920pt,\c!height=1200pt]
1586\definepapersize [HD] [\c!width=960pt,\c!height=540pt]
1587
1588
1589
1590\definepapersize [S33] [\c!width=300pt,\c!height=300pt]
1591\definepapersize [S44] [\c!width=400pt,\c!height=400pt]
1592\definepapersize [S55] [\c!width=500pt,\c!height=500pt]
1593\definepapersize [S66] [\c!width=600pt,\c!height=600pt]
1594
1595
1596
1597
1598\definepapersize [CD] [\c!width=120mm,\c!height=120mm]
1599
1600
1601
1602
1603\definepapersize [letter] [\c!width=8.5in,\c!height=11in]
1604\definepapersize [ledger] [\c!width=11in,\c!height=17in]
1605\definepapersize [tabloid] [\c!width=17in,\c!height=11in]
1606
1607\definepapersize [legal] [\c!width=8.5in,\c!height=14in]
1608\definepapersize [folio] [\c!width=8.5in,\c!height=13in]
1609\definepapersize [executive] [\c!width=7.25in,\c!height=10.5in]
1610
1611\definepapersize [A] [\c!width=8.5in,\c!height=11in]
1612\definepapersize [B] [\c!width=11in,\c!height=17in]
1613\definepapersize [C] [\c!width=17in,\c!height=22in]
1614
1615
1616
1617\definepapersize [envelope 9] [\c!width=8.88in,\c!height=3.88in]
1618\definepapersize [envelope 10] [\c!width=9.5in,\c!height=4.13in]
1619\definepapersize [envelope 11] [\c!width=10.38in,\c!height=4.5in]
1620\definepapersize [envelope 12] [\c!width=11.0in,\c!height=4.75in]
1621\definepapersize [envelope 14] [\c!width=11.5in,\c!height=5.0in]
1622\definepapersize [monarch] [\c!width=7.5in,\c!height=3.88in]
1623\definepapersize [check] [\c!width=8.58in,\c!height=3.88in]
1624\definepapersize [DL] [\c!width=110mm,\c!height=220mm]
1625\definepapersize [E4] [\c!width=280mm,\c!height=400mm]
1626
1627
1628
1629\definepapersize [RA0] [\c!width=860mm,\c!height=1220mm]
1630\definepapersize [RA1] [\c!width=610mm,\c!height=860mm]
1631\definepapersize [RA2] [\c!width=430mm,\c!height=610mm]
1632\definepapersize [RA3] [\c!width=305mm,\c!height=430mm]
1633\definepapersize [RA4] [\c!width=215mm,\c!height=305mm]
1634
1635
1636
1637\definepapersize [SRA0] [\c!width=900mm,\c!height=1280mm]
1638\definepapersize [SRA1] [\c!width=640mm,\c!height=900mm]
1639\definepapersize [SRA2] [\c!width=450mm,\c!height=640mm]
1640\definepapersize [SRA3] [\c!width=320mm,\c!height=450mm]
1641\definepapersize [SRA4] [\c!width=225mm,\c!height=320mm]
1642
1643
1644
1645\definepapersize [G5] [\c!width=169mm,\c!height=239mm]
1646\definepapersize [E5] [\c!width=155mm,\c!height=220mm]
1647
1648
1649
1650\definepapersize [A3plus] [\c!width=329mm,\c!height=483mm]
1651
1652
1653
1654\definepapersize [business] [\c!width=85mm,\c!height=55mm]
1655\definepapersize [businessUS] [\c!width=3.5in,\c!height=2in]
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671\setuppapersize
1672 [\c!distance=1.5cm]
1673
1674\definepapersize
1675 [oversized]
1676 [ \c!width=\dimexpr\paperwidth \layouttargetparameter\c!distance\relax,
1677 \c!height=\dimexpr\paperheight\layouttargetparameter\c!distance\relax]
1678
1679\definepapersize
1680 [undersized]
1681 [ \c!width=\dimexpr\paperwidth \layouttargetparameter\c!distance\relax,
1682 \c!height=\dimexpr\paperheight\layouttargetparameter\c!distance\relax]
1683
1684\definepapersize
1685 [doublesized]
1686 [ \c!width=\dimexpr \paperwidth \relax,
1687 \c!height=\dimexpr2\paperheight\relax]
1688
1689\definepapersize
1690 [doubleoversized]
1691 [ \c!width=\dimexpr \paperwidth \layouttargetparameter\c!distance\relax,
1692 \c!height=\dimexpr2\paperheight\layouttargetparameter\c!distance\relax]
1693
1694\definepapersize
1695 [doublewide]
1696 [ \c!width=\dimexpr2\paperwidth \relax,
1697 \c!height=\dimexpr \paperheight\relax]
1698
1699
1700
1701
1702\setuppapersize
1703 [A4]
1704
1705
1706
1707\definelayout
1708 [\v!page]
1709
1710\setuplayout
1711 [\v!page]
1712 [\c!backspace=\zeropoint,
1713 \c!cutspace=\zeropoint,
1714 \c!topspace=\zeropoint,
1715 \c!bottomspace=\zeropoint,
1716 \c!margin=\zeropoint,
1717 \c!edge=\zeropoint,
1718 \c!header=\zeropoint,
1719 \c!footer=\zeropoint,
1720 \c!top=\zeropoint,
1721 \c!bottom=\zeropoint,
1722 \c!leftmargin=\zeropoint,
1723 \c!rightmargin=\zeropoint,
1724 \c!leftedge=\zeropoint,
1725 \c!rightedge=\zeropoint,
1726 \c!textdistance=\zeropoint,
1727 \c!width=\v!middle,
1728 \c!height=\v!middle,
1729 \c!lines=0,
1730 \c!grid=\v!no]
1731
1732
1733
1734\definelayout
1735 [\v!middle]
1736 [\c!width=\v!middle,
1737 \c!height=\v!middle]
1738
1739
1740
1741\definelayout
1742 [\v!tight]
1743
1744\definelayout
1745 [\v!tight]
1746 [\v!page]
1747 [\c!backspace=5mm,
1748 \c!cutspace=5mm,
1749 \c!topspace=5mm,
1750 \c!bottomspace=5mm]
1751
1752\protect \endinput
1753 |