page-pcl.mkiv /size: 30 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=page-pcl,
3
%D version=2017.11.08,
4
%D title=\CONTEXT\ Page Macros,
5
%D subtitle=Page Columns,
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
/
Page
Columns
}
15 16
%D This is very experimental code! We took a bit from the mixed columns and single
17
%D column page code. This one works acceptable with floats and is for whole double
18
%D column documents. We don't balance (yet). Footnotes are per column. One can have
19
%D side floats too. No balancing and other fancy features.
20
%D
21
%D Don't use this in production! Although the main approach will stay there might be
22
%D changes in the way floats are dealt with. Not much testing has been done but as
23
%D we stay close to the single column mode we expect most to just work. Only floats
24
%D are the (usual) pain. Backgrounds, line numbering, etc.\ not tested either.
25 26
\unprotect
27 28
\definemeasure
[
onecolumn
]
[
\columnwidth
]
29
\definemeasure
[
twocolumns
]
[
\dimexpr
\plustwo
\columnwidth
+
\columndistance
\relax
]
30
\definemeasure
[
threecolumns
][
\dimexpr
\plusthree
\columnwidth
+
\plustwo
\columndistance
\relax
]
31
\definemeasure
[
fourcolumns
]
[
\dimexpr
\plusfour
\columnwidth
+
\plusthree
\columndistance
\relax
]
32 33
\newcount
\c_page_col_n_of_columns
\c_page_col_n_of_columns
\plusone
34
\newcount
\c_page_col_current
\c_page_col_current
\plusone
35
\newdimen
\d_page_col_distance
36
\newdimen
\d_page_col_max_height
37
\newdimen
\d_page_col_max_width
38
%newdimen \d_page_col_balance_step
39
\newdimen
\d_page_col_column_width
40
\newdimen
\d_page_col_top_height
41
\newdimen
\d_page_col_top_width
42
\newdimen
\d_page_col_available
43
\newdimen
\d_page_col_sofar
44
\newconditional
\c_page_col_page
45 46
%D We need to step over empty columns.
47 48
\unexpanded
\def
\page_col_command_next_page
49
{
\page_col_eject_page
}
50 51
\unexpanded
\def
\page_col_column
52
{
\page_otr_eject_page
}
53 54
\unexpanded
\def
\page_col_eject_page
55
{
\begingroup
56
\scratchcountertwo
\realpageno
57
\page_otr_eject_page
58
\scratchcounterone
\c_page_col_current
59
\scratchcounterthree
\zerocount
60
\doloop
{
%
61
\ifnum
\scratchcounterthree
>
\plushundred
62
% too many attempts
63
\exitloop
64
\else\ifnum
\realpageno
>
\scratchcountertwo
65
% we advanced at least one page so we're done
66
\exitloop
67
\else
68
\ifnum
\scratchcounterone
=
\c_page_col_current
69
\dontleavehmode\null
70
\fi
71
\page_otr_eject_page
72
\scratchcounterone
\c_page_col_current
73
\advance
\scratchcounterthree
\plusone
74
\fi\fi
75
}
%
76
\endgroup
}
77 78
%D \unknown
79 80
\unexpanded
\def
\page_col_command_next_page_and_inserts
81
{
\page_otr_eject_page_and_flush_inserts
}
82 83
%D \unknown
84 85
\unexpanded
\def
\page_col_command_set_hsize
86
{
\global\hsize
\d_page_col_column_width
\relax
87
\global
\d_page_col_available
\dimexpr
88
\numexpr
\c_page_col_n_of_columns
-
\c_page_col_current
+
\plusone
\relax
\d_page_col_column_width
89
+
\numexpr
\c_page_col_n_of_columns
-
\c_page_col_current
\relax
\d_page_col_distance
90
\relax
91
\global
\d_page_col_sofar
92
\ifnum
\c_page_col_n_of_columns
=
\plusone
93
\zeropoint
94
\else
95
\numexpr
\c_page_col_n_of_columns
-
\plusone
\relax
96
\dimexpr
\d_page_col_column_width
+
\d_page_col_distance
\relax
97
\fi
98
% consistent with mixed:
99
\textwidth
\d_page_col_column_width
}
100 101
%D \unknown
102 103
\unexpanded
\def
\page_col_command_set_vsize
% \page_one_command_set_vsize minus the pagegoal setting
104
{
\ifgridsnapping
105
\ifcase
\layoutlines
106
\getrawnoflines
\textheight
107
\else
108
\noflines
\layoutlines
109
\fi
110
\global\vsize
\noflines
\openlineheight
111
\else
112
\global\vsize
\textheight
113
\fi
}
114 115
%D \unknown
116 117
\def
\page_col_registered_text_area_b
#
1
%
118
{
\begingroup
119
\makeupwidth
\d_page_col_column_width
120
\page_one_registered_text_area_b
{
#
1
}
%
121
\endgroup
}
122 123
\unexpanded
\def
\page_col_command_package_contents
#
1
#
2
% \box<n> \unvbox<n> % this one will be redone (checked)
124
{
\bgroup
125
\setbox
\b_page_one_contents
\vbox
to
\textheight
126
{
\page_one_registered_text_area_a
#
1
#
2
}
%
127
\page_one_command_package_show_state
128
\ht
\b_page_one_contents
\textheight
129
\page_col_registered_text_area_b
130
{
\box
\b_page_one_contents
}
%
131
\egroup
}
132 133
\unexpanded
\def
\page_col_command_package_contents_one
#
1
#
2
% \box<n> \unvbox<n> % this one will be redone (checked)
134
{
\bgroup
135
\forgetall
136
% see one for comments as it is similar
137
\strc_notes_check_if_bottom_present
138
\d_page_one_natural_depth
\dp
#
2
\relax
139
\setbox
\b_page_one_contents
\vbox
to
\textheight
140
{
\page_col_command_flush_top_insertions
141
\page_one_registered_text_area_a
#
1
#
2
%
142
\hsize
\d_page_col_column_width
143
\ifgridsnapping
144
\vskip\dimexpr
\openstrutdepth
-
\d_page_one_natural_depth
\relax
145
\prevdepth
\openstrutdepth
146
\page_col_command_flush_bottom_insertions
147
\vfil
148
\else\ifcase
\bottomraggednessmode
149
% ragged (default)
150
\vskip\dimexpr
\openstrutdepth
-
\d_page_one_natural_depth
\relax
151
\prevdepth
\openstrutdepth
152
\page_col_command_flush_bottom_insertions
153
\vfil
154
\or
155
% align (normal)
156
\page_col_command_flush_bottom_insertions
157
\or
158
% baseline
159
\kern\dimexpr\maxdepth
-
\d_page_one_natural_depth
\relax
160
\page_col_command_flush_bottom_insertions
161
\fi\fi
162
\fakepagenotes
}
%
163
\page_one_command_package_show_state
164
\ifconditional
\c_notes_bottom_present
165
\ifgridsnapping
166
\ifcase
\layoutlines
167
\getrawnoflines
\textheight
168
\else
169
\noflines
\layoutlines
170
\fi
171
\scratchoffset
\dimexpr\numexpr
\noflines
-
\plusone
\relax
\lineheight
+
\topskip\relax
172
\else
173
\scratchoffset
\ht
\b_page_one_contents
174
\fi
175
\setbox
\b_page_one_bottom_notes
\hpack
176
{
\checksinglecolumnfootnotes
% ?
177
\hsize
\d_page_col_column_width
178
\setupnotes
[
\c!width
=
\textwidth
]
%
179
\lower
\scratchoffset
\vbox
{
\placebottomnotes
\par\kern
\zeropoint
}}
%
180
\ht
\b_page_one_contents
\zeropoint
181
\wd
\b_page_one_contents
\zeropoint
182
\ht
\b_page_one_bottom_notes
\zeropoint
183
\wd
\b_page_one_bottom_notes
\zeropoint
184
\wd
\b_page_one_bottom_notes
\d_page_col_column_width
185
\page_col_registered_text_area_b
186
{
\vpack
to
\textheight
187
{
\hpack
{
\box
\b_page_one_contents
\box
\b_page_one_bottom_notes
}}}
%
188
\else
189
\ht
\b_page_one_contents
\textheight
190
\wd
\b_page_one_contents
\d_page_col_column_width
191
\page_col_registered_text_area_b
192
{
\box
\b_page_one_contents
}
%
193
\fi
194
\egroup
}
195 196
%D \unknown
197 198
\unexpanded
\def
\page_col_command_side_float_output
199
{
% % %
200
\ifvoid
\namedinsertionnumber
\s!topfloat
\else
201
\scratchwidth
\wd
\namedinsertionnumber
\s!topfloat
202
\ifdim
\scratchwidth
>
\d_page_col_top_width
203
\global
\d_page_col_top_width
\scratchwidth
204
\fi
205
\global
\d_page_col_top_height
\ht
\namedinsertionnumber
\s!topfloat
206
\fi
207
% % %
208
\setbox
\scratchbox
\vbox
\bgroup
209
\page_col_command_package_contents_one
\unvbox
\normalpagebox
210
\egroup
211
\putboxincache
\s!pagecolumn
{
\number
\c_page_col_current
}
\scratchbox
212
\ifnum
\c_page_col_current
=
\c_page_col_n_of_columns
213
\page_col_routine_package
214
\page_otr_construct_and_shipout
\box
\normalpagebox\plusone
215
\global
\c_page_col_current
\plusone
216
\global
\d_page_col_top_height
\zeropoint
217
\global
\d_page_col_top_width
\zeropoint
218
% \page_col_command_flush_top_insertions
219
% \page_col_command_flush_floats
220
\else
221
\ifdim
\d_page_col_top_width
>
\zeropoint
222
\ifdim
\dimexpr
\d_page_col_top_width
>
\d_page_col_sofar
\relax
223
\begingroup
224
\floatingpenalty
\zerocount
225
\insert
\namedinsertionnumber
\s!topfloat
\bgroup
226
\vbox
to
\d_page_col_top_height
{
\vss
}
227
% can be an option
228
\page_col_command_flush_top_insertions
229
\page_col_command_flush_floats
230
% so far till option
231
\egroup
232
\endgroup
233
\fi
234
\fi
235
\global\advance
\c_page_col_current
\plusone
236
\fi
237
%
238
\page_col_command_set_vsize
239
\page_col_command_set_hsize
}
240 241
% use \currentmixedcolumns instead of \recurselevel
242 243
\def
\page_col_routine_package_step
244
{
% needs packaging anyway
245
\getboxfromcache
{
\s!pagecolumn
}{
\number
\recurselevel
}
\scratchbox
246
\page_lines_add_numbers_to_box
\scratchbox\recurselevel
\c_page_col_n_of_columns
\plusone
% new
247
\page_marks_synchronize_column
\plusone
\c_page_col_n_of_columns
\recurselevel\scratchbox
248
% backgrounds
249
\anch_mark_column_box
\scratchbox\recurselevel
250
\mixedcolumnseparatorheight
\ht
\scratchbox
251
\mixedcolumnseparatordepth
\dp
\scratchbox
252
\inheritedpagecolumnsframedbox
\recurselevel\scratchbox
}
253 254
\def
\page_col_routine_package
255
{
\global\setbox
\normalpagebox
\hbox
to
\makeupwidth
\bgroup
256
\edef
\p_separator
{
\pagecolumnsparameter
\c!separator
}
%
257
\pagecolumnseparatorwidth
\d_page_col_distance
258
\edef
\p_direction
{
\pagecolumnsparameter
\c!direction
}
%
259
\ifx
\p_direction
\v!reverse
260
\dostepwiserecurse
\c_page_col_n_of_columns
\plusone\minusone
261
{
\page_col_routine_package_step
262
\ifnum
\recurselevel
>
\plusone
263
\page_col_routine_package_separate
264
\fi
}
%
265
\else
266
\dorecurse
\c_page_col_n_of_columns
267
{
\page_col_routine_package_step
268
\ifnum
\recurselevel
<
\c_page_col_n_of_columns
269
\page_col_routine_package_separate
270
\fi
}
%
271
\fi
272
\egroup
273
\resetboxesincache
{
\s!pagecolumn
}}
274 275
%D \unknown
276 277
% \unexpanded\def\page_col_command_check_if_float_fits
278
% {\ifconditional\c_page_floats_not_permitted
279
% \global\setfalse\c_page_floats_room
280
% %\else\ifabsdim\dimexpr\d_page_col_available-\naturalfloatwd\relax<\onepoint
281
% \else\ifdim\dimexpr\d_page_col_available-\naturalfloatwd\relax>-\onepoint
282
% \global\settrue\c_page_floats_room
283
% \else
284
% \global\setfalse\c_page_floats_room
285
% \fi\fi
286
% \ifconditional\c_page_floats_room
287
% \begingroup
288
% \scratchdimen\dimexpr\pagetotal+\lineheight\relax
289
% \ifdim\scratchdimen>\pagegoal
290
% \goodbreak
291
% \ifdim\dimexpr\d_page_col_available-\naturalfloatwd\relax>\onepoint
292
% \global\setfalse\c_page_floats_room
293
% \else
294
% \global\settrue\c_page_floats_room
295
% \fi
296
% \fi
297
% \endgroup
298
% \fi
299
% \ifconditional\c_page_floats_room
300
% \ifdim\pagetotal>\zeropoint
301
% \scratchdimenone\dimexpr\pagetotal+\floatheight+\d_strc_floats_top-\pageshrink\relax
302
% \scratchdimentwo\pagegoal
303
% \relax % needed
304
% \ifcase\c_page_one_float_method
305
% % method 0 : raw
306
% \or
307
% % method 1 : safe
308
% \advance\scratchdimentwo -\strutdp
309
% \or
310
% % method 2 : tight
311
% \advance\scratchdimenone -\onepoint
312
% \fi
313
% \relax % really needed ! ! ! !
314
% \ifdim\scratchdimenone>\scratchdimentwo
315
% \global\setfalse\c_page_floats_room
316
% \fi
317
% \fi
318
% \ifconditional\c_page_floats_room
319
% \global\setbox\floatbox\hpack to \d_page_col_available{\hss\box\floatbox\hss}%
320
% \fi
321
% \fi}
322 323
\unexpanded
\def
\page_col_command_check_if_float_fits
324
{
\ifconditional
\c_page_floats_not_permitted
325
% forget about it anyway
326
\global
\setfalse
\c_page_floats_room
327
\else
328
% first we check the current column
329
% \ifdim\dimexpr\d_page_col_width-\naturalfloatwd\relax>-\onepoint
330
\ifdim
\dimexpr\hsize
-
\naturalfloatwd
\relax
>
-
\onepoint
331
\global
\settrue
\c_page_floats_room
332
\else
333
\global
\setfalse
\c_page_floats_room
334
\fi
335
\ifconditional
\c_page_floats_room
336
% we fit in the column but do we have room
337
\ifdim
\dimexpr\pagetotal
+
\lineheight
\relax
>
\pagegoal
338
% try again later
339
\goodbreak
340
\fi
341
\ifdim
\pagetotal
>
\zeropoint
342
\scratchdimenone
\dimexpr\pagetotal
+
\floatheight
+
\d_strc_floats_top
-
\pageshrink\relax
343
\scratchdimentwo
\pagegoal
344
\relax
% needed
345
\ifcase
\c_page_one_float_method
346
% method 0 : raw
347
\or
348
% method 1 : safe
349
\advance
\scratchdimentwo
-
\strutdp
350
\or
351
% method 2 : tight
352
\advance
\scratchdimenone
-
\onepoint
353
\fi
354
\relax
% really needed ! ! ! !
355
\ifdim
\scratchdimenone
>
\scratchdimentwo
356
% there is no room, give up
357
\global
\setfalse
\c_page_floats_room
358
% now we can decide on a top float
359
% \fi
360
\else
361
% \ifconditional\c_page_floats_room
362
% \global\setbox\floatbox\hpack to \d_page_col_float_available{\hss\box\floatbox\hss}%
363
% \fi
364
\fi
365
\fi
366
\fi
367
\fi
}
368 369
%D \unknown
370 371
\def
\page_col_set_float_pack_hsize
372
{
\ifnum
\c_page_col_current
=
\c_page_col_n_of_columns
373
\c_page_col_current
\plusone
374
\else
375
\advance
\c_page_col_current
\plusone
376
\fi
377
\page_col_command_set_hsize
378
\hsize
\d_page_col_available
}
379 380
\unexpanded
\def
\page_col_command_flush_floats
381
{
\global
\settrue
\c_page_floats_flushing
382
\ifconditional
\c_page_floats_some_waiting
383
\par
384
\page_col_set_float_pack_hsize
385
\page_col_command_flush_floats_indeed
386
\fi
387
\global
\savednoffloats
\zerocount
388
\global
\setfalse
\c_page_floats_some_waiting
389
\global
\setfalse
\c_page_floats_flushing
}
390 391
\def
\page_floats_show_pack_state_indeed
#
1
%
392
{
\llap
{
\smash
{
\backgroundline
[
black
]
{
\strut
\smallinfofont
\white
#
1
\space
\the
\nofcollectedfloats
\space
of
\space
\the
\savednoffloats
:
\the\hsize
}}
\hskip
.
2
5
\emwidth
}}
393 394
\installtextracker
395
{
floats
.
collecting
}
396
{
\let
\page_floats_show_pack_state
\page_floats_show_pack_state_indeed
}
397
{
\let
\page_floats_show_pack_state
\gobbleoneargument
}
398 399
\let
\page_floats_show_pack_state
\gobbleoneargument
400 401
\def
\page_col_command_flush_floats_indeed
% much in common with OTRSET
402
{
\ifconditional
\c_page_floats_some_waiting
403
\ifconditional
\c_page_floats_compress_flushed
404
\setfalse
\c_page_floats_center_box
% not needed as we do call directly
405
\page_floats_collect
\s!text
\hsize
\d_page_floats_compress_distance
406
%
407
\ifnum
\nofcollectedfloats
=
\plusone
408
\ifdim
\naturalfloatwd
>
\hsize
409
\nofcollectedfloats
\zerocount
410
\fi
411
\fi
412
\ifnum
\nofcollectedfloats
>
\zerocount
413
\global\setbox
\floatbox
\hpack
to
\hsize
414
{
\page_floats_show_pack_state
F
%
415
\hfil
416
\dorecurse
\nofcollectedfloats
417
{
\ifcase
\columndirection
% nog document wide
418
\page_floats_flush
\s!text
\plusone
419
\else
420
\page_floats_flush
\s!text
{
\the\numexpr
\nofcollectedfloats
-
\recurselevel
+
1
\relax
}
%
421
\fi
422
% this could happen at the lua end instead
423
\scratchdimen
\dimexpr\wd
\floatbox
-
\naturalfloatwd
\relax
424
\ifdim
\scratchdimen
<
\zeropoint
425
\global\setbox
\floatbox
\hpack
spread
-
\scratchdimen
{
\hss\box
\floatbox
\hss
}
%
426
\fi
427
%
428
\ifdim
\wd
\floatbox
>
\textwidth
% \hsize
429
\hpack
to
\textwidth
{
\hss\box
\floatbox
\hss
}
% \textwidth
430
\else
431
\box
\floatbox
432
\fi
433
\ifnum
\recurselevel
<
\nofcollectedfloats
434
\hfil
435
\fi
}
%
436
\hfil
}
%
437
\doplacefloatbox
438
% \page_one_insert_top_float
439
\doubleexpandafter
\page_col_command_flush_floats_indeed
440
\else
441
% todo
442
\fi
443
\else
444
\page_floats_get
445
% \page_one_insert_top_float
446
\doplacefloatbox
447
\doubleexpandafter
\page_col_command_flush_floats_indeed
448
\fi
449
\fi
}
450 451
\unexpanded
\def
\page_col_command_flush_saved_floats
% like one
452
{
\global
\d_page_floats_inserted_top
\zeropoint
453
\global
\d_page_floats_inserted_bottom
\zeropoint
454
\ifconditional
\c_page_floats_flushing
\else
455
\page_col_command_set_top_insertions
456
\page_col_command_set_bottom_insertions
457
\ifconditional
\c_page_floats_some_waiting
458
\doif
{
\rootfloatparameter
\c!cache
}
\v!no
\page_col_command_flush_floats
% could be _otr_
459
\else
\ifconditional
\c_page_margin_blocks_present
460
\page_col_command_flush_floats
461
\fi\fi
462
\fi
}
463 464
\unexpanded
\def
\page_col_command_set_top_insertions
465
{
\bgroup
466
\ifconditional
\c_page_floats_some_waiting
467
\noffloatinserts
\zerocount
468
\let
\totaltopinserted
\!!zeropoint
469
\page_col_set_float_pack_hsize
470
\page_col_command_set_top_insertions_indeed
471
\ifnum
\rootfloatparameter
\c!nbottom
=
\zerocount
472
\ifnum
\rootfloatparameter
\c!nlines
>
\zerocount
473
\ifdim
\totaltopinserted
>
\zeropoint
\relax
474
\ifdim
\dimexpr
\rootfloatparameter
\c!nlines
\lineheight
+
\totaltopinserted
\relax
>
\textheight
475
\showmessage
\m!floatblocks
8
{
\rootfloatparameter
\c!nlines
}
%
476
\page_otr_fill_and_eject_page
% was tripple: vfilll
477
\fi
478
\fi
479
\fi
480
\fi
481
\fi
482
\egroup
}
483 484
\def
\d_page_col_collected_top_float_height
% pseudo
485
{
\dimexpr
486
\d_page_floats_inserted_top
+
487
\maxcollectedfloatstotal
+
488
\ifdim
\d_strc_floats_top
>
\d_strc_floats_bottom
489
\d_strc_floats_top
490
\else
491
\d_strc_floats_bottom
492
\fi
493
\relax
}
494 495
\def
\page_col_command_set_top_insertions_indeed
496
{
\ifnum
\noffloatinserts
<
\c_page_floats_n_of_top
497
\ifcase
\savednoffloats
498
\let
\page_col_command_set_top_insertions_indeed
\relax
499
\else
500
\page_floats_collect
\s!text
\hsize
\emwidth
501
\ifdim
\d_page_col_collected_top_float_height
<
\textheight
502
\global\setbox
\floatbox
\hpack
to
\hsize
503
{
\page_floats_show_pack_state
T
%
504
\hfil
505
\dorecurse
\nofcollectedfloats
506
{
\ifcase
\columndirection
% nog document wide
507
\page_floats_flush
\s!text
\plusone
508
\else
509
\page_floats_flush
\s!text
{
\the\numexpr
\nofcollectedfloats
-
\recurselevel
+
1
\relax
}
%
510
\fi
511
% this could happen at the lua end instead
512
\scratchdimen
\dimexpr\wd
\floatbox
-
\naturalfloatwd
\relax
513
\ifdim
\scratchdimen
<
\zeropoint
514
\global\setbox
\floatbox
\hpack
spread
-
\scratchdimen
{
\hss\box
\floatbox
\hss
}
%
515
\fi
516
%
517
\ifdim
\wd
\floatbox
>
\makeupwidth
% \hsize
518
\hpack
to
\makeupwidth
{
\hss\box
\floatbox
\hss
}
%
519
\else
520
\box
\floatbox
521
\fi
522
\ifnum
\recurselevel
<
\nofcollectedfloats
523
\hfil
524
\fi
}
%
525
\hfil
}
%
526
\page_one_prepare_top_float
527
\xdef
\totaltopinserted
{
\the
\d_page_floats_inserted_top
}
%
528
\page_one_insert_top_float
529
\ifconditional
\c_page_floats_some_waiting
530
\advance
\noffloatinserts
\plusone
531
\else
532
\noffloatinserts
\c_page_floats_n_of_top
\relax
533
\fi
534
\page_floats_report_flushed
535
\else
536
\let
\page_col_command_set_top_insertions_indeed
\relax
537
\fi
538
\fi
539
\else
540
\ifconditional
\c_page_floats_some_waiting
541
\showmessage
\m!floatblocks
6
{
\the
\c_page_floats_n_of_top
}
%
542
\fi
543
\let
\page_col_command_set_top_insertions_indeed
\relax
544
\fi
545
\page_col_command_set_top_insertions_indeed
}
546 547
\let
\page_col_command_flush_top_insertions
\page_one_command_flush_top_insertions
548
\let
\page_col_command_flush_bottom_insertions
\page_one_command_flush_bottom_insertions
549 550
%let\page_col_command_set_top_insertions \page_one_command_set_top_insertions
551
\let
\page_col_command_set_bottom_insertions
\page_one_command_set_bottom_insertions
552 553
%let\page_col_command_set_top_insertions_indeed \page_one_command_set_top_insertions
554
\let
\page_col_command_set_bottom_insertions_indeed
\page_one_command_set_botttom_insertions
555 556
\let
\page_col_command_flush_float_box
\page_one_command_flush_float_box
557
\let
\page_col_command_synchronize_side_floats
\page_one_command_synchronize_side_floats
558
\let
\page_col_command_flush_side_floats
\page_one_command_flush_side_floats
559
\let
\page_col_command_flush_margin_blocks
\page_one_command_flush_margin_blocks
560
\let
\page_col_command_test_page
\page_one_command_test_page
561 562
%D The separator code is more or less the same as mixed columns but we need
563
%D to compensate for the top floats so we comment a bit for now.
564 565
\newdimen
\pagecolumnseparatorheight
566
\newdimen
\pagecolumnseparatordepth
567
\newdimen
\pagecolumnseparatorwidth
568 569
% \installcorenamespace{pagecolumnsseparator}
570
%
571
% \unexpanded\def\installpagecolumnseparator#1#2%
572
% {\setvalue{\??pagecolumnsseparator#1}{#2}}
573
%
574
% \installpagecolumnseparator\v!rule
575
% {\vrule
576
% \s!width \pagecolumnsparameter\c!rulethickness
577
% \s!height\pagecolumnseparatorheight
578
% \s!depth \pagecolumnseparatordepth
579
% \relax}
580
%
581
% \def\page_col_routine_package_separate
582
% {\ifcsname\??pagecolumnsseparator\p_separator\endcsname
583
% \page_col_command_inject_separator
584
% \else
585
% \hss
586
% \fi}
587
%
588
% \unexpanded\def\page_col_command_inject_separator
589
% {\begingroup
590
% \setbox\scratchbox\hbox to \zeropoint \bgroup
591
% \hss
592
% \starttextproperties
593
% \usepagecolumnscolorparameter\c!rulecolor
594
% \begincsname\??pagecolumnsseparator\p_separator\endcsname % was \c!rule
595
% \stoptextproperties
596
% \hss
597
% \egroup
598
% \ht\scratchbox\zeropoint
599
% \dp\scratchbox\zeropoint
600
% \hss
601
% \box\scratchbox
602
% \hss
603
% \endgroup}
604 605
\def
\page_col_routine_package_separate
606
{
\hss
}
607 608
%D \unknown
609 610
\unexpanded
\def
\page_col_command_routine
611
{
\page_sides_output_routine
}
612 613
% % not:
614
%
615
% \unexpanded\def\page_col_command_routine
616
% {\ifconditional\c_page_sides_short
617
% \page_sides_output_routine_yes_column
618
% \else
619
% \page_sides_output_routine_nop_column
620
% \fi}
621
%
622
% \let\page_sides_output_routine_nop_column\page_sides_output_routine
623
%
624
% \def\page_sides_output_routine_yes_column % this might become the main one too
625
% {\unvbox\normalpagebox % bah, and the discards?
626
% %\page_col_column
627
% \column % \page
628
% % why was this \global\holdinginserts\zerocount
629
% \global\setfalse\c_page_sides_short}
630 631
\let
\page_col_command_flush_all_floats
\relax
632 633
%D \unknown
634 635
\defineoutputroutine
636
[
\s!pagecolumn
]
637
[
\s!page_otr_command_routine
=
\page_col_command_routine
,
638
\s!page_otr_command_package_contents
=
\page_col_command_package_contents
,
639
\s!page_otr_command_set_vsize
=
\page_col_command_set_vsize
,
640
\s!page_otr_command_set_hsize
=
\page_col_command_set_hsize
,
641
% \s!page_otr_command_synchronize_hsize =\page_col_command_synchronize_hsize, % not done
642
\s!page_otr_command_next_page
=
\page_col_command_next_page
,
643
\s!page_otr_command_next_page_and_inserts
=
\page_col_command_next_page_and_inserts
,
644
\s!page_otr_command_set_top_insertions
=
\page_col_command_set_top_insertions
,
645
\s!page_otr_command_set_bottom_insertions
=
\page_col_command_set_bottom_insertions
,
646
\s!page_otr_command_flush_top_insertions
=
\page_col_command_flush_top_insertions
,
647
\s!page_otr_command_flush_bottom_insertions
=
\page_col_command_flush_bottom_insertions
,
648
\s!page_otr_command_check_if_float_fits
=
\page_col_command_check_if_float_fits
,
649
% \s!page_otr_command_set_float_hsize =\page_col_command_set_float_hsize, % not done
650
\s!page_otr_command_flush_float_box
=
\page_col_command_flush_float_box
,
651
\s!page_otr_command_side_float_output
=
\page_col_command_side_float_output
,
652
\s!page_otr_command_synchronize_side_floats
=
\page_col_command_synchronize_side_floats
,
653
\s!page_otr_command_flush_floats
=
\page_col_command_flush_floats
,
654
\s!page_otr_command_flush_side_floats
=
\page_col_command_flush_side_floats
,
655
\s!page_otr_command_flush_saved_floats
=
\page_col_command_flush_saved_floats
,
656
\s!page_otr_command_flush_all_floats
=
\page_col_command_flush_all_floats
,
657
\s!page_otr_command_flush_margin_blocks
=
\page_col_command_flush_margin_blocks
,
658
\s!page_otr_command_test_column
=
\page_col_command_test_page
659
]
660 661
%D \unknown
662 663
\installfloatmethod
\s!pagecolumn
\v!here
\page_one_place_float_here
664
\installfloatmethod
\s!pagecolumn
\v!force
\page_one_place_float_force
665
\installfloatmethod
\s!pagecolumn
\v!left
\page_one_place_float_left
666
\installfloatmethod
\s!pagecolumn
\v!right
\page_one_place_float_right
667
\installfloatmethod
\s!pagecolumn
\v!text
\page_one_place_float_text
668
\installfloatmethod
\s!pagecolumn
\v!top
\page_one_place_float_top
669
\installfloatmethod
\s!pagecolumn
\v!bottom
\page_one_place_float_bottom
670
\installfloatmethod
\s!pagecolumn
\v!auto
\page_one_place_float_auto
671
\installfloatmethod
\s!pagecolumn
\v!margin
\page_one_place_float_margin
672
\installfloatmethod
\s!pagecolumn
\v!opposite
\page_one_place_float_face
673
\installfloatmethod
\s!pagecolumn
\v!page
\page_one_place_float_page
674
\installfloatmethod
\s!pagecolumn
\v!leftpage
\page_one_place_float_leftpage
675
\installfloatmethod
\s!pagecolumn
\v!rightpage
\page_one_place_float_rightpage
676
\installfloatmethod
\s!pagecolumn
\v!inmargin
\page_one_place_float_inmargin
677
\installfloatmethod
\s!pagecolumn
\v!inleft
\page_one_place_float_leftmargin
678
\installfloatmethod
\s!pagecolumn
\v!inright
\page_one_place_float_rightmargin
679
\installfloatmethod
\s!pagecolumn
\v!leftmargin
\page_one_place_float_leftmargin
680
\installfloatmethod
\s!pagecolumn
\v!rightmargin
\page_one_place_float_rightmargin
681
\installfloatmethod
\s!pagecolumn
\v!leftedge
\page_one_place_float_leftedge
682
\installfloatmethod
\s!pagecolumn
\v!rightedge
\page_one_place_float_rightedge
683
\installfloatmethod
\s!pagecolumn
\v!somewhere
\page_one_place_float_somewhere
684
\installfloatmethod
\s!pagecolumn
\v!backspace
\page_one_place_float_backspace
685
\installfloatmethod
\s!pagecolumn
\v!cutspace
\page_one_place_float_cutspace
686
%installfloatmethod \s!pagecolumn \s!tblr \page_one_place_float_top
687
%installfloatmethod \s!pagecolumn \s!lrtb \page_one_place_float_top
688
%installfloatmethod \s!pagecolumn \s!tbrl \page_one_place_float_top
689
%installfloatmethod \s!pagecolumn \s!fxtb \page_one_place_float_top
690
%installfloatmethod \s!pagecolumn \s!rltb \page_one_place_float_top
691
%installfloatmethod \s!pagecolumn \s!btlr \page_one_place_float_bottom
692
%installfloatmethod \s!pagecolumn \s!lrbt \page_one_place_float_bottom
693
%installfloatmethod \s!pagecolumn \s!btrl \page_one_place_float_bottom
694
%installfloatmethod \s!pagecolumn \s!rlbt \page_one_place_float_bottom
695
%installfloatmethod \s!pagecolumn \s!fxbt \page_one_place_float_bottom
696
%installfloatmethod \s!pagecolumn \s!fixd \page_one_place_float_force
697 698
\installfloatmethod
\s!pagecolumn
\v!local
\somelocalfloat
699 700
%D The main interface:
701 702
\installcorenamespace
{
pagecolumns
}
703 704
\installframedcommandhandler
\??pagecolumns
{
pagecolumns
}
\??pagecolumns
705 706
\setuppagecolumns
707
[
\c!distance
=
1
.
5
\bodyfontsize
,
708
\c!n
=
\plustwo
,
709
\c!page
=
\v!yes
,
710
%\c!align=, % inherit (also replaces tolerance)
711
%\c!before=,
712
%\c!after=,
713
%\c!separator=\v!none,
714
%\c!setups=,
715
%\c!balance=\v!no,
716
%\c!blank={\v!line,\v!fixed}, yes or no
717
\c!frame
=
\v!off
,
718
\c!strut
=
\v!no
,
719
\c!offset
=
\v!overlay
,
720
%\c!maxheight=\textheight,
721
\c!maxwidth
=
\makeupwidth
,
722
%\c!grid=\v!tolerant,
723
%\c!internalgrid=\v!line,
724
\c!direction
=
\v!normal
]
725 726
\let
\startpagecolumns
\relax
% defined later
727
\let
\stoppagecolumns
\relax
% defined later
728 729
\appendtoks
% could become an option
730
\setuevalue
{
\e!start
\currentpagecolumns
}{
\startpagecolumns
[
\currentpagecolumns
]
}
%
731
\setuevalue
{
\e!stop
\currentpagecolumns
}{
\stoppagecolumns
}
%
732
\to
\everydefinepagecolumns
733 734
\def
\page_col_pickup_preceding
735
{
\begingroup
736
\setupoutputroutine
[
\s!mixedcolumn
]
%
737
\c_page_mix_routine
\c_page_mix_routine_intercept
738
\page_otr_trigger_output_routine
739
\ifvoid
\b_page_mix_preceding
\else
740
% moved here, before the packaging
741
\page_postprocessors_linenumbers_deepbox
\b_page_mix_preceding
742
% we need to avoid unvboxing with successive balanced on one page
743
\global\setbox
\b_page_mix_preceding
\vbox
\bgroup
744
% yes or no: \forcestrutdepth
745
\unvbox
\b_page_mix_preceding
746
\forcestrutdepth
747
\egroup
748
\wd
\b_page_mix_preceding
\makeupwidth
749
\global
\d_page_mix_preceding_height
\ht
\b_page_mix_preceding
750
\fi
751
\endgroup
}
752 753
\def
\page_col_flush_preceding
754
{
\ifvoid
\b_page_mix_preceding
\else
755
% this is just one method but ok for now
756
\begingroup
757
% we might need more but for now this is ok
758
\setupfloat
[
\c!spacebefore
=
,
\c!spaceafter
=]
%
759
\startplacefigure
[
\c!location
=
{
\v!top
,
\v!none
}
]
%
760
\box
\b_page_mix_preceding
761
\stopplacefigure
762
\endgroup
763
\fi
}
764 765
\unexpanded
\def
\startpagecolumns
766
{
\begingroup
767
\begingroup
768
\dosingleempty
\page_col_start
}
769 770
\unexpanded
\def
\page_col_start
[#
1
]
%
771
{
\doifelseassignment
{
#
1
}
%
772
{
\let
\currentpagecolumns
\empty
773
\setuppagecolumns
[#
1
]
}
%
774
{
\edef
\currentpagecolumns
{
#
1
}}
%
775
\edef
\p_page
{
\pagecolumnsparameter
\c!page
}
%
776
\ifx
\p_page
\empty
777
\setfalse
\c_page_col_page
778
\else\ifx
\p_page
\v!no
779
\setfalse
\c_page_col_page
780
\else
781
\settrue
\c_page_col_page
782
\page
[
\p_page
]
%
783
\fi\fi
784
\c_page_col_n_of_columns
\pagecolumnsparameter
\c!n
\relax
785
\ifnum
\c_page_col_n_of_columns
>
\plusone
786
\expandafter
\page_col_start_yes
787
\else
788
\expandafter
\page_col_start_nop
789
\fi
}
% public
790 791
\unexpanded
\def
\page_col_start_yes
792
{
\d_page_col_distance
\pagecolumnsparameter
\c!distance
\relax
793
% \d_page_col_max_height \pagecolumnsparameter\c!maxheight
794
\d_page_col_max_width
\pagecolumnsparameter
\c!maxwidth
795
% \d_page_col_balance_step \pagecolumnsparameter\c!step
796
\c_page_col_current
\plusone
797
%
798
\d_page_col_column_width
\dimexpr
(
\d_page_col_max_width
-
\d_page_col_distance
*
\numexpr
(
\c_page_col_n_of_columns
-
\plusone
)
\relax
)
/
\c_page_col_n_of_columns
\relax
799
%
800
\columnwidth
\d_page_col_column_width
801
\columndistance
\d_page_col_distance
802
\nofcolumns
\c_page_col_n_of_columns
803
\textwidth
\columnwidth
% kind of redundant
804
%
805
\nopenalties
806
%
807
% \insidecolumnstrue % NO!
808
%
809
\let
\column
\page_col_column
810
%
811
\def
\page_floats_get_used_hsize
{
\makeupwidth
}
% a bit of a hack
812
%
813
\usealignparameter
\pagecolumnsparameter
814
\useblankparameter
\pagecolumnsparameter
815
% \useprofileparameter\pagecolumnsparameter
816
%
817
\usepagecolumnscolorparameter
\c!color
818
%
819
\setupnotes
[
\c!width
=
\textwidth
]
%
820
%
821
\usesetupsparameter
\pagecolumnsparameter
822
%
823
% This will become a method but for now it's good enough
824
%
825
\ifconditional
\c_page_col_page
\else
826
\page_col_pickup_preceding
827
\fi
828
\setupoutputroutine
[
\s!pagecolumn
]
%
829
\ifconditional
\c_page_col_page
\else
830
\page_col_flush_preceding
831
\fi
832
%
833
\setupfloats
[
\c!ntop
=
\plusthousand
]
%
834
% \setupfloats[\c!nbottom=\plusthousand]%
835
%
836
\page_col_command_set_vsize
837
\page_col_command_set_hsize
838
%
839
\unexpanded
\def
\page_col_start
[##
1
]
%
840
{
\page_col_start_nop
}
%
841
%
842
\let
\stoppagecolumns
\page_col_stop_yes
}
843 844
\unexpanded
\def
\page_col_start_nop
845
{
\nofcolumns
\c_page_mix_n_of_columns
846
\let
\stoppagecolumns
\page_col_stop_nop
}
847 848
\unexpanded
\def
\page_col_stop_yes
849
{
\column
% \page_otr_eject_page
850
\page
851
\endgroup
852
% \setupoutputroutine[\s!singlecolumn]%
853
\page_otr_command_set_vsize
854
\page_otr_command_set_hsize
855
\page
856
\endgroup
}
857 858
\unexpanded
\def
\page_col_stop_nop
859
{
\page
860
\endgroup
861
\endgroup
}
862 863
\protect
\endinput
864