1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16\writestatus{loading}{ConTeXt Table Macros Xtreme}
17
18\registerctxluafile{tablxtb}{}
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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\unprotect
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79\let\dotagxtablecell \relax
80\let\dotagxtablesignal\relax
81
82\appendtoks
83 \def\dotagxtablecell
84 {\clf_settagtablecell
85 \numexpr\tablecellrows\relax
86 \numexpr\tablecellcolumns\relax
87 \numexpr\raggedstatus\relax}
88 \def\dotagxtablesignal
89 {\signalcharacter}
90\to \everyenableelements
91
92\newdimen\d_tabl_x_width
93\newdimen\d_tabl_x_height
94\newdimen\d_tabl_x_depth
95\newdimen\d_tabl_x_distance
96\newcount\c_tabl_x_nx
97\newcount\c_tabl_x_ny
98\newcount\c_tabl_x_mode
99\newbox \b_tabl_x
100\newcount\c_tabl_x_state
101\newdimen\d_tabl_x_final_width
102\newcount\c_tabl_x_nesting
103\newcount\c_tabl_x_skip_mode
104\newdimen\d_tabl_x_textwidth
105\newcount\c_tabl_x_swapped
106\newcount\c_tabl_x_swapped_max
107
108\let\m_tabl_x_swapped_settings\empty
109
110\let\currentxtablerow \clf_x_table_r
111\let\currentxtablecolumn\clf_x_table_c
112
113
114
115
116
117\installcorenamespace{xtable}
118\installcorenamespace{xtablecheck}
119\installcorenamespace{xtableswap}
120
121\installframedautocommandhandler \??xtable {xtable} \??xtable
122
123\appendtoks
124 \checkxtableparent
125\to \everysetupxtable
126
127\setupxtable[
128 \c!nr=\plusone,
129 \c!nc=\plusone,
130 \c!nx=\plusone,
131 \c!ny=\plusone,
132 \c!align=\v!table,
133 \c!frameoffset=.5\linewidth,
134 \c!backgroundoffset=\v!frame,
135
136
137
138
139 \c!width=\v!fit,
140 \c!height=\v!fit,
141 \c!maxwidth=8\emwidth,
142 \c!autowidth=\v!yes,
143 \c!rulethickness=\linewidth,
144 \c!strut=\v!yes,
145 \c!autostrut=\v!no,
146 \c!split=\v!auto,
147 \c!splitoffset=\zeropoint,
148 \c!aligncharacter=\v!no,
149 \c!alignmentcharacter={,},
150 \c!alignmentleftsample=,
151 \c!alignmentrightsample=,
152 \c!alignmentleftwidth=\zeropoint,
153 \c!alignmentrightwidth=\zeropoint,
154
155
156
157 \c!spaceinbetween=,
158 \c!textwidth=\v!local,
159 \c!textheight=\vsize,
160 \c!distance=\zeropoint,
161 \c!columndistance=\zeropoint,
162 \c!leftmargindistance=\zeropoint,
163 \c!rightmargindistance=\zeropoint,
164]
165
166\unexpanded\def\startxtable
167 {\dosingleempty\tabl_x_start_table}
168
169\let\stopxtable\relax
170
171\def\tabl_x_default_buffer{xtable\number\c_tabl_x_nesting}
172\let\tabl_x_current_buffer\empty
173
174\unexpanded\def\tabl_x_start_table[#settings]
175 {\bgroup
176 \tabl_x_prepare{#settings}
177 \edef\tabl_x_current_buffer{\tabl_x_default_buffer}
178 \buff_pickup{\tabl_x_current_buffer}{startxtable}{stopxtable}\relax\tabl_x_process\zerocount}
179
180\unexpanded\def\processxtablebuffer
181 {\dosingleempty\tabl_x_process_buffer_directly}
182
183
184
185
186
187
188
189
190\unexpanded\def\tabl_x_process_buffer_directly[#name]
191 {\bgroup
192 \let\tabl_x_start_table\tabl_x_process_buffer
193 \edef\tabl_x_current_buffer{#name}
194 \tabl_x_get_buffer
195 \tabl_x_process}
196
197\unexpanded\def\tabl_x_start_ignore[#settings]
198 {}
199
200\unexpanded\def\tabl_x_process_buffer[#settings]
201 {\tabl_x_prepare{#settings}
202 \let\tabl_x_start_table\tabl_x_start_ignore
203 \gobbleuntil\stopxtable}
204
205
206
207
208\unexpanded\def\startembeddedxtable
209 {\dosingleempty\tabl_x_embedded_start}
210
211\unexpanded\def\tabl_x_embedded_start[#settings]#content\stopembeddedxtable
212 {\tabl_x_prepare{#settings}
213 \clf_assignbuffer{embeddedxtable}{\detokenize{#content}}\catcodetable\relax
214 \bgroup
215 \let\tabl_x_start_table\tabl_x_process_buffer
216 \edef\tabl_x_current_buffer{embeddedxtable}
217 \tabl_x_process}
218
219\let\stopembeddedxtable\relax
220
221
222
223\appendtoks
224 \setuevalue{\e!start\currentxtable}{\tabl_x_start_named{\currentxtable}}
225 \setuevalue{\e!stop \currentxtable}{\tabl_x_stop_named}
226\to \everydefinextable
227
228\unexpanded\def\tabl_x_start_named#tag
229 {\bgroup
230 \edef\currentxtable{#tag}
231 \dosingleempty\tabl_x_start_named_indeed}
232
233\unexpanded\def\tabl_x_start_named_indeed[#settings]
234 {\advance\c_tabl_x_nesting\plusone
235 \dostarttaggedchained\t!table\empty\??xtable
236 \iffirstargument
237 \setupcurrentxtable[#settings]
238 \fi
239 \tabl_x_check_textwidth
240
241 \edef\tabl_x_current_buffer{\tabl_x_default_buffer}
242 \normalexpanded{\buff_pickup{\tabl_x_current_buffer}{\e!start\currentxtable}{\e!stop\currentxtable}\relax\tabl_x_process\zerocount}}
243
244\unexpanded\def\tabl_x_stop_named
245 {}
246
247
248
249\unexpanded\def\tabl_x_check_textwidth
250 {\edef\p_textwidth{\xtableparameter\c!textwidth}
251 \ifx\p_textwidth\v!local
252 \d_tabl_x_textwidth\availablehsize
253 \else
254 \d_tabl_x_textwidth\p_textwidth
255 \fi}
256
257\newtoks\everypreparextable
258
259\unexpanded\def\tabl_x_prepare#settings
260 {\advance\c_tabl_x_nesting\plusone
261 \dostarttaggedchained\t!table\empty\??xtable
262 \iffirstargument
263 \tabl_x_set_checked{#settings}
264 \fi
265 \tabl_x_check_textwidth
266 \the\everypreparextable
267 }
268
269\def\tabl_x_get_buffer
270 {\clf_getbuffertex{\tabl_x_current_buffer}}
271
272\let\tabl_x_start_row_yes \relax
273\let\tabl_x_start_row_nop \relax
274\let\tabl_x_stop_row \relax
275\let\tabl_x_start_cell_yes\relax
276\let\tabl_x_start_cell_nop\relax
277\let\tabl_x_stop_cell \relax
278
279\newtoks\t_table_x_cleanup
280
281\unexpanded\def\tabl_x_process
282 {\begingroup
283 \forgetall
284 \dontcomplain
285 \usebodyfontparameter\xtableparameter
286 \setbox\scratchbox\vbox
287 {\doifsomething{\xtableparameter\c!spaceinbetween}{\blank[\xtableparameter\c!spaceinbetween]}}
288 \clf_x_table_create
289 option {\xtableparameter\c!option}
290 textwidth \d_tabl_x_textwidth
291 textheight \dimexpr\xtableparameter\c!textheight\relax
292 maxwidth \dimexpr\xtableparameter\c!maxwidth\relax
293 lineheight \openlineheight
294 columndistance \dimexpr\xtableparameter\c!columndistance\relax
295 leftmargindistance \dimexpr\xtableparameter\c!leftmargindistance\relax
296 rightmargindistance \dimexpr\xtableparameter\c!rightmargindistance\relax
297 rowdistance \ht\scratchbox
298 header {\xtableparameter\c!header}
299 footer {\xtableparameter\c!footer}
300 \relax
301
302 \letxtableparameter\c!option\empty
303
304 \linewidth\xtableparameter\c!rulethickness\relax
305
306 \c_tabl_x_swapped_max\zerocount
307 \begingroup
308 \let\tabl_x_start_row_yes \tabl_x_start_row_reflow_width_yes
309 \let\tabl_x_start_row_nop \tabl_x_start_row_reflow_width_nop
310 \let\tabl_x_stop_row \tabl_x_stop_row_reflow_width
311 \let\tabl_x_start_cell_yes\tabl_x_start_cell_reflow_width_yes
312 \let\tabl_x_start_cell_nop\tabl_x_start_cell_reflow_width_nop
313 \let\tabl_x_stop_cell \tabl_x_stop_cell_reflow_width
314 \settrialtypesetting
315 \tabl_x_get_buffer
316 \ifcase\c_tabl_x_swapped_max
317 \else
318 \tabl_x_flush_swapped
319 \fi
320 \clf_x_table_reflow_width
321 \endgroup
322 \begingroup
323 \let\tabl_x_start_row_yes \tabl_x_start_row_reflow_height_yes
324 \let\tabl_x_start_row_nop \tabl_x_start_row_reflow_height_nop
325 \let\tabl_x_stop_row \tabl_x_stop_row_reflow_height
326 \let\tabl_x_start_cell_yes\tabl_x_start_cell_reflow_height_yes
327 \let\tabl_x_start_cell_nop\tabl_x_start_cell_reflow_height_nop
328 \let\tabl_x_stop_cell \tabl_x_stop_cell_reflow_height
329 \settrialtypesetting
330 \ifcase\c_tabl_x_swapped_max
331 \tabl_x_get_buffer
332 \else
333 \tabl_x_flush_swapped
334 \fi
335 \clf_x_table_reflow_height
336 \endgroup
337 \begingroup
338 \let\tabl_x_start_row_yes \tabl_x_start_row_construct_yes
339 \let\tabl_x_start_row_nop \tabl_x_start_row_construct_nop
340 \let\tabl_x_stop_row \tabl_x_stop_row_construct
341 \let\tabl_x_start_cell_yes\tabl_x_start_cell_construct_yes
342 \let\tabl_x_start_cell_nop\tabl_x_start_cell_construct_nop
343 \let\tabl_x_stop_cell \tabl_x_stop_cell_construct
344 \ifcase\c_tabl_x_swapped_max
345 \tabl_x_get_buffer
346 \else
347 \tabl_x_flush_swapped
348 \fi
349 \clf_x_table_construct
350 \endgroup
351 \endgroup
352 \ifinsidesplitfloat
353 \tabl_x_flush_float_split
354 \else\ifinsidefloat
355 \tabl_x_flush_float_normal
356 \else
357 \tabl_x_flush_text_checked
358 \fi\fi
359 \clf_x_table_cleanup
360 \dostoptagged
361 \resetbuffer[\tabl_x_current_buffer]
362 \resetcharacteralign
363 \the\t_table_x_cleanup
364 \egroup}
365
366
367
368\installcorenamespace{xtableflushsplit}
369
370\unexpanded\def\tabl_x_flush_text_checked
371 {\expandnamespaceparameter\??xtableflushsplit\xtableparameter\c!split\v!no}
372
373
374
375\setvalue{\??xtableflushsplit\v!yes}
376 {\clf_x_table_flush
377 method {\v!split}
378 \relax}
379
380
381
382\setvalue{\??xtableflushsplit\v!no}
383 {
384
385
386 \kern\zeropoint
387 \ignorespaces
388 \clf_x_table_flush
389 method {\v!normal}
390 \relax
391 \removeunwantedspaces}
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407\defcsname\??xtableflushsplit\v!repeat\endcsname
408 {\doloop
409 {\testpage[5]
410 \clf_x_table_flush
411 method {\v!split}
412 height \ifdim\pagegoal=\maxdimen\textheight\else\dimexpr\pagegoal\pagetotal\lineheight\relax\fi
413 \relax
414 \ifcase\c_tabl_x_state
415 \exitloop
416 \else
417 \page
418 \fi}}
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445\let\extratxtablesplitheight\zeropoint
446
447\unexpanded\def\tabl_x_flush_float_normal
448 {\clf_x_table_flush
449 method {\v!normal}
450 \relax}
451
452\unexpanded\def\tabl_x_flush_float_split
453 {\resetdirecttsplit
454 \edef\extrasplitfloatlines {\xtableparameter\c!split}
455 \edef\tsplitminimumfreespace{\the\dimexpr\extratxtablesplitheight\xtableparameter\c!splitoffset\relax}
456
457 \let\tsplitdirectsplitter\tabl_x_split_splitter
458 \let\tsplitdirectwidth \d_tabl_x_final_width
459 \handledirecttsplit}
460
461\unexpanded\def\tabl_x_split_splitter#height
462 {\setbox\tsplitresult\vbox
463 {\clf_x_table_flush
464 method {\v!split}
465 height \dimexpr#height\relax
466 \relax}
467 \ifcase\c_tabl_x_state
468 \global\setfalse\somenextsplitofffloat
469 \else
470 \global\settrue \somenextsplitofffloat
471 \fi}
472
473\unexpanded\def\startxrow
474 {\begingroup
475 \doifelsenextoptionalcs\tabl_x_start_row_yes\tabl_x_start_row_nop}
476
477\unexpanded\def\tabl_x_start_row_reflow_width_yes[#settings]
478 {\setupcurrentxtable[#settings]
479 \clf_x_table_next_row}
480
481\unexpanded\def\tabl_x_start_row_reflow_width_nop
482 {\clf_x_table_next_row}
483
484\unexpanded\def\tabl_x_stop_row_reflow_width
485 {}
486
487\let\tabl_x_start_row_reflow_height_yes\tabl_x_start_row_reflow_width_yes
488\let\tabl_x_start_row_reflow_height_nop\tabl_x_start_row_reflow_width_nop
489\let\tabl_x_stop_row_reflow_height \tabl_x_stop_row_reflow_width
490
491\unexpanded\def\tabl_x_start_row_construct_yes[#settings]
492 {\setupcurrentxtable[#settings]
493 \dostarttagged\t!tablerow\empty
494 \clf_x_table_next_row_option{\xtableparameter\c!samepage}}
495
496\unexpanded\def\tabl_x_start_row_construct_nop
497 {\dostarttagged\t!tablerow\empty
498 \clf_x_table_next_row}
499
500\unexpanded\def\tabl_x_stop_row_construct
501 {\clf_x_table_finish_row
502 \dostoptagged}
503
504\unexpanded\def\stopxrow
505 {\tabl_x_stop_row
506 \endgroup}
507
508\unexpanded\def\startxcell
509 {\doifelsenextoptionalcs\tabl_x_start_cell_yes\tabl_x_start_cell_nop}
510
511\unexpanded\def\stopxcell
512 {\tabl_x_stop_cell}
513
514
515
516
517
518\unexpanded\def\dummyxcell
519 {\begingroup
520 \let\inheritedxtableframed\relax
521 \tabl_x_start_cell_nop
522 \tabl_x_stop_cell
523 \endgroup}
524
525
526
527
528
529\def\tabl_x_setup_character_align
530 {\edef\p_left {\directxtableparameter\c!alignmentleftsample}
531 \edef\p_right{\directxtableparameter\c!alignmentrightsample}
532 \ifx\p_left\empty
533 \scratchdimenone\dimexpr\directxtableparameter\c!alignmentleftwidth\relax
534 \else
535 \setbox\scratchbox\hbox{\p_left}
536 \scratchdimenone\wd\scratchbox
537 \fi
538 \ifx\p_right\empty
539 \scratchdimentwo\dimexpr\directxtableparameter\c!alignmentrightwidth\relax
540 \else
541 \setbox\scratchbox\hbox{\p_right}
542 \scratchdimentwo\wd\scratchbox
543 \fi
544 \clf_setcharacteraligndetail
545 \clf_x_table_c
546 {\directxtableparameter\c!alignmentcharacter}
547 \scratchdimenone
548 \scratchdimentwo
549 \relax}
550
551\newtoks\t_tabl_x_every_cell
552
553
554
555
556
557\appendtoks
558 \edef\p_characteralign{\directxtableparameter\c!aligncharacter}
559 \ifx\p_characteralign\v!yes
560 \ifcase\clf_x_table_r\or
561 \tabl_x_setup_character_align
562 \fi
563 \signalcharacteralign\clf_x_table_c\clf_x_table_r
564 \fi
565\to \t_tabl_x_every_cell
566
567\unexpanded\def\tabl_x_begin_of_cell
568 {\the\t_tabl_x_every_cell
569 \everypar{\delayedbegstrut}}
570
571\unexpanded\def\tabl_x_end_of_cell
572 {\ifhmode
573 \delayedendstrut
574 \par
575 \else
576 \par
577 \ifdim\prevdepth<\zeropoint
578 \vskip\strutdp
579 \else
580 \removebottomthings
581 \fi
582 \fi}
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603\let\tabl_x_set_hsize\relax
604
605\unexpanded\def\tabl_x_start_cell_reflow_width_yes[#settings]
606 {\setbox\b_tabl_x\hpack\bgroup
607 \ifnum\c_tabl_x_nesting>\plusone
608 \letxtableparameter\c!width \v!fit
609 \letxtableparameter\c!height\v!fit
610 \fi
611
612 \letxtableparameter\c!nx\plusone
613 \letxtableparameter\c!ny\plusone
614 \letxtableparameter\c!nc\plusone
615 \letxtableparameter\c!nr\plusone
616
617 \setupcurrentxtable[#settings]
618
619 \c_tabl_x_nx\directxtableparameter\c!nc\relax
620 \c_tabl_x_ny\directxtableparameter\c!nr\relax
621 \ifnum\c_tabl_x_nx=\plusone
622 \c_tabl_x_nx\directxtableparameter\c!nx\relax
623 \fi
624 \ifnum\c_tabl_x_ny=\plusone
625 \c_tabl_x_ny\directxtableparameter\c!ny\relax
626 \fi
627
628 \d_tabl_x_distance\xtableparameter\c!distance\relax
629 \clf_x_table_init_reflow_width_option{\xtableparameter\c!option}
630 \inheritedxtableframed\bgroup
631 \tabl_x_begin_of_cell
632 \tabl_x_set_hsize}
633
634\unexpanded\def\tabl_x_start_cell_reflow_width_nop
635 {\setbox\b_tabl_x\hpack\bgroup
636 \ifnum\c_tabl_x_nesting>\plusone
637 \letxtableparameter\c!width \v!fit
638 \letxtableparameter\c!height\v!fit
639 \fi
640 \c_tabl_x_nx\plusone
641 \c_tabl_x_ny\plusone
642 \d_tabl_x_distance\xtableparameter\c!distance\relax
643 \clf_x_table_init_reflow_width
644 \inheritedxtableframed\bgroup
645 \tabl_x_begin_of_cell
646 \tabl_x_set_hsize}
647
648\unexpanded\def\tabl_x_stop_cell_reflow_width
649 {\tabl_x_end_of_cell
650 \egroup
651 \egroup
652 \clf_x_table_set_reflow_width}
653
654\unexpanded\def\tabl_x_start_cell_reflow_height_yes[#settings]
655 {\setbox\b_tabl_x\hpack\bgroup
656 \clf_x_table_init_reflow_height
657 \ifcase\c_tabl_x_skip_mode
658 \ifnum\c_tabl_x_nesting>\plusone
659 \letxtableparameter\c!height\v!fit
660 \fi
661 \setupcurrentxtable[#settings]
662 \relax
663 \letxtableparameter\c!width\d_tabl_x_width
664 \inheritedxtableframed\bgroup
665 \tabl_x_begin_of_cell
666 \fi}
667
668\unexpanded\def\tabl_x_start_cell_reflow_height_nop
669 {\setbox\b_tabl_x\hpack\bgroup
670 \clf_x_table_init_reflow_height
671 \ifcase\c_tabl_x_skip_mode
672 \ifnum\c_tabl_x_nesting>\plusone
673 \letxtableparameter\c!height\v!fit
674 \fi
675 \relax
676 \letxtableparameter\c!width\d_tabl_x_width
677 \inheritedxtableframed\bgroup
678 \tabl_x_begin_of_cell
679 \fi}
680
681\unexpanded\def\tabl_x_stop_cell_reflow_height
682 {\ifcase\c_tabl_x_skip_mode
683 \tabl_x_end_of_cell
684 \egroup
685 \fi
686 \egroup
687 \clf_x_table_set_reflow_height}
688
689\unexpanded\def\tabl_x_start_cell_construct_yes[#settings]
690 {\dostarttagged\t!tablecell\empty
691 \setbox\b_tabl_x\hpack\bgroup
692 \setupcurrentxtable[#settings]
693 \letxtableparameter\c!width \d_tabl_x_width
694 \letxtableparameter\c!height\d_tabl_x_height
695 \clf_x_table_init_construct
696 \inheritedxtableframed\bgroup
697 \tabl_x_begin_of_cell
698 \dotagxtablecell}
699
700\unexpanded\def\tabl_x_start_cell_construct_nop
701 {\dostarttagged\t!tablecell\empty
702 \setbox\b_tabl_x\hpack\bgroup
703 \letxtableparameter\c!width \d_tabl_x_width
704 \letxtableparameter\c!height\d_tabl_x_height
705 \clf_x_table_init_construct
706 \inheritedxtableframed\bgroup
707 \tabl_x_begin_of_cell
708 \dotagxtablecell}
709
710\unexpanded\def\tabl_x_stop_cell_construct
711 {\tabl_x_end_of_cell
712 \egroup
713 \dotagxtablesignal
714 \egroup
715 \clf_x_table_set_construct
716 \dostoptagged}
717
718\unexpanded\def\startxcellgroup
719 {\begingroup
720 \dosingleempty\tabl_x_start_cell_group}
721
722\unexpanded\def\stopxcellgroup
723 {\endgroup}
724
725\unexpanded\def\tabl_x_start_cell_group[#settings]
726 {\iffirstargument
727 \tabl_x_set_checked{#settings}
728 \fi}
729
730\unexpanded\def\startxrowgroup
731 {\begingroup
732 \dosingleempty\tabl_x_start_row_group}
733
734\unexpanded\def\stopxrowgroup
735 {\dostoptagged
736 \endgroup}
737
738\unexpanded\def\tabl_x_start_row_group[#settings]
739 {\iffirstargument
740 \tabl_x_set_checked{#settings}
741 \fi}
742
743
744
745
746
747
748
749
750\unexpanded\def\tabl_x_set_checked#settings
751 {\ifcsname\namedxtablehash{#settings}\s!parent\endcsname
752 \edef\currentxtable{#settings}
753 \else
754 \setupcurrentxtable[#settings]
755 \fi}
756
757\unexpanded\def\startxtablehead{\begingroup\c_tabl_x_mode\plusone \dosingleempty\tabl_x_start_partition}
758\unexpanded\def\startxtablefoot{\begingroup\c_tabl_x_mode\plustwo \dosingleempty\tabl_x_start_partition}
759\unexpanded\def\startxtablenext{\begingroup\c_tabl_x_mode\plusthree\dosingleempty\tabl_x_start_partition}
760\unexpanded\def\startxtablebody{\begingroup\c_tabl_x_mode\plusfour \dosingleempty\tabl_x_start_partition}
761
762\unexpanded\def\tabl_x_start_partition[#settings]
763 {\iffirstargument
764 \tabl_x_set_checked{#settings}
765 \fi}
766
767\unexpanded\def\tabl_x_stop_partition
768 {\endgroup}
769
770\let\stopxtablehead\tabl_x_stop_partition
771\let\stopxtablefoot\tabl_x_stop_partition
772\let\stopxtablenext\tabl_x_stop_partition
773\let\stopxtablebody\tabl_x_stop_partition
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804\appendtoks
805 \letvalue{\??xtablecheck\currentxtable}\relax
806\to \everysetupxtable
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823\unexpanded\def\startxgroup
824 {\begingroup
825 \doifelsenextoptionalcs\tabl_x_start_group_delayed_one\relax}
826
827\unexpanded\def\stopxgroup
828 {\endgroup}
829
830\unexpanded\def\tabl_x_start_group_delayed_one[#tag]
831 {\ifcsname\??xtablecheck\detokenize\expandafter{\normalexpanded{#tag}}\endcsname
832 \expandafter\tabl_x_start_group_delayed_two
833 \else
834 \expandafter\setupcurrentxtable
835 \fi[#tag]}
836
837\unexpanded\def\tabl_x_start_group_delayed_two[#tag]
838 {\ifx\currentxtable\empty \else
839 \chaintocurrentxtable{#tag}
840 \fi
841 \edef\currentxtable{#tag}
842 \doifelsenextoptionalcs\setupcurrentxtable\relax}
843
844\let\startxrowgroup \startxgroup
845\let\stopxrowgroup \stopxgroup
846\let\startxcellgroup\startxgroup
847\let\stopxcellgroup \stopxgroup
848
849
850
851\unexpanded\def\startxcell
852 {\begingroup
853 \doifelsenextoptionalcs\tabl_x_start_cell_delayed_one\tabl_x_start_cell_nop}
854
855\unexpanded\def\tabl_x_start_cell_delayed_one[#tag]
856 {\ifcsname\??xtablecheck\detokenize\expandafter{\normalexpanded{#tag}}\endcsname
857 \expandafter\tabl_x_start_cell_delayed_two
858 \else
859 \expandafter\tabl_x_start_cell_yes
860 \fi[#tag]}
861
862\unexpanded\def\tabl_x_start_cell_delayed_two[#tag]
863 {\ifx\currentxtable\empty \else
864 \chaintocurrentxtable{#tag}
865 \fi
866 \edef\currentxtable{#tag}
867 \doifelsenextoptionalcs\tabl_x_start_cell_yes\tabl_x_start_cell_nop}
868
869\unexpanded\def\stopxcell
870 {\tabl_x_stop_cell
871 \endgroup}
872
873
874
875\unexpanded\def\startxrow
876 {\begingroup
877 \doifelsenextoptionalcs\tabl_x_start_row_delayed_one\tabl_x_start_row_nop}
878
879\unexpanded\def\tabl_x_start_row_delayed_one[#tag]
880 {\ifcsname\??xtablecheck\detokenize\expandafter{\normalexpanded{#tag}}\endcsname
881 \expandafter\tabl_x_start_row_delayed_two
882 \else
883 \expandafter\tabl_x_start_row_yes
884 \fi[#tag]}
885
886\unexpanded\def\tabl_x_start_row_delayed_two[#tag]
887 {\ifx\currentxtable\empty \else
888 \chaintocurrentxtable{#tag}
889 \fi
890 \edef\currentxtable{#tag}
891 \doifelsenextoptionalcs\tabl_x_start_row_yes\tabl_x_start_row_nop}
892
893\unexpanded\def\stopxrow
894 {\tabl_x_stop_row
895 \endgroup}
896
897
898
899\unexpanded\def\tabl_x_nc
900 {\startxrow
901 \let\NC\tabl_x_nc_next
902 \let\NR\tabl_x_nr
903 \startxcell}
904
905\unexpanded\def\tabl_x_nc_next
906 {\stopxcell
907 \startxcell}
908
909\unexpanded\def\tabl_x_nr
910 {\stopxcell
911 \stopxrow
912 \let\NC\tabl_x_nc}
913
914\appendtoks
915 \let\NC\tabl_x_nc
916 \let\NR\tabl_x_nr
917\to \everypreparextable
918
919
920
921\unexpanded\def\tabl_x_c_cell_start#settings
922 {\begingroup
923 \tabl_x_set_checked{#settings}
924 \doifelsenextoptionalcs\tabl_x_start_cell_yes\tabl_x_start_cell_nop}
925
926\unexpanded\def\tabl_x_c_cell_stop
927 {\tabl_x_stop_cell
928 \endgroup}
929
930
931
932
933
934\def\tabl_x_flush_swapped
935 {\dorecurse\c_tabl_x_swapped_max
936 {\expandafter
937 \startxrow
938 \the\csname\??xtableswap##1\endcsname\relax
939 \stopxrow}}
940
941\def\tabl_x_collect_allocate
942 {\expandafter\newtoks\csname\??xtableswap\number\c_tabl_x_swapped\endcsname
943 \expandafter\let\expandafter\t_tabl_x_swapped\csname\??xtableswap\number\c_tabl_x_swapped\endcsname}
944
945\def\tabl_x_collect_advance
946 {\global\advance\c_tabl_x_swapped\plusone
947 \ifnum\c_tabl_x_swapped>\c_tabl_x_swapped_max
948 \global\c_tabl_x_swapped_max\c_tabl_x_swapped
949 \fi
950 \expandafter\let\expandafter\t_tabl_x_swapped\csname\??xtableswap\number\c_tabl_x_swapped\endcsname
951 \ifx\t_tabl_x_swapped\relax
952 \tabl_x_collect_allocate
953 \fi}
954
955\unexpanded\def\tabl_x_collect_cell_start
956 {\doifelsenextoptionalcs
957 \tabl_x_collect_cell_start_yes
958 \tabl_x_collect_cell_start_nop}
959
960\def\tabl_x_collect_cell_start_nop#content\stopxcell
961 {\tabl_x_collect_advance
962 \ifx\m_tabl_x_swapped_settings\empty
963 \gtoksapp\t_tabl_x_swapped{\tabl_x_c_cell_start{}#content\tabl_x_c_cell_stop}
964 \else
965 \gtoksapp\t_tabl_x_swapped\expandafter{\expandafter\tabl_x_c_cell_start\expandafter{\m_tabl_x_swapped_settings}#content\tabl_x_c_cell_stop}
966 \fi}
967
968\def\tabl_x_collect_cell_start_yes[#settings]#content\stopxcell
969 {\tabl_x_collect_advance
970 \ifx\m_tabl_x_swapped_settings\empty
971 \gtoksapp\t_tabl_x_swapped{\tabl_x_c_cell_start{}[#settings]#content\tabl_x_c_cell_stop}
972 \else
973 \gtoksapp\t_tabl_x_swapped\expandafter{\expandafter\tabl_x_c_cell_start\expandafter{\m_tabl_x_swapped_settings}[#settings]#content\tabl_x_c_cell_stop}
974 \fi
975 \getdummyparameters[\c!ny=1,#settings]
976 \scratchcounter\numexpr\dummyparameter\c!ny\plusone\relax
977 \ifcase\scratchcounter\else
978 \dorecurse\scratchcounter\tabl_x_collect_advance
979 \fi}
980
981\unexpanded\def\startxcolumn
982 {\begingroup
983 \global\c_tabl_x_swapped\zerocount
984 \let\startxcell\tabl_x_collect_cell_start
985 \let\stopxcell \relax
986 \doifelsenextoptionalcs\tabl_x_start_column_yes\tabl_x_start_column_nop}
987
988\def\tabl_x_start_column_yes[#1]
989 {\xdef\m_tabl_x_swapped_settings{#1}}
990
991\def\tabl_x_start_column_nop
992 {\glet\m_tabl_x_swapped_settings\empty}
993
994\unexpanded\def\stopxcolumn
995 {\endgroup}
996
997\appendtoks
998 \dorecurse\c_tabl_x_swapped_max
999 {\global\csname\??xtableswap\number#1\endcsname\emptytoks}
1000\to \t_table_x_cleanup
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039\protect \endinput
1040 |