summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tabularray/tabularray.tex
blob: 1e5b4a104e8388a1618022148a9a33e871a17d0c (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
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
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
% -*- coding: utf-8 -*-
% !TEX program = lualatex
\documentclass[oneside]{book}
\usepackage[a4paper,margin=2.5cm]{geometry}

\usepackage{codehigh} % https://ctan.org/pkg/codehigh
\usepackage{tabularray}
\usepackage{array,multirow,amsmath}
\usepackage{chemmacros,environ}

\usepackage[firstpage=true]{background}
\backgroundsetup{contents={}}

\UseTblrLibrary{booktabs,diagbox,siunitx}

\usepackage{hyperref}
\hypersetup{
  colorlinks=true,
  urlcolor=blue3,
  linkcolor=blue3,
}

\usepackage{tcolorbox}
\tcbset{sharp corners, boxrule=0.5pt, colback=red9}

\usepackage{float}

\setcounter{tocdepth}{1}

\newcommand*{\K}[1]{\texttt{#1}}
\newcommand*{\V}[1]{\texttt{#1}}
\newcommand*{\None}{$\times$}

\NewTblrEnviron{newtblr}
\SetTblrOuter[newtblr]{long}
\SetTblrInner[newtblr]{
  hlines = {white}, column{1,2} = {co=1}, colsep = 5pt,
  row{odd} = {brown8}, row{even} = {gray8},
  row{1} = {fg=white, bg=purple2, font=\bfseries\sffamily},
}

\NewTblrEnviron{spectblr}
\SetTblrOuter[spectblr]{long}
\SetTblrInner[spectblr]{
  hlines = {white}, column{2} = {co=1}, colsep = 5pt,
  row{odd} = {brown8}, row{even} = {gray8},
  row{1} = {fg=white, bg=purple2, font=\bfseries\sffamily},
  rowhead = 1,
}

\newcommand{\mywarning}[1]{%
  \begin{tcolorbox}
  The interfaces in this #1 should be seen as
  \textcolor{red3}{\bfseries experimental}
  and are likely to change in future releases, if necessary.
  Don’t use them in important documents.
  \end{tcolorbox}
}

\renewcommand*{\thefootnote}{*}

\newcommand*{\myversion}{2021M}
\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}

\colorlet{highback}{azure9}
\CodeHigh{language=latex/table,style/main=highback,style/code=highback}
\NewCodeHighEnv{code}{style/main=gray9,style/code=gray9}
\NewCodeHighEnv{demo}{style/main=gray9,style/code=gray9,demo}

%\CodeHigh{lite}

\begin{document}

\savegeometry{standard}
\newgeometry{left=0pt,right=0pt}

\begin{titlepage}

\backgroundsetup{
  scale = 1,
  angle = 0,
  opacity = 1,
  %color = black,
  contents = {
    \begin{tblr}{
      width = \paperwidth, columns = {1}, rows= {4em},
      cell{odd}{odd} = {gray9}, cell{even}{even} = {gray9},
    }
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
      & & & & & & & & & & & & & & \\
    \end{tblr}
  }
}

\noindent
\begin{tblr}{
  colspec = {lX}, colsep = 12mm, hlines = {2pt, white},
  row{odd} = {azure8}, row{even} = {gray8},
  row{1} = {6em,azure2,fg=white,font=\LARGE\bfseries\sffamily},
  row{2-Z} = {3em,font=\Large},
}
  Tabularray & Typeset Tabulars and Arrays with \LaTeX3 \\
  Author     & Jianrui Lyu (tolvjr@163.com) \\
  Version    & \myversion\ (\the\year-\mylpad\month-\mylpad\day) \\
  Code       & \url{https://github.com/lvjr/tabularray} \\
  Code       & \url{https://bitbucket.org/lvjr/tabularray} \\
  Issue      & \url{https://github.com/lvjr/tabularray/issues} \\
  Forum      & \url{https://github.com/lvjr/tabularray/discussions} \\
\end{tblr}

\begin{codehigh}[boxsep=6mm]
\begin{tblr}{
  colspec = {lX}, colsep = 12mm, hlines = {2pt, white},
  row{odd} = {azure8}, row{even} = {gray8},
  row{1} = {6em,azure2,fg=white,font=\LARGE\bfseries\sffamily},
  row{2-Z} = {3em,font=\Large},
}
  Tabularray & Typeset Tabulars and Arrays with \LaTeX3 \\
  Author     & Jianrui Lyu (tolvjr@163.com) \\
  Version    & \myversion\ (\the\year-\mylpad\month-\mylpad\day) \\
  Code       & \url{https://github.com/lvjr/tabularray} \\
  Code       & \url{https://bitbucket.org/lvjr/tabularray} \\
  Issue      & \url{https://github.com/lvjr/tabularray/issues} \\
  Forum      & \url{https://github.com/lvjr/tabularray/discussions} \\
\end{tblr}
\end{codehigh}

\end{titlepage}

\loadgeometry{standard}

\tableofcontents

\chapter{Overview of Features}

\section{Vertical Space}

After loading \verb!tabularray! package in the preamble,
we can use \verb!tblr! environments to typeset tabulars and arrays.
The name \verb!tblr! is short for \verb!tabularray! or \verb!top-bottom-left-right!.
The following is our first example:

\begin{demo}
\begin{tabular}{lccr}
\hline
 Alpha   & Beta  & Gamma  & Delta \\
\hline
 Epsilon & Zeta  & Eta    & Theta \\
\hline
 Iota    & Kappa & Lambda & Mu    \\
\hline
\end{tabular}
\end{demo}

\begin{demohigh}
\begin{tblr}{lccr}
\hline
 Alpha   & Beta  & Gamma  & Delta \\
\hline
 Epsilon & Zeta  & Eta    & Theta \\
\hline
 Iota    & Kappa & Lambda & Mu    \\
\hline
\end{tblr}
\end{demohigh}

You may notice that there is extra space above and below the table rows with \verb!tblr! envirenment.
This space makes the table look better.
If you don't like it, you could use \verb!\SetTblrInner! command:

\begin{demohigh}
\SetTblrInner{rowsep=0pt}
\begin{tblr}{lccr}
\hline
 Alpha   & Beta  & Gamma  & Delta \\
\hline
 Epsilon & Zeta  & Eta    & Theta \\
\hline
 Iota    & Kappa & Lambda & Mu    \\
\hline
\end{tblr}
\end{demohigh} 

But in many cases, this rowsep is useful:

\begin{demo}
$\begin{array}{rrr}
\hline
 \dfrac{2}{3} &  \dfrac{2}{3} &  \dfrac{1}{3} \\
 \dfrac{2}{3} & -\dfrac{1}{3} & -\dfrac{2}{3} \\
 \dfrac{1}{3} & -\dfrac{2}{3} &  \dfrac{2}{3} \\
\hline
\end{array}$
\end{demo}

\begin{demohigh}
$\begin{tblr}{rrr}
\hline
 \dfrac{2}{3} &  \dfrac{2}{3} &  \dfrac{1}{3} \\
 \dfrac{2}{3} & -\dfrac{1}{3} & -\dfrac{2}{3} \\
 \dfrac{1}{3} & -\dfrac{2}{3} &  \dfrac{2}{3} \\
\hline
\end{tblr}$
\end{demohigh}

Note that you can use \verb!tblr! in both text and math modes.

\section{Multiline Cells}

It's quite easy to write multiline cells without fixing the column width in \verb!tblr! environments:
just enclose the cell text with braces and use \verb!\\! to break lines:

\begin{demohigh}
\begin{tblr}{|l|c|r|}
\hline
 Left & {Center \\ Cent \\ C} & {Right \\ R} \\
\hline
 {L \\ Left} & {C \\ Cent \\ Center} & R \\
\hline
\end{tblr}
\end{demohigh} 

\section{Cell Alignment}

From time to time,
you may want to specify the horizontal and vertical alignment of cells at the same time.
\verb!Tabularray! package provides a \verb!Q! column for this
(In fact, \verb!Q! column is the only primitive column,
other columns are defined as \verb!Q! columns with some options):

\begin{demohigh}
\begin{tblr}{|Q[l,t]|Q[c,m]|Q[r,b]|}
\hline
 {Top Baseline \\ Left Left} & Middle Center & {Right Right \\ Bottom Baseline} \\
\hline
\end{tblr}
\end{demohigh} 

Note that you can use more meaningful \verb!t! instead of \verb!p! for top baseline alignment.
For some users who are familiar with word processors,
these \verb!t! and \verb!b! columns are counter-intuitive.
In \verb!tabularray! package, there are another two column types \verb!h! and \verb!f!,
which will align cell text at the head and the foot, respectively:

\begin{demohigh}
\begin{tblr}{Q[h,4em]Q[t,4em]Q[m,4em]Q[b,4em]Q[f,4em]}
\hline
 {row\\head} & {top\\line} & {middle} & {line\\bottom} & {row\\foot} \\
\hline
 {row\\head} & {top\\line} & {11\\22\\mid\\44\\55} & {line\\bottom} & {row\\foot} \\
\hline
\end{tblr}
\end{demohigh}

\section{Multirow Cells}

The above \verb!h! and \verb!f! alignments are necessary
when we write multirow cells with \verb!\SetCell! command in \verb!tabularray!.

\begin{demo}
\begin{tabular}{|l|l|l|l|}
\hline
 \multirow[t]{4}{1.5cm}{Multirow Cell One} & Alpha &
 \multirow[b]{4}{1.5cm}{Multirow Cell Two} & Alpha \\
 & Beta  & & Beta \\
 & Gamma & & Gamma \\
 & Delta & & Delta \\
\hline
\end{tabular}
\end{demo}

\begin{demohigh}
\begin{tblr}{|l|l|l|l|}
\hline
 \SetCell[r=4]{h,1.5cm} Multirow Cell One & Alpha &
 \SetCell[r=4]{f,1.5cm} Multirow Cell Two & Alpha \\
 & Beta  & & Beta \\
 & Gamma & & Gamma \\
 & Delta & & Delta \\
\hline
\end{tblr}
\end{demohigh}

Note that you don't need to load \verb!multirow! package first,
since \verb!tabularray! doesn't depend on it.
Furthermore, \verb!tabularray! will always typeset decent multirow cells.
First, it will set correct vertical middle alignment,
even though some rows have large height:

\begin{demo}
\begin{tabular}{|l|m{4em}|}
\hline
 \multirow[c]{4}{1.5cm}{Multirow} & Alpha  \\
 & Beta  \\
 & Gamma \\
 & Delta Delta Delta \\
\hline
\end{tabular}
\end{demo}

\begin{demohigh}
\begin{tblr}{|l|m{4em}|}
\hline
 \SetCell[r=4]{m,1.5cm} Multirow & Alpha  \\
 & Beta  \\
 & Gamma \\
 & Delta Delta Delta \\
\hline
\end{tblr}
\end{demohigh}

Second, it will enlarge row heights if the multirow cells have large height,
therefore it always avoids vertical overflow:

\begin{demo}
\begin{tabular}{|l|m{4em}|}
\hline
 \multirow[c]{2}{1cm}{Line \\ Line \\ Line \\ Line} & Alpha \\
\cline{2-2}
 & Beta \\
\hline
\end{tabular}
\end{demo}

\begin{demohigh}
\begin{tblr}{|l|m{4em}|}
\hline
 \SetCell[r=2]{m,1cm} {Line \\ Line \\ Line \\ Line} & Alpha \\
\cline{2}
 & Beta \\
\hline
\end{tblr}
\end{demohigh}

\section{Multi Rows and Columns}

It was a hard job to typeset cells with multiple rows and multiple columns. For example:

\begin{demo}
\begin{tabular}{|c|c|c|c|c|}
\hline
 \multirow{2}{*}{2 Rows}
     & \multicolumn{2}{c|}{2 Columns}
                 & \multicolumn{2}{c|}{\multirow{2}{*}{2 Rows 2 Columns}} \\
\cline{2-3}
     & 2-2 & 2-3 & \multicolumn{2}{c|}{} \\
\hline
 3-1 & 3-2 & 3-3 & 3-4 & 3-5 \\
\hline
\end{tabular}
\end{demo}

With \verb!tabularray! package, you can set spanned cells with \verb!\SetCell! command:
within the optional argument of \verb!\SetCell! command,
option \verb!r! is for rowspan number, and \verb!c! for colspan number;
within the mandatory argument of it, horizontal and vertical alignment options are accepted.
Therefore it's much simpler to typeset spanned cells:

\begin{demohigh}
\begin{tblr}{|c|c|c|c|c|}
\hline
 \SetCell[r=2]{c} 2 Rows
     & \SetCell[c=2]{c} 2 Columns
           &     & \SetCell[r=2,c=2]{c} 2 Rows 2 Columns & \\
\hline
     & 2-2 & 2-3 &     &     \\
\hline
 3-1 & 3-2 & 3-3 & 3-4 & 3-5 \\
\hline
\end{tblr}
\end{demohigh}

Using \verb!\multicolumn! command, the omitted cells \textcolor{red3}{must} be removed.
On the contrary,
using \verb!\multirow! command, the omitted cells \textcolor{red3}{must not} be removed.
\verb!\SetCell! command behaves the same as \verb!\multirow! command in this aspect.

With \verb!tblr! environment, any \verb!\hline! segments inside a spanned cell will be ignored,
therefore we're free to use \verb!\hline! in the above example.
Also, any omitted cell will definitely be ignored when typesetting,
no matter it's empty or not.
With this feature, we could put row and column numbers into the omitted cells,
which will help us to locate cells when the tables are rather complex:

\begin{demohigh}
\begin{tblr}{|ll|c|rr|}
\hline
 \SetCell[r=3,c=2]{h} r=3 c=2 & 1-2 & \SetCell[r=2,c=3]{r} r=2 c=3 & 1-4 & 1-5 \\ 
 2-1 & 2-2 & 2-3 & 2-4 & 2-5 \\
\hline
 3-1 & 3-2 & MIDDLE & \SetCell[r=3,c=2]{f} r=3 c=2 & 3-5 \\
\hline
 \SetCell[r=2,c=3]{l} r=2 c=3 & 4-2 & 4-3 & 4-4 & 4-5 \\
 5-1 & 5-2 & 5-3 & 5-4 & 5-5 \\
\hline
\end{tblr}
\end{demohigh}

\section{Column Types}

\verb!Tabularray! package supports all normal column types, as well as
the extendable \verb!X! column type,
which first occurred in \verb!tabularx! package and was largely improved by \verb!tabu! package:

\begin{demohigh}
\begin{tblr}{|X[2,l]|X[3,l]|X[1,r]|X[r]|}
\hline
 Alpha & Beta & Gamma & Delta \\
\hline
\end{tblr}
\end{demohigh}

Also, \verb!X! columns with negative coefficients are possible:

\begin{demohigh}
\begin{tblr}{|X[2,l]|X[3,l]|X[-1,r]|X[r]|}
\hline
 Alpha & Beta & Gamma & Delta \\
\hline
\end{tblr}
\end{demohigh}

We need the width to typeset a table with \verb!X! columns.
If unset, the default is \verb!\linewidth!.
To change the width, we have to first put all column specifications into \verb!colspec={...}!:

\begin{demohigh}
\begin{tblr}{width=0.8\linewidth,colspec={|X[2,l]|X[3,l]|X[-1,r]|X[r]|}}
\hline
 Alpha & Beta & Gamma & Delta \\
\hline
\end{tblr}
\end{demohigh}

You can define new column types with \verb!\NewColumnType! command.
For example, in \verb!tabularray! package,
\verb!b! and \verb!X! columns are defined as special \verb!Q! columns:
\begin{codehigh}
\NewColumnType{b}[1]{Q[b,wd=#1]}
\NewColumnType{X}[1][]{Q[co=1,#1]}
\end{codehigh}

\section{Row Types}

Now that we have column types and \verb!colspec! option,
you may ask for row types and \verb!rowspec! option.
Yes, they are here:

\begin{demohigh}
\begin{tblr}{colspec={Q[l]Q[c]Q[r]},rowspec={|Q[t]|Q[m]|Q[b]|}}
 {Alpha \\ Alpha} & Beta               & Gamma \\
 Delta            & Epsilon            & {Zeta \\ Zeta}  \\
 Eta              & {Theta \\ Theta}   & Iota  \\
\end{tblr}
\end{demohigh}

Same as column types, \verb!Q! is the only primitive row type,
and other row types are defined as \verb!Q! types with different options.
It's better to specify horizontal alignment in \verb!colspec!,
and vertical alignment in \verb!rowspec!, respectively.

Inside \verb!rowspec!, \verb!|! is the hline type.
Therefore we need not to write \verb!\hline! commnad, which makes table code cleaner.

\section{Hlines and Vlines}

Hlines and vlines have been improved too. You can specify the widths and styles of them:

\begin{demohigh}
\begin{tblr}{|l|[dotted]|[2pt]c|r|[solid]|[dashed]|}
\hline
One   &  Two  & Three \\
\hline\hline[dotted]\hline
Four  & Five  &   Six \\
\hline[dashed]\hline[1pt]
Seven & Eight &  Nine \\
\hline
\end{tblr}
\end{demohigh}

\section{Colorful Tables}

To add colors to your tables, you need to load \verb!xcolor! package first.
\verb!Tabularray! package will also load \verb!ninecolors! package for proper color contrast.
First you can specify background option for \verb!Q! rows/columns inside \verb!rowspec!/\verb!colspec!:

\begin{demohigh}
\begin{tblr}{colspec={lcr},rowspec={|Q[cyan7]|Q[azure7]|Q[blue7]|}}
 Alpha   & Beta  & Gamma  \\
 Epsilon & Zeta  & Eta    \\
 Iota    & Kappa & Lambda \\
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{colspec={Q[l,brown7]Q[c,yellow7]Q[r,olive7]},rowspec={|Q|Q|Q|}}
 Alpha   & Beta  & Gamma  \\
 Epsilon & Zeta  & Eta    \\
 Iota    & Kappa & Lambda \\
\end{tblr}
\end{demohigh}

Also you can use \verb!\SetRow! or \verb!\SetColumn! command to specify row or column colors:

\begin{demohigh}
\begin{tblr}{colspec={lcr},rowspec={|Q|Q|Q|}}
 \SetRow{cyan7}  Alpha   & Beta  & Gamma  \\
 \SetRow{azure7} Epsilon & Zeta  & Eta    \\
 \SetRow{blue7}  Iota    & Kappa & Lambda \\
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{colspec={lcr},rowspec={|Q|Q|Q|}}
 \SetColumn{brown7}
 Alpha          & \SetColumn{yellow7}
                  Beta            & \SetColumn{olive7}
                                    Gamma  \\
 Epsilon        & Zeta            & Eta    \\
 Iota           & Kappa           & Lambda \\
\end{tblr}
\end{demohigh}

Hlines and vlines can also have colors:

\begin{demohigh}
\begin{tblr}{colspec={lcr},rowspec={|[2pt,green7]Q|[teal7]Q|[green7]Q|[3pt,teal7]}}
 Alpha   & Beta  & Gamma  \\
 Epsilon & Zeta  & Eta    \\
 Iota    & Kappa & Lambda \\
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{colspec={|[2pt,violet5]l|[2pt,magenta5]c|[2pt,purple5]r|[2pt,red5]}}
 Alpha   & Beta  & Gamma  \\
 Epsilon & Zeta  & Eta    \\
 Iota    & Kappa & Lambda \\
\end{tblr}
\end{demohigh}

\chapter{Basic Interfaces}

\section{Old and New Interfaces}

With \verb!tabularray! package, you can change the styles of tables via old interfaces or new interfaces.

The old interfaces consist of some table commands inside the table contents.
Same as \verb!tabular! and \verb!array! environments,
all table commands \textcolor{red3}{must} be put at the beginning ot the cell text.
Also, new table commands \textcolor{red3}{must} be defined with \verb!\NewTableCommand!.

The new interfaces consist of some options inside the mandatory argument,
hence totally separating the styles and the contents of tables.

\begin{newtblr}[
  caption = {Old Interfaces and New Interfaces},
  label = {key:interface},
]{verb}
  Old Interfaces                                 & New Interfaces          \\
  \verb!\SetHlines!                              & \K{hlines}              \\
  \verb!\SetHline!, \verb!\hline!, \verb!\cline! & \K{hline}, \K{rowspec}  \\
  \verb!\SetVlines!                              & \K{vlines}              \\
  \verb!\SetVline!, \verb!\vline!, \verb!\rline! & \K{vline}, \K{colspec}  \\
  \verb!\SetCells!                               & \K{cells}               \\
  \verb!\SetCell!                                & \K{cell}                \\
  \verb!\SetRows!                                & \K{rows}                \\
  \verb!\SetRow!                                 & \K{row}, \K{rowspec}    \\
  \verb!\SetColumns!                             & \K{columns}             \\
  \verb!\SetColumn!                              & \K{column}, \K{colspec} \\
\end{newtblr}

\section{Hlines and Vlines}

All available keys for hlines and vlines are described in Table \ref{key:hvline}.

\begin{spectblr}[
  caption = {Keys for Hlines and Vlines},
  label = {key:hvline},
  remark{Note} = {In most cases, you can omit the underlined key names and write only their values.}
]{}
  Key & Description and Values & Initial Value \\
  \underline{\K{dash}} & dash style: \V{solid}, \V{dashed} or \V{dotted} & \V{solid} \\
  \K{text}             & replace hline/vline with text (like \V{!} specifier in \K{colspec}) & \None \\
  \underline{\K{wd}}   & rule width dimension & \None \\
  \underline{\K{fg}}   & rule color name & \None \\
\end{spectblr}

\subsection{Hlines and Vlines in New Interfaces}

Options \verb!hlines! and \verb!vlines! are for setting all hlines and vlines, respectively.
With empty value, all hlines/vlines will be solid.

\begin{demohigh}
\begin{tblr}{hlines,vlines}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
\end{tblr}
\end{demohigh}

With values inside one pair of braces, all hlines/vlines will be styled.

\begin{demohigh}
\begin{tblr}{
 hlines = {1pt,solid}, vlines = {red3,dashed},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
\end{tblr}
\end{demohigh}

Another pair of braces before will select segments in all hlines/vlines.

\begin{demohigh}
\begin{tblr}{
 vlines = {1,3,5}{dashed},
 vlines = {2,4,6}{solid},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

The above example can be simplified with \verb!odd! and \verb!even! values.
(More child selectors can be defined with \verb!\NewChildSelector! command.
Advanced users could read the source code for this.)

\begin{demohigh}
\begin{tblr}{
 vlines = {odd}{dashed},
 vlines = {even}{solid},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

Another pair of braces before will draw more hlines/vlines (in which \verb!-! stands for all line segments).

\begin{demohigh}
\begin{tblr}{
 hlines = {1}{-}{dashed}, hlines = {2}{-}{solid},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
\end{tblr}
\end{demohigh}

Options \verb!hline{i}! and \verb!vline{j}! are for setting some hlines and vlines, respectively.
Their values are the same as options \verb!hliness! and \verb!vlines!:

\begin{demohigh}
\begin{tblr}{
 hline{1,7} = {1pt,solid},
 hline{3-5} = {blue3,dashed},
 vline{1,5} = {3-4}{dotted},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

You can use \verb!X!, \verb!Y!, \verb!Z! to denote the last three childs, respectively.
It is especially useful when you are writing long tables:

\begin{demohigh}
\begin{tblr}{
 hline{1,Z} = {2pt},
 hline{2,Y} = {1pt},
 hline{3-X} = {dashed},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

Now we show the usage of \verb!text! key by the following example%
\footnote{Code from \url{https://tex.stackexchange.com/questions/603023/tabularray-and-tabularx-column-separator}.}:

\begin{demohigh}
\begin{tblr}{
  vlines, hlines,
  colspec = {lX[c]X[c]X[c]X[c]},
  vline{2} = {1}{text=\clap{:}},
  vline{3} = {1}{text=\clap{\ch{+}}},
  vline{4} = {1}{text=\clap{\ch{->}}},
  vline{5} = {1}{text=\clap{\ch{+}}},
}
  Equation & \ch{CH4} & \ch{2 O2} & \ch{CO2} & \ch{2 H2O} \\
  Initial  & $n_1$    & $n_2$     & 0        & 0 \\
  Final    & $n_1-x$  & $n_2-2x$  & $x$      & $2x$ \\
\end{tblr}
\end{demohigh}

You need to load \verb!chemmacros! package for the \verb!\ch! command.

\subsection{Hlines and Vlines in Old Interfaces}

The \verb!\hline! command has an optional argument which accepts key-value options.
The available keys are described in Table \ref{key:hvline}.

\begin{demohigh}
\begin{tblr}{llll}
\hline
 Alpha   & Beta  & Gamma  & Delta \\
\hline[dashed]
 Epsilon & Zeta  & Eta    & Theta \\
\hline[dotted]
 Iota    & Kappa & Lambda & Mu    \\
\hline[2pt,blue5]
\end{tblr}
\end{demohigh}

The \verb!\cline! command also has an optional argument which is the same as \verb!\hline!.

\begin{demohigh}
\begin{tblr}{llll}
\cline{1-4}
 Alpha   & Beta  & Gamma  & Delta \\
\cline[dashed]{1,3}
 Epsilon & Zeta  & Eta    & Theta \\
\cline[dashed]{2,4}
 Iota    & Kappa & Lambda & Mu    \\
\cline[2pt,blue5]{-}
\end{tblr}
\end{demohigh}

You can use child selectors in the mandatory argument of \verb!\cline!.

\begin{demohigh}
\begin{tblr}{llll}
\cline{1-4}
 Alpha   & Beta  & Gamma  & Delta \\
\cline[dashed]{odd}
 Epsilon & Zeta  & Eta    & Theta \\
\cline[dashed]{even}
 Iota    & Kappa & Lambda & Mu    \\
\cline[2pt,blue5]{-}
\end{tblr}
\end{demohigh}

Commands \verb!\SetHline! combines the usages of \verb!\hline! and \verb!\cline!:
 
\begin{demohigh}
\begin{tblr}{llll}
\SetHline{1-3}{blue5,1pt}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\SetHline{2-4}{teal5,1pt}
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{llll}
\SetHline[1]{1-3}{blue5,1pt}
\SetHline[2]{1-3}{azure5,1pt}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\SetHline[1]{2-4}{teal5,1pt}
\SetHline[2]{2-4}{green5,1pt}
\end{tblr}
\end{demohigh}

In fact, table command \verb!\SetHline[<index>]{<columns>}{<styles>}! at the beginning of row \verb!i!
is the same as table option \verb!hline{i}={<index>}{<columns>}{<styles>}!.

Also, table command \verb!\SetHlines[<index>]{<columns>}{<styles>}! at the beginning of some row
is the same as table option \verb!hlines={<index>}{<columns>}{<styles>}!.

The usages of table commands \verb!\vline!, \verb!\rline!, \verb!\SetVline!, \verb!\SetVlines!
are similar to those of \verb!\hline!, \verb!\cline!, \verb!\SetHline!, \verb!\SetHlines!, respectively.
But normally you don't need to use them.

\section{Cells and Spancells}

All available keys for cells are described in Table \ref{key:cell} and Table \ref{key:cellspan}.

\begin{spectblr}[
  caption = {Keys for the Content of Cells},
  label = {key:cell},
  remark{Note} = {In most cases, you can omit the underlined key names and write only their values.}
]{}
  Key & Description and Values & Initial Value \\
  \underline{\K{halign}}
    & horizontal alignment: \V{l} (left), \V{c} (center), or \V{r} (right)
    & \V{l} \\
  \underline{\K{valign}}
    & vertical alignment: \V{t} (top), \V{m} (middle), \V{b} (bottom),
      \V{h} (head) or \V{f} (foot)
    & \V{t} \\
  \underline{\K{wd}} & width dimension & \None \\
  \underline{\K{bg}} & background color name & \None \\
  \K{fg}    & foreground color name & \None \\
  \K{font}  & font commands & \None \\
  \K{preto} & prepend text to the cell & \None \\
  \K{appto} & append text to the cell & \None \\
  \K{cmd}   & execute command for the cell text & \None \\
\end{spectblr}
\vspace{-2em}
\begin{spectblr}[
  caption = {Keys for Multispan of Cells},
  label = {key:cellspan},
]{}
  Key & Description and Values & Initial Value \\
  \K{r} & number of rows the cell spans    & 1 \\
  \K{c} & number of columns the cell spans & 1 \\
\end{spectblr}

\subsection{Cells and Spancells in New Interfaces}

Option \verb!cells! is for setting all cells.
\nopagebreak
\begin{demohigh}
\begin{tblr}{hlines={white},cells={c,blue7}}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
\end{tblr}
\end{demohigh}

Option \verb!cell{i}{j}! is for setting some cells.

\begin{demohigh}
\begin{tblr}{
 hlines = {white},
 vlines = {white},
 cell{1,6}{odd} = {teal7},
 cell{1,6}{even} = {green7},
 cell{2,4}{1,4} = {red7},
 cell{3,5}{1,4} = {purple7},
 cell{2}{2} = {r=4,c=2}{c,azure7},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

\subsection{Cells and Spancells in Old Interfaces}

The \verb!\SetCell! command has a mandatory argument for setting the styles of current cell.
The available keys are described in Table \ref{key:cell}.

\begin{demohigh}
\begin{tblr}{llll}
\hline[1pt]
 Alpha   & \SetCell{bg=teal2,fg=white} Beta & Gamma \\
\hline
 Epsilon & Zeta & \SetCell{r,font=\scshape} Eta \\
\hline
 Iota    & Kappa & Lambda \\
\hline[1pt]
\end{tblr}
\end{demohigh}

The \verb!\SetCell! command also has an optional argument for setting the multispan of current cell.
The available keys are described in Table \ref{key:cellspan}.

\begin{demohigh}
\begin{tblr}{|X|X|X|X|X|X|}
\hline
 Alpha & Beta & Gamma & Delta & Epsilon & Zeta \\
\hline
 \SetCell[c=2]{c} Eta & 2-2
              & \SetCell[c=2]{c} Iota & 2-4
                              & \SetCell[c=2]{c} Lambda  & 2-6 \\
\hline
 \SetCell[c=3]{c} Nu & 3-2 & 3-3
                      & \SetCell[c=3]{c} Pi & 3-5 & 3-6   \\
\hline
 \SetCell[c=6]{c} Tau & 4-2 & 4-3 & 4-4 & 4-5 & 4-6 \\
\hline
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{|X|X|X|X|X|X|}
\hline
 Alpha & Beta    & Gamma   & Delta & Epsilon & Zeta \\
\hline
 \SetCell[r=2]{m} Eta
       & Theta   & Iota    & Kappa & Lambda  & \SetCell[r=2]{m} Mu  \\
\hline
 Nu    & Xi      & Omicron & Pi    & Rho     & Sigma \\
\hline
\end{tblr}
\end{demohigh}

In fact, table command \verb!\SetCell[<span>]{<styles>}! at the beginning of cell at row \verb!i!
and column \verb!j! is the same as table option \verb!cell{i}{j}={<span>}{<styles>}!.

Also, table command \verb!\SetCells[<span>]{<styles>}! at the beginning of some cell
is the same as table option \verb!cells={<span>}{<styles>}!.

\section{Rows and Columns}

All available keys for rows and columns are described in Table \ref{key:row} and Table \ref{key:column}.

\begin{spectblr}[
  caption = {Keys for Rows},
  label = {key:row},
  remark{Note} = {In most cases, you can omit the underlined key names and write only their values.}
]{}
  Key & Description and Values & Initial Value \\
  \underline{\K{halign}}
    & horizontal alignment: \V{l} (left), \V{c} (center), or \V{r} (right)
    & \V{l} \\
  \underline{\K{valign}}
    & vertical alignment: \V{t} (top), \V{m} (middle), \V{b} (bottom),
      \V{h} (head) or \V{f} (foot)
    & \V{t} \\
  \underline{\K{ht}} & height dimension & \None \\
  \underline{\K{bg}} & background color name & \None \\
  \K{fg} & foreground color name & \None \\
  \K{font} & font commands & \None \\
  \K{abovesep} & set vertical space above the row & \V{2pt} \\
  \K{abovesep+} & increase vertical space above the row & \None \\
  \K{belowsep} & set vertical space below the row & \V{2pt} \\
  \K{belowsep+} & increase vertical space below the row & \None \\
  \K{rowsep} & set vertical space above and below the row & \V{2pt} \\
  \K{rowsep+} & increase vertical space above and below the row & \None \\
  \K{preto} & prepend text to every cell (like \V{>} specifier in \K{rowspec}) & \None \\
  \K{appto} & append text to every cell (like \V{<} specifier in \K{rowspec}) & \None \\
  \K{cmd}   & execute command for every cell text & \None \\
\end{spectblr}
\vspace{-2em}
\begin{spectblr}[
  caption = {Keys for Columns},
  label = {key:column},
  remark{Note} = {In most cases, you can omit the underlined key names and write only their values.}
]{}
  Key & Description and Values & Initial Value \\
  \underline{\K{halign}}
    & horizontal alignment: \V{l} (left), \V{c} (center), or \V{r} (right)
    & \V{l} \\
  \underline{\K{valign}}
    & vertical alignment: \V{t} (top), \V{m} (middle), \V{b} (bottom),
      \V{h} (head) or \V{f} (foot)
    & \V{t} \\
  \underline{\K{wd}} & width dimension & \None \\
  \underline{\K{co}} & coefficient for the extendable column (\V{X} column) & \None \\
  \underline{\K{bg}} & background color name & \None \\
  \K{fg} & foreground color name & \None \\
  \K{font} & font commands & \None \\
  \K{leftsep} & set horizontal space to the left of the column & \V{6pt} \\
  \K{leftsep+} & increase horizontal space to the left of the column & \None \\
  \K{rightsep} & set horizontal space to the right of the column & \V{6pt} \\
  \K{rightsep+} & increase horizontal space to the right of the column & \None \\
  \K{colsep} & set horizontal space to both sides of the column & \V{6pt} \\
  \K{colsep+} & increase horizontal space to both sides of the column & \None \\
  \K{preto} & prepend text to every cell (like \V{>} specifier in \K{colspec}) & \None \\
  \K{appto} & append text to every cell (like \V{<} specifier in \K{colspec}) & \None \\
  \K{cmd}   & execute command for every cell text & \None \\
\end{spectblr}

\subsection{Rows and Columns in New Interfaces}

Options \verb!rows! and \verb!columns! are for setting all rows and columns, respectively.
\nopagebreak
\begin{demohigh}
\begin{tblr}{
 hlines, vlines,
 rows = {7mm}, columns = {15mm,c},
}
 Alpha   & Beta  & Gamma   & Delta \\
 Epsilon & Zeta  & Eta     & Theta \\
 Iota    & Kappa & Lambda  & Mu    \\
\end{tblr}
\end{demohigh}

Options \verb!row{i}! and \verb!column{j}! are for setting some rows and columns, respectively.

\begin{demohigh}
\begin{tblr}{
 hlines = {1pt,white},
 row{odd} = {blue7},
 row{even} = {azure7},
 column{1} = {purple7,c},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

The following example demonstrates the usages of \verb!bg!, \verb!fg! and \verb!font! keys.
\nopagebreak
\begin{demohigh}
\begin{tblr}{
 row{odd} = {bg=azure8},
 row{1}   = {bg=azure3, fg=white, font=\sffamily},
}
 Alpha & Beta    & Gamma \\
 Delta & Epsilon & Zeta  \\
 Eta   & Theta   & Iota  \\
 Kappa & Lambda  & Mu    \\
 Nu Xi Omicron & Pi Rho Sigma & Tau Upsilon Phi \\
\end{tblr}
\end{demohigh}

The following example demonstrates the usages of
\verb!abovesep!, \verb!belowsep!, \verb!leftsep!, \verb!rightsep! keys.
%\nopagebreak
\begin{demohigh}
\begin{tblr}{
 hlines, vlines,
 rows = {abovesep=1pt,belowsep=5pt},
 columns = {leftsep=1pt,rightsep=5pt},
}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{tblr}
\end{demohigh}

The following example shows that we can replace \verb!\\[dimen]! with \verb!belowsep+! key.

\begin{demohigh}
\begin{tblr}{
 hlines, row{2} = {belowsep+=5pt},
}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{tblr}
\end{demohigh}

\subsection{Rows and Columns in Old Interfaces}

The \verb!\SetRow! command has a mandatory argument for setting the styles of current row.
The available keys are described in Table \ref{key:row}.

\begin{demohigh}
\begin{tblr}{llll}
\hline[1pt]
 \SetRow{azure8} Alpha & Beta & Gamma & Delta \\
\hline
 \SetRow{blue8,c} Epsilon & Zeta & Eta & Theta \\
\hline
 \SetRow{violet8} Iota & Kappa & Lambda & Mu \\
\hline[1pt]
\end{tblr}
\end{demohigh}

In fact, table command \verb!\SetRow{<styles>}! at the beginning of row \verb!i!
is the same as table option \verb!row{i}={<styles>}!.

Also, table command \verb!\SetRows{<styles>}! at the beginning of some row
is the same as table option \verb!rows={<styles>}!.

The usages of table commands \verb!\SetColumn! and \verb!\SetColumns!
are similar to those of \verb!\SetRow! and \verb!\SetRows!, respectively.
But normally you don't need to use them.

\section{Colspec and Rowspec}

Options \verb!colspec!/\verb!rowspec! are for setting column/row specifications
with column/row type specifiers.

\subsection{Colspec and Width}

Option \verb!width! are for setting the width of the table with extendable columns.
The following example demonstrates the usage of \verb!width! option.
\nopagebreak
\begin{demohigh}
\begin{tblr}{width=0.8\textwidth, colspec={|l|X[2]|X[3]|X[-1]|}}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{tblr}
\end{demohigh}

\subsection{Column Types}

The \verb!tabularray! package has only one type of primitive column: the \verb!Q! column.
Other types of columns are defined as \verb!Q! columns with some keys.

\begin{codehigh}
\NewColumnType{l}{Q[l]}
\NewColumnType{c}{Q[c]}
\NewColumnType{r}{Q[r]}
\NewColumnType{t}[1]{Q[t,wd=#1]}
\NewColumnType{m}[1]{Q[m,wd=#1]}
\NewColumnType{b}[1]{Q[b,wd=#1]}
\NewColumnType{h}[1]{Q[h,wd=#1]}
\NewColumnType{f}[1]{Q[f,wd=#1]}
\NewColumnType{X}[1][]{Q[co=1,#1]}
\end{codehigh}

\begin{demohigh}
\begin{tblr}{|t{15mm}|m{15mm}|b{20mm}|}
 Alpha   & Beta  & {Gamma\\Gamma} \\
 Epsilon & Zeta  & {Eta\\Eta} \\
 Iota    & Kappa & {Lambda\\Lambda} \\
\end{tblr}
\end{demohigh}

Any new column type must be defined with \verb!\NewColumnType! command.
It can have an optional argument when it's defined.

\subsection{Row Types}

The \verb!tabularray! package has only one type of primitive row: the \verb!Q! row.
Other types of rows are defined as \verb!Q! rows with some keys.

\begin{codehigh}
\NewRowType{l}{Q[l]}
\NewRowType{c}{Q[c]}
\NewRowType{r}{Q[r]}
\NewRowType{t}[1]{Q[t,ht=#1]}
\NewRowType{m}[1]{Q[m,ht=#1]}
\NewRowType{b}[1]{Q[b,ht=#1]}
\NewRowType{h}[1]{Q[h,ht=#1]}
\NewRowType{f}[1]{Q[f,ht=#1]}
\end{codehigh}

\begin{demohigh}
\begin{tblr}{rowspec={|t{12mm}|m{10mm}|b{10mm}|}}
 Alpha   & Beta  & {Gamma\\Gamma} \\
 Epsilon & Zeta  & {Eta\\Eta} \\
 Iota    & Kappa & {Lambda\\Lambda} \\
\end{tblr}
\end{demohigh}

Any new row type must be defined with \verb!\NewRowType! command.
It can have an optional argument when it's defined.

\chapter{Extra Interfaces}

\section{Table Specifications}

All available keys for the whole table are described in Table \ref{key:table}.

\begin{spectblr}[
  caption = {Keys for the Whole Table},
  label = {key:table},
]{}
  Key & Description and Values & Initial Value \\
  \K{rulesep} & space between two hlines or vlines & \V{2pt} \\
  \K{stretch} & stretch ratio for struts added to cell text & \V{1} \\
  \K{abovesep} & set vertical space above every row & \V{2pt} \\
  \K{belowsep} & set vertical space below every row & \V{2pt} \\
  \K{rowsep} & set vertical space above and below every row & \V{2pt} \\
  \K{leftsep} & set horizontal space to the left of every column & \V{6pt} \\
  \K{rightsep} & set horizontal space to the right of every column & \V{6pt} \\
  \K{colsep} & set horizontal space to both sides of every column & \V{6pt} \\
  \K{hspan} & horizontal span algorithm: \V{default}, \V{even}, or \V{minimal} & \V{default} \\
  \K{vspan} & vertical span algorithm: \V{default} or \V{even} & \V{default} \\
\end{spectblr}

The following example shows that we can replace \verb!\doublerulesep! parameter with \verb!rulesep! key.
\nopagebreak
\begin{demohigh}
\begin{tblr}{
 colspec={||llll||},rowspec={|QQQ|},rulesep=4pt,
}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{tblr}
\end{demohigh}

The following example shows that we can replace \verb!\arraystretch! parameter with \verb!stretch! key.

\begin{demohigh}
\begin{tblr}{hlines,stretch=1.5}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{tblr}
\end{demohigh}

The following example uses \verb!rowsep! and \verb!colsep! keys to set padding for all rows and columns.
\nopagebreak
\begin{demohigh}
\SetTblrInner{rowsep=2pt,colsep=2pt}
\begin{tblr}{hlines,vlines}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{tblr}
\end{demohigh}

With \verb!hspan=default! or \verb!hspan=even!,
\verb!tabularray! package will compute column widths from span widths.
But with \verb!hspan=minimal!, it will compute span widths from column widths.
The following examples show the results from different \verb!hspan! values.

\begin{demohigh}
\SetTblrInner{hlines, vlines, hspan=default}
\begin{tblr}{cell{2}{1}={c=2}{l},cell{3}{1}={c=3}{l},cell{4}{2}={c=2}{l}}
 111 111 & 222 222 & 333 333 \\
 12 Multi Columns Multi Columns 12 & & 333 \\
 13 Multi Columns Multi Columns Multi Columns 13 & & \\
 111 & 23 Multi Columns Multi Columns 23 & \\
\end{tblr}
\end{demohigh}

\begin{demohigh}
\SetTblrInner{hlines, vlines, hspan=even}
\begin{tblr}{cell{2}{1}={c=2}{l},cell{3}{1}={c=3}{l},cell{4}{2}={c=2}{l}}
 111 111 & 222 222 & 333 333 \\
 12 Multi Columns Multi Columns 12 & & 333 \\
 13 Multi Columns Multi Columns Multi Columns 13 & & \\
 111 & 23 Multi Columns Multi Columns 23 & \\
\end{tblr}
\end{demohigh}

\begin{demohigh}
\SetTblrInner{hlines, vlines, hspan=minimal}
\begin{tblr}{cell{2}{1}={c=2}{l},cell{3}{1}={c=3}{l},cell{4}{2}={c=2}{l}}
 111 111 & 222 222 & 333 333 \\
 12 Multi Columns Multi Columns 12 & & 333 \\
 13 Multi Columns Multi Columns Multi Columns 13 & & \\
 111 & 23 Multi Columns Multi Columns 23 & \\
\end{tblr}
\end{demohigh}

The following examples show the results from different \verb!vspan! values.
\nopagebreak
\begin{demohigh}
\SetTblrInner{hlines, vlines, vspan=default}
\begin{tblr}{column{2}={3.25cm}, cell{2}{2}={r=3}{l}}
  Column1 & Column2 \\
  Row1 & Long text that needs multiple lines.
         Long text that needs multiple lines.
         Long text that needs multiple lines. \\
  Row2 & \\
  Row3 & \\
  Row4 & Short text \\
\end{tblr}
\end{demohigh}

\begin{demohigh}
\SetTblrInner{hlines, vlines, vspan=even}
\begin{tblr}{column{2}={3.25cm}, cell{2}{2}={r=3}{l}}
  Column1 & Column2 \\
  Row1 & Long text that needs multiple lines.
         Long text that needs multiple lines.
         Long text that needs multiple lines. \\
  Row2 & \\
  Row3 & \\
  Row4 & Short text \\
\end{tblr}
\end{demohigh}

\section{Default Specifications}

\verb!Tabularray! package provides \verb!\SetTblrInner! and \verb!\SetTblrOuter! commands
for you to change the default inner and outer specifications of tables.
Inner specifications are all specifications written in the mandatory argument of the \verb!tblr! environment,
while outer specifications are all specifications written in the optional argument of the \verb!tblr! environment.
At this time, most of the outer specifications are used for long tables (see Chapter \ref{chap:long}).

In the below example, the first line draws all hlines and vlines for all tables created afterwards,
while the second line makes all tables created afterwards vertically align at bottom.

\begin{codehigh}
\SetTblrInner{hlines,vlines}
\SetTblrOuter{valign=b}
\end{codehigh}

You can define new \verb!tabularray! environments using \verb!\NewTblrEnviron! command:

\begin{demohigh}
\NewTblrEnviron{mytblr}
\SetTblrInner[mytblr]{hlines,vlines}
\SetTblrOuter[mytblr]{valign=b}
Text \begin{mytblr}{cccc}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{mytblr} Text
\end{demohigh}

If not giving the optional argument to \verb!\SetTblrInner! or \verb!\SetTblrOuter! command,
we set the default specifications for \verb!tblr! environment.
And different tabularray environments could have different default specifications.

\section{New Table Commands}

All commands which change the specifications of tables \textcolor{red3}{must} be defined with \verb!\NewTableCommand!.
The following example demonstrates how to define a new table command:

\begin{demohigh}
\NewTableCommand\myhline{\hline[0.1em,red5]}
\begin{tblr}{llll}
\myhline
 Alpha   & Beta  & Gamma   & Delta \\
 Epsilon & Zeta  & Eta     & Theta \\
 Iota    & Kappa & Lambda  & Mu    \\
\myhline
\end{tblr}
\end{demohigh}

\section{Expand Macros First}

\verb!Tabularray! need to see every \verb!&! and \verb!\\! when splitting the table body
with \verb!l3regex!. And you can not put cell text inside any table command defined with
\verb!\NewTableCommand!. But you could use outer specification \verb!expand! to make \verb!tabularray!
expand every occurrence of a specified macro \underline{once} before splitting the table body:

\begin{demohigh}
\def\tblrbody{
 \hline
  20 & 30 & 40 \\
  50 & 60 & 70 \\
 \hline
}
\begin{tblr}[expand=\tblrbody]{ccc}
 \hline
  AA & BB & CC \\
  \tblrbody
  DD & EE & FF \\
  \tblrbody
  GG & HH & II \\
 \hline
\end{tblr}
\end{demohigh}

With this \verb!expand! option, you can also use \verb!environ! package
to define a new environment based on \verb!tblr! environment:

\begin{demohigh}
\NewEnviron{fancytblr}{
 Before Text
 \begin{tblr}[expand=\BODY]{hlines}
   \BODY
 \end{tblr}
 After Text
}
\begin{fancytblr}
  One   & Two   & Three \\
  Four  & Five  & Six   \\
  Seven & Eight & Nine  \\
\end{fancytblr}
\end{demohigh}

\section{Use Verbatim Commands}

With inner specification \verb!verb!, you can write \verb!\verb! commands in the cell text:

\begin{demohigh}
\begin{tblr}{hlines,verb}
  20 & 30 & \verb!\hello{world}!40 \\
  50 & \verb!\hello!60 & 70 \\
\end{tblr}
\end{demohigh}

\section{Counters and Lengths}

Counters \verb!rownum!, \verb!colnum!, \verb!rowcount!, \verb!colcount! can be used in cell text:
\nopagebreak
\begin{demohigh}
\begin{tblr}{hlines}
 Cell[\arabic{rownum}][\arabic{colnum}] & Cell[\arabic{rownum}][\arabic{colnum}] &
 Cell[\arabic{rownum}][\arabic{colnum}] & Cell[\arabic{rownum}][\arabic{colnum}] \\
 Row=\arabic{rowcount}, Col=\arabic{colcount} &
 Row=\arabic{rowcount}, Col=\arabic{colcount} &
 Row=\arabic{rowcount}, Col=\arabic{colcount} &
 Row=\arabic{rowcount}, Col=\arabic{colcount} \\
 Cell[\arabic{rownum}][\arabic{colnum}] & Cell[\arabic{rownum}][\arabic{colnum}] &
 Cell[\arabic{rownum}][\arabic{colnum}] & Cell[\arabic{rownum}][\arabic{colnum}] \\
\end{tblr}
\end{demohigh}

Also, lengths \verb!\leftsep!, \verb!\rightsep!, \verb!\abovesep!, \verb!\belowsep! can be used in cell text.

\section{Tracing Tabularray}

To trace internal data behind \verb!tblr! environment, you can use \verb!\SetTblrTracing! command.
For example, \verb!\SetTblrTracing{all}! will turn on all tracings,
and \verb!\SetTblrTracing{none}! will turn off all tracings.
\verb!\SetTblrTracing{+row,+column}! will only tracing row and column data.
All tracing messages will be written to the log files.

\chapter{Use Long Tables}
\label{chap:long}

\mywarning{chapter}

\section{A Simple Example}

In fact, to make a decent long table with header and footer, it is better to separate header/footer as
\underline{table head/foot} (which includes caption, footnotes, continuation text)
and \underline{row head/foot} (which includes some rows of the table that should appear in every page).
By this approach, alternating row colors should work as expected.

\NewTblrTheme{fancy}{
  \SetTblrStyle{firsthead}{font=\bfseries}
  \SetTblrStyle{firstfoot}{fg=blue2}
  \SetTblrStyle{middlefoot}{\itshape}
  \SetTblrStyle{caption-tag}{red2}
}
\begin{longtblr}[
  theme = fancy,
  caption = {A Long Long Long Long Long Long Long Table},
  entry = {Short Caption},
  label = {tblr:test},
  note{a} = {It is the first footnote.},
  note{$\dag$} = {It is the second long long long long long long footnote.},
  remark{Note} = {Some general note. Some general note. Some general note.},
  remark{Source} = {Made up by myself. Made up by myself. Made up by myself.},
]{
  colspec = {XXX}, width = 0.85\linewidth,
  rowhead = 2, rowfoot = 1,
  row{odd} = {gray9}, row{even} = {brown9},
  row{1-2} = {purple7}, row{Z} = {blue7},
}
\hline
 Head    & Head  & Head    \\
\hline
 Head    & Head  & Head    \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta\TblrNote{a}       & Eta    \\
\hline
 Iota    & Kappa\TblrNote{$\dag$} & Lambda \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
%\hline
% Alpha   & Beta  & Gamma   \\
%\hline
% Epsilon & Zeta  & Eta     \\
%\hline
% Iota    & Kappa & Lambda  \\
%\hline
% Nu      & Xi    & Omicron \\
%\hline
% Rho     & Sigma & Tau     \\
%\hline
% Phi     & Chi   & Psi     \\
\hline
 Foot    & Foot  & Foot    \\
\hline
\end{longtblr}

As you can see in the above example, the appearance of long tables of \verb!tabularray! package
is similar to that of \verb!threeparttable! and \verb!threeparttablex! packages.
We support table footnotes, but not page footnotes in \verb!tabularray! package.

\newpage

The source code for the above long table is shown below. It is mainly self-explanatory.

\begin{codehigh}
\NewTblrTheme{fancy}{
  \SetTblrStyle{firsthead}{font=\bfseries}
  \SetTblrStyle{firstfoot}{fg=blue2}
  \SetTblrStyle{middlefoot}{\itshape}
  \SetTblrStyle{caption-tag}{red2}
}
\begin{longtblr}[
  theme = fancy,
  caption = {A Long Long Long Long Long Long Long Table},
  entry = {Short Caption},
  label = {tblr:test},
  note{a} = {It is the first footnote.},
  note{$\dag$} = {It is the second long long long long long long footnote.},
  remark{Note} = {Some general note. Some general note. Some general note.},
  remark{Source} = {Made up by myself. Made up by myself. Made up by myself.},
]{
  colspec = {XXX}, width = 0.85\linewidth,
  rowhead = 2, rowfoot = 1,
  row{odd} = {gray9}, row{even} = {brown9},
  row{1-2} = {purple7}, row{Z} = {blue7},
}
\hline
 Head    & Head  & Head    \\
\hline
 Head    & Head  & Head    \\
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta\TblrNote{a}       & Eta    \\
\hline
 Iota    & Kappa\TblrNote{$\dag$} & Lambda \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
......
\hline
 Alpha   & Beta  & Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Foot    & Foot  & Foot    \\
\hline
\end{longtblr}
\end{codehigh}

As you can see in the above code, we typeset long tables with \verb!longtblr! environemnt.
And we can totally separate contents and styles of long tables with \verb!tabularray! package.

Row head and row foot consist of some lines of the table and should appear in every page.
Their options are inner specifications and should be put in the mandatory argument of the \verb!longtblr! environment.
In the above example, We set \verb!rowhead=2! and \verb!rowfoot=1!.

\begin{spectblr}[
  caption = {Inner Specifications for Row Heads and Row Foots}
]{}
  Key Nama    & Key Description & Initial Value \\
  \V{rowhead} & number of the first rows of the table appear in every page & \V{0} \\
  \V{rowfoot} & number of the last rows of the table appear in every page  & \V{0} \\
\end{spectblr}

Table head and table foot consist of the caption, continuation text, footnotes and remarks.
Their options are outer specifications and should be put in the optional argument of the \verb!longtblr! environment.

\begin{spectblr}[
  caption = {Outer Specifications for Table Heads and Table Foots}
]{verb}
  Key Nama            & Key Description & Initial Value \\
  \V{headsep}         & vertical space between table head and table body & \V{6pt} \\
  \V{footsep}         & vertical space between table foot and table body & \V{6pt} \\
  \V{presep}          & vertical space between table head and the above text & \verb!1.5\bigskipamount! \\
  \V{postsep}         & vertical space between table foot and the below text & \verb!1.5\bigskipamount! \\
  \V{theme}           & table theme (including settings for templates and styles) & \None \\
  \V{caption}         & table caption & \None \\
  \V{entry}           & short table caption to be put in List of Tables & \None \\
  \V{label}           & table label & \None \\
  \V{note\{<name>\}}   & table note with \V{<name>} as tag & \None \\
  \V{remark\{<name>\}} & table remark with \V{<name>} as tag & \None \\
\end{spectblr}

If you write \verb!entry=none!, \verb!tabularray! package will not add an entry in List of Tables.
Therefore \verb!caption=text,entry=none! is similar to \verb!\caption[]{text}! in \verb!longtable!.

If you write \verb!label=none!, \verb!tabularray! package will not step \verb!table! counter,
and set the \verb!caption-tag! and \verb!caption-sep! elements (see below) to empty.
Therefore \verb!caption=text,entry=none,label=none! is similar to \verb!\caption*{text}!
in \verb!longtable!, except for the counter.

\section{Customize Templates}

\subsection{Overview of Templates}

The template system for table heads and table foots in \verb!tabularray! is largely inspired
by \verb!beamer!, \verb!caption! and \verb!longtable! packages. For elements in Table \ref{tblr:element},
you can use \verb!\DefTblrTemplate! to define and modify templates,
and use \verb!\SetTblrTemplate! to choose default templates. In defining templates,
you can include other templates with \verb!\UseTblrTemplate! and \verb!\ExpTblrTemplate! commands.

\begin{spectblr}[
  caption = {Elements for Table Heads and Table Foots},
  label = {tblr:element},
]{}
  Element Name     & Element Description and Default Template \\
  \V{contfoot-text}& continuation text in the foot, normally ``Continued on next page'' \\
  \V{contfoot}     & continuation paragraph in the foot, normally including \V{contfoot-text} template \\
  \V{conthead-text}& continuation text in the head, normally ``(Continued)'' \\
  \V{conthead}     & continuation paragraph in the head, normally including \V{conthead-text} template \\
  \V{caption-tag}  & caption tag, normally like ``Table 4.2'' \\
  \V{caption-sep}  & caption separator, normally like ``:\quad'' \\
  \V{caption-text} & caption text, normally using user provided value \\
  \V{caption}      & including \V{caption-tag} + \V{caption-sep} + \V{caption-text} \\
  \V{note-tag}     & note tag, normally using user provided value \\
  \V{note-sep}     & note separator, normally like ``\enskip'' \\
  \V{note-text}    & note tag, normally using user provided value \\
  \V{note}         & including \V{note-tag} + \V{note-sep} + \V{note-text} \\
  \V{remark-tag}   & remark tag, normally using user provided value \\
  \V{remark-sep}   & remark separator, normally like ``:\enskip'' \\
  \V{remark-text}  & remark text, normally using user provided value\\
  \V{remark}       & including \V{remark-tag} + \V{remark-sep} + \V{remark-text} \\
  \V{firsthead}    & table head on the first page, normally including \V{caption} template \\
  \V{middlehead}   & table head on middle pages, normally including \V{caption} and \V{conthead} templates \\
  \V{lasthead}     & table head on the last page, normally including \V{caption} and \V{conthead} templates \\
  \V{head}         & setting all of \V{firsthead}, \V{middlehead} and \V{lasthead} \\
  \V{firstfoot}    & table foot on the first page, normally including \V{contfoot} template \\
  \V{middlefoot}   & table foot on middle pages, normally including \V{contfoot} template \\
  \V{lastfoot}     & table foot on the last page, normally including \V{note} and \V{remark} templates \\
  \V{foot}         & setting all of \V{firstfoot}, \V{middlefoot} and \V{lastfoot} \\
\end{spectblr}

An element which only includes short text is called a \underline{sub element}.
Normally there is one \verb!-! in the name of a sub element.
An element which includes one or more paragraphs is called a \underline{main element}.
Normally there isn't any \verb!-! in the name of a main element.

For each of the above elements, two templates \verb!normal! and \verb!empty! are always defined.
You can select one of them with \verb!\SetTblrTemplate! command.

\subsection{Continuation Templates}

Let us have a look at the code for defining templates of continuation text first:

\begin{codehigh}
\DefTblrTemplate{contfoot-text}{normal}{Continued on next page}
\SetTblrTemplate{contfoot-text}{normal}
\DefTblrTemplate{conthead-text}{normal}{(Continued)}
\SetTblrTemplate{conthead-text}{normal}
\end{codehigh}

In the above code, command \verb!\DefTblrTemplate! defines the templates with name \verb!normal!,
and then command \verb!\SetTblrTemplate! sets the templates with name \verb!normal! as default.
The \verb!normal! template is always defined and set as default for any element in \verb!tabularray!.
Therefore you had better use another name when defining new templates.

If you use \verb!default! as template name in \verb!\DefTblrTemplate!,
you define and set it as default at the same time.
Therefore the above code can be written in another way:

\begin{codehigh}
\DefTblrTemplate{contfoot-text}{default}{Continued on next page}
\DefTblrTemplate{conthead-text}{default}{(Continued)}
\end{codehigh}

You may modify the code to customize continuation text to fit your needs.

The templates for \verb!contfoot! and \verb!conthead! normally
include the templates of their sub elements with \verb!\UseTblrTemplate! commands.
But you can also handle user settings such as horizontal alignment here.

\begin{codehigh}
\DefTblrTemplate{contfoot}{default}{\UseTblrTemplate{contfoot-text}{default}}
\DefTblrTemplate{conthead}{default}{\UseTblrTemplate{conthead-text}{default}}
\end{codehigh}

\subsection{Caption Templates}

Normally a caption consists of three parts, and their templates are defined with the follow code:

\begin{codehigh}
\DefTblrTemplate{caption-tag}{default}{Table\hspace{0.25em}\thetable}
\DefTblrTemplate{caption-sep}{default}{:\enskip}
\DefTblrTemplate{caption-text}{default}{\InsertTblrText{caption}}
\end{codehigh}

The command \verb!\InsertTblrText{caption}! inserts the value of \verb!caption! key,
which you could write in the optional argument of \verb!longtblr! environment.

The \verb!caption! template normally includes three sub templates with \verb!\UseTblrTemplate! commands:
The \verb!caption! template will be used in \verb!firsthead! template.

\begin{codehigh}
\DefTblrTemplate{caption}{default}{
  \UseTblrTemplate{caption-tag}{default}
  \UseTblrTemplate{caption-sep}{default}
  \UseTblrTemplate{caption-text}{default}
}
\end{codehigh}

Furthermore \verb!capcont! template includes \verb!conthead! template as well.
The \verb!capcont! template will be used in \verb!middlehead! and \verb!lasthead! templates.

\begin{codehigh}
\DefTblrTemplate{capcont}{default}{
  \UseTblrTemplate{caption-tag}{default}
  \UseTblrTemplate{caption-sep}{default}
  \UseTblrTemplate{caption-text}{default}
  \UseTblrTemplate{conthead}{default}
}
\end{codehigh}

\subsection{Note and Remark Templates}

The templates for table notes can be defined like this:

\begin{codehigh}
\DefTblrTemplate{note-tag}{default}{\textsuperscript{\InsertTblrNoteTag}}
\DefTblrTemplate{note-sep}{default}{\space}
\DefTblrTemplate{note-text}{default}{\InsertTblrNoteText}
\end{codehigh}
\begin{codehigh}
\DefTblrTemplate{note}{default}{
  \MapTblrNotes{
    \noindent
    \UseTblrTemplate{note-tag}{default}
    \UseTblrTemplate{note-sep}{default}
    \UseTblrTemplate{note-text}{default}
    \par
  }
}
\end{codehigh}

The \verb!\MapTblrNotes! command loops for all table notes,
which are written in the optional argument of \verb!longtblr! environment.
Inside the loop, you can use \verb!\InsertTblrNoteTag! and \verb!\InsertTblrNoteText!
commands to insert current note tag and note text, respectively.

The definition of remark templates are similar to note templates.
\nopagebreak
\begin{codehigh}
\DefTblrTemplate{remark-tag}{default}{\InsertTblrRemarkTag}
\DefTblrTemplate{remark-sep}{default}{:\space}
\DefTblrTemplate{remark-text}{default}{\InsertTblrRemarkText}
\end{codehigh}
\begin{codehigh}
\DefTblrTemplate{remark}{default}{
  \MapTblrRemarks{
    \noindent
    \UseTblrTemplate{remark-tag}{default}
    \UseTblrTemplate{remark-sep}{default}
    \UseTblrTemplate{remark-text}{default}
    \par
  }
}
\end{codehigh}

\subsection{Head and Foot Templates}

The templates for table heads and foots are defined as including other templates:

\begin{codehigh}
\DefTblrTemplate{firsthead}{default}{
  \UseTblrTemplate{caption}{default}
}
\DefTblrTemplate{middlehead,lasthead}{default}{
  \UseTblrTemplate{capcont}{default}
}
\DefTblrTemplate{firstfoot,middlefoot}{default}{
  \UseTblrTemplate{contfoot}{default}
}
\DefTblrTemplate{lastfoot}{default}{
  \UseTblrTemplate{note}{default}
  \UseTblrTemplate{remark}{default}
}
\end{codehigh}

Note that you can define the same template for multiple elements in \verb!\DefTblrTemplate! command.

\section{Change Styles}

All available keys for template elements are described in Table \ref{key:element}.

\begin{spectblr}[
  caption = {Keys for the Styles of Elements},
  label = {key:element},
  remark{Note} = {In most cases, you can omit the underlined key names and write only their values.
                  The keys \K{halign}, \K{indent} and \K{hang} are only for main templates.}
]{}
  Key Name               & Key Description \\
  \underline{\K{fg}}     & foreground color \\
  \underline{\K{font}}   & font commands \\
  \underline{\K{halign}} & horizontal alignment: \V{l} (left), \V{c} (center), or \V{r} (right) \\
  \K{indent}             & parindent value \\
  \K{hang}               & hangindent value \\
\end{spectblr}

You may change the styles of elements with \verb!\SetTblrStyle! command:

\begin{codehigh}
\SetTblrStyle{firsthead}{font=\bfseries}
\SetTblrStyle{firstfoot}{fg=blue2}
\SetTblrStyle{middlefoot}{\itshape}
\SetTblrStyle{caption-tag}{red2}
\end{codehigh}

When you write \verb!\UseTblrTemplate{element}{default}! in defining a template,
beside including template code of the \verb!element!, the foreground color and font commands
of the \verb!element! will be set up automatically.
In contrast, \verb!\ExpTblrTemplate{element}{default}! will only include template code.

\section{Define Themes}

You may define your own themes for table heads and foots with \verb!\NewTblrTheme! command.
a theme consists of some template and style settings. For example:
\nopagebreak
\begin{codehigh}
\NewTblrTheme{fancy}{
  \DefTblrTemplate{conthead}{default}{[Continued]}
  \SetTblrStyle{firsthead}{font=\bfseries}
  \SetTblrStyle{firstfoot}{fg=blue2}
  \SetTblrStyle{middlefoot}{\itshape}
  \SetTblrStyle{caption-tag}{red2}
}
\end{codehigh}

After defining the theme \verb!fancy!, you can use it
by writing \verb!theme=fancy! in the optional argument of \verb!longtblr! environment.

\section{Control Page Breaks}

Just like \verb!longtable! package, inside \verb!longtblr! environment,
you can use \verb!\\*! or \verb!\nopagebreak! to prohibit a page break,
and use \verb!\pagebreak! to force a page break.

\section{Floatable Tall Tables}

There is also a \verb!talltblr! environment as an alternative to \verb!threeparttable! environment.
It can not cross multiple pages, but it can be put inside \verb!table! environment.

\begin{demohigh}
TEXT\begin{talltblr}[
  caption = {Long Long Long Long Tabular},
  entry = {Short Caption},
  label = {tblr:tall},
  note{a} = {It is the first footnote.},
  note{$\dag$} = {It is the second long long long long long long footnote.},
]{
  colspec = {XXX}, width = 0.5\linewidth, hlines,
}
  Alpha   & Beta  & Gamma \\
  Epsilon & Zeta  & Eta\TblrNote{a} \\
  Iota    & Kappa & Lambda\TblrNote{$\dag$} \\
\end{talltblr}TEXT
\end{demohigh}

\chapter{Use Some Libraries}

The \verb!tabularray! package emulates or fixes some commands in other packages.
To avoid potential conflict, you need to enable them with \verb!\UseTblrLibrary! command.

\section{Library \texttt{booktabs}}

When you write \verb!\UseTblrLibrary{booktabs}!,
\verb!tabularray! package will define commands \verb!\toprule!, \verb!\midrule!,
\verb!\bottomrule! and \verb!\cmidrule! inside \verb!tblr! environment.

\begin{demohigh}
\begin{tblr}{llll}
\toprule
 Alpha   & Beta  & Gamma   & Delta \\
\midrule
 Epsilon & Zeta  & Eta     & Theta \\
\cmidrule{1-3}
 Iota    & Kappa & Lambda  & Mu    \\
\cmidrule{2-4}
 Nu      & Xi    & Omicron & Pi    \\
\bottomrule
\end{tblr}
\end{demohigh}

At this moment, \verb!trim! options for \verb!\cmidrule! command are not supported.
(As a workaround, you may insert an empty column to separate two \verb!\cmidrule!'s.)
But rule colors are possible just like \verb!\hline! and \verb!\cline! commands.

\begin{demohigh}
\begin{tblr}{llll}
\toprule[purple3]
 Alpha   & Beta  & Gamma   & Delta \\
\midrule[blue3]
 Epsilon & Zeta  & Eta     & Theta \\
\cmidrule[azure3]{1-3}
 Iota    & Kappa & Lambda  & Mu    \\
\cmidrule[azure3]{2-4}
 Nu      & Xi    & Omicron & Pi    \\
\bottomrule[purple3]
\end{tblr}
\end{demohigh}

\section{Library \texttt{diagbox}}

When writing \verb!\UseTblrLibrary{diagbox}! in the preamble of the document,
\verb!tabularray! package loads \verb!diagbox! package,
and you can use \verb!\diagbox! and \verb!\diagboxthree! commands inside \verb!tblr! environment.

\begin{demohigh}
\begin{tblr}{hlines,vlines}
 \diagbox{Aa}{Pp} & Beta & Gamma \\
 Epsilon & Zeta  & Eta \\
 Iota    & Kappa & Lambda \\
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{hlines,vlines}
 \diagboxthree{Aa}{Pp}{Hh} & Beta & Gamma \\
 Epsilon & Zeta  & Eta \\
 Iota    & Kappa & Lambda \\
\end{tblr}
\end{demohigh}

You can also use \verb!\diagbox! and \verb!\diagboxthree! commands in math mode.
\nopagebreak
\begin{demohigh}
$\begin{tblr}{|c|cc|}
\hline
 \diagbox{X_1}{X_2} & 0 & 1 \\
\hline
  0 & 0.1 & 0.2 \\
  1 & 0.3 & 0.4 \\
\hline
\end{tblr}$
\end{demohigh}

\section{Library \texttt{siunitx}}

When writing \verb!\UseTblrLibrary{siunitx}! in the preamble of the document,
\verb!tabularray! package loads \verb!siunitx! package,
and defines \verb!S! column as \verb!Q! column with \verb!si! key.

\begin{demohigh}
\begin{tblr}{
  hlines, vlines,
  colspec={
    S[table-format=3.2]
    S[table-format=3.2]
    S[table-format=3.2]
  }
}
 {{{Head}}} & {{{Head}}} & {{{Head}}} \\
   111      &   111      &   111      \\
     2.1    &     2.2    &     2.3    \\
    33.11   &    33.22   &    33.33   \\
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{
  hlines, vlines,
  colspec={
    Q[si={table-format=3.2},c]
    Q[si={table-format=3.2},c]
    Q[si={table-format=3.2},c]
  }
}
 {{{Head}}} & {{{Head}}} & {{{Head}}} \\
   111      &   111      &   111      \\
     2.1    &     2.2    &     2.3    \\
    33.11   &    33.22   &    33.33   \\
\end{tblr}
\end{demohigh}

Note that you need to use \underline{triple} pairs of braces to guard non-numeric cells.

Also you must use \verb!l!, \verb!c! or \verb!r! to set horizontal alignment for non-numeric cells:

\begin{demohigh}
\begin{tblr}{
  hlines, vlines, columns={6em},
  colspec={
    Q[si={table-format=3.2,table-number-alignment=left},l,blue7]
    Q[si={table-format=3.2,table-number-alignment=center},c,teal7]
    Q[si={table-format=3.2,table-number-alignment=right},r,purple7]
  }
}
 {{{Head}}} & {{{Head}}} & {{{Head}}} \\
   111      &   111      &   111      \\
     2.1    &     2.2    &     2.3    \\
    33.11   &    33.22   &    33.33   \\
\end{tblr}
\end{demohigh}

Both \verb!S! and \verb!s! columns are supported. In fact, These two columns are defined as follows:
\begin{codehigh}
\NewColumnType{S}[1][]{Q[si={##1},c]}
\NewColumnType{s}[1][]{Q[si={##1},c,cmd=\TblrUnit]}
\end{codehigh}

\chapter{The Source Code}

%\CodeHigh{lite}
\dochighinput[language=latex/latex3]{tabularray.sty}

\end{document}