page-one.mkiv /size: 25 Kb    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=page-one,
3%D        version=2000.10.20,
4%D          title=\CONTEXT\ Page Macros,
5%D       subtitle=Default Routine,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Page Macros / Default Routine}
15
16%D This is just the good old \CONTEXT\ output routine, which
17%D has been there right from the start.
18
19\unprotect
20
21% OTRONE: basic single column
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} % bonus so that it's not zero
34
35\unexpanded\def\page_one_command_set_float_hsize
36  {\global\hsize\textwidth}
37
38% \newdimen\d_page_one_saved_vsize
39%
40% \unexpanded\def\page_one_command_set_vsize
41%   {\ifgridsnapping
42%      \ifcase\layoutlines
43%        \getrawnoflines\textheight
44%      \else
45%        \noflines\layoutlines
46%      \fi
47%      \global\vsize\noflines\openlineheight
48%    \else
49%      \global\vsize\textheight
50%    \fi
51%    \ifdim\pagegoal<\maxdimen
52%      \ifdim\d_page_one_saved_vsize=\vsize
53%        % let's assume that the layout didn't change
54%      \else
55%        \global\d_page_one_saved_vsize\vsize
56%        \pagegoal\dimexpr\vsize-\d_page_floats_inserted_top-\d_page_floats_inserted_bottom\relax
57%      % \bgroup
58%      %   \global\d_page_one_saved_vsize\vsize
59%      %   \advance\vsize-\d_page_floats_inserted_top
60%      %   \advance\vsize-\d_page_floats_inserted_bottom
61%      %   \pagegoal\vsize
62%      % \egroup
63%      \fi
64%    \fi}
65
66% \unexpanded\def\page_one_command_set_vsize
67%   {\ifgridsnapping
68%      \ifcase\layoutlines
69%        \getrawnoflines\textheight
70%      \else
71%        \noflines\layoutlines
72%      \fi
73%      \global\vsize\noflines\openlineheight
74%    \else
75%      \global\vsize\textheight
76%    \fi
77%    \global\advance\vsize\d_page_adapts_delta
78%    % alternatively we could set it in builders.buildpage_filter
79%  % \ifdim\pagegoal<\maxdimen .. \fi
80%    \pagegoal\dimexpr\vsize-\d_page_floats_inserted_top-\d_page_floats_inserted_bottom\relax}
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 % \pagegoal\dimexpr\vsize-\d_page_floats_inserted_top-\d_page_floats_inserted_bottom\relax}
95 % per 2021/9/9 : otherwise weird notes overlap with side floats
96   \settotalinsertionheight
97   \pagegoal\dimexpr\vsize-\totalinsertionheight\relax}
98
99% 1 = partial page, 2 = whole page, 3 = partial page
100
101% We really need a setting! Todo, what key to use?
102
103\pushoverloadmode
104    \setnewconstant\kindofpagetextareas\plustwo % \plusone can become default some day
105    \overloaded\let\kindofpagetextareas\kindofpagetextareas
106\popoverloadmode
107
108\def\page_one_registered_text_area_a % two arguments: (un)vbox n
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 % one arguments: content
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 % two arguments: (un)vbox n
123  {\ifcase\kindofpagetextareas
124     \expandafter\firstofoneargument
125   \or % partial page (experimental)
126     \expandafter\page_areas_register_direct
127   \or % whole page   (default)
128     \expandafter\firstofoneargument
129   \else
130     \expandafter\firstofoneargument
131   \fi}
132
133\def\page_one_registered_text_area_b_indeed % one arguments: content
134  {\ifcase\kindofpagetextareas
135     % \expandafter\firstofoneargument
136   \or % partial page (experimental)
137     % \expandafter\firstofoneargument
138   \or % whole page   (default)
139     \expandafter\page_areas_register_boxed
140   \else
141     % \expandafter\firstofoneargument
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% \fakepagenotes ... needs checking
151%
152% we can also have bottom notes on top of bottom insertions
153
154\unexpanded\def\page_one_command_package_contents#1#2% \box<n> \unvbox<n> % this one will be redone (checked)
155  {\bgroup
156   \strc_notes_check_if_bottom_present
157   \d_page_one_natural_depth\dp#2\relax
158   % we need to set the height as otherwise the shrink will not kick in so the following
159   % no longer applies:
160   %
161   % \setbox\b_page_one_contents\vbox \ifconditional\c_notes_bottom_present to \textheight \fi
162   %
163   \setbox\b_page_one_contents\vbox to \textheight % probably no pack
164     {\page_otr_command_flush_top_insertions
165      % this is messy ... we will provide a more tight area (no big deal as we can
166      % do that at the lua end)
167% \parfillskip\zeropoint
168      \page_one_registered_text_area_a#1#2% \unvbox <box>
169      %
170      \ifgridsnapping
171        \unskip % new per 2019-06-18, otherwise weird bottom floats
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        % ragged (default)
178        \unskip % new per 2019-06-18, otherwise weird bottom floats
179        \vkern\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax
180        \prevdepth\openstrutdepth
181        % these have whitespace before but we can have some more options
182        % like a \vfill or so
183        \page_otr_command_flush_bottom_insertions
184        \vfil
185      \or
186        % align (normal)
187        \page_otr_command_flush_bottom_insertions
188      \or
189        % baseline
190        \unskip % new per 2019-06-18, otherwise weird bottom floats
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}}% kerns makes notes sit on bottom % pack ?
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} % three arguments, we need to be in the output group
224
225\unexpanded\def\page_one_command_routine
226  {\page_sides_output_routine}
227
228%D Insertions
229
230\newconditional\c_page_one_top_of_insert
231\newconditional\c_page_one_correct_top_insert  \settrue\c_page_one_correct_top_insert % false moves up (tight)
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 % maybe remember last beforeskip
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 % [xx] new: see icare topbleed
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 % was tripple: vfilll
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 % vgl topfloats s!
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 % less tracing
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 % [xx] new: see icare topbleed
355   \else
356     \ifcase\c_page_floats_insertions_topskip_mode
357       % 0: default, do nothing
358     \or
359       % 1: no topskip (crossed fingers)
360       \vskip-\topskip % skip !
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   % \rootfloatparameter\c!bottombefore
376     \snaptogrid\hbox{\box\namedinsertionnumber\s!bottomfloat}%
377   % \rootfloatparameter\c!bottomafter
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     % if kept, then option and definitely off in gridmode ! ! ! !
389     % \ifvmode \prevdepth\maxdimen \fi % prevents whitespace; problematic in icare tests
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}} % was copy
401
402\def\page_one_command_floats_get_compressed
403  {\setfalse\c_page_floats_center_box % not needed as we do call directly
404   %% no longer (interferes with footnotes):
405   %%
406   %% \page_one_command_set_vsize % test 2011.06.24.001
407   %%
408   \global\setbox\floatbox\hbox to \hsize
409     {\hfil
410      \dorecurse\nofcollectedfloats
411        {\ifcase\columndirection % nog document wide
412           \page_floats_flush\s!text\plusone
413         \else
414           \page_floats_flush\s!text{\the\numexpr\nofcollectedfloats-\recurselevel+1\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     % there is a chance that due to rounding errors, the float
438     % fits on a page where it was first rejected, in which case
439     % the prevdepth is -maxdimen and we cannot obey the grid
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 % \ifvoid\b_page_margin_blocks \else
446     \ifdim\pagetotal=\zeropoint
447        \null % \fixedspace
448     \fi
449     \page_otr_command_next_page % \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     % new per 31/5/2004, should be an option, only one column mode
462     \begingroup
463     \scratchdimen\dimexpr\pagetotal+\lineheight\relax
464     \ifdim\scratchdimen>\pagegoal
465       \goodbreak % hack ?
466     \fi
467     % should be an option
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 % needed
478     \ifcase\c_page_one_float_method
479       % method 0 : raw
480     \or
481       % method 1 : safe
482       % too fuzzy as it can change and for a high page it's a lot : \scratchdimentwo .99\pagegoal
483       \advance\scratchdimentwo -\strutdp
484     \or
485       % method 2 : tight
486       \advance\scratchdimenone -\onepoint
487     \fi
488     \relax % really needed ! ! ! !
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 % could be _otr_
504     \else\ifconditional\c_page_margin_blocks_present
505       \page_one_command_flush_floats
506     \fi\fi
507   \fi}
508
509% \def\page_one_place_float_here_indeed
510%   {\ifgridsnapping
511%      % otherwise real bad outcome
512%    \else
513%      \baselinecorrection % this has to be done better (and definitely not in column mode)
514%    \fi
515%    \doplacefloatbox
516%    \page_floats_report_total
517%    \dohandlenextfloatindent}
518
519\def\page_one_place_float_here_indeed
520  {\ifgridsnapping
521     % otherwise real bad outcome
522   \else
523    % this was not really applied (delayed)
524    % \baselinecorrection % this has to be done better (and definitely not in column mode)
525    % so we now use this:
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}% ? can go
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} % new, due to popular request
554
555\def\page_one_place_float_leftmargin
556  {\page_one_place_float_side_indeed
557   \page_sides_process_float_leftmargin
558   \nonoindentation} % new, due to popular request
559
560\def\page_one_place_float_rightmargin
561  {\page_one_place_float_side_indeed
562   \page_sides_process_float_rightmargin
563   \nonoindentation} % new, due to popular request
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} % new, due to popular request
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} % new, due to popular request
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 % when empty page, maxdimen
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 % maybe remember last beforeskip
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 % links, rechts, midden, hoog, midden, laag
686  {%\checkwaitingfloats{#1}%
687   \startopposite
688   \page_otr_command_flush_float_box
689   \stopopposite
690  }%\page_floats_report_total}
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     % this is needed in case a float that has been stored
707     % ends up at the current page; this border case occurs when
708     % the calculated room is 'eps' smaller that the room available
709     % when just flushing; so now we have (maybe optional):
710     \pagebaselinecorrection % hm, needs checking, not needed when no floats
711     % alas, this is tricky but needed (first surfaced in prikkels)
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 % \s!page_otr_command_synchronize_hsize      =\page_one_command_synchronize_hsize,
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 % \s!page_otr_command_set_float_hsize        =\page_one_command_set_float_hsize,
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% \setupoutputroutine
747%   [\s!singlecolumn]
748
749\protect \endinput
750