summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/context/manuals/reference/en/co-tables.tex
blob: 9c6e676ab42fcf11abebd8442ab04d89584d7fc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272

\startcomponent co-tables

\environment contextref-env
\product contextref

\start

\unprotect
\def\exampletable
  {\bgroup
   \getvalue{\e!start\v!figure\e!text}[\v!left,\v!none][]{}{\getbuffer}
   \setupwhitespace[\v!none]
   \setuptyping[\c!before=,\c!after=]
   \typebuffer
   \getvalue{\e!stop\v!figure\e!text}
   \egroup}
\protect



\setuptables
  [VL=medium,
   HL=medium]

\chapter[tables]{Tables}

\section{Introduction}

In \CONTEXT\ there are two methods of making tables. The
method chosen depends on the fact if the table is a
component of the running text or the complexity of the
table.

Originally \CONTEXT\ had only one table alternative based on
the flexible, robust and complete macropackage \TABLE. We
added some functionality to that macropackages on behalf of
spacing, color and table splitting. This alternative is very
powerful with table cells with little text.

As soon as you want to typeset complete paragraphs in a table
cell the alternative is inadequate because the width of the
cells have to be set manually. Therefore we added the
tabulation alternative. Tabulation is not that advanced yet
but it is able to automatically divide the available
width of the cells. Cells can be filled with complete
paragraphs and the tabulation environment has no problems
with pagebreaks.

Both the table and the tabulation environment are discussed
in this chapter. Because the definition of tables and
tabulations differ not much they can be converted easily into
each other. Many examples apply to both environments.

\section{Tables}
\index{tables}
\macro{\tex{starttable}}
\macro{\tex{starttables}}
\macro{\tex{setuptables}}
\macro{\tex{placetable}}
\macro{\tex{FR}}
\macro{\tex{LR}}
\macro{\tex{MR}}
\macro{\tex{SR}}
\macro{\tex{NR}}
\macro{\tex{AR}}
\macro{\tex{NC}}
\macro{\tex{FC}}
\macro{\tex{MC}}
\macro{\tex{LC}}
\macro{\tex{LOW}}
\macro{\tex{HL}}
\macro{\tex{VL}}
\macro{\tex{DL}}
\macro{\tex{DC}}
\macro{\tex{DR}}
\macro{\tex{BL}}
\macro{\tex{BC}}
\macro{\tex{BR}}
\macro{\tex{CL}}
\macro{\tex{RL}}

In (plain) \TEX\ there are a few options to construct
tables, for example:

\startbuffer
\settabs 5\columns
\+ The  & quick & brown & fox & jumps \cr
\+ over & the   & lazy  & dog & !     \cr
\stopbuffer

\startexample
\typebuffer
\stopexample

or:

\whitespace

\startreality
\getbuffer
\stopreality

These kind of commands are based on the \type {\halign}
mechanism. In most macropackages tables are developed around
this mechanism. In \CONTEXT\ we use the functionality of
\TABLE\ by M.~Wichura. Although this macropackage is
complete we decided to write a shell around this package.
The most important reason was that we wanted to force users
to work with a consistent spacing within tables without loss
of the \TABLE\ functionality.\footnote {\TABLE\ commands are
described in a seperate manual.}

In due time we will develop a more flexible mechanism that
is compatible with \TABLE\ and in which \METAPOST\
functionality is integrated.

\placetable
  [here][tab:population]
  {Growth of population.}
\starttable[|l|l|]
\HL
\VL \bf year \VL \bf population \VL\SR
\HL
\VL 1500     \VL 0.90 \`a 1.00 million  \VL\FR
\VL 1550     \VL 1.20 \`a 1.30 million  \VL\MR
\VL 1600     \VL 1.40 \`a 1.60 million  \VL\MR
\VL 1650     \VL 1.85 \`a 1.90 million  \VL\MR
\VL 1670     \VL 0.95 million           \VL\MR
\VL 1700     \VL 1.85 \`a 1.95 million  \VL\MR
\VL 1730     \VL 2.12 million           \VL\MR
\VL 1750     \VL 1.90 \`a 1.95 million  \VL\MR
\VL 1770     \VL 2.11 million           \VL\MR
\VL 1800     \VL 2.08 million           \VL\MR
\VL 1820     \VL 2.20 million           \VL\LR
\HL
\stoptable

We begin with an example of a very simple table in normal
\TABLE\ coding. The table identified as als \in {table}
[tab:population] was defined as follows:

\starttyping
\BeginTable
\BeginFormat | l | l | \EndFormat
\_
| \bf year | \bf population | \\+22
\_
| 1500     | 0.90 \`a 1.00 million  | \\+20
| 1550     | 1.20 \`a 1.30 million  | \\+00
. ....     . ...................  . .....
| 1800     | 2.08 million         | \\+00
| 1820     | 2.20 million         | \\+02
\_
\EndTable
\stoptyping

We don't consider this as a transparent way of coding a
table. Furthermore consistent spacing is far off since the
user can alter every interline space at will. As most
commands in \CONTEXT\ we enclose a table with \type
{\start}||\type{\stop}||commands. These commands are used in
stead of the \TABLE\ commands \type {\BeginTable}, \type
{\EndTable}, \type {\BeginFormat} and \type {\EndFormat}.

\showsetup{starttable}

Between \setchars\ the column format is defined. Because
\setchars\ may be used within the table definition
\setchars\ other variations are possible:

\starttyping
\starttable[|l|l|]
\starttable[{|l|l|}]
\starttable{|l|l|}
\stoptyping

In \in {section} [plaatsblokken] we saw that the command
\type {\placetable} gets a table as a last argument. When
the command is used the way it is defined above, you will
not need the curly braces around the table.

Spacing deserves somewhat more attention. Below the
definition of the \in {table} [tab:population] is
given.\footnote {Source: Delta 2, Nederlands verleden in
vogelvlucht, de nieuwe tijd: 1500 tot 1813, S.~Groenveld and
G.J.~Schutte, Martinus Nijhoff Uitgevers, Leiden, 1992.}
More advanced examples can be found in the \TABLE\ manual.

\startexample
\starttyping
\placetable
  [here][tab:population]
  {Growth of population.}
  \starttable[|l|l|]
    \HL
    \VL \bf year \VL \bf population \VL\SR
    \HL
    \VL 1500     \VL 0.90 \`a 1.00 million  \VL\FR
    \VL 1550     \VL 1.20 \`a 1.30 million  \VL\MR
    ... ....     ... ...................    ......
    \VL 1800     \VL 2.08 million           \VL\MR
    \VL 1820     \VL 2.20 million           \VL\LR
    \HL
  \stoptable
\stoptyping
\stopexample

In the \CONTEXT\ interface for table definition \type {\HL}
and \type {\VL} stand for Horizontal Line and Vertical Line.
The other commands stand for Separate Row, First Row, Mid
Row and Last Row.

These commands can be compared with the active \TABLE\
characters \type {|} and \type {"}, the spacing command
\type {\\} and the line command \type {\-}.

When keys like \type {s0} are used in the table
specification we have to use spaces in the specification.
For example:

\starttyping
\starttable[s0 |l|l|]
\stoptyping

In that case we use a space to end the number. We give some
more examples below. When a table is not framed by (\type
{\VL}), we may have to suppress undesired whitespace. The
background of the tables illustrates the effect of the
different location of \type {s0}.

\start

\setupfloat[figure][background=screen]

\startbuffer
\starttable[|l|l|]
\NC first  \NC second \NC \SR
\HL
\NC alfa   \NC beta   \NC \FR
\NC one    \NC two    \NC \LR
\stoptable
\stopbuffer

\exampletable

\startbuffer
\starttable[s0 | c s1 | c s0 |]
\NC first  \NC second \NC \SR
\HL
\NC alfa   \NC beta   \NC \FR
\NC one    \NC two    \NC \LR
\stoptable
\stopbuffer

\exampletable

\startbuffer
\starttable[o0 | c | c o0 |]
\NC first  \NC second \NC \SR
\HL
\NC alfa   \NC beta   \NC \FR
\NC one    \NC two    \NC \LR
\stoptable
\stopbuffer

\exampletable

\stop

We may want to typeset tables like these:

\startbuffer
\starttable[ s0 | l w(6cm) | r s0 | l | ]
\NC first weight (full can)   \NC 151,2 g \NC            \NC\FR
\NC second weight (empty can) \NC  35,6 g \NC            \NC\LR
\NC                           \NC \-      \NC~\Smash{--} \NC\NR
\NC filled weighed t          \NC 115,6 g \NC            \NC\SR
\stoptable
\stopbuffer

\getbuffer

This table is defined by:

\startexample
\typebuffer
\stopexample

% hier werkte het nog %%%%%%%%%%%%%%%%%


One or more table characteristics can be set up with:

\showsetup{setuptables}

The keys \type {HL} and \type {VL} refer to the line
thickness. The tables in this manual are set with
\type {VL=none} en \type {HL=medium}.

\startbuffer
\starttable[|c|c|]
\HL
\VL first \VL second \VL\SR
\HL
\VL first \VL second \VL\FR
\VL first \VL second \VL\LR
\HL
\stoptable
\stopbuffer

\placefigure
  {The available line thicknesses in tables.}
\startcombination[3*1]
  {\setuptables[HL=small]\getbuffer}  {\type{HL=small}}
  {\setuptables[HL=medium]\getbuffer} {\type{HL=medium}}
  {\setuptables[HL=big]\getbuffer}    {\type{HL=big}}
\stopcombination

By means of \type{commands} specific parameters of \TABLE\
itself can be defined, for example:

\starttyping
\setuptables[commands=\Expand]
\stoptyping

This results in a table with a width \type {\hsize}.

The parameters \type {distance} and \type {bodyfont} relate
to the commands mentioned earlier \type {\SR},
\type {\FR}, \type {\MR} and \type {\LR}.

\def\showtable[#1]%
  {\def\doshowtable[##1]%
     {\hbox to .25\hsize
        {\hss
         \setuptables[bodyfont=#1,distance=##1]%
         \starttable[|c|c|]
         \HL
         \VL \TWO{\type{#1 - ##1}} \VL\SR
         \HL
         \VL \TeX \VL \TeX         \VL\FR
         \VL \TeX \VL \TeX         \VL\MR
         \VL \TeX \VL \TeX         \VL\LR
         \HL
         \stoptable
         \hss}}%
   \leavevmode\hbox
      {\doshowtable[big]%
       \doshowtable[medium]%
       \doshowtable[small]%
       \doshowtable[none]}}

\showtable[10pt]

\showtable[9pt]

\showtable[8pt]

Next to these commands we have \type {\DL} that stands for
Division Line, \type {\DC} stands for Division Column and
\type {\DR} stands for Division Row, while \type {\NC} is
used to jump to the Next Column. We also use the command
\type {\NR} that stands for Next Row.

\startbuffer
\starttable[|c|c|c|]
\HL
\VL alfa  \NC beta  \NC gamma \VL\SR
\DC       \DL       \DC          \DR
\VL beta  \VL gamma \VL alfa  \VL\SR
\DC       \DL       \DC          \DR
\VL gamma \NC alfa  \NC beta  \VL\SR
\HL
\stoptable
\stopbuffer

\exampletable

The command \type {\DC} applies default to only one column
and is equal to the \TABLE\ command \type {\=}. When we want
to draw a multi column line we define that in the way that
is shown in the example below.

\startbuffer
\starttable[|c|c|c|]
\HL
\VL \LOW{low} \VL \TWO{n/m} \VL\SR
\DC           \DL[2]           \DR
\VL           \VL n \VL m   \VL\SR
\HL
\VL alfa      \VL 1 \VL a   \VL\FR
\VL alfa      \VL 2 \VL b   \VL\MR
\VL alfa      \VL 3 \VL c   \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

In stead of \type {\TWO} we also could have used the
\TABLE||command \type {\use2}. Because of our criterium of
consistent spacing we can not replace \type {\LOW} by \type
{\lower} in every situation.

We show here another example of the use of \type {\DL}:

\startbuffer
\starttable[|l|c|c|]
\DC        \DL[2]                   \DR
\NC        \VL Mickey   \VL Goofy   \VL\SR \HL
\VL Donald \VL $\star$  \VL         \VL\SR \HL
\VL Pluto  \VL          \VL $\star$ \VL\SR \HL
\stoptable
\stopbuffer

\exampletable

In \in {table} [tab:tablecommands] the commands are
summarized.

\startbuffer[tab-1]
\starttable[|l|l|]
\HL
\VL \bf command   \VL \bf meaning     \VL\SR
\HL
\VL \type{\FR}    \VL First Row       \VL\FR
\VL \type{\LR}    \VL Last Row        \VL\MR
\VL \type{\MR}    \VL Mid Row         \VL\MR
\VL \type{\SR}    \VL Separate Row    \VL\MR
\VL \type{\NR}    \VL No Row          \VL\MR
\VL               \VL                 \VL\MR
\VL \type{\AR}    \VL Auto Row        \VL\LR
\HL
\stoptable
\stopbuffer

\startbuffer[tab-2]
\starttable[|l|l|]
\HL
\VL \bf command            \VL \bf meaning     \VL\SR
\HL
\VL \type{\NC}             \VL Next Column     \VL\FR
\VL \type{\FC}             \VL First Column    \VL\MR
\VL \type{\MC}             \VL Mid Column      \VL\MR
\VL \type{\LC}             \VL Last Column     \VL\MR
\VL                        \VL                 \VL\MR
\VL \type{\LOW}\arg{text}  \VL Low Text        \VL\MR
\VL                        \VL                 \VL\LR
\HL
\stoptable
\stopbuffer

\startbuffer[tab-3]
\starttable[|l|l|]
\HL
\VL \bf command   \VL \bf meaning     \VL\SR
\HL
\VL \type{\HL}    \VL Horizontal Line \VL\FR
\VL \type{\VL}    \VL Vertical Line   \VL\MR
\VL               \VL                 \VL\MR
\VL \type{\DL}    \VL Division Line   \VL\MR
\VL \type{\DL[n]} \VL Division Line n \VL\MR
\VL \type{\DC}    \VL Division Column \VL\MR
\VL \type{\DR}    \VL Division Row    \VL\LR
\HL
\stoptable
\stopbuffer

\placetable
  [here][tab:tablecommands]
  {Table||commands.}
  \startcombination[3*1]
    {\getbuffer[tab-1]} {}
    {\getbuffer[tab-2]} {}
    {\getbuffer[tab-3]} {}
  \stopcombination

You could ask yourself whether determining inter line
spacing within a table should be done manually or
automatically. We would say automatically. In the first
place this reduces the chance for errors. And in the second
place \TEX\ can do the job for us. The commands \type
{\SR}, \type {\FR} etc. are a consequence of \TABLE\
mechanism that was not strict enough for us. Instead of
providing these spacing commands yourself, you can use
\type {\AR} and rely on \CONTEXT\ to sort out the spacing
as good as possible.


\placetable
  [here][tab:registers]
  {Registration (valves) at the base||side of the Schnitke
   organ in Zwolle.}
  {\externalfigure[tables/registers-buffer][width=\textwidth]}

In \in {table} [tab:registers] we used \type {\AR}. The
definition of this table looks likes this.

\startexample
\typebuffer
\stopexample

This mechanism works with rules too, as is demonstrated in
\in {table} [tab:registers].

\startbuffer
\starttable[|||||||||B|]
\HL
\NC\bf8\NC\bf7\NC\bf6\NC\bf5\NC\bf4\NC\bf3\NC\bf2\NC\bf1\NC   \NC\AR
\HL
\NC    \NC  8 \NC    \NC  2 \NC  4 \NC  3 \NC  8 \NC    \NC A \NC\AR
\NC  8 \NC  1+\NC  2 \NC  4 \NC  4 \NC  6 \NC  8 \NC HZ \NC B \NC\AR
\NC    \NC  2 \NC  8 \NC 32 \NC  2 \NC  8 \NC 16 \NC HB \NC C \NC\AR
\NC  8 \NC 16 \NC    \NC  2 \NC  4 \NC  8 \NC 16 \NC HR \NC D \NC\AR
\NC    \NC  8 \NC    \NC    \NC  4 \NC  4 \NC  8 \NC PH \NC E \NC\AR
\HL
\stoptable
\stopbuffer

\startexample
\typebuffer
\stopexample

At the moment the commands \type {\FC}, \type {\MC} and
\type {\LC} are equivalent to \type {\NC}, but in the future
they may show additional functionality.

\placetable
  [here][tab:voetmaten]
  {The pitch of the registrations (valves) at the
   base||side of the Schnitke organ in Zwolle.}
  {\getbuffer}

\section{Color in tables}
\index{color+tables}
\index{tables+color}

The macros that work in the background are rather complicated
but the mechanism for color in tables is this:

\startitemize[n,packed]
\item draw a thick horizontal line
\item jump back vertically
\item set the textline
\stopitemize

The height and depth of the drawn line have to be equal to
that of the textline which accurately defined. We do not
have to bother ourselves with the width because \TEX\ does
that for us. The necessary commands fall back on the command
\type {\noalign}.

The commands to make the cell backgrounds grey or colored
look like the commands to draw Division Lines (see
\in{table}[tab:colored cells]).

\placetable
  [here][tab:colored cells]
  {The table||commands to color cells.}
\starttable[|l|l|]
\HL
\VL \bf command                      \VL \bf meaning       \VL\SR
\HL
\VL \type{\BL}                       \VL Background Line   \VL\FR
\VL \type{\BL[n,type,specification]} \VL Background Line n \VL\MR
\VL \type{\BC}                       \VL Background Column \VL\MR
\VL \type{\BR}                       \VL Background Row    \VL\MR
\VL \type{\CL[specification]}        \VL Color Line        \VL\MR
\VL \type{\RL[specification]}        \VL Raster Line       \VL\LR
\HL
\stoptable

The examples below illustrate the use of these commands. The
lines where the backgrounds are specified {\em precede}
those with the text. Note that just as with \type {\DL} the
command automatically goes to the next column. So do not use
more \type {\BC}'s than necessary.

With \type {\BR} you recall the last specification. This
command is followed by commands like \type {\SR} and \type
{\FR} that give the height of the (yet to follow) textline.

Optional backgrounds are \type {color} and \type {screen}.
When no column is specified the commands are in effect over
only one column. We start with some simple examples.

\startbuffer
\starttable[|c|c|]
\BC      \BL         \SR
\HL
\VL test \VL test \VL\SR
\HL
\VL test \VL test \VL\FR
\VL test \VL test \VL\MR
\VL test \VL test \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

With \type {\BC} we go to column~1. With \type {\BL} we go
to column~2 where a background is intended. At last we
specify by \type {\SR} that the background should be used in
a (still to follow) Separate Row. The space between the
table columns is taken into account during the background
generation.

The reverse alternative is defined below. Keep in mind that
we use \type {\BL} for skipping to the next column.

\startbuffer
\starttable[|c|c|]
\BL                  \SR
\HL
\VL test \VL test \VL\SR
\HL
\VL test \VL test \VL\FR
\VL test \VL test \VL\MR
\VL test \VL test \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

Two or more adjourning cells get a background
when the number of columns is specified:

\startbuffer
\starttable[|c|c|]
\BL[2]               \SR
\HL
\VL test \VL test \VL\SR
\HL
\VL test \VL test \VL\FR
\VL test \VL test \VL\MR
\VL test \VL test \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

And here is another example.

\startbuffer
\starttable[|c|c|c|]
\BL[3]                        \SR
\HL
\VL test \VL test \VL test \VL\SR
\HL
\VL test \VL test \VL test \VL\FR
\VL test \VL test \VL test \VL\MR
\VL test \VL test \VL test \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

\startbuffer
\starttable[|c|c|c|]
\BC      \BL[2]               \SR
\HL
\VL test \VL test \VL test \VL\SR
\HL
\VL test \VL test \VL test \VL\FR
\VL test \VL test \VL test \VL\MR
\VL test \VL test \VL test \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

\startbuffer
\starttable[|c|c|c|]
\BC      \BC      \BL         \SR
\HL
\VL test \VL test \VL test \VL\SR
\HL
\VL test \VL test \VL test \VL\FR
\VL test \VL test \VL test \VL\MR
\VL test \VL test \VL test \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

\startbuffer
\starttable[|c|c|c|]
\BC      \BL                  \SR
\HL
\VL test \VL test \VL test \VL\SR
\HL
\VL test \VL test \VL test \VL\FR
\VL test \VL test \VL test \VL\MR
\VL test \VL test \VL test \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

In the example below there seems to be a missing \type
{\BC}. Note that there is \type {\BL} to jump to the next
column.

\startbuffer
\starttable[|c|c|c|]
\BL               \BL         \SR
\HL
\VL test \VL test \VL test \VL\SR
\HL
\VL test \VL test \VL test \VL\FR
\VL test \VL test \VL test \VL\MR
\VL test \VL test \VL test \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

\startbuffer
\starttable[|c|c|c|]
\BC      \BL                  \SR
\HL
\VL test \VL test \VL test \VL\SR
\HL
                           \BR\FR
\VL test \VL test \VL test \VL\FR
                           \BR\MR
\VL test \VL test \VL test \VL\MR
                           \BR\LR
\VL test \VL test \VL test \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

Because \type {\SR} closes a line we do not
have to specify \type {\BC}'s in the other columns.

We complete these series of examples with a few wider
tables.

\startbuffer
\starttable[|c|c|c|c|]
\BC    \BL[r,0.7]    \BL[r,0.9] \SR
\HL
\VL aa \VL bb \VL cc \VL dd  \VL\SR
\HL
                             \BR\FR
\VL aa \VL bb \VL cc \VL dd  \VL\FR
                             \BR\MR
\VL aa \VL bb \VL cc \VL dd  \VL\MR
                             \BR\LR
\VL aa \VL bb \VL cc \VL dd  \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

With \type {\BR} we recall the most recent specification so
we do not have to specify each background separately. The
spacing however should be specified.

The first line in the example above could have been shorter:

\starttyping
\BC \RL[0.7] \RL[0.9] \SR
\stoptyping

You can use screens and colors in one table. Screens may also be
specified in terms of colors. A screen with a greyshade
$Gr=.9$ can be compared with a color with \kap {rgb}||values
$r=g=b=.9$. Most of the time you can use color and some
greyshades.

\startbuffer
\starttable[|c|c|c|c|]
%\BC    \BL[r,0.8]    \BL[c,red] \SR
\HL
\VL aa \VL bb \VL cc \VL dd   \VL\SR
\HL
                              \BR\FR
\VL aa \VL bb \VL cc \VL dd   \VL\FR
                              \BR\MR
\VL aa \VL bb \VL cc \VL dd   \VL\MR
                              \BR\LR
\VL aa \VL bb \VL cc \VL dd   \VL\LR
\HL
\stoptable
\stopbuffer

TODO: above table doesnt compile

\exampletable 

We can see that with \type {\BL} another background
specification \type {r} or \type {c} is used. The same
result is obtained with \type {screen} or \type {color}.
Colors and screens can be used interchangeably.

A row can be typeset with a background by means of
\type {\RL} and \type {\CL}, without adding rownumbers.

\startbuffer
\starttable[|c|c|c|c|]
                            \RL\FR
\VL aa \VL bb \VL cc \VL dd \VL\FR
\VL aa \VL bb \VL cc \VL dd \VL\MR
                            \RL\MR
\VL aa \VL bb \VL cc \VL dd \VL\MR
\VL aa \VL bb \VL cc \VL dd \VL\LR
\stoptable
\stopbuffer

\exampletable

\startbuffer
\starttable[|c|c|c|c|]
%\CL[green]\FR
\VL aa \VL bb \VL cc \VL dd \VL\FR
\VL aa \VL bb \VL cc \VL dd \VL\MR
\VL aa \VL bb \VL cc \VL dd \VL\MR
\VL aa \VL bb \VL cc \VL dd \VL\LR
\stoptable
\stopbuffer

\exampletable

The next (specifications of) commands are equivalent:

\starttyping
\BL[c,...]  \BL[color,...]   \COLOR[...]
\BL[r,...]  \BL[screen,...]  \SCREEN[...]
\stoptyping

The reader will have noticed that cells get a background
even when no background is specified. These default
backgrounds can be set up with:

\starttyping
\setuptables
  [backgroundcolor=,
   backgroundscreen=,
   background=]
\stoptyping

The key \type {background} can get the value \type
{color} or \type {screen}. The default value is \type
{screen}. As a \type {backgroundcolor} you can specify the
name of a color or as a \type {backgroundscreen} with
a number between~0 and~1.

Unfortunately the line mechanism is not that accurate.
Whether the cause lies with \CONTEXT, \TEX\ or with the \kap
{DVI}||drivers is unclear stil. It is important that the
Horizontal Rules (\type {\HL}) are placed {\em after} the
background is set otherwise the background becomes
foreground and part of the line will disappear. The earlier
examples show how to specify correct; the example below
shows how it is {\em not} done.

\startbuffer
\starttable[|c|c|c|c|]
%\BC    \BL[c,green]  \BL[c,red] \SR
\HL
\VL aa \VL bb \VL cc \VL dd   \VL\SR
                              \BR\FR
\HL
\VL aa \VL bb \VL cc \VL dd   \VL\FR
                              \BR\MR
\VL aa \VL bb \VL cc \VL dd   \VL\MR
                              \BR\LR
\VL aa \VL bb \VL cc \VL dd   \VL\LR
\HL
\stoptable
\stopbuffer

\exampletable

In none of the examples thusfar we see two adjacent colored
columns. The reason is that this is not possible without
complex constructions. One solution is using dummy||columns:

\startbuffer
\starttable[|c||c||c|]
%\BL[c,green] \BL[c,red]         \FR
\NC aa    \NC\NC bb \NC\NC cc \NC\FR
                              \BR\MR
\NC aa    \NC\NC bb \NC\NC cc \NC\MR
                              \BR\LR
\NC aa    \NC\NC bb \NC\NC cc \NC\LR
\stoptable
\stopbuffer

\exampletable

We see that the distance between columns is somewhat too
big. We solve that by adapting the \TABLE||variables \type
{\InterColumn...}. The alternative of using \type {\-} in
stead of \type {\=} is rejected, because the results are
rather poor.

You are free to experiment on this issue. The example shows
that we can fool the mechanism. In this case all textlines
must end with \type {\SR}.

\startbuffer
\starttable[|c|c|c|]
%\BL[c,green] \BL[c,red]  \MR
\NC aa  \NC bb \NC cc \NC\SR
                      \BR\MR
\NC aa  \NC bb \NC cc \NC\SR
                      \BR\MR
\NC aa  \NC bb \NC cc \NC\SR
\stoptable
\stopbuffer

\exampletable

We also see some extra text in this table. We can avoid
extra spaces with the command \type {\tracetablesfalse}.
Default interline inconsistencies are reported during
document generation.

Next to the Format Keys from \TABLE\ the Format Key \type
{K} is available that results in typesetting the text in
that column in capitals (\type {\kap}). In addition to \type
{n} and \type {N} there are \type {q} and \type {Q}. This
command is meant for aligning numbers and it works with
commas in stead of dots.

\startexample
\starttyping
\starttable[{| l k | q[3,4] | Q[2,1] | c |}]
.......
\stoptable
\stoptyping
\stopexample

In this situation we use an extra set of \argchars\ to
prevent any problems. The use of those are explained in the
\TABLE\ manual.

\section{Tables with identical layouts}
\index{tables+templates}
\index{templates+table}

Integrating hundreds of tables is for \TEX\ hardly a
problem. Definition of these tables is a formidable job.
When tables have comparable formats its obvious to specify
common elements only once. The next example will show how it
works. First we define the table layout:

\startbuffer[template]
\definetabletemplate[demo][|r|l|]
\stopbuffer

\typebuffer[template]

\getbuffer[template]

The template, with the name \type {demo}, can be used in the
table definition:

\startbuffer
\starttable[demo]
\VL left \VL right \VL\AR
\VL over \VL under \VL\AR
\stoptable
\stopbuffer

\exampletable

and

\startbuffer
\starttable[demo]
\VL left \VL right \VL\AR
\VL over \VL under \VL\AR
\stoptable
\stopbuffer

\exampletable

We can redefine such a table layout. Next to the layout we
can specify the table head and tail.

\startbuffer[template]
\definetabletemplate[demo][|r|l|][demo head][demo tail]
\stopbuffer

\typebuffer[template]

\getbuffer[template]

The head and tail are defined separately:

\startbuffer[template]
\starttablehead[demo head]
\HL   \VL this \VL that \VL\AR   \HL
\stoptablehead

\starttabletail[demo tail]
\HL
\stoptabletail
\stopbuffer

\typebuffer[template]

\getbuffer[template]

The table we defined earlier looks like this:

\exampletable

The core of this mechanism is the command:

\showsetup{definetabletemplate}

\section{Splitting tables}
\index{tables+splitting}

Like the title of this section says: tables can be split.
Results of splitting tables is satisfactory but the
mechanism is not 100\% waterproof. A table will be split at
a pagebreak when you use \type {\starttables} in stead of
\type {\starttable}

\showsetup{starttables}

The table head and tail are defined in the way described in
the last section.

\startexample
\starttyping
\starttablehead
  ...
\stoptablehead

\starttabletail
  ...
\stoptabletail
\stoptyping
\stopexample

Off course you can also use head and tail definitions that
are defined globally in combination with a specified table
layout. It may be necessary to number a split table. The
next command will do that.

\showsetup{splitfloat}

We may have specified the next splitable table:

\startbuffer
\startbuffer
\starttablehead
\HL \VL Greec \VL Latin \VL\AR \HL
\stoptablehead

\starttabletail
\HL
\stoptabletail

\starttables[|mc|c|]
\VL \alpha \VL a \VL\AR
\VL \beta  \VL b \VL\AR
    ...        .
\VL \zeta  \VL z \VL\AR
\stoptables
\stopbuffer
\stopbuffer

\typebuffer

Because we stored the table in a buffer we specify the table
in the following way:

\starttyping
\splitfloat
  {\placetable[here][tab:demo]{A demo table.}}
  {\getbuffer}
\stoptyping

And the result will be:

\splitfloat
  {\placetable[here][tab:demo]{A demo table.}}
  {\getbuffer}

Set ups can be added as a first optional argument. One of the
parameters is \type {lines}, with which you reserve space
for the caption and vertical spacing. Default the value is~3.

\showsetup{setupfloatsplitting}

The parameter \type {conversion} is used for the
subnumbering of the subtables. Every subtable automatically
gets a subnumber. The parameter \type {conversion} takes
care of its representation (1, 2, 3 -- a, b, c -- I, II, III
-- etc.).




\section{Buffers and scaling}
\index{tables+buffers}
\index{tables+scaling}
\macro{\tex{startbuffer}}
\macro{\tex{getbuffer}}

Very big tables combined with the floating block mechanism
can be a confusing sight in the source file. The following
alternative is recommended.

\startexample
\starttyping
\startbuffer
  ... table ...
\stopbuffer

\placetable{A title.}{\getbuffer}
\stoptyping
\stopexample

In this way we can keep track of what happens. Another
advantage is the fact that we can manipulate tables in this
way (see \in {section} [tex figures]). A table that is too
wide for the page width can be downscaled to that width.
Here is an example:

\startexample
\starttyping
\placetable
  {Fits exactly.}
  {\externalfigure[buffer][width=\textwidth]}
\stoptyping
\stopexample

Default a figure \type {buffer} is defined as the standard
buffer. \in {Table} [tab:registers] is type set in that way.

\section{Remarks}

Within \TABLE\ the bar has a special meaning just like the
double quote. Within \CONTEXT\ we use \type {||} for
combined words and other word related tricks. Furthermore
German users want to use \type {"} as an umlaut trigger.
Conflicts within the \TABLE\ mechanism are at hand and
therefore both characters keep their original meaning. If
you can not live without the \type {|} and \type {"} you can
use the next command to make them behave the way that was
meant in \TABLE. We do not recommend that.

\startexample
\starttyping
\ObeyTableBarAndQuote
\stoptyping
\stopexample

\stop

(unfinished)

\stopcomponent

\section{Opmerkingen}

Het kan voorkomen dat one (omvangrijke) tabel meerdere malen
wordt gebruikt, echter in steeds iets andere vorm. Eenmaal
bekend met de sterke kanten van \TEX, waaronder het kunnen
defini\"eren van commando's, zal in dat geval de vraag
opkomen of men kan volstaan met one definitie. Dat kan. Stel
dat we de volgende tabel hebben gedefinieerd.

\startbuffer
\startbuffer[tabel]
\ifton\starttable[|l|l|l|]\else\starttable[|l|l|]\fi
\HL
\ifhans \VL hans \VL hans \ifton \VL hans \fi         \VL\FR \fi
        \VL test \VL test \ifton \VL ton  \fi \ifhans \VL\MR
                                              \else   \VL\FR \fi
        \VL test \VL test \ifton \VL ton  \fi         \VL\MR
        \VL test \VL test \ifton \VL ton  \fi         \VL\LR
\HL
\stoptable
\stopbuffer
\stopbuffer

\startexample
\typebuffer
\stopexample

In de file(s) waarin we deze tabel oproepen kunnen we deze
tabel als volgt oproepen:

\startexample
\starttyping
\newif\ifton
\newif\ifhans

\placetable {first variant} {\getbuffer[tabel]}
\placetable {second variant} {\tontrue\getbuffer[tabel]}
\placetable {derde variant}  {\hanstrue\getbuffer[tabel]}
\placetable {vierde variant} {\tontrue\hanstrue\getbuffer[tabel]}
\stoptyping
\stopexample

In het onderstaande overzicht geven we deze vier
alternatieven naast elkaar weer.

\newif\ifton
\newif\ifhans

\startlinecorrection
\startcombination[4]
  {\getbuffer\getbuffer[tabel]}
    {\strut}
  {\tontrue\getbuffer\getbuffer[tabel]}
    {\tex{tontrue}}
  {\hanstrue\getbuffer\getbuffer[tabel]}
    {\tex{hanstrue}}
  {\hanstrue\tontrue\getbuffer\getbuffer[tabel]}
    {\tex{tontrue}\endgraf\tex{hanstrue}}
\stopcombination
\stoplinecorrection

Met name bij wat meer gecompliceerde tabellen kan de behoefte
bestaan one setup slechts eenmaal te hoeven defini\"eren. In
deze behoefte is voorzien.

\startexample
\starttyping
\def\standaardsetup%
  {\starttable[|c|c|c|c|]}

\starttable[standaardsetup]
.....
\stoptable
\stoptyping
\stopexample

We herhalen dus \type {\starttable}! Dit maakt het mogelijk
kopregels te defini\"eren, bijvoorbeeld

\startexample
\starttyping
\def\standaardsetup%
  {\starttable[|c|c|c|c|]
   \HL
   \NC a \NC b \NC c \NC d \NC\SR
   \HL}

\starttable[standaardsetup]
.....
\HL
\stoptable
\stoptyping
\stopexample

\stop

\stopcomponent