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