1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19\writestatus{loading}{ConTeXt Page Macros Page Grids}
20
21\registerctxluafile{pagecst}{}
22
23\unprotect
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41\definesystemconstant{pagegrid}
42
43\installcorenamespace{pagegrid}
44
45\installframedcommandhandler \??pagegrid {pagegrid} \??pagegrid
46
47\setuppagegrid
48 [\c!distance=1.5\bodyfontsize,
49 \c!n=\plustwo,
50 \c!nleft=\pagegridparameter\c!n,
51 \c!nright=\pagegridparameter\c!n,
52
53
54
55 \c!lines=\layoutparameter\c!lines,
56 \c!frame=\v!off,
57 \c!strut=\v!no,
58 \c!offset=\v!overlay,
59 \c!alternative=\v!local,
60 \c!width=\v!auto,
61 \c!page=,
62 \c!direction=\v!normal,
63 \c!maxheight=\textheight,
64 \c!maxwidth=\makeupwidth]
65
66\appendtoks
67 \setuevalue{\e!start\currentpagegrid}{\startpagegrid[\currentpagegrid]}
68 \setuevalue{\e!stop \currentpagegrid}{\stoppagegrid}
69 \clf_definecolumnset {
70 name {\currentpagegrid}
71 }
72\to \everydefinepagegrid
73
74\newdimen \d_page_grd_column_width
75\newdimen \d_page_grd_max_height
76\newdimen \d_page_grd_max_width
77\newdimen \d_page_grd_distance
78
79\newdimen \d_page_grd_reserved_height
80\newdimen \d_page_grd_reserved_width
81\newcount \c_page_grd_reserved_state
82
83\newdimen \d_page_grd_gap_height
84
85\newcount \c_page_grd_n_of_left
86\newcount \c_page_grd_n_of_right
87\newcount \c_page_grd_n_of_rows
88\newcount \c_page_grd_first_column
89\newcount \c_page_grd_last_column
90
91\newbox \b_page_grd_collected
92\newbox \b_page_grd_column_rest
93\newbox \b_page_grd_column
94
95\unexpanded\def\setuppagegridlines{\doquadrupleempty\page_grd_setup_lines}
96\unexpanded\def\setuppagegridstart{\doquadrupleempty\page_grd_setup_start}
97
98\def\page_grd_setup_lines[#1][#2][#3][#4]
99 {\clf_setcolumnsetlines{name {#1} page #2 column #3 value #4}}
100
101\def\page_grd_setup_start[#1][#2][#3][#4]
102 {\clf_setcolumnsetstart{name {#1} page #2 column #3 value #4}}
103
104\unexpanded\def\page_grd_check
105 {\dorecurse{\numexpr\pagegridparameter\c!nleft\pagegridparameter\c!nright}
106 {\page_grd_check_column{##1}}}
107
108\unexpanded\def\page_grd_check_column#1
109 {\chaintocurrentpagegrid{\currentpagegrid:#1}
110 \edef\p_distance{\namedpagegridparameter{\currentpagegrid:#1}\c!distance}
111 \edef\p_width {\namedpagegridparameter{\currentpagegrid:#1}\c!width}
112 \clf_setcolumnsetproperties {
113 name {\currentpagegrid}
114 column \numexpr#1\relax
115 \ifx\p_distance\empty\else
116 distance \p_distance
117 \fi
118 \ifx\p_width\empty\else\ifx\p_width\v!auto\else
119 width \p_width
120 \fi\fi
121 }}
122
123\appendtoks
124 \dorecurse{\numexpr\pagegridparameter\c!nleft\pagegridparameter\c!nright}
125 {\chaintocurrentpagegrid{\currentpagegrid:#1}}
126\to \everydefinepagegrid
127
128\unexpanded\def\startpagegrid
129 {\bgroup
130 \dodoubleempty\page_grd_start}
131
132\def\page_grd_start_dummy[#1][#2]
133 {\let\page_grd_stop\egroup}
134
135\def\page_grd_start[#1][#2]
136 {\let\page_grd_start\page_grd_start_dummy
137 \ifsecondargument
138 \edef\currentpagegrid{#1}
139 \setupcurrentpagegrid[#2]
140 \else\iffirstargument
141 \doifassignmentelse{#1}
142 {\let\currentpagegrid\empty
143 \setupcurrentpagegrid[#1]}
144 {\def\currentpagegrid{#1}}
145 \else
146 \let\currentpagegrid\empty
147 \fi\fi
148 \usepageparameter\pagegridparameter
149 \c_page_grd_n_of_left \pagegridparameter\c!nleft\relax
150 \c_page_grd_n_of_right\pagegridparameter\c!nright\relax
151 \c_page_grd_n_of_rows \pagegridparameter\c!lines\relax
152 \d_page_grd_max_width \pagegridparameter\c!maxwidth\relax
153 \d_page_grd_max_height\pagegridparameter\c!maxheight\relax
154 \d_page_grd_distance \pagegridparameter\c!distance\relax
155
156 \ifcase\c_page_grd_n_of_rows
157 \getrawnoflines{\dimexpr\d_page_grd_max_height\strutheight\topskip\relax}
158 \c_page_grd_n_of_rows\noflines
159 \fi
160 \edef\p_width{\pagegridparameter\c!width}
161 \insidecolumnstrue
162 \clf_resetcolumnset {
163 name {\currentpagegrid}
164 nofrows \c_page_grd_n_of_rows
165 nofleft \c_page_grd_n_of_left
166 nofright \c_page_grd_n_of_right
167 lineheight \strutht
168 linedepth \strutdp
169 \ifx\p_width\v!auto
170
171 \else
172 width \p_width
173 \fi
174 distance \d_page_grd_distance
175 maxwidth \d_page_grd_max_width
176 }
177
178 \page_grd_check
179
180 \clf_flushcolumnsetareas{\currentpagegrid}\relax
181 \setupoutputroutine[\s!pagegrid]
182 \page_grd_command_set_hsize
183 \page_grd_command_set_vsize
184
185 \columnwidth \d_page_grd_column_width
186 \columndistance\d_page_grd_distance
187 \nofcolumns \c_page_grd_n_of_left
188 \textwidth \d_page_grd_column_width
189
190 }
191
192\unexpanded\def\stoppagegrid
193 {\page_grd_stop}
194
195\def\page_grd_stop
196 {\endgraf
197 \vfill
198 \page_grd_command_set_vsize
199 \penalty\c_page_otr_eject_penalty
200 \page_grd_command_flush_page
201 \page_otr_fill_and_eject_page
202 \page_grd_command_set_vsize
203 \egroup
204 \page_otr_command_set_vsize
205 \page_otr_command_set_hsize}
206
207\unexpanded\def\reservepagegrid[#1]
208 {\begingroup
209 \letdummyparameter\c!c\plusone
210 \letdummyparameter\c!r\plusone
211 \letdummyparameter\c!nc\plusone
212 \letdummyparameter\c!nr\plusone
213 \getdummyparameters[#1]
214 \clf_blockcolumnset {
215 name {\currentpagegrid}
216 c \dummyparameter\c!c
217 r \dummyparameter\c!r
218 nc \dummyparameter\c!nc
219 nr \dummyparameter\c!nr
220 }
221 \endgroup}
222
223\unexpanded\def\setpagegrid
224 {\dosingleempty\page_grd_set}
225
226\unexpanded\def\page_grd_set[#1]
227 {\begingroup
228 \letdummyparameter\c!c\zerocount
229 \letdummyparameter\c!r\zerocount
230 \letdummyparameter\c!method\v!here
231 \letdummyparameter\c!option\v!none
232 \getdummyparameters[#1]
233 \dowithnextboxcs\page_grd_set_indeed\hbox}
234
235\def\page_grd_set_indeed
236 {\clf_checkcolumnset {
237 name {\currentpagegrid}
238 c \dummyparameter\c!c
239 r \dummyparameter\c!r
240 box \nextbox
241 method {\dummyparameter\c!method}
242 option {\dummyparameter\c!option}
243 }
244 \ifcase\c_page_grd_reserved_state
245 \setbox\nextbox\vpack to \d_page_grd_reserved_height \bgroup
246 \vss
247 \hpack to \d_page_grd_reserved_width \bgroup
248 \box\nextbox
249 \hss
250 \egroup
251 \vss
252 \egroup
253 \wd\nextbox\d_page_grd_reserved_width
254 \clf_putincolumnset {
255 name {\currentpagegrid}
256 box \nextbox
257 }
258 \fi
259 \endgroup}
260
261
262\unexpanded\def\page_grd_command_set_vsize
263 {\clf_setvsizecolumnset{\currentpagegrid}
264 \ifdim\d_page_grd_gap_height<\lineheight
265 \page_grd_command_flush_page
266 \page_otr_fill_and_eject_page
267 \fi
268 \global\vsize\d_page_grd_gap_height
269 \pagegoal\vsize}
270
271\unexpanded\def\page_grd_command_set_hsize
272 {\clf_sethsizecolumnset{\currentpagegrid}
273 \hsize\d_page_grd_column_width
274 \textwidth\d_page_grd_column_width}
275
276\unexpanded\def\page_grd_command_routine
277 {\ifvoid\normalpagebox \else
278 \clf_addtocolumnset{\currentpagegrid}\normalpagebox
279 \fi
280 \page_grd_command_set_vsize
281 \page_grd_command_flush_saved_floats
282 \page_grd_command_set_vsize
283 \ifdim\d_page_grd_gap_height<\lineheight
284 \page_grd_command_flush_page
285 \fi
286 \page_grd_command_set_vsize
287 \clf_flushcolumnsetrest {\currentpagegrid}\normalpagebox
288 \ifvoid\normalpagebox \else
289 \unvbox\normalpagebox
290 \fi}
291
292\installoutputroutine\synchronizepagegrid
293 {\ifvoid\normalpagebox\else
294 \clf_addtocolumnset{\currentpagegrid}\normalpagebox
295 \page_grd_command_set_vsize
296 \clf_flushcolumnsetrest{\currentpagegrid}\normalpagebox
297 \ifvoid\normalpagebox \else
298 \unvbox\normalpagebox
299 \fi
300 \fi}
301
302
303
304\unexpanded\def\page_grd_command_flush_page_column#1
305 {\privatescratchcounter#1\relax
306 \clf_flushcolumnsetcolumn{\currentpagegrid}\privatescratchcounter
307 \anch_mark_column_box\b_page_grd_column\privatescratchcounter
308 \page_marks_synchronize_column\c_page_grd_first_column\c_page_grd_last_column\privatescratchcounter\b_page_grd_column
309 \ifnum\privatescratchcounter>\c_page_grd_n_of_left
310 \advance\privatescratchcounter\c_page_grd_n_of_left
311 \page_lines_add_numbers_to_box\b_page_grd_column\privatescratchcounter\c_page_grd_n_of_right\plustwo
312 \else
313 \page_lines_add_numbers_to_box\b_page_grd_column\privatescratchcounter\c_page_grd_n_of_left\plustwo
314 \fi
315 \begingroup
316 \edef\currentpagegrid{\currentpagegrid:#1}
317 \inheritedpagegridframedbox\box\b_page_grd_column
318 \endgroup}
319
320\unexpanded\def\page_grd_command_flush_page
321 {\deactivatecolor
322 \setbox\b_page_grd_collected\hpack\bgroup
323 \clf_preparecolumnsetflush{\currentpagegrid}
324 \letpagegridparameter\c!region\currentpagegrid
325 \doifelse{\pagegridparameter\c!direction}\v!reverse
326 {\dostepwiserecurse\c_page_grd_last_column\c_page_grd_first_column\minusone
327 {\page_grd_command_flush_page_column{##1}
328 \ifnum##1>\plusone
329 \kern\namedpagegridparameter{\currentpagegrid:##1}\c!distance\relax
330 \fi}}
331 {\dostepwiserecurse\c_page_grd_first_column\c_page_grd_last_column\plusone
332 {\page_grd_command_flush_page_column{##1}
333 \ifnum##1<\c_page_grd_last_column
334 \kern\namedpagegridparameter{\currentpagegrid:##1}\c!distance\relax
335 \fi}}
336 \clf_finishcolumnsetflush{\currentpagegrid}
337 \egroup
338 \page_otr_construct_and_shipout\box\b_page_grd_collected\zerocount
339 \clf_flushcolumnsetareas{\currentpagegrid}\relax
340 \page_grd_command_flush_saved_floats}
341
342
343
344\unexpanded\def\page_grd_command_next_progress
345 {\strut
346 \page_grd_command_flush_all_floats
347 \page_otr_eject_page
348 \ifcase\clf_columnsetnoto\else
349 \expandafter\page_grd_command_next_progress
350 \fi}
351
352\unexpanded\def\page_grd_command_handle_column
353 {\ifcase\clf_columnsetgoto{\currentpagegrid}{\page_breaks_columns_current_option}\relax\else
354 \expandafter\page_grd_command_next_progress
355 \fi}
356
357\installcolumnbreakmethod\s!pagegrid\s!unknown {\page_grd_command_handle_column}
358\installcolumnbreakmethod\s!pagegrid\v!yes {\page_grd_command_handle_column}
359
360\unexpanded\def\page_grd_command_next_page
361 {\ifcase\clf_columnsetgoto{\currentpagegrid}{\v!page}\relax\else
362 \page_grd_command_flush_page
363 \fi}
364
365\unexpanded\def\page_grd_command_next_page_and_inserts
366 {\page_grd_command_flush_all_floats
367 \page_grd_command_next_page}
368
369\let\page_grd_command_flush_all_floats\page_one_command_flush_all_floats
370\let\page_grd_command_package_contents\page_one_command_package_contents
371
372\unexpanded\def\page_grd_command_flush_saved_floats
373 {\ifconditional\c_page_floats_flushing \else
374 \ifconditional\c_page_floats_some_waiting
375 \page_grd_command_flush_saved_floats_indeed
376 \fi
377 \fi}
378
379\unexpanded\def\page_grd_command_flush_saved_floats_indeed
380 {\page_floats_flush\s!text\plusone
381 \clf_checkcolumnset {
382 name {\currentpagegrid}
383 method {\floatmethod}
384 width \wd\floatbox
385 height \ht\floatbox
386 }
387 \ifcase\c_page_grd_reserved_state
388 \page_grd_place_float_here_indeed
389 \page_grd_command_set_vsize
390 \ifconditional\c_page_floats_some_waiting
391 \doubleexpandafter\page_grd_command_flush_saved_floats_indeed
392 \fi
393 \else
394 \page_floats_resave\s!text
395 \fi}
396
397
398
399\unexpanded\def\page_grd_command_flush_floats
400 {\wait\global\settrue\c_page_floats_flushing
401 \ifconditional\c_page_floats_some_waiting
402 \par
403 \page_grd_command_flush_floats_indeed
404 \fi
405 \global\savednoffloats\zerocount
406 \global\setfalse\c_page_floats_some_waiting
407 \global\setfalse\c_page_floats_flushing}
408
409\def\page_grd_command_flush_floats_indeed
410 {\ifconditional\c_page_floats_some_waiting
411 \ifconditional\c_page_floats_compress_flushed
412 \page_floats_collect\s!text\hsize\d_page_floats_compress_distance
413 \ifcase\nofcollectedfloats
414 \page_floats_get
415
416
417 \else
418 \setfalse\c_page_floats_center_box
419 \global\setbox\floatbox\hbox to \hsize
420 {\hfil
421 \dorecurse\nofcollectedfloats
422 {\ifcase\columndirection
423 \page_floats_flush\s!text\plusone
424 \else
425 \page_floats_flush\s!text{\the\numexpr\nofcollectedfloats\recurselevel1\relax}
426 \fi
427 \ifdim\wd\floatbox>\makeupwidth
428 \hbox to \makeupwidth{\hss\box\floatbox\hss}
429 \else
430 \box\floatbox
431 \fi
432 \ifnum\recurselevel<\nofcollectedfloats
433 \hfil
434 \fi}
435 \hfil}
436 \fi
437 \else
438 \page_floats_get
439 \fi
440 \doplacefloatbox
441 \expandafter\page_grd_command_flush_floats_indeed
442 \fi}
443
444
445
446\unexpanded\def\page_grd_command_check_if_float_fits
447 {\clf_checkcolumnset {
448 name {\currentpagegrid}
449 method {\floatmethod}
450
451
452 box \floatbox
453 }
454 \ifcase\c_page_grd_reserved_state
455 \global\settrue\c_page_floats_room
456 \else
457 \global\setfalse\c_page_floats_room
458 \fi}
459
460\unexpanded\def\page_grd_place_float_here_indeed
461 {\setbox\floatbox\vpack to \d_page_grd_reserved_height \bgroup
462 \vss
463 \hpack to \d_page_grd_reserved_width \bgroup
464
465 \box\floatbox
466 \hss
467 \egroup
468 \vss
469 \egroup
470 \clf_putincolumnset {
471 name {\currentpagegrid}
472 box \floatbox
473 }}
474
475\def\page_grd_place_float_slot
476 {
477 \ifx\floatmethod\empty
478 \let\floatmethod\v!here
479 \fi
480
481 \penalty\c_page_otr_eject_penalty
482
483 \setbox\savedfloatbox\box\floatbox
484 \page_grd_command_flush_saved_floats
485 \setbox\floatbox\box\savedfloatbox
486
487 \ifconditional\c_page_floats_some_waiting
488 \page_floats_save\s!text
489 \nonoindentation
490 \else
491 \clf_checkcolumnset {
492 name {\currentpagegrid}
493 method {\floatmethod}
494 \ifx\floatcolumn\empty \else
495 c \floatcolumn
496 \fi
497 \ifx\floatrow\empty \else
498 r \floatrow
499 \fi
500 box \floatbox
501 }
502 \ifcase\c_page_grd_reserved_state
503 \page_grd_place_float_here_indeed
504 \else
505 \page_floats_save\s!text
506 \nonoindentation
507 \fi
508 \fi}
509
510\def\page_grd_place_float_fixed
511 {\ifx\floatcolumn\empty
512 \let\floatmethod\v!here
513 \else\ifx\floatrow\empty
514 \let\floatmethod\v!here
515 \else
516 \let\floatmethod\v!fixed
517 \fi\fi
518 \page_grd_place_float_slot}
519
520\def\page_grd_place_float_force
521 {
522 \penalty\c_page_otr_eject_penalty
523 \clf_checkcolumnset {
524 name {\currentpagegrid}
525 method {\floatmethod}
526 box \floatbox
527 }
528 \ifcase\c_page_grd_reserved_state
529 \page_grd_place_float_here_indeed
530 \else
531 \page_floats_save\s!text
532 \nonoindentation
533 \fi}
534
535\def\page_grd_place_float_page {\page_grd_place_float_slot}
536
537\def\page_grd_place_float_here {\let\floatmethod\v!here\page_grd_place_float_slot}
538\def\page_grd_place_float_top {\page_grd_place_float_slot}
539\def\page_grd_place_float_bottom{\page_grd_place_float_slot}
540
541\installfloatmethod \s!pagegrid \v!here \page_grd_place_float_here
542\installfloatmethod \s!pagegrid \v!force \page_grd_place_float_force
543
544
545
546\installfloatmethod \s!pagegrid \v!top \page_grd_place_float_top
547\installfloatmethod \s!pagegrid \v!bottom \page_grd_place_float_bottom
548
549
550
551\installfloatmethod \s!pagegrid \v!page \page_grd_place_float_page
552
553
554
555
556
557
558
559
560
561
562
563
564\installfloatmethod \s!pagegrid \s!tblr \page_grd_place_float_slot
565\installfloatmethod \s!pagegrid \s!lrtb \page_grd_place_float_slot
566\installfloatmethod \s!pagegrid \s!tbrl \page_grd_place_float_slot
567\installfloatmethod \s!pagegrid \s!rltb \page_grd_place_float_slot
568\installfloatmethod \s!pagegrid \s!fxtb \page_grd_place_float_slot
569\installfloatmethod \s!pagegrid \s!btlr \page_grd_place_float_slot
570\installfloatmethod \s!pagegrid \s!lrbt \page_grd_place_float_slot
571\installfloatmethod \s!pagegrid \s!btrl \page_grd_place_float_slot
572\installfloatmethod \s!pagegrid \s!rlbt \page_grd_place_float_slot
573\installfloatmethod \s!pagegrid \s!fxbt \page_grd_place_float_slot
574\installfloatmethod \s!pagegrid \s!fixd \page_grd_place_float_fixed
575
576
577
578\unexpanded\def\page_grd_command_side_float_output
579 {}
580
581\unexpanded\def\page_grd_command_flush_side_floats
582 {\page_sides_forget_floats}
583
584\unexpanded\def\page_grd_command_synchronize_side_floats
585 {\page_sides_forget_floats}
586
587\unexpanded\def\page_grd_command_synchronize_hsize
588 {\page_grd_command_set_hsize}
589
590\unexpanded\def\page_grd_command_flush_all_floats
591 {\page_one_command_flush_all_floats}
592
593\defineoutputroutine
594 [\s!pagegrid]
595 [\s!page_otr_command_routine =\page_grd_command_routine,
596 \s!page_otr_command_package_contents =\page_grd_command_package_contents,
597 \s!page_otr_command_set_vsize =\page_grd_command_set_vsize,
598 \s!page_otr_command_set_hsize =\page_grd_command_set_hsize,
599 \s!page_otr_command_synchronize_hsize =\page_grd_command_synchronize_hsize,
600 \s!page_otr_command_next_page =\page_grd_command_next_page,
601 \s!page_otr_command_next_page_and_inserts =\page_grd_command_next_page_and_inserts,
602
603
604
605
606 \s!page_otr_command_check_if_float_fits =\page_grd_command_check_if_float_fits,
607
608
609 \s!page_otr_command_synchronize_side_floats =\page_grd_command_synchronize_side_floats,
610 \s!page_otr_command_side_float_output =\page_grd_command_side_float_output,
611 \s!page_otr_command_flush_floats =\page_grd_command_flush_floats,
612 \s!page_otr_command_flush_side_floats =\page_grd_command_flush_side_floats,
613 \s!page_otr_command_flush_saved_floats =\page_grd_command_flush_saved_floats,
614 \s!page_otr_command_flush_all_floats =\page_grd_command_flush_all_floats,
615
616 ]
617
618
619
620\installcorenamespace{pagegridspan}
621
622\installframedcommandhandler \??pagegridspan {pagegridspan} \??pagegridspan
623
624\setuppagegridspan
625 [\c!frame=\v!off,
626 \c!before=,
627 \c!after=,
628 \c!offset=\v!overlay,
629 \c!location=\v!left,
630 \c!linecorrection=\v!off,
631 \c!depthcorrection=\v!off,
632 \c!n=\plustwo,
633 \c!nlines=\zerocount,
634 \c!align=\v!normal,
635 \c!width=\d_page_grd_span_width,
636 \c!indenting=,
637 \c!indentnext=\v!yes,
638 \c!default=\v!here,
639 \c!alternative=\v!a]
640
641\newdimen\d_page_grd_span_width
642
643\unexpanded\def\startpagegridspan
644 {\dotripleempty\page_grd_span_start}
645
646\def\page_grd_span_start[#1][#2][#3]
647 {\endgraf
648 \synchronizepagegrid
649 \bgroup
650 \forgetall
651 \edef\currentpagegridspan{#1}
652 \clf_sethsizecolumnspan{\currentpagegrid}\pagegridspanparameter\c!n\relax
653 \setbox\scratchbox\hbox\bgroup\inheritedpagegridspanframed\bgroup
654 \def\page_grd_span_stop{\page_grd_span_stop_indeed{#2}}
655 \usepagegridspanstyleandcolor\c!style\c!color
656 \pagegridspanparameter\c!before
657 \ignorespaces}
658
659\unexpanded\def\page_grd_span_stop_indeed#1
660 {\removeunwantedspaces
661 \par
662 \verticalstrut
663 \kern2\struttotal
664 \verticalstrut
665 \endgraf
666 \pagegridspanparameter\c!after
667 \egroup\egroup
668 \setpagegrid[#1]{\box\scratchbox}
669
670 \egroup
671 \endgraf}
672
673\unexpanded\def\stoppagegridspan
674 {\page_grd_span_stop}
675
676\def\pagegridspanwidth#1
677 {\the\dimexpr
678 #1\d_page_grd_column_width
679 #1\d_page_grd_distance
680 \d_page_grd_distance
681 \relax}
682
683
684
685\installcorenamespace{pagegridarea}
686
687\installframedcommandhandler \??pagegridarea {pagegridarea} \??pagegridarea
688
689\setuppagegridarea
690 [\c!x=\plusone,
691 \c!y=\plusone,
692 \c!nx=\plusone,
693 \c!ny=\plusone,
694 \c!clipoffset=2\lineheight,
695 \c!leftoffset=\zeropoint,
696 \c!rightoffset=\zeropoint,
697 \c!offset=\v!overlay,
698 \c!strut=\v!no,
699 \c!frame=\v!off,
700
701 \c!align=\v!normal,
702 \c!page=\plusone,
703 \c!state=\v!stop]
704
705
706
707
708\appendtoks
709
710
711
712
713
714
715 \clf_registercolumnsetarea {
716 name {\currentpagegridarea}
717
718
719 state {\pagegridareaparameter\c!state}
720 c \pagegridareaparameter\c!x
721 r \pagegridareaparameter\c!y
722 nc \pagegridareaparameter\c!nx
723 nr \pagegridareaparameter\c!ny
724 }
725\to \everydefinepagegridarea
726
727\unexpanded\def\setuppagegridareatext
728 {\dodoubleargument\page_grd_set_area_text}
729
730\def\page_grd_set_area_text[#1][#2]
731 {\edef\currentpagegridarea{#1}
732 \setpagegridareaparameter\c!text{#2}}
733
734
735
736\unexpanded\def\page_grd_set_area#1#2#3#4#5#6#7#8
737 {\begingroup
738 \edef\currentpagegridarea{#2}
739 \setpagegridareaparameter\c!width {#5\scaledpoint}
740 \setpagegridareaparameter\c!height{#6\scaledpoint}
741 \setbox\nextbox\hpack\bgroup\inheritedpagegridareaframed\bgroup
742 \usepagegridareastyleandcolor\c!style\c!color
743 \ignorespaces
744 \pagegridareaparameter\c!text
745 \egroup\egroup
746
747 \scratchdimen#8\scaledpoint
748 \ifdim\scratchdimen>\zeropoint
749 \setbox\scratchbox\vbox\bgroup
750 \clip
751 [ \c!offset=\pagegridareaparameter\c!clipoffset,
752 \c!rightoffset=\pagegridareaparameter\c!rightoffset,
753 \c!width=\scratchdimen,
754
755 ]
756 {\copy\nextbox}
757 \egroup
758 \clf_setcolumnsetarea{name {#1} box \scratchbox c #3 r #4}
759 \setbox\scratchbox\vbox\bgroup
760 \hskip\layoutparameter\c!backspace
761 \clip
762 [ \c!offset=\pagegridareaparameter\c!clipoffset,
763 \c!leftoffset=\pagegridareaparameter\c!rightoffset,
764 \c!hoffset=\scratchdimen,
765 \c!width=\dimexpr\wd\nextbox\scratchdimen\relax,
766
767 ]
768 {\box\nextbox}
769 \egroup
770 \clf_setcolumnsetarea{name {#1} box \scratchbox c #7 r #4}
771 \else
772 \setbox\scratchbox\vbox\bgroup
773 \box\nextbox
774 \egroup
775 \clf_setcolumnsetarea{name {#1} box \scratchbox c #3 r #4}
776 \fi
777 \endgroup}
778
779\let\setpagegridarea\page_grd_set_area
780
781
782
783
784
785\let\definecolumnset \definepagegrid
786\let\setupcolumnset \setuppagegrid
787\let\setupcolumnsetlines \setuppagegridlines
788\let\setupcolumnsetstart \setuppagegridstart
789\let\startcolumnset \startpagegrid
790\let\stopcolumnset \stoppagegrid
791\let\definecolumnsetspan \definepagegridspan
792\let\setupcolumnsetspan \setuppagegridspan
793\let\startcolumnsetspan \startpagegridspan
794\let\stopcolumnsetspan \stoppagegridspan
795\let\columnsetspanwidth \pagegridspanwidth
796\let\definecolumnsetarea \definepagegridarea
797\let\setupcolumnsetarea \setuppagegridarea
798\let\setupcolumnsetareatext\setuppagegridareatext
799
800
801
802\protect \endinput
803 |