1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Page Macros Default Routine}
15
16
17
18
19\unprotect
20
21
22
23\newconstant \c_page_one_float_method
24
25\unexpanded\def\page_one_command_next_page
26 {\page_otr_eject_page}
27
28\unexpanded\def\page_one_command_next_page_and_inserts
29 {\page_otr_eject_page_and_flush_inserts}
30
31\unexpanded\def\page_one_command_set_hsize
32 {\global\hsize\textwidth
33 \columnwidth\textwidth}
34
35\unexpanded\def\page_one_command_set_float_hsize
36 {\global\hsize\textwidth}
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82\unexpanded\def\page_one_command_set_vsize
83 {\ifgridsnapping
84 \ifcase\layoutlines
85 \getrawnoflines\textheight
86 \else
87 \noflines\layoutlines
88 \fi
89 \global\vsize\noflines\openlineheight
90 \else
91 \global\vsize\textheight
92 \fi
93 \global\advance\vsize\d_page_adapts_delta
94
95
96 \settotalinsertionheight
97 \pagegoal\dimexpr\vsize\totalinsertionheight\relax}
98
99
100
101
102
103\pushoverloadmode
104 \setnewconstant\kindofpagetextareas\plustwo
105 \overloaded\let\kindofpagetextareas\kindofpagetextareas
106\popoverloadmode
107
108\def\page_one_registered_text_area_a
109 {\ifconditional\c_page_areas_enabled
110 \expandafter\page_one_registered_text_area_a_indeed
111 \else
112 \expandafter\firstofoneargument
113 \fi}
114
115\def\page_one_registered_text_area_b
116 {\ifconditional\c_page_areas_enabled
117 \expandafter\page_one_registered_text_area_b_indeed
118 \else
119 \expandafter\firstofoneargument
120 \fi}
121
122\def\page_one_registered_text_area_a_indeed
123 {\ifcase\kindofpagetextareas
124 \expandafter\firstofoneargument
125 \or
126 \expandafter\page_areas_register_direct
127 \or
128 \expandafter\firstofoneargument
129 \else
130 \expandafter\firstofoneargument
131 \fi}
132
133\def\page_one_registered_text_area_b_indeed
134 {\ifcase\kindofpagetextareas
135
136 \or
137
138 \or
139 \expandafter\page_areas_register_boxed
140 \else
141
142 \fi}
143
144\newdimen\d_page_one_natural_depth
145\newbox \b_page_one_bottom_notes
146\newbox \b_page_one_contents
147
148\let\page_one_command_package_show_state\relax
149
150
151
152
153
154\unexpanded\def\page_one_command_package_contents#1#2
155 {\bgroup
156 \strc_notes_check_if_bottom_present
157 \d_page_one_natural_depth\dp#2\relax
158
159
160
161
162
163 \setbox\b_page_one_contents\vbox to \textheight
164 {\page_otr_command_flush_top_insertions
165
166
167
168 \page_one_registered_text_area_a#1#2
169
170 \ifgridsnapping
171 \unskip
172 \vkern\dimexpr\openstrutdepth\d_page_one_natural_depth\relax
173 \prevdepth\openstrutdepth
174 \page_otr_command_flush_bottom_insertions
175 \vfil
176 \else\ifcase\bottomraggednessmode
177
178 \unskip
179 \vkern\dimexpr\openstrutdepth\d_page_one_natural_depth\relax
180 \prevdepth\openstrutdepth
181
182
183 \page_otr_command_flush_bottom_insertions
184 \vfil
185 \or
186
187 \page_otr_command_flush_bottom_insertions
188 \or
189
190 \unskip
191 \vkern\dimexpr\maxdepth\d_page_one_natural_depth\relax
192 \page_otr_command_flush_bottom_insertions
193 \fi\fi
194 \fakepagenotes}
195 \page_one_command_package_show_state
196 \ifconditional\c_notes_bottom_present
197 \ifgridsnapping
198 \ifcase\layoutlines
199 \getrawnoflines\textheight
200 \else
201 \noflines\layoutlines
202 \fi
203 \scratchoffset\dimexpr\numexpr\noflines\plusone\relax\lineheight\topskip\relax
204 \else
205 \scratchoffset\ht\b_page_one_contents
206 \fi
207 \setbox\b_page_one_bottom_notes\hpack
208 {\lower\scratchoffset\vbox{\placebottomnotes\par\kern\zeropoint}}
209 \smashbox\b_page_one_bottom_notes
210 \ht\b_page_one_contents\zeropoint
211 \page_one_registered_text_area_b
212 {\vpack to \textheight
213 {\box\b_page_one_contents
214 \box\b_page_one_bottom_notes}}
215 \else
216 \ht\b_page_one_contents\textheight
217 \page_one_registered_text_area_b
218 {\box\b_page_one_contents}
219 \fi
220 \egroup}
221
222\unexpanded\def\page_one_command_side_float_output
223 {\page_otr_construct_and_shipout\unvbox\normalpagebox\plusone}
224
225\unexpanded\def\page_one_command_routine
226 {\page_sides_output_routine}
227
228
229
230\newconditional\c_page_one_top_of_insert
231\newconditional\c_page_one_correct_top_insert \settrue\c_page_one_correct_top_insert
232\newskip \s_page_one_between_top_insert
233
234\def\page_one_prepare_top_float
235 {\ifdim\d_page_floats_inserted_top=\zeropoint
236 \settrue\c_page_one_top_of_insert
237 \else
238 \setfalse\c_page_one_top_of_insert
239 \fi
240 \s_page_one_between_top_insert\ifdim\d_strc_floats_top>\d_strc_floats_bottom\d_strc_floats_top\else\d_strc_floats_bottom\fi\relax
241 \global\advance\d_page_floats_inserted_top\dimexpr\ht\floatbox\dp\floatbox\s_page_one_between_top_insert\relax}
242
243\def\page_one_insert_top_float
244 {\floatingpenalty\zerocount
245 \insert\namedinsertionnumber\s!topfloat\bgroup
246 \forgetall
247 \ifconditional\c_page_one_top_of_insert
248 \ifconditional\c_page_one_correct_top_insert
249 \topskipcorrection
250 \kern\lineskip
251 \par
252 \prevdepth\maxdimen
253 \fi
254 \fi
255 \page_otr_command_flush_float_box
256 \vskip\s_page_one_between_top_insert
257 \egroup}
258
259\let\totaltopinserted\!!zeropoint
260\let\totalbotinserted\!!zeropoint
261
262\unexpanded\def\page_one_command_set_top_insertions
263 {\bgroup
264 \ifconditional\c_page_floats_some_waiting
265 \noffloatinserts\zerocount
266 \let\totaltopinserted\!!zeropoint
267 \page_one_command_set_top_insertions_indeed
268 \ifnum\rootfloatparameter\c!nbottom=\zerocount
269 \ifnum\rootfloatparameter\c!nlines>\zerocount
270 \ifdim\totaltopinserted>\zeropoint\relax
271 \ifdim\dimexpr\rootfloatparameter\c!nlines\lineheight\totaltopinserted\relax>\textheight
272 \showmessage\m!floatblocks8{\rootfloatparameter\c!nlines}
273 \page_otr_fill_and_eject_page
274 \fi
275 \fi
276 \fi
277 \fi
278 \fi
279 \egroup}
280
281\def\page_one_command_set_top_insertions_indeed
282 {\ifnum\noffloatinserts<\c_page_floats_n_of_top
283 \page_floats_get
284 \page_one_prepare_top_float
285 \ifdim\d_page_floats_inserted_top<\textheight\relax
286 \xdef\totaltopinserted{\the\d_page_floats_inserted_top}
287 \page_one_insert_top_float
288 \ifconditional\c_page_floats_some_waiting
289 \advance\noffloatinserts \plusone
290 \else
291 \noffloatinserts\c_page_floats_n_of_top\relax
292 \fi
293 \page_floats_report_flushed
294 \else
295 \page_floats_resave\s!text
296 \noffloatinserts\c_page_floats_n_of_top\relax
297 \fi
298 \else
299 \ifconditional\c_page_floats_some_waiting
300 \showmessage\m!floatblocks6{\the\c_page_floats_n_of_top}
301 \fi
302 \let\page_one_command_set_top_insertions_indeed\relax
303 \fi
304 \page_one_command_set_top_insertions_indeed}
305
306\unexpanded\def\page_one_command_set_bottom_insertions
307 {\bgroup
308 \ifconditional\c_page_floats_some_waiting
309 \noffloatinserts\zerocount
310 \page_one_command_set_bottom_insertions_indeed
311 \fi
312 \egroup}
313
314\def\page_one_command_set_bottom_insertions_indeed
315 {\ifnum\noffloatinserts<\c_page_floats_n_of_bottom\relax
316 \page_floats_get
317 \global\advance\d_page_floats_inserted_bottom\dimexpr\ht\floatbox\dp\floatbox\d_strc_floats_top\relax
318 \ifdim\d_page_floats_inserted_bottom<\pagegoal\relax
319 \floatingpenalty\zerocount
320 \insert\namedinsertionnumber\s!bottomfloat\bgroup
321 \forgetall
322 \blank[\rootfloatparameter\c!spacebefore]
323 \page_otr_command_flush_float_box
324 \egroup
325 \ifconditional\c_page_floats_some_waiting
326 \advance\noffloatinserts \plusone
327 \else
328 \noffloatinserts\c_page_floats_n_of_bottom
329 \fi
330 \page_floats_report_flushed
331 \else
332 \page_floats_resave\s!text
333 \noffloatinserts\c_page_floats_n_of_bottom\relax
334 \fi
335 \global\settrue\c_page_floats_not_permitted
336 \else
337 \ifconditional\c_page_floats_some_waiting
338 \showmessage\m!floatblocks7{\the\c_page_floats_n_of_bottom}
339 \fi
340 \let\page_one_command_set_bottom_insertions_indeed\relax
341 \fi
342 \page_one_command_set_bottom_insertions_indeed}
343
344\unexpanded\def\page_one_command_flush_top_insertions
345 {\ifvoid\namedinsertionnumber\s!topfloat\else
346 \page_one_command_flush_top_insertions_indeed
347 \fi
348 \global\d_page_floats_inserted_top\zeropoint}
349
350\def\page_one_command_flush_top_insertions_indeed
351 {\ifgridsnapping
352 \box\namedinsertionnumber\s!topfloat
353 \vkern\topskip
354 \vkern\strutheight
355 \else
356 \ifcase\c_page_floats_insertions_topskip_mode
357
358 \or
359
360 \vskip\topskip
361 \vkern\strutheight
362 \fi
363 \unvbox\namedinsertionnumber\s!topfloat
364 \fi}
365
366\unexpanded\def\page_one_command_flush_bottom_insertions
367 {\ifvoid\namedinsertionnumber\s!bottomfloat\else
368 \page_one_command_flush_bottom_insertions_indeed
369 \fi
370 \global\d_page_floats_inserted_bottom\zeropoint
371 \global\setfalse\c_page_floats_not_permitted}
372
373\def\page_one_command_flush_bottom_insertions_indeed
374 {\ifgridsnapping
375
376 \snaptogrid\hbox{\box\namedinsertionnumber\s!bottomfloat}
377
378 \else
379 \rootfloatparameter\c!bottombefore
380 \unvbox\namedinsertionnumber\s!bottomfloat
381 \rootfloatparameter\c!bottomafter
382 \fi}
383
384\unexpanded\def\page_one_command_flush_floats
385 {\global\settrue\c_page_floats_flushing
386 \ifconditional\c_page_floats_some_waiting
387 \par
388
389
390 \page_one_command_flush_floats_indeed
391 \fi
392 \global\savednoffloats\zerocount
393 \global\setfalse\c_page_floats_some_waiting
394 \global\setfalse\c_page_floats_flushing}
395
396\unexpanded\def\page_one_command_flush_float_box
397 {\ifconditional\c_page_floats_center_box \ifdim\wd\floatbox<\hsize
398 \global\setbox\floatbox\hpack to \hsize{\hss\box\floatbox\hss}
399 \fi \fi
400 \snaptogrid\hpack{\box\floatbox}}
401
402\def\page_one_command_floats_get_compressed
403 {\setfalse\c_page_floats_center_box
404
405
406
407
408 \global\setbox\floatbox\hbox to \hsize
409 {\hfil
410 \dorecurse\nofcollectedfloats
411 {\ifcase\columndirection
412 \page_floats_flush\s!text\plusone
413 \else
414 \page_floats_flush\s!text{\the\numexpr\nofcollectedfloats\recurselevel1\relax}
415 \fi
416 \hpack to \ifdim\naturalfloatwd>\makeupwidth\makeupwidth\else\naturalfloatwd\fi
417 {\hss\box\floatbox\hss}
418 \ifnum\recurselevel<\nofcollectedfloats
419 \hfil
420 \fi}
421 \hfil}}
422
423\def\page_one_command_flush_floats_indeed
424 {\ifconditional\c_page_floats_some_waiting
425 \ifconditional\c_page_floats_pack_flushed
426 \page_floats_collect\s!text\hsize\d_page_floats_compress_distance
427 \ifcase\nofcollectedfloats
428 \page_floats_get
429 \or
430 \page_floats_get
431 \else
432 \page_one_command_floats_get_compressed
433 \fi
434 \else
435 \page_floats_get
436 \fi
437
438
439
440 \doplacefloatbox
441 \expandafter\page_one_command_flush_floats_indeed
442 \fi}
443
444\unexpanded\def\page_one_command_flush_margin_blocks
445 {\ifconditional\c_page_margin_blocks_present
446 \ifdim\pagetotal=\zeropoint
447 \null
448 \fi
449 \page_otr_command_next_page
450 \ifvoid\b_page_margin_blocks
451 \global\setfalse\c_page_margin_blocks_present
452 \else
453 \doubleexpandafter\page_one_command_flush_margin_blocks
454 \fi
455 \fi}
456
457\unexpanded\def\page_one_command_check_if_float_fits
458 {\ifconditional\c_page_floats_not_permitted
459 \global\setfalse\c_page_floats_room
460 \else
461
462 \begingroup
463 \scratchdimen\dimexpr\pagetotal\lineheight\relax
464 \ifdim\scratchdimen>\pagegoal
465 \goodbreak
466 \fi
467
468 \endgroup
469 \scratchdimenone\dimexpr
470 \pagetotal
471 \floatheight
472 \d_strc_floats_top
473 \d_strc_floats_overflow
474 \pageshrink
475 \relax
476 \scratchdimentwo\pagegoal
477 \relax
478 \ifcase\c_page_one_float_method
479
480 \or
481
482
483 \advance\scratchdimentwo \strutdp
484 \or
485
486 \advance\scratchdimenone \onepoint
487 \fi
488 \relax
489 \ifdim\scratchdimenone>\scratchdimentwo
490 \global\setfalse\c_page_floats_room
491 \else
492 \global\settrue\c_page_floats_room
493 \fi
494 \fi}
495
496\unexpanded\def\page_one_command_flush_saved_floats
497 {\global\d_page_floats_inserted_top\zeropoint
498 \global\d_page_floats_inserted_bottom\zeropoint
499 \ifconditional\c_page_floats_flushing \else
500 \page_one_command_set_top_insertions
501 \page_one_command_set_bottom_insertions
502 \ifconditional\c_page_floats_some_waiting
503 \doif{\rootfloatparameter\c!cache}\v!no\page_one_command_flush_floats
504 \else\ifconditional\c_page_margin_blocks_present
505 \page_one_command_flush_floats
506 \fi\fi
507 \fi}
508
509
510
511
512
513
514
515
516
517
518
519\def\page_one_place_float_here_indeed
520 {\ifgridsnapping
521
522 \else
523
524
525
526 \checkprevdepth
527 \fi
528 \doplacefloatbox
529 \page_floats_report_total
530 \dohandlenextfloatindent}
531
532\def\page_one_place_float_force
533 {\showmessage\m!floatblocks9\empty
534 \page_one_place_float_here_indeed}
535
536\def\page_one_place_float_side_indeed#1
537 {\setbox\floatbox\vpack{\box\floatbox}
538 \wd\floatbox\floatwidth
539 #1{\box\floatbox}
540 \doifinset\v!tall\floatlocationmethod\page_sides_flush_floats_after_par}
541
542\def\page_one_place_float_left
543 {\page_one_place_float_side_indeed
544 \page_sides_process_float_left
545 \presetindentation}
546
547\def\page_one_place_float_right
548 {\page_one_place_float_side_indeed
549 \page_sides_process_float_right}
550
551\def\page_one_place_float_margin
552 {\page_margin_blocks_process_float
553 \nonoindentation}
554
555\def\page_one_place_float_leftmargin
556 {\page_one_place_float_side_indeed
557 \page_sides_process_float_leftmargin
558 \nonoindentation}
559
560\def\page_one_place_float_rightmargin
561 {\page_one_place_float_side_indeed
562 \page_sides_process_float_rightmargin
563 \nonoindentation}
564
565\def\page_one_place_float_leftedge
566 {\page_one_place_float_side_indeed
567 \page_sides_process_float_leftedge}
568
569\def\page_one_place_float_rightedge
570 {\page_one_place_float_side_indeed
571 \page_sides_process_float_rightedge}
572
573\def\page_one_place_float_inmargin
574 {\page_one_place_float_side_indeed
575 \page_sides_process_float_cutspace}
576
577\def\page_one_place_float_backspace
578 {\page_one_place_float_side_indeed
579 \page_sides_process_float_backspace}
580
581\def\page_one_place_float_cutspace
582 {\page_one_place_float_side_indeed
583 \page_sides_process_float_cutspace}
584
585\def\page_one_place_float_page {\page_floats_save_page_float \s!page \floatlocationmethod}
586\def\page_one_place_float_leftpage {\page_floats_save_page_float \s!leftpage \floatlocationmethod}
587\def\page_one_place_float_rightpage {\page_floats_save_page_float \s!rightpage\floatlocationmethod}
588\def\page_one_place_float_somewhere {\page_floats_save_somewhere_float\s!somewhere\floatlocationmethod}
589
590\def\page_one_place_float_here
591 {\page_one_place_float_otherwise_here}
592
593\def\page_one_place_float_auto
594 {\page_one_place_float_otherwise
595 \nonoindentation}
596
597\def\page_one_place_float_top
598 {\page_one_place_float_otherwise
599 \nonoindentation}
600
601\def\page_one_place_float_bottom
602 {\page_one_place_float_otherwise
603 \nonoindentation}
604
605\def\page_one_place_float_otherwise
606 {\doifelseinset\v!here\floatlocationmethod
607 \page_one_place_float_otherwise_here
608 \page_one_place_float_otherwise_else}
609
610\def\page_one_place_float_otherwise_here
611 {\doifelseinset\v!always\floatlocationmethod
612 {\page[\v!preference]
613 \page_otr_command_check_if_float_fits
614 \ifconditional\c_page_floats_room
615 \page_one_place_float_here_indeed
616 \else
617 \showmessage\m!floatblocks9\empty
618 \page_floats_resave\s!text
619 \fi}
620 {\ifconditional\c_page_floats_some_waiting
621 \page_floats_save\s!text
622 \nonoindentation
623 \else
624 \page[\v!preference]
625 \page_otr_command_check_if_float_fits
626 \ifconditional\c_page_floats_room
627 \page_one_place_float_here_indeed
628 \else
629 \page_floats_save\s!text
630 \nonoindentation
631 \fi
632 \fi}}
633
634\def\page_one_place_float_otherwise_else
635 {\doifelseinset\v!always\floatlocationmethod
636 {\page_otr_command_check_if_float_fits
637 \ifconditional\c_page_floats_room
638 \page_one_place_float_auto_top_bottom
639 \else
640 \showmessage\m!floatblocks9\empty
641 \page_floats_resave\s!text
642 \fi}
643 {\page_otr_command_check_if_float_fits
644 \ifconditional\c_page_floats_room
645 \page_one_place_float_auto_top_bottom
646 \else
647 \page_floats_save\s!text
648 \nonoindentation
649 \fi}}
650
651\def\floatautofactor{.5}
652
653\def\page_one_place_float_auto_top_bottom
654 {\ifx\floatmethod\v!auto
655 \ifdim\pagetotal<\floatautofactor\pagegoal
656 \page_one_place_float_top_indeed
657 \else
658 \page_one_place_float_bottom_indeed
659 \fi
660 \else
661 \ifx\floatmethod\v!top
662 \page_one_place_float_top_indeed
663 \else\ifx\floatmethod\v!bottom
664 \page_one_place_float_bottom_indeed
665 \else
666 \page_one_place_float_here_indeed
667 \fi\fi
668 \fi}
669
670\def\page_one_place_float_top_indeed
671 {\page_one_prepare_top_float
672 \page_one_insert_top_float
673 \page_floats_report_total}
674
675\def\page_one_place_float_bottom_indeed
676 {\global\advance\d_page_floats_inserted_bottom\dimexpr\ht\floatbox\dp\floatbox\d_strc_floats_top\relax
677 \floatingpenalty\zerocount
678 \insert\namedinsertionnumber\s!bottomfloat\bgroup
679 \forgetall
680 \blank[\rootfloatparameter\c!spacebefore]
681 \page_otr_command_flush_float_box
682 \egroup
683 \page_floats_report_total}
684
685\def\page_one_place_float_face
686 {
687 \startopposite
688 \page_otr_command_flush_float_box
689 \stopopposite
690 }
691
692\unexpanded\def\page_one_command_flush_side_floats
693 {\page_sides_flush_floats}
694
695\unexpanded\def\page_one_command_synchronize_side_floats
696 {\page_sides_synchronize_floats}
697
698\unexpanded\def\page_one_command_test_page
699 {\testpage}
700
701\unexpanded\def\page_one_command_flush_all_floats
702 {\ifconditional\c_page_floats_some_waiting
703 \begingroup
704 \c_page_floats_n_of_top\plusthousand
705 \c_page_floats_n_of_bottom\zerocount
706
707
708
709
710 \pagebaselinecorrection
711
712 \page_otr_command_flush_floats
713 \endgroup
714 \fi}
715
716\unexpanded\def\page_one_command_flush_facing_floats
717 {\strc_floats_facing_flush}
718
719\defineoutputroutine
720 [\s!singlecolumn]
721 [\s!page_otr_command_routine =\page_one_command_routine,
722 \s!page_otr_command_package_contents =\page_one_command_package_contents,
723 \s!page_otr_command_set_vsize =\page_one_command_set_vsize,
724 \s!page_otr_command_set_hsize =\page_one_command_set_hsize,
725
726 \s!page_otr_command_next_page =\page_one_command_next_page,
727 \s!page_otr_command_next_page_and_inserts =\page_one_command_next_page_and_inserts,
728 \s!page_otr_command_set_top_insertions =\page_one_command_set_top_insertions,
729 \s!page_otr_command_set_bottom_insertions =\page_one_command_set_bottom_insertions,
730 \s!page_otr_command_flush_top_insertions =\page_one_command_flush_top_insertions,
731 \s!page_otr_command_flush_bottom_insertions=\page_one_command_flush_bottom_insertions,
732 \s!page_otr_command_check_if_float_fits =\page_one_command_check_if_float_fits,
733
734 \s!page_otr_command_flush_float_box =\page_one_command_flush_float_box,
735 \s!page_otr_command_side_float_output =\page_one_command_side_float_output,
736 \s!page_otr_command_synchronize_side_floats=\page_one_command_synchronize_side_floats,
737 \s!page_otr_command_flush_floats =\page_one_command_flush_floats,
738 \s!page_otr_command_flush_side_floats =\page_one_command_flush_side_floats,
739 \s!page_otr_command_flush_saved_floats =\page_one_command_flush_saved_floats,
740 \s!page_otr_command_flush_all_floats =\page_one_command_flush_all_floats,
741 \s!page_otr_command_flush_margin_blocks =\page_one_command_flush_margin_blocks,
742 \s!page_otr_command_test_column =\page_one_command_test_page,
743 \s!page_otr_command_flush_facing_floats =\page_one_command_flush_facing_floats
744]
745
746
747
748
749\protect \endinput
750 |