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
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
|
% \iffalse
%%
%% Source File: `colortbl.dtx'.
%% Copyright 1996 1998 1999 2012 2018 2020 2022 2024 David Carlisle
%%
%% This file may be distributed under the terms of the LPPL.
%% See readme for details.
%%
%
%<*dtx>
\ProvidesFile{colortbl.dtx}
%</dtx>
%<package>\NeedsTeXFormat{LaTeX2e}[1995/06/01]
%<package>\ProvidesPackage{colortbl}
%<driver>\ProvidesFile{colortbl.drv}
% \fi
% \ProvidesFile{colortbl.dtx}
[2024/05/26 v1.0h Color table columns (DPC)]
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage
% [debugshow]
{colortbl}
\usepackage{dcolumn,longtable,hhline}
\setlongtables% in case an old copy of longtable is being used.
\begin{document}
\DeleteShortVerb{\|}
\MakeShortVerb{\"}
\DocInput{colortbl.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{colortbl.dtx}
% \title{The \textsf{colortbl} package\thanks{This file
% has version number \fileversion, last
% revised \filedate.}}
% \author{David Carlisle%\thanks
% {Report issues to
% \texttt{https://github.com/davidcarlisle/dpctex/issues}}}
% \date{\filedate}
%
% \maketitle
%
%
% \begin{abstract}
% This package implements a flexible mechanism for giving colored
% `panels' behind specified columns in a table.
% This package requires the \textsf{array} and \textsf{color} packages.
% \end{abstract}
%
% \changes{v0.1}{1996/09/20}{First draft}
% \changes{v0.1a}{1996/09/21}{Started documentation in doc format}
% \changes{v0.1b}{1996/09/22}
% {New scheme: redefine \cs{@classz} rather than just
% simple \cs{newcolumntype} definition.}
% \changes{v0.1c}{1996/09/24}
% {Make overhang arguments optional (suggestion of S. Rahtz).}
% \changes{v0.1d}{1996/10/05}
% {\cs{rowcolor} added to make S. Rahtz happy.}
% \changes{v0.1d}{1996/10/05}
% {Add \cs{hline} \cs{hhline} and \cs{longtable} support
% to make S. Rahtz even happier.}
% \changes{v0.1e}{1996/10/06}
% {Minor cleanup.}
% \changes{v0.1f}{1996/10/10}
% {Better \cs{hhline} and support nested constructs}
% \changes{v0.1f}{1996/10/12}
% {0.1f, first public version, had a missing percent....}
% \changes{v0.1i}{1999/03/24}
% {LPPL}
% \changes{v0.1j}{2001/02/13}{\cs{cellcolor} (Donald Arseneau)}
% \changes{v1.0c}{2018/05/02}{Updates to match new array code}
% \changes{v1.0d}{2018/12/22}{Updates to match even newer array code}
% \changes{v1.0e}{2020/01/04}{Updates to match updated hhline}
% \changes{v1.0f}{2022/06/20}{moved \cs{rowcolors} code from xcolor}
%
% \section{Introduction}
%
% This package is for coloring tables (i.e., giving colored panels
% behind column entries). In that it has many similarities with
% Timothy Van Zandt's \textsf{colortab} package. The internal
% implementation is quite different though, also \textsf{colortab}
% works with the table constructs of other formats besides \LaTeX.
% This package requires \LaTeX\ (and its \textsf{color} and
% \textsf{array} packages).
%
% First, a standard \textsf{tabular}, for comparison.
% \begin{center}
%\begin{minipage}{.75\textwidth}
%\begin{verbatim}
% \begin{tabular}{|l|c|}
% one&two\\
% three&four
% \end{tabular}
%\end{verbatim}
%\end{minipage}
% {\bfseries
% \begin{tabular}{|l|c|}
% one&two\\
% three&four
% \end{tabular}}
% \end{center}
%
% \section{ The \cs{columncolor} command}
%
% The examples below demonstrate various possibilities of the
% "\columncolor" command introduced by this package. The vertical rules
% specified by "|" are kept in all the examples, to make the column
% positioning clearer, although possibly you would not want colored
% panels \emph{and} vertical rules in practice.
%
% The package supplies a "\columncolor" command, that should (only) be
% used in the argument of a ">" column specifier, to add a colored
% panel behind the specified column. It can be used in the main
% `preamble' argument of \textsf{array} or \textsf{tabular}, and also in
% "\multicolumn" specifiers.
%
% The basic format is:\\
% "\columncolor"\oarg{color model}\marg{color}
% \oarg{left overhang}\oarg{right overhang}
%
% The first argument (or first two if the optional argument is used)
% are standard \textsf{color} package arguments, as used by "\color".
%
% The last two arguments control how far the panel overlaps past the
% widest entry in the column.
% If the \emph{right overhang} argument is omitted then it defaults to
% \emph{left overhang}. If they are both omitted they default to
% "\tabcolsep" (in \textsf{tabular}) or "\arraycolsep"
% (in \textsf{array}).
%
% If the overhangs are both set to "0pt" then the effect is:
% \begin{center}
%\begin{minipage}{.75\textwidth}
%\begin{verbatim}
%|>{\columncolor[gray]{.8}[0pt]}l|
%>{\color{white}%
% \columncolor[gray]{.2}[0pt]}l|
%\end{verbatim}
%\end{minipage}
% {\bfseries
% \begin{tabular}{%
% |>{\columncolor[gray]{.8}[0pt]}l|
% >{\color{white}%
% \columncolor[gray]{.2}[0pt]}l|
% }
% one&two\\
% three&four
% \end{tabular}}
% \end{center}
% The default overhang of "\tabcolsep" produces:
%\begin{center}
%\begin{minipage}{.75\textwidth}
%\begin{verbatim}
%|>{\columncolor[gray]{.8}}l|
%>{\color{white}%
% \columncolor[gray]{.2}}l|
%\end{verbatim}
%\end{minipage}
% {\bfseries
% \begin{tabular}{%
% |>{\columncolor[gray]{.8}}l|
% >{\color{white}%
% \columncolor[gray]{.2}}l|
% }
% one&two\\
% three&four
% \end{tabular}}
% \end{center}
% You might want something between these two extremes.
% A value of ".5\tabcolsep" produces the following effect
% \begin{center}
%\begin{minipage}{.75\textwidth}
%\begin{verbatim}
%|>{\columncolor[gray]{.8}[.5\tabcolsep]}l|
% >{\color{white}%
% \columncolor[gray]{.2}[.5\tabcolsep]}l|
%\end{verbatim}
%\end{minipage}
% {\bfseries
% \begin{tabular}{%
% |>{\columncolor[gray]{.8}[.5\tabcolsep]}l|
% >{\color{white}\columncolor[gray]{.2}[.5\tabcolsep]}l|
% }
% one&two\\
% three&four
% \end{tabular}}
% \end{center}
%
%
% This package should work with most other packages that are
% compatible with the \textsf{array} package syntax. In particular it
% works with \textsf{longtable} and \textsf{dcolumn}
% as the following example shows.
%\errorcontextlines10
% \newcolumntype{A}{%^^A
% >{\color{white}\columncolor{red}[.5\tabcolsep]%^^A
% \raggedright}%
% p{2cm}}
% \newcolumntype{B}{%^^A
% >{\columncolor{blue}[.5\tabcolsep]%^^A
% \color{yellow}\raggedright}
% p{3cm}}
% \newcolumntype{E}{%^^A
% >{\large\bfseries
% \columncolor{cyan}[.5\tabcolsep]}c}
% \newcolumntype{F}{%^^A
% >{\color{white}
% \columncolor{magenta}[.5\tabcolsep]}c}
% \newcolumntype{G}{%^^A
% >{\columncolor[gray]{0.8}[.5\tabcolsep][\tabcolsep]}l}
% \newcolumntype{H}{>{\columncolor[gray]{0.8}}l}
%
%
%^^A 3.3 (as used in the verbatim text below) is best but
%^^A needs a June 96 version of dcolumn, so use -1 here.
% \newcolumntype{C}{%
% >{\columncolor{yellow}[.5\tabcolsep]}%
% D{.}{\cdot}{-1}}
% \newcolumntype{I}{%^^A
% >{\columncolor[gray]{0.8}[\tabcolsep][.5\tabcolsep]}%^^A
% D{.}{\cdot}{-1}}
%
% \setlength\minrowclearance{2pt}
% Before starting give a little space: "\setlength\minrowclearance{2pt}"
%
% \begin{longtable}{ABC}
% \multicolumn{3}{E}{A long table example}\\
% \multicolumn{2}{F}{First two columns}&
% \multicolumn{1}{F}{Third column}\\
% \multicolumn{2}{F}{p-type}&
% \multicolumn{1}{F}{D-type (\textsf{dcolumn})}\endfirsthead
% \multicolumn{3}{E}{A long table example (continued)}\\
% \multicolumn{2}{F}{First two columns}&
% \multicolumn{1}{F}{Third column}\\
% \multicolumn{2}{F}{p-type}&
% \multicolumn{1}{F}{D-type (\textsf{dcolumn})}\endhead
% \multicolumn{3}{E}{Continued\ldots}\endfoot
% \multicolumn{3}{E}{The End}\endlastfoot
% P-column&and another one&12.34\\
% \multicolumn{1}{G}{Total}&
% \multicolumn{1}{H}{(wrong)}&
% \multicolumn{1}{I}{100.6}\\
% Some long text in the first column&bbb&1.2\\
% aaa&and some long text in the second column&1.345\\
% \multicolumn{1}{G}{Total}&
% \multicolumn{1}{H}{(wrong)}&
% \multicolumn{1}{I}{100.6}\\
% aaa&bbb&1.345\\
% Note that the colored rules in all columns stretch to accomodate
% large entries in one column. &bbb&1.345\\
% aaa&bbb&100\\
% aaa&Depending on your driver you may get unsightly gaps or lines
% where the `screens' used to produce different shapes interact
% badly. You may want to cause adjacent panels of the same color by
% specifying a larger overhang
% or by adding some negative space (in a "\noalign" between rows.&12.4\\
% aaa&bbb&45.3\\
% \end{longtable}
%
% This
% example shows rather poor taste but is quite colorful!
% Inspect the source file, "colortbl.dtx", to see the full code for
% the example, but it uses the following column types.
%\begin{verbatim}
% \newcolumntype{A}{%
% >{\color{white}\columncolor{red}[.5\tabcolsep]%
% \raggedright}%
% p{2cm}}
% \newcolumntype{B}{%
% >{\columncolor{blue}[.5\tabcolsep]%
% \color{yellow}\raggedright}
% p{3cm}}
% \newcolumntype{C}{%
% >{\columncolor{yellow}[.5\tabcolsep]}%
% D{.}{\cdot}{3.3}}
% \newcolumntype{E}{%
% >{\large\bfseries
% \columncolor{cyan}[.5\tabcolsep]}c}
% \newcolumntype{F}{%
% >{\color{white}
% \columncolor{magenta}[.5\tabcolsep]}c}
% \newcolumntype{G}{%
% >{\columncolor[gray]{0.8}[.5\tabcolsep][\tabcolsep]}l}
% \newcolumntype{H}{>{\columncolor[gray]{0.8}}l}
% \newcolumntype{I}{%
% >{\columncolor[gray]{0.8}[\tabcolsep][.5\tabcolsep]}%
% D{.}{\cdot}{3.3}}
%\end{verbatim}
%
% \section{Using the `overhang' arguments for \textsf{tabular*}}
%
% The above is all very well for \textsf{tabular}, but what about
% \textsf{tabular*}?
%
% Here the problem is rather harder. Although \TeX's "\leader" mechanism
% which is used by this package to insert the `stretchy' colored panels
% is rather like \emph{glue}, the "\tabskip" glue that is inserted
% between columns of \textsf{tabular*} (and \textsf{longtable} for that
% matter) has to be `real glue' and not `leaders'.
%
% Within limits the overhang options may be used here. Consider the
% first table example above. If we use \textsf{tabular*} set to 3\,cm
% with a preamble setting of
% \begin{center}
%\begin{minipage}{.6\textwidth}
%\begin{verbatim}
%\begin{tabular*}{3cm}{%
%@{\extracolsep{\fill}}
%>{\columncolor[gray]{.8}[0pt][20mm]}l
%>{\columncolor[gray]{.8}[5mm][0pt]}l
%@{}}
%\end{verbatim}
%\end{minipage}
% {\bfseries
% \begin{tabular*}{3cm}{%
% @{\extracolsep{\fill}}
% >{\columncolor[gray]{.8}[0pt][20mm]}l
% >{\columncolor[gray]{.8}[5mm][0pt]}l
% @{}%
% }
% one&two\\
% three&four
% \end{tabular*}}
% \end{center}
%
% Changing the specified width to 4\,cm works, but don't push your
% luck to 5\,cm\ldots
% \begin{center}
% \bfseries
% \begin{tabular*}{4cm}{%
% @{\extracolsep{\fill}}
% >{\columncolor[gray]{.8}[0pt][20mm]}l
% >{\columncolor[gray]{.8}[5mm][0pt]}l
% @{}%
% }
% one&two\\
% three&four
% \end{tabular*}\hfill
% \begin{tabular*}{5cm}{%
% @{\extracolsep{\fill}}
% >{\columncolor[gray]{.8}[0pt][20mm]}l
% >{\columncolor[gray]{.8}[5mm][0pt]}l
% @{}%
% }
% one&two\\
% three&four
% \end{tabular*}
% \end{center}
%
% \section{The \cs{rowcolor} command}
%
% As demonstrated above, one may change the color of specified rows
% of a table by the use of "\multicolumn" commands in each entry of
% the row. However if your table is to be marked principally by
% \emph{rows}, you may find this rather inconvenient. For this reason
% a new mechanism, "\rowcolor", has been introduced\footnote{At some
% cost to the internal complexity of this package}.
%
% "\rowcolor" takes the same argument forms as "\columncolor". It must
% be used at the \emph{start} of a row. If the optional overhang
% arguments are not used the overhangs will default to the overhangs
% specified in any "\columncolor" comands for that column, or
% "\tabcolsep" ("\arraycolsep" in \textsf{array}).
%
% If a table entry is in the scope of a "\columncolor" specified in the
% table preamble, and also a "\rowcolor" at the start of the current
% row, the color specified by "\rowcolor" will take effect. A
% "\multicolumn" command may contain ">{\rowcolor"\ldots\ which will
% override the default colors for both the current row and column.
% \begin{center}
%\begin{minipage}{.75\textwidth}
%\begin{verbatim}
% \begin{tabular}{|l|c|}
% \rowcolor[gray]{.9}
% one&two\\
% \rowcolor[gray]{.5}
% three&four
% \end{tabular}
%\end{verbatim}
%\end{minipage}
% {\bfseries
% \begin{tabular}{|l|c|}
% \rowcolor[gray]{.9}
% one&two\\
% \rowcolor[gray]{.5}
% three&four
% \end{tabular}}
% \end{center}
%
% \section{The \cs{rowcolors} command}
% The \cs{rowcolors} command and its documentation originate in the \textsf{xcolor} package
% by Dr.\ Uwe Kern.
%
% \DescribeMacro\rowcolors
% \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\
% \DescribeMacro{\rowcolors*}
% \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\
% One of these commands has to be executed \emph{before} a table starts.
% \meta{row} tells the number of the first row which should be colored according to the \meta{odd-row color} and \meta{even-row color} scheme.
% Each of the color arguments may also be left empty (= no color).
% In the starred version, \meta{commands} are ignored in rows with inactive \emph{rowcolors status} (see below), whereas in the non-starred version, \meta{commands} are applied to every row of the table.
% Such optional commands may be "\hline" or "\noalign"\marg{stuff}.
%
% \DescribeMacro\showrowcolors
% \DescribeMacro\hiderowcolors
% The \emph{rowcolors status} is activated (i.e., use coloring scheme) by default and/or "\showrowcolors", it is inactivated (i.e., ignore coloring scheme) by the command "\hiderowcolors".
% \DescribeMacro\rownum
% The counter "\rownum" (or \LaTeX\ counter "rownum")
% may be used within such a table to access the current row number.
%
% At the present time, the "rownum" counter is only incremented in tables using "\rowcolors".
%
% \begin{center}
% \begin{minipage}{\textwidth}
% \begin{verbatim}
% \rowcolors[\hline]{3}{green}{yellow} \arrayrulecolor{red}
% \begin{tabular}{ll}
% test & row \therownum\\
% test & row \therownum\\
% test & row \therownum\\
% test & row \therownum\\
% \arrayrulecolor{black}
% test & row \therownum\\
% test & row \therownum\\
% \rowcolor{blue}
% test & row \therownum\\
% test & row \therownum\\
% \hiderowcolors
% test & row \therownum\\
% test & row \therownum\\
% \showrowcolors
% test & row \therownum\\
% test & row \therownum\\
% \multicolumn{1}%
% {>{\columncolor{red}}l}{test} & row \therownum\\
% \end{tabular}
% \end{verbatim}
% \end{minipage}
% \hskip-.5\textwidth
% \rowcolors[\hline]{3}{green}{yellow} \arrayrulecolor{red}
% \begin{tabular}{ll}
% test & row \therownum\\
% test & row \therownum\\
% test & row \therownum\\
% test & row \therownum\\
% \arrayrulecolor{black}
% test & row \therownum\\
% test & row \therownum\\
% \rowcolor{cyan}
% test & row \therownum\\
% test & row \therownum\\
% \hiderowcolors
% test & row \therownum\\
% test & row \therownum\\
% \showrowcolors
% test & row \therownum\\
% test & row \therownum\\
% \multicolumn{1}%
% {>{\columncolor{magenta}}l}{test} & row \therownum\\
% \end{tabular}
% \qquad
% \rowcolors*[\hline]{3}{green}{yellow}\arrayrulecolor{red}
% \begin{tabular}{ll}
% test & row \therownum\\
% test & row \therownum\\
% test & row \therownum\\
% test & row \therownum\\
% \arrayrulecolor{black}
% test & row \therownum\\
% test & row \therownum\\
% \rowcolor{blue}
% test & row \therownum\\
% test & row \therownum\\
% \hiderowcolors
% test & row \therownum\\
% test & row \therownum\\
% \showrowcolors
% test & row \therownum\\
% test & row \therownum\\
% \multicolumn{1}%
% {>{\columncolor{red}}l}{test} & row \therownum\\
% \end{tabular}
% \arrayrulecolor{black}
% \end{center}
%
% \section{The \cs{cellcolor} command}
%
% A background color can be applied to a single cell of a table by
% beginning it with
% "\multicolumn"\nolinebreak[3]"{1}"\nolinebreak[3]"{>{\rowcolor"\ldots,
% (or "\columncolor" if no row-color is in effect) but this has some
% deficiencies:
% 1)~It prevents data within the cell from triggering the coloration; \
% 2)~The alignment specification must be copied from the top of the tabular,
% which is prone to errors, especially for "p{}" columns; \
% 3)~"\multicolumn{1}" is just silly. \
% Therefore, there is the \cs{cellcolor} command, which works like
% \cs{columncolor} and \cs{rowcolor}, but over-rides both of them;
% \cs{cellcolor} can be placed anywhere in the tabular cell to which
% it applies.
%
% \section{Coloring rules.}
%
% So you want colored rules as well?
%
% One could do vertical rules without any special commands, just use
% something like "!{\color{green}\vline}" where you'd
% normally use "|". The space between "||" will normally be left white.
% If you want to color that as well, either increase the overhang of
% the previous column (to
% "\tabcolsep" + "\arrayrulewidth" + "\doublerulesep")
% Or remove the inter rule glue, and replace by a colored rule of the
% required thickness. So
%\begin{verbatim}
%!{\color{green}\vline}
%@{\color{yellow}\vrule width \doublerulesep}
%!{\color{green}\vline}
%\end{verbatim}
% Should give the same spacing as "||" but more color.
%
% However coloring "\hline" and "\cline" is a bit more tricky, so
% extra commands are provided (which then apply to vertical rules as
% well).
%
% \section{\cs{arrayrulecolor}}
% "\arrayrulecolor" takes the same arguments as "\color", and is a
% global declaration which affects all following horizontal and
% vertical rules in tables. It may be given outside any table, or at
% the start of a row, or in a ">" specification in a table preamble.
% You should note however that if given mid-table it only affects
% rules that are specified after this point, any vertical rules
% specified in the preamble will keep their original colors.
%
% \section{\cs{doublerulesepcolor}}
% Having colored your rules, you'll probably want something other
% than white to go in the gaps made by "||" or "\hline\hline".
% "\doublerulesepcolor" works just the same way as "\arrayrulecolor".
% The main thing to note that if this command is used, then
% \textsf{longtable} will not `discard' the space between
% "\hline\hline" at a page break. (\TeX\ has a built-in ability to
% discard space, but the colored `space' which is used once
% "\doublerulesep" is in effect is really a third rule of a different
% color to the two outer rules, and rules are rather harder to
% discard.)
%
% \begin{center}
% \setlength\arrayrulewidth{2pt}\arrayrulecolor{blue}
% \setlength\doublerulesep{2pt}\doublerulesepcolor{yellow}
%
%\begin{minipage}{.75\textwidth}
%\begin{verbatim}
%\setlength\arrayrulewidth{2pt}\arrayrulecolor{blue}
%\setlength\doublerulesep{2pt}\doublerulesepcolor{yellow}
% \begin{tabular}{||l||c||}
% \hline\hline
% one&two\\
% three&four\\
% \hline\hline
% \end{tabular}
%\end{verbatim}
%\end{minipage}
% {\bfseries
% \begin{tabular}{|l||c||}
% \hline\hline
% one&two\\
% three&four\\
% \hline\hline
% \end{tabular}}
% \end{center}
%
% \section{More fun with \cs{hhline}}
% The above commands work with "\hhline" from the \textsf{hhline}
% package, however if \textsf{hhline} is loaded in addition to this
% package, a new possibility is added. You may use ">{"\ldots"}" to add
% declarations that apply to the following "-" or "=" column rule.
% In particular you may give "\arrayrulecolor" and
% "\doublerulesepcolor" declarations in this argument.
%
% Most manuals of style warn against over use of rules in tables.
% I hate to think what they would make of the following rainbow
% example:
% \begin{center}
% \setlength\arrayrulewidth{5pt}
% \setlength\doublerulesep{5pt}
% \renewcommand{\arraystretch}{2}
% \definecolor{orange}{cmyk}{0,0.61,0.87,0}
% \definecolor{indigo}{cmyk}{0.8,0.9,0,0}
% \definecolor{violet}{cmyk}{0.6,0.9,0,0}
% \newcommand\rainbowline[1]{%^^A
% \hhline{%^^A
% >{\arrayrulecolor {red}\doublerulesepcolor[rgb]{.3,.3,1}}%^^A
% |#1:=%^^A
% >{\arrayrulecolor{orange}\doublerulesepcolor[rgb]{.4,.4,1}}%^^A
% =%^^A
% >{\arrayrulecolor{yellow}\doublerulesepcolor[rgb]{.5,.5,1}}%^^A
% =%^^A
% >{\arrayrulecolor {green}\doublerulesepcolor[rgb]{.6,.6,1}}%^^A
% =%^^A
% >{\arrayrulecolor {blue}\doublerulesepcolor[rgb]{.7,.7,1}}%^^A
% =%^^A
% >{\arrayrulecolor{indigo}\doublerulesepcolor[rgb]{.8,.8,1}}%^^A
% =%^^A
% >{\arrayrulecolor{violet}\doublerulesepcolor[rgb]{.9,.9,1}}%^^A
% =:#1|%^^A
% }}
% \arrayrulecolor{red}
% \doublerulesepcolor[rgb]{.3,.3,1}
% \begin{tabular}{||*7{>{\columncolor[gray]{.9}}c}||}
% \rainbowline{t}%^^A
% \arrayrulecolor{violet}\doublerulesepcolor[rgb]{.9,.9,1}
% Richard&of&York&gave&battle&in&
% \multicolumn{1}{>{\columncolor[gray]{.9}}c||}{vain}\\
% \rainbowline{}%^^A
% 1&2&3&4&5&6&
% \multicolumn{1}{>{\columncolor[gray]{.9}}c||}{7}\\
% \rainbowline{b}%^^A
% \end{tabular}
% \end{center}
%\begin{verbatim}
% \newcommand\rainbowline[1]{%
% \hhline{%
% >{\arrayrulecolor {red}\doublerulesepcolor[rgb]{.3,.3,1}}%
% |#1:=%
% >{\arrayrulecolor{orange}\doublerulesepcolor[rgb]{.4,.4,1}}%
% =%
% >{\arrayrulecolor{yellow}\doublerulesepcolor[rgb]{.5,.5,1}}%
% =%
% >{\arrayrulecolor {green}\doublerulesepcolor[rgb]{.6,.6,1}}%
% =%
% >{\arrayrulecolor {blue}\doublerulesepcolor[rgb]{.7,.7,1}}%
% =%
% >{\arrayrulecolor{indigo}\doublerulesepcolor[rgb]{.8,.8,1}}%
% =%
% >{\arrayrulecolor{violet}\doublerulesepcolor[rgb]{.9,.9,1}}%
% =:#1|%
% }}
% \arrayrulecolor{red}
% \doublerulesepcolor[rgb]{.3,.3,1}%
% \begin{tabular}{||*7{>{\columncolor[gray]{.9}}c}||}
% \rainbowline{t}%
% \arrayrulecolor{violet}\doublerulesepcolor[rgb]{.9,.9,1}
% Richard&of&York&gave&battle&in&
% \multicolumn{1}{>{\columncolor[gray]{.9}}c||}{vain}\\
% \rainbowline{}%
% 1&2&3&4&5&6&
% \multicolumn{1}{>{\columncolor[gray]{.9}}c||}{7}\\
% \rainbowline{b}%
% \end{tabular}
%\end{verbatim}
%
% \section{Less fun with \cs{cline}}
% Lines produced by "\cline" are colored if you use
% "\arrayrulecolor" but you may not notice as they are covered up by
% any color pannels in the following row. This is a `feature' of
% "\cline". If using this package you would probably better using the
% "-" rule type in a "\hhline" argument, rather than "\cline".
%
% \section{The \cs{minrowclearance} command}
%
% As this package has to box and measure every entry to figure out
% how wide to make the rules, I thought I may as well add the
% following feature. `Large' entries in tables may touch a preceding
% "\hline" or the top of a color panel defined by this style.
% It is best to increase "\extrarowsep" or "\arraystretch"
% sufficiently to ensure this doesn't happen, as that will keep the
% line spacing in the table regular. Sometimes however, you just want
% to \LaTeX\ to insert a bit of extra space above a large entry.
% You can set the length "\minrowclearance" to a small value.
% (The height of a capital letter plus this value should not be
% greater than the normal height of table rows, else a very uneven
% table spacing will result.)
%
% Donald Arseneau's \textsf{tabls} packages provides a similar
% "\tablinesep". I was going to give this the same name for
% compatibility with \textsf{tabls}, but that is implemented quite
% differently and probably has different behaviour. So I'll keep a new
% name for now.
%
% \StopEventually{}
%
% \section{The Code}
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% Nasty hacky way used by all the graphics packages to include debugging
% code.
% \begin{macrocode}
\edef\@tempa{%
\noexpand\AtEndOfPackage{%
\catcode`\noexpand\^^A\the\catcode`\^^A\relax}}
\@tempa
\catcode`\^^A=\catcode`\%
\DeclareOption{debugshow}{\catcode`\^^A=9 }
% \end{macrocode}
%
% All the other options are handled by the \textsf{color} package.
% \begin{macrocode}
\DeclareOption*{\PassOptionsToPackage\CurrentOption{color}}
\ProcessOptions
% \end{macrocode}
%
% I need these so load them now. Actually Mark Wooding's
% \textsf{mdwtab} package could probably work instead of \textsf{array},
% but currently I assume \textsf{array} package internals so\ldots
% \begin{macrocode}
\RequirePackage{array,color}
% \end{macrocode}
%
%
% \begin{macro}{\@classz}
% First define stub for new \textsf{array} package code.
% \begin{macrocode}
\ifx\do@row@strut\@undefined\let\do@row@strut\relax\fi
% \end{macrocode}
%
% "\@classz" is the main function in the \textsf{array} package handling
% of primitive column types: It inserts the code for each of the column
% specifiers, `"clrpmb"'. The other classes deal with the other preamble
% tokens such as `"@" 'or `">"'.
% \begin{macrocode}
\def\@classz{\@classx
\@tempcnta \count@
\prepnext@tok
% \end{macrocode}
% At this point the color specification for the background panel will
% be in the code for the `">"' specification of this column. This is
% saved in "\toks\@temptokena" but \textsf{array} will insert it too
% late (well it would work for "c", but not for "p") so fish the color
% stuff out of that token register by hand, and then insert it around
% the entry.
%
% Of course this is a terrible hack. What is really needed is a new
% column type that inserts stuff in the right place (rather like "!"
% but without the spacing that that does). The "\newcolumntype"
% command of \textsf{array} only adds `second class' column types.
% The re-implementations of "\newcolumntype" in my \textsf{blkarray} or
% Mark Wooding's \textsf{mdwtab} allow new `first class' column types
% to be declared, but stick with \textsf{array} for now. This means we
% have to lift the stuff out of the register before the register gets
% emptied in the wrong place.
% \begin{macrocode}
\expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil
% \end{macrocode}
% Save the entry into a box (using a double group for color safety as
% usual).
% \begin{macrocode}
\@addtopreamble{%
\setbox\z@\hbox\bgroup\bgroup
% \end{macrocode}
% \changes{v1.0a}{2012/02/13}{reset \cs{everycr} for nested uses (see test ct2)}
% \begin{macrocode}
\CT@everycr{}%
\ifcase \@chnum
% \end{macrocode}
% "c" code: This used to use twice as much glue as "l" and "r" (1fil
% on each side). Now modify it to use 1fill total. Also increase the
% order from 1fil to 1fill to dissuade people from putting stretch glue
% in table entries.
% \begin{macrocode}
\hskip\stretch{.5}\kern\z@
\d@llarbegin
\insert@column
\d@llarend\do@row@strut\hskip\stretch{.5}\or
% \end{macrocode}
% "l" and "r" as before, but using fill glue.
% \begin{macrocode}
\d@llarbegin \insert@column \d@llarend\do@row@strut \hfill
\or
\hfill\kern\z@ \d@llarbegin \insert@column \d@llarend\do@row@strut
\or
% \end{macrocode}
% "m", "p" and "b" as before, but need to take account of array package update.
% \begin{macrocode}
\ifx\ar@align@mcell\@undefined
$\vcenter
\@startpbox{\@nextchar}\insert@column \@endpbox $
\else
\setbox\ar@mcellbox\vbox
\@startpbox{\@nextchar}\insert@column \@endpbox
\ar@align@mcell
\do@row@strut
\fi
\or
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox\do@row@strut
\or
\vbox \@startpbox{\@nextchar}\insert@column \@endpbox\do@row@strut
\fi
% \end{macrocode}
% Close the box register assignment.
% \begin{macrocode}
\egroup\egroup
% \end{macrocode}
% \changes{v0.1d}{1996/10/05}
% {add \cs{CT@row@color} to support \cs{rowcolor}}
% The main new stuff.
% \begin{macrocode}
\begingroup
% \end{macrocode}
% Initalise color command and overhands.
% \begin{macrocode}
\CT@setup
% \end{macrocode}
% Run any code resulting from "\columncolor" commands.
% \begin{macrocode}
\CT@column@color
% \end{macrocode}
% Run code from "\rowcolor" (so this takes precedence over
% "\columncolor").
% \begin{macrocode}
\CT@row@color
% \end{macrocode}
% Run code from "\cellcolor" (so this takes precedence over
% both "\columncolor" and "\rowcolor").
% \begin{macrocode}
\CT@cell@color
% \end{macrocode}
% This is "\relax" unless one of the three previous commands has requested
% a color, in which case it will be "\CT@@do@color" which will insert
% "\leaders" of appropriate color.
% \begin{macrocode}
\CT@do@color
\endgroup
% \end{macrocode}
% Nothing to do with color this bit, since we are boxing and measuring
% the entry anyway may as well check the height, so that large entries
% don't bump into horizontal rules (or the top of the color panels).
% \begin{macrocode}
\@tempdima\ht\z@
\advance\@tempdima\minrowclearance
\vrule\@height\@tempdima\@width\z@
% \end{macrocode}
% It would be safer to leave this boxed, but unboxing allows some
% flexibilty. However the total glue stretch should either be finite
% or fil (which will be ignored). There may be fill glue (which will not
% be ignored) but it should \emph{total 0fill}. If this box contributes
% fill glue, then the leaders will not reach the full width of the
% entry. In the case of "\multicolumn" entries it is actually possible
% for this box to contribute \emph{shrink} glue, in which case the
% colored panel for that entry will be too wide. Tough luck.
% \begin{macrocode}
\unhbox\z@}%
% \end{macrocode}
%
% \begin{macrocode}
\prepnext@tok}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@setup}
% Initialise the overhang lengths and the color command.
% \begin{macrocode}
\def\CT@setup{%
\@tempdimb\col@sep
\@tempdimc\col@sep
\def\CT@color{%
\global\let\CT@do@color\CT@@do@color
\color}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@@do@color}
% The main point of the package: Add the color panels.
%
% Add a leader of the specified color, with natural width the
% width of the entry plus the specified overhangs and 1fill stretch.
% Surround by negative kerns so total natural width is not affected by
% overhang.
% \begin{macrocode}
\def\CT@@do@color{%
\global\let\CT@do@color\relax
\@tempdima\wd\z@
\advance\@tempdima\@tempdimb
\advance\@tempdima\@tempdimc
\kern-\@tempdimb
\leaders\vrule
% \end{macrocode}
% For quick debugging with xdvi (which can't do colors). Limit the size
% of the rule, so I can see the text as well.
% \begin{macrocode}
^^A \@height\p@\@depth\p@
% \end{macrocode}
%
% \begin{macrocode}
\hskip\@tempdima\@plus 1fill
\kern-\@tempdimc
% \end{macrocode}
% Now glue to exactly compensate for the leaders.
% \begin{macrocode}
\hskip-\wd\z@ \@plus -1fill }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@extract}
% \changes{v1.0f}{2022/06/20}{protect against active characters}
% Now the code to extract the "\columncolor" commands.
% \begin{macrocode}
\def\CT@extract#1\columncolor#2#3\@nil{%
\if!\noexpand#2%
% \end{macrocode}
% "!" is a fake token inserted at the end.
% \begin{macrocode}
\let\CT@column@color\@empty
\else
% \end{macrocode}
% If there was an optional argument
% \begin{macrocode}
\if[\noexpand#2%
\CT@extractb{#1}#3\@nil
\else
% \end{macrocode}
% No optional argument
% \begin{macrocode}
\def\CT@column@color{%
\CT@color{#2}}%
\CT@extractd{#1}#3\@nil
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@extractb}
% Define "\CT@column@color" to add the right color, and save the
% overhang lengths. Finally reconstitute the saved `">"' tokens,
% without the color specification.
% First grab the color spec, with optional arg.
% \begin{macrocode}
\def\CT@extractb#1#2]#3{%
\def\CT@column@color{%
\CT@color[#2]{#3}}%
\CT@extractd{#1}}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@extractd}
% Now look for left-overhang (default to "\col@sep").
% \begin{macrocode}
\def\CT@extractd#1{\@testopt{\CT@extracte{#1}}\col@sep}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@extracte}
% Same for right-overhang (default to left-overhang).
% \begin{macrocode}
\def\CT@extracte#1[#2]{\@testopt{\CT@extractf{#1}[#2]}{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@extractf}
% Add the overhang info to "\CT@do@color", for excuting later.
% \begin{macrocode}
{\catcode`\!\active
\gdef\CT@extractf#1[#2][#3]#4\columncolor#5\@nil{%
\@tempdimb#2\relax
\@tempdimc#3\relax
\edef!{\string!}%
\edef\CT@column@color{%
\CT@column@color
\@tempdimb\the\@tempdimb\@tempdimc\the\@tempdimc\relax}%
\toks\@tempcnta{#1#4}}}%
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\CT@everycr}
% Steal "\everypar" to initialise row colors
% \begin{macrocode}
\let\CT@everycr\everycr
\newtoks\everycr
\CT@everycr{\noalign{\global\let\CT@row@color\relax}\the\everycr}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@start}
% \changes{v0.1f}{1996/10/10}
% {Nested support for \cs{rowcolor} (prompted by Denis Girou)}
%
% \begin{macrocode}
\def\CT@start{%
\let\CT@arc@save\CT@arc@
\let\CT@drsc@save\CT@drsc@
\let\CT@row@color@save\CT@row@color
\let\CT@cell@color@save\CT@cell@color
\global\let\CT@cell@color\relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@end}
% \begin{macrocode}
\def\CT@end{%
\global\let\CT@arc@\CT@arc@save
\global\let\CT@drsc@\CT@drsc@save
\global\let\CT@row@color\CT@row@color@save
\global\let\CT@cell@color\CT@cell@color@save}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\shortstack}
% "\shortstack"
% \begin{macrocode}
\gdef\@ishortstack#1{%
\CT@start\ialign{\mb@l {##}\unskip\mb@r\cr #1\crcr}\CT@end\egroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tabarray}
% \textsf{array} and \textsf{tabular} (delayed for \textsf{delarray})
% \begin{macrocode}
\AtBeginDocument{%
\expandafter\def\expandafter\@tabarray\expandafter{%
\expandafter\CT@start\@tabarray}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endarray}
% \changes{v1.0b}{2012/21/06}{re-insert \cs{@arrayright} to match \textsf{array} definition, for \textsf{delarray}}
% \changes{v1.0h}{2024/05/26}{Don't assume existing \cs{endarray} definition, to work with tagging code}
% \begin{macrocode}
\expandafter\def\expandafter\endarray\expandafter{\endarray\CT@end}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\multicolumn}
% "\multicolumn"
% \changes{v1.0a}{2012/02/13}{make \cs{multicolumn} long (see test ct1)}
% \changes{v1.0g}{2024/02/20}{Add to existing definition to for dpctex 47}
% Patch "\multicolumn" to restore color settings. Done this way to work wth
% different versions depending on the age of the \textsf{array} package.
% \begin{macrocode}
\def\@tempa#1\@arstrut#2\relax{
\long\def\multicolumn##1##2##3{%
#1%
% \end{macrocode}
% \changes{v1.0a}{2012/02/13}{don't reset \cs{CT@row@color} (see test ct3)}
% \let\CT@row@color\relax
% \begin{macrocode}
\let\CT@cell@color\relax
\let\CT@column@color\relax
\let\CT@do@color\relax
\@arstrut
#2}}
\expandafter\@tempa\multicolumn{#1}{#2}{#3}\relax
\let\@temp\relax
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@classvi}
% Colored rules and rule separations.
% \begin{macrocode}
\def\@classvi{\ifcase \@lastchclass
\@acol \or
\ifx\CT@drsc@\relax
\@addtopreamble{\hskip\doublerulesep}%
\else
\@addtopreamble{{\CT@drsc@\vrule\@width\doublerulesep}}%
\fi\or
\@acol \or
\@classvii
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\doublerulesepcolor}
% \begin{macrocode}
\def\doublerulesepcolor#1#{\CT@drs{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@drs}
% \begin{macrocode}
\def\CT@drs#1#2{%
\ifdim\baselineskip=\z@\noalign\fi
{\gdef\CT@drsc@{\color#1{#2}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@drsc@}
% \begin{macrocode}
\let\CT@drsc@\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\arrayrulecolor}
% \begin{macrocode}
\def\arrayrulecolor#1#{\CT@arc{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@arc}
% \begin{macrocode}
\def\CT@arc#1#2{%
\ifdim\baselineskip=\z@\noalign\fi
{\gdef\CT@arc@{\color#1{#2}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@arc@}
% \begin{macrocode}
\let\CT@arc@\relax
% \end{macrocode}
% \end{macro}
%
% hline
%
% \begin{macro}{\@arrayrule}
% \begin{macrocode}
\def\@arrayrule{\@addtopreamble {{\CT@arc@\vline}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hline}
% \begin{macrocode}
\def\hline{%
\noalign{\ifnum0=`}\fi
\let\hskip\vskip
\let\vrule\hrule
\let\@width\@height
{\CT@arc@\vline}%
\futurelet
\reserved@a\@xhline}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xhline}
% \begin{macrocode}
\def\@xhline{\ifx\reserved@a\hline
{\ifx\CT@drsc@\relax
\vskip
\else
\CT@drsc@\hrule\@height
\fi
\doublerulesep}%
\fi
\ifnum0=`{\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cline}
% "\cline" doesn't really work, as it comes behind the colored panels,
% but at least make it the right color (the bits you can see, anyway).
% \begin{macrocode}
\def\@cline#1-#2\@nil{%
\omit
\@multicnt#1%
\advance\@multispan\m@ne
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#2%
\advance\@multicnt-#1%
\advance\@multispan\@ne
{\CT@arc@\leaders\hrule\@height\arrayrulewidth\hfill}%
\cr
\noalign{\vskip-\arrayrulewidth}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\minrowclearance}
% The row height fudge length.
% \begin{macrocode}
\newlength\minrowclearance
\minrowclearance=0pt
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mkpream}
% \begin{macro}{\@mkpreamarray}
% While expanding the preamble \textsf{array} passes tokens through an
% "\edef". It doesn't use "\protect"ion as it thinks it has full control
% at that point. As the redefinition above adds "\color", I need to add
% that to the list of commands made safe.
% \begin{macrocode}
\let\@mkpreamarray\@mkpream
\def\@mkpream{%
\let\CT@setup\relax
\let\CT@color\relax
\let\CT@do@color\relax
\let\color\relax
\let\CT@column@color\relax
\let\CT@row@color\relax
\let\CT@cell@color\relax
\@mkpreamarray}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\CT@do@color}
% For similar reasons, need to make this non-expandable
% \begin{macrocode}
\let\CT@do@color\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rowcolor}
% \changes{v0.1f}{1996/10/10}
% {Add \cs{noalign} (Denis Girou)}
% \begin{macrocode}
\def\rowcolor{%
\noalign{\ifnum0=`}\fi
\global\let\CT@do@color\CT@@do@color
\@ifnextchar[\CT@rowa\CT@rowb}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@rowa}
% \begin{macrocode}
\def\CT@rowa[#1]#2{%
\gdef\CT@row@color{\CT@color[#1]{#2}}%
\CT@rowc}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@rowb}
% \begin{macrocode}
\def\CT@rowb#1{%
\gdef\CT@row@color{\CT@color{#1}}%
\CT@rowc}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@rowc}
% \begin{macrocode}
\def\CT@rowc{%
\@ifnextchar[\CT@rowd{\ifnum`{=0\fi}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@rowd}
% \begin{macrocode}
\def\CT@rowd[#1]{\@testopt{\CT@rowe[#1]}{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@rowe}
% \changes{v0.1h}{1998/05/06}
% {Fix typo in \cs{ifnum} (Robin F.)}
% \begin{macrocode}
\def\CT@rowe[#1][#2]{%
\@tempdimb#1%
\@tempdimc#2%
\xdef\CT@row@color{%
\expandafter\noexpand\CT@row@color
\@tempdimb\the\@tempdimb
\@tempdimc\the\@tempdimc
\relax}%
\ifnum0=`{\fi}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ifxempty}
% \marg{arg}\marg{empty}\marg{non-empty}\\
% Tests without expanding, whether the argument \marg{arg} is empty and executes the following code accordingly; \marg{arg} must not start with the token "\XC@@".
% Can also be used within "\edef".
% \begin{macrocode}
\def\@ifxempty#1{\@@ifxempty#1\@@ifxempty\XC@@}
\def\@@ifxempty#1#2\XC@@
{\ifx#1\@@ifxempty
\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rowcolors}
% \begin{macro}{\rowcolors*}
% \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\
% Defines alternating colors for the next tabular environment.
% Starting with row \meta{row}, odd and even rows get their respective colors.
% The color arguments may also be left empty (= no color).
% Optional commands may be "hline" or "noalign"\marg{stuff}.
%
% In the starred version, \meta{commands} are ignored in rows with
% inactive rowcolors status (see below), whereas in the non-starred
% version, \meta{commands} are applied to every row of the
% table.
% \begin{macrocode}
\def\rowcolors
{\@ifstar{\@rowcmdfalse\rowc@lors}{\@rowcmdtrue\rowc@lors}}
% \end{macrocode}
%
% \begin{macrocode}
\def\rowc@lors{\@testopt{\rowc@l@rs}{}}
% \end{macrocode}
%
% \begin{macrocode}
\def\rowc@l@rs[#1]#2#3#4%
{\global\rownum=\z@
\global\@rowcolorstrue
\@ifxempty{#3}%
{\def\@oddrowcolor{\@norowcolor}}%
{\def\@oddrowcolor{\gdef\CT@row@color{\CT@color{#3}}}}%
\@ifxempty{#4}%
{\def\@evenrowcolor{\@norowcolor}}%
{\def\@evenrowcolor{\gdef\CT@row@color{\CT@color{#4}}}}%
\if@rowcmd
\def\@rowcolors
{#1\if@rowcolors
\noalign{\relax\ifnum\rownum<#2\@norowcolor\else
\ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi\fi}%
\fi}%
\else
\def\@rowcolors
{\if@rowcolors
\ifnum\rownum<#2\noalign{\@norowcolor}\else
#1\noalign{\ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi}\fi
\fi}%
\fi
\CT@everycr{\@rowc@lors\the\everycr}%
\ignorespaces}
% \end{macrocode}
%
% \begin{macrocode}
\def\@rowc@lors{\noalign{\global\advance\rownum\@ne}\@rowcolors}
\let\@rowcolors\@empty
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\showrowcolors}
% \begin{macro}{\hiderowcolors}
% Switch coloring mode on/off.
% \begin{macrocode}
\def\showrowcolors{\noalign{\global\@rowcolorstrue}\@rowcolors}
\def\hiderowcolors{\noalign{\global\@rowcolorsfalse\@norowcolor}}
\def\@norowcolor{\global\let\CT@row@color\relax}
\@norowcolor
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@rowcolors}
% \begin{macro}{\if@rowcmd}
% \begin{macrocode}
\newif\if@rowcolors
\newif\if@rowcmd
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rownum}
% \begin{macro}{\c@rownum}
% Reserve a counter register. Also alias as a \LaTeX\ counter
% (but not via "\newcounter" as should not be in the reset list.)
% \begin{macrocode}
\@ifundefined{rownum}{%
\@ifundefined{c@rownum}%
{\newcount\rownum\let\c@rownum\rownum}%
{\let\rownum\c@rownum}%
}%
{\let\c@rownum\rownum}
\providecommand\therownum{\arabic{rownum}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\cellcolor}
% "\cellcolor" applies the specified color to just its own tabular cell.
% It is defined robust, but without using "\DeclareRobustCommand" or
% "\newcommand{}[][]" because those forms are not used elsewhere, and
% would not work in \emph{very} old \LaTeX.
% \begin{macrocode}
\edef\cellcolor{\noexpand\protect
\expandafter\noexpand\csname cellcolor \endcsname}
\@namedef{cellcolor }{%
\@ifnextchar[{\CT@cellc\@firstofone}{\CT@cellc\@gobble[]}%
}
\def\CT@cellc#1[#2]#3{%
\expandafter\gdef\expandafter\CT@cell@color\expandafter{%
\expandafter\CT@color#1{[#2]}{#3}%
\global\let\CT@cell@color\relax
}}
\global\let\CT@cell@color\relax
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DC@endright}
% \textsf{dcolumn} support. the "D" column sometimes internally converts
% a "c" column to an "r" one by squashing the supplied glue. This is bad
% news for this package, so redefine it to add negative glue to one
% side and positive to the other to keep the total added zero.
% \begin{macrocode}
\AtBeginDocument{%
\def\@tempa{$\hfil\egroup\box\z@\box\tw@}%
\ifx\@tempa\DC@endright
% \end{macrocode}
%
% New version of \textsf{dcolumn}, only want to fudge it
% in the "D{.}{.}{3}" case, not the new "D{.}{.}{3.3}" possibility.
% "\hfill" has already been inserted, so need to remove 1fill's worth
% of stretch.
% \begin{macrocode}
\def\DC@endright{%
$\hfil\egroup
\ifx\DC@rl\bgroup
\hskip\stretch{-.5}\box\z@\box\tw@\hskip\stretch{-.5}%
\else
\box\z@\box\tw@
\fi}%
\else
\def\@tempa{$\hfil\egroup\hfill\box\z@\box\tw@}%
\ifx\@tempa\DC@endright
% \end{macrocode}
%
% Old \textsf{dcolumn} code.
% \begin{macrocode}
\def\DC@endright{%
$\hfil\egroup%
\hskip\stretch{.5}\box\z@\box\tw@\hskip\stretch{-.5}}%
\fi
\fi}
% \end{macrocode}
% \end{macro}
%
% hhline support (almost the whole package, repeated, sigh).
% \changes{v1.0a}{2012/02/13}{Several improvements (see test ct4)}
% \begin{macrocode}
\AtBeginDocument{%
\ifx\hhline\@undefined\else
\def\HH@box#1#2{\vbox{{%
\ifx\CT@drsc@\relax\else
\global\dimen\thr@@\tw@\arrayrulewidth
\global\advance\dimen\thr@@\doublerulesep
{\CT@drsc@
\hrule \@height\dimen\thr@@
\vskip-\dimen\thr@@}%
\fi
\CT@arc@
\hrule \@height \arrayrulewidth \@width #1
\vskip\doublerulesep
\hrule \@height \arrayrulewidth \@width #2}}}
% \end{macrocode}
%
% \begin{macrocode}
\def\HH@loop{%
\ifx\@tempb`\def\next##1{\the\toks@\cr}\else\let\next\HH@let
\ifx\@tempb|\if@tempswa
\ifx\CT@drsc@\relax
\HH@add{\hskip\doublerulesep}%
\else
\HH@add{{\CT@drsc@\vrule\@width\doublerulesep}}%
\fi
\fi\@tempswatrue
\HH@add{{\CT@arc@\vline}}\else
\ifx\@tempb:\if@tempswa
\ifx\CT@drsc@\relax
\HH@add{\hskip\doublerulesep}%
\else
\HH@add{{\CT@drsc@\vrule\@width\doublerulesep}}%
\fi
\fi\@tempswatrue
\HH@add{\@tempc\HH@box\arrayrulewidth\arrayrulewidth\@tempc}\else
\ifx\@tempb##\if@tempswa\HH@add{\hskip\doublerulesep}\fi\@tempswatrue
\HH@add{{\CT@arc@\vline\copy\@ne\@tempc\vline}}\else
\ifx\@tempb~\@tempswafalse
\if@firstamp\@firstampfalse\else\HH@add{&\omit}\fi
\ifx\CT@drsc@\relax
\HH@add{\hfil}\else
\HH@add{{%
\CT@drsc@\leaders\hrule\@height\HH@height\hfil}}%
\fi
\else
\ifx\@tempb-\@tempswafalse
\gdef\HH@height{\arrayrulewidth}%
\if@firstamp\@firstampfalse\else\HH@add{&\omit}\fi
\HH@add{{%
\CT@arc@\leaders\hrule\@height\arrayrulewidth\hfil}}%
\else
\ifx\@tempb=\@tempswafalse
\gdef\HH@height{\dimen\thr@@}%
\if@firstamp\@firstampfalse\else\HH@add{&\omit}\fi
\HH@add
{\rlap{\copy\@ne}\leaders\copy\@ne\hfil\llap{\copy\@ne}}\else
% \end{macrocode}
% \changes{v0.1f}{1996/10/10}
% {Remove backspacing for t and b in \cs{hhline}}
% Stop the backspacing for "t" and "b", it messes up the underlying
% color.
% \begin{macrocode}
\ifx\@tempb t\HH@add{%
\def\HH@height{\dimen\thr@@}%
\HH@box\doublerulesep\z@}\@tempswafalse\else
\ifx\@tempb b\HH@add{%
\def\HH@height{\dimen\thr@@}%
\HH@box\z@\doublerulesep}\@tempswafalse\else
\ifx\@tempb>\def\next##1##2{%
\HH@add{%
{\baselineskip\p@\relax
##2%
\global\setbox\@ne\HH@box\doublerulesep\doublerulesep}}%
\HH@let!}\else
\ifx\@tempb\@sptoken\let\next\HH@spacelet\else
\PackageWarning{hhline}%
{\meaning\@tempb\space ignored in \noexpand\hhline argument%
\MessageBreak}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
\next}
\lowercase{\def\HH@spacelet} {\futurelet\@tempb \HH@loop}
% \end{macrocode}
%
% \begin{macrocode}
\fi}
% \end{macrocode}
%
%
% longtable support.
% \begin{macrocode}
\AtBeginDocument{
\ifx\longtable\@undefined\else
\def\LT@@hline{%
\ifx\LT@next\hline
\global\let\LT@next\@gobble
\ifx\CT@drsc@\relax
\gdef\CT@LT@sep{%
\noalign{\penalty-\@medpenalty\vskip\doublerulesep}}%
\else
\gdef\CT@LT@sep{%
\multispan\LT@cols{%
\CT@drsc@\leaders\hrule\@height\doublerulesep\hfill}\cr}%
\fi
\else
\global\let\LT@next\empty
\gdef\CT@LT@sep{%
\noalign{\penalty-\@lowpenalty\vskip-\arrayrulewidth}}%
\fi
\ifnum0=`{\fi}%
\multispan\LT@cols
{\CT@arc@\leaders\hrule\@height\arrayrulewidth\hfill}\cr
\CT@LT@sep
\multispan\LT@cols
{\CT@arc@\leaders\hrule\@height\arrayrulewidth\hfill}\cr
\noalign{\penalty\@M}%
\LT@next}
\fi}
% \end{macrocode}
%
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \Finale
%
|