tabl-tbl.mkxl /size: 104 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=core-tbl,
3
%D version=1998.11.03,
4
%D title=\CONTEXT\ Table Macros,
5
%D subtitle=Text Flow Tabulation,
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
Table
Macros
/
Tabulation
}
15 16
\unprotect
17 18
\registerctxluafile
{
tabl
-
tbl
}{}
% experiment
19 20
%D I can probably reimplement this using a \LUATEX\ combination but it does not pay
21
%D of in development time. If I need something else I will write it from scratch
22
%D anyway. This module looks a bit complex which is a consequence of it dealing with
23
%D paragraphs being split over pages and that there are several passes over the data
24
%D set. We can probably do some cleanup (combine/split).
25
%D
26
%D Caching the preamble does not save much (compared to other bits and pieces of
27
%D \CONTEXT). There are not that many ways to deal with preambles and this is just
28
%D one of them. The keys are somewhat similar to those of the \TABLE\ package.
29 30
% |p2|p3| 2:3 -> spanning (maybe)
31
%
32
% In-text tabbing environment
33
%
34
% \starttabulate[| separated template] % eg [|l|p|] or [|l|p|p|]
35
% \NC ... \NC ... \NC\NR
36
% \stoptabulate
37
%
38
% with: two pass auto width calculation when no p-width
39
% specified, even with multiple p's, see examples.
40
%
41
% TaBlE compatible specifications:
42
%
43
% l align column/paragraph left
44
% r align column/paragraph right
45
% c align column/paragraph center
46
% p p(dimen) of automatisch als alleen p
47
% w column width
48
% f font#1
49
% A {alignmentoptions}
50
% B bold
51
% I italic
52
% S slanted
53
% T type
54
% R roman
55
% m math
56
% M display math
57
% h hook (inner level or par lines)
58
% b before (may be command#1)
59
% a after
60
% i i<n> skip left of column
61
% j i<n> skip right of column
62
% k i<n> skip around column
63
% d digits (~)
64
%
65
% C [LMRT] {color} % T is text color
66
%
67
% | {color,n}
68
%
69
% s setups
70
%
71
% g g{char} align at char
72
% . align at .
73
% , align at ,
74
%
75
% Still to be done
76
%
77
% N math numbers (best hook into existing digits mechanism)
78
% n numbers (best hook into existing digits mechanism)
79
% Q math numbers (best hook into existing digits mechanism)
80
% q numbers (best hook into existing digits mechanism)
81
% ~ \hskip.5em
82
% | check
83
%
84
% nesting
85
%
86
% 10 evt auto stack; dan wel andere signal dan void nodig
87
%
88
% present but not yet 100% ok
89
%
90
% \TL [width,color] bottom hrule
91
% \FL [width,color] first hrule
92
% \ML [width,color] mid hrule (with auto split)
93
% \LL [width,color] bottom hrule
94
% \BL [width,color] last hrule
95
%
96
% \HL [width,color] top rule
97
% \VL [width,color]
98
%
99
% \CC \CL \CM \CR color
100
%
101
% \EQ \RQ \HQ equal (raw, hook)
102
% \NC \RC \HC normal (raw, hook)
103
%
104
% \NR checked break
105
% \NB no break
106
%
107
% \HR : rule with lineheight
108
%
109
% \autotabulaterule : with lineheight, not first/last
110
% \autotabulateline : spaced, not first/last
111
% \tabulaterule : with lineheight
112
% \tabulateline : spaced
113
%
114
% tricky: align scans ahead, over # and expands ones before
115
% while doing
116
%
117
% new:
118
%
119
% \starttabulate[|cg{.}|cg{,}|cg{,}|]
120
% \NC period \NC comma \NC comma \NC\NR
121
% \NG 100.000,00 \NG 100.000,00 \NG 100,00 \NC\NR
122
% \NG 10.000,00 \NG 10.000,00 \NG 1000,00 \NC\NR
123
% \NG 100,00 \NG 100,00 \NG 10,00 \NC\NR
124
% \NG 10 \NG 10 \NG 0,00 \NC\NR
125
% \stoptabulate
126
%
127
% \starttabulate[|c.|c,|c,|]
128
% \NC period \NC comma \NC comma \NC\NR
129
% \NG 100.000,00 \NG 100.000,00 \NG 100,00 \NC\NR
130
% \NG 10.000,00 \NG 10.000,00 \NG 1000,00 \NC\NR
131
% \NG 100,00 \NG 100,00 \NG 10,00 \NC\NR
132
% \NG 10 \NG 10 \NG 0,00 \NC\NR
133
% \stoptabulate
134 135
% nice demo (for BG)
136
%
137
% \starttabulate[|r|b{$\star$}|ra{\percent}|b{=}|r|]
138
% \NC 500 \NC \NC 60 \NC \NC 300 \NC \NR
139
% \NC 500 \NC \NC 55 \NC \NC 275 \NC \NR
140
% \NC 500 \NC \NC 50 \NC \NC 250 \NC \NR
141
% \NC 500 \NC \NC 45 \NC \NC 225 \NC \NR
142
% \NC 500 \NC \NC 40 \NC \NC 200 \NC \NR
143
% \NC 500 \NC \NC 35 \NC \NC 175 \NC \NR
144
% \NC 500 \NC \NC 30 \NC \NC 150 \NC \NR
145
% \NC 500 \NC \NC 25 \NC \NC 125 \NC \NR
146
% \NC 500 \NC \NC 20 \NC \NC 100 \NC \NR
147
% \stoptabulate
148 149
\newtoks
\t_tabl_tabulate_preamble
150
\newtoks
\t_tabl_tabulate_before
151
\newtoks
\t_tabl_tabulate_after
152
\newtoks
\t_tabl_tabulate_bmath
153
\newtoks
\t_tabl_tabulate_emath
154
\newtoks
\t_tabl_tabulate_font
155
\newtoks
\t_tabl_tabulate_settings
156
\newtoks
\t_tabl_tabulate_dummy
157
\newtoks
\t_tabl_tabulate_every_row
158
\newtoks
\t_tabl_tabulate_every_after_row
159
\newtoks
\t_tabl_tabulate_every_real_row
160 161
\newtoks
\t_tabl_tabulate_initializers_first
162
\newtoks
\t_tabl_tabulate_initializers_second
163 164
\newcount
\c_tabl_tabulate_nofauto
165
\newcount
\c_tabl_tabulate_columns
166
\newcount
\c_tabl_tabulate_column
167
\newcount
\c_tabl_tabulate_plines_min
168
\newcount
\c_tabl_tabulate_plines_max
169
\newcount
\c_tabl_tabulate_max_colorcolumn
170
\newcount
\c_tabl_tabulate_max_vrulecolumn
171
\newcount
\c_tabl_tabulate_repeathead
172
\newcount
\c_tabl_tabulate_noflines
173
\newcount
\c_tabl_tabulate_totalnoflines
174
\newcount
\c_tabl_tabulate_minusnoflines
175
\newcount
\c_tabl_tabulate_align
176
\newcount
\c_tabl_tabulate_nofrealrows
177
\newcount
\c_tabl_tabulate_autocolor
178 179
\newcount
\c_tabl_tabulate_nofcolumns
% set at the lua end by parser
180
\newcount
\c_tabl_tabulate_has_rule_spec_first
% set at the lua end by parser (for the moment a count)
181
\newcount
\c_tabl_tabulate_has_rule_spec_last
% set at the lua end by parser (for the moment a count)
182 183
\newconditional
\c_tabl_tabulate_nopbreak
184
\newconditional
\c_tabl_tabulate_firstflushed
185
\newconditional
\c_tabl_tabulate_equal
186
\newconditional
\c_tabl_tabulate_split
\settrue
\c_tabl_tabulate_split
187
\newconditional
\c_tabl_tabulate_automode
188
\newconditional
\c_tabl_tabulate_handlepbreak
\settrue
\c_tabl_tabulate_handlepbreak
189
\newconditional
\c_tabl_tabulate_autorulespacing
\settrue
\c_tabl_tabulate_autorulespacing
190
\newconditional
\c_tabl_tabulate_someamble
191
\newconditional
\c_tabl_tabulate_tolerant_break
192
\newconditional
\c_tabl_tabulate_splitoff_whitespace
193
\newconditional
\c_tabl_tabulate_pwidth_set
194
\newconditional
\c_tabl_tabulate_reshape
195 196
\newdimen
\d_tabl_tabulate_width_p
197
\newdimen
\d_tabl_tabulate_width_w
198
\newdimen
\d_tabl_tabulate_width
199
\newdimen
\d_tabl_tabulate_unit
200
\newdimen
\d_tabl_tabulate_height_p_max
201
\newdimen
\d_tabl_tabulate_vrulethickness_default
202
\newdimen
\d_tabl_tabulate_hrulethickness_default
203
\newdimen
\d_tabl_tabulate_vrulethickness
204
\newdimen
\d_tabl_tabulate_hrulethickness
% not used
205
\newdimen
\d_tabl_tabulate_vrulethickness_local
206
\newdimen
\d_tabl_tabulate_hrulethickness_local
207
\newdimen
\d_tabl_tabulate_indent
208
\newdimen
\d_tabl_tabulate_splitoff_betweenskip
209
\newdimen
\d_tabl_tabulate_margin
210 211
\newskip
\s_tabl_tabulate_pre
212
\newskip
\s_tabl_tabulate_post
213
\newskip
\s_tabl_tabulate_first
214
\newskip
\s_tabl_tabulate_last
215
\newskip
\s_tabl_tabulate_separator
216 217
\newbox
\b_tabl_tabulate
218 219
\newconstant
\c_tabl_tabulate_pass
220
\newconstant
\c_tabl_tabulate_type
221
\newconstant
\c_tabl_tabulate_kind
% 1=strong 2=equals
222
\newconstant
\c_tabl_tabulate_splitlinemode
\c_tabl_tabulate_splitlinemode
\plusone
223
\newconstant
\c_tabl_tabulate_colorspan
224
\newconstant
\c_tabl_tabulate_localcolorspan
225
\newconstant
\c_tabl_tabulate_modus
226 227
\let
\tabulatesplitlinemode
\c_tabl_tabulate_splitlinemode
% temp hack, we need an interface
228 229
\let
\m_tabl_tabulate_separator_factor
\empty
% fraction
230 231
\newtoks
\everytabulatepar
% where used ?
232
\newtoks
\everytabulate
% public ?
233 234
\unexpanded
\def
\tolerantTABLEbreaktrue
{
\settrue
\c_tabl_tabulate_tolerant_break
}
% used in styles !
235
\unexpanded
\def
\handletabulatepbreakfalse
{
\setfalse
\c_tabl_tabulate_handlepbreak
}
% depricated
236 237
\def
\noftabulaterows
{
\number
\c_tabl_tabulate_noflines
}
% handy for testing if a table is empty
238 239
\installcorenamespace
{
tabulatebox
}
240
\installcorenamespace
{
tabulatesetup
}
241
\installcorenamespace
{
tabulatehook
}
242
\installcorenamespace
{
tabulatesplit
}
243
\installcorenamespace
{
tabulateseparator
}
244
\installcorenamespace
{
tabulatecolor
}
245
\installcorenamespace
{
tabulateheader
}
246
\installcorenamespace
{
tabulatealigning
}
247
\installcorenamespace
{
tabulatepreamble
}
248
\installcorenamespace
{
tabulatevrule
}
249 250
\installcorenamespace
{
tabulatehead
}
251
\installcorenamespace
{
tabulatefoot
}
252
\installcorenamespace
{
tabulatenext
}
253 254
\prependtoks
255
\global
\c_tabl_tabulate_nofrealrows
\zerocount
256
\to
\t_tabl_tabulate_initializers_first
257 258
\prependtoks
259
\global
\c_tabl_tabulate_nofrealrows
\zerocount
260
\to
\t_tabl_tabulate_initializers_second
261 262
\prependtoks
263
\global\advance
\c_tabl_tabulate_nofrealrows
\plusone
264
\to
\t_tabl_tabulate_every_real_row
265 266
\def
\b_tabl_tabulate_current
#
1
%
267
{
\csname
\??tabulatebox
\number
#
1
\endcsname
}
% beware, a synonym
268 269
\def
\tabl_tabulate_initialize_boxes
#
1
%
270
{
\scratchcounter
#
1
\relax
271
\tabl_tabulate_initialize_boxes_step
}
272 273
\def
\tabl_tabulate_initialize_boxes_step
274
{
\ifnum
\scratchcounter
>
\zerocount
275
\tabl_tabulate_initialize_box
\scratchcounter
276
\advance
\scratchcounter
\minusone
277
\expandafter
\tabl_tabulate_initialize_boxes_step
278
\fi
}
279 280
\def
\tabl_tabulate_initialize_box
#
1
% also used elsewhere
281
{
\ifcsname
\??tabulatebox
\number
#
1
\endcsname
282
\tabl_tabulate_initialize_box_yes
283
\else
284
\tabl_tabulate_initialize_box_nop
#
1
%
285
\fi
}
286 287
\def
\tabl_tabulate_initialize_box_yes
{
\global
\setbox\lastnamedcs
\emptybox
}
288
\def
\tabl_tabulate_initialize_box_nop
#
1
{
\expandafter
\newbox
\csname
\??tabulatebox
\number
#
1
\endcsname
}
289 290
\tabl_tabulate_initialize_boxes
{
1
6
}
% not really needed
291 292
\let
\initializetablebox
\tabl_tabulate_initialize_box
% used elsewhere, will change
293
\let
\initializetableboxes
\tabl_tabulate_initialize_boxes
% used elsewhere, will change
294
\let
\tablebox
\b_tabl_tabulate_current
295 296
% 0 = NC column next EQ equal column
297
% 1 = RC column raw RQ equal column raw
298
% 2 = HC column hook HQ equal column hook
299 300
% handy helper (problem: we have an extra group when we nest; playing with en engine
301
% solution turned out to be too messy due to states; an ignoreendgroup trick also is
302
% messy and interferes).
303 304
\def
\tabulatenoalign
% public ?
305
{
\noalign
306
\bgroup
307
\let\noalign\relax
308
\let
\tabulatenoalign
\relax
309
\let
\next
=
}
310 311
\def
\starttabulatenoalign
% public ?
312
{
\tabulatenoalign
\bgroup
}
313 314
\let
\stoptabulatenoalign
\egroup
315 316
% [|lg{.}|] => \NG 12.34 \NC
317 318
\def
\tabl_tabulate_nobreak_inject_tracer
319
{
\red
% maybe use the fast color switcher here
320
\hrule
\s!height
.
5
\linewidth
\s!depth
.
5
\linewidth
321
\par
322
\kern
-
\linewidth
323
\tabl_tabulate_break_no
}
324 325
\installtextracker
326
{
tables
.
tabulate
.
breaks
}
327
{
\let
\tabl_tabulate_break_no_tracer
\tabl_tabulate_nobreak_inject_tracer
}
328
{
\let
\tabl_tabulate_break_no_tracer
\donothing
}
329 330
\let
\tabl_tabulate_break_no_tracer
\donothing
331 332
\def
\tabl_tabulate_nobreak_inject_indeed
333
{
\tabl_tabulate_break_no
334
\tabl_tabulate_break_no_tracer
}
335 336
\def
\tabl_tabulate_nobreak_inject
337
{
\tabulatenoalign
{
\tabl_tabulate_nobreak_inject_indeed
}}
338 339
\unexpanded
\def
\tabl_tabulate_hook_check
340
{
\ifnum
\c_tabl_tabulate_type
<
\plustwo
341
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_nop
342
\else
343
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_yes
344
\fi
}
345 346
\unexpanded
\def
\tabl_tabulate_setups_check
347
{
\begincsname
\??tabulatesetup
\the
\c_tabl_tabulate_column
\endcsname
}
348 349
\unexpanded
\def
\tabl_tabulate_entry_before
{
\ignorespaces
\tabl_tabulate_hook
}
350
\unexpanded
\def
\tabl_tabulate_entry_after
{
\unskip\unskip\ifmmode\else
\endgraf
\fi
}
351 352
\unexpanded
\def
\tabl_tabulate_shaped_par_begin
353
{
\dowithnextboxcs
\tabl_tabulate_shaped_par_finish
\vbox
\bgroup
}
354 355
\def
\tabl_tabulate_shaped_par_finish
356
{
\clf_doreshapeframedbox
\nextbox
\relax
357
\ifvmode
\unvbox\else\box\fi
\nextbox
}
358 359
\let
\tabl_tabulate_shaped_par_end
\egroup
360 361
\ifdefined
\dotagtabulatecell
\else
\let
\dotagtabulatecell
\relax
\fi
362
\ifdefined
\dotagtabulatesignal
\else
\let
\dotagtabulatesignal
\relax
\fi
363 364
\unexpanded
\def
\tabl_tabulate_check_local_color_first
#
1
#
2
%
365
{
\relax
}
366 367
\unexpanded
\def
\tabl_tabulate_check_local_color_second
#
1
#
2
%
368
{
\relax
369
\ifempty
\m_tabl_tabulate_color_local
370
\xdef
\m_tabl_tabulate_color
{
#
1
}
%
371
\else
372
\glet
\m_tabl_tabulate_color
\m_tabl_tabulate_color_local
373
\glet
\m_tabl_tabulate_color_local
\empty
374
\fi
375
\ifcase
\c_tabl_tabulate_localcolorspan
376
\global
\c_tabl_tabulate_colorspan
#
2
\relax
377
\else
378
\global
\c_tabl_tabulate_colorspan
\c_tabl_tabulate_localcolorspan
379
\global
\c_tabl_tabulate_localcolorspan
\zerocount
380
\fi
}
381 382
\unexpanded
\def
\tabl_tabulate_check_local_vrule_thickness
#
1
%
383
{
\relax
384
\ifcase
\d_tabl_tabulate_vrulethickness_local
385
\global
\d_tabl_tabulate_vrulethickness
#
1
\relax
386
\else
387
\global
\d_tabl_tabulate_vrulethickness
\d_tabl_tabulate_vrulethickness_local
388
\global
\d_tabl_tabulate_vrulethickness_local
\zeropoint
389
\fi
}
390 391
\unexpanded
\def
\tabl_tabulate_check_local_vrule_color_first
#
1
%
392
{
\relax
}
393 394
\unexpanded
\def
\tabl_tabulate_check_local_vrule_color_second
#
1
%
395
{
\relax
396
\ifempty
\m_tabl_tabulate_vrule_color_local
397
\xdef
\m_tabl_tabulate_vrule_color
{
#
1
}
%
398
\else
399
\glet
\m_tabl_tabulate_vrule_color
\m_tabl_tabulate_vrule_color_local
400
\glet
\m_tabl_tabulate_vrule_color_local
\empty
401
\fi
}
402 403
\let
\tabl_tabulate_check_local_color
\gobbletwoarguments
404
\let
\tabl_tabulate_check_local_vrule_color
\gobbleoneargument
405 406
\appendtoks
407
\let
\tabl_tabulate_check_local_color
\tabl_tabulate_check_local_color_first
408
\let
\tabl_tabulate_check_local_vrule_color
\tabl_tabulate_check_local_vrule_color_first
409
\to
\t_tabl_tabulate_initializers_first
410 411
\appendtoks
412
\let
\tabl_tabulate_check_local_color
\tabl_tabulate_check_local_color_second
413
\let
\tabl_tabulate_check_local_vrule_color
\tabl_tabulate_check_local_vrule_color_second
414
\to
\t_tabl_tabulate_initializers_second
415 416
% \unexpanded % we can expand this one
417
\def
\tabl_tabulate_inject_pre_skip
#
1
%
418
{
\ifdim
#
1
>
\zeropoint
419
\kern
#
1
\relax
% was \hskip
420
\orelse\ifnum
\c_tabl_tabulate_column
=
\zerocount
421
\ifconditional
\c_tabl_tabulate_autorulespacing
422
\ifcase
\c_tabl_tabulate_has_rule_spec_first
\else
423
\kern
\s_tabl_tabulate_first
\relax
% was \hskip
424
\fi
425
\fi
426
\fi
}
427 428
% \unexpanded % we can expand this one
429
\def
\tabl_tabulate_inject_post_skip
#
1
%
430
{
\ifdim
#
1
>
\zeropoint
431
\kern
#
1
\relax
% was \hskip
432
\orelse\ifnum
\c_tabl_tabulate_columns
=
\c_tabl_tabulate_nofcolumns
433
\ifconditional
\c_tabl_tabulate_autorulespacing
434
\ifcase
\c_tabl_tabulate_has_rule_spec_last
\else
435
\kern
\s_tabl_tabulate_last
\relax
% was \hskip
436
\fi
437
\fi
438
\fi
}
439 440
\let
\tabl_tabulate_hook_b
\donothing
441
\let
\tabl_tabulate_hook_e
\donothing
442 443
\let
\tabl_tabulate_hook_g
\donothing
444 445
\def
\tabl_tabulate_set_preamble_step
#
1
#
2
% only makes sense for many tabulates
446
{
\etoksapp
\t_tabl_tabulate_preamble
{
%
447
\tabl_tabulate_check_local_vrule_thickness
\constantdimenargument
\d_tabl_tabulate_vrulethickness
448
\tabl_tabulate_check_local_vrule_color
\constantemptyargument
\m_tabl_tabulate_vrule_color
449
\tabl_tabulate_check_local_color
\constantemptyargument
\m_tabl_tabulate_color
\constantnumberargument
\c_tabl_tabulate_colorspan
450
\tabl_tabulate_color_side_right
451
\aligntab
452
\tabl_tabulate_column_vrule_inject
453
\tabl_tabulate_color_side_left
454
\tabl_tabulate_inject_pre_skip
{
\the\dimexpr
\s_tabl_tabulate_pre
}
% get rid of plus
455
\alignmark\alignmark
456
\aligntab
457
\tabl_tabulate_color_side_both
458
\global
\c_tabl_tabulate_colorspan
\zerocount
459
\global
\c_tabl_tabulate_column
\constantnumber
\c_tabl_tabulate_columns
460
\tabl_tabulate_hook_g
461
\tabl_tabulate_setups_check
% unexpandable
462
\tabl_tabulate_hook_check
% unexpandable
463
\ifzeropt
\d_tabl_tabulate_width
464
\ifcase
\c_tabl_tabulate_modus
\else
465
\settrue
\c_tabl_tabulate_automode
466
\fi
467
\else
468
\ifcase
\c_tabl_tabulate_modus
469
\hbox
to
470
\else
471
\hsize
472
\fi
473
\the
\d_tabl_tabulate_width
474
\fi
475
\bgroup
476
\tabl_tabulate_bbskip
477
\bgroup
% we cannot combine the if because a cell may have only one ##
478
\tabl_tabulate_hook_b
479
\c_tabl_tabulate_align
\constantnumber
\c_tabl_tabulate_align
% needed in tag passing
480
\ifempty
\m_tabl_tabulate_alignment
\else
481
\spac_align_use_now
{
\m_tabl_tabulate_alignment
}
%
482
\fi
483
\noexpand
\dostarttagged
\noexpand
\t!tabulatecell
\noexpand
\empty
484
\noexpand
\dotagtabulatecell
485
\noexpand
#
1
%
486
\ifconditional
\c_tabl_tabulate_reshape
487
\tabl_tabulate_shaped_par_begin
488
\fi
489
\dotagtabulatesignal
% empty cells .. todo (can be removed as soon as build)
490
\noexpand\ifnum\noexpand
\c_tabl_tabulate_type
=
\plusone
\noexpand\else
491
\the
\t_tabl_tabulate_bmath
% maybe later? can interfere with char 0
492
\the
\t_tabl_tabulate_font
493
\the
\t_tabl_tabulate_settings
494
\the
\t_tabl_tabulate_before
495
\ifempty
\m_tabl_tabulate_text_color
496
\expandafter
\gobbleoneargument
497
\else
498
\expandafter
\dofastcoloractivation
499
\fi
\m_tabl_tabulate_text_color
500
\noexpand\fi
501
% grouping needs to be outside macros (or expandable), nice test
502
% example \NC \string \aligntab \NC which will fail otherwise (mk)
503
\bgroup
504
\tabl_tabulate_entry_before
505
\alignmark\alignmark
506
\tabl_tabulate_entry_after
507
\egroup
508
\noexpand\ifnum\noexpand
\c_tabl_tabulate_type
=
\plusone
\noexpand\else
509
\the
\t_tabl_tabulate_after
510
\the
\t_tabl_tabulate_emath
511
\noexpand\fi
512
\ifconditional
\c_tabl_tabulate_reshape
513
\tabl_tabulate_shaped_par_end
514
\fi
515
\noexpand
#
2
%
516
\tabl_tabulate_hook_e
517
\egroup
518
\egroup
519
\aligntab
520
\noexpand
\dostoptagged
521
\tabl_tabulate_inject_post_skip
{
\the\dimexpr
\s_tabl_tabulate_post
}
% get rid of plus
522
\alignmark\alignmark
523
}
%
524
\toksapp
\t_tabl_tabulate_dummy
{
\NC
}
%
525
\s_tabl_tabulate_pre
.
5
\d_tabl_tabulate_unit
\relax
526
\ifnum
\c_tabl_tabulate_columns
<
\numexpr
\c_tabl_tabulate_nofcolumns
-
\plusone
\relax
527
\s_tabl_tabulate_post
\s_tabl_tabulate_pre
528
\else
529
\s_tabl_tabulate_post
\zeropoint
530
\fi
531
%\let\gettabulateexit\dogettabulateexit % still needed ?
532
\d_tabl_tabulate_width
\zeropoint
}
533 534
\unexpanded
\def
\installtabulatepreambleoption
#
1
#
2
%
535
{
\setvalue
{
\??tabulatepreamble
\string
#
1
}{
#
2
}}
%
536 537
\installtabulatepreambleoption
{
x
}{
\c_tabl_tabulate_align
\zerocount
538
\tabl_tabulate_set_preamble
}
% internal
539
\installtabulatepreambleoption
{
l
}{
\c_tabl_tabulate_align
\plusone
540
\tabl_tabulate_set_preamble
}
541
\installtabulatepreambleoption
{
r
}{
\c_tabl_tabulate_align
\plustwo
542
\tabl_tabulate_set_preamble
}
543
\installtabulatepreambleoption
{
c
}{
\c_tabl_tabulate_align
\plusthree
544
\tabl_tabulate_set_preamble
}
545
\installtabulatepreambleoption
{
p
}{
\tabl_tabulate_set_paragraph
}
546
\installtabulatepreambleoption
{
s
}{
\tabl_tabulate_set_setups
}
547
\installtabulatepreambleoption
{
w
}{
\tabl_tabulate_set_width
}
548
\installtabulatepreambleoption
{
f
}{
\tabl_tabulate_set_font
}
549
\installtabulatepreambleoption
{
B
}{
\t_tabl_tabulate_font
{
\bf
}
%
550
\tabl_tabulate_set_preamble
}
551
\installtabulatepreambleoption
{
I
}{
\t_tabl_tabulate_font
{
\it
}
%
552
\tabl_tabulate_set_preamble
}
553
\installtabulatepreambleoption
{
S
}{
\t_tabl_tabulate_font
{
\sl
}
%
554
\tabl_tabulate_set_preamble
}
555
\installtabulatepreambleoption
{
T
}{
\t_tabl_tabulate_font
{
\tt
}
%
556
\tabl_tabulate_set_preamble
}
557
\installtabulatepreambleoption
{
R
}{
\t_tabl_tabulate_font
{
\rm
}
%
558
\tabl_tabulate_set_preamble
}
559
\installtabulatepreambleoption
{
m
}{
\t_tabl_tabulate_bmath
{
\normalstartimath
}
%
560
\t_tabl_tabulate_emath
{
\normalstopimath
}
%
561
\tabl_tabulate_set_preamble
}
562
\installtabulatepreambleoption
{
M
}{
\t_tabl_tabulate_bmath
{
\normalstartimath
\displaystyle
}
%
563
\t_tabl_tabulate_emath
{
\normalstopimath
}
%
564
\tabl_tabulate_set_preamble
}
565
\installtabulatepreambleoption
{
h
}{
\tabl_tabulate_set_hook
}
566
\installtabulatepreambleoption
{
b
}{
\tabl_tabulate_set_before
}
567
\installtabulatepreambleoption
{
a
}{
\tabl_tabulate_set_after
}
568
\installtabulatepreambleoption
{
i
}{
\tabl_tabulate_set_preskip
}
569
\installtabulatepreambleoption
{
j
}{
\tabl_tabulate_set_posskip
}
570
\installtabulatepreambleoption
{
k
}{
\tabl_tabulate_set_preposskip
}
571
\installtabulatepreambleoption
{
e
}{
\toksapp
\t_tabl_tabulate_settings
{
\global
\settrue
\c_tabl_tabulate_equal
}
%
572
\tabl_tabulate_set_preamble
}
573
\installtabulatepreambleoption
{
g
}{
\tabl_tabulate_set_align
}
574
\installtabulatepreambleoption
{
.
}{
\tabl_tabulate_set_align
.
}
575
\installtabulatepreambleoption
{
,
}{
\tabl_tabulate_set_align
,
}
576
\installtabulatepreambleoption
{
C
}{
\tabl_tabulate_set_color_span
}
577
\installtabulatepreambleoption
{
d
}{
\toksapp
\t_tabl_tabulate_settings
{
\fixedspaces
}
%
578
\tabl_tabulate_set_preamble
}
579
\installtabulatepreambleoption
{
}{
\tabl_tabulate_set_preamble
}
580
\installtabulatepreambleoption
{
A
}{
\tabl_tabulate_set_alignment
}
581 582
%D We no longer deal with \type {~} here but map it onto \type {d} instead. Of
583
%D course we could prefix a key with \type {\meaning} instead, which works ok (and
584
%D is needed in order to pseudo expand \type {\next}, but is ugly at the same time.
585
%D The type {d} stands for digitspace.
586 587
%D \starttyping
588
%D \installtabulatepreambleoption{~}{...} % see 'd'
589
%D \stoptyping
590
%D
591
%D Also, as there is always a key, we no longer do some after assigment or future
592
%D let but just pick up the key.
593 594
% \installtabulatepreambleoption \s!unknown %
595
% {\writestatus{tabulate}{unknown preamble key [\normalmeaning\next]}%
596
% \tabl_tabulate_set_preamble}
597
%
598
% \def\tabl_tabulate_set_preamble
599
% {\afterassignment\dosettabulatepreamble\let\next=}
600
%
601
% \def\dosettabulatepreamble
602
% {\ifx\next\relax \else
603
% \csname\??tabulatepreamble
604
% \ifcsname\??tabulatepreamble\next\endcsname\next\else\s!unknown\fi
605
% \expandafter\endcsname
606
% \fi}
607 608
\installtabulatepreambleoption
\relax
609
{}
% finished
610 611
\def
\tabl_tabulate_set_preamble
#
1
%
612
{
\ifcsname
\??tabulatepreamble
\string
#
1
\endcsname
613
%\expandafter\tabl_tabulate_set_preamble_yes
614
\expandafter\expandafter\expandafter\lastnamedcs\expandafter
\gobbleoneargument
615
\else
616
\expandafter
\tabl_tabulate_set_preamble_nop
617
\fi
{
#
1
}}
618 619
\def
\tabl_tabulate_set_preamble_yes
#
1
%
620
{
\csname
\??tabulatepreamble
\string
#
1
\expandafter\endcsname
}
621 622
\def
\tabl_tabulate_set_preamble_nop
#
1
%
623
{
\writestatus
{
tabulate
}{
unknown
preamble
key
:
#
1
}
%
624
\tabl_tabulate_set_preamble
}
625 626
\def
\tabl_tabulate_set_preskip
#
1
%
627
{
\doifelsenumber
{
#
1
}
%
628
{
\s_tabl_tabulate_pre
#
1
\d_tabl_tabulate_unit
\tabl_tabulate_set_preamble
}
%
629
{
\s_tabl_tabulate_pre
.
5
\d_tabl_tabulate_unit
\tabl_tabulate_set_preamble
#
1
}}
630 631
\def
\tabl_tabulate_set_posskip
#
1
%
632
{
\doifelsenumber
{
#
1
}
%
633
{
\s_tabl_tabulate_post
#
1
\d_tabl_tabulate_unit
\tabl_tabulate_set_preamble
}
%
634
{
\s_tabl_tabulate_post
.
5
\d_tabl_tabulate_unit
\tabl_tabulate_set_preamble
#
1
}}
635 636
\def
\tabl_tabulate_set_preposskip
#
1
%
637
{
\doifelsenumber
{
#
1
}
%
638
{
\s_tabl_tabulate_pre
#
1
\d_tabl_tabulate_unit
\s_tabl_tabulate_post
\s_tabl_tabulate_pre
\tabl_tabulate_set_preamble
}
%
639
{
\s_tabl_tabulate_pre
.
5
\d_tabl_tabulate_unit
\s_tabl_tabulate_post
\s_tabl_tabulate_pre
\tabl_tabulate_set_preamble
#
1
}}
640 641
\def
\tabl_tabulate_set_setups
#
1
%
642
{
\setvalue
{
\??tabulatesetup
\the
\c_tabl_tabulate_columns
}{
\setups
[#
1
]
}
%
643
\tabl_tabulate_set_preamble
}
644 645
\def
\tabl_tabulate_set_hook
#
1
%
646
{
\setvalue
{
\??tabulatehook
\the
\c_tabl_tabulate_columns
}{
#
1
}
%
647
\tabl_tabulate_set_preamble
}
648 649
% begin of character align plugin
650 651
\newconditional
\c_tabl_auto_align_mode
% reset later
652 653
\def
\tabl_tabulate_hook_g
% partly expanded
654
{
\ifconditional
\c_tabl_auto_align_mode
655
\signalcharacteralign
\c_tabl_tabulate_column
{
\c_tabl_tabulate_noflines
+
\plusone
}
%
656
\typo_charalign_adapt_font
657
\fi
}
658 659
\def
\tabl_tabulate_set_align
#
1
%
660
{
\global
\settrue
\c_tabl_auto_align_mode
661
\setcharacteralign
\c_tabl_tabulate_columns
{
#
1
}
%
662
\tabl_tabulate_set_preamble
}
663 664
% end of character align plugin
665 666
\def
\tabl_tabulate_set_before
#
1
%
667
{
\t_tabl_tabulate_before
{
#
1
}
%
668
\tabl_tabulate_set_preamble
}
669 670
\def
\tabl_tabulate_set_after
#
1
%
671
{
\t_tabl_tabulate_after
{
#
1
}
%
672
\tabl_tabulate_set_preamble
}
673 674
\def
\tabl_tabulate_set_font
#
1
%
675
{
\t_tabl_tabulate_font
{
#
1
}
%
676
\tabl_tabulate_set_preamble
}
677 678
\def
\tabl_tabulate_pickup_width
679
{
\doifelsenextparenthesis
\tabl_tabulate_set_width_indeed
\tabl_tabulate_set_preamble
}
680 681
\def
\tabl_tabulate_set_width
682
{
\setfalse
\c_tabl_tabulate_pwidth_set
683
\c_tabl_tabulate_modus
\zerocount
684
\tabl_tabulate_pickup_width
}
685 686
\def
\tabl_tabulate_set_alignment
#
1
%
687
{
\edef
\m_tabl_tabulate_alignment
{
#
1
}
%
688
\spac_align_use_later
\m_tabl_tabulate_alignment
689
\tabl_tabulate_set_preamble
}
690 691
\def
\tabl_tabulate_set_paragraph
692
{
\doifelsenextparenthesis
693
{
\c_tabl_tabulate_modus
\plusone
694
\settrue
\c_tabl_tabulate_pwidth_set
695
\tabl_tabulate_pickup_width
}
696
{
\c_tabl_tabulate_modus
\plustwo
697
\setfalse
\c_tabl_tabulate_pwidth_set
698
\tabl_tabulate_set_preamble
}}
699 700
% \startbuffer
701
% \toplinebox{\framed[width=3cm,height=2cm]{tufte}}
702
% \stopbuffer
703
% \starttabulate[|p(fixed)|p|]
704
% \dorecurse{100}{\NC \getbuffer \NC test \par test \par \NC \NR}
705
% \stoptabulate
706
% \starttabulate[|p(fit)|p|]
707
% \dorecurse{100}{\NC \getbuffer \NC test \par test \par \NC \NR}
708
% \stoptabulate
709 710
\def
\tabl_tabulate_set_width_indeed
(#
1
)
%
711
{
\processallactionsinset
% can be made faster
712
[#
1
]
%
713
[
\v!fit
=>
\c_tabl_tabulate_modus
\plusthree
,
714
\v!fixed
=>
\c_tabl_tabulate_modus
\plusthree
715
\settrue
\c_tabl_tabulate_nopbreak
,
716
\v!auto
=>
\c_tabl_tabulate_modus
\plusthree
717
\settrue
\c_tabl_tabulate_reshape
,
718
\s!unknown
=>
\d_tabl_tabulate_width
#
1
\relax
]
%
719
\ifconditional
\c_tabl_tabulate_pwidth_set
720
\global\advance
\d_tabl_tabulate_width_p
\d_tabl_tabulate_width
% accumulated parwidth
721
\fi
722
\tabl_tabulate_set_preamble
}
723 724
% faster but seldom used
725
%
726
% \installcorenamespace{tabulatewidth}
727
%
728
% \setvalue{\??tabulatewidth\v!fit }{\c_tabl_tabulate_modus\plusthree}
729
% \setvalue{\??tabulatewidth\v!fixed}{\c_tabl_tabulate_modus\plusthree\settrue\c_tabl_tabulate_nopbreak}
730
% \setvalue{\??tabulatewidth\v!auto }{\c_tabl_tabulate_modus\plusthree\settrue\c_tabl_tabulate_reshape}
731
%
732
% \def\tabl_tabulate_set_width_step#1%
733
% {\ifcsname\??tabulatewidth#1\endcsname
734
% \lastnamedcs
735
% \else
736
% \d_tabl_tabulate_width#1\relax
737
% \fi}
738
%
739
% \def\tabl_tabulate_set_width_indeed(#1)%
740
% {\rawprocesscommacommand[#1]\tabl_tabulate_set_width_step
741
% \ifconditional\c_tabl_tabulate_pwidth_set
742
% \global\advance\d_tabl_tabulate_width_p\d_tabl_tabulate_width % accumulated parwidth
743
% \fi
744
% \tabl_tabulate_set_preamble}
745
%
746
\def
\tabl_tabulate_set_raggedright
{
\ifnum
\c_tabl_tabulate_type
=
\plusone
\else
\raggedright
\fi
}
747
\def
\tabl_tabulate_set_raggedcenter
{
\ifnum
\c_tabl_tabulate_type
=
\plusone
\else
\raggedcenter
\fi
}
748
\def
\tabl_tabulate_set_raggedleft
{
\ifnum
\c_tabl_tabulate_type
=
\plusone
\else
\raggedleft
\fi
}
749
\def
\tabl_tabulate_set_notragged
{
\ifnum
\c_tabl_tabulate_type
=
\plusone
\else
\notragged
\fi
}
750
\def
\tabl_tabulate_set_hss
{
\ifnum
\c_tabl_tabulate_type
=
\plusone
\else\hss
\fi
}
% never change this to a fill
751 752
\def
\tabl_tabulate_bskip_raggedright
{
\tabl_tabulate_bskip
\tabl_tabulate_set_raggedright
}
753
\def
\tabl_tabulate_bskip_raggedleft
{
\tabl_tabulate_bskip
\tabl_tabulate_set_raggedleft
}
754
\def
\tabl_tabulate_bskip_raggedcenter
{
\tabl_tabulate_bskip
\tabl_tabulate_set_raggedcenter
}
755 756
\def
\tabl_tabulate_set_width_normal
757
{
\ifcase
\c_tabl_tabulate_align
\relax
758
\tabl_tabulate_set_preamble_step
\empty
\tabl_tabulate_set_hss
\or
759
\tabl_tabulate_set_preamble_step
\empty
\tabl_tabulate_set_hss
\or
760
\tabl_tabulate_set_preamble_step
\tabl_tabulate_set_hss
\empty
\or
761
\tabl_tabulate_set_preamble_step
\tabl_tabulate_set_hss
\tabl_tabulate_set_hss
\fi
}
762 763
\def
\tabl_tabulate_set_width_fixed
764
{
\ifcase
\c_tabl_tabulate_align
\relax
765
\tabl_tabulate_set_preamble_step
\tabl_tabulate_bskip
\tabl_tabulate_eskip
\or
766
\tabl_tabulate_set_preamble_step
\tabl_tabulate_bskip_raggedright
\tabl_tabulate_eskip
\or
767
\tabl_tabulate_set_preamble_step
\tabl_tabulate_bskip_raggedleft
\tabl_tabulate_eskip
\or
768
\tabl_tabulate_set_preamble_step
\tabl_tabulate_bskip_raggedcenter
\tabl_tabulate_eskip
\fi
}
769 770
\def
\tabl_tabulate_set_width_auto
771
{
\global\advance
\c_tabl_tabulate_nofauto
\plusone
772
\ifcase
\c_tabl_tabulate_align
\relax
773
\tabl_tabulate_set_preamble_step
\tabl_tabulate_bskip
\tabl_tabulate_eskip
\or
774
\tabl_tabulate_set_preamble_step
\tabl_tabulate_bskip_raggedright
\tabl_tabulate_eskip
\or
775
\tabl_tabulate_set_preamble_step
\tabl_tabulate_bskip_raggedleft
\tabl_tabulate_eskip
\or
776
\tabl_tabulate_set_preamble_step
\tabl_tabulate_bskip_raggedcenter
\tabl_tabulate_eskip
\fi
}
777 778
\def
\tabl_tabulate_set_width_simple
779
{
\tabl_tabulate_set_preamble_step
\tabl_tabulate_xbskip
\tabl_tabulate_xeskip
}
780 781
% \def\tabl_tabulate_set_color_span#1#2%
782
% {\xdef\m_tabl_tabulate_color{#2}%
783
% \global\c_tabl_tabulate_colorspan\if#1L\plusone\else\if#1M\plustwo\else\if#1R\plusthree\else\zerocount\fi\fi\fi\relax
784
% \tabl_tabulate_set_preamble}
785 786
\installcorenamespace
{
tabulatecolorspec
}
787 788
\setvalue
{
\??tabulatecolorspec
C
}
#
1
{
\xdef
\m_tabl_tabulate_color
{
#
1
}
\global
\c_tabl_tabulate_colorspan
\zerocount
}
789
\setvalue
{
\??tabulatecolorspec
L
}
#
1
{
\xdef
\m_tabl_tabulate_color
{
#
1
}
\global
\c_tabl_tabulate_colorspan
\plusone
}
790
\setvalue
{
\??tabulatecolorspec
M
}
#
1
{
\xdef
\m_tabl_tabulate_color
{
#
1
}
\global
\c_tabl_tabulate_colorspan
\plustwo
}
791
\setvalue
{
\??tabulatecolorspec
R
}
#
1
{
\xdef
\m_tabl_tabulate_color
{
#
1
}
\global
\c_tabl_tabulate_colorspan
\plusthree
}
792
\setvalue
{
\??tabulatecolorspec
T
}
#
1
{
\xdef
\m_tabl_tabulate_text_color
{
#
1
}}
793 794
\def
\tabl_tabulate_set_color_span
#
1
#
2
%
795
{
\csname
\??tabulatecolorspec
#
1
\endcsname
{
#
2
}
%
796
\tabl_tabulate_set_preamble
}
797 798
\def
\tabl_tabulate_set_vrule_command
#
1
%
799
{
\doifelsenumber
{
#
1
}
800
{
\global
\d_tabl_tabulate_vrulethickness
#
1
\d_tabl_tabulate_vrulethickness_default
}
801
{
\xdef
\m_tabl_tabulate_vrule_color
{
#
1
}}}
802 803
\def
\tabl_tabulate_set_entry
#
1
#
2
% rulespec template
804
{
\c_tabl_tabulate_align
\v_tabl_tabulate_align
805
\c_tabl_tabulate_modus
\zerocount
806
\setfalse
\c_tabl_tabulate_pwidth_set
807
\setfalse
\c_tabl_tabulate_reshape
808
\t_tabl_tabulate_before
\emptytoks
809
\t_tabl_tabulate_after
\emptytoks
810
\t_tabl_tabulate_bmath
\emptytoks
811
\t_tabl_tabulate_emath
\emptytoks
812
\t_tabl_tabulate_font
\emptytoks
813
\t_tabl_tabulate_settings
\emptytoks
814
\glet
\m_tabl_tabulate_alignment
\empty
815
\glet
\m_tabl_tabulate_color
\empty
816
\glet
\m_tabl_tabulate_text_color
\empty
817
\glet
\m_tabl_tabulate_vrule_color
\empty
818
\global
\c_tabl_tabulate_colorspan
\zerocount
819
\global
\setfalse
\c_tabl_auto_align_mode
820
\global\advance
\c_tabl_tabulate_columns
\plusone
821
\expandafter\let\csname
\??tabulatesetup
\the
\c_tabl_tabulate_columns
\endcsname
\donothing
% here ?
822
\edef
\currenttabulationtrulespec
{
#
1
}
%
823
\ifempty
\currenttabulationtrulespec
824
\global
\d_tabl_tabulate_vrulethickness
\zeropoint
825
\else
826
\global
\d_tabl_tabulate_vrulethickness
\d_tabl_tabulate_vrulethickness_default
827
\rawprocesscommalist
[#
1
]
\tabl_tabulate_set_vrule_command
828
\fi
829
\tabl_tabulate_set_preamble
#
2
\relax\relax
% permits i without n
830
\ifcase
\c_tabl_tabulate_modus
\relax
831
\tabl_tabulate_set_width_normal
832
\or
% fixed width
833
\tabl_tabulate_set_width_fixed
834
\or
% auto width
835
\tabl_tabulate_set_width_auto
836
\or
% simple
837
\tabl_tabulate_set_width_simple
838
\fi
}
839 840
\def
\tabl_tabulate_set_last_entry
#
1
% rulespec
841
{
\glet
\m_tabl_tabulate_color
\empty
842
\glet
\m_tabl_tabulate_vrule_color
\empty
843
\edef
\currenttabulationtrulespec
{
#
1
}
%
844
\ifempty
\currenttabulationtrulespec
845
\global
\d_tabl_tabulate_vrulethickness
\zeropoint
846
\else
847
\global
\d_tabl_tabulate_vrulethickness
\d_tabl_tabulate_vrulethickness_default
848
\rawprocesscommalist
[#
1
]
\tabl_tabulate_set_vrule_command
849
\fi
850
\etoksapp
\t_tabl_tabulate_preamble
{
%
851
\tabl_tabulate_check_local_vrule_thickness
\constantdimenargument
\d_tabl_tabulate_vrulethickness
852
\tabl_tabulate_check_local_vrule_color
\constantemptyargument
\m_tabl_tabulate_vrule_color
853
\tabl_tabulate_column_vrule_inject
}}
854 855
\let
\settabulateentry
\tabl_tabulate_set_entry
% used at the lua end
856
\let
\settabulatelastentry
\tabl_tabulate_set_last_entry
% used at the lua end
857 858
\def
\tabl_tabulate_normalize_splitline
859
{
\ifcase
\c_tabl_tabulate_splitlinemode
860
% nothing
861
\or
862
\ht
\b_tabl_tabulate
\strutht
863
\dp
\b_tabl_tabulate
\strutdp
864
\or
865
\ifdim
\ht
\b_tabl_tabulate
<
\strutht
866
\ht
\b_tabl_tabulate
\strutht
867
\fi
868
\ifdim
\dp
\b_tabl_tabulate
<
\strutdp
869
\dp
\b_tabl_tabulate
\strutdp
870
\fi
871
\fi
}
872 873
\def
\tabl_tabulate_whitespace
874
{
\ifdim
\d_tabl_tabulate_splitoff_betweenskip
>
\zeropoint
875
\vskip
\d_tabl_tabulate_splitoff_betweenskip
876
\global
\d_tabl_tabulate_splitoff_betweenskip
\zeropoint
877
\fi
}
878 879
\def
\tabl_tabulate_check_whitespace
880
{
\setbox
\scratchbox
\vpack
881
{
\splitdiscards
882
\unskip
883
\ifdim
\lastskip
>
\d_tabl_tabulate_splitoff_betweenskip
884
\global
\d_tabl_tabulate_splitoff_betweenskip
\lastskip
885
\fi
}}
886 887
\installtexdirective
888
{
tabulate
.
linenumbers
}
889
{
\def
\tabl_tabulate_check_linenumbers
{
\page_postprocessors_linenumbers_deepbox
\b_tabl_tabulate
}}
890
{
\let
\tabl_tabulate_check_linenumbers
\relax
}
891 892
\let
\tabl_tabulate_check_linenumbers
\relax
893 894
\def
\tabl_tabulate_splitoff_box
895
{
\dontcomplain
896
\global\setbox
\b_tabl_tabulate
\vsplit
\b_tabl_tabulate_current
\c_tabl_tabulate_column
to
\lineheight
% % % global ? % % %
897
\setbox
\b_tabl_tabulate
\vbox
898
{
\unvbox
\b_tabl_tabulate
}
%
899
\ifconditional
\c_tabl_tabulate_splitoff_whitespace
900
\tabl_tabulate_check_whitespace
901
\fi
902
\tabl_tabulate_color_repeat
% needs to end up in a cell
903
\setbox
\b_tabl_tabulate
\hpack
to
\wd
\b_tabl_tabulate
904
{
\hss
\tabl_tabulate_hook_yes
{
\box
\b_tabl_tabulate
}
\hss
}
%
905
\tabl_tabulate_normalize_splitline
906
\tabl_tabulate_check_linenumbers
907
\box
\b_tabl_tabulate
}
908 909
\unexpanded
\def
\tabl_tabulate_hook_nop
910
{}
911 912
\let
\tabl_tabulate_hook
\tabl_tabulate_hook_nop
913 914
\def
\tabl_tabulate_hook_yes
{
\begincsname
\??tabulatehook
\the
\c_tabl_tabulate_column
\endcsname
}
915 916
\def
\tabl_tabulate_pheight_reset
917
{
\global
\c_tabl_tabulate_plines_min
\plusone
918
\ifdim
\d_tabl_tabulate_height_p_max
>
\zeropoint
919
\getnoflines
\d_tabl_tabulate_height_p_max
920
\global
\c_tabl_tabulate_plines_max
\noflines
921
\else
922
\global
\c_tabl_tabulate_plines_max
\zerocount
923
\fi
924
\global
\d_tabl_tabulate_height_p_max
\zeropoint
}
925 926
\def
\tabl_tabulate_pheight_set
927
{
\scratchdimen
\ht
\b_tabl_tabulate_current
\c_tabl_tabulate_column
\relax
928
\ifdim
\scratchdimen
>
\d_tabl_tabulate_height_p_max
929
\global
\d_tabl_tabulate_height_p_max
\scratchdimen
930
\fi
}
931 932
\def
\tabl_tabulate_pbreak_inject
933
{
\ifconditional
\c_tabl_tabulate_handlepbreak
934
\ifconditional
\c_tabl_tabulate_nopbreak
935
\tabl_tabulate_nobreak_inject
936
\orelse\ifnum
\c_tabl_tabulate_plines_max
>
\plusone
937
\ifnum
\c_tabl_tabulate_plines_min
=
\plusone
938
\tabl_tabulate_nobreak_inject
939
\fi
940
\global\advance
\c_tabl_tabulate_plines_min
\plusone
941
\ifnum
\c_tabl_tabulate_plines_min
=
\c_tabl_tabulate_plines_max
\relax
942
\tabl_tabulate_nobreak_inject
943
\fi
944
\fi
945
\fi
}
946 947
\def
\tabl_tabulate_pbreak_check
948
{
\starttabulatenoalign
949
\tabl_tabulate_pbreak_inject
950
\ifconditional
\c_tabl_tabulate_splitoff_whitespace
951
\tabl_tabulate_whitespace
952
\fi
953
\stoptabulatenoalign
}
954 955
%D \startbuffer
956
%D \starttabulate[|c|p|p|]
957
%D \NC \bf Alpha \NC \bf Beta \NC \bf Gamma \NC\NR
958
%D \NC 1 \NC right indeed \NC definitely wrong \NC\NR
959
%D \NC 2 \NC \thinrules[n=3] \NC \thinrules[n=3] \NC\NR
960
%D \NC 3 \NC oh yes \NC simply no \NC\NR
961
%D \NC 4 \NC very true \NC as false as can be \NC\NR
962
%D \NC 5 \NC \thinrules[n=5] \NC \thinrules[n=5] \NC\NR
963
%D \NC 6 \NC \thinrules[n=3] \NC \thinrules[n=4] \NC\NR
964
%D \stoptabulate
965
%D \stopbuffer
966
%D
967
%D \typebuffer {\tracetabulatetrue\getbuffer}
968
%D
969
%D \startbuffer
970
%D \starttabulate[|c|p|p|]
971
%D \NC \bf Alpha \NC \bf Beta \NC \bf Gamma \NC\NR
972
%D \NC 1 \NC right indeed \NC definitely wrong \NC\NR
973
%D \NC 2 \NC oh yes \NC simply no \NC\NR
974
%D \NC 3 \NC very true \NC as false as can be \NC\NR
975
%D \NC 4 \NC the whole truth \NC but the truth \NC\NR
976
%D \stoptabulate
977
%D \stopbuffer
978
%D
979
%D \typebuffer {\tracetabulatetrue\getbuffer}
980 981
%D Because we want to be compatible we use an indirect way to implement the
982
%D definers. The next examples demonstrate the difference:
983
%D
984
%D \starttyping
985
%D \definetabulate[test][|l|c|r|]
986
%D \definetabulate[test][two][|r|c|l|]
987
%D
988
%D \definetabulation[more][format={|l|c|r|}]
989
%D \definetabulation[more:two][format={|r|c|l|}]
990
%D
991
%D \starttest
992
%D \NC t \NC t \NC t \NC \NR
993
%D \NC te \NC te \NC te \NC \NR
994
%D \NC tes \NC tes \NC tes \NC \NR
995
%D \NC test \NC test \NC test \NC \NR
996
%D \stoptest
997
%D
998
%D \starttest[two]
999
%D \NC t \NC t \NC t \NC \NR
1000
%D \NC te \NC te \NC te \NC \NR
1001
%D \NC tes \NC tes \NC tes \NC \NR
1002
%D \NC test \NC test \NC test \NC \NR
1003
%D \stoptest
1004
%D \startmore
1005
%D \NC t \NC t \NC t \NC \NR
1006
%D \NC te \NC te \NC te \NC \NR
1007
%D \NC tes \NC tes \NC tes \NC \NR
1008
%D \NC test \NC test \NC test \NC \NR
1009
%D \stopmore
1010
%D
1011
%D \startmore[two]
1012
%D \NC t \NC t \NC t \NC \NR
1013
%D \NC te \NC te \NC te \NC \NR
1014
%D \NC tes \NC tes \NC tes \NC \NR
1015
%D \NC test \NC test \NC test \NC \NR
1016
%D \stopmore
1017
%D \stoptyping
1018 1019
\installcorenamespace
{
tabulation
}
1020 1021
\installcommandhandler
\??tabulation
{
tabulation
}
\??tabulation
1022 1023
\setuptabulation
1024
[
\c!unit
=
1
em
,
1025
EQ
=
{
:
}
,
1026
\c!format
=
{
|
l
|
p
|
}
,
1027
\c!frame
=
\v!off
,
1028
%\c!bodyfont=,
1029
\c!rule
=
\v!normal
,
1030
%\c!rulecolor=,
1031
\c!rulethickness
=
\linewidth
,
1032
%\c!inner=,
1033
\c!before
=
\blank
,
1034
\c!after
=
\blank
,
1035
\c!distance
=
{
\v!depth
,
\v!medium
}
,
1036
\c!align
=
\v!normal
,
1037
\c!margin
=
\!!zeropoint
,
1038
\c!split
=
\v!auto
,
1039
\c!header
=
\v!yes
,
1040
%\c!title=,
1041
\c!indenting
=
\v!no
]
1042 1043
\unexpanded
\def
\definetabulate
1044
{
\dotripleempty
\tabl_tabulate_define
}
1045 1046
\def
\tabl_tabulate_define
[#
1
][#
2
][#
3
]
%
1047
{
\ifthirdargument
1048
% [tag] [sub] [template]
1049
\ifcsname
\namedtabulationhash
{
#
1
}
\s!check
\endcsname
\else
1050
\definetabulation
[#
1
][
\c!format
=
{
#
3
}
,
\s!check
=]
%
1051
\fi
1052
\definetabulation
[#
1
:
#
2
][#
1
][
\c!format
=
{
#
3
}
,
\s!check
=]
%
1053
\orelse
\ifsecondargument
1054
% [tag] [template]
1055
\definetabulation
[#
1
][
\c!format
=
{
#
2
}
,
\s!check
=]
%
1056
\else
1057
% [tag]
1058
\definetabulation
[#
1
][
\c!format
=
{
|
l
|
p
|
}
,
\s!check
=]
%
1059
\fi
}
1060 1061
\unexpanded
\def
\setuptabulate
1062
{
\dotripleempty
\tabl_tabulate_setup
}
1063 1064
\def
\tabl_tabulate_setup
[#
1
][#
2
][#
3
]
%
1065
{
\ifthirdargument
1066
% [tag] [sub] [settings]
1067
\setuptabulation
[#
1
:
#
2
][#
3
]
%
1068
\orelse
\ifsecondargument
1069
% [tag] [settings]
1070
\setuptabulation
[#
1
][#
2
]
%
1071
\else
1072
% [tag]
1073
\setuptabulation
[#
1
]
%
1074
\fi
}
1075 1076
\appendtoks
1077
\setuevalue
{
\e!start
\currenttabulation
}{
\tabl_start_defined
[
\currenttabulation
]
}
%
1078
\letvalue
{
\e!stop
\currenttabulation
}
\relax
1079
\letvalue
{
\??tabulatehead
\currenttabulation
}
\empty
1080
\letvalue
{
\??tabulatefoot
\currenttabulation
}
\empty
1081
\to
\everydefinetabulation
1082 1083
\let
\tabulateparameter
\tabulationparameter
% will stay for a while
1084
\def
\currenttabulate
{
\currenttabulation
}
% will stay for a while
1085 1086
% Here begins the implementation.
1087 1088
\let
\tabl_tabulate_insert_head
\empty
1089
\let
\tabl_tabulate_insert_body
\empty
1090
\let
\tabl_tabulate_insert_foot
\empty
1091 1092
\def
\tabl_tabulate_insert_head_content
1093
{
\tabulatenoalign
{
\global
\settrue
\c_tabl_tabulate_someamble
}
%
1094
\begincsname
\??tabulatehead
\currenttabulation
\endcsname
1095
\tabulatenoalign
{
\global
\setfalse
\c_tabl_tabulate_someamble
}}
%
1096 1097
\def
\tabl_tabulate_insert_foot_content
1098
{
\tabulatenoalign
{
\global
\settrue
\c_tabl_tabulate_someamble
}
%
1099
\begincsname
\??tabulatefoot
\currenttabulation
\endcsname
1100
\tabulatenoalign
{
\global
\setfalse
\c_tabl_tabulate_someamble
}}
%
1101 1102
\def
\tabl_tabulate_check_full_content
% - needed, else confusion with \c!header
1103
{
\ifcsname
\??tabulatehead
\currenttabulation
\endcsname
1104
%\expandafter\ifempty\csname\??tabulatehead\currenttabulation\endcsname
1105
\expandafter\ifempty\lastnamedcs
1106
\let
\tabl_tabulate_insert_head
\empty
1107
\else
1108
\let
\tabl_tabulate_insert_head
\tabl_tabulate_insert_head_content
1109
\fi
1110
\else
1111
\let
\tabl_tabulate_insert_head
\empty
1112
\fi
1113
\ifcsname
\??tabulatefoot
\currenttabulation
\endcsname
1114
\expandafter\ifempty\csname
\??tabulatefoot
\currenttabulation
\endcsname
1115
%\expandafter\ifempty\lastnamedcs
1116
\let
\tabl_tabulate_insert_foot
\empty
1117
\else
1118
\let
\tabl_tabulate_insert_foot
\tabl_tabulate_insert_foot_content
1119
\fi
1120
\else
1121
\let
\tabl_tabulate_insert_foot
\empty
1122
\fi
}
1123 1124
\def
\tabl_tabulate_insert_content
1125
{
\tabl_tabulate_insert_head
1126
\ifcase
\c_tabl_tabulate_repeathead
\else
1127
\tabulatenoalign
{
\penalty
\zerocount
}
% added 7/5/2014 WS mail
1128
\fi
1129
\tabl_tabulate_insert_body
1130
\tabl_tabulate_insert_foot
1131
\tabl_tabulate_remove_funny_line
}
1132 1133
\def
\tabl_tabulate_remove_funny_line
1134
{
\ifhmode
1135
\strut
\crcr
1136
\tabulatenoalign
{
\kern
-
\lineheight
}
%
1137
\fi
}
1138 1139
% todo: make footer synonym to tail
1140 1141
\setuvalue
{
\e!start\v!tabulatehead
}{
\doifelsenextoptionalcs
\tabl_tabulate_start_head_yes
\tabl_tabulate_start_head_nop
}
1142
\setuvalue
{
\e!start\v!tabulatetail
}{
\doifelsenextoptionalcs
\tabl_tabulate_start_foot_yes
\tabl_tabulate_start_foot_nop
}
1143 1144
\let
\m_tabl_tabulate_data
\empty
1145 1146
\def
\tabl_tabulate_start_head_yes
[#
1
]
%
1147
{
\processcontent
{
\e!stop\v!tabulatehead
}
\m_tabl_tabulate_data
{
\letvalue
{
\??tabulatehead
#
1
}
\m_tabl_tabulate_data
}}
1148 1149
\def
\tabl_tabulate_start_foot_yes
[#
1
]
%
1150
{
\processcontent
{
\e!stop\v!tabulatetail
}
\m_tabl_tabulate_data
{
\letvalue
{
\??tabulatefoot
#
1
}
\m_tabl_tabulate_data
}}
1151 1152
\def
\tabl_tabulate_start_head_nop
{
\tabl_tabulate_start_head_yes
[
\v!tabulate
]
}
1153
\def
\tabl_tabulate_start_foot_nop
{
\tabl_tabulate_start_foot_yes
[
\v!tabulate
]
}
1154 1155
\unexpanded
\def
\tabl_start_defined
[#
1
]
%
1156
{
\bgroup
1157
\edef
\currenttabulationparent
{
#
1
}
%
1158
\let
\currenttabulation
\currenttabulationparent
1159
\edef
\p_format
{
\tabulationparameter
\c!format
}
%
1160
\ifx
\p_format
\v!none
1161
% this is special case: we need to define the generic english
1162
% \starttabulate in other interfaces as well
1163
\expandafter
\dodoubleempty
\expandafter
\tabl_start_regular
1164
\else
1165
\expandafter
\dodoubleargument
\expandafter
\tabl_start_defined_indeed
1166
\fi
}
1167 1168
\def
\tabl_start_defined_indeed
1169
{
\iffirstargument
1170
\ifsecondargument
1171
\doubleexpandafter
\tabl_start_defined_two
1172
\else
1173
\doubleexpandafter
\tabl_start_defined_one
1174
\fi
1175
\else
1176
\singleexpandafter
\tabl_start_defined_zero
1177
\fi
}
1178 1179
\def
\tabl_start_defined_one
[#
1
][#
2
]
%
1180
{
\ifcondition
\validassignment
{
#
1
}
%
1181
\setuptabulation
[
\currenttabulation
][#
1
]
%
1182
\else
1183
\edef
\currenttabulation
{
\currenttabulation
:
#
1
}
%
1184
\fi
1185
\tabl_tabulate_start_building
}
1186 1187
\def
\tabl_start_defined_two
[#
1
][#
2
]
%
1188
{
\edef
\currenttabulation
{
\currenttabulation
:
#
1
}
%
1189
\setuptabulation
[
\currenttabulation
][#
2
]
%
1190
\tabl_tabulate_start_building
}
1191 1192
\def
\tabl_start_defined_zero
[#
1
][#
2
]
%
1193
{
\tabl_tabulate_start_building
}
1194 1195
% \definetabulate[\v!tabulate][|l|p|] % we need to get rid of this one
1196 1197
\unexpanded\setuvalue
{
\e!start\v!tabulate
}
%
1198
{
\bgroup
% whole thing
1199
\let
\currenttabulationparent
\empty
1200
\dodoubleempty
\tabl_start_regular
}
1201 1202
\def
\tabl_start_regular
1203
{
\let
\currenttabulation
\currenttabulationparent
1204
\ifsecondargument
1205
\expandafter
\tabl_start_regular_two
1206
\else
1207
\expandafter
\tabl_start_regular_one
1208
\fi
}
1209 1210
\def
\tabl_default_format
{
|
l
|
p
|
}
1211 1212
\def
\tabl_start_regular_one
[#
1
][#
2
]
%
1213
{
\ifcondition
\validassignment
{
#
1
}
%
1214
\lettabulationparameter
\c!format
\tabl_default_format
1215
\setupcurrenttabulation
[#
1
]
%
1216
\else
1217
\def
\p_format
{
#
1
}
%
1218
\ifempty
\p_format
1219
\def
\p_format
{
|
l
|
p
|
}
%
1220
\fi
1221
\lettabulationparameter
\c!format
\p_format
1222
\fi
1223
\tabl_tabulate_start_building
}
1224 1225
\def
\tabl_start_regular_two
[#
1
][#
2
]
%
1226
{
\def
\p_format
{
#
1
}
%
1227
\ifempty
\p_format
1228
\let
\p_format
\tabl_default_format
1229
\fi
1230
\lettabulationparameter
\c!format
\p_format
1231
\setupcurrenttabulation
[#
2
]
%
1232
\tabl_tabulate_start_building
}
1233 1234
\letvalue
{
\e!stop\v!tabulate
}
\relax
1235
\letvalue
{
\e!stop\v!tabulatehead
}
\relax
1236
\letvalue
{
\e!stop\v!tabulatetail
}
\relax
1237 1238
\unexpanded
\def
\tabl_tabulate_start_ignore
1239
{
\em
Nested
tabulate
is
not
(
yet
)
supported
.
\relax
1240
\expandafter
\gobbleuntil
\csname
\ifconditional
\c_tabl_generic
stoptabulate
\else
\e!stop\v!tabulate
\fi\endcsname
}
1241 1242
\appendtoks
1243
\letvalue
{
\e!start\v!tabulate
}
\tabl_tabulate_start_ignore
% only the main one
1244
\to
\everytabulate
1245 1246
\setvalue
{
\??tabulatesplit\v!yes
}{
\settrue
\c_tabl_tabulate_split
}
1247
\setvalue
{
\??tabulatesplit\v!repeat
}{
\settrue
\c_tabl_tabulate_split
}
1248
\setvalue
{
\??tabulatesplit\v!no
}{
\setfalse
\c_tabl_tabulate_split
}
1249
\setvalue
{
\??tabulatesplit\v!auto
}{
\ifinsidefloat\ifinsidesplitfloat
\else
\setfalse
\c_tabl_tabulate_split
\fi\fi
}
1250 1251
% todo: spacing around tabulate when bodyfont is set
1252 1253
% \let\tabl_tabulate_inside_before \relax
1254
% \let\tabl_tabulate_inside_after \relax
1255
% \let\tabl_tabulate_inside_inbetween\relax
1256
%
1257
% \def\tabl_tabulate_outside_before
1258
% {\whitespace
1259
% \tabulationparameter\c!before}
1260
%
1261
% \def\tabl_tabulate_outside_after
1262
% {\tabulationparameter\c!after}
1263 1264
% \showboxes
1265
%
1266
% \startcombination
1267
% {\insidefloattrue \starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate} {}
1268
% {\insidefloattrue \starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate} {}
1269
% \stopcombination
1270
%
1271
% \startcombination
1272
% {\vbox{\starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate}} {}
1273
% {\vbox{\starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate}} {}
1274
% \stopcombination
1275
%
1276
% \startcombination
1277
% {\starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate} {}
1278
% {\starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate} {}
1279
% \stopcombination
1280 1281
\let
\tabl_tabulate_inside_after
\relax
1282
\let
\tabl_tabulate_outside_after
\relax
1283
\let
\tabl_tabulate_inside_inbetween
\relax
1284
\let
\tabl_tabulate_outside_inbetween
\relax
1285 1286
\unexpanded
\def
\tabl_tabulate_inside_before
1287
{
\ifhmode
\par\fi
1288
\ifhmode
1289
\ifinsidesplitfloat
1290
\let
\tabl_tabulate_inside_after
\relax
1291
\else
1292
\vbox
\bgroup
1293
\let
\tabl_tabulate_inside_after
\egroup
1294
\fi
1295
\else
1296
\let
\tabl_tabulate_inside_after
\relax
1297
\fi
}
1298 1299
\unexpanded
\def
\tabl_tabulate_outside_before
1300
{
\ifhmode
\par\fi
1301
\ifhmode
1302
\vbox
\bgroup
1303
\let
\tabl_tabulate_outside_after
\egroup
1304
\let
\tabl_tabulate_outside_inbetween
\relax
1305
\orelse\ifinner
1306
\let
\tabl_tabulate_outside_after
\relax
1307
\let
\tabl_tabulate_outside_inbetween
\relax
1308
\else
1309
\whitespace
1310
\tabulationparameter
\c!before
1311
\relax
1312
\let
\tabl_tabulate_outside_after
\tabl_tabulate_outside_after_indeed
1313
\let
\tabl_tabulate_outside_inbetween
\tabl_tabulate_outside_inbetween_indeed
1314
\fi
}
1315 1316
\def
\tabl_tabulate_outside_after_indeed
1317
{
\tabulationparameter
\c!after
}
1318 1319
\def
\tabl_tabulate_outside_inbetween_indeed
1320
{
\doifempty
{
\tabulationparameter
\c!after
}
1321
{
\vskip
\strutdp
1322
\verticalstrut
1323
\vskip
-
\struttotal
}}
1324 1325
\def
\tabl_tabulate_inside_inbetween
% needs checking
1326
{
\doifempty
{
\tabulationparameter
\c!after
}
1327
{
\vskip
\strutdp
1328
\verticalstrut
1329
\vskip
-
\struttotal
}}
1330 1331
\unexpanded
\def
\tabl_tabulate_start_building
1332
{
\ifinsidefloat
1333
\tabl_tabulate_inside_before
1334
\else
1335
\tabl_tabulate_outside_before
1336
\fi
1337
\bgroup
% settings
1338
%
1339
\t_tabl_tabulate_preamble
\emptytoks
1340
\t_tabl_tabulate_dummy
\emptytoks
1341
%
1342
\resetcharacteralign
1343
%
1344
\edef
\p_distance
{
\tabulationparameter
\c!distance
}
%
1345
\edef
\p_align
{
\tabulationparameter
\c!align
}
%
1346
\edef
\p_line
{
\tabulationparameter
\c!rule
}
%
1347
\edef
\p_rulecolor
{
\tabulationparameter
\c!rulecolor
}
%
1348
\edef
\p_rulethickness
{
\tabulationparameter
\c!rulethickness
}
%
1349
\edef
\p_bodyfont
{
\tabulationparameter
\c!bodyfont
}
1350
\edef
\p_indenting
{
\tabulationparameter
\c!indenting
}
%
1351
\edef
\p_keeptogether
{
\tabulationparameter
\c!keeptogether
}
%
1352
\edef
\p_blank
{
\tabulationparameter
\c!blank
}
%
1353
%
1354
\ifx
\p_keeptogether
\v!no
1355
\settrue
\c_tabl_tabulate_tolerant_break
1356
%\setfalse\c_tabl_tabulate_handlepbreak
1357
\else
1358
\setfalse
\c_tabl_tabulate_tolerant_break
1359
%\settrue \c_tabl_tabulate_handlepbreak
1360
\fi
1361
%
1362
\settrue
\c_tabl_tabulate_split
1363
\begincsname
\??tabulatesplit
\tabulationparameter
\c!split
\endcsname
1364
%
1365
\let
\m_tabl_tabulate_blank_default
\p_blank
1366
%
1367
\d_tabl_tabulate_unit
\tabulationparameter
\c!unit
1368
\d_tabl_tabulate_margin
\tabulationparameter
\c!margin
1369
\let
\m_tabl_tabulate_vrule_color_default
\p_rulecolor
1370
\let
\m_tabl_tabulate_hrule_color_default
\p_rulecolor
1371
\d_tabl_tabulate_vrulethickness_default
\p_rulethickness
1372
\d_tabl_tabulate_hrulethickness_default
\p_rulethickness
1373
\ifempty
\p_bodyfont
\else
1374
\switchtobodyfont
[
\p_bodyfont
]
%
1375
\fi
1376
\postponenotes
% new, to be tested / will be configurable
1377
\widowpenalty
\zerocount
% otherwise lines are not broken
1378
\clubpenalty
\zerocount
% but overlap in funny ways
1379
\the
\everytabulate
1380
\tabulationparameter
\c!inner
1381
\d_tabl_tabulate_indent
\dimexpr\leftskip
+
\hangindent\ifx
\p_indenting
\v!yes
+
\parindent\fi\relax
1382
\global
\c_tabl_tabulate_column
\zerocount
1383
\processcontent
1384
{
\ifconditional
\c_tabl_generic
stoptabulate
\else
\e!stop
\ifempty
\currenttabulationparent
\v!tabulate
\else
\currenttabulationparent
\fi\fi
}
1385
\tabl_tabulate_insert_body
1386
\tabl_tabulate_process
}
1387 1388
\def
\tabulateEQ
1389
{
\ifconditional
\c_tabl_tabulate_firstflushed
\else
1390
\dostarttaggedchained
\t!ignore
\empty\empty
1391
\dostarttagged
\t!ignore
\empty
1392
\tabulationparameter
{
EQ
}
%
1393
\dostoptagged
1394
\dostoptagged
1395
\fi
1396
\global
\setfalse
\c_tabl_tabulate_equal
}
1397 1398
% The next ones will be token registers
1399 1400
\let
\tabulatenormalpos
\relax
% hooks, todo
1401
\let
\tabulateequalpos
\relax
% hooks, todo
1402 1403
% color columns
1404 1405
\let
\m_tabl_tabulate_color_previous
\empty
1406
\let
\m_tabl_tabulate_color
\empty
1407
\let
\m_tabl_tabulate_text_color
\empty
1408
\let
\m_tabl_tabulate_color_local
\empty
1409
\let
\m_tabl_tabulate_vrule_color
\empty
1410
\let
\m_tabl_tabulate_vrule_color_local
\empty
1411
\let
\m_tabl_tabulate_vrule_color_default
\empty
% used local
1412
\let
\m_tabl_tabulate_hrule_color_default
\empty
% used local
1413
\let
\m_tabl_tabulate_blank_default
\empty
1414 1415
\appendtoks
1416
\glet
\m_tabl_tabulate_color_previous
\empty
1417
\glet
\m_tabl_tabulate_color
\empty
1418
\glet
\m_tabl_tabulate_text_color
\empty
1419
\glet
\m_tabl_tabulate_color_local
\empty
1420
\glet
\m_tabl_tabulate_vrule_color
\empty
1421
\glet
\m_tabl_tabulate_vrule_color_local
\empty
1422
\global
\d_tabl_tabulate_vrulethickness_local
\zeropoint
1423
\to
\t_tabl_tabulate_every_row
1424 1425
\unexpanded
\def
\tabl_tabulate_color_side_right_second
1426
{
\ifempty
\m_tabl_tabulate_color_previous
\else
1427
\tabl_tabulate_color_set
\m_tabl_tabulate_color_previous
1428
\glet
\m_tabl_tabulate_color_previous
\empty
1429
\fi
}
1430 1431
\unexpanded
\def
\tabl_tabulate_color_side_left_second
1432
{
\ifempty
\m_tabl_tabulate_color
\else
1433
\ifcase
\c_tabl_tabulate_colorspan
1434
\or
1435
\tabl_tabulate_color_set
\m_tabl_tabulate_color
1436
\or
1437
\tabl_tabulate_color_set
\m_tabl_tabulate_color
1438
\fi
1439
\fi
}
1440 1441
\unexpanded
\def
\tabl_tabulate_color_side_both_second
1442
{
\ifempty
\m_tabl_tabulate_color
\else
1443
\tabl_tabulate_color_set
\m_tabl_tabulate_color
1444
\ifcase
\c_tabl_tabulate_colorspan
1445
%\glet\m_tabl_tabulate_color_previous\empty
1446
\or
1447
\glet
\m_tabl_tabulate_color_previous
\empty
1448
\or
1449
\glet
\m_tabl_tabulate_color_previous
\m_tabl_tabulate_color
1450
\or
1451
\glet
\m_tabl_tabulate_color_previous
\m_tabl_tabulate_color
1452
\fi
1453
\fi
}
1454 1455
\let
\tabl_tabulate_color_side_right
\relax
1456
\let
\tabl_tabulate_color_side_left
\relax
1457
\let
\tabl_tabulate_color_side_both
\relax
1458 1459
\appendtoks
1460
\let
\tabl_tabulate_color_side_right
\tabl_tabulate_color_side_right_second
1461
\let
\tabl_tabulate_color_side_left
\tabl_tabulate_color_side_left_second
1462
\let
\tabl_tabulate_color_side_both
\tabl_tabulate_color_side_both_second
1463
\to
\t_tabl_tabulate_initializers_second
1464 1465
\def
\tabl_tabulate_set_color_column
#
1
% overloaded
1466
{
\unskip
1467
\doifelsefastoptionalcheck
{
\tabl_tabulate_set_color_column_yes
#
1
}{
\tabl_tabulate_set_color_column_nop
#
1
}}
1468 1469
\def
\tabl_tabulate_set_color_column_nop
1470
{
\tabl_tabulate_column_normal
\zerocount
}
1471 1472
\def
\tabl_tabulate_set_color_column_yes
#
1
[#
2
]
%
1473
{
\xdef
\m_tabl_tabulate_color_local
{
#
2
}
%
1474
\tabl_tabulate_column_normal
\zerocount
#
1
}
1475 1476
% normal columns:
1477 1478
\def
\tabl_tabulate_column_normal
#
1
#
2
%
1479
{
\unskip
1480
\aligntab
1481
\ifconditional
\c_tabl_tabulate_equal
\tabulateequalpos
\else
\tabulatenormalpos
\fi
1482
\ifnum
\c_tabl_tabulate_column
>
\c_tabl_tabulate_max_vrulecolumn
\else
1483
\tabl_tabulate_column_vrule_setup
1484
\fi
1485
\aligntab
1486
\global
\c_tabl_tabulate_kind
#
1
%
1487
\global
\c_tabl_tabulate_type
#
2
%
1488
\aligntab
}
1489 1490
% equal columns
1491 1492
\def
\tabl_tabulate_column_equal
#
1
#
2
%
1493
{
\unskip
1494
\aligntab
1495
\tabulateequalpos
1496
\aligntab
1497
\global
\c_tabl_tabulate_kind
#
1
%
1498
\global
\c_tabl_tabulate_type
#
2
%
1499
\aligntab
}
1500 1501
% ruled columns
1502 1503
\def
\tabl_tabulate_column_vruled_preset
1504
{
\glet
\m_tabl_tabulate_vrule_color_local
\m_tabl_tabulate_vrule_color_default
1505
\global
\d_tabl_tabulate_vrulethickness_local
\d_tabl_tabulate_vrulethickness_default
}
1506 1507
\def
\tabl_tabulate_column_vruled
#
1
#
2
%
1508
{
\unskip
% 0-n
1509
%\ifnum\c_tabl_tabulate_column=\plusone
1510
% \global\c_tabl_tabulate_has_rule_spec_first\plusone
1511
%\orelse\ifnum\c_tabl_tabulate_column=\c_tabl_tabulate_nofcolumns
1512
% \global\c_tabl_tabulate_has_rule_spec_last\plusone
1513
%\fi
1514
\ifnum
\c_tabl_tabulate_column
>
\c_tabl_tabulate_max_vrulecolumn
1515
\global
\c_tabl_tabulate_max_vrulecolumn
\c_tabl_tabulate_column
1516
\fi
1517
\doifelsefastoptionalcheck
{
\tabl_tabulate_column_vruled_yes
#
1
#
2
}{
\tabl_tabulate_column_vruled_nop
#
1
#
2
}}
1518 1519
\def
\tabl_tabulate_column_vrule_setup
1520
{
\begincsname
\??tabulatevrule
\the
\c_tabl_tabulate_column
\endcsname
}
1521 1522
\def
\tabl_tabulate_column_vruled_nop
1523
{
\expandafter
\glet
\csname
\??tabulatevrule
\the
\c_tabl_tabulate_column
\endcsname
\tabl_tabulate_column_vruled_preset
1524
\tabl_tabulate_column_normal
}
1525 1526
\def
\tabl_tabulate_column_vruled_step
#
1
%
1527
{
\doifelsenumber
{
#
1
}
1528
{
\global
\d_tabl_tabulate_vrulethickness_local
#
1
\d_tabl_tabulate_vrulethickness_default
}
1529
{
\xdef
\m_tabl_tabulate_vrule_color_local
{
#
1
}}}
1530 1531
\def
\tabl_tabulate_column_vruled_yes
#
1
#
2
[#
3
]
%
1532
{
\expandafter\gdef\csname
\??tabulatevrule
\the
\c_tabl_tabulate_column
\endcsname
1533
{
\tabl_tabulate_column_vruled_preset
1534
\rawprocesscommalist
[#
3
]
\tabl_tabulate_column_vruled_step
}
%
1535
\tabl_tabulate_column_normal
#
1
#
2
}
1536 1537
\def
\tabl_tabulate_vrule_reset
1538
{
\ifcase
\c_tabl_tabulate_max_vrulecolumn
\else
1539
\tabl_tabulate_vrule_reset_indeed
1540
\fi
}
1541 1542
\def
\tabl_tabulate_vrule_reset_indeed
1543
{
\dofastloopcs
\c_tabl_tabulate_max_vrulecolumn
\tabl_tabulate_vrule_reset_step
1544
\global
\c_tabl_tabulate_max_vrulecolumn
\zerocount
}
1545 1546
\def
\tabl_tabulate_vrule_reset_step
% undefined or relax
1547
{
\expandafter
\glet
\csname
\??tabulatevrule
\the
\fastloopindex
\endcsname
\undefined
}
1548 1549
\appendtoks
1550
\tabl_tabulate_vrule_reset
1551
\to
\t_tabl_tabulate_every_after_row
1552 1553
% sometimes more efficient:
1554
%
1555
% \def\tabl_tabulate_column_vruled_yes#1#2[#3]%
1556
% {\rawprocesscommalist[#3]\tabl_tabulate_column_vruled_step
1557
% \expandafter\xdef\csname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname
1558
% {\global\d_tabl_tabulate_vrulethickness_local\the\d_tabl_tabulate_vrulethickness_default
1559
% \noexpand\xdef\noexpand\m_tabl_tabulate_vrule_color_local{\m_tabl_tabulate_vrule_color_local}}%
1560
% \tabl_tabulate_column_normal#1#2}
1561 1562
\def
\tabl_tabulate_column_vruled_normal
1563
{
\vrule
\s!width
\d_tabl_tabulate_vrulethickness
\relax
}
1564 1565
\def
\tabl_tabulate_column_vruled_colored
1566
{
\dousecolorparameter
\m_tabl_tabulate_vrule_color
1567
\vrule
\s!width
\d_tabl_tabulate_vrulethickness
\relax
}
1568 1569
\unexpanded
\def
\tabl_tabulate_column_vrule_inject_first
1570
{
\ifcase
\d_tabl_tabulate_vrulethickness
\else
1571
\tabl_tabulate_column_vruled_normal
% could be a skip instead
1572
\fi
1573
\global
\d_tabl_tabulate_vrulethickness
\zeropoint
}
% nils second one
1574 1575
\unexpanded
\def
\tabl_tabulate_column_vrule_inject_second
1576
{
\ifcase
\d_tabl_tabulate_vrulethickness
\else
1577
\ifempty
\m_tabl_tabulate_vrule_color
1578
\tabl_tabulate_column_vruled_normal
1579
\else
1580
\tabl_tabulate_column_vruled_colored
1581
\fi
1582
\fi
1583
\global
\d_tabl_tabulate_vrulethickness
\zeropoint
}
% nils second one
1584 1585
\let
\tabl_tabulate_column_vrule_inject
\relax
1586 1587
\appendtoks
1588
\let
\tabl_tabulate_column_vrule_inject
\tabl_tabulate_column_vrule_inject_first
1589
\to
\t_tabl_tabulate_initializers_first
1590 1591
\appendtoks
1592
\let
\tabl_tabulate_column_vrule_inject
\tabl_tabulate_column_vrule_inject_second
1593
\to
\t_tabl_tabulate_initializers_second
1594 1595
% auto columns
1596 1597
\def
\tabl_tabulate_column_inject_auto
1598
{
\tabl_tabulate_column_normal
\zerocount\zerocount
1599
\ifnum
\c_tabl_tabulate_column
>
\c_tabl_tabulate_columns
\relax
1600
\expandafter
\NR
1601
\else
1602
\expandafter\ignorespaces
% interferes with the more tricky hooks
1603
\fi
}
1604 1605
\unexpanded
\def
\setquicktabulate
#
1
% see \startlegend \startgiven (for the moment still public)
1606
{
\let
#
1
\tabl_tabulate_column_inject_auto
1607
\let
\\
\tabl_tabulate_column_inject_auto
}
% brrr, will go
1608 1609
\setvalue
{
\??tabulateseparator\v!blank
}{
\s_tabl_tabulate_separator
\bigskipamount
}
1610
\setvalue
{
\??tabulateseparator\v!depth
}{
\s_tabl_tabulate_separator
\strutdp
}
1611
\setvalue
{
\??tabulateseparator\v!small
}{
\def
\m_tabl_tabulate_separator_factor
{
.
2
5
}}
1612
\setvalue
{
\??tabulateseparator\v!medium
}{
\def
\m_tabl_tabulate_separator_factor
{
.
5
}}
1613
\setvalue
{
\??tabulateseparator\v!big
}{}
1614
\setvalue
{
\??tabulateseparator\v!none
}{
\s_tabl_tabulate_separator
\zeropoint
\let
\m_tabl_tabulate_separator_factor
\zerocount
}
1615
\setvalue
{
\??tabulateseparator\v!grid
}{
\s_tabl_tabulate_separator
\zeropoint
\let
\m_tabl_tabulate_separator_factor
\zerocount
}
1616 1617
\def
\tabl_tabulate_column_rule_separator_step
#
1
%
1618
{
\ifcsname
\??tabulateseparator
#
1
\endcsname
1619
\lastnamedcs
1620
\else
1621
\s_tabl_tabulate_separator
#
1
\relax
1622
\fi
}
1623 1624
\def
\tabl_tabulate_column_rule_separator_inject
% can be sped up (will do when used frequently)
1625
{
\bgroup
1626
\s_tabl_tabulate_separator
\strutdp
1627
\ifempty
\p_distance
\else
1628
\let
\m_tabl_tabulate_separator_factor
\plusone
1629
\processcommacommand
[
\p_distance
]
\tabl_tabulate_column_rule_separator_step
1630
\s_tabl_tabulate_separator
\m_tabl_tabulate_separator_factor
\s_tabl_tabulate_separator
1631
\fi
1632
% someamble: footer or header: unfortunately a skip can trigger a page break (weird
1633
% as we have lots of nobreaks)
1634
% \ifconditional\c_tabl_tabulate_someamble\kern\else\vskip\fi\s_tabl_tabulate_separator % new
1635
% \directvspacing{\the\s_tabl_tabulate_separator}% new
1636
\directvskip
\s_tabl_tabulate_separator
1637
\egroup
}
1638 1639
\def
\tabl_tabulate_hrule_spec_ignore
#
1
%
1640
{
%\glet\currenttabulationlocalhrulecolor\empty
1641
%\global\d_tabl_tabulate_hrulethickness_local\d_tabl_tabulate_hrulethickness_default
1642
\doifelsefastoptionalcheck
#
1
#
1
}
1643 1644
\def
\tabl_tabulate_hrule_spec_pickup
#
1
%
1645
{
\glet
\currenttabulationlocalhrulecolor
\m_tabl_tabulate_hrule_color_default
1646
\global
\d_tabl_tabulate_hrulethickness_local
\d_tabl_tabulate_hrulethickness_default
1647
\doifelsefastoptionalcheck
{
\tabl_tabulate_hrule_preset
#
1
}
#
1
}
1648 1649
\def
\tabl_tabulate_hrule_preset_step
#
1
%
1650
{
\doifelsenumber
{
#
1
}
1651
{
\global
\d_tabl_tabulate_hrulethickness_local
#
1
\d_tabl_tabulate_hrulethickness_default
}
1652
{
\xdef
\currenttabulationlocalhrulecolor
{
#
1
}}}
1653 1654
\def
\tabl_tabulate_hrule_preset
#
1
[#
2
]
%
1655
{
\rawprocesscommalist
[#
2
]
\tabl_tabulate_hrule_preset_step
1656
#
1
}
1657 1658
\def
\tabl_tabulate_hrule_inject_normal
1659
{
\autorule
1660
\s!height
.
5
\d_tabl_tabulate_hrulethickness_local
1661
\s!depth
.
5
\d_tabl_tabulate_hrulethickness_local
1662
\s!left
\d_tabl_tabulate_indent
1663
\relax
}
1664 1665
\def
\tabl_tabulate_hrule_inject_colored
1666
{
\dousecolorparameter
\currenttabulationlocalhrulecolor
1667
\tabl_tabulate_hrule_inject_normal
}
1668 1669
\unexpanded
\def
\tabl_tabulate_hrule_inject_first
1670
{
\ifcase
\d_tabl_tabulate_hrulethickness_local
\else
1671
\tabl_tabulate_hrule_inject_normal
1672
\fi
}
1673 1674
\unexpanded
\def
\tabl_tabulate_hrule_inject_second
1675
{
\ifcase
\d_tabl_tabulate_hrulethickness_local
\else
1676
\ifempty
\currenttabulationlocalhrulecolor
1677
\tabl_tabulate_hrule_inject_normal
1678
\else
1679
\tabl_tabulate_hrule_inject_colored
1680
\fi
1681
\fi
}
1682 1683
\let
\tabl_tabulate_hrule_inject
\relax
1684 1685
\appendtoks
1686
\let
\tabl_tabulate_hrule_inject
\tabl_tabulate_hrule_inject_first
1687
\to
\t_tabl_tabulate_initializers_first
1688 1689
\appendtoks
1690
\let
\tabl_tabulate_hrule_inject
\tabl_tabulate_hrule_inject_second
1691
\to
\t_tabl_tabulate_initializers_second
1692 1693
%D Color:
1694 1695
% \starttabulate[||p||]
1696
% \NC test \NC test \NC test \NC \NR
1697
% \NC test \CC[green] \input tufte \CC[yellow] test \NC \NR
1698
% \NC test \NC test \NC test \NC \NR
1699
% \NC test \NC test \NC test \NC \NR
1700
% \NC test \NC test \NC test \NC \NR
1701
% \NC test \NC test \NC test \NC \NR
1702
% \CC[blue] test \CC[red] test \NC test \NC \NR
1703
% \NC test \NC test \NC test \NC \NR
1704
% \NC test \NC test \NC test \NC \NR
1705
% \NC test \NC test \NC test \NC \NR
1706
% \NC test \NC test \CC[gray] test \NC \NR
1707
% \NC test \NC test \NC test \NC \NR
1708
% \NC test \NC test \NC test \NC \NR
1709
% \CC[blue] test \NC test \NC test \NC \NR
1710
% \NC test \NC test \NC test \NC \NR
1711
% \NC test \NC test \CC[magenta] test \NC \NR
1712
% \NC test \NC test \NC test \NC \NR
1713
% \NC test \CC[cyan] \dorecurse{10}{\input ward }\NC test \NC \NR
1714
% \NC test \NC test \NC test \NC \NR
1715
% \NC test \CC[yellow] test \NC test \NC \NR
1716
% \stoptabulate
1717 1718
\unexpanded
\def
\tabl_tabulate_color_set
#
1
% we could store the attributes at the cost of a lua call
1719
{
\begingroup
1720
\clf_enablebackgroundalign
% was \node_backgrounds_align_initialize
1721
\glet
\tabl_tabulate_color_repeat
\tabl_tabulate_color_repeat_second
1722
\global
\settrue
\c_tabl_tabulate_has_colors
1723
\ifnum
\c_tabl_tabulate_column
>
\c_tabl_tabulate_max_colorcolumn
1724
\global
\c_tabl_tabulate_max_colorcolumn
\c_tabl_tabulate_column
1725
\fi
1726
\expandafter\xdef\csname
\??tabulatecolor
\the
\c_tabl_tabulate_column
\endcsname
{
#
1
}
%
1727
\hpack
\thealignbackgroundcolorattr
{
#
1
}{}
% pack ?
1728
\endgroup
}
1729 1730
\def
\tabl_tabulate_color_repeat_second
% for split off lines
1731
{
\begingroup
1732
\scratchcounter
\numexpr
\c_tabl_tabulate_column
-
\plusone
\relax
% ugly !
1733
\ifcsname
\??tabulatecolor
\the
\scratchcounter
\endcsname
1734
% \hbox \thealignbackgroundcolorattr{\csname\??tabulatecolor\the\scratchcounter\endcsname}{}% pack ?
1735
\hpack
\expandafter
\thealignbackgroundcolorattr
\expandafter
{
\lastnamedcs
}{}
% pack ?
1736
\fi
1737
\endgroup
}
1738 1739
\let
\tabl_tabulate_color_repeat
\relax
1740 1741
\appendtoks
1742
\let
\tabl_tabulate_color_repeat
\relax
1743
\to
\everytabulate
1744 1745
\def
\tabl_tabulate_color_reset
1746
{
\ifcase
\c_tabl_tabulate_max_colorcolumn
\else
1747
\tabl_tabulate_color_reset_indeed
1748
\fi
}
1749 1750
% \def\tabl_tabulate_color_reset_indeed
1751
% {\dorecurse\c_tabl_tabulate_max_colorcolumn{\letgvalue{\??tabulatecolor\recurselevel}\undefined}} % slow
1752 1753
\def
\tabl_tabulate_color_reset_indeed
1754
{
\dofastloopcs
\c_tabl_tabulate_max_colorcolumn
\tabl_tabulate_color_reset_step
}
1755 1756
\def
\tabl_tabulate_color_reset_step
% undefined or empty?
1757
{
\expandafter
\glet
\csname
\??tabulatecolor
\number
\fastloopindex
\endcsname
\undefined
}
1758 1759
\appendtoks
1760
\tabl_tabulate_color_reset
1761
\to
\t_tabl_tabulate_every_after_row
1762 1763
% \def\tabl_tabulate_register_par_options_indeed
1764
% {\iftrialtypesetting \else
1765
% \registerparoptions
1766
% \ifinsidefloat
1767
% % that is, an unbreakable one
1768
% \glet\tabl_tabulate_register_par_options\empty
1769
% \else
1770
% % unsafe in crossing pages, at each b...
1771
% % \glet\tabl_tabulate_register_par_options\empty
1772
% \fi
1773
% \fi}
1774
%
1775
% \appendtoks
1776
% \glet\tabl_tabulate_register_par_options\tabl_tabulate_register_par_options_indeed
1777
% \to \everytabulate
1778 1779
\def
\tabl_tabulate_register_par_options_first
% maybe track here if needed
1780
{}
1781 1782
\def
\tabl_tabulate_register_par_options_second
1783
{
\registerparoptions
1784
\ifinsidefloat
1785
% that is, an unbreakable one
1786
\glet
\tabl_tabulate_register_par_options
\empty
1787
\else
1788
% unsafe in crossing pages, at each b...
1789
% \glet\tabl_tabulate_register_par_options\empty
1790
\fi
}
1791 1792
\let
\tabl_tabulate_register_par_options
\relax
1793 1794
\appendtoks
1795
\let
\tabl_tabulate_register_par_options
\tabl_tabulate_register_par_options_first
1796
\to
\t_tabl_tabulate_initializers_first
1797 1798
\appendtoks
1799
\let
\tabl_tabulate_register_par_options
\tabl_tabulate_register_par_options_second
1800
\to
\t_tabl_tabulate_initializers_second
1801 1802
\appendtoks
1803
\tabl_tabulate_register_par_options
1804
\to
\t_tabl_tabulate_every_row
1805 1806
\def
\tabl_tabulate_flush_indent_indeed
1807
{
\hbox
to
\d_tabl_tabulate_indent
% pack ?
1808
{
% we now have a local hsize, and since we want to
1809
% register positional info (i.e. real hsizes) we
1810
% need to reconstitute the original hsize
1811
\advance\hsize
\d_tabl_tabulate_indent
1812
% this is indeed rather messy and took a few hours
1813
% to dis/uncover
1814
\the
\t_tabl_tabulate_every_row
1815
\hss
}}
1816 1817
\def
\tabl_tabulate_flush_indent
1818
{
\ifnum
\c_tabl_tabulate_column
=
\zerocount
1819
\tabl_tabulate_flush_indent_indeed
1820
\fi
}
1821 1822
\def
\tabl_tabulate_digits
{
\digits
}
1823 1824
%D Beware, we cannot use \type {\unexpanded} on \type {\HL} cum suis, since \TEX's
1825
%D hard coded noalign lookahead fails on it! I mistakenly added this for a while.
1826 1827
\setvalue
{
\??tabulatealigning\v!normal
}{
0
}
1828
\setvalue
{
\??tabulatealigning\v!right
}{
1
}
1829
\setvalue
{
\??tabulatealigning\v!left
}{
2
}
1830
\setvalue
{
\??tabulatealigning\v!middle
}{
3
}
1831 1832
\setvalue
{
\??tabulateheader\v!repeat
}{
\plusone
}
1833
\setvalue
{
\??tabulateheader\v!text
}{
\plustwo
}
1834 1835
\unexpanded
\def
\tabl_tabulate_bskip_first
{
\setbox
\b_tabl_tabulate
\vbox
\bgroup
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_nop
}
1836
\unexpanded
\def
\tabl_tabulate_eskip_first
{
\par
\egroup
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_yes
}
1837
\unexpanded
\def
\tabl_tabulate_xbskip_first
{
\hpack
\bgroup
\vbox
\bgroup
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_nop
}
1838
\unexpanded
\def
\tabl_tabulate_xeskip_first
{
\par
\egroup\egroup
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_yes
}
1839 1840
\let
\tabl_tabulate_bbskip
\relax
1841
\let
\tabl_tabulate_eeskip
\relax
1842
\let
\tabl_tabulate_bskip
\relax
1843
\let
\tabl_tabulate_eskip
\relax
1844
\let
\tabl_tabulate_xbskip
\relax
1845
\let
\tabl_tabulate_xeskip
\relax
1846 1847
\appendtoks
1848
\let
\tabl_tabulate_bbskip
\relax
1849
%\let\tabl_tabulate_eeskip\relax % adapted by bskip
1850
\let
\tabl_tabulate_bskip
\tabl_tabulate_bskip_first
1851
\let
\tabl_tabulate_eskip
\tabl_tabulate_eskip_first
1852
\let
\tabl_tabulate_xbskip
\tabl_tabulate_xbskip_first
1853
\let
\tabl_tabulate_xeskip
\tabl_tabulate_xeskip_first
1854
\to
\t_tabl_tabulate_initializers_first
1855 1856
\def
\tabl_tabulate_baselinecorrection
% keep an eye on this one
1857
{
\def
\dobaselinecorrection
{
\vskip\dimexpr
-
\prevdepth
+
\strutdp
+
\strutdp
\relax
}
% todo: mkiv
1858
\baselinecorrection
}
1859 1860
% some hack to prevent an allowbreak ... actually we could set up a system then
1861
% that is dealt with atthe lua end in the skip handler: turn penalties with attributes
1862
% values into other penalties that get removed
1863 1864
\installcorenamespace
{
tabulatenobreak
}
1865 1866
\def
\tabl_tabulate_break_allow
{
\directvpenalty
\zerocount
}
1867
\def
\tabl_tabulate_break_maybe
{
\directvpenalty
\zerocount
}
1868
\def
\tabl_tabulate_break_no
{
\directvpenalty
\plustenthousand
}
% ,order:2}}
1869 1870
\let
\tabl_tabulate_break_state_set
\relax
1871
\let
\tabl_tabulate_break_state_reset
\relax
1872
\let
\tabl_tabulate_break_state_allowbreak
\tabl_tabulate_break_maybe
1873 1874
% so far
1875 1876
\unexpanded
\def
\tabl_tabulate_VL_first
{
\tabl_tabulate_column_vruled
\zerocount\zerocount
}
1877
\unexpanded
\def
\tabl_tabulate_NC_first
{
\tabl_tabulate_column_normal
\zerocount\zerocount
}
1878
\unexpanded
\def
\tabl_tabulate_RC_first
{
\tabl_tabulate_column_normal
\zerocount\plusone
}
1879
\unexpanded
\def
\tabl_tabulate_HC_first
{
\tabl_tabulate_column_normal
\zerocount\plustwo
}
1880
\unexpanded
\def
\tabl_tabulate_EQ_first
{
\tabl_tabulate_column_equal
\plustwo
\zerocount
}
1881
\unexpanded
\def
\tabl_tabulate_RQ_first
{
\tabl_tabulate_column_equal
\zerocount\plusone
}
1882
\unexpanded
\def
\tabl_tabulate_HQ_first
{
\tabl_tabulate_column_equal
\zerocount\plustwo
}
1883 1884
\unexpanded
\def
\tabl_tabulate_NG_first
{
\tabl_tabulate_column_normal
\zerocount\zerocount
}
1885
\unexpanded
\def
\tabl_tabulate_NN_first
{
\tabl_tabulate_column_normal
\zerocount\zerocount
\tabl_tabulate_digits
}
% new, undocumented, test first
1886
\unexpanded
\def
\tabl_tabulate_ND_first
{
\tabl_tabulate_column_normal
\zerocount\zerocount
\tabl_tabulate_digits
}
% same, for old times sake
1887 1888
\unexpanded
\def
\tabl_tabulate_NR_first
{
\tabl_tabulate_NR_common
\conditionaltrue
\tabl_tabulate_check_penalties
}
% next row
1889
\unexpanded
\def
\tabl_tabulate_NB_first
{
\tabl_tabulate_NR_common
\conditionaltrue
\tabl_tabulate_nobreak_inject
}
% next row no break
1890 1891
\unexpanded
\def
\tabl_tabulate_NR_second
{
\tabl_tabulate_NR_common
\conditionalfalse
\tabl_tabulate_check_penalties
}
% next row
1892
\unexpanded
\def
\tabl_tabulate_NB_second
{
\tabl_tabulate_NR_common
\conditionalfalse
\tabl_tabulate_nobreak_inject
}
% next row no break
1893 1894
\unexpanded
\def
\tabl_tabulate_CC_first
{
\global
\c_tabl_tabulate_localcolorspan
\zerocount
\tabl_tabulate_set_color_column
\zerocount
}
1895
\unexpanded
\def
\tabl_tabulate_CL_first
{
\global
\c_tabl_tabulate_localcolorspan
\plusone
\tabl_tabulate_set_color_column
\zerocount
}
1896
\unexpanded
\def
\tabl_tabulate_CM_first
{
\global
\c_tabl_tabulate_localcolorspan
\plustwo
\tabl_tabulate_set_color_column
\zerocount
}
1897
\unexpanded
\def
\tabl_tabulate_CR_first
{
\global
\c_tabl_tabulate_localcolorspan
\plusthree
\tabl_tabulate_set_color_column
\zerocount
}
1898 1899
%D Sort of special:
1900
%D
1901
%D \startbuffer
1902
%D \startitemize[n]
1903
%D \starttabulate[|||||]
1904
%D \NC p \NC \itemtag \NC q \NC r \NC \NR
1905
%D \NC p \NC \itemtag \NC q \NC r \NC \NR
1906
%D \NC p \NC \itemtag \NC q \NC r \NC \NR
1907
%D \NC p \NC \itemtag \NC q \NC r \NC \NR
1908
%D \stoptabulate
1909
%D \stopitemize
1910
%D
1911
%D \startitemize[n]
1912
%D \starttabulate[|||||]
1913
%D \NI b \NC c \NC d \NC \NR
1914
%D \NC a \NI c \NC d \NC \NR
1915
%D \NC a \NC b \NI d \NC \NR
1916
%D \NC a \NC b \NC c \NI \NR
1917
%D \stoptabulate
1918
%D \stopitemize
1919
%D \stopbuffer
1920
%D
1921
%D \typebuffer \getbuffer
1922 1923
\unexpanded
\def
\tabl_tabulate_NI_first
{
\doifelsefastoptionalcheck
\tabl_tbl_NI_yes
\tabl_tbl_NI_nop
}
1924 1925
\def
\tabl_tbl_NI_yes
[#
1
]
{
\NC
\itemtag
[#
1
]
\NC
}
1926
\def
\tabl_tbl_NI_nop
{
\NC
\itemtag
\NC
}
1927 1928
%D The following shortcut is handy for tables where one needs bold headers:
1929 1930
\unexpanded
\def
\tabl_tabulate_BC_first
1931
{
\tabl_tabulate_column_normal
\plusone\zerocount
1932
\let
\fontstyle
\globalfontstyle
1933
\bf
}
1934 1935
\appendtoks
1936
\let
\VL
\tabl_tabulate_VL_first
1937
\let
\NC
\tabl_tabulate_NC_first
1938
\let
\BC
\tabl_tabulate_BC_first
1939
\let
\RC
\tabl_tabulate_RC_first
1940
\let
\HC
\tabl_tabulate_HC_first
1941
\let
\EQ
\tabl_tabulate_EQ_first
1942
\let
\RQ
\tabl_tabulate_RQ_first
1943
\let
\HQ
\tabl_tabulate_HQ_first
1944
\let
\NG
\tabl_tabulate_NG_first
1945
\let
\NN
\tabl_tabulate_NN_first
1946
\let
\ND
\tabl_tabulate_ND_first
1947
\let
\NR
\tabl_tabulate_NR_first
1948
\let
\NB
\tabl_tabulate_NB_first
1949
\let
\CC
\tabl_tabulate_CC_first
1950
\let
\CL
\tabl_tabulate_CL_first
1951
\let
\CM
\tabl_tabulate_CM_first
1952
\let
\CR
\tabl_tabulate_CR_first
1953
\let
\NI
\tabl_tabulate_NI_first
1954
\to
\t_tabl_tabulate_initializers_first
1955 1956
\appendtoks
1957
\let
\NR
\tabl_tabulate_NR_second
1958
\let
\NB
\tabl_tabulate_NB_second
1959
\to
\t_tabl_tabulate_initializers_second
1960 1961
\appendtoks
1962
\let
\SR
\NR
1963
\let
\FR
\NR
1964
\let
\MR
\NR
1965
\let
\LR
\NR
1966
\let
\AR
\NR
1967
\to
\t_tabl_tabulate_initializers_first
1968 1969
\unexpanded
\def
\tabl_tabulate_NR_common
#
1
#
2
%
1970
{
\global\advance
\c_tabl_tabulate_noflines
\plusone
1971
\global
\setfalse
\c_tabl_tabulate_firstflushed
1972
\global
\setfalse
\c_tabl_tabulate_equal
1973
\global
\c_tabl_tabulate_column
\zerocount
1974
\ifconditional
#
1
\relax
1975
\tabl_tabulate_break_state_reset
1976
\fi
1977
\tabl_tabulate_pheight_reset
1978
\unskip\unskip\crcr
\tabl_tabulate_flush_collected
1979
% can we omit the next one in the first run? probably
1980
\starttabulatenoalign
1981
\the
\t_tabl_tabulate_every_after_row
1982
#
2
%
1983
\stoptabulatenoalign
}
1984 1985
\def
\tabl_tabulate_check_penalties
1986
{
\ifconditional
\c_tabl_tabulate_tolerant_break
\else
1987
\ifnum
\c_tabl_tabulate_totalnoflines
=
\plusone
1988
% \tabl_tabulate_break_allow
1989
\else
1990
\ifconditional
\c_tabl_tabulate_someamble
\ifcase
\c_tabl_tabulate_repeathead
\else
1991
\tabl_tabulate_break_allow
1992
\fi
\fi
1993
\ifnum
\c_tabl_tabulate_noflines
=
\plusone
1994
\tabl_tabulate_nobreak_inject
1995
\orelse\ifnum
\c_tabl_tabulate_noflines
=
\c_tabl_tabulate_minusnoflines
1996
\ifnum
\c_tabl_tabulate_plines_max
<
\plustwo
1997
\tabl_tabulate_nobreak_inject
1998
\else
1999
\tabl_tabulate_break_allow
% needed with pbreak prevention
2000
\fi
2001
\else
2002
\tabl_tabulate_break_state_allowbreak
2003
\fi
2004
\fi
2005
\fi
2006
\global
\setfalse
\c_tabl_tabulate_firstflushed
}
2007 2008
\unexpanded
\def
\tabl_tabulate_bbskip_second_split_yes
2009
{
\ifvoid
\b_tabl_tabulate_current
\c_tabl_tabulate_column
2010
\ifempty
\tabl_tabulate_flush_collected_indeed
\else
2011
\setbox
0
\hbox
2012
\fi
2013
\fi
}
2014 2015
\unexpanded
\def
\tabl_tabulate_eskip_second
2016
{
\par
\egroup
2017
\tabl_tabulate_pheight_set
2018
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_yes
2019
\tabl_tabulate_splitoff_box
}
2020 2021
\unexpanded
\def
\tabl_tabulate_bskip_second_split_yes
2022
{
\ifvoid
\b_tabl_tabulate_current
\c_tabl_tabulate_column
2023
% first line
2024
\global\setbox
\b_tabl_tabulate_current
\c_tabl_tabulate_column
\vbox
2025
\bgroup
2026
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_nop
2027
\ifconditional
\c_tabl_tabulate_automode
\hsize
\d_tabl_tabulate_width
\fi
2028
% \begstrut % interferes with pre-\pars
2029
% evt: \appendtoks\begstrut\to\everypar
2030
\ignorespaces
2031
\let
\tabl_tabulate_eskip
\tabl_tabulate_eskip_second
2032
\else
2033
% successive lines
2034
\let
\tabl_tabulate_eskip
\empty
2035
\dontcomplain
2036
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_yes
2037
\expandafter
\tabl_tabulate_splitoff_box
2038
\fi
}
2039 2040
\unexpanded
\def
\tabl_tabulate_xbskip_second
{
\tabl_tabulate_bskip
}
2041
\unexpanded
\def
\tabl_tabulate_xeskip_second
{
\tabl_tabulate_eskip
}
2042 2043
\unexpanded
\def
\tabl_tabulate_flush_second_indeed
2044
{
\glet
\tabl_tabulate_flush_collected_indeed
\empty
2045
\global
\c_tabl_tabulate_column
\zerocount
2046
\tabl_tabulate_pbreak_check
2047
\dofastloopcs
\c_tabl_tabulate_columns
\tabl_tabulate_flush_second_step
2048
\global
\settrue
\c_tabl_tabulate_firstflushed
}
2049 2050
\unexpanded
\def
\tabl_tabulate_flush_second_step
2051
{
\ifvoid
\b_tabl_tabulate_current
\fastloopindex
\else
2052
\gdef
\tabl_tabulate_flush_collected_indeed
{
\the
\t_tabl_tabulate_dummy
}
%
2053
\fi
}
2054 2055
\def
\tabl_tabulate_flush_second
2056
{
\tabulatenoalign
{
\tabl_tabulate_flush_second_indeed
}
%
2057
\tabl_tabulate_flush_collected_indeed
}
2058 2059
\unexpanded
\def
\tabl_tabulate_bskip_second_split_nop
2060
{
\vtop
\bgroup
2061
\ifconditional
\c_tabl_tabulate_automode
\hsize
\d_tabl_tabulate_width
\fi
2062
% \begstrut % interferes with pre-\pars
2063
% evt: \appendtoks\begstrut\to\everypar
2064
\ignorespaces
}
2065 2066
\unexpanded
\def
\tabl_tabulate_eskip_second_split_nop
% vertical strut added august 2003
2067
{
\par
\verticalstrut
2068
\vskip
-
\struttotal
2069
\egroup
}
2070 2071
% \let\tabl_tabulate_eskip \relax % adapted by bskip
2072
% \let\tabl_tabulate_eeskip\relax % adapted by bskip
2073 2074
\appendtoks
2075
\let
\tabl_tabulate_xbskip
\tabl_tabulate_xbskip_second
2076
\let
\tabl_tabulate_xeskip
\tabl_tabulate_xeskip_second
2077
\ifconditional
\c_tabl_tabulate_split
2078
\let
\tabl_tabulate_bskip
\tabl_tabulate_bskip_second_split_yes
2079
\let
\tabl_tabulate_bbskip
\tabl_tabulate_bbskip_second_split_yes
2080
\else
2081
\let
\tabl_tabulate_bskip
\tabl_tabulate_bskip_second_split_nop
2082
\let
\tabl_tabulate_eskip
\tabl_tabulate_eskip_second_split_nop
2083
\fi
2084
\to
\t_tabl_tabulate_initializers_second
2085 2086
% see ***
2087
%
2088
% \enabletrackers[nodes.page_vspacing]
2089
% \starttext
2090
% \starttabulate[||] \dorecurse{100}{\NC Eins \NC \NR \HL} \stoptabulate
2091
% \stoptext
2092 2093
\def
\tabl_tabulate_XX_none
2094
{
\starttabulatenoalign
2095
\tabl_tabulate_break_state_set
2096
\tabl_tabulate_hrule_spec_ignore
2097
\stoptabulatenoalign
}
2098 2099
\def
\tabl_tabulate_FL_second
{
\starttabulatenoalign
\tabl_tabulate_hrule_spec_pickup
\tabl_tabulate_FL_second_indeed
}
2100
\def
\tabl_tabulate_ML_second
{
\starttabulatenoalign
\tabl_tabulate_hrule_spec_pickup
\tabl_tabulate_ML_second_indeed
}
2101
\def
\tabl_tabulate_LL_second
{
\starttabulatenoalign
\tabl_tabulate_hrule_spec_pickup
\tabl_tabulate_LL_second_indeed
}
2102
\def
\tabl_tabulate_TL_second
{
\starttabulatenoalign
\tabl_tabulate_hrule_spec_pickup
\tabl_tabulate_TL_second_indeed
}
2103
\def
\tabl_tabulate_BL_second
{
\starttabulatenoalign
\tabl_tabulate_hrule_spec_pickup
\tabl_tabulate_BL_second_indeed
}
2104 2105
\unexpanded
\def
\tabl_tabulate_FL_second_indeed
2106
{
\ifinsidefloat
\else
2107
\doifempty
{
\tabulationparameter
\c!before
}
\tabl_tabulate_baselinecorrection
% no expansion
2108
\fi
2109
\tabl_tabulate_hrule_inject
2110
\tabl_tabulate_nobreak_inject
2111
\tabl_tabulate_column_rule_separator_inject
2112
\prevdepth
\strutdp
2113
\tabl_tabulate_nobreak_inject
2114
\stoptabulatenoalign
}
2115 2116
\def
\spac_vspacing_no_topskip
% use grouped
2117
{
\c_attr_skipcategory
\plusten
}
2118 2119
\unexpanded
\def
\tabl_tabulate_ML_second_indeed
2120
{
\tabl_tabulate_break_no
2121
\tabl_tabulate_column_rule_separator_inject
2122
\tabl_tabulate_break_no
2123
\tabl_tabulate_hrule_inject
2124
\vskip
-
\p_rulethickness
\relax
2125
\begingroup
2126
\spac_vspacing_no_topskip
2127
\tabl_tabulate_hrule_inject
2128
\endgroup
2129
\tabl_tabulate_break_no
2130
\tabl_tabulate_column_rule_separator_inject
2131
\stoptabulatenoalign
}
2132 2133
\unexpanded
\def
\tabl_tabulate_LL_second_indeed
2134
{
\tabl_tabulate_nobreak_inject
2135
\tabl_tabulate_column_rule_separator_inject
2136
\tabl_tabulate_nobreak_inject
2137
\tabl_tabulate_hrule_inject
2138
\ifinsidefloat
2139
\tabl_tabulate_inside_inbetween
2140
\else
2141
\tabl_tabulate_outside_inbetween
2142
\fi
2143
\stoptabulatenoalign
}
2144 2145
\unexpanded
\def
\tabl_tabulate_TL_second_indeed
2146
{
\tabl_tabulate_nobreak_inject
2147
\tabl_tabulate_column_rule_separator_inject
2148
\tabl_tabulate_nobreak_inject
2149
\tabl_tabulate_hrule_inject
2150
\tabl_tabulate_nobreak_inject
2151
\tabl_tabulate_column_rule_separator_inject
2152
%\prevdepth\strutdp % todo, might differ between TL and BL
2153
\tabl_tabulate_nobreak_inject
2154
\stoptabulatenoalign
}
2155 2156
\let
\tabl_tabulate_BL_second_indeed
\tabl_tabulate_TL_second_indeed
2157 2158
\def
\tabl_tabulate_HL_second
2159
{
\csname
2160
\ifnum
\c_tabl_tabulate_noflines
=
\zerocount
F
\orelse
2161
\ifnum
\c_tabl_tabulate_noflines
=
\c_tabl_tabulate_totalnoflines
L
\else
2162
M
\fi
2163
L
\endcsname
}
2164 2165
\appendtoks
2166
\let
\FL
\tabl_tabulate_XX_none
2167
\let
\ML
\tabl_tabulate_XX_none
2168
\let
\LL
\tabl_tabulate_XX_none
2169
\let
\TL
\tabl_tabulate_XX_none
2170
\let
\BL
\tabl_tabulate_XX_none
2171
\let
\HL
\tabl_tabulate_XX_none
2172
\let
\HR
\tabl_tabulate_XX_none
2173
\to
\t_tabl_tabulate_initializers_first
2174 2175
\appendtoks
2176
\let
\FL
\tabl_tabulate_FL_second
2177
\let
\ML
\tabl_tabulate_ML_second
2178
\let
\LL
\tabl_tabulate_LL_second
2179
\let
\TL
\tabl_tabulate_TL_second
2180
\let
\BL
\tabl_tabulate_BL_second
2181
\let
\HL
\tabl_tabulate_HL_second
2182
\let
\HR
\tabl_tabulate_HL_second
2183
\to
\t_tabl_tabulate_initializers_second
2184 2185
% \def\tabulatedoHRfive % horizontal rule line (break untested)
2186
% {\starttabulatenoalign
2187
% \glet\dotabulateautoline\dotabulatelinerule
2188
% %\ifcase#1\or % todo: check what this does
2189
% \ifnum\noftabulatelines=\zerocount
2190
% \glet\dotabulateautoline\donothing
2191
% \else\ifnum\noftabulatelines=\totalnoftabulatelines
2192
% \glet\dotabulateautoline\donothing
2193
% \fi\fi
2194
% %\fi
2195
% \dotabulatenobreak
2196
% \stoptabulatenoalign
2197
% \dotabulateautoline
2198
% \starttabulatenoalign
2199
% \tabl_tabulate_break_no
2200
% \ifx\dotabulateautoline\dotabulatelinerule\kern-\lineheight\fi
2201
% \ifnum\noftabulatelines=\totalnoftabulatelines
2202
% \expandafter\dotabulatenobreak
2203
% \else
2204
% \expandafter\tabl_tabulate_break_allow
2205
% \fi
2206
% \stoptabulatenoalign
2207
% \dotabulateautoline
2208
% \starttabulatenoalign
2209
% \dotabulatenobreak
2210
% \stoptabulatenoalign}
2211 2212
% \dorecurse{10}{
2213
% \starttabulate[|l|]
2214
% \FL
2215
% \NC first line, bound to next rule \NC \NR
2216
% \TL
2217
% \NC bound to previous rule \NC \NR
2218
% \NC some line \NC \NR
2219
% \NC some line \NC \NR
2220
% \NC some line \NC \NR
2221
% \NC bound to next rule \NC \NR
2222
% \ML
2223
% \NC bound to previous rule \NC \NR
2224
% \NC bound to next rule \NC \NR
2225
% \BL
2226
% \NC last line, bound to previous rule \NC \NR
2227
% \LL
2228
% \stoptabulate
2229
% }
2230 2231
% This needs checking:
2232 2233
\def
\tabulaterule
{
\HR
}
% a rule with lineheight
2234
\def
\tabulateline
{
\HL
}
% just a spaced rule
2235
\def
\tabulateautorule
{
\HR
}
%
2236
\def
\tabulateautoline
{
\HL
}
% no longer different (to be looked into)
2237 2238
%D When support for vertical rules we needed a way to pick up the specification for
2239
%D the final rule and a \type {|{}} interface was chosen. As a result parsing had to
2240
%D become more complex and I was not in the mood for messing up the code too much.
2241
%D Therefore from now on the preamble is split by \LUA. There are definitely more
2242
%D places where we can use \LUA\ code (for instance in alignment of numbers. The
2243
%D repeat parser is replace at the \LUA\ end as well.
2244 2245
\let
\tabl_tabulate_flush_collected
\empty
2246
\let
\tabl_tabulate_flush_collected_indeed
\empty
2247 2248
\let
\v_tabl_tabulate_align
\!!zerocount
2249 2250
\def
\tabl_tabulate_check_side_float
% new per 29-07-2016
2251
{
\ifdefined
\page_sides_check_floats_indeed
2252
\page_sides_check_floats_indeed
2253
\ifdim
\hangindent
>
\zeropoint
2254
\advance
\d_tabl_tabulate_indent
\hangindent
2255
\fi
2256
\fi
}
2257 2258
\def
\tabl_tabulate_set_local_hsize
2259
{
\setlocalhsize
2260
\hsize
\localhsize
}
2261 2262
\def
\tabl_tabulate_process
2263
{
\c_tabl_tabulate_pass
\plusone
2264
\tabl_tabulate_check_full_content
2265
\edef
\v_tabl_tabulate_align
{
\ifcsname
\??tabulatealigning
\p_align
\endcsname\lastnamedcs\else
0
\fi
}
%
2266
\s_tabl_tabulate_first
.
5
\d_tabl_tabulate_unit
2267
\s_tabl_tabulate_last
\s_tabl_tabulate_first
2268
\s_tabl_tabulate_pre
\zeropoint
2269
\s_tabl_tabulate_post
\s_tabl_tabulate_first
% was: \zeropoint
2270
\global
\c_tabl_tabulate_columns
\zerocount
2271
\global
\c_tabl_tabulate_nofauto
\zerocount
2272
\global
\c_tabl_tabulate_noflines
\zerocount
2273
\c_tabl_tabulate_totalnoflines
\zerocount
2274
\c_tabl_tabulate_minusnoflines
\zerocount
2275
\global
\d_tabl_tabulate_width_p
\zeropoint
2276
\global
\d_tabl_tabulate_width_w
\zeropoint
2277
\global
\setfalse
\c_tabl_tabulate_equal
2278
\tabl_tabulate_pheight_reset
2279
\tabskip
\zeropoint
2280
\ifinsidesplitfloat
2281
\donetrue
2282
\orelse
\ifinsidefloat
2283
\donefalse
2284
\else
2285
\donetrue
2286
\fi
2287
\global
\c_tabl_tabulate_repeathead
2288
\ifdone
2289
\ifcsname
\??tabulateheader
\tabulationparameter
\c!header
\endcsname
2290
\lastnamedcs
2291
\else
2292
\zerocount
2293
\fi
2294
\else
2295
\zerocount
2296
\fi
2297
%
2298
\the
\t_tabl_tabulate_initializers_first
% collect more here
2299
%
2300
\glet
\tabl_tabulate_flush_collected
\empty
2301
\ifdim
\d_tabl_tabulate_margin
>
\zeropoint
2302
\t_tabl_tabulate_preamble
2303
{
\aligntab
2304
\tabl_tabulate_flush_indent
2305
% \global\advance\c_tabl_tabulate_noflines\plusone
2306
\strut
2307
\alignmark\alignmark
2308
\tabskip
\d_tabl_tabulate_margin
2309
\strut
2310
\aligntab
2311
\alignmark\alignmark
2312
\tabskip
\zeropoint
}
%
2313
\else
2314
\t_tabl_tabulate_preamble
2315
{
\aligntab
2316
\tabl_tabulate_flush_indent
2317
% \global\advance\c_tabl_tabulate_noflines\plusone
2318
\strut
2319
\alignmark\alignmark
2320
\aligntab
2321
\alignmark\alignmark
2322
\tabskip
\zeropoint
}
%
2323
\fi
2324
\d_tabl_tabulate_width
\zeropoint
2325
% these counters are set at the lua end
2326
\c_tabl_tabulate_nofcolumns
\zerocount
2327
\c_tabl_tabulate_has_rule_spec_first
\zerocount
2328
\c_tabl_tabulate_has_rule_spec_last
\zerocount
2329
\clf_presettabulate
{
\detokenizedtabulationparameter
\c!format
}
%
2330
%
2331
% \edef\totaltabulatecolumns{\the\numexpr3*\c_tabl_tabulate_columns+\plusfour}%
2332
\d_tabl_tabulate_width
\zeropoint
2333
\tabl_tabulate_initialize_boxes
\c_tabl_tabulate_columns
2334
\toksapp
\t_tabl_tabulate_preamble
{
%
2335
\aligntab\alignmark\alignmark
2336
\global\advance
\c_tabl_tabulate_column
\plusone
% maybe just set it already
2337
}
%
2338
\toksapp
\t_tabl_tabulate_dummy
{
%
2339
\NC
\unskip\unskip\crcr
\tabl_tabulate_flush_collected
% no count
2340
}
%
2341
\global
\c_tabl_tabulate_column
\zerocount
2342
\tabl_tabulate_pheight_reset
2343
\glet
\tabl_tabulate_hook
\tabl_tabulate_hook_yes
2344
\ifx
\p_indenting
\v!no
2345
\forgetparindent
2346
\fi
2347
\ifinsidefloat
2348
\d_tabl_tabulate_indent
\zeropoint
2349
\else
2350
\tabl_tabulate_check_side_float
2351
\tabl_tabulate_set_local_hsize
2352
\fi
2353
\dontcomplain
2354
\forgetall
% hm, interference with preceding \forgetparindent probably bug, to be solved
2355
\everypar
\everytabulatepar
2356
\setbox
\scratchbox
\vbox
% outside \if because of line counting
2357
{
\notesenabledfalse
2358
\d_tabl_tabulate_indent
\zeropoint
2359
\settrialtypesetting
% very important
2360
\anch_backgrounds_text_level_start
2361
\expandafter\halign\expandafter
{
\the
\t_tabl_tabulate_preamble
\crcr
\tabl_tabulate_insert_content
\crcr
}}
%
2362
\anch_backgrounds_text_level_stop
2363
\ifcase
\c_anch_backgrounds_text_state
\else
2364
\global
\settrue
\tablehaspositions
2365
\fi
2366
\ifnum
\c_tabl_tabulate_nofauto
>
\zerocount
2367
% so, even if the natural size is larger, in the final run, we force the calculated width
2368
\d_tabl_tabulate_width
\dimexpr\hsize
-
\wd
\scratchbox
-
\d_tabl_tabulate_width_p
-
\d_tabl_tabulate_width_w
\relax
2369
\ifnum
\c_tabl_tabulate_nofauto
>
\zerocount
2370
\divide
\d_tabl_tabulate_width
\c_tabl_tabulate_nofauto
\relax
2371
\fi
2372
\fi
2373
\setbox
\scratchbox
\emptybox
% free memory
2374
\ifconditional
\c_tabl_tabulate_split
2375
\splittopskip
\strutht
2376
\glet
\tabl_tabulate_flush_collected_indeed
\empty
2377
\glet
\tabl_tabulate_flush_collected
\tabl_tabulate_flush_second
2378
\fi
2379
\c_tabl_tabulate_totalnoflines
\c_tabl_tabulate_noflines
2380
\c_tabl_tabulate_minusnoflines
\numexpr
\c_tabl_tabulate_noflines
+
\minusone
\relax
2381
\global
\c_tabl_tabulate_noflines
\zerocount
2382
%
2383
\c_tabl_tabulate_pass
\plustwo
% final pass
2384
\the
\t_tabl_tabulate_initializers_second
% collect more here
2385
%
2386
\ifx
\p_line
\v!line
2387
\let
\HL
\HR
2388
\let
\tabulateautoline\tabulateautorule
2389
\let
\tabulateline\tabulaterule
2390
\fi
2391
%
2392
\ifcase
\c_tabl_tabulate_repeathead
2393
\ifinsidesplitfloat
2394
\global\setbox
\b_tabl_tabulate
\vbox
\bgroup
2395
\else
2396
\startframedcontent
[
\tabulationparameter
\c!frame
]
%
2397
\fi
2398
\else
2399
\global\setbox
\b_tabl_tabulate
\vbox
\bgroup
2400
\fi
2401
%
2402
\dostarttaggedchained
\t!tabulate
\empty
\??tabulation
2403
\dostarttagged
\t!tabulaterow
\empty
2404
\setfalse
\inhibitmargindata
% new per 2012.06.13 ... really needed
2405
% \everycr\expandafter{\the\everycr\noalign{\the\t_tabl_tabulate_every_real_row}\dostoptagged\dostarttagged\t!tabulaterow\empty}%
2406
\toksapp\everycr
{
\noalign
{
\the
\t_tabl_tabulate_every_real_row
}
\dostoptagged
\dostarttagged
\t!tabulaterow
\empty
}
%
2407
\expandafter\halign\expandafter
{
\the
\t_tabl_tabulate_preamble
\crcr
\tabl_tabulate_insert_content
\crcr
}
%
2408
\dostoptagged
2409
\dostoptagged
2410
\ifhmode
\par\prevdepth
\strutdp
\fi
% nog eens beter, temporary hack
2411
\ifx
\p_distance
\v!grid
2412
\vskip
-
\strutdp
% experimental tm-prikkels
2413
\fi
2414
%
2415
\ifcase
\c_tabl_tabulate_repeathead
2416
\ifinsidesplitfloat
2417
\egroup
% box
2418
\egroup
% settings
2419
\tabl_split_box
\b_tabl_tabulate
2420
\else
2421
\stopframedcontent
2422
\egroup
2423
\fi
2424
\else
2425
\egroup
% box
2426
\egroup
% settings
2427
\tabl_split_box
\b_tabl_tabulate
2428
\fi
2429
%
2430
\ifinsidefloat
2431
\tabl_tabulate_inside_after
2432
\else
2433
\tabl_tabulate_outside_after
2434
\fi
2435
\egroup
}
% whole thing
2436 2437
% \egroup
2438 2439
% \setuptabulate[split=yes,header=text,title=Vervolg van Tabel]
2440
%
2441
% % \starttabulatehead
2442
% % \NC test \NC hans\NC \NR
2443
% % \stoptabulatehead
2444
%
2445
% \starttabulate
2446
% \NC test \NC \input tufte \relax \NC \NR
2447
% \NC test \NC \input knuth \relax \NC \NR
2448
% \NC test \NC \input knuth \relax \NC \NR
2449
% \NC test \NC \input tufte \relax \NC \NR
2450
% \NC test \NC \input tufte \relax \NC \NR
2451
% \NC test \NC \input tufte \relax \NC \NR
2452
% \stoptabulate
2453 2454
\def
\tabl_split_box
#
1
% #1 <> 0/2 / derived from the one in core-ntb.tex
2455
{
\ifinsidesplitfloat
2456
\tabl_split_box_indeed
#
1
%
2457
\orelse
\ifinsidefloat
2458
\unvbox
#
1
%
2459
\else
2460
\tabl_split_box_indeed
#
1
%
2461
\fi
}
2462 2463
\def
\tabl_split_box_indeed
#
1
%
2464
{
\resettsplit
2465
\def
\tsplitminimumfreelines
{
2
}
%
2466
\def
\tsplitminimumfreespace
{
0
pt
}
%
2467
\setbox
\tsplitcontent
\box
#
1
%
2468
\ifcase
\c_tabl_tabulate_repeathead
\or
2469
\setbox
\tsplithead
\vsplit
\tsplitcontent
to
\lineheight
2470
\setbox
\tsplithead
\vbox
{
\unvbox
\tsplithead
}
%
2471
\or
2472
\setbox
\tsplithead
\vbox
{
\hbox
{
\strut
\tabulationparameter
\c!title
}}
%
2473
\fi
2474
\handletsplit
}
2475 2476
%D \starttyping
2477
%D \setuptabulate[split=no,rule=line]
2478
%D
2479
%D \starttabulate
2480
%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
2481
%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
2482
%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
2483
%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
2484
%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
2485
%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
2486
%D \stoptabulate
2487
%D \stoptyping
2488 2489
%D Spacing:
2490
%
2491
% \starttabulate
2492
% \NC text \NC text \NC \NR
2493
% \TB[small]
2494
% \NC text \NC text \NC \NR
2495
% \TB[4*big]
2496
% \NC text \NC text \NC \NR
2497
% \stoptabulate
2498 2499
\def
\tabl_tabulate_TB
2500
{
\starttabulatenoalign
2501
\dosingleempty
\tabl_tabulate_TB_indeed
}
2502 2503
\def
\tabl_tabulate_TB_indeed
[#
1
]
%
2504
{
\iffirstargument
2505
\blank
[#
1
]
2506
\orelse\ifempty
\m_tabl_tabulate_blank_default
2507
\blank
2508
\else
2509
\blank
[
\m_tabl_tabulate_blank_default
]
%
2510
\fi
2511
\stoptabulatenoalign
}
2512 2513
% to be tested:
2514
%
2515
% \def\tabl_tabulate_TB
2516
% {\starttabulatenoalign
2517
% \doiffastoptionalcheckelse\tabl_tabulate_TB_yes\tabl_tabulate_TB_nop}
2518
%
2519
% \def\tabl_tabulate_TB_yes[#1]%
2520
% {\blank[#1]
2521
% \stoptabulatenoalign}
2522
%
2523
% \def\tabl_tabulate_TB_nop[#1]%
2524
% {\blank
2525
% \stoptabulatenoalign}
2526 2527
\appendtoks
2528
\let
\TB
\tabl_tabulate_TB
2529
\to
\everytabulate
2530 2531
% %D Between alignment lines certain rules apply, and even a simple test can mess
2532
% %D up a table, which is why we have a special test facilityL
2533
% %D
2534
% %D \startbuffer
2535
% %D \starttabulate[|l|p|]
2536
% %D \NC 1test \NC test \NC \NR
2537
% %D \tableifelse{\doifelse{a}{a}}{\NC Xtest \NC test \NC \NR}{}%
2538
% %D \stoptabulate
2539
% %D \stopbuffer
2540
% %D
2541
% %D \typebuffer \getbuffer
2542
%
2543
% \def\tableifelse#1% should be tabulatenoalign then
2544
% {\tablenoalign
2545
% {#1%
2546
% {\aftergroup \firstoftwoarguments}%
2547
% {\aftergroup\secondoftwoarguments}}}
2548
%
2549
% \def\tableiftextelse#1{\tableifelse{\doiftextelse{#1}}}
2550 2551
%D Some new trickery:
2552
%D
2553
%D \startbuffer
2554
%D \settrue\c_tabl_tabulate_splitoff_whitespace
2555
%D
2556
%D \starttabulate[|p(2cm)|p(2cm)|p(2cm)|]
2557
%D \NC test 1a \NC test 2a \NC test 3a
2558
%D \par
2559
%D test 3b \NC \NR
2560
%D \NC test 1a \NC test 2a \NC test 3a
2561
%D \blank[line]
2562
%D test 3b \NC \NR
2563
%D \NC test 1a \NC test 2a \NC test 3a
2564
%D \blank[halfline]
2565
%D test 3b
2566
%D \blank[halfline]
2567
%D test 3c \NC \NR
2568
%D \NC \blank \NC \blank \NC \blank \NC \NR
2569
%D \NC test 1a \NC test 2a \NC test 3a
2570
%D \blank[halfline]
2571
%D test 3b
2572
%D \blank[halfline]
2573
%D test 3c \NC \NR
2574
%D \NC \blank \NC \blank \NC \NC \NR
2575
%D \NC test 1a
2576
%D \par
2577
%D test 1b
2578
%D \par
2579
%D test 1b \NC test 2a
2580
%D \par
2581
%D test 2b
2582
%D \par
2583
%D test 2b \NC test 3a \NC \NR
2584
%D \NC test 1a
2585
%D \blank
2586
%D test 1b
2587
%D \par
2588
%D test 1b \NC test 2a
2589
%D \par
2590
%D test 2b
2591
%D \blank
2592
%D test 2b \NC test 3a \NC \NR
2593
%D \stoptabulate
2594
%D \stopbuffer
2595
%D
2596
%D \typebuffer \start \getbuffer \stop
2597 2598
% \starttabulatie[|mc|]
2599
% \NC \digits{100.000,00} \NC\NR
2600
% \NC \digits{@10.000,00} \NC\NR
2601
% \NC \digits{@@@.100,00} \NC\NR
2602
% \NC \digits{@@@.@10,@@} \NC\NR
2603
% \NC \digits{@@@.@@1,@@} \NC\NR
2604
% \stoptabulatie
2605
%
2606
% \starttabulatie[|mc|]
2607
% \ND 100.000,00 \NC\NR
2608
% \ND @10.000,00 \NC\NR
2609
% \ND @@@.100,00 \NC\NR
2610
% \ND @@@.@10,@@ \NC\NR
2611
% \ND @@@.@@1,@@ \NC\NR
2612
% \stoptabulatie
2613
%
2614
% \starttabulatie[|c|]
2615
% \ND $100.000,00$ \NC\NR
2616
% \ND $@10.000,00$ \NC\NR
2617
% \ND $@@@.100,00$ \NC\NR
2618
% \ND $@@@.@10,@@$ \NC\NR
2619
% \ND $@@@.@@1,@@$ \NC\NR
2620
% \stoptabulatie
2621
%
2622
% \starttabulatie[|c|]
2623
% \NC $\digits 100.000,00 $ \NC\NR
2624
% \NC $\digits @10.000,00 $ \NC\NR
2625
% \NC $\digits @@@.100,00 $ \NC\NR
2626
% \NC $\digits @@@.@10,@@ $ \NC\NR
2627
% \NC $\digits @@@.@@1,@@ $ \NC\NR
2628
% \stoptabulatie
2629
%
2630
% \starttabulatie[|c|]
2631
% \NC \digits $100.000,00$ \NC\NR
2632
% \NC \digits $@10.000,00$ \NC\NR
2633
% \NC \digits $@@@.100,00$ \NC\NR
2634
% \NC \digits $@@@.@10,@@$ \NC\NR
2635
% \NC \digits $@@@.@@1,@@$ \NC\NR
2636
% \stoptabulatie
2637 2638
%D Predefined categories (moved from core-mis):
2639 2640
\definetabulate
2641
[
\v!legend
]
2642
[
|
emj
1
|
i
1
|
mR
|
]
2643 2644
\setuptabulate
2645
[
\v!legend
]
2646
[
\c!unit
=
.
7
5
em
,
\c!inner
=
\setquicktabulate
\leg
,
EQ
=
{
=
}
]
2647 2648
\definetabulate
2649
[
\v!legend
][
\v!two
]
2650
[
|
emj
1
|
emk
1
|
i
1
|
mR
|
]
2651 2652
\definetabulate
2653
[
\v!fact
]
2654
[
|
R
|
ecmj
1
|
i
1
mR
|
]
2655 2656
\setuptabulate
2657
[
\v!fact
]
2658
[
\c!unit
=
.
7
5
em
,
\c!inner
=
\setquicktabulate
\fact
,
EQ
=
{
=
}
]
2659 2660
%D Another example:
2661
%D
2662
%D \starttyping
2663
%D \definetabulate
2664
%D [whatever]
2665
%D [|l|r|]
2666
%D
2667
%D \definetabulate
2668
%D [whatever][else]
2669
%D [|l|c|r|]
2670
%D
2671
%D \startwhatever
2672
%D \NC l \NC r \NC \NR
2673
%D \NC left \NC right \NC \NR
2674
%D \stopwhatever
2675
%D
2676
%D \startwhatever[else]
2677
%D \NC l \NC m \NC r \NC \NR
2678
%D \NC left \NC middle \NC right \NC \NR
2679
%D \stopwhatever
2680
%D
2681
%D \startwhatever[else][format={|c|c|c|c|}]
2682
%D \NC l \NC m \NC m \NC r \NC \NR
2683
%D \NC left \NC middle \NC middle \NC right \NC \NR
2684
%D \stopwhatever
2685
%D \stoptyping
2686 2687
%D This is needed because we sometimes use the english command in tracing macros. In
2688
%D fact, most detailed tracing macros that are done with \LUA\ only work in the
2689
%D english interface anyway.
2690 2691
% \definetabulate[tabulate] \setuptabulate[tabulate][\c!format=\v!none] % so no \v! here
2692 2693
\newconditional
\c_tabl_generic
2694 2695
\unexpanded\setuvalue
{
starttabulate
}
%
2696
{
\bgroup
% whole thing
2697
\settrue
\c_tabl_generic
2698
\let
\currenttabulationparent
\empty
2699
\dodoubleempty
\tabl_start_regular
}
2700 2701
\letvalue
{
stoptabulate
}
\relax
2702 2703
%D The following helpers are just there because we also have them at the \LUA\ end:
2704
%D
2705
%D \startbuffer
2706
%D \starttabulate[|l|c|r|]
2707
%D \tabulaterow {a,b,c}
2708
%D \tabulaterowbold{aa,bb,cc}
2709
%D \tabulaterowtype{aaa,bbb,ccc}
2710
%D \tabulaterowtyp {aaaa,bbbb,cccc}
2711
%D \stoptabulate
2712
%D \stopbuffer
2713
%D
2714
%D \typebuffer \getbuffer
2715 2716
\def
\tabl_tabulate_compact_row
#
1
#
2
%
2717
{
\NC
\tabl_tabulate_compact_step
#
1
#
2
,
\end
,
}
2718 2719
\def
\tabl_tabulate_compact_step
#
1
#
2
#
3
,
%
2720
{
\ifx
#
2
\end
2721
\NR
2722
\expandafter
\gobbleoneargument
2723
\else
2724
#
1
{
#
2
#
3
}
\NC
2725
\expandafter
\tabl_tabulate_compact_step
2726
\fi
#
1
}
2727 2728
\unexpanded
\def
\tabulaterow
{
\tabl_tabulate_compact_row
\relax
}
2729
\unexpanded
\def
\tabulaterowbold
{
\tabl_tabulate_compact_row
\bold
}
2730
\unexpanded
\def
\tabulaterowtype
{
\tabl_tabulate_compact_row
\type
}
2731
\unexpanded
\def
\tabulaterowtyp
{
\tabl_tabulate_compact_row
\typ
}
2732 2733
%D Here we plug in a row background feature. As we only have support for
2734
%D \type {frame=name} we can use these variables.
2735
%D
2736
%D \starttyping
2737
%D \startuseMPgraphic{foo}
2738
%D fill unitsquare
2739
%D xyscaled (RuleWidth,RuleHeight+RuleDepth) enlarged (ExHeight/4,ExHeight/8)
2740
%D randomized ExHeight
2741
%D shifted (-ExHeight/8,ExHeight/16)
2742
%D withcolor RuleColor ;
2743
%D \stopuseMPgraphic
2744
%D
2745
%D \setuptabulate % wel only have frame=name so we can use these:
2746
%D [background=foo,
2747
%D backgroundcolor=darkred,
2748
%D foregroundcolor=white]
2749
%D
2750
%D \definelinefiller[foo][mp=foo,color=darkgreen]
2751
%D \definelinefiller[bar][mp=foo,color=darkred]
2752
%D
2753
%D \starttabulate[|||]
2754
%D \DB foo \BC bar \BC \NR
2755
%D \NC foo \NC bar \NC \NR
2756
%D \NC foo \NC bar \NC \NR
2757
%D \NC foo \NC bar \NC \NR
2758
%D \NC foo \NC bar \NC \NR
2759
%D \stoptabulate
2760
%D
2761
%D \starttabulate[|||]
2762
%D \PB foo \BC bar \BC \NR
2763
%D \NC foo \NC bar \NC \NR
2764
%D \NC foo \NC bar \NC \NR
2765
%D \NC foo \NC bar \NC \NR
2766
%D \NC foo \NC bar \NC \NR
2767
%D \stoptabulate
2768
%D
2769
%D \starttabulate[|||]
2770
%D \FB[bar] foo \BC bar \BC \NR
2771
%D \NC foo \NC bar \NC \NR
2772
%D \NC foo \NC bar \NC \NR
2773
%D \NC foo \NC bar \NC \NR
2774
%D \NC foo \NC bar \NC \NR
2775
%D \stoptabulate
2776
%D
2777
%D \startnarrower
2778
%D \starttabulate[|||]
2779
%D \DB foo \DB bar \BC \NR
2780
%D \NC foo \NC bar \NC \NR
2781
%D \NC foo \NC bar \NC \NR
2782
%D \NC foo \NC bar \NC \NR
2783
%D \NC foo \NC bar \NC \NR
2784
%D \stoptabulate
2785
%D \stopnarrower
2786
%D
2787
%D \starttabulate[|||]
2788
%D \BC foo \BC bar \BC \NR
2789
%D \NL[magenta] foo \NC bar \NC \NR
2790
%D \NL[yellow] foo \NC bar \NC \NR
2791
%D \NL[cyan] foo \NC bar \NC \NR
2792
%D \NL[gray] foo \NC bar \NC \NR
2793
%D \stoptabulate
2794
%D
2795
%D \starttabulate
2796
%D \NL[red] foo \NC bar \NC \NR
2797
%D \NL[green] foo \NL[red] bar \NC \NR
2798
%D \NC foo \NC bar \NC \NR
2799
%D \NL[blue] foo \NC \input tufte \NC \NR
2800
%D \NL[gray] foo \NC bar \NC \NR
2801
%D \NL[yellow] foo \NC bar \NC \NR
2802
%D \stoptabulate
2803
%D \stoptyping
2804 2805
% \setuptabulate
2806
% [\c!background=,
2807
% \c!backgroundcolor=,
2808
% \c!foregroundcolor=,
2809
% \c!foregroundstyle=]
2810 2811
\let
\m_table_current_row_background
\empty
2812
\let
\m_table_current_row_background_default
\empty
2813
\let
\m_table_current_row_background_filler
\empty
2814
\let
\m_table_current_row_background_defaultfiller
\empty
2815
\let
\m_table_current_row_background_auto
\empty
2816 2817
\unexpanded
\def
\tabl_register_row_background
#
1
%
2818
{
\xdef
\m_table_current_row_background
{
#
1
}}
2819 2820
\unexpanded
\def
\tabl_register_row_background_filler
#
1
%
2821
{
\xdef
\m_table_current_row_background_filler
{
#
1
}}
2822 2823
\unexpanded
\def
\tabl_synchronize_row_background
2824
{
\iftrialtypesetting
\else
2825
\ifempty
\m_table_current_row_background_filler
2826
\ifempty
\m_table_current_row_background
2827
% nothing
2828
\tabl_synchronize_row_background_dummy
2829
\else
2830
\tabl_synchronize_row_background_indeed
\m_table_current_row_background
2831
\fi
2832
\else
2833
\tabl_synchronize_row_background_filler_indeed
\m_table_current_row_background_filler
2834
\fi
2835
\fi
}
2836 2837
\unexpanded
\def
\tabl_synchronize_row_background_dummy
2838
{
\iftrialtypesetting
\else
2839
\begingroup
2840
%\clf_setbackgroundrowdata\numexpr\c_tabl_tabulate_nofrealrows+\minusone\relax\zerocount\zeropoint
2841
\clf_setbackgroundrowdata
\c_tabl_tabulate_nofrealrows
\zerocount\zeropoint
2842
\endgroup
2843
\fi
}
2844 2845
\unexpanded
\def
\tabl_synchronize_row_background_indeed
#
1
%
2846
{
\iftrialtypesetting
\else
2847
\begingroup
2848
\clf_enablebackgroundalign
% can be moved into \clf_setbackgroundrowdata
2849
\dousecolorparameter
{
#
1
}
%
2850
\setbox
\scratchbox
\hpack
{}
%
2851
%\clf_setbackgroundrowdata\numexpr\c_tabl_tabulate_nofrealrows+\minusone\relax\scratchbox\d_tabl_tabulate_indent
2852
\clf_setbackgroundrowdata
\c_tabl_tabulate_nofrealrows
\scratchbox
\d_tabl_tabulate_indent
2853
\endgroup
2854
\fi
}
2855 2856
\unexpanded
\def
\tabl_synchronize_row_background_filler_indeed
#
1
%
2857
{
\iftrialtypesetting
\else
2858
\begingroup
2859
\clf_enablebackgroundalign
% can be moved into \clf_setbackgroundrowdata
2860
\node_linefiller_set
{
#
1
}
%
2861
\setbox
\scratchbox
\hpack
{}
%
2862
%\clf_setbackgroundrowdata\numexpr\c_tabl_tabulate_nofrealrows+\minusone\relax\scratchbox\d_tabl_tabulate_indent
2863
\clf_setbackgroundrowdata
\c_tabl_tabulate_nofrealrows
\scratchbox
\d_tabl_tabulate_indent
2864
\endgroup
2865
\fi
}
2866 2867
\appendtoks
2868
\glet
\m_table_current_row_background
\empty
2869
\glet
\m_table_current_row_background_filler
\empty
2870
\global
\c_tabl_tabulate_nofrealrows
\zerocount
2871
\global
\c_tabl_tabulate_autocolor
\zerocount
2872
\clf_resetbackgroundrowdata
2873
\to
\t_tabl_tabulate_initializers_first
2874 2875
\appendtoks
2876
\glet
\m_table_current_row_background
\empty
2877
\glet
\m_table_current_row_background_filler
\empty
2878
\global
\c_tabl_tabulate_nofrealrows
\zerocount
2879
\global
\c_tabl_tabulate_autocolor
\zerocount
2880
\clf_resetbackgroundrowdata
2881
\to
\t_tabl_tabulate_initializers_second
2882 2883
\appendtoks
2884
\tabl_synchronize_row_background
2885
\to
\t_tabl_tabulate_every_real_row
2886 2887
\appendtoks
2888
\glet
\m_table_current_row_background
\empty
2889
\glet
\m_table_current_row_background_filler
\empty
2890
\to
\t_tabl_tabulate_every_after_row
2891 2892
\unexpanded
\def
\tabl_tabulate_NL_first
[#
1
]
%
2893
{
\tabl_tabulate_column_normal
\zerocount\zerocount
\relax
2894
\ifcase
\c_tabl_tabulate_column
\or
2895
\tabl_register_row_background
{
#
1
}
%
2896
\fi
2897
\ignorespaces
}
2898 2899
\unexpanded
\def
\tabl_tabulate_ND_first
2900
{
\tabl_tabulate_column_normal
\zerocount\zerocount
\relax
2901
\ifcase
\c_tabl_tabulate_column
\or
2902
\tabl_register_row_background
\m_table_current_row_background_default
2903
\fi
2904
\ignorespaces
}
2905 2906
\unexpanded
\def
\tabl_tabulate_LB_first
[#
1
]
%
2907
{
\tabl_tabulate_column_normal
\plusone\zerocount
\relax
2908
\ifcase
\c_tabl_tabulate_column
\or
2909
\tabl_register_row_background
{
#
1
}
%
2910
\fi
2911
\usetabulationstyleandcolor
\c!foregroundstyle\c!foregroundcolor
2912
\ignorespaces
}
2913 2914
\unexpanded
\def
\tabl_tabulate_DB_first
2915
{
\tabl_tabulate_column_normal
\plusone\zerocount
\relax
2916
\ifcase
\c_tabl_tabulate_column
\or
2917
\tabl_register_row_background
\m_table_current_row_background_default
2918
\fi
2919
\let
\fontstyle
\globalfontstyle
2920
\usetabulationstyleandcolor
\c!foregroundstyle\c!foregroundcolor
2921
\ignorespaces
}
2922 2923
\unexpanded
\def
\tabl_tabulate_NF_first
[#
1
]
%
2924
{
\tabl_tabulate_column_normal
\zerocount\zerocount
\relax
2925
\ifcase
\c_tabl_tabulate_column
\or
2926
\tabl_register_row_background_filler
{
#
1
}
%
2927
\fi
2928
\ignorespaces
}
2929 2930
\unexpanded
\def
\tabl_tabulate_NP_first
2931
{
\tabl_tabulate_column_normal
\zerocount\zerocount
\relax
2932
\ifcase
\c_tabl_tabulate_column
\or
2933
\tabl_register_row_background_filler
\m_table_current_row_background_default_filler
2934
\fi
2935
\ignorespaces
}
2936 2937
\unexpanded
\def
\tabl_tabulate_FB_first
[#
1
]
%
2938
{
\tabl_tabulate_column_normal
\plusone\zerocount
\relax
2939
\ifcase
\c_tabl_tabulate_column
\or
2940
\tabl_register_row_background_filler
{
#
1
}
%
2941
\fi
2942
\usetabulationstyleandcolor
\c!foregroundstyle\c!foregroundcolor
2943
\ignorespaces
}
2944 2945
\unexpanded
\def
\tabl_tabulate_PB_first
2946
{
\tabl_tabulate_column_normal
\plusone\zerocount
\relax
2947
\ifcase
\c_tabl_tabulate_column
\or
2948
\tabl_register_row_background_filler
\m_table_current_row_background_default_filler
2949
\fi
2950
\let
\fontstyle
\globalfontstyle
2951
\usetabulationstyleandcolor
\c!foregroundstyle\c!foregroundcolor
2952
\ignorespaces
}
2953 2954
\unexpanded
\def
\tabl_tabulate_BC_first
% overloaded
2955
{
\tabl_tabulate_column_normal
\plusone\zerocount
2956
\let
\fontstyle
\globalfontstyle
2957
\ifempty
\m_table_current_row_background
2958
\ifempty
\m_table_current_row_background_filler
2959
\usetabulationstyleandcolor
\c!headstyle\c!headcolor
2960
\else
2961
\usetabulationstyleandcolor
\c!foregroundstyle\c!foregroundcolor
2962
\fi
2963
\else
2964
\usetabulationstyleandcolor
\c!foregroundstyle\c!foregroundcolor
2965
\fi
}
2966 2967
\unexpanded
\def
\tabl_tabulate_A_first
2968
{
\global\advance
\c_tabl_tabulate_autocolor
\plusone
2969
\edef
\m_table_current_row_background_auto
{
\tabulateparameter
{
\c!backgroundcolor
:
\number
\c_tabl_tabulate_autocolor
}}
%
2970
\ifempty
\m_table_current_row_background_auto
2971
\global
\c_tabl_tabulate_autocolor
\plusone
2972
\edef
\m_table_current_row_background_auto
{
\tabulateparameter
{
\c!backgroundcolor
:
\number
\c_tabl_tabulate_autocolor
}}
%
2973
\fi
2974
\ifempty
\m_table_current_row_background_auto
2975
\let
\m_table_current_row_background_auto
\empty
% \m_table_current_row_background_default
2976
\fi
2977
\tabl_register_row_background
{
\m_table_current_row_background_auto
}}
2978 2979
\unexpanded
\def
\tabl_tabulate_NA_first
2980
{
\tabl_tabulate_column_normal
\zerocount\zerocount
\relax
2981
\iftrialtypesetting
\else
2982
\ifcase
\c_tabl_tabulate_column
\or
2983
\tabl_tabulate_A_first
2984
\fi
2985
\fi
2986
\ignorespaces
}
2987 2988
\unexpanded
\def
\tabl_tabulate_BA_first
2989
{
\tabl_tabulate_column_normal
\plusone\zerocount
\relax
2990
\iftrialtypesetting
\else
2991
\ifcase
\c_tabl_tabulate_column
\or
2992
\tabl_tabulate_A_first
2993
\fi
2994
\fi
2995
\usetabulationstyleandcolor
\c!foregroundstyle\c!foregroundcolor
2996
\ignorespaces
}
2997 2998
\appendtoks
2999
\let
\NL
\tabl_tabulate_NL_first
% NC with Line
3000
\let
\ND
\tabl_tabulate_ND_first
% NC with Default Line
3001
\let
\LB
\tabl_tabulate_LB_first
% BC with Line
3002
\let
\DB
\tabl_tabulate_DB_first
% BC with Default Line
3003
\let
\NF
\tabl_tabulate_NF_first
% NC with Filler
3004
\let
\NP
\tabl_tabulate_NP_first
% NC with Predefined Filler
3005
\let
\FB
\tabl_tabulate_FB_first
% BC with Filler
3006
\let
\PB
\tabl_tabulate_PB_first
% BC with Predefined Filler
3007
\let
\NA
\tabl_tabulate_NA_first
% NC with Auto Line
3008
\let
\BA
\tabl_tabulate_BA_first
% NC with Auto Line
3009
\to
\t_tabl_tabulate_initializers_first
3010 3011
\appendtoks
3012
\edef
\m_table_current_row_background_default
{
\tabulateparameter
\c!backgroundcolor
}
%
3013
\edef
\m_table_current_row_background_default_filler
{
\tabulateparameter
\c!background
}
%
3014
\let
\m_table_current_row_background_auto
\empty
3015
\to
\everytabulate
3016 3017
\setuptabulate
3018
[
\c!headcolor
=
,
3019
\c!headstyle
=
\bf
,
3020
\c!backgroundcolor
=
\tabulationparameter
\c!rulecolor
,
3021
\c!foregroundcolor
=
,
3022
\c!foregroundstyle
=
\tabulationparameter
\c!headstyle
]
3023 3024
\protect
\endinput
3025