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
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
|
% \iffalse meta-comment
%
% Copyright (C) 2018-2022 by F. Pantigny
% -----------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
% http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% \fi
% \iffalse
\def\myfileversion{6.8a}
\def\myfiledate{2022/05/08}
%
%
%<*batchfile>
\begingroup
\input l3docstrip.tex
\keepsilent
\usedir{tex/latex/nicematrix}
\preamble
Copyright (C) 2018-2022 by F. Pantigny
-----------------------------------
This file may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
of this license or (at your option) any later version.
The latest version of this license is in:
http://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of LaTeX
version 2005/12/01 or later.
\endpreamble
\askforoverwritefalse
\endgroup
%</batchfile>
%
%<*driver>
\documentclass[dvipsnames]{l3doc}% dvipsnames is for xcolor (loaded by Tikz)
\VerbatimFootnotes
\usepackage{xltxtra}
\usepackage[xetex]{geometry}
\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}}
\usepackage{tikz}
\usetikzlibrary{fit,patterns,arrows.meta,decorations.pathmorphing}
\usepackage{nicematrix}
\usepackage{siunitx}
\usepackage{varwidth}
\usepackage[auto-lang=false]{lipsum}
\NewDocumentEnvironment {scope} {} {} {}
\def\interitem{\vspace{7mm plus 2 mm minus 3mm}}
\def\emphase{\bgroup\color{RoyalPurple}\let\next=}
\fvset{commandchars=\~\#\@,formatcom=\color{gray}}
\usepackage{titlesec}
\titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex}
\titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex}
\usepackage{footnotehyper}
\def\LetterAt{@}
\parindent 0pt
\skip \footins = 2 \bigskipamount
\EnableCrossrefs
\makeatletter
\ExplSyntaxOn
\DoNotIndex{\begin,\end}
\DoNotIndex{\c@iRow,\c@jCol,\theiRow,\thejCol}
\DoNotIndex{\pgfpicture,\endpgfpicture,\tikzpicture,\endtikzpicture}
\DoNotIndex{\pgfpoint,\pgfnode,\pgfnodealias,\pgfcoordinate}
\DoNotIndex{\pgf@x,\pgf@y}
\DoNotIndex{\int_add:Nn,\int_case:nnTF,\int_compare:nNnTF,\int_compare:nTF,
\int_compare_p:nNn,\int_decr:N,\int_eval:n,\int_add:Nn,\int_gdecr:N,\int_gincr:N
\int_gset:Nn,\int_gset_eq:NN,\int_gzero:N,\int_gzero_new:N,\int_if_odd:nTF,
\int_max:nn,\int_new:N,\int_set:Nn,\int_set_eq:NN,\int_step_inline:nnn,
\int_step_variable:nNn,\int_step_variable:nnNn,\int_sub:Nn,\int_use:N,\int_zero:N,
\int_zero_new:N,\g_tmpa_int,\l_tmpa_int,\l_tmpb_int}
\DoNotIndex{\dim_abs:n,\dim_add:Nn,\dim_compare:nNnTF,\dim_compare_p:nNn,
\dim_const:Nn,\dim_eval:n,\dim_gadd:Nn,\dim_gset:Nn,\dim_gset_eq:NN,
\dim_gset:Nn,\dim_gset_eq:NN,\dim_gsub:Nn,\dim_gzero_new:N,\dim_max:nn,
\dim_min:nn,\dim_new:N,\dim_ration:nn,\dim_set:Nn,\dim_set_eq:NN,\dim_sub:Nn,
\dim_use:N,\dim_zero:N,\dim_zero_new:N,\g_tmpa_dim,\l_tmpa_dim,\l_tmpb_dim,
\c_zero_dim}
\DoNotIndex{\cs_new_protected:Npn,\cs_new:Npn,\cs_set_eq:NN,
\cs_set_protected:Npn}
\DoNotIndex{\bool_if:NTF,\bool_new:N,\bool_set_false:N,\bool_set_true:N,\l_tmpa_bool}
\DoNotIndex{\group_begin:,\group_end:,\c_math_toggle_token}
\DoNotIndex{\tl_set:Nn,\l_tmpa_tl,\l_tmpb_tl}
\DoNotIndex{\tl_gput_left:Nn,\tl_gput_right:Nn}
\ExplSyntaxOff
\makeatother
\begin{document}
\DocInput{nicematrix.dtx}
\end{document}
%</driver>
% \fi
% \title{The package \pkg{nicematrix}\thanks{This document corresponds to the version~\myfileversion\space of \pkg{nicematrix},
% at the date of~\myfiledate.}} \author{F. Pantigny \\ \texttt{fpantigny@wanadoo.fr}}
%
% \hypersetup
% {
% pdfinfo =
% {
% Title = The package 'nicematrix' ,
% Subject = A LaTeX package ,
% Author = F. Pantigny
% }
% }
%
%
% \maketitle
%
% \begin{abstract}
% The LaTeX package \pkg{nicematrix} provides new environments similar to the
% classical environments |{tabular}|, |{array}| and |{matrix}| of \pkg{array}
% and \pkg{amsmath} but with extended features.
% \end{abstract}
%
% \vspace{1cm}
% \hspace{1cm}
% $\begin{bNiceArray}{cccc}[first-row,first-col,
% code-for-first-col=\color{blue}\scriptstyle,
% code-for-first-row=\color{blue}\scriptstyle,
% columns-width = auto]
% & C_1 & C_2 & \Cdots & C_n \\
% L_1 & a_{11} & a_{12} & \Cdots & a_{1n} \\
% L_2 & a_{21} & a_{22} & \Cdots & a_{2n} \\
% \Vdots & \Vdots & \Vdots & \Ddots & \Vdots\\
% L_n & a_{n1} & a_{n2} & \Cdots & a_{nn}
% \end{bNiceArray}$\hspace{2cm}
% \begin{NiceTabular}{lSSSS}[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
% \toprule
% \Block{2-1}{Product} & \multicolumn{3}{c}{dimensions (cm)} & \Block{2-1}{\rotate Price} \\
% \cmidrule(rl){2-4}
% & L & l & h \\
% \midrule
% small & 3 & 5.5 & 1 & 30 \\
% standard & 5.5 & 8 & 1.5 & 50.5 \\
% premium & 8.5 & 10.5 & 2 & 80 \\
% extra & 8.5 & 10 & 1.5 & 85.5 \\
% special & 12 & 12 & 0.5 & 70 \\
% \bottomrule
% \end{NiceTabular}
%
% \vspace{1cm}
% The package \pkg{nicematrix} is entirely contained in the file
% |nicematrix.sty|. This file may be put in the current directory or in a
% |texmf| tree. However, the best is to install \pkg{nicematrix} with a TeX
% distribution such as MiKTeX, TeX Live or MacTeX.
%
% \medskip
% \emph{Remark}: If you use LaTeX via Internet with, for example, Overleaf, you
% can upload the file |nicematrix.sty| in the repertory of your
% project in order to take full advantage of the latest version de
% \pkg{nicematrix}.\footnote{The latest version of the file
% |nicematrix.sty| may be downloaded from the \textsc{svn} server of
% TeXLive:\newline
% \small
% \url{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty}}
%
% \medskip
% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by
% the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller).
% \textsl{However, the file nicematrix.dtx of the present documentation should
% be compiled with XeLaTeX.}
%
% \medskip
% This package requires and \textbf{loads} the packages \pkg{l3keys2e},
% \pkg{array}, \pkg{amsmath}, \pkg{pgfcore} and the module \pkg{shapes} of
% \textsc{pgf} (\pkg{tikz}, which is a layer over \textsc{pgf} is \emph{not}
% loaded). The final user only has to load the package with
% |\usepackage{nicematrix}|.
%
% \medskip
% If you use TeX~Live as TeX distribution, you should note that TeX~Live 2020 at
% least is required by \pkg{nicematrix}.
%
% \medskip
% The idea of \pkg{nicematrix} is to create \textsc{pgf} nodes under the cells
% and the positions of the rules of the tabular created by \pkg{array} and to
% use these nodes to develop new features. As usual with \textsc{pgf}, the
% coordinates of these nodes are written in the |aux| to be used on the next
% compilation and that's why \pkg{nicematrix} may need \textbf{several
% compilations}.\footnote{If you use Overleaf, Overleaf will do automatically
% the right number of compilations.}
%
% \medskip
% Most features of \pkg{nicematrix} may be used without explicit use of
% \textsc{pgf} or Tikz (which, in fact, is not loaded by default).
%
% \medskip
% A command |\NiceMatrixOptions| is provided to fix the options (the
% scope of the options fixed by this command is the current TeX group: they are
% semi-global).
%
%
%
% \newpage
%
% \section{The environments of this package}
%
% The package \pkg{nicematrix} defines the following new environments.
%
% \medskip
% \begin{ttfamily}
% \setlength{\tabcolsep}{3mm}
% \begin{tabular}{llll}
% \{NiceTabular\} & \{NiceArray\} & \{NiceMatrix\} \\
% \{NiceTabular*\} & \{pNiceArray\} & \{pNiceMatrix\} \\
% \{NiceTabularX\} & \{bNiceArray\} & \{bNiceMatrix\} \\
% & \{BNiceArray\} & \{BNiceMatrix\} \\
% & \{vNiceArray\} & \{vNiceMatrix\} \\
% & \{VNiceArray\} & \{VNiceMatrix\}
% \end{tabular}
% \end{ttfamily}
%
% %
% \medskip
% The environments |{NiceArray}|, |{NiceTabular}| and |{NiceTabular*}| are
% similar to the environments |{array}|, |{tabular}| and |{tabular*}| of the
% package \pkg{array} (which is loaded by \pkg{nicematrix}).
%
% \medskip
% The environments |{pNiceArray}|, |{bNiceArray}|, etc. have no equivalent in
% \pkg{array}.
%
% \medskip
% The environments |{NiceMatrix}|, |{pNiceMatrix}|, etc. are similar to the
% corresponding environments of \pkg{amsmath} (which is loaded by
% \pkg{nicematrix}): |{matrix}|, |{pmatrix}|, etc.
%
% \medskip
% The environment |{NiceTabularX}| is similar to the environment |{tabularx}|
% from the eponymous package.\footnote{In fact, it's possible to use directly the
% |X| columns in the environment |{NiceTabular}| (and the required
% width for the tabular is fixed by the key |width|): cf. p.~\pageref{X-columns}}.
%
% \medskip
% \textbf{It's recommended to use primarily the classical environments and to use the
% environments of \pkg{nicematrix} only when some feature provided by these
% environments is used (this will save memory).}
%
% \medskip
% All the environments of the package \pkg{nicematrix} accept, between square
% brackets, an optional list of \textsl{key=value} pairs. \textbf{There must be
% no space before the opening bracket (|[|) of this list of options.}
%
%
% \section{The vertical space between the rows}
%
% \label{cell-space}
%
% It's well known that some rows of the arrays created by default with LaTeX
% are, by default, too close to each other. Here is a classical example.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% $\begin{pmatrix}
% \frac12 & -\frac12 \\
% \frac13 & \frac14 \\
% \end{pmatrix}$
% \end{BVerbatim}
% $\begin{pmatrix}
% \frac12 & -\frac12 \\
% \frac13 & \frac14 \\
% \end{pmatrix}$
%
% \bigskip
% Inspired by the package \pkg{cellspace} which deals with that problem, the
% package \pkg{nicematrix} provides two keys |cell-space-top-limit| and
% |cell-space-bottom-limit| similar to the parameters |\cellspacetoplimit| and
% |\cellspacebottomlimit| of \pkg{cellspace}.
%
% There is also a key |cell-space-limits| to set both parameters at once.
%
% The initial value of these parameters is $0$~pt in order to have for the
% environments of \pkg{nicematrix} the same behaviour as those of \pkg{array}
% and \pkg{amsmath}. However, a value of $1$~pt would probably be a good choice
% and we suggest to set them with |\NiceMatrixOptions|.\footnote{One should
% remark that these parameters apply also to the columns of type |S| of
% \pkg{siunitx} whereas the package \pkg{cellspace} is not able to act on such
% columns of type~|S|.}
%
% \medskip
% \begin{Verbatim}
% \NiceMatrixOptions{~emphase#cell-space-limits = 1pt@}
% \end{Verbatim}
%
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% $\begin{pNiceMatrix}
% \frac12 & -\frac12 \\
% \frac13 & \frac14 \\
% \end{pNiceMatrix}$
% \end{BVerbatim}
% \begin{scope}
% \NiceMatrixOptions{cell-space-limits = 1pt}
% $\begin{pNiceMatrix}
% \frac12 & -\frac12 \\
% \frac13 & \frac14 \\
% \end{pNiceMatrix}$
% \end{scope}
%
%
%
%
%
% \bigskip
% \section{The vertical position of the arrays}
%
% The package \pkg{nicematrix} provides a option |baseline| for the vertical
% position of the arrays. This option takes in as value an integer which is the
% number of the row on which the array will be aligned.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% $A = \begin{pNiceMatrix}[~emphase#baseline=2@]
% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
% 1 & 1 & 1 \\
% 1 & p & 1+p
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $A = \begin{pNiceMatrix}[baseline=2]
% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
% 1 & 1 & 1 \\
% 1 & p & 1+p
% \end{pNiceMatrix}$
%
%
% \medskip
% It's also possible to use the option |baseline| with one of the special values
% |t|, |c| or |b|. These letters may also be used absolutely like the option of
% the environments |{tabular}| and |{array}| of \pkg{array}. The initial value
% of |baseline| is~|c|.
%
%
% \medskip
% In the following example, we use the option |t| (equivalent to |baseline=t|)
% immediately after an |\item| of list. One should remark that the presence of a
% |\hline| at the beginning of the array doesn't prevent the alignment of the
% baseline with the baseline of the first row (with |{tabular}| or |{array}| of
% \pkg{array}, one must use |\firsthline|).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% \begin{enumerate}
% \item an item
% \smallskip
% \item \renewcommand{\arraystretch}{1.2}
% $\begin{NiceArray}~emphase#[t]@{lcccccc}
% \hline
% n & 0 & 1 & 2 & 3 & 4 & 5 \\
% u_n & 1 & 2 & 4 & 8 & 16 & 32
% \hline
% \end{NiceArray}$
% \end{enumerate}
% \end{BVerbatim}
% \begin{minipage}{5cm}
% \begin{enumerate}
% \item an item
% \smallskip
% \item \renewcommand{\arraystretch}{1.2}
% $\begin{NiceArray}[t]{lcccccc}
% \hline
% n & 0 & 1 & 2 & 3 & 4 & 5 \\
% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
% \hline
% \end{NiceArray}$
% \end{enumerate}
% \end{minipage}
%
% \medskip
% However, it's also possible to use the tools of
% \pkg{booktabs}\footnote{The extension \pkg{booktabs} is \emph{not} loaded
% by \pkg{nicematrix}.}: |\toprule|,
% |\bottomrule|, |\midrule|, etc.\par\nobreak
%
% \smallskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% \begin{enumerate}
% \item an item
% \smallskip
% \item
% $\begin{NiceArray}[t]{lcccccc}
% ~emphase#\toprule@
% n & 0 & 1 & 2 & 3 & 4 & 5 \\
% ~emphase#\midrule@
% u_n & 1 & 2 & 4 & 8 & 16 & 32
% ~emphase#\bottomrule@
% \end{NiceArray}$
% \end{enumerate}
% \end{BVerbatim}
% \begin{minipage}{5cm}
% \begin{enumerate}
% \item an item
% \smallskip
% \item
% $\begin{NiceArray}[t]{lcccccc}
% \toprule
% n & 0 & 1 & 2 & 3 & 4 & 5 \\
% \midrule
% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
% \bottomrule
% \end{NiceArray}$
% \end{enumerate}
% \end{minipage}
%
% \bigskip
% It's also possible to use the key |baseline| to align a matrix on an
% horizontal rule (drawn by |\hline|). In this aim, one should give the value
% |line-|\textsl{i} where \textsl{i} is the number of the row \emph{following} the
% horizontal rule.
%
% \smallskip
% \begin{Verbatim}
% \NiceMatrixOptions{cell-space-limits=1pt}
% \end{Verbatim}
%
% \smallskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% $A=\begin{pNiceArray}{cc|cc}~emphase#[baseline=line-3]@
% \dfrac1A & \dfrac1B & 0 & 0 \\
% \dfrac1C & \dfrac1D & 0 & 0 \\
% \hline
% 0 & 0 & A & B \\
% 0 & 0 & D & D \\
% \end{pNiceArray}$
% \end{BVerbatim}
% \begin{scope}
% \NiceMatrixOptions{cell-space-limits=1pt}
% \raisebox{-5mm}{$A=\begin{pNiceArray}{cc|cc}[baseline=line-3]
% \dfrac1A & \dfrac1B & 0 & 0 \\
% \dfrac1C & \dfrac1D & 0 & 0 \\
% \hline
% 0 & 0 & A & B \\
% 0 & 0 & D & D \\
% \end{pNiceArray}$}
% \end{scope}
%
%
% \section{The blocks}
% \label{Block}
%
% \subsection{General case}
%
% In the environments of \pkg{nicematrix}, it's possible to use the command
% |\Block| in order to place an element in the center of a rectangle of merged
% cells of the array.\footnote{The spaces after a command |\Block| are deleted.}
%
% The command |\Block| must be used in the upper leftmost cell of the array with
% two arguments.
%
% \begin{itemize}
% \item The first argument is the size of the block with the syntax
% $i$|-|$j$ where $i$ is the number of rows of the block and $j$ its number
% of columns.
%
% If this argument is empty, its default
% value is |1-1|. If the number of rows is not specified, or equal to |*|, the
% block extends until the last row (idem for the columns).
%
% \item The second argument is the content of the block. It's possible to use
% |\\| in that content to have a content on several lines. In |{NiceTabular}|,
% |{NiceTabular*}| and |{NiceTabularX}|, the content of the block is composed in
% text mode whereas, in the other environments, it is composed in math mode.
% \end{itemize}
%
%
% \interitem
% Here is an example of utilisation of the command |\Block| in mathematical matrices.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin]
% ~emphase#\Block{3-3}{A}@ & & & 0 \\
% & & & \Vdots \\
% & & & 0 \\
% \hline
% 0 & \Cdots& 0 & 0
% \end{bNiceArray}$
% \end{BVerbatim}
% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin]
% \Block{3-3}{A} & & & 0 \\
% & & & \Vdots \\
% & & & 0 \\
% \hline
% 0 & \Cdots& 0 & 0
% \end{bNiceArray}$
%
% \bigskip
% One may wish to raise the size of the ``$A$'' placed in the block of the
% previous example. Since this element is composed in math mode, it's not
% possible to use directly a command like |\large|, |\Large| and |\LARGE|.
% That's why the command |\Block| provides an option between angle brackets to
% specify some TeX code which will be inserted before the beginning of the
% math mode.\footnote{This argument between angular brackets may also be used to
% insert a command of font such as |\bfseries| when the command |\\| is used in
% the content of the block.}
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin]
% \Block{3-3}~emphase#<\Large>@{A} & & & 0 \\
% 0 & & & \Vdots \\
% & & & 0 \\
% \hline
% 0 & \Cdots& 0 & 0
% \end{bNiceArray}$
% \end{BVerbatim}
% \begin{scope}
% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin]
% \Block{3-3}<\Large>{A} & & & 0 \\
% & & & \Vdots \\
% & & & 0 \\
% \hline
% 0 & \Cdots& 0 & 0
% \end{bNiceArray}$
% \end{scope}
%
% \medskip
% It's possible to set the horizontal position of the block with one of the keys
% |l|, |c| and |r|.
%
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin]
% \Block~emphase#[r]@{3-3}<\LARGE>{A} & & & 0 \\
% & & & \Vdots \\
% & & & 0 \\
% \hline
% 0 & \Cdots& 0 & 0
% \end{bNiceArray}$
% \end{BVerbatim}
% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin]
% \Block[r]{3-3}<\LARGE>{A} & & & 0 \\
% & & & \Vdots \\
% & & & 0 \\
% \hline
% 0 & \Cdots& 0 & 0
% \end{bNiceArray}$
%
% \interitem
% In fact, the command |\Block| accepts as first optional argument (between
% square brackets) a list of couples \textsl{key=value}. The available keys are as
% follows:
% \begin{itemize}
% \item the keys |l|, |c| and |r| are used to fix the horizontal position of the
% content of the block, as explained previously;
% \item the key |fill| takes in as value a color and fills the block with that
% color;
% \item the key |draw| takes in as value a color and strokes the frame of the
% block with that color (the default value of that key is the current color of
% the rules of the array);
% \item the key |color| takes in as value a color and apply that color the
% content of the block but draws also the frame of the block with that color;
% \item the key |line-width| is the width (thickness) of the frame (this key
% should be used only when the key |draw| or the key |hvlines| is in force);
% \item the key |rounded-corners| requires rounded corners (for the frame drawn
% by |draw| and the shape drawn by |fill|) with a radius equal to the value of
% that key (the default value is 4~pt\footnote{This value is the initial value
% of the \emph{rounded corners} of Tikz.});
% \item the keys |t| and |b| fix the base line that will be given to the block
% when it has a multi-line content (the lines are separated by |\\|);
% \item the keys |hlines|, |vlines| and |hvlines| draw all the corresponding
% rules in the block;
% \item when the key |tikz| is used, the Tikz path corresponding of the
% rectangle which delimits the block is executed with Tikz\footnote{Tikz should
% be loaded (by default, \pkg{nicematrix} only loads \textsc{pgf}) and, if it's
% not, an error will be raised.} by using as options the value of that key
% |tikz| (which must be a list of keys allowed for a Tikz path). For examples,
% cf. p.~\pageref{tikz-key-examples};
% \item the key |name| provides a name to the rectangular Tikz node
% corresponding to the block; it's possible to use that name with Tikz in the
% |\CodeAfter| of the environment (cf.~p.~\pageref{code-after});
% \item \colorbox{yellow!50}{\textbf{New 6.5}}\enskip the key
% |respect-arraystretch| prevents the setting of |\arraystretch| to $1$ at the
% beginning of the block (which is the behaviour by default) ;
% \item the key |borders| provides the ability to draw only some borders of the
% blocks; the value of that key is a (comma-separated) list of elements covered
% by |left|, |right|, |top| and |bottom|;\newline
% \colorbox{yellow!50}{\textbf{Nouveau 6.7}}\enskip it's possible, in fact, in
% the list which is the value of the key |borders|, to add an entry of the form
% |tikz={|\textsl{list}|}| where \textsl{list} is a list of couples
% \textsl{key=value} of Tikz specifying the graphical characteristics of the
% lines that will be drawn (for an example, see p.~\pageref{dashed}).
% \end{itemize}
%
% \interitem
% {\bfseries One must remark that, by default, the commands |\Blocks| don't create space}.
% There is exception only for the blocks mono-row and the blocks mono-column as
% explained just below.
%
% \medskip
% In the following example, we have had to enlarge by hand the columns 2 and 3
% (with the construction |wc{...}| of \pkg{array}).
%
% \bigskip
% \begin{BVerbatim}
% \begin{NiceTabular}{cwc{2cm}wc{3cm}c}
% rose & tulip & daisy & dahlia \\
% violet
% & ~emphase#\Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}@
% ~emphase#{\LARGE Some beautiful flowers}@
% & & marigold \\
% iris & & & lis \\
% arum & periwinkle & forget-me-not & hyacinth
% \end{NiceTabular}
% \end{BVerbatim}
%
% \medskip
% \begin{center}
% \begin{NiceTabular}{cwc{2cm}wc{3cm}c}
% rose & tulip & daisy & dahlia \\
% violet & \Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}
% {\LARGE Some beautiful flowers} & & marigold \\
% iris & & & lis \\
% arum & periwinkle & forget-me-not & hyacinth
% \end{NiceTabular}
% \end{center}
%
% \subsection{The mono-column blocks}
%
% The mono-column blocks have a special behaviour.
%
% \begin{itemize}
% \item The natural width of the contents of these blocks is taken into account
% for the width of the current column.
%
% In the columns with a fixed width (columns |w{...}{...}|, |p{...}|, |b{...}|,
% |m{...}| and |X|), the content of the block is formatted as a paragraph of
% that width.
%
% \item The specification of the horizontal position provided by the type of
% column (|c|, |r| or |l|) is taken into account for the blocks.
%
% \item The specifications of font specified for the column by a construction
% |>{...}| in the preamble of the array are taken into account for the
% mono-column blocks of that column (this behaviour is probably expected).
% \end{itemize}
%
%
% \bigskip
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=12cm]
% \begin{NiceTabular}{~LetterAt{}>{\bfseries}lr~LetterAt{}} \hline
% \Block{2-1}{John} & 12 \\
% & 13 \\ \hline
% Steph & 8 \\ \hline
% \Block{3-1}{Sarah} & 18 \\
% & 17 \\
% & 15 \\ \hline
% Ashley & 20 \\ \hline
% Henry & 14 \\ \hline
% \Block{2-1}{Madison} & 15 \\
% & 19 \\ \hline
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{@{}>{\bfseries}lr@{}}[baseline=c] \hline
% \Block{2-1}{John} & 12 \\
% & 13 \\ \hline
% Steph & 8 \\ \hline
% \Block{3-1}{Sarah} & 18 \\
% & 17 \\
% & 15 \\ \hline
% Ashley & 20 \\ \hline
% Henry & 14 \\ \hline
% \Block{2-1}{Madison} & 15 \\
% & 19 \\ \hline
% \end{NiceTabular}
% \end{scope}
%
%
% \subsection{The mono-row blocks}
%
% For the mono-row blocks, the natural height and depth are taken into account
% for the height and depth of the current row (as does a standard |\multicolumn|
% of LaTeX).
%
% \subsection{The mono-cell blocks}
%
% A mono-cell block inherits all the properties of the mono-row blocks and
% mono-column blocks.
%
% \medskip
% At first sight, one may think that there is no point using a mono-cell block.
% However, there are some good reasons to use such a block.
% \begin{itemize}
% \item It's possible to use the command |\\| in a (mono-cell) block.
%
% \item It's possible to use the option of horizontal alignment of the block in
% derogation of the type of column given in the preamble of the array.
%
% \item It's possible do draw a frame around the cell with the key |draw| of the
% command |\Block| and to fill the background with rounded corners with the keys
% |fill| and |rounded-corners|.\footnote{If one simply wishes to color the
% background of a unique cell, there is no point using the command |\Block|:
% it's possible to use the command |\cellcolor| (when the key |colortbl-like| is
% used).}
%
% \item It's possible to draw one or several borders of the cell with the key |borders|.
% \end{itemize}
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{NiceTabular}{cc}
% \toprule
% Writer & ~emphase#\Block[l]{}{year\\ of birth}@ \\
% \midrule
% Hugo & 1802 \\
% Balzac & 1799 \\
% \bottomrule
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{cc}
% \toprule
% Writer & \Block[l]{}{year\\ of birth} \\
% \midrule
% Hugo & 1802 \\
% Balzac & 1799 \\
% \bottomrule
% \end{NiceTabular}
%
% \medskip
% We recall that if the first mandatory argument of |\Block| is left blank, the
% block is mono-cell.\footnote{One may consider that the default value of the
% first mandatory argument of |\Block| is |1-1|.}
%
%
%
%
% \subsection{Horizontal position of the content of the block}
%
% By default, the horizontal position of the content of a block is computed
% by using the positions of the \emph{contents} of the columns implied in that
% block. That's why, in the following example, the header ``First group'' is
% correctly centered despite the instruction |!{\qquad}| in the preamble which
% has been used to increase the space between the columns (this
% is not the behaviour of |\multicolumn|).
%
% \medskip
% \begin{center}
% \fvset{commandchars=\~\#\+}
% \begin{BVerbatim}
% \begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc@{}}
% \toprule
% Rank & ~emphase#\Block{1-3}{First group}+ & & & \Block{1-3}{Second group} \\
% & 1A & 1B & 1C & 2A & 2B & 2C \\
% \midrule
% 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\
% 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\
% 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\
% 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\
% \bottomrule
% \end{NiceTabular}
% \end{BVerbatim}
% \end{center}
%
% \bigskip
% \begin{center}
% \begin{NiceTabular}{@{}c!{\qquad}ccc!{\qquad}ccc@{}}
% \toprule
% Rank & \Block{1-3}{First group} & & & \Block{1-3}{Second group} \\
% & 1A & 1B & 1C & 2A & 2B & 2C \\
% \midrule
% 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\
% 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\
% 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\
% 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\
% \bottomrule
% \end{NiceTabular}
% \end{center}
%
% \medskip
% In order to have an horizontal positionning of the content of the block
% computed with the limits of the columns of the LaTeX array (and not with the
% contents of those columns), one may use the key |L|, |R| and |C| of the
% command |\Block|.
%
%
% \section{The rules}
%
% The usual techniques for the rules may be used in the environments of
% \pkg{nicematrix} (excepted |\vline|). However, there is some small differences
% with the classical environments.
%
% \bigskip
% \subsection{Some differences with the classical environments}
%
% \subsubsection{The vertical rules}
%
% In the environments of \pkg{nicematrix}, the vertical rules specified by
% \verb+|+ in the preambles of the environments are never broken, even by an
% incomplete row or by a double horizontal rule specified by |\hline\hline|
% (there is no need to use \pkg{hhline}).
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{NiceTabular}{|c|c|} \hline
% First & Second \\ ~emphase#\hline\hline@
% Peter \\ \hline
% Mary & George\\ \hline
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{|c|c|}[c] \hline
% First & Second \\ \hline\hline
% Peter \\ \hline
% Mary & George \\ \hline
% \end{NiceTabular}
%
%
% \bigskip
% However, the vertical rules are not drawn in the blocks (created by |\Block|:
% cf.~p.~\pageref{Block}) nor in the corners (created by the key |corner|:
% cf.~p.~\pageref{corners}).
%
% \bigskip
% If you use \pkg{booktabs} (which provides |\toprule|, |\midrule|,
% |\bottomrule|, etc.) and if you really want to add vertical rules (which is
% not in the spirit of \pkg{booktabs}), you should notice that the vertical rules
% drawn by \pkg{nicematrix} are compatible with \pkg{booktabs}.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.5cm]
% $\begin{NiceArray}{~emphase#|cccc|@} \toprule
% a & b & c & d \\ \midrule
% 1 & 2 & 3 & 4 \\
% 1 & 2 & 3 & 4 \\ \bottomrule
% \end{NiceArray}$
% \end{BVerbatim}
% $\begin{NiceArray}{|cccc|}
% \toprule
% a & b & c & d \\
% \midrule
% 1 & 2 & 3 & 4 \\
% 1 & 2 & 3 & 4 \\
% \bottomrule
% \end{NiceArray}$
%
% \bigskip
% However, it's still possible to define a specifier (named, for instance, |I|)
% to draw vertical rules with the standard behaviour of \pkg{array}.
%
% \begin{Verbatim}
% \newcolumntype{I}{!{\vrule}}
% \end{Verbatim}
%
%
% \bigskip
% \subsubsection{The command \textbackslash cline}
%
%\label{remark-cline}
%
% The horizontal and vertical rules drawn by |\hline| and the specifier
% ``\verb+|+'' make the array larger or wider by a quantity equal to the width
% of the rule (with \pkg{array} and also with \pkg{nicematrix}).
%
% \smallskip
% For historical reasons, this is not the case with the command |\cline|, as
% shown by the following example.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \setlength{\arrayrulewidth}{2pt}
% \begin{tabular}{cccc} \hline
% A&B&C&D \\ ~emphase#\cline{2-2}@
% A&B&C&D \\ \hline
% \end{tabular}
% \end{BVerbatim}
% \begin{scope}
% \setlength{\arrayrulewidth}{2pt}
% \begin{tabular}[c]{cccc}
% \hline
% A&B&C&D \\
% \cline{2-2}
% A&B&C&D \\
% \hline
% \end{tabular}
% \end{scope}
%
% \medskip
% In the environments of \pkg{nicematrix}, this situation is corrected (it's
% still possible to go to the standard behaviour of |\cline| with the key |standard-cline|).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \setlength{\arrayrulewidth}{2pt}
% \begin{NiceTabular}{cccc} \hline
% A&B&C&D \\ ~emphase#\cline{2}@
% A&B&C&D \\ \hline
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{scope}
% \setlength{\arrayrulewidth}{2pt}
% \begin{NiceTabular}[c]{cccc}
% \hline
% A&B&C&D \\
% \cline{2}
% A&B&C&D \\
% \hline
% \end{NiceTabular}
% \end{scope}
%
% \medskip
% In the environments of \pkg{nicematrix}, an instruction |\cline{|\textsl{\texttt{i}}|}|
% is equivalent to |\cline{|\textsl{\texttt{i}}|-|\textsl{\texttt{i}}|}|.
%
%
% \subsection{The thickness and the color of the rules}
%
% The environments of \pkg{nicematrix} provide a key |rules/width| to set the
% width (in fact the thickness) of the rules in the current environment. In
% fact, this key merely sets the value of the length |\arrayrulewidth|.
%
% \smallskip
% It's well known that \pkg{colortbl} provides the command |\arrayrulecolor| in
% order to specify the color of the rules.
%
% \smallskip
% With \pkg{nicematrix}, it's possible to specify the color of the rules even
% when \pkg{colortbl} is not loaded. For sake of compatibility, the command is
% also named |\arrayrulecolor|. The environments of \pkg{nicematrix} also
% provide a key |rules/color| to fix the color of the rules in the current
% environment. This key sets the value locally (whereas |\arrayrulecolor| acts
% globally).
%
% \medskip
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
% \begin{NiceTabular}{|ccc|}[~emphase#rules/color=[gray]{0.9},rules/width=1pt@]
% \hline
% rose & tulipe & lys \\
% arum & iris & violette \\
% muguet & dahlia & souci \\
% \hline
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{|ccc|}[rules/color=[gray]{0.9},rules/width=1pt]
% \hline
% rose & tulipe & lys \\
% arum & iris & violette \\
% muguet & dahlia & souci \\
% \hline
% \end{NiceTabular}
% \end{scope}
%
%
%
% \subsection{The tools of nicematrix for the rules}
%
% Here are the tools provided by \pkg{nicematrix} for the rules.
% \begin{itemize}
% \item the keys |hlines|, |vlines|, |hvlines| and |hvlines-except-borders|;
% \item the specifier ``\verb+|+'' in the preamble (for the environments with
% preamble);
% \item the command |\Hline|.
% \end{itemize}
%
% \medskip
% \textbf{All these tools don't draw the rules in the blocks nor in the
% empty corners (when the key |corners| is used).}
% \begin{itemize}
% \item These blocks are:
% \begin{itemize}
% \item the blocks created by the command |\Block|\footnote{And also the command |\multicolumn| but
% it's recommended to use instead |\Block| in the environments of
% \pkg{nicematrix}.} presented
% p.~\pageref{Block};
% \item the blocks implicitely delimited by the continuous dotted lines created
% by |\Cdots|, |\Vdots|, etc. (cf.~p.~\pageref{Cdots}).
% \end{itemize}
% \item The corners are created by the key |corners| explained below (see p.~\pageref{corners}).
% \end{itemize}
%
% In particular, this remark explains the difference between the standard
% command |\hline| and the command |\Hline| provided by \pkg{nicematrix}.
%
%
% \subsubsection{The keys hlines and vlines}
%
% The keys |hlines| and |vlines| (which draw, of course, horizontal and vertical
% rules) take in as value a list of numbers which are the numbers of the rules
% to draw.\footnote{It's possible to put in that list some intervals of integers
% with the syntax $i$|-|$j$.}
%
% In fact, for the environments with delimiters (such as |{pNiceMatrix}| or
% |{bNiceArray}|), the key |vlines| don't draw the exterior rules (this is
% certainly the expected behaviour).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
% $\begin{pNiceMatrix}[~emphase#vlines@,rules/width=0.2pt]
% 1 & 2 & 3 & 4 & 5 & 6 \\
% 1 & 2 & 3 & 4 & 5 & 6 \\
% 1 & 2 & 3 & 4 & 5 & 6
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $\begin{pNiceMatrix}[vlines,rules/width=0.2pt]
% 1 & 2 & 3 & 4 & 5 & 6 \\
% 1 & 2 & 3 & 4 & 5 & 6 \\
% 1 & 2 & 3 & 4 & 5 & 6
% \end{pNiceMatrix}$
%
%
%
% \subsubsection{The keys hvlines and hvlines-except-borders}
% \label{hvlines}
%
% The key |hvlines| (no value) is the conjonction of the keys |hlines| and |vlines|.
%
% \smallskip
% \begin{Verbatim}
% \setlength{\arrayrulewidth}{1pt}
% \begin{NiceTabular}{cccc}[~emphase#hvlines@,rules/color=blue]
% rose & tulipe & marguerite & dahlia \\
% violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\
% pervenche & & & lys \\
% arum & iris & jacinthe & muguet
% \end{NiceTabular}
% \end{Verbatim}
%
% \begin{center}
% \setlength{\arrayrulewidth}{1pt}
% \begin{NiceTabular}{cccc}[hvlines,rules/color=blue]
% rose & tulipe & marguerite & dahlia \\
% violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\
% pervenche & & & lys \\
% arum & iris & jacinthe & muguet
% \end{NiceTabular}
% \end{center}
%
% \bigskip
% The key |hvlines-except-borders| is similar to the key |hvlines| but does not
% draw the rules on the horizontal and vertical borders of the array.
%
% \subsubsection{The (empty) corners}
%
% \label{corners}
%
% The four |corners| of an array will be designed by |NW|, |SW|, |NE| and |SE|
% (\emph{north west}, \emph{south west}, \emph{north east} and \emph{south east}).
%
% For each of these corners, we will call \emph{empty corner} (or simply
% \emph{corner}) the reunion of all the empty rectangles starting from the cell
% actually in the corner of the array.\footnote{For sake of completeness, we
% should also say that a cell contained in a block (even an empty cell) is not
% taken into account for the determination of the corners. That behaviour is
% natural. The precise definition of a ``non-empty cell'' is given below (cf.
% p.~\pageref{empty-cells}).}
%
% However, it's possible, for a cell without content, to require \pkg{nicemarix}
% to consider that cell as not empty with the key |\NotEmpty|.
%
%\bigskip
% \begin{minipage}{9cm}
% In the example on the right (where B is in the center of a block of size
% $2\times2$), we have colored in blue the four (empty) corners of the array.
% \end{minipage}\hspace{2cm}%
% \begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt]
% \CodeBefore
% \rectanglecolor{blue!10}{1-1}{4-2}
% \rectanglecolor{blue!10}{1-1}{1-4}
% \rectanglecolor{blue!10}{1-6}{3-6}
% \rectanglecolor{blue!10}{7-1}{9-1}
% \rectanglecolor{blue!10}{7-5}{9-6}
% \Body
% & & & & A \\
% & & A & A & A \\
% & & & A \\
% & & A & A & A & A \\
% A & A & A & A & A & A \\
% A & A & A & A & A & A \\
% & A & A & A \\
% & \Block{2-2}{B} & & A \\
% & & & A \\
% \end{NiceTabular}
%
% \bigskip
% When the key |corners| is used, \pkg{nicematrix} computes the (empty) corners
% and these corners will be taken into account by the tools for drawing the
% rules (the rules won't be drawn in the corners).
%
% \bigskip
% \begin{BVerbatim}[boxwidth=11cm,baseline=c]
% \NiceMatrixOptions{cell-space-top-limit=3pt}
% \begin{NiceTabular}{*{6}{c}}[~emphase#corners@,hvlines]
% & & & & A \\
% & & A & A & A \\
% & & & A \\
% & & A & A & A & A \\
% A & A & A & A & A & A \\
% A & A & A & A & A & A \\
% & A & A & A \\
% & \Block{2-2}{B} & & A \\
% & & & A \\
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{*{6}{c}}[corners,hvlines,cell-space-top-limit=3pt]
% & & & & A \\
% & & A & A & A \\
% & & & A \\
% & & A & A & A & A \\
% A & A & A & A & A & A \\
% A & A & A & A & A & A \\
% & A & A & A \\
% & \Block{2-2}{B} & & A \\
% & & & A \\
% \end{NiceTabular}
%
%
% \bigskip
% It's also possible to provide to the key |corners| a (comma-separated) list of
% corners (designed by |NW|, |SW|, |NE| and |SE|).
%
% \medskip
% \begin{BVerbatim}[boxwidth=11cm,baseline=c]
% \NiceMatrixOptions{cell-space-top-limit=3pt}
% \begin{NiceTabular}{*{6}{c}}[~emphase#corners=NE@,hvlines]
% 1\\
% 1&1\\
% 1&2&1\\
% 1&3&3&1\\
% 1&4&6&4&1\\
% & & & & &1
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{*{6}{c}}[c,corners=NE,hvlines,cell-space-top-limit=3pt]
% 1\\
% 1&1\\
% 1&2&1\\
% 1&3&3&1\\
% 1&4&6&4&1\\
% & & & & &1
% \end{NiceTabular}
%
%
% \medskip
% $\triangleright$ The corners are also taken into account by the tools provided
% by \pkg{nicematrix} to color cells, rows and columns. These tools don't color
% the cells which are in the corners (cf.~p.~\pageref{color-in-code-before}).
%
% \subsection{The command \textbackslash diagbox}
%
% The command |\diagbox| (inspired by the package \pkg{diagbox}), allows, when
% it is used in a cell, to slash that cell diagonally downwards.\footnote{The
% author of this document considers that type of construction as graphically
% poor.}.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $\begin{NiceArray}{*{5}{c}}[hvlines]
% ~emphase#\diagbox{x}{y}@ & e & a & b & c \\
% e & e & a & b & c \\
% a & a & e & c & b \\
% b & b & c & e & a \\
% c & c & b & a & e
% \end{NiceArray}$
% \end{BVerbatim}
% $\begin{NiceArray}{*{5}{c}}[hvlines]
% \diagbox{x}{y} & e & a & b & c \\
% e & e & a & b & c \\
% a & a & e & c & b \\
% b & b & c & e & a \\
% c & c & b & a & e
% \end{NiceArray}$
%
% \medskip
% It's possible to use the command |\diagbox| in a |\Block|.
%
%
%
%
% \subsection{Commands for customized rules}
% \label{custom-line}
%
% \colorbox{yellow!50}{\textbf{New 6.5}}\enskip It's possible to define commands
% and letters for customized rules with the key |custom-line| available in
% |\NiceMatrixOptions| and in the options of individual environments. That key
% takes in as argument a list of \textsl{key=value} pairs. First, there is two
% keys to define the tools which will be used to use that new type of rule.
%
% \begin{itemize}
% \item the key |command| is the name (without the backslahs) of a command that
% will be created by \pkg{nicematrix} and that will be available for the final
% user in order to draw horizontal rules (similarly to |\hline|);
%
% \item the key |letter| takes in as argument a letter\footnote{The following
% letters are forbidden: \verb+lcrpmbVX|()[]!@<>+} that the user will use in
% the preamble of an environment with preamble (such as |{NiceTabular}| in order
% to specify a vertical rule.
% \end{itemize}
%
% \bigskip
% For the description of the rule itself, there is three possibilities.
%
% \begin{itemize}
% \item \emph{First possibility}\par\nobreak
%
% It's possible to specify composite rules, with a color and a color for the
% inter-rule space (as possible with \pkg{colortbl} for instance).
%
% \begin{itemize}
% \item the key |multiplicity| is the number to consecutive rules that will be
% drawn: for instance, a value of $2$ will create double rules such those
% created by |\hline\hline| or \verb+||+ in the preamble of an environment;
%
% \item the key |color| sets the color of the rule ;
%
% \item the key |sep-color| sets the color between two successive rules (should be
% used only in conjonction with |multiplicity|).
% \end{itemize}
%
% \medskip
% That system may be used, in particular, for the definition of commands and
% letters to draw rules with a specific color (and those rules will respect the
% blocks and corners as do all the rules of \pkg{nicematrix}).
%
% \medskip
% \begin{Verbatim}
% \begin{NiceTabular}{lcIcIc}~emphase#[custom-line = {letter=I, color=blue}]@
% \hline
% & \Block{1-3}{dimensions} \\
% & L & l & h \\
% \hline
% Product A & 3 & 1 & 2 \\
% Product B & 1 & 3 & 4 \\
% Product C & 5 & 4 & 1 \\
% \hline
% \end{NiceTabular}
% \end{Verbatim}
%
%
% \bigskip
% \item \colorbox{yellow!50}{\textbf{New 6.6}}\enskip \emph{Second
% possibility}\par\nobreak
%
% It's possible to use the key |tikz| (if Tikz is loaded). In that case, the
% rule is drawn directly with Tikz by using as parameters the value of the key
% |tikz| which must be a list of \textsl{key=value} pairs which may be applied
% to a Tikz path.
%
% By default, no space is reserved for the rule that will be drawn with Tikz. It
% is possible to specify a reservation (horizontal for a vertical rule and
% vertical for an horizontal one) with the key |width|. That value of that key,
% is, in some ways, the width of the rule that will be drawn (\pkg{nicematrix}
% does not compute that width from the characteristics of the rule specified in
% |tikz|).
%
%
% \begin{center}
% \begin{NiceTabular}{lcIcIc}[custom-line = {letter=I, color=blue}]
% \hline
% & \Block{1-3}{dimensions} \\
% & L & l & H \\
% \hline
% Product A & 3 & 1 & 2 \\
% Product B & 1 & 3 & 4 \\
% Product C & 5 & 4 & 1 \\
% \hline
% \end{NiceTabular}
% \end{center}
%
% \bigskip
% Here is an example with the key |dotted| of Tikz.
%
% \begin{BVerbatim}[boxwidth=9cm,baseline=c]
% \NiceMatrixOptions
% {
% custom-line =
% {
% letter = I ,
% ~emphase#tikz = dotted@ ,
% ~emphase#width = \pgflinewidth@
% }
% }
%
% \begin{NiceTabular}{cIcIc}
% one & two & three \\
% four & five & six \\
% seven & eight & nine
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{scope}
% \NiceMatrixOptions
% {
% custom-line =
% {
% letter = I ,
% tikz = dotted ,
% width = \pgflinewidth
% }
% }
% \begin{NiceTabular}{cIcIc}
% one & two & three \\
% four & five & six \\
% seven & eight & nine
% \end{NiceTabular}
% \end{scope}
%
% \bigskip
% \item \emph{Third possibility} : the key |dotted|
% \label{dotted}
%
% As one can see, the dots of a dotted line of Tikz have the shape of a square,
% and not a circle. That's why the extension \pkg{nicematrix} provides in the
% key |custom-line| a key |dotted| which will draw rounded dots. The value of
% the key |width| is, in this case, preset to the diameter of the dots. Those
% dotted rules are also used by \pkg{nicematrix} to draw continuous dotted rules
% between cells of the matrix with |\Cdots|, |\Vdots|, etc. (cf. p.~\pageref{Cdots}).
%
% In fact, \pkg{nicematrix} defines by default the command |\hdottedline| and the
% letter ``|:|'' for those dotted rules.\footnote{However, it's possible to
% overwrite those definitions with a |custom-line| (in order, for example, to
% switch to dashed lines).}
%
%\smallskip
%\begin{BVerbatim}
%
% \NiceMatrixOptions % ~textsl#présent dans nicematrix.sty@
% {
% custom-line =
% {
% letter = : ,
% command = hdottedline ,
% ~emphase#dotted@
% }
% }
% \end{BVerbatim}
%
% Thus, it's possible to use the command |\hdottedline| to draw a horizontal
% dotted rule.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
% \begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 \\
% ~emphase#\hdottedline@
% 6 & 7 & 8 & 9 & 10 \\
% 11 & 12 & 13 & 14 & 15
% \end{pNiceMatrix}
% \end{BVerbatim}
% $\begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 \\
% \hdottedline
% 6 & 7 & 8 & 9 & 10 \\
% 11 & 12 & 13 & 14 & 15
% \end{pNiceMatrix}$
%
%
% \bigskip
% In the environments with an explicit preamble (like |{NiceTabular}|,
% |{NiceArray}|, etc.), it's possible to draw a vertical dotted line with the
% specifier ``|:|''.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
% \left(\begin{NiceArray}{cccc~emphase#:@c}
% 1 & 2 & 3 & 4 & 5 \\
% 6 & 7 & 8 & 9 & 10 \\
% 11 & 12 & 13 & 14 & 15
% \end{NiceArray}\right)
% \end{BVerbatim}
% $\left(\begin{NiceArray}{cccc:c}
% 1 & 2 & 3 & 4 & 5 \\
% 6 & 7 & 8 & 9 & 10 \\
% 11 & 12 & 13 & 14 & 15
% \end{NiceArray}\right)$
%
% \end{itemize}
%
%
%
%\section{The color of the rows and columns}
%
% \subsection{Use of colortbl}
%
% We recall that the package \pkg{colortbl} can be loaded directly with
% |\usepackage{colortbl}| or by loading \pkg{xcolor} with the key |table|:
% |\usepackage[table]{xcolor}|.
%
% \medskip
% Since the package \pkg{nicematrix} is based on \pkg{array}, it's possible to
% use \pkg{colortbl} with \pkg{nicematrix}.
%
% \medskip
% However, there is two drawbacks:
% \begin{itemize}
% \item The package \pkg{colortbl} patches \pkg{array}, leading to some
% incompatibilities (for instance with the command |\hdotsfor|).
%
% \item The package \pkg{colortbl} constructs the array row by row, alterning
% colored rectangles, rules and contents of the cells. The resulting
% \textsc{pdf} is difficult to interpret by some \textsc{pdf} viewers and may
% lead to artefacts on the screen.
% \begin{itemize}
% \item Some rules seem to disappear. This is because many PDF viewers give
% priority to graphical element drawn posteriorly (which is in the spirit of the
% ``painting model'' of PostScript and PDF). Concerning this problem, MuPDF
% (which is used, for instance, by SumatraPDF) gives better results than Adobe
% Reader).
% \item A thin white line may appear between two cells of the same color. This
% phenomenon occurs when each cell is colored with its own instruction |fill|
% (the PostScript operator |fill| noted |f| in PDF). This is the case with
% \pkg{colortbl}: each cell is colored on its own, even when |\columncolor| or
% |\rowcolor| is used.
%
% As for this phenomenon, Adobe Reader gives better results than MuPDF.
% \end{itemize}
%
% The package \pkg{nicematrix} provides tools to avoid those problems.
% \end{itemize}
%
% \subsection{The tools of nicematrix in the \textbackslash CodeBefore}
%
% \label{color-in-code-before}
%
% The package \pkg{nicematrix} provides some tools (independent of
% \pkg{colortbl}) to draw the colored panels first, and, then, the content of
% the cells and the rules. This strategy is more conform to the ``painting
% model'' of the formats PostScript and \textsc{pdf} and is more suitable for
% the \textsc{pdf} viewers. However, it requires several
% compilations.\footnote{If you use Overleaf, Overleaf will do automatically the
% right number of compilations.}
%
% \medskip
% The extension \pkg{nicematrix} provides a key |code-before| for some code that
% will be executed before the drawing of the tabular.
%
% \medskip
% An alternative syntax is provided: it's possible to put the content of that
% |code-before| between the keywords |\CodeBefore| and |\Body| at the beginning
% of the environment.
%
% \begin{Verbatim}
% \begin{pNiceArray}{~textsl#preamble@}
% ~emphase#\CodeBefore@
% ~textsl#instructions of the code-before@
% ~emphase#\Body@
% ~textsl#contents of the environment@
% \end{pNiceArray}
% \end{Verbatim}
%
% New commands are available in that |\CodeBefore|: |\cellcolor|,
% |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|,
% |\rowlistcolors|, |\chessboardcolors| and |arraycolor|.\footnote{Remark that,
% in the |\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are
% also available to indicate the position to the potential rules:
% cf.~p.~\pageref{nodes-i}.}
% \label{code-before}
%
% \medskip
% All these commands accept an optional argument (between square brackets and
% in first position) which is the color model for the specification of the
% colors.
%
% \medskip
% These commands don't color the cells which are in the ``corners'' if the key
% |corners| is used. This key has been described p.~\pageref{corners}.
%
% \medskip
% \begin{itemize}
% \item The command |\cellcolor| takes its name from the command |\cellcolor| of
% \pkg{colortbl}.
%
% This command takes in as mandatory arguments a color and a list of cells, each
% of which with the format $i$-$j$ where $i$ is the number of the row and $j$ the
% number of the colummn of the cell.
%
%
% \medskip
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
% \begin{NiceTabular}{|c|c|c|}
% \CodeBefore
% ~emphase#\cellcolor[HTML]{FFFF88}{3-1,2-2,1-3}@
% \Body
% \hline
% a & b & c \\ \hline
% e & f & g \\ \hline
% h & i & j \\ \hline
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{|c|c|c|}
% \CodeBefore
% \cellcolor[HTML]{FFFF88}{3-1,2-2,1-3}
% \Body
% \hline
% a & b & c \\ \hline
% e & f & g \\ \hline
% h & i & j \\ \hline
% \end{NiceTabular}
% \end{scope}
%
% \bigskip
% \item The command |\rectanglecolor| takes three mandatory arguments. The first
% is the color. The second is the upper-left cell of the rectangle and the third
% is the lower-right cell of the rectangle.
%
% \medskip
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
% \begin{NiceTabular}{|c|c|c|}
% \CodeBefore
% ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@
% \Body
% \hline
% a & b & c \\ \hline
% e & f & g \\ \hline
% h & i & j \\ \hline
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{|c|c|c|}
% \CodeBefore
% \rectanglecolor{blue!15}{2-2}{3-3}
% \Body
% \hline
% a & b & c \\ \hline
% e & f & g \\ \hline
% h & i & j \\ \hline
% \end{NiceTabular}
% \end{scope}
%
% \bigskip
% \item The command |\arraycolor| takes in as mandatory argument a color and
% color the whole tabular with that color (excepted the potential exterior rows
% and columns: cf.~p.~\pageref{exterior}). It's only a particular case of
% |\rectanglecolor|.
%
%
% \bigskip
% \item The command |\chessboardcolors| takes in as mandatory arguments two colors
% and it colors the cells of the tabular in quincunx with these colors.
%
% \medskip
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% $\begin{pNiceMatrix}[r,margin]
% \CodeBefore
% ~emphase#\chessboardcolors{red!15}{blue!15}@
% \Body
% 1 & -1 & 1 \\
% -1 & 1 & -1 \\
% 1 & -1 & 1
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $\begin{pNiceMatrix}[r,baseline=1, margin]
% \CodeBefore
% \chessboardcolors{red!15}{blue!15}
% \Body
% 1 & -1 & 1 \\
% -1 & 1 & -1 \\
% 1 & -1 & 1
% \end{pNiceMatrix}$
% \end{scope}
%
% \medskip
% We have used the key |r| which aligns all the columns rightwards (cf.
% p.~\pageref{key-R}).
%
%
% \bigskip
% \item The command |\rowcolor| takes its name from the command |\rowcolor| of
% \pkg{colortbl}. Its first mandatory argument is the color and the second is a
% comma-separated list of rows or interval of rows with the form $a$-$b$ (an
% interval of the form $a$- represent all the rows from the row $a$ until the end).
%
% \medskip
% \begin{scope}
% \hfuzz = 10cm
% \begin{BVerbatim}[boxwidth=9cm,baseline=c]
% $\begin{NiceArray}{lll}[hvlines]
% \CodeBefore
% ~emphase#\rowcolor{red!15}{1,3-5,8-}@
% \Body
% a_1 & b_1 & c_1 \\
% a_2 & b_2 & c_2 \\
% a_3 & b_3 & c_3 \\
% a_4 & b_4 & c_4 \\
% a_5 & b_5 & c_5 \\
% a_6 & b_6 & c_6 \\
% a_7 & b_7 & c_7 \\
% a_8 & b_8 & c_8 \\
% a_9 & b_9 & c_9 \\
% a_{10} & b_{10} & c_{10} \\
% \end{NiceArray}$
% \end{BVerbatim}
% $\begin{NiceArray}{lll}[baseline=4,hvlines]
% \CodeBefore
% \rowcolor{red!15}{1,3-5,8-}
% \Body
% a_1 & b_1 & c_1 \\
% a_2 & b_2 & c_2 \\
% a_3 & b_3 & c_3 \\
% a_4 & b_4 & c_4 \\
% a_5 & b_5 & c_5 \\
% a_6 & b_6 & c_6 \\
% a_7 & b_7 & c_7 \\
% a_8 & b_8 & c_8 \\
% a_9 & b_9 & c_9 \\
% a_{10} & b_{10} & c_{10} \\
% \end{NiceArray}$
% \end{scope}
%
%
% \bigskip
% \item The command |\columncolor| takes its name from the command
% |\columncolor| of \pkg{colortbl}. Its syntax is similar to the syntax of
% |\rowcolor|.
%
% \bigskip
% \item The command |\rowcolors| (with a \emph{s}) takes its name from the
% command |\rowcolors| of \pkg{xcolor}\footnote{The command |\rowcolors| of
% \pkg{xcolor} is available when \pkg{xcolor} is loaded with the option~|table|.
% That option also loads the package \pkg{colortbl}.}. The \emph{s} emphasizes
% the fact that there is \emph{two} colors. This command colors alternately the
% rows of the tabular with the tow colors (provided in second and third
% argument), beginning with the row whose number is given in first (mandatory)
% argument.
%
% In fact, the first (mandatory) argument is, more generally, a comma separated
% list of intervals describing the rows involved in the action of |\rowcolors|
% (an interval of the form $i$|-| describes in fact the interval of all the rows
% of the tabular, beginning with the row~$i$).
%
%
% \bigskip
% The last argument of |\rowcolors| is an optional list of pairs
% \textsl{key=value} (the optional argument in the first position corresponds to
% the colorimetric space). The available keys are |cols|, |restart| and
% |respect-blocks|.
% \begin{itemize}
% \item The key |cols| describes a set of columns. The command |\rowcolors| will
% color only the cells of these columns. The value is a comma-separated list of
% intervals of the form $i$-$j$ (where $i$ or $j$ may be replaced by |*|).
% \item With the key |restart|, each interval of rows (specified by the first
% mandatory argument) begins with the same color.\footnote{Otherwise, the color
% of a given row relies only upon the parity of its absolute number.}
% \item With the key |respect-blocks| the ``rows'' alternately colored may extend over
% several rows if they have to incorporate blocks (created with the command
% |\Block|: cf.~p.~\pageref{Block}).
% \end{itemize}
%
% \medskip
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{NiceTabular}{clr}[hvlines]
% \CodeBefore
% ~emphase#\rowcolors[gray]{2}{0.8}{}[cols=2-3,restart]@
% \Body
% \Block{1-*}{Results} \\
% John & 12 \\
% Stephen & 8 \\
% Sarah & 18 \\
% Ashley & 20 \\
% Henry & 14 \\
% Madison & 15
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{clr}[hvlines,baseline=2]
% \CodeBefore
% \rowcolors[gray]{2}{0.8}{}[cols=2-3,restart]
% \Body
% \Block{1-*}{Results} \\
% \Block{2-1}{A}& John & 12 \\
% & Stephen & 8 \\
% \Block{4-1}{B}& Sarah & 18 \\
% & Ashley & 20 \\
% & Henry & 14 \\
% & Madison & 15
% \end{NiceTabular}
% \end{scope}
%
% \vspace{1cm}
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{NiceTabular}{lr}[hvlines]
% \CodeBefore
% ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@
% \Body
% \Block{2-1}{John} & 12 \\
% & 13 \\
% Steph & 8 \\
% \Block{3-1}{Sarah} & 18 \\
% & 17 \\
% & 15 \\
% Ashley & 20 \\
% Henry & 14 \\
% \Block{2-1}{Madison} & 15 \\
% & 19
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{lr}[hvlines,baseline=c]
% \CodeBefore
% \rowcolors{1}{blue!10}{}[respect-blocks]
% \Body
% \Block{2-1}{John} & 12 \\
% & 13 \\
% Steph & 8 \\
% \Block{3-1}{Sarah} & 18 \\
% & 17 \\
% & 15 \\
% Ashley & 20 \\
% Henry & 14 \\
% \Block{2-1}{Madison} & 15 \\
% & 19
% \end{NiceTabular}
% \end{scope}
%
%
%
%
% \bigskip
% \item The extension \pkg{nicematrix} provides also a command |\rowlistcolors|.
% This command generalises the command |\rowcolors|: instead of two successive
% arguments for the colors, this command takes in an argument which is a
% (comma-separated) list of colors. In that list, the symbol |=| represent a
% color identical to the previous one.
% \end{itemize}
%
% \smallskip
% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
% \begin{NiceTabular}{c}
% \CodeBefore
% ~emphase#\rowlistcolors{1}{red!15,blue!15,green!15}@
% \Body
% Peter \\
% James \\
% Abigail \\
% Elisabeth \\
% Claudius \\
% Jane \\
% Alexandra \\
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{c}
% \CodeBefore
% \rowlistcolors{1}{red!15,blue!15,green!15}
% \Body
% Peter \\
% James \\
% Abigail \\
% Elisabeth \\
% Claudius \\
% Jane \\
% Alexandra \\
% \end{NiceTabular}
%
%
% \medskip
% We recall that all the color commands we have described don't color the cells
% which are in the ``corners''. In the following example, we use the key
% |corners| to require the determination of the corner \emph{north east} (NE).
%
%\medskip
% \begin{scope}
% \hfuzz=11cm
% \begin{BVerbatim}[boxwidth=9cm,baseline=c]
% \begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col]
% \CodeBefore
% ~emphase#\rowlistcolors{1}{blue!15, }@
% \Body
% & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
% 0 & 1 \\
% 1 & 1 & 1 \\
% 2 & 1 & 2 & 1 \\
% 3 & 1 & 3 & 3 & 1 \\
% 4 & 1 & 4 & 6 & 4 & 1 \\
% 5 & 1 & 5 & 10 & 10 & 5 & 1 \\
% 6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col]
% \CodeBefore
% \rowlistcolors{1}{blue!15, }
% \Body
% & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
% 0 & 1 \\
% 1 & 1 & 1 \\
% 2 & 1 & 2 & 1 \\
% 3 & 1 & 3 & 3 & 1 \\
% 4 & 1 & 4 & 6 & 4 & 1 \\
% 5 & 1 & 5 & 10 & 10 & 5 & 1 \\
% 6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
% \end{NiceTabular}
% \end{scope}
%
%
% \bigskip
% One should remark that all the previous commands are compatible with the
% commands of \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc).
% However, \pkg{booktabs} is not loaded by \pkg{nicematrix}.
%
% \medskip
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
% \begin{NiceTabular}[c]{lSSSS}
% \CodeBefore
% \rowcolor{red!15}{1-2}
% \rowcolors{3}{blue!15}{}
% \Body
% ~emphase#\toprule@
% \Block{2-1}{Product} &
% \Block{1-3}{dimensions (cm)} & & &
% \Block{2-1}{\rotate Price} \\
% ~emphase#\cmidrule(rl){2-4}@
% & L & l & h \\
% ~emphase#\midrule@
% small & 3 & 5.5 & 1 & 30 \\
% standard & 5.5 & 8 & 1.5 & 50.5 \\
% premium & 8.5 & 10.5 & 2 & 80 \\
% extra & 8.5 & 10 & 1.5 & 85.5 \\
% special & 12 & 12 & 0.5 & 70 \\
% ~emphase#\bottomrule@
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}[c]{lSSSS}
% \CodeBefore
% \rowcolor{red!15}{1-2}
% \rowcolors{3}{blue!15}{}
% \Body
% \toprule
% \Block{2-1}{Product} &
% \Block{1-3}{dimensions (cm)} & & &
% \Block{2-1}{\rotate Price} \\
% \cmidrule(rl){2-4}
% & L & l & h \\
% \midrule
% small & 3 & 5.5 & 1 & 30 \\
% standard & 5.5 & 8 & 1.5 & 50.5 \\
% premium & 8.5 & 10.5 & 2 & 80 \\
% extra & 8.5 & 10 & 1.5 & 85.5 \\
% special & 12 & 12 & 0.5 & 70 \\
% \bottomrule
% \end{NiceTabular}
% \end{scope}
%
% \medskip
% We have used the type of column |S| of \pkg{siunitx}.
%
%
% \subsection{Color tools with the syntax of colortbl}
%
% It's possible to access the preceding tools with a syntax close to the syntax
% of \pkg{colortbl}. For that, one must use the key |colortbl-like| in the
% current environment.\footnote{Up to now, this key is \emph{not} available in |\NiceMatrixOptions|.}
%
% There are three commands available (they are inspired by \pkg{colortbl} but
% are \emph{independent} of \pkg{colortbl}):
% \begin{itemize}
% \item |\cellcolor| which colorizes a cell;\footnote{However, this command
% |\cellcolor| will delete the following spaces, which does not the command
% |\cellcolor| of \pkg{colortbl}.}
% \item |\rowcolor| which must be used in a cell and which colorizes the end of
% the row;
% \item |\columncolor| which must be used in the preamble of the environment
% with the same syntax as the corresponding command of
% \pkg{colortbl} (however, unlike the command |\columncolor| of \pkg{colortbl},
% this command |\columncolor| can appear within another command, itself used in the
% preamble of the array).
% \end{itemize}
%
% \medskip
% \begin{Verbatim}
% \NewDocumentCommand { \Blue } { } { ~emphase#\columncolor{blue!15}@ }
% \begin{NiceTabular}[colortbl-like]{>{\Blue}c>{\Blue}cc}
% \toprule
% ~emphase#\rowcolor{red!15}@
% Last name & First name & Birth day \\
% \midrule
% Achard & Jacques & 5 juin 1962 \\
% Lefebvre & Mathilde & 23 mai 1988 \\
% Vanesse & Stephany & 30 octobre 1994 \\
% Dupont & Chantal & 15 janvier 1998 \\
% \bottomrule
% \end{NiceTabular}
% \end{Verbatim}
%
%
% \begin{center}
% \NewDocumentCommand { \Blue } { } { \columncolor{blue!15} }
% \begin{NiceTabular}[colortbl-like]{>{\Blue}c>{\Blue}cc}
% \toprule
% \rowcolor{red!15}
% Last name & First name & Birth day \\
% \midrule
% Achard & Jacques & 5 juin 1962 \\
% Lefebvre & Mathilde & 23 mai 1988 \\
% Vanesse & Stephany & 30 octobre 1994 \\
% Dupont & Chantal & 15 janvier 1998 \\
% \bottomrule
% \end{NiceTabular}
% \end{center}
%
% \section{The command \textbackslash RowStyle}
%
% \label{RowStyle}
%
% The command |\RowStyle| takes in as argument some formatting intructions that
% will be applied to each cell on the rest of the current row.
%
% \medskip
% That command also takes in as optional argument (between square brackets)
% a list of \textsl{key=value} pairs.
% \begin{itemize}
% \item The key |nb-rows| sets
% the number of rows to which the specifications of the current command will
% apply.
% \item The keys |cell-space-top-limit|, |cell-space-bottom-limit| and
% |cell-space-limits| are available with the same meaning that the corresponding
% global keys (cf. p.~\pageref{cell-space}).
% \item The key |rowcolor| sets
% the color of the background and the key |color| sets the
% color of the text.\footnote{The key |color| uses the command
% |\color| but inserts also an instruction |\leavevmode| before. This
% instruction prevents a extra vertical space in the cells which belong to
% columns of type |p|, |b|, |m| and |X| (which start in
% vertical mode).}
% \item The key |bold| enforces
% bold characters for the cells of the row, both in math mode and text mode.
% \end{itemize}
%
% \medskip
% \begin{BVerbatim}[boxwidth=12cm,baseline=c]
% \begin{NiceTabular}{cccc}
% \hline
% ~emphase#\RowStyle[cell-space-limits=3pt]{\rotate}@
% first & second & third & fourth \\
% ~emphase#\RowStyle[nb-rows=2,rowcolor=blue!50,color=white]{\sffamily}@
% 1 & 2 & 3 & 4 \\
% I & II & III & IV
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{cccc}
% \hline
% \RowStyle[cell-space-limits=3pt]{\rotate}
% first & second & third & fourth \\
% \RowStyle[nb-rows=2,rowcolor=blue!50,color=white]{\sffamily}
% 1 & 2 & 3 & 4 \\
% I & II & III & IV \\
% \end{NiceTabular}
%
% \medskip
% The command |\rotate| is described p.~\pageref{rotate}.
%
% \section{The width of the columns}
% \label{width}
%
% \subsection{Basic tools}
%
% In the environments with an explicit preamble (like |{NiceTabular}|,
% |{NiceArray}|, etc.), it's possible to fix the width of a given column with
% the standard letters |w|, |W|, |p|, |b| and |m| of the package \pkg{array}.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% \begin{NiceTabular}{~emphase#Wc{2cm}@cc}[hvlines]
% Paris & New York & Madrid \\
% Berlin & London & Roma \\
% Rio & Tokyo & Oslo
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{Wc{2cm}cc}[hvlines]
% Paris & New York & Madrid \\
% Berlin & London & Roma \\
% Rio & Tokyo & Oslo
% \end{NiceTabular}
%
%
% \bigskip
% In the environments of \pkg{nicematrix}, it's also possible to fix the \emph{minimal}
% width of all the columns (excepted the potential exterior columns: cf. p.~\pageref{exterior}) directly
% with the key |columns-width|.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $\begin{pNiceMatrix}[~emphase#columns-width = 1cm@]
% 1 & 12 & -123 \\
% 12 & 0 & 0 \\
% 4 & 1 & 2
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $\begin{pNiceMatrix}[columns-width = 1cm]
% 1 & 12 & -123 \\
% 12 & 0 & 0 \\
% 4 & 1 & 2
% \end{pNiceMatrix}$
%
% \medskip
% Note that the space inserted between two columns (equal to 2 |\tabcolsep| in
% |{NiceTabular}| and to 2 |\arraycolsep| in the other environments)
% is not suppressed (of course, it's possible to suppress this space by setting
% |\tabcolsep| or |\arraycolsep| equal to $0$~pt before the environment).
%
% \bigskip
% It's possible to give the special value |auto| to the option |columns-width|:
% all the columns of the array will have a width equal to the widest cell of the
% array.\footnote{The result is achieved with only one compilation (but PGF/Tikz
% will have written informations in the |aux| file and a message requiring a
% second compilation will appear).}\par\nobreak
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $\begin{pNiceMatrix}[~emphase#columns-width = auto@]
% 1 & 12 & -123 \\
% 12 & 0 & 0 \\
% 4 & 1 & 2
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $\begin{pNiceMatrix}[columns-width = auto]
% 1 & 12 & -123 \\
% 12 & 0 & 0 \\
% 4 & 1 & 2
% \end{pNiceMatrix}$
%
% \bigskip
% Without surprise, it's possible to fix the minimal width of the columns of all
% the arrays of a current scope with the command
% |\NiceMatrixOptions|.\par\nobreak
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
% ~emphase#\NiceMatrixOptions{columns-width=10mm}@
% $\begin{pNiceMatrix}
% a & b \\ c & d
% \end{pNiceMatrix}
% =
% \begin{pNiceMatrix}
% 1 & 1245 \\ 345 & 2
% \end{pNiceMatrix}$
% \end{BVerbatim}
% \begin{scope}
% \NiceMatrixOptions{columns-width=10mm}
% $\begin{pNiceMatrix}
% a & b \\
% c & d
% \end{pNiceMatrix}
% =
% \begin{pNiceMatrix}
% 1 & 1245 \\
% 345 & 2
% \end{pNiceMatrix}$
% \end{scope}
%
%
% \bigskip
% But it's also possible to fix a zone where all the matrices will have their
% columns of the same width, equal to the widest cell of all the matrices. This
% construction uses the environment |{NiceMatrixBlock}| with the option
% |auto-columns-width|\footnote{At this time, this is the only usage of the
% environment |{NiceMatrixBlock}| but it may have other usages in the future.}.
% The environment |{NiceMatrixBlock}| has no direct link with the command
% |\Block| presented previously in this document (cf.~p.~\pageref{Block}).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
% $\begin{array}{c}
% \begin{bNiceMatrix}
% 9 & 17 \\ -2 & 5
% \end{bNiceMatrix} \\ \\
% \begin{bNiceMatrix}
% 1 & 1245345 \\ 345 & 2
% \end{bNiceMatrix}
% \end{array}$
% ~emphase#\end{NiceMatrixBlock}@
% \end{BVerbatim}
% \begin{NiceMatrixBlock}[auto-columns-width]
% $\begin{array}{c}
% \begin{bNiceMatrix}
% 9 & 17 \\ -2 & 5
% \end{bNiceMatrix} \\ \\
% \begin{bNiceMatrix}
% 1 & 1245345 \\ 345 & 2
% \end{bNiceMatrix}
% \end{array}$
% \end{NiceMatrixBlock}
%
% \subsection{The columns V of varwidth}
%
% \label{varwidth}
%
% Let's recall first the behaviour of the environment |{varwidth}| of the
% eponymous package \pkg{varwidth}. That environment is similar to the classical
% environment |{minipage}| but the width provided in the argument is only the
% \emph{maximal} width of the created box. In the general case, the width of the
% box constructed by an environment |{varwidth}| is the natural width of its
% contents.
%
% \medskip
% That point is illustrated on the following examples.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=6cm]
% \fbox{%
% \begin{~emphase#varwidth@}{8cm}
% \begin{itemize}
% \item first item
% \item second item
% \end{itemize}
% \end{~emphase#varwidth@}}
% \end{BVerbatim}
% \fbox{\begin{varwidth}{8cm}
% \begin{itemize}
% \item first item
% \item second item
% \end{itemize}
% \end{varwidth}}
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=6cm]
% \fbox{%
% \begin{~emphase#minipage@}{8cm}
% \begin{itemize}
% \item first item
% \item second item
% \end{itemize}
% \end{~emphase#minipage@}}
% \end{BVerbatim}
% \fbox{\begin{minipage}{8cm}
% \begin{itemize}
% \item first item
% \item second item
% \end{itemize}
% \end{minipage}}
%
%
% \bigskip
% The package \pkg{varwidth} provides also the column type |V|. A column of type
% |V{|$\langle$\textsl{dim}$\rangle$|}| encapsulates all its cells in a
% |{varwidth}| with the argument $\langle$\textsl{dim}$\rangle$ (and does also some tuning).
%
% \smallskip
% When the package \pkg{varwidth} is loaded, the columns |V| of \pkg{varwidth}
% are supported by \pkg{nicematrix}. Concerning \pkg{nicematrix}, one of the
% interests of this type of columns is that, for a cell of a column of type~|V|,
% the PGF/Tikz node created by \pkg{nicematrix} for the content of that cell has
% a width adjusted to the content of the cell : cf. p.~\pageref{node-V}. If the
% content of the cell is empty, the cell will be considered as empty by
% \pkg{nicematrix} in the construction of the dotted lines and the «empty
% corners» (that's not the case with a cell of a column |p|, |m| or |b|).
%
% \medskip
% \begin{Verbatim}
% \begin{NiceTabular}[corners=NW,hvlines]{~emphase#V{3cm}V{3cm}V{3cm}@}
% & some very very very long text & some very very very long text \\
% some very very very long text \\
% some very very very long text
% \end{NiceTabular}
% \end{Verbatim}
%
% \medskip
% \begin{center}
% \begin{NiceTabular}[corners=NW,hvlines]{V{3cm}V{3cm}V{3cm}}
% & some very very very long text & some very very very long text \\
% some very very very long text \\
% some very very very long text
% \end{NiceTabular}
% \end{center}
%
% \bigskip
% One should remark that the extension \pkg{varwidth} (at least in its version
% 0.92) has some problems: for instance, with LuaLaTeX, it does not work when
% the content begins with |\color|.
%
%
% \subsection{The columns X}
%
% \label{X-columns}
%
% The environment |{NiceTabular}| provides |X| columns similar to those provided
% by the environment |{tabularx}| of the eponymous package.
%
% The required width of the tabular may be specified with the key |width| (in
% |{NiceTabular}| or in |\NiceMatrixOptions|). The initial value of this
% parameter is |\linewidth| (and not |\textwidth|).
%
% For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix}
% also provides an environment |{NiceTabularX}| with a first mandatory argument
% which is the width of the tabular.\footnote{If \pkg{tabularx} is loaded, one
% must use |{NiceTabularX}| (and not |{NiceTabular}|) in order to use the
% columns |X| (this point comes from a conflict in the definitions of the
% specifier |X|).}
%
% As with the packages \pkg{tabu} and \pkg{tabularray}, the specifier |X| takes
% in an optional argument (between square brackets) which is a list of keys.
% \begin{itemize}
% \item It's possible to give a weight for the column by providing a positive
% integer directly as argument of the specifier |X|. For example, a column
% |X[2]| will have a width double of the width of a column~|X| (which has a
% weight equal to $1$).\footnote{The negative values of the weight, as provided
% by \pkg{tabu} (which is now obsolete), are \emph{not} supported by \pkg{nicematrix}.
% If such a value is used, an error will be raised.}
% \item It's possible to specify an horizontal alignment with one of the
% letters |l|, |c| and |r| (which insert respectively |\raggedright|,
% |\centering| and |\raggedleft| followed by |\arraybackslash|).
% \item It's possible to specify a vertical alignment with one of the keys
% |t| (alias |p|), |m| and |b| (which construct respectively columns of type
% |p|, |m| and |b|). The default value is |t|.
% \end{itemize}
%
% \begin{Verbatim}
% \begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines]
% a rather long text which fits on several lines
% & a rather long text which fits on several lines \\
% a shorter text & a shorter text
% \end{NiceTabular}
% \end{Verbatim}
%
% \begin{center}
% \begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines]
% a rather long text which fits on several lines
% & a rather long text which fits on several lines \\
% a shorter text & a shorter text
% \end{NiceTabular}
% \end{center}
%
% \bigskip
% \section{The exterior rows and columns}
%
% The options |first-row|, |last-row|, |first-col| and |last-col| allow the
% composition of exterior rows and columns in the environments of
% \pkg{nicematrix}. It's particularly interesting for the (methematical)
% matrices.
% \label{exterior}
%
% A potential ``first row'' (exterior) has the number $0$ (and not $1$). Idem
% for the potential ``first column''.
%
% \begin{Verbatim}
% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots]
% & C_1 & \Cdots & & C_4 & \\
% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
% & a_{31} & a_{32} & a_{33} & a_{34} & \\
% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
% & C_1 & \Cdots & & C_4 &
% \end{pNiceMatrix}$
% \end{Verbatim}
%
% \[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots]
% & C_1 & \Cdots & & C_4 & \\
% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
% & a_{31} & a_{32} & a_{33} & a_{34} & \\
% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
% & C_1 & \Cdots & & C_4 &
% \end{pNiceMatrix}\]
%
% \medskip
% The dotted lines have been drawn with the tools presented p.~\pageref{Cdots}.
%
% \bigskip
% We have several remarks to do.
% \begin{itemize}[beginpenalty=10000]
% \item For the environments with an explicit preamble (i.e. |{NiceTabular}|,
% |{NiceArray}| and its variants), no letter must be given in that preamble for
% the potential first column and the potential last column: they will
% automatically (and necessarily) be of type |r| for the first column and |l|
% for the last one.\footnote{The users wishing exterior columns with another
% type of alignment should consider the command |\SubMatrix| available in the
% |\CodeAfter| (cf.~p.~\pageref{sub-matrix}).}
% \item One may wonder how \pkg{nicematrix} determines the number of rows and
% columns which are needed for the composition of the ``last row'' and ``last
% column''.
% \begin{itemize}
% \item For the environments with explicit preamble, like |{NiceTabular}| and
% |{pNiceArray}|, the number of columns can obviously be computed from the
% preamble.
%
% \item When the option |light-syntax| (cf. p. \pageref{light-syntax}) is used,
% \pkg{nicematrix} has, in any case, to load the whole body of the environment
% (and that's why it's not possible to put verbatim material in the array with
% the option |light-syntax|). The analysis of this whole body gives the number
% of rows (but not the number of columns).
%
% \item In the other cases, \pkg{nicematrix} compute the number of rows and
% columns during the first compilation and write the result in the |aux| file
% for the next run.
%
% \textsl{However, it's possible to provide the number of the last row and the
% number of the last column as values of the options |last-row| and |last-col|,
% tending to an acceleration of the whole compilation of the document.} That's
% what we will do throughout the rest of the document.
% \end{itemize}
% \end{itemize}
%
% \bigskip
% It's possible to control the appearance of these rows and columns with options
% |code-for-first-row|, |code-for-last-row|, |code-for-first-col| and
% |code-for-last-col|. These options specify tokens that will be inserted before
% each cell of the corresponding row or column.
%
%
% \begin{Verbatim}
% \NiceMatrixOptions{~emphase#code-for-first-row@ = \color{red},
% ~emphase#code-for-first-col@ = \color{blue},
% ~emphase#code-for-last-row@ = \color{green},
% ~emphase#code-for-last-col@ = \color{magenta}}
% $\begin{pNiceArray}{cc|cc}[first-row,last-row=5,first-col,last-col,nullify-dots]
% & C_1 & \Cdots & & C_4 & \\
% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
% \hline
% & a_{31} & a_{32} & a_{33} & a_{34} & \\
% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
% & C_1 & \Cdots & & C_4 &
% \end{pNiceArray}$
% \end{Verbatim}
%
% \begin{scope}
% \NiceMatrixOptions{code-for-first-row = \color{red},
% code-for-first-col = \color{blue},
% code-for-last-row = \color{green},
% code-for-last-col = \color{magenta}}
% \begin{displaymath}
% \begin{pNiceArray}{cc|cc}[first-row,last-row=5,first-col,last-col,nullify-dots]
% & C_1 & \multicolumn1c{\Cdots} & & C_4 & \\
% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
% \hline
% & a_{31} & a_{32} & a_{33} & a_{34} & \\
% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
% & C_1 & \multicolumn1c{\Cdots} & & C_4 &
% \end{pNiceArray}
% \end{displaymath}
% \end{scope}
%
%
% \emph{Remarks}
% \begin{itemize}[beginpenalty=10000]
% \item As shown in the previous example, the horizontal and vertical rules
% don't extend in the exterior rows and columns. This remark also applies to the
% customized rules created by the key |custom-line|
% (cf.~p.~\pageref{custom-line}).
%
% \item A specification of color present in |code-for-first-row| also applies to
% a dotted line drawn in that exterior ``first row'' (excepted if a value has
% been given to |xdots/color|). Idem for the other exterior rows and columns.
%
% \item Logically, the potential option |columns-width| (described
% p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''.
%
% \item For technical reasons, it's not possible to use the option of the
% command |\\| after the ``first row'' or before the ``last row''. The placement
% of the delimiters would be wrong. If you are looking for a workaround,
% consider the command |\SubMatrix| in the |\CodeAfter| described
% p.~\pageref{sub-matrix}.
% \end{itemize}
%
%
%
%
%
% \section{The continuous dotted lines}
%
% \label{Cdots}
% Inside the environments of the package \pkg{nicematrix}, new commands are
% defined: |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots|. These commands
% are intended to be used in place of |\dots|, |\cdots|, |\vdots|, |\ddots| and
% |\iddots|.\footnote{The command |\iddots|, defined in \pkg{nicematrix}, is a
% variant of |\ddots| with dots going forward. If |mathdots| is loaded, the
% version of |mathdots| is used. It corresponds to the command |\adots| of
% \pkg{unicode-math}.}
% \newcounter{fniddots}
% \setcounter{fniddots}{\thefootnote}
%
% \smallskip
% Each of them must be used alone in the cell of the array and it draws a dotted
% line between the first non-empty cells\footnote{The precise definition of a
% ``non-empty cell'' is given below (cf. p.~\pageref{empty-cells}).} on both
% sides of the current cell. Of course, for |\Ldots| and |\Cdots|, it's an
% horizontal line; for |\Vdots|, it's a vertical line and for |\Ddots| and
% |\Iddots| diagonal ones. It's possible to change the color of these lines
% with the option |color|.\footnote{It's also possible to change the color of
% all these dotted lines with the option |xdots/color| (\textsl{xdots} to
% remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p.
% \pageref{customisation}.}\par\nobreak
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{bNiceMatrix}
% a_1 & \Cdots & & & a_1 \\
% \Vdots & a_2 & \Cdots & & a_2 \\
% & \Vdots & \Ddots[color=red] \\
% \\
% a_1 & a_2 & & & a_n
% \end{bNiceMatrix}
% \end{BVerbatim}
% $\begin{bNiceMatrix}
% a_1 & \Cdots & & & a_1 \\
% \Vdots & a_2 & \Cdots & & a_2 \\
% & \Vdots & \Ddots[color=red] \\
% \\
% a_1 & a_2 & & & a_n
% \end{bNiceMatrix}$
%
% \interitem
% In order to represent the null matrix, one can use the following
% codage:\par\nobreak
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{bNiceMatrix}
% 0 & \Cdots & 0 \\
% \Vdots & & \Vdots \\
% 0 & \Cdots & 0
% \end{bNiceMatrix}
% \end{BVerbatim}
% $\begin{bNiceMatrix}
% 0 & \Cdots & 0 \\
% \Vdots & & \Vdots \\
% 0 & \Cdots & 0
% \end{bNiceMatrix}$
%
% \bigskip
% However, one may want a larger matrix. Usually, in such a case, the users of
% LaTeX add a new row and a new column. It's possible to use the same method
% with \pkg{nicematrix}:\par\nobreak
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{bNiceMatrix}
% 0 & \Cdots & \Cdots & 0 \\
% \Vdots & & & \Vdots \\
% \Vdots & & & \Vdots \\
% 0 & \Cdots & \Cdots & 0
% \end{bNiceMatrix}
% \end{BVerbatim}
% $\begin{bNiceMatrix}
% 0 & \Cdots & \Cdots & 0 \\
% \Vdots & & & \Vdots \\
% \Vdots & & & \Vdots \\
% 0 & \Cdots & \Cdots & 0
% \end{bNiceMatrix}$
%
% \bigskip
% In the first column of this exemple, there are two instructions |\Vdots| but,
% of course, only one dotted line is drawn.
%
% \bigskip
% In fact, in this example, it would be possible to draw the same matrix more
% easily with the following code:\par\nobreak
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{bNiceMatrix}
% 0 & \Cdots & & 0 \\
% \Vdots & & & \\
% & & & \Vdots \\
% 0 & & \Cdots & 0
% \end{bNiceMatrix}
% \end{BVerbatim}
% $\begin{bNiceMatrix}
% 0 & \Cdots & & 0 \\
% \Vdots & & & \\
% & & & \Vdots \\
% 0 & & \Cdots & 0
% \end{bNiceMatrix}$
%
% \bigskip
% There are also other means to change the size of the matrix. Someone might
% want to use the optional argument of the command~|\\| for the vertical
% dimension and a command~|\hspace*| in a cell for the horizontal
% dimension.\footnote{In \pkg{nicematrix}, one should use |\hspace*| and not
% |\hspace| for such an usage because \pkg{nicematrix} loads \pkg{array}. One
% may also remark that it's possible to fix the width of a column by using the
% environment |{NiceArray}| (or one of its variants) with a column of type~|w|
% or~|W|: see p.~\pageref{width}}
%
% However, a command~|\hspace*| might interfer with the construction of the
% dotted lines. That's why the package \pkg{nicematrix} provides a
% command~|\Hspace| which is a variant of |\hspace| transparent for the dotted
% lines of \pkg{nicematrix}.\par\nobreak
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{bNiceMatrix}
% 0 & \Cdots & ~emphase#\Hspace*{1cm}@ & 0 \\
% \Vdots & & & \Vdots \\~emphase#[1cm]@
% 0 & \Cdots & & 0
% \end{bNiceMatrix}
% \end{BVerbatim}
% $\begin{bNiceMatrix}
% 0 & \Cdots & \Hspace*{1cm} & 0 \\
% \Vdots & & & \Vdots \\[1cm]
% 0 & \Cdots & & 0
% \end{bNiceMatrix}$
%
% \subsection{The option nullify-dots}
%
%
% Consider the following matrix composed classicaly with the environment
% |{pmatrix}| of \pkg{amsmath}.\par\nobreak
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $A = \begin{pmatrix}
% h & i & j & k & l & m \\
% x & & & & & x
% \end{pmatrix}$
% \end{BVerbatim}
% $A = \begin{pmatrix}
% h & i & j & k & l & m \\
% x & & & & & x
% \end{pmatrix}$
%
%
% \bigskip
% If we add |\ldots| instructions in the second row, the geometry of the
% matrix is modified.\par\nobreak
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $B = \begin{pmatrix}
% h & i & j & k & l & m \\
% x & \ldots & \ldots & \ldots & \ldots & x
% \end{pmatrix}$
% \end{BVerbatim}
% $B = \begin{pmatrix}
% h & i & j & k & l & m \\
% x & \ldots & \ldots & \ldots & \ldots & x
% \end{pmatrix}$
%
% \bigskip
% By default, with \pkg{nicematrix}, if we replace |{pmatrix}| by
% |{pNiceMatrix}| and |\ldots| by |\Ldots|, the geometry of the matrix is not
% changed.\par\nobreak
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $C = \begin{pNiceMatrix}
% h & i & j & k & l & m \\
% x & \Ldots & \Ldots & \Ldots & \Ldots & x
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $C = \begin{pNiceMatrix}
% h & i & j & k & l & m \\
% x & \Ldots & \Ldots & \Ldots & \Ldots & x
% \end{pNiceMatrix}$
%
% \bigskip
% However, one may prefer the geometry of the first matrix $A$ and would like to
% have such a geometry with a dotted line in the second row. It's possible by
% using the option |nullify-dots| (and only one instruction |\Ldots| is
% necessary).\par\nobreak
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $D = \begin{pNiceMatrix}[~emphase#nullify-dots@]
% h & i & j & k & l & m \\
% x & \Ldots & & & & x
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $D = \begin{pNiceMatrix}[nullify-dots]
% h & i & j & k & l & m \\
% x & \Ldots & & & & x
% \end{pNiceMatrix}$
%
% \medskip
% The option |nullify-dots| smashes the instructions |\Ldots| (and the variants)
% horizontally but also vertically.
%
%
%
% \subsection{The commands \textbackslash Hdotsfor and \textbackslash Vdotsfor}
%
% Some people commonly use the command |\hdotsfor| of \pkg{amsmath} in order to
% draw horizontal dotted lines in a matrix. In the environments of
% \pkg{nicematrix}, one should use instead |\Hdotsfor| in order to draw dotted
% lines similar to the other dotted lines drawn by the package \pkg{nicematrix}.
%
% As with the other commands of \pkg{nicematrix} (like |\Cdots|, |\Ldots|,
% |\Vdots|, etc.), the dotted line drawn with |\Hdotsfor| extends until the
% contents of the cells on both sides.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=7cm]
% $\begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 \\
% 1 & ~emphase#\Hdotsfor{3}@ & 5 \\
% 1 & 2 & 3 & 4 & 5 \\
% 1 & 2 & 3 & 4 & 5
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $\begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 \\
% 1 & \Hdotsfor{3} & 5 \\
% 1 & 2 & 3 & 4 & 5 \\
% 1 & 2 & 3 & 4 & 5
% \end{pNiceMatrix}$
%
% \bigskip
% However, if these cells are empty, the dotted line extends only in the cells
% specified by the argument of |\Hdotsfor| (by design).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=7cm]
% $\begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 \\
% & ~emphase#\Hdotsfor{3}@ \\
% 1 & 2 & 3 & 4 & 5 \\
% 1 & 2 & 3 & 4 & 5
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $\begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 \\
% & \Hdotsfor{3} \\
% 1 & 2 & 3 & 4 & 5 \\
% 1 & 2 & 3 & 4 & 5
% \end{pNiceMatrix}$
%
% \medskip
% Remark: Unlike the command |\hdotsfor| of \pkg{amsmath}, the command
% |\Hdotsfor| may be used even when the package \pkg{colortbl}\footnote{We
% recall that when \pkg{xcolor} is loaded with the option |table|, the
% package \pkg{colortbl} is loaded.} is loaded (but you might have problem if
% you use |\rowcolor| on the same row as |\Hdotsfor|).
%
% \bigskip
% The package \pkg{nicematrix} also provides a command |\Vdotsfor| similar to
% |\Hdotsfor| but for the vertical dotted lines.
% \bigskip
% The following example uses both |\Hdotsfor| and |\Vdotsfor|:
%
% \begin{Verbatim}[formatcom=\small\color{gray}]
% \begin{bNiceMatrix}
% C[a_1,a_1] & \Cdots & C[a_1,a_n]
% & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\
% \Vdots & \Ddots & \Vdots
% & ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\
% C[a_n,a_1] & \Cdots & C[a_n,a_n]
% & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\
% \rule{0pt}{15mm}\NotEmpty & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\
% C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n]
% & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\
% \Vdots & \Ddots & \Vdots
% & ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\
% C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n]
% & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}]
% \end{bNiceMatrix}
% \end{Verbatim}
%
%
% \[\begin{bNiceMatrix}
% C[a_1,a_1] & \Cdots & C[a_1,a_n] & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\
% \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\
% C[a_n,a_1] & \Cdots & C[a_n,a_n] & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\
% \rule{0pt}{15mm}\NotEmpty & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\
% C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\
% \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\
% C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}]
% \end{bNiceMatrix}\]
%
%
%
%
% \subsection{How to generate the continuous dotted lines transparently}
%
% Imagine you have a document with a great number of mathematical matrices with
% ellipsis. You may wish to use the dotted lines of \pkg{nicematrix} without
% having to modify the code of each matrix. It's possible with the keys.
% |renew-dots| and |renew-matrix|.\footnote{The options |renew-dots|,
% |renew-matrix| can be fixed with the command
% |\NiceMatrixOptions| like the other options. However, they can also be fixed
% as options of the command |\usepackage|. There is also a key |transparent|
% which is an alias for the conjonction of |renew-dots| and |renew-matrix| but it
% must be considered as obsolete.}
%
% \smallskip
%
% \begin{itemize}
% \item The option |renew-dots|\par\nobreak
%
% With this option, the commands |\ldots|, |\cdots|, |\vdots|, |\ddots|,
% |\iddots|\footnotemark[\thefniddots] and |\hdotsfor| are redefined within the
% environments provided by \pkg{nicematrix} and behave like |\Ldots|, |\Cdots|,
% |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor|; the command |\dots|
% (``automatic dots'' of |amsmath|) is also redefined to behave like |\Ldots|.
%
% \item The option |renew-matrix|\par\nobreak
%
% With this option, the environment |{matrix}| is redefined and behave like
% |{NiceMatrix}|, and so on for the five variants.
% \end{itemize}
%
% \bigskip
% Therefore, with the keys |renew-dots| and |renew-matrix|, a classical code
% gives directly the ouput of \pkg{nicematrix}.\par\nobreak
%
% \bigskip
% \begin{scope}
% \NiceMatrixOptions{renew-dots,renew-matrix}
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% ~emphase#\NiceMatrixOptions{renew-dots,renew-matrix}@
% \begin{pmatrix}
% 1 & \cdots & \cdots & 1 \\
% 0 & \ddots & & \vdots \\
% \vdots & \ddots & \ddots & \vdots \\
% 0 & \cdots & 0 & 1
% \end{pmatrix}
% \end{BVerbatim}
% $\begin{pmatrix}
% 1 & \cdots & \cdots & 1 \\
% 0 & \ddots & & \vdots \\
% \vdots & \ddots & \ddots & \vdots \\
% 0 & \cdots & 0 & 1
% \end{pmatrix}$
% \end{scope}
%
% \subsection{The labels of the dotted lines}
%
% The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor|
% (and the command |\line| in the |\CodeAfter| which is described
% p.~\pageref{line-in-code-after}) accept two optional arguments specified
% by the tokens |_| and |^| for labels positionned below and above the line. The
% arguments are composed in math mode with |\scriptstyle|.
%
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $\begin{bNiceMatrix}
% 1 & \hspace*{1cm} & 0 \\[8mm]
% & ~emphase#\Ddots^{n \text{ times}}@ & \\
% 0 & & 1
% \end{bNiceMatrix}$
% \end{BVerbatim}
% $\begin{bNiceMatrix}
% 1 & \hspace*{1cm} & 0 \\[8mm]
% & \Ddots^{n \text{ times}} & \\
% 0 & & 1
% \end{bNiceMatrix}$
%
% \subsection{Customisation of the dotted lines}
%
% \label{customisation}
% The dotted lines drawn by |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots|,
% |\Hdotsfor| and |\Vdotsfor| (and by the command |\line| in the |\CodeAfter|
% which is described p.~\pageref{line-in-code-after}) may be customized by three
% options (specified between square brackets after the command):
% \begin{itemize}
% \item |color|;
% \item |shorten|;
% \item |line-style|.
% \end{itemize}
%
% These options may also be fixed with |\NiceMatrixOptions|, as options of
% |\CodeAfter| or at the level of a given environment but, in those cases, they
% must be prefixed by |xdots| (\textsl{xdots} to remind that it works for
% |\Cdots|, |\Ldots|, |\Vdots|, etc.), and, thus have for names:
% \begin{itemize}
% \item |xdots/color|;
% \item |xdots/shorten|;
% \item |xdots/line-style|.
% \end{itemize}
%
% For the clarity of the explanations, we will use those names.
%
% \bigskip
% \textbf{The option xdots/color}\par\nobreak
%
% \smallskip
% The option |xdots/color| fixes the color or the dotted line. However, one should
% remark that the dotted lines drawn in the exterior rows and columns have a
% special treatment: cf. p.~\pageref{exterior}.
%
% \bigskip
% \textbf{The option xdots/shorten}\par\nobreak
%
% \smallskip
% The option |xdots/shorten| fixes the margin of both extremities of the line.
% The name is derived from the options ``|shorten >|'' and ``|shorten <|'' of
% Tikz but one should notice that \pkg{nicematrix} only provides
% |xdots/shorten|. The initial value of this parameter is 0.3~em (it is
% recommanded to use a unit of length dependent of the current font).
%
% \bigskip
% \textbf{The option xdots/line-style}\par\nobreak
%
% \smallskip
% It should be pointed that, by default, the lines drawn by Tikz with the
% parameter |dotted| are composed of square dots (and not rounded
% ones).\footnote{The first reason of this behaviour is that the \textsc{pdf}
% format includes a description for dashed lines. The lines specified with this
% descriptor are displayed very efficiently by the \textsc{pdf} readers. It's
% easy, starting from these dashed lines,
% to create a line composed by square dots whereas a line of rounded dots needs
% a specification of each dot in the \textsc{pdf} file.}
%
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% \tikz \draw [dotted] (0,0) -- (5,0) ;
% \end{BVerbatim}
% \tikz \draw [dotted] (0,0) -- (5,0) ;
%
% \medskip
% In order to provide lines with rounded dots in the style of those provided by
% |\ldots| (at least with the \emph{Computer Modern} fonts), the package
% \pkg{nicematrix} embeds its own system to draw a dotted line (and this system
% uses \textsc{pgf} and not Tikz). This style is called |standard| and that's
% the initial value of the parameter |xdots/line-style|.
%
% However (when Tikz is loaded) it's possible to use for |xdots/line-style| any style
% provided by Tikz, that is to say any sequence of options provided by Tikz for
% the Tizk pathes (with the exception of ``|color|'', ``|shorten >|'' and
% ``|shorten <|'').
%
% \medskip
% Here is for example a tridiagonal matrix with the style |loosely dotted|:\par\nobreak
%
% \medskip
% \begin{BVerbatim}[baseline=c]
% $\begin{pNiceMatrix}[nullify-dots,~emphase#xdots/line-style=loosely dotted@]
% a & b & 0 & & \Cdots & 0 \\
% b & a & b & \Ddots & & \Vdots \\
% 0 & b & a & \Ddots & & \\
% & \Ddots & \Ddots & \Ddots & & 0 \\
% \Vdots & & & & & b \\
% 0 & \Cdots & & 0 & b & a
% \end{pNiceMatrix}$
% \end{BVerbatim}
%
%
% \[\begin{pNiceMatrix}[nullify-dots,xdots/line-style=loosely dotted]
% a & b & 0 & & \Cdots & 0 \\
% b & a & b & \Ddots & & \Vdots \\
% 0 & b & a & \Ddots & & \\
% & \Ddots & \Ddots & \Ddots & & 0 \\
% \Vdots & & & & & b \\
% 0 & \Cdots & & 0 & b & a
% \end{pNiceMatrix}\]
%
%
% \subsection{The dotted lines and the rules}
%
% \label{dotted-and-rules}
%
% The dotted lines determine virtual blocks which have the same behaviour
% regarding the rules (the rules specified by the specifier \verb+|+ in the
% preamble, by the command |\Hline|, by the keys |hlines|, |vlines|,
% |hvlines| and |hvlines-except-borders| and by the tools created by
% |custom-line| are not drawn within the
% blocks).\footnote{On the other side, the command |\line| in the
% |\CodeAfter| (cf.~p.~\pageref{line-in-code-after}) does \emph{not} create
% block.}
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
% $\begin{bNiceMatrix}[margin,~emphase#hvlines@]
% \Block{3-3}<\LARGE>{A} & & & 0 \\
% & \hspace*{1cm} & & \Vdots \\
% & & & 0 \\
% 0 & \Cdots& 0 & 0
% \end{bNiceMatrix}$
% \end{BVerbatim}
% $\begin{bNiceMatrix}[margin,hvlines]
% \Block{3-3}<\LARGE>{A} & & & 0 \\
% & \hspace*{1cm} & & \Vdots \\
% & & & 0 \\
% 0 & \Cdots& 0 & 0
% \end{bNiceMatrix}$
%
%
%
% \section{The \textbackslash CodeAfter}
%
% \label{code-after}
% The option |code-after| may be used to give some code that will be executed
% \emph{after} the construction of the matrix.\footnote{There is also a key
% |code-before| described p.~\pageref{code-before}.}
%
% \medskip
% For the legibility of the code, an alternative syntax is provided: it's
% possible to give the instructions of the |code-after| at the end of the
% environment, after the keyword |\CodeAfter|. Although |\CodeAfter| is a
% keyword, it takes in an optional argument (between square brackets). The keys
% accepted in that optional ragument form a subset of the keys of the command
% |\WithArrowsOptions|.
%
%
% \medskip
% The experienced users may, for instance, use the PGF/Tikz nodes created by
% \pkg{nicematrix} in the |\CodeAfter|. These nodes are described further
% beginning on p.~\pageref{PGF-nodes}.
%
% \medskip
% Moreover, several special commands are available in the |\CodeAfter|: |line|,
% |\SubMatrix|, |\OverBrace| and |\UnderBrace|. We will now present these commands.
%
% \subsection{The command \textbackslash line in the \textbackslash CodeAfter}
%
% \label{line-in-code-after}
% The command |\line| draws directly dotted lines between nodes. It takes in two
% arguments for the two cells to link, both of the form $i$-$j$ where is the
% number of the row and $j$ is the number of the column. The options available
% for the customisation of the dotted lines created by |\Cdots|, |\Vdots|, etc.
% are also available for this command (cf. p.~\pageref{customisation}).
%
% \bigskip
% This command may be used, for example, to draw a dotted line between two
% adjacent cells.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
% \NiceMatrixOptions{xdots/shorten = 0.6 em}
% \begin{pNiceMatrix}
% I & 0 & \Cdots &0 \\
% 0 & I & \Ddots &\Vdots\\
% \Vdots &\Ddots & I &0 \\
% 0 &\Cdots & 0 &I
% ~emphase#\CodeAfter \line{2-2}{3-3}@
% \end{pNiceMatrix}
% \end{BVerbatim}
% \begin{scope}
% \NiceMatrixOptions{xdots/shorten = 0.6 em}
% $\begin{pNiceMatrix}
% I & 0 & \Cdots &0 \\
% 0 & I & \Ddots &\Vdots\\
% \Vdots &\Ddots & I &0 \\
% 0 &\Cdots & 0 &I
% \CodeAfter \line{2-2}{3-3}
% \end{pNiceMatrix}$
% \end{scope}
%
% \bigskip
% It can also be used to draw a diagonal line not parallel to the other diagonal
% lines (by default, the dotted lines drawn by |\Ddots| are ``parallelized'':
% cf.~p.~\pageref{parallelization}).
%
% \medskip
% \begin{BVerbatim}
% \begin{bNiceMatrix}
% 1 & \Cdots & & 1 & 2 & \Cdots & 2 \\
% 0 & \Ddots & & \Vdots & \Vdots & \hspace*{2.5cm} & \Vdots \\
% \Vdots & \Ddots & & & & & \\
% 0 & \Cdots & 0 & 1 & 2 & \Cdots & 2
% ~emphase#\CodeAfter \line[shorten=6pt]{1-5}{4-7}@
% \end{bNiceMatrix}
% \end{BVerbatim}
% \[\begin{bNiceMatrix}
% 1 & \Cdots & & 1 & 2 & \Cdots & 2 \\
% 0 & \Ddots & & \Vdots & \Vdots & \hspace*{2.5cm} & \Vdots \\
% \Vdots & \Ddots & & & & & \\
% 0 & \Cdots & 0 & 1 & 2 & \Cdots & 2
% \CodeAfter \line[shorten=6pt]{1-5}{4-7}
% \end{bNiceMatrix}\]
%
%
%
% \subsection{The command \textbackslash SubMatrix in the \textbackslash CodeAfter}
%
% \label{sub-matrix}
%
% The command |\SubMatrix| provides a way to put delimiters on a portion
% of the array considered as a submatrix. The command |\SubMatrix| takes in five
% arguments:
% \begin{itemize}
% \item the first argument is the left delimiter, which may be any extensible delimiter
% provided by LaTeX : |(|, |[|, |\{|, |\langle|, |\lgroup|, |\lfloor|, etc. but also
% the null delimiter |.|;
% \item the second argument is the upper-left corner of the submatrix with the
% syntax $i$|-|$j$ where $i$ the number of row and $j$ the number of column;
% \item the third argument is the lower-right corner with the same syntax;
% \item the fourth argument is the right delimiter;
% \item the last argument, which is optional, is a list of \textsl{key=value}
% pairs.\footnote{There is no optional argument between square brackets in first
% position because a square bracket just after |\SubMatrix| must be interpreted
% as the first (mandatory) argument of the command |\SubMatrix|: that bracket is
% the left delimiter of the sub-matrix to construct (eg.:
% |\SubMatrix[{2-2}{4-7}]|).}
% \end{itemize}
%
% One should remark that the command |\SubMatrix| draws the delimiters after the
% construction of the array: no space is inserted by the command |\SubMatrix|
% itself. That's why, in the following example, we have used the key |margin|
% and you have added by hand some space between the third and fourth column with
% |@{\hspace{1.5em}}| in the preamble of the array.
%
% \medskip
% \begin{scope}
% \hfuzz=15cm
% \fvset{commandchars=\~\#\+}%
% \begin{BVerbatim}[boxwidth=11cm,baseline=c]
% \[\begin{NiceArray}{ccc~emphase#@{\hspace{1.5em}}+c}[cell-space-limits=2pt,~emphase#margin+]
% 1 & 1 & 1 & x \\
% \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\
% 1 & 2 & 3 & z
% \CodeAfter
% ~emphase#\SubMatrix({1-1}{3-3})+
% ~emphase#\SubMatrix({1-4}{3-4})+
% \end{NiceArray}\]
% \end{BVerbatim}
% \end{scope}
% $\begin{NiceArray}{ccc@{\hspace{1.5em}}c}[cell-space-limits=2pt,margin]
% 1 & 1 & 1 & x \\
% \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\
% 1 & 2 & 3 & z
% \CodeAfter
% \SubMatrix({1-1}{3-3})
% \SubMatrix({1-4}{3-4})
% \end{NiceArray}$
%
% \bigskip
% In fact, the command |\SubMatrix| also takes in two optional arguments
% specified by the traditional symbols |^| and |_| for material in superscript
% and subscript.
%
% \medskip
% \begin{scope}
% \hfuzz=15cm
% \begin{BVerbatim}[boxwidth=11cm,baseline=c]
% $\begin{bNiceMatrix}[right-margin=1em]
% 1 & 1 & 1 \\
% 1 & a & b \\
% 1 & c & d
% \CodeAfter
% ~emphase#\SubMatrix[{2-2}{3-3}]^{T}@
% \end{bNiceMatrix}$
% \end{BVerbatim}
% $\begin{bNiceMatrix}[right-margin=1em]
% 1 & 1 & 1 \\
% 1 & a & b \\
% 1 & c & d
% \CodeAfter
% \SubMatrix[{2-2}{3-3}]^{T}
% \end{bNiceMatrix}$
% \end{scope}
%
%
% \bigskip
% The options of the command |\SubMatrix| are as follows:
% \begin{itemize}
% \item |left-xshift| and |right-xshift| shift horizontally the delimiters (there
% exists also the key |xshift| which fixes both parameters);
% \item |extra-height| adds a quantity to the total height of the delimiters
% (height |\ht| + depth |\dp|);
% \item |delimiters/color| fixes the color of the delimiters (also
% available in |\NiceMatrixOptions|, in the environments with delimiters and as
% option of the keyword |\CodeAfter|);
% \item |slim| is a boolean key: when that key is in force, the horizontal
% position of the delimiters is computed by using only the contents of the cells
% of the submatrix whereas, in the general case, the position is computed by
% taking into account the cells of the whole columns implied in the submatrix
% (see example below). ;
% \item |vlines| contents a list of numbers of vertical rules that will be drawn in
% the sub-matrix (if this key is used without value, all the vertical rules of
% the sub-matrix are drawn);
% \item |hlines| is similar to |vlines| but for the horizontal rules;
% \item |hvlines|, which must be used without value, draws all the vertical and
% horizontal rules.
% \end{itemize}
% One should remark that these keys add their rules after the construction of
% the main matrix: no space is added between the rows and the columns of the
% array for theses rules.
%
% \bigskip
% All these keys are also available in |\NiceMatrixOptions|, at the level of the
% environments of \pkg{nicematrix} or as option of the command |\CodeAfter| with
% the prefix |sub-matrix| which means that their names are therefore
% |sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc.
%
% \bigskip
% \begin{scope}
% \hfuzz=12cm
% \fvset{commandchars=\~\#\!}%
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt]
% & & \frac12 \\
% & & \frac14 \\[1mm]
% a & b & \frac12a+\frac14b \\
% c & d & \frac12c+\frac14d \\
% \CodeAfter
% \SubMatrix({1-3}{2-3})
% \SubMatrix({3-1}{4-2})
% \SubMatrix({3-3}{4-3})
% \end{NiceArray}$
% \end{BVerbatim}
% \end{scope}
% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt]
% & & \frac12 \\
% & & \frac14 \\[1mm]
% a & b & \frac12a+\frac14b \\
% c & d & \frac12c+\frac14d \\
% \CodeAfter
% \SubMatrix({1-3}{2-3})
% \SubMatrix({3-1}{4-2})
% \SubMatrix({3-3}{4-3})
% \end{NiceArray}$
%
% \medskip
% Here is the same example with the key |slim| used for one of the submatrices.
%
% \medskip
% \begin{scope}
% \hfuzz=12cm
% \fvset{commandchars=\~\#\!}%
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt]
% & & \frac12 \\
% & & \frac14 \\[1mm]
% a & b & \frac12a+\frac14b \\
% c & d & \frac12c+\frac14d \\
% \CodeAfter
% \SubMatrix({1-3}{2-3})[~emphase#slim!]
% \SubMatrix({3-1}{4-2})
% \SubMatrix({3-3}{4-3})
% \end{NiceArray}$
% \end{BVerbatim}
% \end{scope}
% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt]
% & & \frac12 \\
% & & \frac14 \\[1mm]
% a & b & \frac12a+\frac14b \\
% c & d & \frac12c+\frac14d \\
% \CodeAfter
% \SubMatrix({1-3}{2-3})[slim]
% \SubMatrix({3-1}{4-2})
% \SubMatrix({3-3}{4-3})
% \end{NiceArray}$
%
%
% \bigskip
% There is also a key |name| which gives a name to the submatrix created by
% |\SubMatrix|. That name is used to create PGF/Tikz nodes: cf
% p.~\pageref{node-sub-matrix}.
%
%
% \bigskip
% It's also possible to specify some delimiters\footnote{Those delimiters are
% |(|, |[|, |\{| and the closing ones. Of course, it's also
% possible to put \verb+|+ and \verb+||+ in the preamble of the environement.}
% by placing them in the preamble of the environment (for the environments with
% a preamble: |{NiceArray}|, |{pNiceArray}|, etc.). This syntax is inspired by
% the extension \pkg{blkarray}.
%
% When there are two successive delimiters (necessarily a closing one following by
% an opening one for another submatrix), a space equal to |\enskip| is
% automatically inserted.
%
% \medskip
% \begin{BVerbatim}
% $\begin{pNiceArray}{~emphase#(c)(c)(c)@}
% a_{11} & a_{12} & a_{13} \\
% a_{21} & \displaystyle \int_0^1\dfrac{1}{x^2+1}\,dx & a_{23} \\
% a_{31} & a_{32} & a_{33}
% \end{pNiceArray}$
% \end{BVerbatim}
%
% \[\begin{pNiceArray}{(c)(c)(c)}
% a_{11} & a_{12} & a_{13} \\
% a_{21} & \displaystyle \int_0^1\dfrac{1}{x^2+1}\,dx & a_{23} \\
% a_{31} & a_{32} & a_{33}
% \end{pNiceArray}\]
%
%
% \subsection{The commands \textbackslash OverBrace and \textbackslash
% UnderBrace in the \textbackslash CodeAfter}
%
% The commands |\OverBrace| and |\UnderBrace| provide a way to put
% horizontal braces on a part of the array. These commands take in three
% arguments:
% \begin{itemize}
% \item the first argument is the upper-left corner of the submatrix with the
% syntax $i$|-|$j$ where $i$ the number of row and $j$ the number of column;
% \item the second argument is the lower-right corner with the same syntax;
% \item the third argument is the label of the brace that will be put by
% \pkg{nicematrix} (with \textsc{pgf}) above the brace (for the command
% |\OverBrace|) or under the brace (for |\UnderBrace|).
% \end{itemize}
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% \begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 & 6 \\
% 11 & 12 & 13 & 14 & 15 & 16 \\
% \CodeAfter
% ~emphase#\OverBrace{1-1}{2-3}{A}@
% ~emphase#\OverBrace{1-4}{2-6}{B}@
% \end{pNiceMatrix}
% \end{BVerbatim}
% $\begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 & 6 \\
% 11 & 12 & 13 & 14 & 15 & 16 \\
% \CodeAfter
% \OverBrace{1-1}{2-3}{A}
% \OverBrace{1-4}{2-6}{B}
% \end{pNiceMatrix}$
%
% \bigskip
% In fact, the commands |\OverBrace| and |\UnderBrace| take in an optional
% argument (in first position and between square brackets) for a list of
% \textsl{key=value} pairs. The available keys are:
% \begin{itemize}
% \item |left-shorten| and |right-shorten| which do not take in value; when the
% key |left-shorten| is used, the abscissa of the left extremity of the brace is
% computed with the contents of the cells of the involved sub-array, otherwise,
% the position of the potential vertical rule is used (idem for
% |right-shorten|).
%
% \item |shorten|, which is the conjunction of the keys |left-shorten| and
% |right-shorten|;
%
% \item |yshift|, which shifts vertically the brace (and its label) ;
%
% \item \colorbox{yellow!50}{\textbf{New 6.7}}\enskip |color|, which sets the
% color of the brace (and its label).
% \end{itemize}
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% \begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 & 6 \\
% 11 & 12 & 13 & 14 & 15 & 16 \\
% \CodeAfter
% \OverBrace~emphase#[shorten,yshift=3pt]@{1-1}{2-3}{A}
% \OverBrace~emphase#[shorten,yshift=3pt]@{1-4}{2-6}{B}
% \end{pNiceMatrix}
% \end{BVerbatim}
% $\begin{pNiceMatrix}
% 1 & 2 & 3 & 4 & 5 & 6 \\
% 11 & 12 & 13 & 14 & 15 & 16 \\
% \CodeAfter
% \OverBrace[shorten,yshift=3pt]{1-1}{2-3}{A}
% \OverBrace[shorten,yshift=3pt]{1-4}{2-6}{B}
% \end{pNiceMatrix}$
%
%
%
% \section{The notes in the tabulars}
%
% \label{s:notes}
%
% \subsection{The footnotes}
%
% \smallskip
% The package \pkg{nicematrix} allows, by using \pkg{footnote} or
% \pkg{footnotehyper}, the extraction of the notes inserted by |\footnote| in
% the environments of \pkg{nicematrix} and their composition in the footpage
% with the other notes of the document.
%
% \smallskip
%
% \smallskip
% If \pkg{nicematrix} is loaded with the option |footnote| (with
% |\usepackage[footnote]{nicematrix}| or with |\PassOptionsToPackage|), the
% package \pkg{footnote} is loaded (if it is not yet loaded) and it is used to
% extract the footnotes.
%
% \smallskip
% If \pkg{nicematrix} is loaded with the option |footnotehyper|, the package
% \pkg{footnotehyper} is loaded (if it is not yet loaded) ant it is used to
% extract footnotes.
%
% \smallskip
% Caution: The packages \pkg{footnote} and \pkg{footnotehyper} are incompatible.
% The package \pkg{footnotehyper} is the successor of the package \pkg{footnote}
% and should be used preferently. The package \pkg{footnote} has some drawbacks,
% in particular: it must be loaded after the package \pkg{xcolor} and it is not
% perfectly compatible with \pkg{hyperref}.
%
%
% \subsection{The notes of tabular}
%
% The package \pkg{nicematrix} also provides a command |\tabularnote| which
% gives the ability to specify notes that will be composed at the end of the
% array with a width of line equal to the width of the array (excepted the
% potential exterior columns specified by |first-col| and |last-col|). With no
% surprise, that command is available only in the environments without
% delimiters, that is to say |{NiceTabular}|, |{NiceArray}| and |{NiceMatrix}|.
%
% In fact, this command is available only if the extension \pkg{enumitem} has
% been loaded (before or after \pkg{nicematrix}). Indeed, the notes are composed
% at the end of the array with a type of list provided by the package
% \pkg{enumitem}.
%
% \begin{scope}
% \fvset{commandchars=\~\#\!}
% \begin{Verbatim}
% \begin{NiceTabular}{@{}llr@{}}
% \toprule \RowStyle{\bfseries}
% Last name & First name & Birth day \\
% \midrule
% Achard\tabularnote{~emphase#Achard is an old family of the Poitou.!}
% & Jacques & 5 juin 1962 \\
% Lefebvre\tabularnote{~emphase#The name Lefebvre is an alteration of the name Lefebure.!}
% & Mathilde & 23 mai 1988 \\
% Vanesse & Stephany & 30 octobre 1994 \\
% Dupont & Chantal & 15 janvier 1998 \\
% \bottomrule
% \end{NiceTabular}
% \end{Verbatim}
% \end{scope}
%
% \begin{center}
% \begin{NiceTabular}{@{}llr@{}}
% \toprule \RowStyle{\bfseries}
% Last name & First name & Birth day \\
% \midrule
% Achard\tabularnote{Achard is an old family of the Poitou.}
% & Jacques & June 5, 2005 \\
% Lefebvre\tabularnote{The name Lefebvre is an alteration of the name Lefebure.}
% & Mathilde & January 23, 1975 \\
% Vanesse & Stephany & October 30, 1994 \\
% Dupont & Chantal & January 15, 1998 \\
% \bottomrule
% \end{NiceTabular}
% \end{center}
%
%
% \bigskip
% \begin{itemize}
% \item If you have several successive commands |\tabularnote{...}| \emph{with no
% space at all between them}, the labels of the corresponding notes are composed
% together, separated by commas (this is similar to the option |multiple| of
% \pkg{footmisc} for the footnotes).
%
% \item If a command |\tabularnote{...}| is exactly at the end of a cell (with
% no space at all after), the label of the note is composed in an overlapping
% position (towards the right). This structure may provide a better alignment of
% the cells of a given column.
%
% \item If the key |notes/para| is used, the notes are composed at the end of
% the array in a single paragraph (as with the key |para| of \pkg{threeparttable}).
%
% \item There is a key |tabularnote| which provides a way to insert some text in
% the zone of the notes before the numbered tabular notes.
%
% \item If the package \pkg{booktabs} has been loaded (before or after
% \pkg{nicematrix}), the key |notes/bottomrule| draws a |\bottomrule| of
% \pkg{booktabs} \emph{after} the notes.
%
% \item The command |\tabularnote| may be used \emph{before}
% the environment of \pkg{nicematrix}. Thus, it's possible to use it on the
% title inserted by |\caption| in an environment |{table}| of LaTeX.
%
% \colorbox{yellow!50}{\textbf{New 6.8}}\enskip If several commands
% |\tabularnote| are used in a tabular with the same argument, only one note is
% inserted at the end of the tabular (but all the labels are composed, of
% course). It's possible to control that feature with the key
% |notes/detect-duplicates|.
%
% \item It's possible to create a reference to a tabular note created by |\tabularnote|
% (with the usual command |\label| used after the |\tabularnote|).
% \end{itemize}
% %
% For an illustration of some of those remarks, see table
% \ref{t:tabularnote}, p.~\pageref{t:tabularnote}. This table has been composed
% with the following code.
%
% \begin{center}
% \fvset{commandchars=\~\#\!}
% \begin{Verbatim}[formatcom=\small\color{gray}]
% \begin{table}
% \setlength{\belowcaptionskip}{1ex}
% \centering
% \caption{Use of \texttt{\textbackslash tabularnote}~emphase#\tabularnote{It's possible!
% ~emphase#to put a note in the caption.}}!
% \label{t:tabularnote}
% \begin{NiceTabular}{@{}llc@{}
% [~emphase#notes/bottomrule!, tabularnote = Some text before the notes.]
% \toprule
% Last name & First name & Length of life \\
% \midrule
% Churchill & Wiston & 91\\
% Nightingale~emphase#\tabularnote{Considered as the first nurse of history}!
% ~emphase#\tabularnote{Nicknamed ``the Lady with the Lamp''.}!
% & Florence~emphase#\tabularnote{This note is shared by two references.}! & 90 \\
% Schoelcher & Victor & 89~emphase#\tabularnote{The label of the note is overlapping.}!\\
% Touchet & Marie~emphase#\tabularnote{This note is shared by two references.}! & 89 \\
% Wallis & John & 87 \\
% \bottomrule
% \end{NiceTabular}
% \end{table}
% \end{Verbatim}
% \end{center}
%
%
% \begin{table}[hb]
% \setlength{\belowcaptionskip}{1ex}
% \centering
% \caption{Use of \texttt{\textbackslash tabularnote}\tabularnote{It's possible
% to put a note in the caption.}}
% \label{t:tabularnote}
% \begin{NiceTabular}{@{}llc@{}}[notes/bottomrule,
% tabularnote = Some text before the notes.]
% \toprule
% Last name & First name & Length of life \\
% \midrule
% Churchill & Wiston & 91\\
% Nightingale\tabularnote{Considered as the first nurse of
% history.}\tabularnote{Nicknamed ``the Lady with the Lamp''.}
% & Florence\tabularnote{This note is shared by two references.} & 90 \\
% Schoelcher & Victor & 89\tabularnote{The label of the note is overlapping.}\\
% Touchet & Marie\tabularnote{This note is shared by two references.} & 89 \\
% Wallis & John & 87 \\
% \bottomrule
% \end{NiceTabular}
% \end{table}
%
%
%\subsection{Customisation of the tabular notes}
%
%
% The tabular notes can be customized with a set of keys available in
% |\NiceMatrixOptions|. The name of these keys is prefixed by |notes|.
% \begin{itemize}
% \item |notes/para|
% \item |notes/bottomrule|
% \item |notes/style|
% \item |notes/label-in-tabular|
% \item |notes/label-in-list|
% \item |notes/enumitem-keys|
% \item |notes/enumitem-keys-para|
% \item |notes/code-before|
% \end{itemize}
% For sake of commodity, it is also possible to set these keys in
% |\NiceMatrixOptions| via a key |notes| which takes in as value a list of
% pairs \textsl{key=value} where the name of the keys need no longer be
% prefixed by |notes|:
% \begin{center}
% \begin{BVerbatim}[formatcom = \small \color{gray}]
% \NiceMatrixOptions
% {
% notes =
% {
% bottomrule ,
% style = ... ,
% label-in-tabular = ... ,
% enumitem-keys =
% {
% labelsep = ... ,
% align = ... ,
% ...
% }
% }
% }
% \end{BVerbatim}
% \end{center}
%
%
% \bigskip
% We detail these keys.
%
% \begin{itemize}[itemsep=\medskipamount]
% \item The key |notes/para| requires the composition of the notes (at the end of
% the tabular) in a single paragraph.
%
% Initial value: |false|
%
% That key is also available within a given environment.
%
% \item The key |notes/bottomrule| adds a |\bottomrule| of \pkg{booktabs}
% \emph{after} the notes. Of course, that rule is drawn only if there is really
% notes in the tabular. The package \pkg{booktabs} must have been loaded (before
% or after the package \pkg{nicematrix}). If it is not, an error is raised.
%
% Initial value: |false|
%
% That key is also available within a given environment.
%
% \item The key |notes/style| is a command whose argument is specified by |#1|
% and which gives the style of numerotation of the notes. That style will be
% used by |\ref| when referencing a tabular note marked with a command |\label|.
% The labels formatted by that style are used, separated by commas, when the user
% puts several consecutive commands |\tabularnote|. The marker |#1| is meant to
% be the name of a LaTeX counter.
%
% Initial value: |\textit{\alph{#1}}|
%
% Another possible value should be a mere |\arabic{#1}|
%
% \item The key |notes/label-in-tabular| is a command whose argument is
% specified by |#1| which is used when formatting the label of a note in the
% tabular. Internally, this number of note has already been formatted by
% |notes/style| before sent to that command.
%
% Initial value: |\textsuperscript{#1}|
%
% In French, it's a tradition of putting a small space before the label of note.
% That tuning could be acheived by the following code:
% %
% \begin{Verbatim}
% \NiceMatrixOptions{notes/label-in-tabular = \,\textsuperscript{~#1}}
% \end{Verbatim}
%
%
% \item The key |notes/label-in-list| is a command whose argument is specified
% by |#1| which is used when formatting the label in the list of notes at the
% end of the tabular. Internally, this number of note has already been formatted by
% |notes/style| before sent to that command.
%
% Initial value: |\textsuperscript{#1}|
%
% In French, the labels of notes are not composed in upper position when
% composing the notes. Such behaviour could be acheived by:
% \begin{Verbatim}
% \NiceMatrixOptions{notes/label-in-list = ~#1.\nobreak\hspace{0.25em}}
% \end{Verbatim}
% The command |\nobreak| is for the event that the option |para| is used.
%
%
% \item The notes are composed at the end of the tabular by using internally a
% style of list of \pkg{enumitem}. This style of list is defined as follows (with, of
% course, keys of \pkg{enumitem}):
%
% |noitemsep , leftmargin = * , align = left , labelsep = 0pt|
%
% The specification |align = left| in that style requires a
% composition of the label leftwards in the box affected to that label.
% With that tuning, the notes are composed flush left, which is pleasant when
% composing tabulars in the spirit of \pkg{booktabs} (see for example the
% table \ref{t:tabularnote}, p.~\pageref{t:tabularnote}).
%
% \medskip
% The key |notes/enumitem-keys| specifies a list of pairs
% \textsl{key=value} (following the specifications of \pkg{enumitem}) to
% customize that style of list (it uses internally the command |\setlist*| of
% \pkg{enumitem}).
%
%
% \item The key |notes/enumitem-keys-para| is similar to the previous one but
% corresponds to the type of list used when the option |para| is in force. Of
% course, when the option |para| is used, a list of type |inline| (as called by
% \pkg{enumitem}) is used and the pairs \textsl{key=value} should correspond to
% such a list of type |inline|.
%
% Initially, the style of list is defined by:\quad
% |afterlabel = \nobreak, itemjoin = \quad|
%
%
% \item The key |notes/code-before| is a token list inserted by \pkg{nicematrix}
% just before the composition of the notes at the end of the tabular.
%
% Initial value: \textsl{empty}
%
% For example, if one wishes to compose all the notes in gray and |\footnotesize|,
% he should use that key:
% \begin{Verbatim}
% \NiceMatrixOptions{notes/code-before = \footnotesize \color{gray}}
% \end{Verbatim}
% It's also possible to add |\raggedright| or |\RaggedRight| in that key (|\RaggedRight|
% is a command of \pkg{ragged2e}).
%
% \item The key |notes/detect-duplicates| activates the detection of the commands
% |\tabularnotes| with the same argument.
%
% Initial value : |true|
% \end{itemize}
%
%
%
% \bigskip
% For an example of customisation of the tabular notes, see p.~\pageref{ex:notes}.
%
%
% \subsection{Use of \{NiceTabular\} with threeparttable}
%
%
% If you wish to use the environment |{NiceTabular}|, |{NiceTabular*}|
% |{NiceTabularX}|in an environment |{threeparttable}| of the eponymous package,
% you have to patch the environment |{threeparttable}| with the following code
% (with a version of LaTeX at least 2020/10/01).
% \begin{Verbatim}[commandchars=\~\#\!]
% \makeatletter
% \AddToHook{env/threeparttable/begin}
% {\TPT@hookin{NiceTabular}\TPT@hookin{NiceTabular*}\TPT@hookin{NiceTabularX}}
% \makeatother
% \end{Verbatim}
%
%
%
% \section{Other features}
%
% \subsection{Use of the column type S of siunitx}
%
% If the package \pkg{siunitx} is loaded (before or after \pkg{nicematrix}),
% it's possible to use the |S| column type of \pkg{siunitx} in the environments
% of \pkg{nicematrix}. The implementation doesn't use explicitly any private
% macro of \pkg{siunitx}.
%
%
% \medskip
% \begin{BVerbatim}[baseline = c, boxwidth = 10.5cm]
% $\begin{pNiceArray}{~emphase#S@cWc{1cm}c}[nullify-dots,first-row]
% {C_1} & \Cdots & & C_n \\
% 2.3 & 0 & \Cdots & 0 \\
% 12.4 & \Vdots & & \Vdots \\
% 1.45 \\
% 7.2 & 0 & \Cdots & 0
% \end{pNiceArray}$
% \end{BVerbatim}
% $\begin{pNiceArray}{ScWc{1cm}c}[nullify-dots,first-row]
% {C_1} & \Cdots & & C_n \\
% 2.3 & 0 & \Cdots & 0 \\
% 12.4 & \Vdots & & \Vdots \\
% 1.45 \\
% 7.2 & 0 & \Cdots & 0
% \end{pNiceArray}$
%
% \medskip
% On the other hand, the |d| columns of the package \pkg{dcolumn} are not
% supported by \pkg{nicematrix}.
%
%
% \subsection{Alignment option in \{NiceMatrix\}}
%
% \label{key-R}
%
% The environments without preamble (|{NiceMatrix}|, |{pNiceMatrix}|,
% |{bNiceMatrix}|, etc.) provide two options |l| and |r| which generate all the
% columns aligned leftwards (or rightwards).
%
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $\begin{bNiceMatrix}[r]
% \cos x & - \sin x \\
% \sin x & \cos x
% \end{bNiceMatrix}$
% \end{BVerbatim}
% $\begin{bNiceMatrix}[r]
% \cos x & - \sin x \\
% \sin x & \cos x
% \end{bNiceMatrix}$
%
%
% \subsection{The command \textbackslash rotate}
%
% \label{rotate}
%
% The package \pkg{nicematrix} provides a command |\rotate|. When used in the
% beginning of a cell, this command composes the contents of the cell after a
% rotation of 90° in the direct sens.
%
% In the following command, we use that command in the
% |code-for-first-row|.\footnote{It can also be used in |\RowStyle|
% (cf.~p.~\pageref{RowStyle}.}
%
%\bigskip
%
%\begin{BVerbatim}[baseline=c,boxwidth=12cm]
% \NiceMatrixOptions%
% {code-for-first-row = \scriptstyle ~emphase#\rotate@ \text{image of },
% code-for-last-col = \scriptstyle }
% $A = \begin{pNiceMatrix}[first-row,last-col=4]
% e_1 & e_2 & e_3 \\
% 1 & 2 & 3 & e_1 \\
% 4 & 5 & 6 & e_2 \\
% 7 & 8 & 9 & e_3
% \end{pNiceMatrix}$
% \end{BVerbatim}
% \begin{varwidth}{10cm}
% \NiceMatrixOptions%
% {code-for-first-row = \scriptstyle\rotate \text{image of },
% code-for-last-col = \scriptstyle }
% $ A = \begin{pNiceMatrix}[first-row,last-col=4]
% e_1 & e_2 & e_3 \\
% 1 & 2 & 3 & e_1 \\
% 4 & 5 & 6 & e_2 \\
% 7 & 8 & 9 & e_3
% \end{pNiceMatrix}$
% \end{varwidth}
%
% \bigskip
% If the command |\rotate| is used in the ``last row'' (exterior to the matrix),
% the corresponding elements are aligned upwards as shown below.
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=12cm]
% \NiceMatrixOptions%
% {code-for-last-row = \scriptstyle ~emphase#\rotate@ ,
% code-for-last-col = \scriptstyle }
% $A = \begin{pNiceMatrix}[last-row=4,last-col=4]
% 1 & 2 & 3 & e_1 \\
% 4 & 5 & 6 & e_2 \\
% 7 & 8 & 9 & e_3 \\
% \text{image of } e_1 & e_2 & e_3
% \end{pNiceMatrix}$
% \end{BVerbatim}
% \begin{varwidth}{10cm}
% \NiceMatrixOptions%
% {code-for-last-row = \scriptstyle\rotate ,
% code-for-last-col = \scriptstyle }%
% $A = \begin{pNiceMatrix}[last-row=4,last-col=4]
% 1 & 2 & 3 & e_1 \\
% 4 & 5 & 6 & e_2 \\
% 7 & 8 & 9 & e_3 \\
% \text{image of } e_1 & e_2 & e_3
% \end{pNiceMatrix}$
% \end{varwidth}
%
%
%
% \subsection{The option small}
%
% \label{small}
%
% With the option |small|, the environments of the package \pkg{nicematrix}
% are composed in a way similar to the environment |{smallmatrix}| of the
% package \pkg{amsmath} (and the environments |{psmallmatrix}|,
% |{bsmallmatrix}|, etc. of the package \pkg{mathtools}).
%
% \bigskip
% \begin{Verbatim}
% $\begin{bNiceArray}{cccc|c}[~emphase#small@,
% last-col,
% code-for-last-col = \scriptscriptstyle,
% columns-width = 3mm ]
% 1 & -2 & 3 & 4 & 5 \\
% 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\
% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3
% \end{bNiceArray}$
% \end{Verbatim}
% %
% \[\begin{bNiceArray}{cccc|c}[small, last-col,
% code-for-last-col = \scriptscriptstyle,
% columns-width=3mm]
% 1 & -2 & 3 & 4 & 5 \\
% 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\
% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3
% \end{bNiceArray}\]
%
%
%
% \bigskip
% One should note that the environment |{NiceMatrix}| with the option |small| is
% not composed \emph{exactly} as the environment |{smallmatrix}|. Indeed, all
% the environments of \pkg{nicematrix} are constructed upon |{array}| (of the
% package \pkg{array}) whereas the environment |{smallmatrix}| is constructed
% directly with an |\halign| of TeX.
%
% \medskip
% In fact, the option |small| corresponds to the following tuning:
% \begin{itemize}
% \item the cells of the array are composed with |\scriptstyle|;
% \item |\arraystretch| is set to $0.47$;
% \item |\arraycolsep| is set to $1.45$~pt;
% \item the characteristics of the dotted lines are also modified.
% \end{itemize}
%
% \subsection{The counters iRow and jCol}
%
% In the cells of the array, it's possible to use the LaTeX counters |iRow| and
% |jCol| which represent the number of the current row and the number of the
% current column\footnote{We recall that the exterior ``first row'' (if it
% exists) has the number~$0$ and that the exterior ``first column'' (if it
% exists) has also the number~$0$.}. Of course, the user must not change the
% value of these counters which are used internally by \pkg{nicematrix}.
%
% In the |\CodeBefore| (cf. p. \pageref{code-before}) and in the |\CodeAfter|
% (cf. p. \pageref{code-after}), |iRow| represents the total number of rows
% (excepted the potential exterior rows) and |jCol| represents the total number
% of columns (excepted the potential exterior columns).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
% $\begin{pNiceMatrix}% don't forget the %
% [first-row,
% first-col,
% code-for-first-row = \mathbf{~emphase#\alph{jCol}@} ,
% code-for-first-col = \mathbf{~emphase#\arabic{iRow}@} ]
% & & & & \\
% & 1 & 2 & 3 & 4 \\
% & 5 & 6 & 7 & 8 \\
% & 9 & 10 & 11 & 12
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $\begin{pNiceMatrix}[first-row,
% first-col,
% code-for-first-row = \mathbf{\alph{jCol}} ,
% code-for-first-col = \mathbf{\arabic{iRow}} ]
% & & & & \\
% & 1 & 2 & 3 & 4 \\
% & 5 & 6 & 7 & 8 \\
% & 9 & 10 & 11 & 12
% \end{pNiceMatrix}$
%
% \medskip
% If LaTeX counters called |iRow| and |jCol| are defined in the document by
% packages other than \pkg{nicematrix} (or by the final user), they are shadowed
% in the environments of \pkg{nicematrix}.
%
% \bigskip
% The package \pkg{nicematrix} also provides commands in order to compose
% automatically matrices from a general pattern. These commands are
% |\AutoNiceMatrix|, |\pAutoNiceMatrix|, |\bAutoNiceMatrix|, |\vAutoNiceMatrix|,
% |\VAutoNiceMatrix| and |\BAutoNiceMatrix|.
%
% These commands take in two mandatory arguments. The first is the format of the
% matrix, with the syntax $n$-$p$ where $n$ is the number of rows and $p$ the
% number of columns. The second argument is the pattern (it's a list of tokens
% which are inserted in each cell of the constructed matrix).
%
% \medskip
% \begin{Verbatim}
% $C = ~emphase#\pAutoNiceMatrix@{3-3}{C_{\arabic{iRow},\arabic{jCol}}}$
% \end{Verbatim}
%
%
% \[C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}\]
%
%
% \subsection{The option light-syntax}
%
% \label{light-syntax}
% The option |light-syntax| (inpired by the package \pkg{spalign}) allows the
% user to compose the arrays with a lighter syntax, which gives a better
% legibility of the TeX source.
%
% When this option is used, one should use the semicolon for the end of a row
% and spaces or tabulations to separate the columns. However, as usual in the
% TeX world, the spaces after a control sequence are discarded and the elements
% between curly braces are considered as a whole.
%
%
% \medskip
% \begin{scope}
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% $\begin{bNiceMatrix}[~emphase#light-syntax@,first-row,first-col]
% {} a b ;
% a 2\cos a {\cos a + \cos b} ;
% b \cos a+\cos b { 2 \cos b }
% \end{bNiceMatrix}$
% \end{BVerbatim}
% \end{scope}
% $\begin{bNiceMatrix}[light-syntax,first-row,first-col]
% {} a b ;
% a 2\cos a {\cos a + \cos b} ;
% b \cos a+\cos b { 2 \cos b }
% \end{bNiceMatrix}$
%
% \medskip
% It's possible to change the character used to mark the end of rows with the
% option |end-of-row|. As said before, the initial value is a semicolon.
%
% \medskip
% When the option |light-syntax| is used, it is not possible to put verbatim
% material (for example with the command |\verb|) in the cells of the
% array.\footnote{The reason is that, when the option |light-syntax| is used,
% the whole content of the environment is loaded as a TeX argument to be
% analyzed. The environment doesn't behave in that case as a standard
% environment of LaTeX which only put TeX commands before and after the content.}
%
%
% \subsection{Color of the delimiters}
%
% For the environements with delimiters (|{pNiceArray}|, |{pNiceMatrix}|, etc.),
% it's possible to change the color of the delimiters with the key
% |delimiters/color|.
%
% \medskip
% \begin{BVerbatim}[boxwidth=12cm,baseline=c]
% $\begin{bNiceMatrix}[delimiters/color=red]
% 1 & 2 \\
% 3 & 4
% \end{bNiceMatrix}$
% \end{BVerbatim}
% $\begin{bNiceMatrix}[delimiters/color=red]
% 1 & 2 \\
% 3 & 4
% \end{bNiceMatrix}$
%
% \medskip
% This colour alos applies to the delimiters drawn by the command |\SubMatrix|
% (cf.~p.~\pageref{sub-matrix}).
%
% \subsection{The environment \{NiceArrayWithDelims\}}
%
% In fact, the environment |{pNiceArray}| and its variants are based upon a
% more general environment, called |{NiceArrayWithDelims}|. The first two
% mandatory arguments of this environment are the left and right delimiters used
% in the construction of the matrix. It's possible to use
% |{NiceArrayWithDelims}| if we want to use atypical or asymetrical delimiters.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
% $\begin{~emphase#NiceArrayWithDelims@}
% {\downarrow}{\uparrow}{ccc}[margin]
% 1 & 2 & 3 \\
% 4 & 5 & 6 \\
% 7 & 8 & 9
% \end{~emphase#NiceArrayWithDelims@}$
% \end{BVerbatim}
% $\begin{NiceArrayWithDelims}
% {\downarrow}{\uparrow}{ccc}[margin]
% 1 & 2 & 3 \\
% 4 & 5 & 6 \\
% 7 & 8 & 9
% \end{NiceArrayWithDelims}$
%
% \subsection{The command \textbackslash OnlyMainNiceMatrix}
%
% The command |\OnlyMainNiceMatrix| executes its argument only when it is in the
% main part of the array, that is to say it is not in one of the exterior rows.
% If it is used outside an environment of \pkg{nicematrix}, that command is no-op.
%
% For an example of utilisation, see \url{tex.stackexchange.com/questions/488566}
%
% \section{Use of Tikz with nicematrix}
%
% \label{name}\label{PGF-nodes}
%
% \subsection{The nodes corresponding to the contents of the cells}
%
% The package \pkg{nicematrix} creates a PGF/Tikz node for each (non-empty) cell
% of the considered array. These nodes are used to draw the dotted lines between
% the cells of the matrix (inter alia).
%
%
% \smallskip
% \textbf{Caution} : By default, no node is created in a empty cell.
%
% \smallskip
% However, it's possible to impose the creation of a node with the command
% |\NotEmpty|. \footnote{One should note that, with that command, the cell is
% considered as non-empty, which has consequencies for the continuous dotted
% lines (cf. p.~\pageref{Cdots}) and the computation of the ``corners''
% (cf.~p.~\pageref{corners}).}
%
% \medskip
% The nodes of a document must have distinct names. That's why the names of the
% nodes created by \pkg{nicematrix} contains the number of the current
% environment. Indeed, the environments of \pkg{nicematrix} are numbered by a
% internal global counter.
%
% \smallskip
% In the environment with the number $n$, the node of the row $i$ and
% column~$j$ has for name |nm-|$n$|-|$i$|-|$j$.
%
% \smallskip
% The command |\NiceMatrixLastEnv| provides the number of the last environment
% of \pkg{nicematrix} (for LaTeX, it's a ``fully expandable'' command and not a
% counter).
%
% \smallskip
% However, it's advisable to use instead the key |name|. This key gives a name
% to the current environment. When the environment has a name, the nodes are
% accessible with the name ``\textsl{name}-$i$-$j$'' where \textsl{name} is the
% name given to the array and $i$ and $j$ the numbers of row and column. It's
% possible to use these nodes with \textsc{pgf} but the final user will
% probably prefer to use Tikz (which is a convenient layer upon \textsc{pgf}).
% However, one should remind that \pkg{nicematrix} doesn't load Tikz by default.
% In the following examples, we assume that Tikz has been loaded.
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
% $\begin{pNiceMatrix}[name=~emphase#mymatrix@]
% 1 & 2 & 3 \\
% 4 & 5 & 6 \\
% 7 & 8 & 9
% \end{pNiceMatrix}$
% \tikz[remember picture,overlay]
% \draw ~emphase#(mymatrix-2-2)@ circle (2mm) ;
% \end{BVerbatim}
% $\begin{pNiceMatrix}[name=mymatrix]
% 1 & 2 & 3 \\
% 4 & 5 & 6 \\
% 7 & 8 & 9
% \end{pNiceMatrix}$
% \tikz[remember picture,overlay]
% \draw (mymatrix-2-2) circle (2mm) ;
%
% \medskip
% Don't forget the options |remember picture| and |overlay|.
%
% \bigskip
% In the |\CodeAfter|, the things are easier : one must refer to the nodes with
% the form $i$-$j$ (we don't have to indicate the environment which is of
% course the current environment).
%
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
% $\begin{pNiceMatrix}
% 1 & 2 & 3 \\
% 4 & 5 & 6 \\
% 7 & 8 & 9
% \CodeAfter
% \tikz \draw ~emphase#(2-2)@ circle (2mm) ;
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $\begin{pNiceMatrix}
% 1 & 2 & 3 \\
% 4 & 5 & 6 \\
% 7 & 8 & 9
% \CodeAfter
% \tikz \draw (2-2) circle (2mm) ;
% \end{pNiceMatrix}$
%
%
% \bigskip
% In the following example, we have underlined all the nodes of the matrix (we
% explain below the technic used : cf. p. \pageref{highlight}).
%
%
% \[\begin{pNiceMatrix}
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture}%
% [every node/.style = { inner sep = 0 pt , fill = red!15 }]
% \node [fit = (1-1)] {} ;
% \node [fit = (1-3)] {} ;
% \node [fit = (2-2)] {} ;
% \node [fit = (3-1)] {} ;
% \node [fit = (3-3)] {} ;
% \node [fit = (1-2)] {} ;
% \node [fit = (2-1)] {} ;
% \node [fit = (2-3)] {} ;
% \node [fit = (3-2)] {} ;
% \end{tikzpicture}
% \Body
% a & a + b & a + b + c \\
% a & a & a + b \\
% a & a & a
% \end{pNiceMatrix}\]
%
%
% The nodes of the last column (excepted the potential «last column» specified
% by |last-col|) may also be indicated by $i$-|last|. Similarly, the nodes of
% the last row may be indicated by |last|-$j$.
%
% \subsubsection{The columns V of varwidth}
%
% \label{node-V}
% When the extension \pkg{varwidth} is loaded, the columns of the type |V|
% defined by \pkg{varwidth} are supported by \pkg{nicematrix}. It may be
% interessant to notice that, for a cell of a column of type |V|, the PGF/Tikz
% node created by \pkg{nicematrix} for the content of that cell has a width
% adjusted to the content of the cell. This is in contrast to the case of the
% columns of type |p|, |m| or |b| for which the nodes have always a width equal
% to the width of the column. In the following example, the command |\lipsum| is
% provided by the eponymous package.
%
% \begin{Verbatim}
% \begin{NiceTabular}{V{10cm}}
% \bfseries \large
% Titre \\
% \lipsum[1][1-4]
% \CodeAfter
% \tikz \draw [rounded corners] (1-1) -| (last-|2) -- (last-|1) |- (1-1) ;
% \end{NiceTabular}
% \end{Verbatim}
%
%
% \begin{center}
% \begin{NiceTabular}{V{10cm}}
% \bfseries \large
% Titre \\
% \lipsum[1][1-4]
% \CodeAfter
% \tikz \draw [rounded corners] (1-1) -| (last-|2) -- (last-|1) |- (1-1) ;
% \end{NiceTabular}
% \end{center}
%
% We have used the nodes corresponding to the position of the potential rules,
% which are described below (cf. p.~\pageref{nodes-i}).
%
%
% \subsection[The medium nodes and the large nodes]{The ``medium nodes'' and the ``large nodes''}
%
% In fact, the package \pkg{nicematrix} can create ``extra nodes'': the ``medium
% nodes'' and the ``large nodes''. The first ones
% are created with the option |create-medium-nodes| and the second ones with the
% option |create-large-nodes|.\footnote{There is also an option
% |create-extra-nodes| which is an alias for the conjonction of
% |create-medium-nodes| and |create-large-nodes|.}
%
% \medskip
% These nodes are not used by \pkg{nicematrix} by default, and that's why they
% are not created by default.
%
% \medskip
% The names of the ``medium nodes'' are constructed by adding the suffix
% ``|-medium|'' to the names of the ``normal nodes''. In the following example,
% we have underlined the ``medium nodes''. We consider that this example is
% self-explanatory.
% \[\begin{pNiceMatrix}[create-medium-nodes]
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture}
% [every node/.style = {fill = red!15, inner sep = 0 pt},
% name suffix = -medium]
% \node [fit = (1-1)] {} ;
% \node [fit = (1-2)] {} ;
% \node [fit = (1-3)] {} ;
% \node [fit = (2-1)] {} ;
% \node [fit = (2-2)] {} ;
% \node [fit = (2-3)] {} ;
% \node [fit = (3-1)] {} ;
% \node [fit = (3-2)] {} ;
% \node [fit = (3-3)] {} ;
% \end{tikzpicture}
% \Body
% a & a + b & a + b + c \\
% a & a & a + b \\
% a & a & a
% \end{pNiceMatrix}\]
%
%
% \medskip
% The names of the ``large nodes'' are constructed by adding the suffix
% ``|-large|'' to the names of the ``normal nodes''. In the following example,
% we have underlined the ``large nodes''. We consider that this example is
% self-explanatory.\footnote{There is no ``large nodes'' created in the exterior
% rows and columns (for these rows and columns, cf. p.~\pageref{exterior}).}
% \[\begin{pNiceMatrix}[create-large-nodes]
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture}
% [every node/.style = { inner sep = 0 pt} ,
% name suffix = -large]
% \node [fit = (1-1),fill = red!15] {} ;
% \node [fit = (1-3),fill = red!15] {} ;
% \node [fit = (2-2),fill = red!15] {} ;
% \node [fit = (3-1),fill = red!15] {} ;
% \node [fit = (3-3),fill = red!15] {} ;
% \node [fit = (1-2),fill = blue!15] {} ;
% \node [fit = (2-1),fill = blue!15] {} ;
% \node [fit = (2-3),fill = blue!15] {} ;
% \node [fit = (3-2),fill = blue!15] {} ;
% \end{tikzpicture}
% \Body
% a & a + b & a + b + c \\
% a & a & a + b \\
% a & a & a
% \end{pNiceMatrix}\]
%
%
%
% \medskip
% The ``large nodes'' of the first column and last column may appear too small
% for some usage. That's why it's possible to use the options |left-margin| and
% |right-margin| to add space on both sides of the array and also space in the
% ``large nodes'' of the first column and last column. In the following example,
% we have used the options |left-margin| and |right-margin|.\footnote{The
% options |left-margin| and |right-margin| take dimensions as values but, if no
% value is given, the default value is used, which is |\arraycolsep| (by
% default: 5~pt). There is also an option |margin| to fix both |left-margin| and
% |right-margin| to the same value.}
% \[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin]
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture}
% [every node/.style = {inner sep = 0 pt},
% name suffix = -large]
% \node [fit = (1-1),fill = red!15] {} ;
% \node [fit = (1-3),fill = red!15] {} ;
% \node [fit = (2-2),fill = red!15] {} ;
% \node [fit = (3-1),fill = red!15] {} ;
% \node [fit = (3-3),fill = red!15] {} ;
% \node [fit = (1-2),fill = blue!15] {} ;
% \node [fit = (2-1),fill = blue!15] {} ;
% \node [fit = (2-3),fill = blue!15] {} ;
% \node [fit = (3-2),fill = blue!15] {} ;
% \end{tikzpicture}
% \Body
% a & a + b & a + b + c \\
% a & a & a + b \\
% a & a & a
% \end{pNiceMatrix}\]
%
%
% \medskip
% It's also possible to add more space on both side of the array with the
% options |extra-left-margin| and |extra-right-margin|. These margins are not
% incorporated in the ``large nodes''. It's possible to fix both values with the
% option |extra-margin| and, in the following example, we use |extra-margin|
% with the value $3$~pt.
% \[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt]
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture}
% [every node/.style = {inner sep = 0 pt},
% name suffix = -large]
% \node [fit = (1-1),fill = red!15] {} ;
% \node [fit = (1-3),fill = red!15] {} ;
% \node [fit = (2-2),fill = red!15] {} ;
% \node [fit = (3-1),fill = red!15] {} ;
% \node [fit = (3-3),fill = red!15] {} ;
% \node [fit = (1-2),fill = blue!15] {} ;
% \node [fit = (2-1),fill = blue!15] {} ;
% \node [fit = (2-3),fill = blue!15] {} ;
% \node [fit = (3-2),fill = blue!15] {} ;
% \end{tikzpicture}
% \Body
% a & a + b & a + b + c \\
% a & a & a + b \\
% a & a & a
% \end{pNiceMatrix}\]
%
%
%
% \bigskip
% \textbf{Be careful} : These nodes are reconstructed from the contents of the
% contents cells of the array. Usually, they do not correspond to the cells
% delimited by the rules (if we consider that these rules are drawn).
%
% \bigskip
% \begin{minipage}[c]{7.6cm}
% Here is an array composed with the following code:
%
% \medskip
% \begin{BVerbatim}
% \large
% \begin{NiceTabular}{wl{2cm}ll}[hvlines]
% fraise & amande & abricot \\
% prune & pêche & poire \\[1ex]
% noix & noisette & brugnon
% \end{NiceTabular}
% \end{BVerbatim}
% \end{minipage}
% \hspace{0.9cm}
% \begin{scope}
% \large
% \begin{NiceTabular}[c]{wl{2cm}ll}[hvlines]
% fraise & amande & abricot \\
% prune & pêche & poire \\[1ex]
% noix & noisette & brugnon
% \end{NiceTabular}
% \end{scope}
%
% \vspace{1cm}
% \begin{minipage}[c]{7cm}
% Here, we have colored all the cells of the array with |\chessboardcolors|.
% \end{minipage}
% \hspace{1.5cm}
% \begin{scope}
% \large
% \begin{NiceTabular}[c]{wl{2cm}ll}[hvlines,code-before = \chessboardcolors{red!15}{blue!15}]
% fraise & amande & abricot \\
% prune & pêche & poire \\[1ex]
% noix & noisette & brugnon
% \end{NiceTabular}
% \end{scope}
%
%
% \vspace{1cm}
% \begin{minipage}[c]{7cm}
% Here are the ``large nodes'' of this array (without use of |margin|
% nor |extra-margin|).
% \end{minipage}
% \hspace{1.5cm}
% \begin{scope}
% \large
% \begin{NiceTabular}[c]{w{l}{2cm}ll}[hvlines,create-large-nodes]
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture}
% [every node/.style = {inner sep = 0 pt},
% name suffix = -large]
% \node [fit = (1-1),fill = red!15] {} ;
% \node [fit = (1-3),fill = red!15] {} ;
% \node [fit = (2-2),fill = red!15] {} ;
% \node [fit = (3-1),fill = red!15] {} ;
% \node [fit = (3-3),fill = red!15] {} ;
% \node [fit = (1-2),fill = blue!15] {} ;
% \node [fit = (2-1),fill = blue!15] {} ;
% \node [fit = (2-3),fill = blue!15] {} ;
% \node [fit = (3-2),fill = blue!15] {} ;
% \end{tikzpicture}
% \Body
% fraise & amande & abricot \\
% prune & pêche & poire \\[1ex]
% noix & noisette & brugnon
% \end{NiceTabular}
% \end{scope}
%
%
% \vspace{1cm}
% The nodes we have described are not available by default in the |\CodeBefore|
% (described p.~\pageref{code-before}).\par\nobreak
%
% It's possible to have these nodes available in the |\CodeBefore| by using the
% key |create-cell-nodes| of the keyword |\CodeBefore| (in that case, the nodes
% are created first before the construction of the array by using informations
% written on the |aux| file and created a second time during the contruction of
% the array itself).
%
% \bigskip
% Here is an example which uses these nodes in the |\CodeAfter|.
%
% \begin{center}
% \fvset{commandchars=\~\#\+}
% \begin{Verbatim}
% \begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes]
% u_1 &-& u_0 &=& r \\
% u_2 &-& u_1 &=& r \\
% u_3 &-& u_2 &=& r \\
% u_4 &-& u_3 &=& r \\
% \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\
% u_n &-& u_{n-1} &=& r \\[3pt]
% \hline
% u_n &-& u_0 &=& nr \\
% \CodeAfter
% \tikz[very thick, red, opacity=0.4,name suffix = -medium]
% \draw (1-1.north west) -- (2-3.south east)
% (2-1.north west) -- (3-3.south east)
% (3-1.north west) -- (4-3.south east)
% (4-1.north west) -- (5-3.south east)
% (5-1.north west) -- (6-3.south east) ;
% \end{NiceArray}
% \end{Verbatim}
% \end{center}
%
% \[\begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes]
% u_1 &-& u_0 &=& r \\
% u_2 &-& u_1 &=& r \\
% u_3 &-& u_2 &=& r \\
% u_4 &-& u_3 &=& r \\
% \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\
% u_n &-& u_{n-1} &=& r \\[3pt]
% \hline
% u_n &-& u_0 &=& nr \\
% \CodeAfter
% \tikz[very thick, red, opacity=0.4,name suffix = -medium]
% \draw (1-1.north west) -- (2-3.south east)
% (2-1.north west) --(3-3.south east)
% (3-1.north west) -- (4-3.south east)
% (4-1.north west) -- (5-3.south east)
% (5-1.north west) -- (6-3.south east) ;
% \end{NiceArray}\]
%
%
%
% \subsection{The nodes which indicate the position of the rules}
%
% \label{nodes-i}
% The package \pkg{nicematrix} creates a PGF/Tikz node merely called $i$ (with
% the classical prefix) at the intersection of the horizontal rule of number~$i$
% and the vertical rule of number~$i$ (more specifically the potential position
% of those rules because maybe there are not actually drawn). The last node has
% also an alias called |last|. There is also a node called $i$|.5| midway
% between the node $i$ and the node $i+1$.
%
% These nodes are available in the |\CodeBefore| and the |\CodeAfter|.
%
% \begin{center}
% \begin{NiceTabular}{ccc}[hvlines,rules/width=1pt,rules/color=gray]
% & tulipe & lys \\
% arum & & violette mauve \\
% muguet & dahlia
% \CodeAfter
% \tiny
% \begin{tikzpicture}
% \foreach \i in {1,1.5,2,2.5,3,3.5,4}
% {
% \fill [red] (\i) circle (0.5mm) ;
% \node [red,above right] at (\i) {\i} ;
% }
% \end{tikzpicture}
% \end{NiceTabular}
% \end{center}
%
% \bigskip
% If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by default,
% by only \textsc{pgf}, which is a sub-layer of Tikz), we can access, in the
% |\CodeAfter| but also in the |\CodeBefore|, to the intersection of the
% (potential) horizontal rule~$i$ and the (potential) vertical rule~$j$ with the
% syntax |(|$i$\verb+-|+$j$|)|.
%
% \medskip
% \begin{Verbatim}
% \begin{NiceMatrix}
% \CodeBefore
% ~emphase#\tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;@
% \Body
% 1 \\
% 1 & 1 \\
% 1 & 2 & 1 \\
% 1 & 3 & 3 & 1 \\
% 1 & 4 & 6 & 4 & 1 \\
% 1 & 5 & 10 & 10 & 5 & 1 \\
% 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
% 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
% 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
% \end{NiceMatrix}
% \end{Verbatim}
% %
% \[\begin{NiceMatrix}
% \CodeBefore
% \tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;
% \Body
% 1 \\
% 1 & 1 \\
% 1 & 2 & 1 \\
% 1 & 3 & 3 & 1 \\
% 1 & 4 & 6 & 4 & 1 \\
% 1 & 5 & 10 & 10 & 5 & 1 \\
% 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
% 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
% 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
% \end{NiceMatrix}\]
%
%
% \bigskip
% The nodes of the form $i$|.5| may be used, for example to cross a row of a
% matrix (if Tikz is loaded).
%
% \smallskip
% \begin{BVerbatim}[boxwidth=11cm,baseline=c]
% $\begin{pNiceArray}{ccc|c}
% 2 & 1 & 3 & 0 \\
% 3 & 3 & 1 & 0 \\
% 3 & 3 & 1 & 0
% \CodeAfter
% \tikz \draw [red] (~emphase#3.5@-|1) -- (~emphase#3.5@-|last) ;
% \end{pNiceArray}$
% \end{BVerbatim}
% $\begin{pNiceArray}{ccc|c}
% 2 & 1 & 3 & 0 \\
% 3 & 3 & 1 & 0 \\
% 3 & 3 & 1 & 0
% \CodeAfter
% \tikz \draw [red] (3.5-|1) -- (3.5-|last) ;
% \end{pNiceArray}$
%
% \subsection{The nodes corresponding to the command \textbackslash SubMatrix}
%
% \label{node-sub-matrix}
%
% The command |\SubMatrix| available in the |\CodeAfter| has been described
% p.~\pageref{sub-matrix}.
%
% \smallskip
% If a command |\SubMatrix| has been used with the key |name| with an expression
% such as |name=|\textsl{\ttfamily MyName} three PGF/Tikz nodes are created
% with the names \textsl{\ttfamily MyName}|-left|, \textsl{\ttfamily MyName} and
% \textsl{\ttfamily MyName}|-right|.
%
% \smallskip
% The nodes \textsl{\ttfamily MyName}|-left| and \textsl{\ttfamily
% MyName}|-right| correspond to the delimiters left and right and the node
% \textsl{\ttfamily MyName} correspond to the submatrix itself.
%
% \medskip
% In the following example, we have highlighted these nodes (the submatrix itself has
% been created with |\SubMatrix\{{2-2}{3-3}\}|).
%
% \[\begin{pNiceMatrix}
% 121 & 23 & 345 & 345\\
% 45 & 346 & 863 & 444\\
% 3462 & 38458 & 34 & 294 \\
% 34 & 7 & 78 & 309 \\
% \CodeAfter
% \SubMatrix\{{2-2}{3-3}\}[name=A]
% \begin{tikzpicture}
% [every node/.style = {blend mode = multiply,
% inner sep = 0 pt}]
% \node [fit = (A),fill = red!15] {} ;
% \node [fit = (A-left),fill = blue!15] {} ;
% \node [fit = (A-right),fill = blue!15] {} ;
% \end{tikzpicture}
% \end{pNiceMatrix}\]
%
% \section{API for the developpers}
%
% The package \pkg{nicematrix} provides two variables which are internal but
% public\footnote{According to the LaTeX3 conventions,
% each variable with name beginning with |\g_nicematrix| ou |\l_nicematrix| is
% public and each variable with name beginning with |\g__nicematrix| or
% |\l__nicematrix| is private.}:
% \begin{itemize}
% \item |\g_nicematrix_code_before_tl| ;
% \item |\g_nicematrix_code_after_tl|.
% \end{itemize}
%
%
% \medskip
% These variables contain the code of what we have called the ``|code-before|''
% (usually specified at the beginning of the environment with the syntax using
% the keywords |\CodeBefore| and |\Body|) and the ``|code-after|'' (usually
% specified at the end of the environment after the keyword |\CodeAfter|). The
% developper can use them to add code from a cell of the array (the affectation
% must be global, allowing to exit the cell, which is a TeX group).
%
% \medskip
% One should remark that the use of |\g_nicematrix_code_before_tl| needs one
% compilation more (because the instructions are written on the |aux| file to be
% used during the next run).
%
% \bigskip
% \emph{Example} : We want to write a command |\crossbox| to draw a cross in the
% current cell. This command will take in an optional argument between square
% brackets for a list of pairs \textsl{key}-\textsl{value} which will be given to
% Tikz before the drawing.
%
% It's possible to program such command |\crossbox| as follows, explicitely
% using the public variable |\g_nicematrix_code_after_tl|.
%
% \begin{scope}
% \fvset{commandchars=\§\¤\μ}
% \begin{Verbatim}
% \ExplSyntaxOn
% \cs_new_protected:Nn \__pantigny_crossbox:nnn
% {
% \tikz \draw [ #3 ]
% ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 )
% ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
% }
%
% \NewDocumentCommand \crossbox { ! O { } }
% {
% \tl_gput_right:Nx §emphase¤\g_nicematrix_code_after_tlμ
% {
% \__pantigny_crossbox:nnn
% { \int_use:c { c@iRow } }
% { \int_use:c { c@jCol } }
% { \exp_not:n { #1 } }
% }
% }
% \ExplSyntaxOff
% \end{Verbatim}
% \end{scope}
%
%
% \ExplSyntaxOn
% \cs_new_protected:Nn \__pantigny_crossbox:nnn
% {
% \tikz \draw [ #3 ]
% ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 )
% ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
% }
%
%
% \NewDocumentCommand \crossbox { ! O { } }
% {
% \tl_gput_right:Nx \g_nicematrix_code_after_tl
% {
% \__pantigny_crossbox:nnn
% { \int_use:c { c@iRow } }
% { \int_use:c { c@jCol } }
% { \exp_not:n { #1 } }
% }
% }
% \ExplSyntaxOff
%
% \bigskip
% Here is an example of utilisation:
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% \begin{NiceTabular}{ccc}[hvlines]
% merlan & requin & cabillaud \\
% baleine & ~emphase#\crossbox[red]@ & morue \\
% mante & raie & poule
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{ccc}[hvlines]
% merlan & requin & cabillaud \\
% baleine & \crossbox[red] & morue \\
% mante & raie & poule
% \end{NiceTabular}
%
%
%
% \section{Technical remarks}
%
%
%
% \subsection{Diagonal lines}
%
% \label{parallelization}
% By default, all the diagonal lines\footnote{We speak of the lines created by
% |\Ddots| and not the lines created by a command |\line| in the |\CodeAfter|.} of a
% same array are ``parallelized''. That means that the first diagonal line is
% drawn and, then, the other lines are drawn parallel to the first one (by
% rotation around the left-most extremity of the line). That's why the position
% of the instructions |\Ddots| in the array can have a marked effect on the
% final result.
%
% \medskip
% In the following examples, the first |\Ddots| instruction is written in color:
%
% % \medskip
% \begin{scope}
% \begin{minipage}{9.5cm}
% Example with parallelization (default):
% \begin{Verbatim}
% $A = \begin{pNiceMatrix}
% 1 & \Cdots & & 1 \\
% a+b & ~emphase#\Ddots@~ & & \Vdots \\
% \Vdots & \Ddots & & \\
% a+b & \Cdots & a+b & 1
% \end{pNiceMatrix}$
% \end{Verbatim}
% \end{minipage}
% $A = \begin{pNiceMatrix}
% 1 & \Cdots & & 1 \\
% a+b & \Ddots & & \Vdots \\
% \Vdots & \Ddots & & \\
% a+b & \Cdots & a+b & 1
% \end{pNiceMatrix}$
%
% \bigskip
% \NiceMatrixOptions{parallelize-diags=true}%
% \begin{minipage}{9.5cm}
% % \begin{Verbatim}
% $A = \begin{pNiceMatrix}
% 1 & \Cdots & & 1 \\
% a+b & & & \Vdots \\
% \Vdots & ~emphase#\Ddots@~ & \Ddots & \\
% a+b & \Cdots & a+b & 1
% \end{pNiceMatrix}$
% \end{Verbatim}
% \end{minipage}
% $A = \begin{pNiceMatrix}
% 1 & \Cdots & & 1 \\
% a+b & & & \Vdots \\
% \Vdots & \Ddots & \Ddots & \\
% a+b & \Cdots & a+b & 1
% \end{pNiceMatrix}$
%
% \bigskip
% It's possible to turn off the parallelization with the option
% |parallelize-diags| set to |false|: \par\nobreak
%
% \medskip
% \NiceMatrixOptions{parallelize-diags=false}%
% \begin{minipage}{9.5cm}
% The same example without parallelization:
% \end{minipage}
% $A = \begin{pNiceMatrix}
% 1 & \Cdots & & 1 \\
% a+b & \Ddots & & \Vdots \\
% \Vdots & \Ddots & & \\
% a+b & \Cdots & a+b & 1
% \end{pNiceMatrix}$
%
% \end{scope}
%
% It's possible to specify the instruction |\Ddots| which will be drawn first
% (and which will be used to draw the other diagonal dotted lines when the
% parallelization is in force) with the key |draw-first|: |\Ddots[draw-first]|.
%
% \subsection[The empty cells]{The ``empty'' cells}
%
% \label{empty-cells}
% An instruction like |\Ldots|, |\Cdots|, etc. tries to determine the first
% non-empty cell on both sides. When the key |corners| is used
% (cf.~p.~\pageref{corners}), \pkg{nicematrix} computes corners consisting of
% empty cells. However, an ``empty cell'' is not necessarily a cell with no TeX
% content (that is to say a cell with no token between the two ampersands~|&|).
% The precise rules are as follow.
%
% \begin{itemize}
% \item An implicit cell is empty. For example, in the following matrix:
%
% \begin{Verbatim}
% \begin{pmatrix}
% a & b \\
% c \\
% \end{pmatrix}
% \end{Verbatim}
%
% the last cell (second row and second column) is empty.
%
% \medskip
% \item Each cell whose TeX ouput has a width equal to zero is empty.
%
% \medskip
% \item A cell containing the command |\NotEmpty| is not empty (and a PGF/Tikz
% node) is created in that cell.
%
% \medskip
% \item A cell with a command |\Hspace| (or |\Hspace*|) is empty. This command
% |\Hspace| is a command defined by the package \pkg{nicematrix} with the same
% meaning as |\hspace| except that the cell where it is used is considered as
% empty. This command can be used to fix the width of some columns of the matrix
% without interfering with \pkg{nicematrix}.
%
% \medskip
% \item A cell of a column of type |p|, |m| or |t| is always considered as not
% empty. \emph{Caution} : One should not rely upon that point because it may
% change in a future version of \pkg{nicematrix}. On the other side, a cell of a
% column of type |V| of \pkg{varwidth} (cf.~p.~\pageref{varwidth}) is empty when
% its TeX content has a width equal to zero.
% % \end{itemize}
%
%
% \subsection{The option exterior-arraycolsep}
%
% The environment |{array}| inserts an horizontal space equal to |\arraycolsep|
% before and after each column. In particular, there is a space equal to
% |\arraycolsep| before and after the array. This feature of the environment
% |{array}| was probably not a good idea\footnote{In the documentation of
% |{amsmath}|, we can read: {\itshape The extra space of |\arraycolsep| that
% \pkg{array} adds on each side is a waste so we remove it [in |{matrix}|]
% (perhaps we should instead remove it from array in general, but that's a
% harder task).}}. The environment |{matrix}| of
% \pkg{amsmath} and its variants (|{pmatrix}|, |{vmatrix}|, etc.) of
% \pkg{amsmath} prefer to delete these spaces with explicit instructions
% |\hskip -\arraycolsep|\footnote{And not by inserting |@{}| on both sides of the
% preamble of the array. As a consequence, the length of the |\hline| is not
% modified and may appear too long, in particular when using square brackets.}.
% The package \pkg{nicematrix} does the same in all its environments,
% |{NiceArray}| included. However, if the user wants the environment
% |{NiceArray}| behaving by default like the environment |{array}| of
% \pkg{array} (for example, when adapting an existing document) it's possible to
% control this behaviour with the option |exterior-arraycolsep|, set by the
% command |\NiceMatrixOptions|. With this option, exterior spaces of length
% |\arraycolsep| will be inserted in the environments |{NiceArray}| (the other
% environments of \pkg{nicematrix} are not affected).
%
%
%
%
% \subsection{Incompatibilities}
%
%
% The package \pkg{nicematrix} is not compatible with the class \cls{ieeeaccess}
% (because that class is not compatible with PGF/Tikz).\footnote{See
% \url{https://tex.stackexchange.com/questions/528975/error-loading-tikz-in-ieeeaccess-class}}
%
% \bigskip
% In order to use \pkg{nicematrix} with the class \cls{aastex631}, you have to
% add the following lines in the preamble of your document :
%
% \begin{Verbatim}
% \BeforeBegin{NiceTabular}{\let\begin\BeginEnvironment\let\end\EndEnvironment}
% \BeforeBegin{NiceArray}{\let\begin\BeginEnvironment}
% \BeforeBegin{NiceMatrix}{\let\begin\BeginEnvironment}
% \end{Verbatim}
%
% \bigskip
% In order to use \pkg{nicematrix} with the class \cls{sn-jnln}, \pkg{pgf} must
% be loaded before the |\documentclass|:
%
% \begin{Verbatim}
% \RequirePackage{pgf}
% \documentclass{sn-jnl}
% \end{Verbatim}
%
% \bigskip
% The package \pkg{nicematrix} is not fully compatible with the package
% \pkg{arydshln} (because this package redefines many internal of \pkg{array}).
% By any means, in the context of \pkg{nicematrix}, it's recommended to draw
% dashed rules with the tools provided by \pkg{nicematrix}, by creating a
% customized line style with |custom-line|: cf.~p.~\pageref{custom-line}.
%
%
% \section{Examples}
%
% \subsection[{Utilisation of the key 'tikz' of the command \textbackslash
% Block}]{Utilisation of the key ``tikz'' of the command \textbackslash Block}
%\label{tikz-key-examples}
%
%
% The key |tikz| of the command |\Block| is available only when Tikz is
% loaded.\footnote{By default, \pkg{nicematrix} only loads \textsc{pgf}, which is
% a sub-layer of Tikz.}
%
% For the following example, we need also the Tikz library |patterns|.
%
% \begin{Verbatim}
% \usetikzlibrary{patterns}
% \end{Verbatim}
%
%
% \begin{Verbatim}
% \ttfamily \small
% \begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt]
% \Block[~emphase#tikz={pattern=grid,pattern color=lightgray}@]{}
% {pattern = grid,\\ pattern color = lightgray}
% & \Block[~emphase#tikz={pattern = north west lines,pattern color=blue}@]{}
% {pattern = north west lines,\\ pattern color = blue}
% & \Block[~emphase#tikz={outer color = red!50, inner color=white }@]{2-1}
% {outer color = red!50,\\ inner color = white} \\
% \Block[~emphase#tikz={pattern = sixpointed stars, pattern color = blue!15}@]{}
% {pattern = sixpointed stars,\\ pattern color = blue!15}
% & \Block[~emphase#tikz={left color = blue!50}@]{}
% {left color = blue!50} \\
% \end{NiceTabular}
% \end{Verbatim}
%
% \begin{center}
% \ttfamily \small
% \begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt]
% \Block[tikz={pattern=grid,pattern color=lightgray}]{}
% {pattern = grid,\\ pattern color = lightgray}
% & \Block[tikz={pattern = north west lines,pattern color=blue}]{}
% {pattern = north west lines,\\ pattern color = blue}
% & \Block[tikz={outer color = red!50, inner color=white }]{2-1}
% {outer color = red!50,\\ inner color = white} \\
% \Block[tikz={pattern = sixpointed stars, pattern color = blue!15}]{}
% {pattern = sixpointed stars,\\ pattern color = blue!15}
% & \Block[tikz={left color = blue!50}]{}
% {left color = blue!50} \\
% \end{NiceTabular}
% \end{center}
%
%
% \subsection{Notes in the tabulars}
%
% \label{ex:notes}
%
% The tools provided by \pkg{nicematrix} for the composition of the tabular
% notes have been presented in the section \ref{s:notes} p.~\pageref{s:notes}.
%
% \medskip
% Let's consider that we wish to number the notes of a tabular with
% stars.\footnote{Of course, it's realistic only when there is very few notes in
% the tabular.}
%
% \medskip
% First, we write a command |\stars| similar the well-known commands
% |\arabic|, |\alph|, |\Alph|, etc. which produces a number of stars equal to
% its argument \footnote{In fact: the value of its argument.}
% \begin{Verbatim}
% \ExplSyntaxOn
% \NewDocumentCommand ~emphase#\stars@ { m }
% { \prg_replicate:nn { \value { ~#1 } } { $ \star $ } }
% \ExplSyntaxOff
% \end{Verbatim}
% %
% Of course, we change the style of the labels with the key |notes/style|.
% However, it would be interesting to change also some parameters in the type of
% list used to compose the notes at the end of the tabular.
% First, we required a composition flush right for the labels with the setting
% |align=right|.
% Moreover, we want the labels to be composed on a width equal to the width of
% the widest label. The widest label is, of course, the label with the greatest
% number of stars. We know that number: it is equal to |\value{tabularnote}|
% (because |tabularnote| is the LaTeX counter used by |\tabularnote| and,
% therefore, at the end of the tabular, its value is equal to the total number
% of tabular notes). We use the key |widest*| of \pkg{enumitem} in order to
% require a width equal to that value: |widest*=\value{tabularnote}|.
% \begin{Verbatim}
% \NiceMatrixOptions
% {
% notes =
% {
% ~emphase#style = \stars{~#1} , @
% ~emphase#enumitem-keys = @
% ~emphase# { @
% ~emphase# widest* = \value{tabularnote} ,@
% ~emphase# align = right @
% ~emphase# } @
% }
% }
% \end{Verbatim}
%
%
%
% \begin{scope}
% \ExplSyntaxOn
% \NewDocumentCommand \stars { m }
% { \prg_replicate:nn { \value { #1 } } { $ \star $ } }
% \NiceMatrixOptions
% {
% notes =
% {
% style = \stars{#1} ,
% enumitem-keys =
% {
% widest* = \value{tabularnote} ,
% align = right
% }
% }
% }
% \ExplSyntaxOff
% \begin{Verbatim}
% \begin{NiceTabular}{~@{}llr~@{}}
% \toprule \RowStyle{\bfseries}
% Last name & First name & Birth day \\
% \midrule
% Achard\tabularnote{~emphase#Achard is an old family of the Poitou.@}
% & Jacques & 5 juin 1962 \\
% Lefebvre\tabularnote{~emphase#The name Lefebvre is an alteration of the name Lefebure.@}
% & Mathilde & 23 mai 1988 \\
% Vanesse & Stephany & 30 octobre 1994 \\
% Dupont & Chantal & 15 janvier 1998 \\
% \bottomrule
% \end{NiceTabular}
% \end{Verbatim}
%
% \begin{center}
% \begin{NiceTabular}{@{}llr@{}}
% \toprule \RowStyle{\bfseries}
% Last name & First name & Birth day \\
% \midrule
% Achard\tabularnote{Achard is an old family of the Poitou.}
% & Jacques & June 5, 2005 \\
% Lefebvre\tabularnote{The name Lefebvre is an alteration of the name Lefebure.}
% & Mathilde & January 23, 1975 \\
% Vanesse & Stephany & October 30, 1994 \\
% Dupont & Chantal & January 15, 1998 \\
% \bottomrule
% \end{NiceTabular}
% \end{center}
% \end{scope}
%
%
%
% \subsection{Dotted lines}
%
% An example with the resultant of two polynoms:\par\nobreak
%
% \bigskip
% \begin{BVerbatim}
% \setlength{\extrarowheight}{1mm}
% \[\begin{vNiceArray}{cccc:ccc}[columns-width=6mm]
% a_0 & && &b_0 & & \\
% a_1 &\Ddots&& &b_1 &\Ddots& \\
% \Vdots&\Ddots&& &\Vdots &\Ddots&b_0 \\
% a_p & &&a_0 & & &b_1 \\
% &\Ddots&&a_1 &b_q & &\Vdots\\
% & &&\Vdots & &\Ddots& \\
% & &&a_p & & &b_q
% \end{vNiceArray}\]
% \end{BVerbatim}
%
% \bigskip
%
% \begin{scope}
% \setlength{\extrarowheight}{1mm}
% \[\begin{vNiceArray}{cccc:ccc}[columns-width=6mm]
% a_0 & && &b_0 & & \\
% a_1 &\Ddots&& &b_1 &\Ddots& \\
% \Vdots&\Ddots&& &\Vdots &\Ddots&b_0 \\
% a_p & &&a_0 & & &b_1 \\
% &\Ddots&&a_1 &b_q & &\Vdots\\
% & &&\Vdots & &\Ddots& \\
% & &&a_p & & &b_q
% \end{vNiceArray}\]
% \end{scope}
%
% \vspace{2cm}
% An example for a linear system:\par\nobreak
%
% \begin{Verbatim}
% $\begin{pNiceArray}{*6c|c}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\
% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
% 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\
% & & &\Ddots & & & \Vdots & \Vdots \\
% \Vdots & & &\Ddots & & 0 & \\
% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
% \end{pNiceArray}$
% \end{Verbatim}
%
%
% \[\begin{pNiceArray}{*6c|c}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\
% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
% 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\
% & & &\Ddots & & & \Vdots & \Vdots \\
% \Vdots & & &\Ddots & & 0 & \\
% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
% \end{pNiceArray}\]
%
%
%
% \subsection{Dotted lines which are no longer dotted}
%
% The option |line-style| controls the style of the lines drawn by |\Ldots|,
% |\Cdots|, etc. Thus, it's possible with these commands to draw lines which are
% not longer dotted.
%
%
% \begin{Verbatim}[formatcom=\small\color{gray}]
% \NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle }
% \setcounter{MaxMatrixCols}{12}
% \newcommand{\blue}{\color{blue}}
% \[\begin{pNiceMatrix}[last-row,last-col,nullify-dots,xdots/line-style={dashed,blue}]
% 1& & & \Vdots & & & & \Vdots \\
% & \Ddots[line-style=standard] \\
% & & 1 \\
% \Cdots[color=blue,line-style=dashed]& & & \blue 0 &
% \Cdots & & & \blue 1 & & & \Cdots & \blue \leftarrow i \\
% & & & & 1 \\
% & & &\Vdots & & \Ddots[line-style=standard] & & \Vdots \\
% & & & & & & 1 \\
% \Cdots & & & \blue 1 & \Cdots & & \Cdots & \blue 0 & & & \Cdots & \blue \leftarrow j \\
% & & & & & & & & 1 \\
% & & & & & & & & & \Ddots[line-style=standard] \\
% & & & \Vdots & & & & \Vdots & & & 1 \\
% & & & \blue \overset{\uparrow}{i} & & & & \blue \overset{\uparrow}{j} \\
% \end{pNiceMatrix}\]
% \end{Verbatim}
%
%
% \begin{scope}
% \NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle }
% \setcounter{MaxMatrixCols}{12}
% \newcommand{\blue}{\color{blue}}
% \[\begin{pNiceMatrix}[last-row,last-col,nullify-dots,xdots/line-style={dashed,blue}]
% 1& & & \Vdots & & & & \Vdots \\
% & \Ddots[line-style=standard] \\
% & & 1 \\
% \Cdots[color=blue,line-style=dashed]& & & \blue 0 &
% \Cdots & & & \blue 1 & & & \Cdots & \blue \leftarrow i \\
% & & & & 1 \\
% & & &\Vdots & & \Ddots[line-style=standard] & & \Vdots \\
% & & & & & & 1 \\
% \Cdots & & & \blue 1 & \Cdots & & \Cdots & \blue 0 & & & \Cdots & \blue \leftarrow j \\
% & & & & & & & & 1 \\
% & & & & & & & & & \Ddots[line-style=standard] \\
% & & & \Vdots & & & & \Vdots & & & 1 \\
% & & & \blue \overset{\uparrow}{i} & & & & \blue \overset{\uparrow}{j} \\
% \end{pNiceMatrix}\]
% \end{scope}
%
% \interitem
% In fact, it's even possible to draw solid lines with the commands |\Cdots|,
% |\Vdots|, etc.\footnote{In this document, the Tikz library \pkg{arrows.meta}
% has been loaded, which impacts the shape of the arrow tips.}
%
% \begin{Verbatim}
% \NiceMatrixOptions
% {nullify-dots,code-for-first-col = \color{blue},code-for-first-row=\color{blue}}
% $\begin{pNiceMatrix}[first-row,first-col]
% & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\
% & 1 & 1 & 1 & \Ldots & 1 \\
% & 1 & 1 & 1 & & 1 \\
% \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\
% & 1 & 1 & 1 & & 1 \\
% & 1 & 1 & 1 & \Ldots & 1
% \end{pNiceMatrix}$
% \end{Verbatim}
%
%
% \begin{scope}
% \NiceMatrixOptions
% {nullify-dots,code-for-first-col = \color{blue},code-for-first-row=\color{blue}}
% \[\begin{pNiceMatrix}[first-row,first-col]
% & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\
% & 1 & 1 & 1 & \Ldots & 1 \\
% & 1 & 1 & 1 & & 1 \\
% \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\
% & 1 & 1 & 1 & & 1 \\
% & 1 & 1 & 1 & \Ldots & 1
% \end{pNiceMatrix}\]
% \end{scope}
%
% \subsection{Dashed rules}
% \label{dashed}
%
% In the following example, we use the command |\Block| to draw dashed rules.
% For that example, Tikz should be loaded (by |\usepackage{tikz}|).
%
%
% \begin{Verbatim}
% \begin{pNiceMatrix}
% ~emphase#\Block[borders={bottom,right,tikz=dashed}]{2-2}{}@
% 1 & 2 & 0 & 0 & 0 & 0 \\
% 4 & 5 & 0 & 0 & 0 & 0 \\
% 0 & 0 & ~emphase#\Block[borders={bottom,top,right,left,tikz=dashed}]{2-2}{}@
% 7 & 1 & 0 & 0 \\
% 0 & 0 & -1 & 2 & 0 & 0 \\
% 0 & 0 & 0 & 0 & ~emphase#\Block[borders={left,top,tikz=dashed}]{2-2}{}@
% 3 & 4 \\
% 0 & 0 & 0 & 0 & 1 & 4
% \end{pNiceMatrix}
% \end{Verbatim}
%
%
% \[\begin{pNiceMatrix}
% \Block[borders={bottom,right,tikz=dashed}]{2-2}{}
% 1 & 2 & 0 & 0 & 0 & 0 \\
% 4 & 5 & 0 & 0 & 0 & 0 \\
% 0 & 0 & \Block[borders={bottom,top,right,left,tikz=dashed}]{2-2}{}
% 7 & 1 & 0 & 0 \\
% 0 & 0 & -1 & 2 & 0 & 0 \\
% 0 & 0 & 0 & 0 & \Block[borders={left,top,tikz=dashed}]{2-2}{}
% 3 & 4 \\
% 0 & 0 & 0 & 0 & 1 & 4
% \end{pNiceMatrix}\]
%
%
% \subsection{Stacks of matrices}
%
% We often need to compose mathematical matrices on top on each other (for
% example for the resolution of linear systems).
%
% \medskip
% In order to have the columns aligned one above the other, it's possible to
% fix a width for all the columns. That's what is done in the following example
% with the environment |{NiceMatrixBlock}| and its option |auto-columns-width|.
%
% \begin{Verbatim}[formatcom=\small\color{gray}]
% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
% \NiceMatrixOptions
% {
% light-syntax,
% last-col, code-for-last-col = \color{blue} \scriptstyle,
% }
% \setlength{\extrarowheight}{1mm}
%
% $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 {} ;
% 3 -18 12 1 4 ;
% -3 -46 29 -2 -15 ;
% 9 10 -5 4 7
% \end{pNiceArray}$
%
% \smallskip
% $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 ;
% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
% \end{pNiceArray}$
%
% \smallskip
% $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 ;
% 0 64 -41 1 19 ;
% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
% \end{pNiceArray}$
%
% \smallskip
% $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 {} ;
% 0 64 -41 1 19 ;
% \end{pNiceArray}$
%
% ~emphase#\end{NiceMatrixBlock}@
% \end{Verbatim}
%
% \bigskip
% \begin{NiceMatrixBlock}[auto-columns-width]
% \NiceMatrixOptions
% {
% light-syntax,
% last-col, code-for-last-col = \color{blue} \scriptstyle ,
% }
% \setlength{\extrarowheight}{1mm}
%
% \quad $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 {} ;
% 3 -18 12 1 4 ;
% -3 -46 29 -2 -15 ;
% 9 10 -5 4 7
% \end{pNiceArray}$
%
% \smallskip
% \quad $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 ;
% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
% \end{pNiceArray}$
%
% \smallskip
% \quad $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 ;
% 0 64 -41 1 19 ;
% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
% \end{pNiceArray}$\par\nobreak
%
% \smallskip
% \quad $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 {} ;
% 0 64 -41 1 19 ;
% \end{pNiceArray}$
% \end{NiceMatrixBlock}
%
% \bigskip
% However, one can see that the last matrix is not perfectly aligned with
% others. That's why, in LaTeX, the parenthesis have not exactly the same width
% (smaller parenthesis are a bit slimer).
%
% \medskip
% In order the solve that problem, it's possible to require the delimiters to be
% composed with the maximal width, thanks to the boolean key
% |delimiters/max-width|.
%
% \begin{Verbatim}[formatcom=\small\color{gray}]
% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
% \NiceMatrixOptions
% {
% ~emphase#delimiters/max-width@,
% light-syntax,
% last-col, code-for-last-col = \color{blue}\scriptstyle,
% }
% \setlength{\extrarowheight}{1mm}
%
% $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 {} ;
% 3 -18 12 1 4 ;
% -3 -46 29 -2 -15 ;
% 9 10 -5 4 7
% \end{pNiceArray}$
%
% ...
% ~emphase#\end{NiceMatrixBlock}@
% \end{Verbatim}
%
% \bigskip
% \begin{NiceMatrixBlock}[auto-columns-width]
% \NiceMatrixOptions
% {
% delimiters/max-width,
% light-syntax,
% last-col, code-for-last-col = \color{blue}\scriptstyle,
% }
% \setlength{\extrarowheight}{1mm}
%
% \quad $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 {} ;
% 3 -18 12 1 4 ;
% -3 -46 29 -2 -15 ;
% 9 10 -5 4 7
% \end{pNiceArray}$
%
% \smallskip
% \quad $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 ;
% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
% \end{pNiceArray}$
%
% \smallskip
% \quad $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 ;
% 0 64 -41 1 19 ;
% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
% \end{pNiceArray}$\par\nobreak
%
% \smallskip
% \quad $\begin{pNiceArray}{rrrr|r}
% 12 -8 7 5 3 {} ;
% 0 64 -41 1 19 ;
% \end{pNiceArray}$
%
% \end{NiceMatrixBlock}
%
%
% \interitem
% If you wish an alignment of the different matrices without the same width
% for all the columns, you can construct a unique array and place the
% parenthesis with commands |\SubMatrix| in the |\CodeAfter|. Of course, that
% array can't be broken by a page break.
%
% \medskip
% \begin{Verbatim}
% \setlength{\extrarowheight}{1mm}
% \[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ]
% 12 & -8 & 7 & 5 & 3 \\
% 3 & -18 & 12 & 1 & 4 \\
% -3 & -46 & 29 &-2 &-15 \\
% 9 & 10 &-5 &4 & 7 \\[1mm]
% 12 & -8 & 7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 &1 &19 \\
% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 \\
% ~emphase#\CodeAfter [sub-matrix/vlines=4]@
% ~emphase# \SubMatrix({1-1}{4-5})@
% ~emphase# \SubMatrix({5-1}{8-5})@
% ~emphase# \SubMatrix({9-1}{11-5})@
% ~emphase# \SubMatrix({12-1}{13-5})@
% \end{NiceMatrix}\]
% \end{Verbatim}
%
% \medskip
% \begin{scope}
% \setlength{\extrarowheight}{1mm}
% \[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ]
% 12 & -8 & 7 & 5 & 3 \\
% 3 & -18 & 12 & 1 & 4 \\
% -3 & -46 & 29 &-2 &-15 \\
% 9 & 10 &-5 &4 & 7 \\[1mm]
% 12 & -8 & 7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 &1 &19 \\
% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 \\
% \CodeAfter [sub-matrix/vlines=4]
% \SubMatrix({1-1}{4-5})
% \SubMatrix({5-1}{8-5})
% \SubMatrix({9-1}{11-5})
% \SubMatrix({12-1}{13-5})
% \end{NiceMatrix}\]
% \end{scope}
%
% \bigskip
% In this tabular, the instructions |\SubMatrix| are executed after the
% composition of the tabular and, thus, the vertical rules are drawn without
% adding space between the columns.
%
%
%\bigskip
% In fact, it's possible, with the key |vlines-in-sub-matrix|, to choice a
% letter in the preamble of the array to specify vertical rules which will be
% drawn in the |\SubMatrix| only (by adding space between the columns).
%
% \medskip
% \begin{Verbatim}
% \setlength{\extrarowheight}{1mm}
% \[\begin{NiceArray}
% [
% ~emphase#vlines-in-sub-matrix=I@,
% last-col,
% code-for-last-col = \scriptstyle \color{blue}
% ]
% {rrrrIr}
% 12 & -8 & 7 & 5 & 3 \\
% 3 & -18 & 12 & 1 & 4 \\
% -3 & -46 & 29 &-2 &-15 \\
% 9 & 10 &-5 &4 & 7 \\[1mm]
% 12 & -8 & 7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 &1 &19 \\
% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 \\
% \CodeAfter
% \SubMatrix({1-1}{4-5})
% \SubMatrix({5-1}{8-5})
% \SubMatrix({9-1}{11-5})
% \SubMatrix({12-1}{13-5})
% \end{NiceArray}\]
% \end{Verbatim}
%
%
% \medskip
% \begin{scope}
% \setlength{\extrarowheight}{1mm}
% \[\begin{NiceArray}
% [
% vlines-in-sub-matrix=I,
% last-col,
% code-for-last-col = \scriptstyle \color{blue}
% ]
% {rrrrIr}
% 12 & -8 & 7 & 5 & 3 \\
% 3 & -18 & 12 & 1 & 4 \\
% -3 & -46 & 29 &-2 &-15 \\
% 9 & 10 &-5 &4 & 7 \\[1mm]
% 12 & -8 & 7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 &1 &19 \\
% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 \\
% \CodeAfter
% \SubMatrix({1-1}{4-5})
% \SubMatrix({5-1}{8-5})
% \SubMatrix({9-1}{11-5})
% \SubMatrix({12-1}{13-5})
% \end{NiceArray}\]
% \end{scope}
%
%
%
%
%
% \subsection{How to highlight cells of a matrix}
%
%
% \label{highlight}
%
% \medskip
% In order to highlight a cell of a matrix, it's possible to ``draw'' that cell
% with the key |draw| of the command |\Block| (this is one of the uses of a
% mono-cell block\footnote{We recall that, if the first mandatory argument of
% the command |\Block| is left empty, that means that the block is a mono-cell block}).
%
% \label{example-CodeAfter}
%
%
% \begin{Verbatim}
% $\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue]
% ~emphase#\Block[draw]{}{a_{11}}@ & a_{12} & a_{13} & a_{14} \\
% a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\
% a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\
% a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\
% \end{pNiceArray}$
% \end{Verbatim}
% \[\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue]
% \Block[draw]{}{a_{11}} & a_{12} & a_{13} & a_{14} \\
% a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\
% a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\
% a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\
% \end{pNiceArray}\]
%
% We should remark that the rules we have drawn are drawn \emph{after} the
% construction of the array and thus, they don't spread the cells of the array.
% We recall that, on the other side, the commands |\hline| and |\Hline|, the
% specifier ``"|"'' and the options |hlines|, |vlines|, |hvlines| and
% |hvlines-except-borders| spread the cells.\footnote{For the command |\cline|,
% see the remark p.~\pageref{remark-cline}.}
%
%
% \vspace{1cm}
% It's possible to color a row with |\rowcolor| in the |code-before| (or with
% |\rowcolor| in the first cell of the row if the key |colortbl-like| is
% used−even when \pkg{colortbl} is not loaded).
%
% \medskip
% \begin{Verbatim}
% \begin{pNiceArray}{>{\strut}cccc}[margin, extra-margin=2pt,colortbl-like]
% ~emphase#\rowcolor{red!15}@A_{11} & A_{12} & A_{13} & A_{14} \\
% A_{21} & ~emphase#\rowcolor{red!15}@A_{22} & A_{23} & A_{24} \\
% A_{31} & A_{32} & ~emphase#\rowcolor{red!15}@A_{33} & A_{34} \\
% A_{41} & A_{42} & A_{43} & ~emphase#\rowcolor{red!15}@A_{44}
% \end{pNiceArray}
% \end{Verbatim}
%
%
%
% \[\begin{pNiceArray}{>{\strut}cccc}[margin, extra-margin=2pt,colortbl-like]
% \rowcolor{red!15}A_{11} & A_{12} & A_{13} & A_{14} \\
% A_{21} & \rowcolor{red!15}A_{22} & A_{23} & A_{24} \\
% A_{31} & A_{32} & \rowcolor{red!15}A_{33} & A_{34} \\
% A_{41} & A_{42} & A_{43} & \rowcolor{red!15}A_{44}
% \end{pNiceArray}\]
%
% \bigskip
% However, it's not possible to do a fine tuning. That's why we describe now a
% method to highlight a row of the matrix.
%
% \medskip
% That example and the following ones require Tikz (by default, \pkg{nicematrix}
% only loads \textsc{pgf}, which is a sub-layer of Tikz) and the Tikz library
% |fit|. The following lines in the preamble of your document do the job:
% \begin{verbatim}
% \usepackage{tikz}
% \usetikzlibrary{fit}
% \end{verbatim}
%
% \medskip
% We create a rectangular Tikz node which encompasses the nodes of the second
% row by using the tools of the Tikz library \pkg{fit}. Those nodes are not
% available by default in the |\CodeBefore| (for efficiency). We have to require
% their creation with the key |create-cell-nodes| of the keyword |\CodeBefore|.
%
% \tikzset{highlight/.style={rectangle,
% fill=red!15,
% rounded corners = 0.5 mm,
% inner sep=1pt,
% fit = #1}}
%
% \medskip
% \begin{Verbatim}
% \tikzset{highlight/.style={rectangle,
% fill=red!15,
% rounded corners = 0.5 mm,
% inner sep=1pt,
% fit=~#1}}
%
% $\begin{bNiceMatrix}
% ~emphase#\CodeBefore [create-cell-nodes] @
% ~emphase# \tikz \node [highlight = (2-1) (2-3)] {} ; @
% ~emphase# \Body @
% 0 & \Cdots & 0 \\
% 1 & \Cdots & 1 \\
% 0 & \Cdots & 0 \\
% \end{bNiceMatrix}$
% \end{Verbatim}
% \[\begin{bNiceMatrix}
% \CodeBefore [create-cell-nodes]
% \tikz \node [highlight = (2-1) (2-3)] {} ;
% \Body
% 0 & \Cdots & 0 \\
% 1 & \Cdots & 1 \\
% 0 & \Cdots & 0 \\
% \end{bNiceMatrix}\]
%
%
% \vspace{1cm}
% We consider now the following matrix. If we want to highlight each row of
% this matrix, we can use the previous technique three times.
%
% \begin{Verbatim}
% \[\begin{pNiceArray}{ccc}[last-col]
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture}
% ~emphase# \node [highlight = (1-1) (1-3)] {} ;@
% ~emphase# \node [highlight = (2-1) (2-3)] {} ;@
% ~emphase# \node [highlight = (3-1) (3-3)] {} ;@
% \end{tikzpicture}
% \Body
% a & a + b & a + b + c & L_1 \\
% a & a & a + b & L_2 \\
% a & a & a & L_3
% \end{pNiceArray}\]
% \end{Verbatim}
%
%
% \[\begin{pNiceArray}{ccc}[last-col]
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture}
% \node [highlight = (1-1) (1-3)] {} ;
% \node [highlight = (2-1) (2-3)] {} ;
% \node [highlight = (3-1) (3-3)] {} ;
% \end{tikzpicture}
% \Body
% a & a + b & a + b + c & L_1 \\
% a & a & a + b & L_2 \\
% a & a & a & L_3
% \end{pNiceArray}\]
%
% \medskip
% The result may seem disappointing. We can improve it by using the ``medium
% nodes'' instead of the ``normal nodes''.
%
% \begin{Verbatim}
% \[\begin{pNiceArray}{ccc}[last-col,create-medium-nodes]
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture} ~emphase#[name suffix = -medium]@
% \node [highlight = (1-1) (1-3)] {} ;
% \node [highlight = (2-1) (2-3)] {} ;
% \node [highlight = (3-1) (3-3)] {} ;
% \end{tikzpicture}
% \Body
% a & a + b & a + b + c & L_1 \\
% a & a & a + b & L_2 \\
% a & a & a & L_3
% \end{pNiceArray}\]
% \end{Verbatim}
%
%
%\[\begin{pNiceArray}{ccc}[last-col,create-medium-nodes]
% \CodeBefore [create-cell-nodes]
% \begin{tikzpicture} [name suffix = -medium]
% \node [highlight = (1-1) (1-3)] {} ;
% \node [highlight = (2-1) (2-3)] {} ;
% \node [highlight = (3-1) (3-3)] {} ;
% \end{tikzpicture}
% \Body
% a & a + b & a + b + c & L_1 \\
% a & a & a + b & L_2 \\
% a & a & a & L_3
% \end{pNiceArray}\]
%
%
% \subsection{Utilisation of \textbackslash SubMatrix in the \textbackslash CodeBefore}
%
% In the following example, we illustrate the mathematical product of two
% matrices.
%
% The whole figure is an environment |{NiceArray}| and the three pairs of
% parenthesis have been added with |\SubMatrix| in the |\CodeBefore|.
%
% \tikzset{highlight/.style={rectangle,
% fill=red!15,
% rounded corners = 0.5 mm,
% inner sep=1pt,
% fit=#1}}%
% \[\begin{NiceArray}{*{6}{c}@{\hspace{6mm}}*{5}{c}}[nullify-dots]
% \CodeBefore [create-cell-nodes]
% \SubMatrix({2-7}{6-11})
% \SubMatrix({7-2}{11-6})
% \SubMatrix({7-7}{11-11})
% \begin{tikzpicture}
% \node [highlight = (9-2) (9-6)] { } ;
% \node [highlight = (2-9) (6-9)] { } ;
% \end{tikzpicture}
% \Body
% & & & & & & & & \color{blue}\scriptstyle C_j \\
% & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
% & & & & & & \Vdots & & \Vdots & & \Vdots \\
% & & & & & & & & b_{kj} \\
% & & & & & & & & \Vdots \\
% & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm]
% & a_{11} & \Cdots & & & a_{1n} \\
% & \Vdots & & & & \Vdots & & & \Vdots \\
% \color{blue}\scriptstyle L_i
% & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\
% & \Vdots & & & & \Vdots \\
% & a_{n1} & \Cdots & & & a_{nn} \\
% \CodeAfter
% \tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ;
% \end{NiceArray}\]
%
%
% \vspace{1cm}
% \begin{Verbatim}
% \tikzset{highlight/.style={rectangle,
% fill=red!15,
% rounded corners = 0.5 mm,
% inner sep=1pt,
% fit=~#1}}
% \end{Verbatim}
%
% \begin{Verbatim}[formatcom = \small\color{gray}]
% \[\begin{NiceArray}{*{6}{c}~LetterAt{\hspace{6mm}}*{5}{c}}[nullify-dots]
% \CodeBefore [create-cell-nodes]
% \SubMatrix({2-7}{6-11})
% \SubMatrix({7-2}{11-6})
% \SubMatrix({7-7}{11-11})
% \begin{tikzpicture}
% \node [highlight = (9-2) (9-6)] { } ;
% \node [highlight = (2-9) (6-9)] { } ;
% \end{tikzpicture}
% \Body
% & & & & & & & & \color{blue}\scriptstyle C_j \\
% & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
% & & & & & & \Vdots & & \Vdots & & \Vdots \\
% & & & & & & & & b_{kj} \\
% & & & & & & & & \Vdots \\
% & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm]
% & a_{11} & \Cdots & & & a_{1n} \\
% & \Vdots & & & & \Vdots & & & \Vdots \\
% \color{blue}\scriptstyle L_i
% & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\
% & \Vdots & & & & \Vdots \\
% & a_{n1} & \Cdots & & & a_{nn} \\
% \CodeAfter
% \tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ;
% \end{NiceArray}\]
% \end{Verbatim}
%
%
% \section{Implementation}
%
% By default, the package \pkg{nicematrix} doesn't patch any existing code.
%
% \smallskip
% However, when the option |renew-dots| is used, the commands |\cdots|,
% |\ldots|, |\dots|, |\vdots|, |\ddots| and |\iddots| are redefined in the
% environments provided by \pkg{nicematrix} as explained previously. In the same
% way, if the option |renew-matrix| is used, the environment |{matrix}| of
% \pkg{amsmath} is redefined.
%
% \smallskip
% On the other hand, the environment |{array}| is never redefined.
%
% \smallskip
% Of course, the package \pkg{nicematrix} uses the features of the package
% \pkg{array}. It tries to be independent of its implementation. Unfortunately,
% it was not possible to be strictly independent. For example, the package
% \pkg{nicematrix} relies upon the fact that the package |{array}| uses
% |\ialign| to begin the |\halign|.
%
%
% \bigskip
% \subsection*{Declaration of the package and packages loaded}
%
%
% The prefix |nicematrix| has been registred for this package.
%
% See: |http://mirrors.ctan.org/macros/latex/contrib/l3kernel/l3prefixes.pdf|
%
%<@@=nicematrix>
%
% \bigskip
% First, we load \pkg{pgfcore} and the module \pkg{shapes}. We do so because
% it's not possible to use |\usepgfmodule| in |\ExplSyntaxOn|.
% \begin{macrocode}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
% \end{macrocode}
%
%
% We give the traditional declaration of a package written with the L3
% programming layer.
% \begin{macrocode}
\RequirePackage{l3keys2e}
\ProvidesExplPackage
{nicematrix}
{\myfiledate}
{\myfileversion}
{Enhanced arrays with the help of PGF/TikZ}
% \end{macrocode}
%
%
% \bigskip
% The command for the treatment of the options of |\usepackage| is at the end of
% this package for technical reasons.
%
% \bigskip
% We load some packages. The package \pkg{xparse} is still loaded for use on
% Overleaf. However, since oct. 2021, Overleaf uses TeXLive 2021 and we will be
% able to delete that row.
% \begin{macrocode}
\RequirePackage { xparse }
\RequirePackage { array }
\RequirePackage { amsmath }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_error:n { \msg_error:nn { nicematrix } }
\cs_new_protected:Npn \@@_error:nn { \msg_error:nnn { nicematrix } }
\cs_generate_variant:Nn \@@_error:nn { n x }
\cs_new_protected:Npn \@@_error:nnn { \msg_error:nnnn { nicematrix } }
\cs_new_protected:Npn \@@_fatal:n { \msg_fatal:nn { nicematrix } }
\cs_new_protected:Npn \@@_fatal:nn { \msg_fatal:nnn { nicematrix } }
\cs_new_protected:Npn \@@_msg_new:nn { \msg_new:nnn { nicematrix } }
\cs_new_protected:Npn \@@_msg_new:nnn { \msg_new:nnnn { nicematrix } }
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_msg_redirect_name:nn
{ \msg_redirect_name:nnn { nicematrix } }
% \end{macrocode}
%
%
% \bigskip
% \subsection*{Technical definitions}
%
% \begin{macrocode}
\tl_new:N \l_@@_argspec_tl
% \end{macrocode}
%
% \begin{macrocode}
\cs_generate_variant:Nn \seq_gset_split:Nnn { N V n }
\cs_generate_variant:Nn \keys_define:nn { n x }
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\@ifpackageloaded { varwidth }
{ \bool_const:Nn \c_@@_varwidth_loaded_bool { \c_true_bool } }
{ \bool_const:Nn \c_@@_varwidth_loaded_bool { \c_false_bool } }
\@ifpackageloaded { arydshln }
{ \bool_const:Nn \c_@@_arydshln_loaded_bool { \c_true_bool } }
{ \bool_const:Nn \c_@@_arydshln_loaded_bool { \c_false_bool } }
\@ifpackageloaded { booktabs }
{ \bool_const:Nn \c_@@_booktabs_loaded_bool { \c_true_bool } }
{ \bool_const:Nn \c_@@_booktabs_loaded_bool { \c_false_bool } }
\@ifpackageloaded { enumitem }
{ \bool_const:Nn \c_@@_enumitem_loaded_bool { \c_true_bool } }
{ \bool_const:Nn \c_@@_enumitem_loaded_bool { \c_false_bool } }
\@ifpackageloaded { tabularx }
{ \bool_const:Nn \c_@@_tabularx_loaded_bool { \c_true_bool } }
{ \bool_const:Nn \c_@@_tabularx_loaded_bool { \c_false_bool } }
{ }
\@ifpackageloaded { tikz }
{
% \end{macrocode}
% In some constructions, we will have to use a |{pgfpicture}| which \emph{must}
% be replaced by a |{tikzpicture}| if Tikz is loaded. However, this switch
% between |{pgfpicture}| and |{tikzpicture}| can't be done dynamically with a
% conditional because, when the Tikz library |external| is loaded by the user,
% the pair |\tikzpicture|-|\endtikpicture| (or
% |\begin{tikzpicture}-\end{tikzpicture}|) must be statically ``visible'' (even
% when externalization is not activated).
%
% That's why we create |\c_@@_pgfortikzpicture_tl| and
% |\c_@@_endpgfortikzpicture_tl| which will be used to construct in a
% |\AtBeginDocument| the correct version of some commands. The tokens
% |\exp_not:N| are mandatory.
% \begin{macrocode}
\bool_const:Nn \c_@@_tikz_loaded_bool \c_true_bool
\tl_const:Nn \c_@@_pgfortikzpicture_tl { \exp_not:N \tikzpicture }
\tl_const:Nn \c_@@_endpgfortikzpicture_tl { \exp_not:N \endtikzpicture }
}
{
\bool_const:Nn \c_@@_tikz_loaded_bool \c_false_bool
\tl_const:Nn \c_@@_pgfortikzpicture_tl { \exp_not:N \pgfpicture }
\tl_const:Nn \c_@@_endpgfortikzpicture_tl { \exp_not:N \endpgfpicture }
}
}
% \end{macrocode}
%
% We test whether the current class is \cls{revtex4-1} (deprecated) or
% \cls{revtex4-2} because these classes redefines |\array| (of \pkg{array}) in a
% way incompatible with our programmation. At the date January 2022, the current
% version \cls{revtex4-2} is 4.2e (compatible with \pkg{booktabs}).
%
% \begin{macrocode}
\@ifclassloaded { revtex4-1 }
{ \bool_const:Nn \c_@@_revtex_bool \c_true_bool }
{
\@ifclassloaded { revtex4-2 }
{ \bool_const:Nn \c_@@_revtex_bool \c_true_bool }
{
% \end{macrocode}
% Maybe one of the previous classes will be loaded inside another class... We
% try to detect that situation.
% \begin{macrocode}
\cs_if_exist:NT \rvtx@ifformat@geq
{ \bool_const:Nn \c_@@_revtex_bool \c_true_bool }
{ \bool_const:Nn \c_@@_revtex_bool \c_false_bool }
}
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_generate_variant:Nn \tl_if_single_token_p:n { V }
% \end{macrocode}
%
% \bigskip
% The following regex will be used to modify the preamble of the array when the
% key |colortbl-like| is used.
% \begin{macrocode}
\regex_const:Nn \c_@@_columncolor_regex { \c { columncolor } }
% \end{macrocode}
%
% \bigskip
% If the final user uses \pkg{nicematrix}, PGF/Tikz will write instruction
% |\pgfsyspdfmark| in the |aux| file. If he changes its mind and no longer loads
% \pkg{nicematrix}, an error may occur at the next compilation because of
% remanent instructions |\pgfsyspdfmark| in the |aux| file. With the following
% code, we try to avoid that situation.
% \begin{macrocode}
\cs_new_protected:Npn \@@_provide_pgfsyspdfmark:
{
\iow_now:Nn \@mainaux
{
\ExplSyntaxOn
\cs_if_free:NT \pgfsyspdfmark
{ \cs_set_eq:NN \pgfsyspdfmark \@gobblethree }
\ExplSyntaxOff
}
\cs_gset_eq:NN \@@_provide_pgfsyspdfmark: \prg_do_nothing:
}
% \end{macrocode}
%
%
% \bigskip
% We define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots
% going forward ($\iddots$). We use |\ProvideDocumentCommand| and so, if the
% command |\iddots| has already been defined (for example by the package
% \pkg{mathdots}), we don't define it again.
%
% \begin{macrocode}
\ProvideDocumentCommand \iddots { }
{
\mathinner
{
\tex_mkern:D 1 mu
\box_move_up:nn { 1 pt } { \hbox:n { . } }
\tex_mkern:D 2 mu
\box_move_up:nn { 4 pt } { \hbox:n { . } }
\tex_mkern:D 2 mu
\box_move_up:nn { 7 pt }
{ \vbox:n { \kern 7 pt \hbox:n { . } } }
\tex_mkern:D 1 mu
}
}
% \end{macrocode}
%
% This definition is a variant of the standard definition of |\ddots|.
%
%
% \bigskip
% In the |aux| file, we will have the references of the PGF/Tikz nodes created
% by \pkg{nicematrix}. However, when \pkg{booktabs} is used, some nodes (more
% precisely, some |row| nodes) will be defined twice because their position will
% be modified. In order to avoid an error message in this case, we will redefine
% |\pgfutil@check@rerun| in the |aux| file.
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\@ifpackageloaded { booktabs }
{ \iow_now:Nn \@mainaux \nicematrix@redefine@check@rerun }
{ }
}
\cs_set_protected:Npn \nicematrix@redefine@check@rerun
{
\cs_set_eq:NN \@@_old_pgfutil@check@rerun \pgfutil@check@rerun
% \end{macrocode}
% The new version of |\pgfutil@check@rerun| will not check the PGF nodes whose
% names start with |nm-| (which is the prefix for the nodes created by
% \pkg{nicematrix}).
% \begin{macrocode}
\cs_set_protected:Npn \pgfutil@check@rerun ##1 ##2
{
\str_if_eq:eeF { nm- } { \tl_range:nnn { ##1 } 1 3 }
{ \@@_old_pgfutil@check@rerun { ##1 } { ##2 } }
}
}
% \end{macrocode}
%
% \bigskip
% We have to know whether \pkg{colortbl} is loaded in particular for the
% redefinition of |\everycr|.
% \begin{macrocode}
\bool_new:N \l_@@_colortbl_loaded_bool
\hook_gput_code:nnn { begindocument } { . }
{
\@ifpackageloaded { colortbl }
{ \bool_set_true:N \l_@@_colortbl_loaded_bool }
{
% \end{macrocode}
% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of
% the rules in the array. We will use it to store the instruction of color for
% the rules even if \pkg{colortbl} is not loaded.
% \begin{macrocode}
\cs_set_protected:Npn \CT@arc@ { }
\cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } }
\cs_set:Npn \CT@arc #1 #2
{
\dim_compare:nNnT \baselineskip = \c_zero_dim \noalign
{ \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } }
}
% \end{macrocode}
% Idem for |\CT@drs@|.
% \begin{macrocode}
\cs_set:Npn \doublerulesepcolor #1 # { \CT@drs { #1 } }
\cs_set:Npn\CT@drs #1 #2
{
\dim_compare:nNnT \baselineskip = \c_zero_dim \noalign
{ \cs_gset:Npn \CT@drsc@ { \color #1 { #2 } } }
}
\cs_set:Npn \hline
{
\noalign { \ifnum 0 = `} \fi
\cs_set_eq:NN \hskip \vskip
\cs_set_eq:NN \vrule \hrule
\cs_set_eq:NN \@width \@height
{ \CT@arc@ \vline }
\futurelet \reserved@a
\@xhline
}
}
}
% \end{macrocode}
%
% \bigskip
% We have to redefine |\cline| for several reasons. The command |\@@_cline| will
% be linked to |\cline| in the beginning of |{NiceArrayWithDelims}|. The
% following commands must \emph{not} be protected.
% \begin{macrocode}
\cs_set:Npn \@@_standard_cline #1 { \@@_standard_cline:w #1 \q_stop }
\cs_set:Npn \@@_standard_cline:w #1-#2 \q_stop
{
\int_compare:nNnT \l_@@_first_col_int = 0 { \omit & }
\int_compare:nNnT { #1 } > 1 { \multispan { \int_eval:n { #1 - 1 } } & }
\multispan { \int_eval:n { #2 - #1 + 1 } }
{
\CT@arc@
\leaders \hrule \@height \arrayrulewidth \hfill
% \end{macrocode}
% The following |\skip_horizontal:N \c_zero_dim| is to prevent a potential
% |\unskip| to delete the |\leaders|\footnote{See question 99041 on TeX
% StackExchange.}
% \begin{macrocode}
\skip_horizontal:N \c_zero_dim
}
% \end{macrocode}
% Our |\everycr| has been modified. In particular, the creation of the |row|
% node is in the |\everycr| (maybe we should put it with the incrementation of
% |\c@iRow|). Since the following |\cr| correspond to a ``false row'', we have
% to nullify |\everycr|.
% \begin{macrocode}
\everycr { }
\cr
\noalign { \skip_vertical:N -\arrayrulewidth }
}
% \end{macrocode}
%
% \bigskip
% The following version of |\cline| spreads the array of a quantity equal
% to |\arrayrulewidth| as does |\hline|. It will be loaded excepted if the key
% |standard-cline| has been used.
% \begin{macrocode}
\cs_set:Npn \@@_cline
% \end{macrocode}
% We have to act in a fully expandable way since there may be |\noalign| (in the
% |\multispan|) to detect. That's why we use |\@@_cline_i:en|.
% \begin{macrocode}
{ \@@_cline_i:en \l_@@_first_col_int }
% \end{macrocode}
% The command |\cline_i:nn| has two arguments. The first is the number of the
% current column (it \emph{must} be used in that column). The second is a
% standard argument of |\cline| of the form \textsl{i}-\textsl{j} or the form
% \textsl{i}.
% \begin{macrocode}
\cs_set:Npn \@@_cline_i:nn #1 #2 { \@@_cline_i:w #1|#2- \q_stop }
\cs_set:Npn \@@_cline_i:w #1|#2-#3 \q_stop
{
\tl_if_empty:nTF { #3 }
{ \@@_cline_iii:w #1|#2-#2 \q_stop }
{ \@@_cline_ii:w #1|#2-#3 \q_stop }
}
\cs_set:Npn \@@_cline_ii:w #1|#2-#3-\q_stop
{ \@@_cline_iii:w #1|#2-#3 \q_stop }
\cs_set:Npn \@@_cline_iii:w #1|#2-#3 \q_stop
{
% \end{macrocode}
% Now, |#1| is the number of the current column and we have to draw a line from
% the column |#2| to the column |#3| (both included).
% \begin{macrocode}
\int_compare:nNnT { #1 } < { #2 }
{ \multispan { \int_eval:n { #2 - #1 } } & }
\multispan { \int_eval:n { #3 - #2 + 1 } }
{
\CT@arc@
\leaders \hrule \@height \arrayrulewidth \hfill
\skip_horizontal:N \c_zero_dim
}
% \end{macrocode}
% You look whether there is another |\cline| to draw (the final user may put
% several |\cline|).
% \begin{macrocode}
\peek_meaning_remove_ignore_spaces:NTF \cline
{ & \@@_cline_i:en { \int_eval:n { #3 + 1 } } }
{ \everycr { } \cr }
}
\cs_generate_variant:Nn \@@_cline_i:nn { e n }
% \end{macrocode}
%
%
% \bigskip
% The following command is a small shortcut.
% \begin{macrocode}
\cs_new:Npn \@@_math_toggle_token:
{ \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_set_CT@arc@:
{ \peek_meaning:NTF [ \@@_set_CT@arc@_i: \@@_set_CT@arc@_ii: }
\cs_new_protected:Npn \@@_set_CT@arc@_i: [ #1 ] #2 \q_stop
{ \cs_set:Npn \CT@arc@ { \color [ #1 ] { #2 } } }
\cs_new_protected:Npn \@@_set_CT@arc@_ii: #1 \q_stop
{ \cs_set:Npn \CT@arc@ { \color { #1 } } }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_set_CT@drsc@:
{ \peek_meaning:NTF [ \@@_set_CT@drsc@_i: \@@_set_CT@drsc@_ii: }
\cs_new_protected:Npn \@@_set_CT@drsc@_i: [ #1 ] #2 \q_stop
{ \cs_set:Npn \CT@drsc@ { \color [ #1 ] { #2 } } }
\cs_new_protected:Npn \@@_set_CT@drsc@_ii: #1 \q_stop
{ \cs_set:Npn \CT@drsc@ { \color { #1 } } }
% \end{macrocode}
%
%
% \bigskip
% \begin{macrocode}
\cs_set_eq:NN \@@_old_pgfpointanchor \pgfpointanchor
% \end{macrocode}
%
% \bigskip
% \textbf{The column S of siunitx}\par\nobreak
%
% \medskip
% We want to know whether the package \pkg{siunitx} is loaded and, if it is
% loaded, we redefine the |S| columns of \pkg{siunitx}.
% \begin{macrocode}
\bool_new:N \l_@@_siunitx_loaded_bool
\hook_gput_code:nnn { begindocument } { . }
{
\@ifpackageloaded { siunitx }
{ \bool_set_true:N \l_@@_siunitx_loaded_bool }
{ }
}
% \end{macrocode}
%
%
%
% \bigskip
% The command |\@@_renew_NC@rewrite@S:| will be used in each environment of
% \pkg{nicematrix} in order to ``rewrite'' the |S| column in each environment.
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\bool_if:nTF { ! \l_@@_siunitx_loaded_bool }
{ \cs_set_eq:NN \@@_renew_NC@rewrite@S: \prg_do_nothing: }
{
\cs_new_protected:Npn \@@_renew_NC@rewrite@S:
{
\renewcommand*{\NC@rewrite@S}[1][]
{
% \end{macrocode}
% |\@temptokena| is a toks (not supported by the L3 programming layer).
% \begin{macrocode}
\@temptokena \exp_after:wN
{ \tex_the:D \@temptokena \@@_S: [ ##1 ] }
\NC@find
}
}
}
}
% \end{macrocode}
%
%
%
% \bigskip
% \subsection*{Parameters}
%
% \bigskip
% The following counter will count the environments |{NiceArray}|. The value of
% this counter will be used to prefix the names of the Tikz nodes created in the
% array.
% \begin{macrocode}
\int_new:N \g_@@_env_int
% \end{macrocode}
%
% \bigskip
% The following command is only a syntaxic shortcut. It must \emph{not} be
% protected (it will be used in names of \textsc{pgf} nodes).
% \begin{macrocode}
\cs_new:Npn \@@_env: { nm - \int_use:N \g_@@_env_int }
% \end{macrocode}
%
% \bigskip
% The command |\NiceMatrixLastEnv| is not used by the package \pkg{nicematrix}.
% It's only a facility given to the final user. It gives the number of the last
% environment (in fact the number of the current environment but it's meant to
% be used after the environment in order to refer to that environment --- and
% its nodes --- without having to give it a name). This command \emph{must} be
% expandable since it will be used in \pkg{pgf} nodes.
% \begin{macrocode}
\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
{ \int_use:N \g_@@_env_int }
% \end{macrocode}
%
%
% \bigskip
% The following command is only a syntaxic shortcut. The |q| in |qpoint| means
% \emph{quick}.
% \begin{macrocode}
\cs_new_protected:Npn \@@_qpoint:n #1
{ \pgfpointanchor { \@@_env: - #1 } { center } }
% \end{macrocode}
%
% \bigskip
% The following counter will count the environments |{NiceMatrixBlock}|.
% \begin{macrocode}
\int_new:N \g_@@_NiceMatrixBlock_int
% \end{macrocode}
%
% \bigskip
% The dimension |\l_@@_columns_width_dim| will be used when the options specify
% that all the columns must have the same width (but, if the key |columns-width|
% is used with the special value |auto|, the boolean
% |l_@@_auto_columns_width_bool| also will be raised).
% \begin{macrocode}
\dim_new:N \l_@@_columns_width_dim
% \end{macrocode}
%
% \bigskip
% The dimension |\l_@@_col_width_dim| will be available in each cell which
% belongs to a column of fixed width: |w{...}{...}|, |W{...}{...}|, |p{}|,
% |m{}|, |b{}| but also |X| (when the actual width of that column is known, that
% is to say after the first compilation). It's the width of that column. It will
% be used by some commands |\Block|. A non positive value means that the column
% has no fixed width (it's a column of type |c|, |r|, |l|, etc.).
% \begin{macrocode}
\dim_new:N \l_@@_col_width_dim
\dim_set:Nn \l_@@_col_width_dim { -1 cm }
% \end{macrocode}
%
%
% \bigskip
% The following counters will be used to count the numbers of rows and columns
% of the array.
% \begin{macrocode}
\int_new:N \g_@@_row_total_int
\int_new:N \g_@@_col_total_int
% \end{macrocode}
%
% \bigskip
% The following counter corresponds to the key |nb-rows| of the command
% |\RowStyle|.
% \begin{macrocode}
\int_new:N \l_@@_key_nb_rows_int
% \end{macrocode}
%
%
% \bigskip
% The following token list will contain the type of horizontal alignment of the
% current cell as provided by the corresponding column. The possible values are
% |r|, |l|, |c|. For exemple, a column |p[l]{3cm}| will provide the value |l|
% for all the cells of the column.
% \begin{macrocode}
\str_new:N \l_@@_hpos_cell_str
\str_set:Nn \l_@@_hpos_cell_str { c }
% \end{macrocode}
%
% \bigskip
% When there is a mono-column block (created by the command |\Block|), we want
% to take into account the width of that block for the width of the column.
% That's why we compute the width of that block in the |\g_@@_blocks_wd_dim|
% and, after the construction of the box |\l_@@_cell_box|, we change the width
% of that box to take into account the length |\g_@@_blocks_wd_dim|.
% \begin{macrocode}
\dim_new:N \g_@@_blocks_wd_dim
% \end{macrocode}
%
% \bigskip
% Idem pour the mono-row blocks.
% \begin{macrocode}
\dim_new:N \g_@@_blocks_ht_dim
\dim_new:N \g_@@_blocks_dp_dim
% \end{macrocode}
%
% \bigskip
% The following dimension correspond to the key |width| (which may be fixed in
% |\NiceMatrixOptions| but also in an environment |{NiceTabular}|).
% \begin{macrocode}
\dim_new:N \l_@@_width_dim
% \end{macrocode}
%
% \bigskip
% The sequence |\g_@@_names_seq| will be the list of all the names of
% environments used (via the option |name|) in the document: two environments
% must not have the same name. However, it's possible to use the option
% |allow-duplicate-names|.
% \begin{macrocode}
\seq_new:N \g_@@_names_seq
% \end{macrocode}
%
% \bigskip
% We want to know whether we are in an environment of \pkg{nicematrix} because we
% will raise an error if the user tries to use nested environments.
% \begin{macrocode}
\bool_new:N \l_@@_in_env_bool
% \end{macrocode}
%
% \bigskip
% The following key corresponds to the key |notes/detect_duplicates|.
% \begin{macrocode}
\bool_new:N \l_@@_notes_detect_duplicates_bool
\bool_set_true:N \l_@@_notes_detect_duplicates_bool
% \end{macrocode}
%
% \bigskip
% If the user uses |{NiceArray}| or |{NiceTabular}| the flag
% |\l_@@_NiceArray_bool| will be raised.
% \begin{macrocode}
\bool_new:N \l_@@_NiceArray_bool
% \end{macrocode}
% In fact, if there is delimiters in the preamble of |{NiceArray}| (eg:
% |[cccc]|), this boolean will be set to false.
%
% \bigskip
% If the user uses |{NiceTabular}| or |{NiceTabular*}|, we will raise the
% following flag.
% \begin{macrocode}
\bool_new:N \l_@@_NiceTabular_bool
% \end{macrocode}
%
% \bigskip
% If the user uses |{NiceTabular*}|, the width of the tabular (in the first
% argument of the environment |{NiceTabular*}|) will be stored in the following
% dimension.
% \begin{macrocode}
\dim_new:N \l_@@_tabular_width_dim
% \end{macrocode}
%
% \bigskip
% If the user uses an environment without preamble, we will raise the following
% flag.
% \begin{macrocode}
\bool_new:N \l_@@_Matrix_bool
% \end{macrocode}
%
% \bigskip
% The following boolean will be raised when the command |\rotate| is used.
% \begin{macrocode}
\bool_new:N \g_@@_rotate_bool
% \end{macrocode}
%
% \bigskip
% In a cell, it will be possible to know whether we are in a cell of a column of
% type |X| thanks to that flag.
% \begin{macrocode}
\bool_new:N \l_@@_X_column_bool
% \end{macrocode}
%
% \bigskip
% We will write in |\g_@@_aux_tl| all the instructions that we have to write on
% the |aux| file for the current environment. The contain of that token list
% will be written on the |aux| file at the end of the environment (in an
% instruction |\tl_gset:cn { c_@@_ \int_use:N \g_@@_env_int _ tl }|).
% \begin{macrocode}
\tl_new:N \g_@@_aux_tl
% \end{macrocode}
%
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_if_math_mode:
{
\if_mode_math: \else:
\@@_fatal:n { Outside~math~mode }
\fi:
}
% \end{macrocode}
%
% \bigskip
% The letter used for the vlines which will be drawn only in the sub-matrices.
% |vlism| stands for \emph{vertical lines in sub-matrices}.
% \begin{macrocode}
\tl_new:N \l_@@_letter_vlism_tl
% \end{macrocode}
%
% The list of the columns where vertical lines in sub-matrices (vlism) must be
% drawn. Of course, the actual value of this sequence will be known after the
% analyse of the preamble of the array.
% \begin{macrocode}
\seq_new:N \g_@@_cols_vlism_seq
% \end{macrocode}
%
% \bigskip
% The following colors will be used to memorize the color of the potential ``first
% col'' and the potential ``first row''.
% \begin{macrocode}
\colorlet { nicematrix-last-col } { . }
\colorlet { nicematrix-last-row } { . }
% \end{macrocode}
% \bigskip
% The following string is the name of the current environment or the current
% command of \pkg{nicematrix} (despite its name which contains \textsl{env}).
% \begin{macrocode}
\str_new:N \g_@@_name_env_str
% \end{macrocode}
%
% \bigskip
% The following string will contain the word \emph{command} or
% \emph{environment} whether we are in a command of \pkg{nicematrix} or in an
% environment of \pkg{nicematrix}. The default value is \emph{environment}.
% \begin{macrocode}
\tl_new:N \g_@@_com_or_env_str
\tl_gset:Nn \g_@@_com_or_env_str { environment }
% \end{macrocode}
%
% \bigskip
% The following command will be able to reconstruct the full name of the current
% command or environment (despite its name which contains \textsl{env}). This
% command must \emph{not} be protected since it will be used in error messages
% and we have to use |\str_if_eq:VnTF| and not |\tl_if_eq:NnTF| because we need
% to be fully expandable).
% \begin{macrocode}
\cs_new:Npn \@@_full_name_env:
{
\str_if_eq:VnTF \g_@@_com_or_env_str { command }
{ command \space \c_backslash_str \g_@@_name_env_str }
{ environment \space \{ \g_@@_name_env_str \} }
}
% \end{macrocode}
%
% \bigskip
% The following token list corresponds to the option |code-after| (it's also
% possible to set the value of that parameter with the keyword |\CodeAfter|).
% That parameter is \emph{public}.
% \begin{macrocode}
\tl_new:N \g_nicematrix_code_after_tl
% \end{macrocode}
%
% \bigskip
% For the key |code| of the command |\SubMatrix| (itself in the main
% |\CodeAfter|), we will use the following token list.
% \begin{macrocode}
\tl_new:N \l_@@_code_tl
% \end{macrocode}
%
% \bigskip
% The following token list has a function similar to
% |\g_nicematrix_code_after_tl| but it is used internally by \pkg{nicematrix}.
% In fact, we have to distinguish between |\g_nicematrix_code_after_tl| and
% |\g_@@_internal_code_after_tl| because we must take care of the order in which
% instructions stored in that parameters are executed.
% \begin{macrocode}
\tl_new:N \g_@@_internal_code_after_tl
% \end{macrocode}
%
% \bigskip
% The counters |\l_@@_old_iRow_int| and |\l_@@_old_jCol_int| will be used to
% save the values of the potential LaTeX counters |iRow| and |jCol|. These LaTeX
% counters will be restored at the end of the environment.
% \begin{macrocode}
\int_new:N \l_@@_old_iRow_int
\int_new:N \l_@@_old_jCol_int
% \end{macrocode}
% The TeX counters |\c@iRow| and |\c@jCol| will be created in the beginning of
% |{NiceArrayWithDelims}| (if they don't exist previously).
%
% \bigskip
% The following sequence will contain the names (without backslash) of the
% commands created by |custom-line| (commands used by the final user in order to
% draw horizontal rules).
% \begin{macrocode}
\seq_new:N \l_@@_custom_line_commands_seq
% \end{macrocode}
%
% \bigskip
% The following token list corresponds to the key |rules/color| available
% in the environments.
% \begin{macrocode}
\tl_new:N \l_@@_rules_color_tl
% \end{macrocode}
%
% \bigskip
% The sum of the weights of all the |X|-columns in the preamble. The weight of a
% |X|-column is given as optional argument between square brackets. The default
% value, of course, is $1$.
% \begin{macrocode}
\int_new:N \g_@@_total_X_weight_int
% \end{macrocode}
%
% If there is at least one |X|-column in the preamble of the array, the
% following flag will be raised via the |aux| file. The length
% |l_@@_x_columns_dim| will be the width of |X|-columns of weight $1$ (the width
% of a column of weigth $n$ will be that dimension multiplied by~$n$). That
% value is computed after the construction of the array during the first
% compilation in order to be used in the following run.
% \begin{macrocode}
\bool_new:N \l_@@_X_columns_aux_bool
\dim_new:N \l_@@_X_columns_dim
% \end{macrocode}
%
% \bigskip
% This boolean will be used only to detect in an expandable way whether we are
% at the beginning of the (potential) column zero, in order to raise an error if
% |\Hdotsfor| is used in that column.
% \begin{macrocode}
\bool_new:N \g_@@_after_col_zero_bool
% \end{macrocode}
%
% \bigskip
% A kind of false row will be inserted at the end of the array for the
% construction of the |col| nodes (and also to fix the width of the columns when
% |columns-width| is used). When this special row will be created, we will raise
% the flag |\g_@@_row_of_col_done_bool| in order to avoid some actions set in
% the redefinition of |\everycr| when the last |\cr| of the |\halign| will occur
% (after that row of |col| nodes).
% \begin{macrocode}
\bool_new:N \g_@@_row_of_col_done_bool
% \end{macrocode}
%
% \bigskip
% It's possible to use the command |\NotEmpty| to specify explicitely that a
% cell must be considered as non empty by \pkg{nicematrix} (the Tikz nodes are
% constructed only in the non empty cells).
% \begin{macrocode}
\bool_new:N \g_@@_not_empty_cell_bool
% \end{macrocode}
%
% \bigskip
% |\l_@@_code_before_tl| may contain two types of informations:
% \begin{itemize}
% \item A |code-before| written in the |aux| file by a previous run. When the
% |aux| file is read, this |code-before| is stored in
% |\g_@@_code_before_|\textsl{i}|_tl| (where \textsl{i} is the number of the
% environment) and, at the beginning of the environment, it will be put in
% |\l_@@_code_before_tl|.
% \item The final user can explicitly add material in |\l_@@_code_before_tl| by
% using the key |code-before| or the keyword |\CodeBefore| (with the keyword
% |\Body|).
% \end{itemize}
% \begin{macrocode}
\tl_new:N \l_@@_code_before_tl
\bool_new:N \l_@@_code_before_bool
% \end{macrocode}
%
% \bigskip
% The following token list will contain the code inserted in each cell of the
% current row (this token list will be cleared at the beginning of each row).
% \begin{macrocode}
\tl_new:N \g_@@_row_style_tl
% \end{macrocode}
%
% \bigskip
% The following dimensions will be used when drawing the dotted lines.
% \begin{macrocode}
\dim_new:N \l_@@_x_initial_dim
\dim_new:N \l_@@_y_initial_dim
\dim_new:N \l_@@_x_final_dim
\dim_new:N \l_@@_y_final_dim
% \end{macrocode}
%
% \bigskip
% The L3 programming layer provides scratch dimensions |\l_tmpa_dim| and
% |\l_tmpb_dim|. We creates two more in the same spirit.
% \begin{macrocode}
\dim_zero_new:N \l_@@_tmpc_dim
\dim_zero_new:N \l_@@_tmpd_dim
% \end{macrocode}
%
% \bigskip
% Some cells will be declared as ``empty'' (for example a cell with an
% instruction |\Cdots|).
% \begin{macrocode}
\bool_new:N \g_@@_empty_cell_bool
% \end{macrocode}
%
%
% \bigskip
% The following dimensions will be used internally to compute the width of the
% potential ``first column'' and ``last column''.
% \begin{macrocode}
\dim_new:N \g_@@_width_last_col_dim
\dim_new:N \g_@@_width_first_col_dim
% \end{macrocode}
%
% \bigskip
% The following sequence will contain the characteristics of the blocks of the
% array, specified by the command |\Block|. Each block is represented by 6
% components surrounded by curly braces:
%
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{options}|}{|\textsl{contents}|}|.
%
% The variable is global because it will be modified in the cells of the array.
% \begin{macrocode}
\seq_new:N \g_@@_blocks_seq
% \end{macrocode}
% We also manage a sequence of the \emph{positions} of the blocks. In that
% sequence, each block is represented by only five components:
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|%
% \textsl{name}|}|. A block with the key |hvlines| won't appear in that
% sequence (otherwise, the lines in that block would not be drawn!).
% \begin{macrocode}
\seq_new:N \g_@@_pos_of_blocks_seq
% \end{macrocode}
% In fact, this sequence will also contain the positions of the cells with a
% |\diagbox|. The sequence |\g_@@_pos_of_blocks_seq| will be used when we will
% draw the rules (which respect the blocks).
%
% \bigskip
% We will also manage a sequence for the positions of the dotted lines. These
% dotted lines are created in the array by |\Cdots|, |\Vdots|, |\Ddots|, etc.
% However, their positions, that is to say, their extremities, will be
% determined only after the construction of the array. In this sequence, each
% item contains five components:
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|%
% \textsl{name}|}|.
% \begin{macrocode}
\seq_new:N \g_@@_pos_of_xdots_seq
% \end{macrocode}
% The sequence |\g_@@_pos_of_xdots_seq| will be used when we will draw the rules
% required by the key |hvlines| (these rules won't be drawn within the virtual
% blocks corresponding to the dotted lines).
%
% \medskip
% The final user may decide to ``stroke'' a block (using, for example, the key
% |draw=red!15| when using the command |\Block|). In that case, the rules
% specified, for instance, by |hvlines| must not be drawn around the block.
% That's why we keep the information of all that stroken blocks in the following
% sequence.
% \begin{macrocode}
\seq_new:N \g_@@_pos_of_stroken_blocks_seq
% \end{macrocode}
%
%
% \medskip
% If the user has used the key |corners| (or the key |hvlines-except-corners|,
% even though that key is deprecated), all the cells which are in an (empty)
% corner will be stored in the following sequence.
% \begin{macrocode}
\seq_new:N \l_@@_corners_cells_seq
% \end{macrocode}
%
% \medskip
% The list of the names of the potential |\SubMatrix| in the |\CodeAfter| of an
% environment. Unfortunately, that list has to be global (we have to use it
% inside the group for the options of a given |\SubMatrix|).
% \begin{macrocode}
\seq_new:N \g_@@_submatrix_names_seq
% \end{macrocode}
%
% \medskip
% The following flag will be raised if the key |width| is used in an environment
% |{NiceTabular}| (not in a comamnd |\NiceMatrixOptions|). You use it to raise
% an error when this key is used while no column |X| is used.
% \begin{macrocode}
\bool_new:N \l_@@_width_used_bool
% \end{macrocode}
%
% \medskip
% The sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells
% of the array where a command |\multicolumn{|$n$|}{...}{...}| with $n>1$ is
% issued. In |\g_@@_multicolumn_sizes_seq|, the ``sizes'' (that is to say the
% values of $n$) correspondant will be stored. These lists will be used for the
% creation of the ``medium nodes'' (if they are created).
% \begin{macrocode}
\seq_new:N \g_@@_multicolumn_cells_seq
\seq_new:N \g_@@_multicolumn_sizes_seq
% \end{macrocode}
%
% \medskip
% The following counters will be used when searching the extremities of a dotted
% line (we need these counters because of the potential ``open'' lines in the
% |\SubMatrix|---the |\SubMatrix| in the |code-before|).
% \begin{macrocode}
\int_new:N \l_@@_row_min_int
\int_new:N \l_@@_row_max_int
\int_new:N \l_@@_col_min_int
\int_new:N \l_@@_col_max_int
% \end{macrocode}
%
% \medskip
% The following sequence will be used when the command |\SubMatrix| is used in
% the |\CodeBefore| (and not in the |\CodeAfter|). It will contain the position of
% all the sub-matrices specified in the |code-before|. Each sub-matrix is
% represented by an ``object'' of the forme |{|$i$|}{|$j$|}{|$k$|}{|$l$|}|
% where $i$ and $j$ are the number of row and column of the upper-left cell and
% $k$ and $l$ the number of row and column of the lower-right cell.
% \begin{macrocode}
\seq_new:N \g_@@_submatrix_seq
% \end{macrocode}
%
% \medskip
% We are able to determine the number of columns specified in the preamble (for
% the environments with explicit preamble of course and without the potential
% exterior columns).
% \begin{macrocode}
\int_new:N \g_@@_static_num_of_col_int
% \end{macrocode}
%
% \medskip
% The following parameters correspond to the keys |fill|, |draw|, |tikz|, |borders|,
% and |rounded-corners| of the command |\Block|.
% \begin{macrocode}
\tl_new:N \l_@@_fill_tl
\tl_new:N \l_@@_draw_tl
\seq_new:N \l_@@_tikz_seq
\clist_new:N \l_@@_borders_clist
\dim_new:N \l_@@_rounded_corners_dim
% \end{macrocode}
% The last parameter has no direct link with the [empty] corners of the array
% (which are computed and taken into account by \pkg{nicematrix} when the key
% |corners| is used).
%
% \medskip
% The following token list correspond to the key |color| of the command |\Block|.
% \begin{macrocode}
\tl_new:N \l_@@_color_tl
% \end{macrocode}
%
% \medskip
% Here is the dimension for the width of the rule when a block (created by
% |\Block|) is stroked.
% \begin{macrocode}
\dim_new:N \l_@@_line_width_dim
% \end{macrocode}
%
% \medskip
% The parameters of the horizontal position of the label of a block. If the user
% uses the key |c| or |C|, the value is |c|. If the user uses the key |l| or
% |L|, the value is |l|. If the user uses the key |r| or |R|, the value is |r|.
% If the user has used a capital letter, the boolean
% |\l_@@_hpos_of_block_cap_bool| will be raised (in the second pass of the
% analyze of the keys of the command |\Block|).
% \begin{macrocode}
\str_new:N \l_@@_hpos_block_str
\str_set:Nn \l_@@_hpos_block_str { c }
\bool_new:N \l_@@_hpos_of_block_cap_bool
% \end{macrocode}
%
% \medskip
% For the vertical position, the possible values are |c|, |t| and |b|. Of
% course, it would be interesting to program a key |T| and a key |B|.
% \begin{macrocode}
\tl_new:N \l_@@_vpos_of_block_tl
\tl_set:Nn \l_@@_vpos_of_block_tl { c }
% \end{macrocode}
%
%
% \medskip
% Used when the key |draw-first| is used for |\Ddots| or |\Iddots|.
% \begin{macrocode}
\bool_new:N \l_@@_draw_first_bool
% \end{macrocode}
%
%
% \medskip
% The following flag corresponds to the keys |vlines| and |hlines| of the
% command |\Block| (the key |hvlines| is the conjunction of both).
% \begin{macrocode}
\bool_new:N \l_@@_vlines_block_bool
\bool_new:N \l_@@_hlines_block_bool
% \end{macrocode}
%
%
% \medskip
% The blocks which use the key |-| will store their content in a box. These
% boxes are numbered with the following counter.
% \begin{macrocode}
\int_new:N \g_@@_block_box_int
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\dim_new:N \l_@@_submatrix_extra_height_dim
\dim_new:N \l_@@_submatrix_left_xshift_dim
\dim_new:N \l_@@_submatrix_right_xshift_dim
\clist_new:N \l_@@_hlines_clist
\clist_new:N \l_@@_vlines_clist
\clist_new:N \l_@@_submatrix_hlines_clist
\clist_new:N \l_@@_submatrix_vlines_clist
% \end{macrocode}
%
%
% \bigskip
% The following flag will be used by (for instance) |\@@_vline_ii:|.
% When |\l_@@_dotted_bool| is |true|, a dotted line (with our system) will be drawn.
% \begin{macrocode}
\bool_new:N \l_@@_dotted_bool
% \end{macrocode}
%
%
% \bigskip
% \textbf{Variables for the exterior rows and columns}\par\nobreak
%
% \medskip
% The keys for the exterior rows and columns are |first-row|, |first-col|,
% |last-row| and |last-col|. However, internally, these keys are not coded in a
% similar way.
%
% \bigskip
% \begin{itemize}
% \item \textbf{First row}\par\nobreak
% The integer |\l_@@_first_row_int| is the number of the first row of the
% array. The default value is $1$, but, if the option |first-row| is used,
% the value will be~$0$.
% \begin{macrocode}
\int_new:N \l_@@_first_row_int
\int_set:Nn \l_@@_first_row_int 1
% \end{macrocode}
%
% \medskip
% \item \textbf{First column}\par\nobreak
% The integer |\l_@@_first_col_int| is the number of the first column of the
% array. The default value is $1$, but, if the option |first-col| is used,
% the value will be~$0$.
% \begin{macrocode}
\int_new:N \l_@@_first_col_int
\int_set:Nn \l_@@_first_col_int 1
% \end{macrocode}
%
% \medskip
% \item \textbf{Last row}\par\nobreak
% The counter |\l_@@_last_row_int| is the number of the potential ``last row'',
% as specified by the key |last-row|. A value of $-2$ means that there is no
% ``last row''. A value of $-1$ means that there is a ``last row'' but we don't
% know the number of that row (the key |last-row| has been used without value
% and the actual value has not still been read in the |aux| file).
% \begin{macrocode}
\int_new:N \l_@@_last_row_int
\int_set:Nn \l_@@_last_row_int { -2 }
% \end{macrocode}
%
% \smallskip
% If, in an environment like |{pNiceArray}|, the option |last-row| is used
% without value, we will globally raise the following flag. It will be used to
% know if we have, after the construction of the array, to write in the |aux|
% file the number of the ``last row''.\footnote{We can't use
% |\l_@@_last_row_int| for this usage because, if \pkg{nicematrix} has read its
% value from the |aux| file, the value of the counter won't be $-1$ any longer.}
% \begin{macrocode}
\bool_new:N \l_@@_last_row_without_value_bool
% \end{macrocode}
%
% \smallskip
% Idem for |\l_@@_last_col_without_value_bool|
% \begin{macrocode}
\bool_new:N \l_@@_last_col_without_value_bool
% \end{macrocode}
%
% \medskip
% \item \textbf{Last column}\par\nobreak
%
% For the potential ``last column'', we use an integer. A value of $-2$ means
% that there is no last column. A value of $-1$ means that we are in an
% environment without preamble (e.g. |{bNiceMatrix}|) and there is a last column
% but we don't know its value because the user has used the option |last-col|
% without value. A value of $0$ means that the option |last-col| has been used
% in an environment with preamble (like |{pNiceArray}|): in this case, the key
% was necessary without argument.
% \begin{macrocode}
\int_new:N \l_@@_last_col_int
\int_set:Nn \l_@@_last_col_int { -2 }
% \end{macrocode}
%
% However, we have also a boolean. Consider the following code:
% \begin{center}
% \begin{BVerbatim}
% \begin{pNiceArray}{cc}[last-col]
% 1 & 2 \\
% 3 & 4
% \end{pNiceArray}
% \end{BVerbatim}
% \end{center}
% In such a code, the ``last column'' specified by the key |last-col| is not
% used. We want to be able to detect such a situation and we create a boolean
% for that job.
% \begin{macrocode}
\bool_new:N \g_@@_last_col_found_bool
% \end{macrocode}
% This boolean is set to |false| at the end of |\@@_pre_array_ii:|.
% \end{itemize}
%
% \bigskip
% \textbf{Some utilities}
%
% \begin{macrocode}
\cs_set_protected:Npn \@@_cut_on_hyphen:w #1-#2\q_stop
{
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_set:Nn \l_tmpb_tl { #2 }
}
% \end{macrocode}
%
%
% The following takes as argument the name of a |clist| and which should be a
% list of intervals of integers. It \emph{expands} that list, that is to say,
% it replaces (by a sort of |mapcan| or |flat_map|) the interval by the explicit
% list of the integers.
% \begin{macrocode}
\cs_new_protected:Npn \@@_expand_clist:N #1
{
\clist_if_in:NnF #1 { all }
{
\clist_clear:N \l_tmpa_clist
\clist_map_inline:Nn #1
{
\tl_if_in:nnTF { ##1 } { - }
{ \@@_cut_on_hyphen:w ##1 \q_stop }
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_set:Nn \l_tmpb_tl { ##1 }
}
\int_step_inline:nnn { \l_tmpa_tl } { \l_tmpb_tl }
{ \clist_put_right:Nn \l_tmpa_clist { ####1 } }
}
\tl_set_eq:NN #1 \l_tmpa_clist
}
}
% \end{macrocode}
%
% \bigskip
% \subsection*{The command \textbackslash tabularnote}
%
% \bigskip
% The LaTeX counter |tabularnote| will be used to count the tabular notes during
% the construction of the array (this counter won't be used during the
% composition of the notes at the end of the array). You use a LaTeX counter
% because we will use |\refstepcounter| in order to have the tabular notes
% referenceable.
% \begin{macrocode}
\newcounter { tabularnote }
% \end{macrocode}
%
% \bigskip
% We will store in the following sequence the tabular notes of a given array.
% \begin{macrocode}
\seq_new:N \g_@@_tabularnotes_seq
% \end{macrocode}
%
% \bigskip
% However, before the actual tabular notes, it's possible to put a text
% specified by the key |tabularnote| of the environment. The token list
% |\l_@@_tabularnote_tl| corresponds to the value of that key.
% \begin{macrocode}
\tl_new:N \l_@@_tabularnote_tl
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\seq_new:N \l_@@_notes_labels_seq
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\newcounter{nicematrix_draft}
\cs_new_protected:Npn \@@_notes_format:n #1
{
\setcounter { nicematrix_draft } { #1 }
\@@_notes_style:n { nicematrix_draft }
}
% \end{macrocode}
%
% \bigskip
% The following function can be redefined by using the key |notes/style|.
% \begin{macrocode}
\cs_new:Npn \@@_notes_style:n #1 { \textit { \alph { #1 } } }
% \end{macrocode}
%
% \bigskip
% The following fonction can be redefined by using the key
% |notes/label-in-tabular|.
% \begin{macrocode}
\cs_new:Npn \@@_notes_label_in_tabular:n #1 { \textsuperscript { #1 } }
% \end{macrocode}
%
% \bigskip
% The following function can be redefined by using the key |notes/label-in-list|.
% \begin{macrocode}
\cs_new:Npn \@@_notes_label_in_list:n #1 { \textsuperscript { #1 } }
% \end{macrocode}
%
% \bigskip
% We define |\thetabularnote| because it will be used by LaTeX if the user want
% to reference a footnote which has been marked by a |\label|. The TeX group is
% for the case where the user has put an instruction such as |\color{red}| in
% |\@@_notes_style:n|.
% \begin{macrocode}
\cs_set:Npn \thetabularnote { { \@@_notes_style:n { tabularnote } } }
% \end{macrocode}
%
% \bigskip
% The tabular notes will be available for the final user only when
% \pkg{enumitem} is loaded. Indeed, the tabular notes will be composed at the end
% of the array with a list customized by \pkg{enumitem} (a list |tabularnotes|
% in the general case and a list |tabularnotes*| if the key |para| is in force).
% However, we can test whether \pkg{enumitem} has been loaded only at the
% beginning of the document (we want to allow the user to load \pkg{enumitem}
% after \pkg{nicematrix}).
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\bool_if:nTF { ! \c_@@_enumitem_loaded_bool }
{
\NewDocumentCommand \tabularnote { m }
{ \@@_error:n { enumitem~not~loaded } }
}
{
% \end{macrocode}
% The type of list |tabularnotes| will be used to format the tabular notes at
% the end of the array in the general case and |tabularnotes*| will be used if
% the key |para| is in force.
% \begin{macrocode}
\newlist { tabularnotes } { enumerate } { 1 }
\setlist [ tabularnotes ]
{
topsep = 0pt ,
noitemsep ,
leftmargin = * ,
align = left ,
labelsep = 0pt ,
label =
\@@_notes_label_in_list:n { \@@_notes_style:n { tabularnotesi } } ,
}
\newlist { tabularnotes* } { enumerate* } { 1 }
\setlist [ tabularnotes* ]
{
afterlabel = \nobreak ,
itemjoin = \quad ,
label =
\@@_notes_label_in_list:n { \@@_notes_style:n { tabularnotes*i } }
}
% \end{macrocode}
%
% \medskip
% The command |\tabularnote| is available in the whole document (and not only in
% the environments of \pkg{nicematrix}) because we want it to be available in
% the caption of a |{table}| (before the following |{NiceTabular}| or
% |{NiceArray}|). That's also the reason why the variables |\c@tabularnote| and
% |\g_@@_tabularnotes_seq| will be cleared at the end of the environment of
% \pkg{nicematrix} (and not at the beginning).
%
% Unfortunately, if the package \pkg{caption} is loaded, the command |\caption|
% evaluates its argument twice and since it is not aware (of course) of
% |\tabularnote|, the command |\tabularnote| is, in fact, not usable in
% |\caption| when \pkg{caption} is loaded.\footnote{We should try to find a
% solution to that problem.}
% \begin{macrocode}
\NewDocumentCommand \tabularnote { m }
{
\bool_if:nTF { ! \l_@@_NiceArray_bool && \l_@@_in_env_bool }
{ \@@_error:n { tabularnote~forbidden } }
{
% \end{macrocode}
% You have to see whether the argument of |\tabularnote| has yet been used as
% argument of another |\tabularnote| in the same tabular. In that case, there
% will be only one note (for both commands |\tabularnote|) at the end of the
% tabular. We search the argument of our command |\tabularnote| in the
% |\g_@@_tabularnotes_seq|. The position in the sequence will be stored in
% |\l_tmpa_int| (0 if the text is not in the sequence yet).
% \begin{macrocode}
\int_zero:N \l_tmpa_int
\bool_if:NT \l_@@_notes_detect_duplicates_bool
{
\seq_map_indexed_inline:Nn \g_@@_tabularnotes_seq
{
\tl_if_eq:nnT { #1 } { ##2 }
{ \int_set:Nn \l_tmpa_int { ##1 } \seq_map_break: }
}
}
\int_compare:nNnTF \l_tmpa_int = 0
{
\stepcounter { tabularnote }
\seq_put_right:Nx \l_@@_notes_labels_seq
{ \@@_notes_format:n { \int_use:c { c @ tabularnote } } }
\seq_gput_right:Nn \g_@@_tabularnotes_seq { #1 }
}
{
\seq_put_right:Nx \l_@@_notes_labels_seq
{ \@@_notes_format:n { \int_use:N \l_tmpa_int } }
}
\peek_meaning:NF \tabularnote
{
% \end{macrocode}
% If the following token is \emph{not} a |\tabularnote|, we have finished the
% sequence of successive commands |\tabularnote| and we have to format the
% labels of these tabular notes (in the array). We compose those labels in a box
% |\l_tmpa_box| because we will do a special construction in order to have this
% box in a overlapping position if we are at the end of a cell.
% \begin{macrocode}
\hbox_set:Nn \l_tmpa_box
{
% \end{macrocode}
% We remind that it is the command |\@@_notes_label_in_tabular:n| that will
% (most of the time) put the labels in a |\textsuperscript|.
% \begin{macrocode}
\@@_notes_label_in_tabular:n
{
\seq_use:Nnnn
\l_@@_notes_labels_seq { , } { , } { , }
}
}
% \end{macrocode}
% We use |\refstepcounter| in order to have the (last) tabular note referenceable
% (with the standard command |\label|) and that's why we have to go back with a
% decrementation of the counter |tabularnote| first.
% \begin{macrocode}
\addtocounter { tabularnote } { -1 }
\refstepcounter { tabularnote }
\seq_clear:N \l_@@_notes_labels_seq
\hbox_overlap_right:n { \box_use:N \l_tmpa_box }
% \end{macrocode}
% If the command |\tabularnote| is used exactly at the end of the cell, the
% |\unskip| (inserted by \pkg{array}?) will delete the skip we insert now
% and the label of the footnote will be composed in an overlapping position (by
% design).
% \begin{macrocode}
\skip_horizontal:n { \box_wd:N \l_tmpa_box }
}
}
}
}
}
% \end{macrocode}
%
%
%
% \subsection*{Command for creation of rectangle nodes}
%
% The following command should be used in a |{pgfpicture}|. It creates a
% rectangle (empty but with a name).
%
% |#1| is the name of the node which will be created;
% |#2| and |#3| are the coordinates of one of the corner of the rectangle;
% |#4| and |#5| are the coordinates of the opposite corner.
% \begin{macrocode}
\cs_new_protected:Npn \@@_pgf_rect_node:nnnnn #1 #2 #3 #4 #5
{
\begin { pgfscope }
\pgfset
{
outer~sep = \c_zero_dim ,
inner~sep = \c_zero_dim ,
minimum~size = \c_zero_dim
}
\pgftransformshift { \pgfpoint { 0.5 * ( #2 + #4 ) } { 0.5 * ( #3 + #5 ) } }
\pgfnode
{ rectangle }
{ center }
{
\vbox_to_ht:nn
{ \dim_abs:n { #5 - #3 } }
{
\vfill
\hbox_to_wd:nn { \dim_abs:n { #4 - #2 } } { }
}
}
{ #1 }
{ }
\end { pgfscope }
}
% \end{macrocode}
%
% \medskip
% The command |\@@_pgf_rect_node:nnn| is a variant of |\@@_pgf_rect_node:nnnnn|:
% it takes two \textsc{pgf} points as arguments instead of the four dimensions
% which are the coordinates.
% \begin{macrocode}
\cs_new_protected:Npn \@@_pgf_rect_node:nnn #1 #2 #3
{
\begin { pgfscope }
\pgfset
{
outer~sep = \c_zero_dim ,
inner~sep = \c_zero_dim ,
minimum~size = \c_zero_dim
}
\pgftransformshift { \pgfpointscale { 0.5 } { \pgfpointadd { #2 } { #3 } } }
\pgfpointdiff { #3 } { #2 }
\pgfgetlastxy \l_tmpa_dim \l_tmpb_dim
\pgfnode
{ rectangle }
{ center }
{
\vbox_to_ht:nn
{ \dim_abs:n \l_tmpb_dim }
{ \vfill \hbox_to_wd:nn { \dim_abs:n \l_tmpa_dim } { } }
}
{ #1 }
{ }
\end { pgfscope }
}
% \end{macrocode}
%
%
% \bigskip
% \subsection*{The options}
%
% By default, the commands |\cellcolor| and |\rowcolor| are available for the
% user in the cells of the tabular (the user may use the commands provided by
% |\colortbl|). However, if the key |colortbl-like| is used, these
% commands are available.
% \begin{macrocode}
\bool_new:N \l_@@_colortbl_like_bool
% \end{macrocode}
%
% \bigskip
% By default, the behaviour of |\cline| is changed in the environments of
% \pkg{nicematrix}: a |\cline| spreads the array by an amount equal to
% |\arrayrulewidht|. It's possible to disable this feature with the key
% |\l_@@_standard_line_bool|.
% \begin{macrocode}
\bool_new:N \l_@@_standard_cline_bool
% \end{macrocode}
%
% \bigskip
% The following dimensions correspond to the options |cell-space-top-limit| and co
% (these parameters are inspired by the package \pkg{cellspace}).
% \begin{macrocode}
\dim_new:N \l_@@_cell_space_top_limit_dim
\dim_new:N \l_@@_cell_space_bottom_limit_dim
% \end{macrocode}
%
% \bigskip
% The following dimension is the distance between two dots for the dotted lines
% (when |line-style| is equal to |standard|, which is the initial value). The
% initial value is 0.45~em but it will be changed if the option |small| is used.
% \begin{macrocode}
\dim_new:N \l_@@_inter_dots_dim
\hook_gput_code:nnn { begindocument } { . }
{ \dim_set:Nn \l_@@_inter_dots_dim { 0.45 em } }
% \end{macrocode}
% We use a hook only by security in case \cls{revtex4-1}
% is used (even though it is obsolete).
%
% \bigskip
% The following dimension is the minimal distance between a node (in fact an
% anchor of that node) and a dotted line (we say ``minimal'' because, by
% definition, a dotted line is not a continuous line and, therefore, this
% distance may vary a little).
% \begin{macrocode}
\dim_new:N \l_@@_xdots_shorten_dim
\hook_gput_code:nnn { begindocument } { . }
{ \dim_set:Nn \l_@@_xdots_shorten_dim { 0.3 em } }
% \end{macrocode}
% We use a hook only by security in case \cls{revtex4-1} is used (even though it
% is obsolete).
%
% \bigskip
% The following dimension is the radius of the dots for the dotted lines (when
% |line-style| is equal to |standard|, which is the initial value). The initial
% value is 0.53~pt but it will be changed if the option |small| is used.
% \begin{macrocode}
\dim_new:N \l_@@_radius_dim
\hook_gput_code:nnn { begindocument } { . }
{ \dim_set:Nn \l_@@_radius_dim { 0.53 pt } }
% \end{macrocode}
% We use a hook only by security in case \cls{revtex4-1} is used (even though it
% is obsolete).
%
%
% \bigskip
% The token list |\l_@@_xdots_line_style_tl| corresponds to the option |tikz| of the
% commands |\Cdots|, |\Ldots|, etc. and of the options |line-style| for the
% environments and |\NiceMatrixOptions|. The constant |\c_@@_standard_tl| will
% be used in some tests.
% \begin{macrocode}
\tl_new:N \l_@@_xdots_line_style_tl
\tl_const:Nn \c_@@_standard_tl { standard }
\tl_set_eq:NN \l_@@_xdots_line_style_tl \c_@@_standard_tl
% \end{macrocode}
%
% \bigskip
% The boolean |\l_@@_light_syntax_bool| corresponds to the option |light-syntax|.
% \begin{macrocode}
\bool_new:N \l_@@_light_syntax_bool
% \end{macrocode}
%
% \bigskip
% The string |\l_@@_baseline_tl| may contain one of the three values |t|,
% |c| or |b| as in the option of the environment |{array}|. However, it may also
% contain an integer (which represents the number of the row to which align the
% array).
% \begin{macrocode}
\tl_new:N \l_@@_baseline_tl
\tl_set:Nn \l_@@_baseline_tl c
% \end{macrocode}
%
% \bigskip
% The flag |\l_@@_exterior_arraycolsep_bool| corresponds to the option
% |exterior-arraycolsep|. If this option is set, a space equal to |\arraycolsep|
% will be put on both sides of an environment |{NiceArray}| (as it is done in
% |{array}| of \pkg{array}).
% \begin{macrocode}
\bool_new:N \l_@@_exterior_arraycolsep_bool
% \end{macrocode}
%
% \bigskip
% The flag |\l_@@_parallelize_diags_bool| controls whether the diagonals are
% parallelized. The initial value is~|true|.
% \begin{macrocode}
\bool_new:N \l_@@_parallelize_diags_bool
\bool_set_true:N \l_@@_parallelize_diags_bool
% \end{macrocode}
%
% \bigskip
% The following parameter correspond to the key |corners|. The elements of that
% |clist| must be in |NW|, |SW|, |NE| and |SE|.
% \begin{macrocode}
\clist_new:N \l_@@_corners_clist
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\dim_new:N \l_@@_notes_above_space_dim
\hook_gput_code:nnn { begindocument } { . }
{ \dim_set:Nn \l_@@_notes_above_space_dim { 1 mm } }
% \end{macrocode}
% We use a hook only by security in case \cls{revtex4-1} is used (even though it
% is obsolete).
%
% \bigskip
% The flag |\l_@@_nullify_dots_bool| corresponds to the option |nullify-dots|.
% When the flag is down, the instructions like |\vdots| are inserted within a
% |\hphantom| (and so the constructed matrix has exactly the same size as a
% matrix constructed with the classical |{matrix}| and |\ldots|, |\vdots|,
% etc.).
% \begin{macrocode}
\bool_new:N \l_@@_nullify_dots_bool
% \end{macrocode}
%
% \medskip
% The following flag corresponds to the key |respect-arraystretch| (that key has
% an effect on the blocks).
% \begin{macrocode}
\bool_new:N \l_@@_respect_arraystretch_bool
% \end{macrocode}
%
%
% \bigskip
% The following flag will be used when the current options specify that all the
% columns of the array must have the same width equal to the largest width of a
% cell of the array (except the cells of the potential exterior columns).
% \begin{macrocode}
\bool_new:N \l_@@_auto_columns_width_bool
% \end{macrocode}
%
% \bigskip
% The following boolean corresponds to the key |create-cell-nodes| of the
% keyword |\CodeBefore|.
% \begin{macrocode}
\bool_new:N \g_@@_recreate_cell_nodes_bool
% \end{macrocode}
%
% \bigskip
% The string |\l_@@_name_str| will contain the optional name of the
% environment: this name can be used to access to the Tikz nodes created in the
% array from outside the environment.
% \begin{macrocode}
\str_new:N \l_@@_name_str
% \end{macrocode}
%
% \bigskip
% The boolean |\l_@@_medium_nodes_bool| will be used to indicate whether the
% ``medium nodes'' are created in the array. Idem for the ``large nodes''.
% \begin{macrocode}
\bool_new:N \l_@@_medium_nodes_bool
\bool_new:N \l_@@_large_nodes_bool
% \end{macrocode}
%
% \bigskip
% The boolean |\l_@@_except_borders_bool| will be raised when the key
% |hvlines-except-borders| will be used (but that key has also other effects).
% \begin{macrocode}
\bool_new:N \l_@@_except_borders_bool
% \end{macrocode}
%
%
% \bigskip
% The dimension |\l_@@_left_margin_dim| correspond to the option |left-margin|.
% Idem for the right margin. These parameters are involved in the creation of
% the ``medium nodes'' but also in the placement of the delimiters and the
% drawing of the horizontal dotted lines (|\hdottedline|).
% \begin{macrocode}
\dim_new:N \l_@@_left_margin_dim
\dim_new:N \l_@@_right_margin_dim
% \end{macrocode}
%
%
% \bigskip
% The dimensions |\l_@@_extra_left_margin_dim| and
% |\l_@@_extra_right_margin_dim| correspond to the options |extra-left-margin|
% and |extra-right-margin|.
% \begin{macrocode}
\dim_new:N \l_@@_extra_left_margin_dim
\dim_new:N \l_@@_extra_right_margin_dim
% \end{macrocode}
%
% \medskip
% The token list |\l_@@_end_of_row_tl| corresponds to the option |end-of-row|.
% It specifies the symbol used to mark the ends of rows when the light syntax is
% used.
% \begin{macrocode}
\tl_new:N \l_@@_end_of_row_tl
\tl_set:Nn \l_@@_end_of_row_tl { ; }
% \end{macrocode}
%
% \medskip
% The following parameter is for the color the dotted lines drawn by |\Cdots|,
% |\Ldots|, |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor| but \emph{not} the
% dotted lines drawn by |\hdottedline| and ``|:|''.
% \begin{macrocode}
\tl_new:N \l_@@_xdots_color_tl
% \end{macrocode}
%
% \bigskip
% The following token list corresponds to the key |delimiters/color|.
% \begin{macrocode}
\tl_new:N \l_@@_delimiters_color_tl
% \end{macrocode}
%
% \bigskip
% Sometimes, we want to have several arrays vertically juxtaposed in order to
% have an alignment of the columns of these arrays. To acheive this goal, one
% may wish to use the same width for all the columns (for example with the
% option |columns-width| or the option |auto-columns-width| of the environment
% |{NiceMatrixBlock}|). However, even if we use the same type of delimiters, the
% width of the delimiters may be different from an array to another because the
% width of the delimiter is fonction of its size. That's why we create an option
% called |delimiters/max-width| which will give to the delimiters the width of
% a delimiter (of the same type) of big size. The following boolean corresponds
% to this option.
% \begin{macrocode}
\bool_new:N \l_@@_delimiters_max_width_bool
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / xdots }
{
line-style .code:n =
{
\bool_lazy_or:nnTF
% \end{macrocode}
% We can't use |\c_@@_tikz_loaded_bool| to test whether \pkg{tikz} is loaded
% because |\NiceMatrixOptions| may be used in the preamble of the document.
% \begin{macrocode}
{ \cs_if_exist_p:N \tikzpicture }
{ \str_if_eq_p:nn { #1 } { standard } }
{ \tl_set:Nn \l_@@_xdots_line_style_tl { #1 } }
{ \@@_error:n { bad~option~for~line-style } }
} ,
line-style .value_required:n = true ,
color .tl_set:N = \l_@@_xdots_color_tl ,
color .value_required:n = true ,
shorten .code:n =
\hook_gput_code:nnn { begindocument } { . }
{ \dim_set:Nn \l_@@_xdots_shorten_dim { #1 } } ,
% \end{macrocode}
% We use a hook only by security in case \cls{revtex4-1}
% is used (even though it is obsolete).
% \begin{macrocode}
shorten .value_required:n = true ,
% \end{macrocode}
% The options |down| and |up| are not documented for the final user because he
% should use the syntax with |^| and |_|.
% \begin{macrocode}
down .tl_set:N = \l_@@_xdots_down_tl ,
up .tl_set:N = \l_@@_xdots_up_tl ,
% \end{macrocode}
% The key |draw-first|, which is meant to be used only with |\Ddots| and
% |\Iddots|, which be catched when |\Ddots| or |\Iddots| is used (during the
% construction of the array and not when we draw the dotted lines).
% \begin{macrocode}
draw-first .code:n = \prg_do_nothing: ,
unknown .code:n = \@@_error:n { Unknown~key~for~xdots }
}
% \end{macrocode}
%
%
% \bigskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / rules }
{
color .tl_set:N = \l_@@_rules_color_tl ,
color .value_required:n = true ,
width .dim_set:N = \arrayrulewidth ,
width .value_required:n = true
}
% \end{macrocode}
%
%
% \bigskip
% First, we define a set of keys ``|NiceMatrix / Global|'' which will be used
% (with the mechanism of |.inherit:n|) by other sets of keys.
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Global }
{
custom-line .code:n = \@@_custom_line:n { #1 } ,
delimiters .code:n = \keys_set:nn { NiceMatrix / delimiters } { #1 } ,
delimiters .value_required:n = true ,
rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
rules .value_required:n = true ,
standard-cline .bool_set:N = \l_@@_standard_cline_bool ,
standard-cline .default:n = true ,
cell-space-top-limit .dim_set:N = \l_@@_cell_space_top_limit_dim ,
cell-space-top-limit .value_required:n = true ,
cell-space-bottom-limit .dim_set:N = \l_@@_cell_space_bottom_limit_dim ,
cell-space-bottom-limit .value_required:n = true ,
cell-space-limits .meta:n =
{
cell-space-top-limit = #1 ,
cell-space-bottom-limit = #1 ,
} ,
cell-space-limits .value_required:n = true ,
xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } ,
light-syntax .bool_set:N = \l_@@_light_syntax_bool ,
light-syntax .default:n = true ,
end-of-row .tl_set:N = \l_@@_end_of_row_tl ,
end-of-row .value_required:n = true ,
first-col .code:n = \int_zero:N \l_@@_first_col_int ,
first-row .code:n = \int_zero:N \l_@@_first_row_int ,
last-row .int_set:N = \l_@@_last_row_int ,
last-row .default:n = -1 ,
code-for-first-col .tl_set:N = \l_@@_code_for_first_col_tl ,
code-for-first-col .value_required:n = true ,
code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl ,
code-for-last-col .value_required:n = true ,
code-for-first-row .tl_set:N = \l_@@_code_for_first_row_tl ,
code-for-first-row .value_required:n = true ,
code-for-last-row .tl_set:N = \l_@@_code_for_last_row_tl ,
code-for-last-row .value_required:n = true ,
hlines .clist_set:N = \l_@@_hlines_clist ,
vlines .clist_set:N = \l_@@_vlines_clist ,
hlines .default:n = all ,
vlines .default:n = all ,
vlines-in-sub-matrix .code:n =
{
\tl_if_single_token:nTF { #1 }
{ \tl_set:Nn \l_@@_letter_vlism_tl { #1 } }
{ \@@_error:n { One~letter~allowed } }
} ,
vlines-in-sub-matrix .value_required:n = true ,
hvlines .code:n =
{
\clist_set:Nn \l_@@_vlines_clist { all }
\clist_set:Nn \l_@@_hlines_clist { all }
} ,
hvlines-except-borders .code:n =
{
\clist_set:Nn \l_@@_vlines_clist { all }
\clist_set:Nn \l_@@_hlines_clist { all }
\bool_set_true:N \l_@@_except_borders_bool
} ,
parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool ,
% \end{macrocode}
%
% \bigskip
% With the option |renew-dots|, the command |\cdots|, |\ldots|, |\vdots|,
% |\ddots|, etc. are redefined and behave like the commands |\Cdots|, |\Ldots|,
% |\Vdots|, |\Ddots|, etc.
% \begin{macrocode}
renew-dots .bool_set:N = \l_@@_renew_dots_bool ,
renew-dots .value_forbidden:n = true ,
nullify-dots .bool_set:N = \l_@@_nullify_dots_bool ,
create-medium-nodes .bool_set:N = \l_@@_medium_nodes_bool ,
create-large-nodes .bool_set:N = \l_@@_large_nodes_bool ,
create-extra-nodes .meta:n =
{ create-medium-nodes , create-large-nodes } ,
left-margin .dim_set:N = \l_@@_left_margin_dim ,
left-margin .default:n = \arraycolsep ,
right-margin .dim_set:N = \l_@@_right_margin_dim ,
right-margin .default:n = \arraycolsep ,
margin .meta:n = { left-margin = #1 , right-margin = #1 } ,
margin .default:n = \arraycolsep ,
extra-left-margin .dim_set:N = \l_@@_extra_left_margin_dim ,
extra-right-margin .dim_set:N = \l_@@_extra_right_margin_dim ,
extra-margin .meta:n =
{ extra-left-margin = #1 , extra-right-margin = #1 } ,
extra-margin .value_required:n = true ,
respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
respect-arraystretch .default:n = true
}
% \end{macrocode}
%
% \bigskip
% We define a set of keys used by the environments of \pkg{nicematrix} (but not
% by the command |\NiceMatrixOptions|).
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Env }
{
% \end{macrocode}
% The key |hvlines-except-corners| is now deprecated (use |hvlines| and
% |corners| instead).
% \begin{macrocode}
hvlines-except-corners .code:n =
{
\@@_error:n { hvlines-except-corners }
\group_begin:
\globaldefs = 1
\@@_msg_redirect_name:nn { hvlines-except-corners } { none }
\group_end:
\clist_set:Nn \l_@@_corners_clist { #1 }
\clist_set:Nn \l_@@_vlines_clist { all }
\clist_set:Nn \l_@@_hlines_clist { all }
} ,
hvlines-except-corners .default:n = { NW , SW , NE , SE } ,
corners .clist_set:N = \l_@@_corners_clist ,
corners .default:n = { NW , SW , NE , SE } ,
code-before .code:n =
{
\tl_if_empty:nF { #1 }
{
\tl_put_right:Nn \l_@@_code_before_tl { #1 }
\bool_set_true:N \l_@@_code_before_bool
}
} ,
% \end{macrocode}
% \bigskip
% The options |c|, |t| and |b| of the environment |{NiceArray}| have the same
% meaning as the option of the classical environment |{array}|.
% \begin{macrocode}
c .code:n = \tl_set:Nn \l_@@_baseline_tl c ,
t .code:n = \tl_set:Nn \l_@@_baseline_tl t ,
b .code:n = \tl_set:Nn \l_@@_baseline_tl b ,
baseline .tl_set:N = \l_@@_baseline_tl ,
baseline .value_required:n = true ,
columns-width .code:n =
\tl_if_eq:nnTF { #1 } { auto }
{ \bool_set_true:N \l_@@_auto_columns_width_bool }
{ \dim_set:Nn \l_@@_columns_width_dim { #1 } } ,
columns-width .value_required:n = true ,
name .code:n =
% \end{macrocode}
% We test whether we are in the measuring phase of an environment of
% \pkg{amsmath} (always loaded by \pkg{nicematrix}) because we want to avoid a
% fallacious message of duplicate name in this case.
% \begin{macrocode}
\legacy_if:nF { measuring@ }
{
\str_set:Nn \l_tmpa_str { #1 }
\seq_if_in:NVTF \g_@@_names_seq \l_tmpa_str
{ \@@_error:nn { Duplicate~name } { #1 } }
{ \seq_gput_left:NV \g_@@_names_seq \l_tmpa_str }
\str_set_eq:NN \l_@@_name_str \l_tmpa_str
} ,
name .value_required:n = true ,
code-after .tl_gset:N = \g_nicematrix_code_after_tl ,
code-after .value_required:n = true ,
colortbl-like .code:n =
\bool_set_true:N \l_@@_colortbl_like_bool
\bool_set_true:N \l_@@_code_before_bool ,
colortbl-like .value_forbidden:n = true
}
% \end{macrocode}
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / notes }
{
para .bool_set:N = \l_@@_notes_para_bool ,
para .default:n = true ,
code-before .tl_set:N = \l_@@_notes_code_before_tl ,
code-before .value_required:n = true ,
code-after .tl_set:N = \l_@@_notes_code_after_tl ,
code-after .value_required:n = true ,
bottomrule .bool_set:N = \l_@@_notes_bottomrule_bool ,
bottomrule .default:n = true ,
style .code:n = \cs_set:Nn \@@_notes_style:n { #1 } ,
style .value_required:n = true ,
label-in-tabular .code:n =
\cs_set:Nn \@@_notes_label_in_tabular:n { #1 } ,
label-in-tabular .value_required:n = true ,
label-in-list .code:n =
\cs_set:Nn \@@_notes_label_in_list:n { #1 } ,
label-in-list .value_required:n = true ,
enumitem-keys .code:n =
{
\hook_gput_code:nnn { begindocument } { . }
{
\bool_if:NT \c_@@_enumitem_loaded_bool
{ \setlist* [ tabularnotes ] { #1 } }
}
} ,
enumitem-keys .value_required:n = true ,
enumitem-keys-para .code:n =
{
\hook_gput_code:nnn { begindocument } { . }
{
\bool_if:NT \c_@@_enumitem_loaded_bool
{ \setlist* [ tabularnotes* ] { #1 } }
}
} ,
enumitem-keys-para .value_required:n = true ,
detect-duplicates .bool_set:N = \l_@@_notes_detect_duplicates_bool ,
detect-duplicates .default:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~notes }
}
% \end{macrocode}
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / delimiters }
{
max-width .bool_set:N = \l_@@_delimiters_max_width_bool ,
max-width .default:n = true ,
color .tl_set:N = \l_@@_delimiters_color_tl ,
color .value_required:n = true ,
}
% \end{macrocode}
%
% \bigskip
% We begin the construction of the major sets of keys (used by the different
% user commands and environments).
% \begin{macrocode}
\keys_define:nn { NiceMatrix }
{
NiceMatrixOptions .inherit:n =
{ NiceMatrix / Global } ,
NiceMatrixOptions / xdots .inherit:n = NiceMatrix / xdots ,
NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules ,
NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes ,
NiceMatrixOptions / delimiters .inherit:n = NiceMatrix / delimiters ,
NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
SubMatrix / rules .inherit:n = NiceMatrix / rules ,
CodeAfter / xdots .inherit:n = NiceMatrix / xdots ,
NiceMatrix .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
} ,
NiceMatrix / xdots .inherit:n = NiceMatrix / xdots ,
NiceMatrix / rules .inherit:n = NiceMatrix / rules ,
NiceMatrix / delimiters .inherit:n = NiceMatrix / delimiters ,
NiceTabular .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env
} ,
NiceTabular / xdots .inherit:n = NiceMatrix / xdots ,
NiceTabular / rules .inherit:n = NiceMatrix / rules ,
NiceTabular / delimiters .inherit:n = NiceMatrix / delimiters ,
NiceArray .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
} ,
NiceArray / xdots .inherit:n = NiceMatrix / xdots ,
NiceArray / rules .inherit:n = NiceMatrix / rules ,
NiceArray / delimiters .inherit:n = NiceMatrix / delimiters ,
pNiceArray .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
} ,
pNiceArray / xdots .inherit:n = NiceMatrix / xdots ,
pNiceArray / rules .inherit:n = NiceMatrix / rules ,
pNiceArray / delimiters .inherit:n = NiceMatrix / delimiters ,
}
% \end{macrocode}
%
%
% \bigskip
% We finalise the definition of the set of keys
% ``|NiceMatrix / NiceMatrixOptions|'' with the options specific to
% |\NiceMatrixOptions|.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceMatrixOptions }
{
width .code:n = \dim_set:Nn \l_@@_width_dim { #1 } ,
width .value_required:n = true ,
last-col .code:n = \tl_if_empty:nF { #1 }
{ \@@_error:n { last-col~non~empty~for~NiceMatrixOptions } }
\int_zero:N \l_@@_last_col_int ,
small .bool_set:N = \l_@@_small_bool ,
small .value_forbidden:n = true ,
% \end{macrocode}
%
% With the option |renew-matrix|, the environment |{matrix}| of \pkg{amsmath}
% and its variants are redefined to behave like the environment |{NiceMatrix}|
% and its variants.
% \begin{macrocode}
renew-matrix .code:n = \@@_renew_matrix: ,
renew-matrix .value_forbidden:n = true ,
% \end{macrocode}
%
% \bigskip
% The option |exterior-arraycolsep| will have effect only in |{NiceArray}| for
% those who want to have for |{NiceArray}| the same behaviour as |{array}|.
% \begin{macrocode}
exterior-arraycolsep .bool_set:N = \l_@@_exterior_arraycolsep_bool ,
% \end{macrocode}
%
% \bigskip
% If the option |columns-width| is used, all the columns will have the same
% width.
%
% In |\NiceMatrixOptions|, the special value |auto| is not available.
% \begin{macrocode}
columns-width .code:n =
\tl_if_eq:nnTF { #1 } { auto }
{ \@@_error:n { Option~auto~for~columns-width } }
{ \dim_set:Nn \l_@@_columns_width_dim { #1 } } ,
% \end{macrocode}
%
% \bigskip
% Usually, an error is raised when the user tries to give the same name to two
% distincts environments of \pkg{nicematrix} (theses names are global and not
% local to the current TeX scope). However, the option |allow-duplicate-names|
% disables this feature.
% \begin{macrocode}
allow-duplicate-names .code:n =
\@@_msg_redirect_name:nn { Duplicate~name } { none } ,
allow-duplicate-names .value_forbidden:n = true ,
% \end{macrocode}
%
% \bigskip
% The key |letter-for-dotted-lines| is now obsolete. You will delete it in a
% future version.
% \begin{macrocode}
letter-for-dotted-lines .code:n =
{
\@@_error:n { letter-for-dotted-lines }
\group_begin:
\globaldefs = 1
\@@_msg_redirect_name:nn { letter-for-dotted-lines } { none }
\group_end:
\tl_if_single_token:nTF { #1 }
{ \str_set:Nx \l_@@_letter_for_dotted_lines_str { #1 } }
{ \@@_error:n { One~letter~allowed } }
} ,
letter-for-dotted-lines .value_required:n = true ,
notes .code:n = \keys_set:nn { NiceMatrix / notes } { #1 } ,
notes .value_required:n = true ,
sub-matrix .code:n =
\keys_set:nn { NiceMatrix / sub-matrix } { #1 } ,
sub-matrix .value_required:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~NiceMatrixOptions }
}
% \end{macrocode}
%
%
% The following string will initially be empty. It will be set by the key
% 'letter-for-dotted-lines'.
% \begin{macrocode}
\str_new:N \l_@@_letter_for_dotted_lines_str
% \end{macrocode}
%
% \bigskip
% |\NiceMatrixOptions| is the command of the \pkg{nicematrix} package to fix
% options at the document level. The scope of these specifications is the
% current TeX group.
% \begin{macrocode}
\NewDocumentCommand \NiceMatrixOptions { m }
{ \keys_set:nn { NiceMatrix / NiceMatrixOptions } { #1 } }
% \end{macrocode}
%
%
% \bigskip
% We finalise the definition of the set of keys
% ``|NiceMatrix / NiceMatrix|'' with the options specific to |{NiceMatrix}|.
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceMatrix }
{
last-col .code:n = \tl_if_empty:nTF {#1}
{
\bool_set_true:N \l_@@_last_col_without_value_bool
\int_set:Nn \l_@@_last_col_int { -1 }
}
{ \int_set:Nn \l_@@_last_col_int { #1 } } ,
l .code:n = \tl_set:Nn \l_@@_type_of_col_tl l ,
r .code:n = \tl_set:Nn \l_@@_type_of_col_tl r ,
small .bool_set:N = \l_@@_small_bool ,
small .value_forbidden:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~NiceMatrix }
}
% \end{macrocode}
%
%
%
% \bigskip
% We finalise the definition of the set of keys ``|NiceMatrix / NiceArray|''
% with the options specific to |{NiceArray}|.
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceArray }
{
% \end{macrocode}
%
% In the environments |{NiceArray}| and its variants, the option |last-col| must
% be used without value because the number of columns of the array is read
% from the preamble of the array.
% \begin{macrocode}
small .bool_set:N = \l_@@_small_bool ,
small .value_forbidden:n = true ,
last-col .code:n = \tl_if_empty:nF { #1 }
{ \@@_error:n { last-col~non~empty~for~NiceArray } }
\int_zero:N \l_@@_last_col_int ,
notes / para .bool_set:N = \l_@@_notes_para_bool ,
notes / para .default:n = true ,
notes / bottomrule .bool_set:N = \l_@@_notes_bottomrule_bool ,
notes / bottomrule .default:n = true ,
tabularnote .tl_set:N = \l_@@_tabularnote_tl ,
tabularnote .value_required:n = true ,
r .code:n = \@@_error:n { r~or~l~with~preamble } ,
l .code:n = \@@_error:n { r~or~l~with~preamble } ,
unknown .code:n = \@@_error:n { Unknown~key~for~NiceArray }
}
% \end{macrocode}
%
%
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / pNiceArray }
{
first-col .code:n = \int_zero:N \l_@@_first_col_int ,
last-col .code:n = \tl_if_empty:nF {#1}
{ \@@_error:n { last-col~non~empty~for~NiceArray } }
\int_zero:N \l_@@_last_col_int ,
first-row .code:n = \int_zero:N \l_@@_first_row_int ,
small .bool_set:N = \l_@@_small_bool ,
small .value_forbidden:n = true ,
r .code:n = \@@_error:n { r~or~l~with~preamble } ,
l .code:n = \@@_error:n { r~or~l~with~preamble } ,
unknown .code:n = \@@_error:n { Unknown~key~for~NiceMatrix }
}
% \end{macrocode}
%
% \bigskip
% We finalise the definition of the set of keys ``|NiceMatrix / NiceTabular|''
% with the options specific to |{NiceTabular}|.
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceTabular }
{
% \end{macrocode}
% The dimension |width| will be used if at least a column of type |X| is used.
% If there is no column of type |X|, an error will be raised.
% \begin{macrocode}
width .code:n = \dim_set:Nn \l_@@_width_dim { #1 }
\bool_set_true:N \l_@@_width_used_bool ,
width .value_required:n = true ,
notes / para .bool_set:N = \l_@@_notes_para_bool ,
notes / para .default:n = true ,
notes / bottomrule .bool_set:N = \l_@@_notes_bottomrule_bool ,
notes / bottomrule .default:n = true ,
tabularnote .tl_set:N = \l_@@_tabularnote_tl ,
tabularnote .value_required:n = true ,
last-col .code:n = \tl_if_empty:nF {#1}
{ \@@_error:n { last-col~non~empty~for~NiceArray } }
\int_zero:N \l_@@_last_col_int ,
r .code:n = \@@_error:n { r~or~l~with~preamble } ,
l .code:n = \@@_error:n { r~or~l~with~preamble } ,
unknown .code:n = \@@_error:n { Unknown~key~for~NiceTabular }
}
% \end{macrocode}
%
% \bigskip
% \subsection*{Important code used by \{NiceArrayWithDelims\} }
%
% The pseudo-environment |\@@_cell_begin:w|--|\@@_cell_end:| will be used to format the
% cells of the array. In the code, the affectations are global because this
% pseudo-environment will be used in the cells of a |\halign| (via an
% environment |{array}|).
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_cell_begin:w
{
% \end{macrocode}
% The token list |\g_@@_post_action_cell_tl| will be set during the
% composition of the box |\l_@@_cell_box| and will be used \emph{after} the
% composition in order to modify that box (that's why it's called a
% \emph{post-action}).
% \begin{macrocode}
\tl_gclear:N \g_@@_post_action_cell_tl
% \end{macrocode}
% At the beginning of the cell, we link |\CodeAfter| to a command which do
% begins with |\\| (whereas the standard version of |\CodeAfter| begins does
% not).
% \begin{macrocode}
\cs_set_eq:NN \CodeAfter \@@_CodeAfter_i:
% \end{macrocode}
% We increment |\c@jCol|, which is the counter of the columns.
% \begin{macrocode}
\int_gincr:N \c@jCol
% \end{macrocode}
% Now, we increment the counter of the rows. We don't do this incrementation in
% the |\everycr| because some packages, like \pkg{arydshln}, create special rows
% in the |\halign| that we don't want to take into account.
% \begin{macrocode}
\int_compare:nNnT \c@jCol = 1
{ \int_compare:nNnT \l_@@_first_col_int = 1 \@@_begin_of_row: }
% \end{macrocode}
% The content of the cell is composed in the box |\l_@@_cell_box|. The
% |\hbox_set_end:| corresponding to this |\hbox_set:Nw| will be in the
% |\@@_cell_end:| (and the potential |\c_math_toggle_token| also).
% \begin{macrocode}
\hbox_set:Nw \l_@@_cell_box
\bool_if:NF \l_@@_NiceTabular_bool
{
\c_math_toggle_token
\bool_if:NT \l_@@_small_bool \scriptstyle
}
% \end{macrocode}
%
% \bigskip
% For unexplained reason, with XeTeX (and not with the other engines), the
% environments of \pkg{nicematrix} were all composed in black and do not take
% into account the color of the encompassing text. As a workaround, you peek the
% color in force at the beginning of the environment and we use it now (in each
% cell of the array).
% \begin{macrocode}
\color { nicematrix }
% \end{macrocode}
%
% \begin{macrocode}
\g_@@_row_style_tl
% \end{macrocode}
%
% We will call \emph{corners} of the matrix the cases which are at the
% intersection of the exterior rows and exterior columns (of course, the four
% corners doesn't always exist simultaneously).
%
% The codes |\l_@@_code_for_first_row_tl| and \emph{al} don't apply in the
% corners of the matrix.
% \begin{macrocode}
\int_compare:nNnTF \c@iRow = 0
{
\int_compare:nNnT \c@jCol > 0
{
\l_@@_code_for_first_row_tl
\xglobal \colorlet { nicematrix-first-row } { . }
}
}
{
\int_compare:nNnT \c@iRow = \l_@@_last_row_int
{
\l_@@_code_for_last_row_tl
\xglobal \colorlet { nicematrix-last-row } { . }
}
}
}
% \end{macrocode}
%
% \interitem
% The following macro |\@@_begin_of_row| is usually used in the cell
% number~$1$ of the row. However, when the key |first-col| is used,
% |\@@_begin_of_row| is executed in the cell number~$0$ of the row.
% \begin{macrocode}
\cs_new_protected:Npn \@@_begin_of_row:
{
\int_gincr:N \c@iRow
\dim_gset_eq:NN \g_@@_dp_ante_last_row_dim \g_@@_dp_last_row_dim
\dim_gset:Nn \g_@@_dp_last_row_dim { \box_dp:N \@arstrutbox }
\dim_gset:Nn \g_@@_ht_last_row_dim { \box_ht:N \@arstrutbox }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate
{ \@@_env: - row - \int_use:N \c@iRow - base }
{ \pgfpoint \c_zero_dim { 0.5 \arrayrulewidth } }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{ \l_@@_name_str - row - \int_use:N \c@iRow - base }
{ \@@_env: - row - \int_use:N \c@iRow - base }
}
\endpgfpicture
}
% \end{macrocode}
% Remark: If the key |recreate-cell-nodes| of the |\CodeBefore| is used, then we
% will add some lines to that command.
%
%
% \interitem
% The following code is used in each cell of the array. It actualises quantities
% that, at the end of the array, will give informations about the vertical
% dimension of the two first rows and the two last rows. If the user uses the
% |last-row|, some lines of code will be dynamically added to this command.
% \begin{macrocode}
\cs_new_protected:Npn \@@_update_for_first_and_last_row:
{
\int_compare:nNnTF \c@iRow = 0
{
\dim_gset:Nn \g_@@_dp_row_zero_dim
{ \dim_max:nn \g_@@_dp_row_zero_dim { \box_dp:N \l_@@_cell_box } }
\dim_gset:Nn \g_@@_ht_row_zero_dim
{ \dim_max:nn \g_@@_ht_row_zero_dim { \box_ht:N \l_@@_cell_box } }
}
{
\int_compare:nNnT \c@iRow = 1
{
\dim_gset:Nn \g_@@_ht_row_one_dim
{ \dim_max:nn \g_@@_ht_row_one_dim { \box_ht:N \l_@@_cell_box } }
}
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_rotate_cell_box:
{
\box_rotate:Nn \l_@@_cell_box { 90 }
\int_compare:nNnT \c@iRow = \l_@@_last_row_int
{
\vbox_set_top:Nn \l_@@_cell_box
{
\vbox_to_zero:n { }
\skip_vertical:n { - \box_ht:N \@arstrutbox + 0.8 ex }
\box_use:N \l_@@_cell_box
}
}
\bool_gset_false:N \g_@@_rotate_bool
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_adjust_size_box:
{
\dim_compare:nNnT \g_@@_blocks_wd_dim > \c_zero_dim
{
\box_set_wd:Nn \l_@@_cell_box
{ \dim_max:nn { \box_wd:N \l_@@_cell_box } \g_@@_blocks_wd_dim }
\dim_gzero:N \g_@@_blocks_wd_dim
}
\dim_compare:nNnT \g_@@_blocks_dp_dim > \c_zero_dim
{
\box_set_dp:Nn \l_@@_cell_box
{ \dim_max:nn { \box_dp:N \l_@@_cell_box } \g_@@_blocks_dp_dim }
\dim_gzero:N \g_@@_blocks_dp_dim
}
\dim_compare:nNnT \g_@@_blocks_ht_dim > \c_zero_dim
{
\box_set_ht:Nn \l_@@_cell_box
{ \dim_max:nn { \box_ht:N \l_@@_cell_box } \g_@@_blocks_ht_dim }
\dim_gzero:N \g_@@_blocks_ht_dim
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_cell_end:
{
\@@_math_toggle_token:
\hbox_set_end:
% \end{macrocode}
% The token list |\g_@@_post_action_cell_tl| is (potentially) set during the
% composition of the box |\l_@@_cell_box| and is used now \emph{after} the
% composition in order to modify that box.
% \begin{macrocode}
\g_@@_post_action_cell_tl
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
\@@_adjust_size_box:
% \end{macrocode}
%
% \begin{macrocode}
\box_set_ht:Nn \l_@@_cell_box
{ \box_ht:N \l_@@_cell_box + \l_@@_cell_space_top_limit_dim }
\box_set_dp:Nn \l_@@_cell_box
{ \box_dp:N \l_@@_cell_box + \l_@@_cell_space_bottom_limit_dim }
% \end{macrocode}
%
% We want to compute in |\g_@@_max_cell_width_dim| the width of the widest cell
% of the array (except the cells of the ``first column'' and the ``last
% column'').
% \begin{macrocode}
\dim_gset:Nn \g_@@_max_cell_width_dim
{ \dim_max:nn \g_@@_max_cell_width_dim { \box_wd:N \l_@@_cell_box } }
% \end{macrocode}
%
% The following computations are for the ``first row'' and the ``last row''.
% \begin{macrocode}
\@@_update_for_first_and_last_row:
% \end{macrocode}
%
% \medskip
% If the cell is empty, or may be considered as if, we must not create the
% \textsc{pgf} node, for two reasons:
% \begin{itemize}
% \item it's a waste of time since such a node would be rather pointless;
% \item we test the existence of these nodes in order to determine whether a
% cell is empty when we search the extremities of a dotted line.
% \end{itemize}
% However, it's very difficult to determine whether a cell is empty. Up to now
% we use the following technic:
% \begin{itemize}
% \item if the width of the box |\l_@@_cell_box| (created with the content of
% the cell) is equal to zero, we consider the cell as empty (however,
% this is not perfect since the user may have used a |\rlap|, a |\llap| or a
% |\mathclap| of \pkg{mathtools}.
% \item the cells with a command |\Ldots| or |\Cdots|, |\Vdots|, etc.,
% should also be considered as empty; if |nullify-dots| is in force, there would
% be nothing to do (in this case the previous commands only write an instruction
% in a kind of |\CodeAfter|); however, if |nullify-dots| is not in force, a
% phantom of |\ldots|, |\cdots|, |\vdots| is inserted and its width is not equal
% to zero; that's why these commands raise a boolean |\g_@@_empty_cell_bool| and
% we begin by testing this boolean.
% \end{itemize}
% \begin{macrocode}
\bool_if:NTF \g_@@_empty_cell_bool
{ \box_use_drop:N \l_@@_cell_box }
{
\bool_lazy_or:nnTF
\g_@@_not_empty_cell_bool
{ \dim_compare_p:nNn { \box_wd:N \l_@@_cell_box } > \c_zero_dim }
\@@_node_for_cell:
{ \box_use_drop:N \l_@@_cell_box }
}
\int_gset:Nn \g_@@_col_total_int { \int_max:nn \g_@@_col_total_int \c@jCol }
\bool_gset_false:N \g_@@_empty_cell_bool
\bool_gset_false:N \g_@@_not_empty_cell_bool
}
% \end{macrocode}
%
% \medskip
% The following command creates the \textsc{pgf} name of the node with, of
% course, |\l_@@_cell_box| as the content.
% \begin{macrocode}
\cs_new_protected:Npn \@@_node_for_cell:
{
\pgfpicture
\pgfsetbaseline \c_zero_dim
\pgfrememberpicturepositiononpagetrue
\pgfset
{
inner~sep = \c_zero_dim ,
minimum~width = \c_zero_dim
}
\pgfnode
{ rectangle }
{ base }
{ \box_use_drop:N \l_@@_cell_box }
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol }
{ }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{ \l_@@_name_str - \int_use:N \c@iRow - \int_use:N \c@jCol }
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol }
}
\endpgfpicture
}
% \end{macrocode}
%
% \medskip
% As its name says, the following command is a patch for the command
% |\@@_node_for_cell:|. This patch will be appended on the left of
% |\@@_node_for_the_cell:| when the construction of the cell nodes (of the form
% |(i-j)|) in the |\CodeBefore| is required.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_node_for_cell:n #1
{
\cs_new_protected:Npn \@@_patch_node_for_cell:
{
\hbox_set:Nn \l_@@_cell_box
{
\box_move_up:nn { \box_ht:N \l_@@_cell_box}
\hbox_overlap_left:n
{
\pgfsys@markposition
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol - NW }
% \end{macrocode}
% I don't know why the following adjustement is needed when the compilation is
% done with XeLaTeX or with the classical way |latex|, |divps|, |ps2pdf| (or
% Adobe Distiller). However, it seems to work.
% \begin{macrocode}
#1
}
\box_use:N \l_@@_cell_box
\box_move_down:nn { \box_dp:N \l_@@_cell_box }
\hbox_overlap_left:n
{
\pgfsys@markposition
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol - SE }
#1
}
}
}
}
% \end{macrocode}
%
% \bigskip
% We have no explanation for the different behaviour between the TeX engines...
% \begin{macrocode}
\bool_lazy_or:nnTF \sys_if_engine_xetex_p: \sys_if_output_dvi_p:
{
\@@_patch_node_for_cell:n
{ \skip_horizontal:n { 0.5 \box_wd:N \l_@@_cell_box } }
}
{ \@@_patch_node_for_cell:n { } }
% \end{macrocode}
%
%
% \interitem
% The second argument of the following command |\@@_instruction_of_type:nnn|
% defined below is the type of the instruction (|Cdots|, |Vdots|, |Ddots|,
% etc.). The third argument is the list of options. This command writes in the
% corresponding |\g_@@_|\textsl{type}|_lines_tl| the instruction which will
% actually draw the line after the construction of the matrix.
%
% \medskip
% For example, for the following matrix,
%
% \smallskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
% \begin{pNiceMatrix}
% 1 & 2 & 3 & 4 \\
% 5 & \Cdots & & 6 \\
% 7 & \Cdots[color=red]
% \end{pNiceMatrix}
% \end{BVerbatim}
% $\begin{pNiceMatrix}
% 1 & 2 & 3 & 4 \\
% 5 & \Cdots & & 6 \\
% 7 & \Cdots[color=red]
% \end{pNiceMatrix}$
%
% \smallskip
% the content of |\g_@@_Cdots_lines_tl| will be:
%
% \smallskip
% \begin{scope}
% \color{gray}
% |\@@_draw_Cdots:nnn {2}{2}{}|
%
% |\@@_draw_Cdots:nnn {3}{2}{color=red}|
% \end{scope}
%
%
% \bigskip
% The first argument is a boolean which indicates whether you must put the
% instruction on the left or on the right on the list of instructions.
% \begin{macrocode}
\cs_new_protected:Npn \@@_instruction_of_type:nnn #1 #2 #3
{
\bool_if:nTF { #1 } \tl_gput_left:cx \tl_gput_right:cx
{ g_@@_ #2 _ lines _ tl }
{
\use:c { @@ _ draw _ #2 : nnn }
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ \exp_not:n { #3 } }
}
}
% \end{macrocode}
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_array:
{
\bool_if:NTF \l_@@_NiceTabular_bool
{ \dim_set_eq:NN \col@sep \tabcolsep }
{ \dim_set_eq:NN \col@sep \arraycolsep }
\dim_compare:nNnTF \l_@@_tabular_width_dim = \c_zero_dim
{ \cs_set_nopar:Npn \@halignto { } }
{ \cs_set_nopar:Npx \@halignto { to \dim_use:N \l_@@_tabular_width_dim } }
% \end{macrocode}
% It \pkg{colortbl} is loaded, |\@tabarray| has been redefined to incorporate
% |\CT@start|.
% \begin{macrocode}
\@tabarray
% \end{macrocode}
% |\l_@@_baseline_tl| may have the value |t|, |c| or |b|. However, if the value
% is |b|, we compose the |\array| (of \pkg{array}) with the option |t| and the
% right translation will be done further. Remark that |\str_if_eq:VnTF| is
% fully expandable and you need something fully expandable here.
% \begin{macrocode}
[ \str_if_eq:VnTF \l_@@_baseline_tl c c t ]
}
% \end{macrocode}
%
% \medskip
% We keep in memory the standard version of |\ialign| because we will redefine
% |\ialign| in the environment |{NiceArrayWithDelims}| but restore the standard
% version for use in the cells of the array.
% \begin{macrocode}
\cs_set_eq:NN \@@_old_ialign: \ialign
% \end{macrocode}
%
%
% The following command creates a |row| node (and not a row of nodes!).
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_row_node:
{
% \end{macrocode}
% The |\hbox:n| (or |\hbox|) is mandatory.
% \begin{macrocode}
\hbox
{
\bool_if:NT \l_@@_code_before_bool
{
\vtop
{
\skip_vertical:N 0.5\arrayrulewidth
\pgfsys@markposition
{ \@@_env: - row - \int_eval:n { \c@iRow + 1 } }
\skip_vertical:N -0.5\arrayrulewidth
}
}
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \@@_env: - row - \int_eval:n { \c@iRow + 1 } }
{ \pgfpoint \c_zero_dim { - 0.5 \arrayrulewidth } }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{ \l_@@_name_str - row - \int_eval:n { \c@iRow + 1 } }
{ \@@_env: - row - \int_eval:n { \c@iRow + 1 } }
}
\endpgfpicture
}
}
% \end{macrocode}
%
%
%
% \bigskip
% The following must \emph{not} be protected because it begins with |\noalign|.
% \begin{macrocode}
\cs_new:Npn \@@_everycr: { \noalign { \@@_everycr_i: } }
% \end{macrocode}
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_everycr_i:
{
\int_gzero:N \c@jCol
\bool_gset_false:N \g_@@_after_col_zero_bool
\bool_if:NF \g_@@_row_of_col_done_bool
{
\@@_create_row_node:
% \end{macrocode}
% We don't draw now the rules of the key |hlines| (or |hvlines|) but we reserve the
% vertical space for theses rules (the rules will be drawn by \textsc{pgf}).
% \begin{macrocode}
\tl_if_empty:NF \l_@@_hlines_clist
{
\tl_if_eq:NnF \l_@@_hlines_clist { all }
{
\exp_args:NNx
\clist_if_in:NnT
\l_@@_hlines_clist
{ \int_eval:n { \c@iRow + 1 } }
}
{
% \end{macrocode}
% The counter |\c@iRow| has the value $-1$ only if there is a ``first
% row'' and that we are before that ``first row'', i.e. just before the
% beginning of the array.
% \begin{macrocode}
\int_compare:nNnT \c@iRow > { -1 }
{
\int_compare:nNnF \c@iRow = \l_@@_last_row_int
% \end{macrocode}
% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of
% the rules in the array. The package \pkg{nicematrix} uses it even if
% \pkg{colortbl} is not loaded. We use a TeX group in order to limit the scope
% of |\CT@arc@|.
% \begin{macrocode}
{ \hrule height \arrayrulewidth width \c_zero_dim }
}
}
}
}
}
% \end{macrocode}
%
% \bigskip
% The command |\@@_newcolumntype| is the command |\newcolumntype| of
% \pkg{array} without the warnings for redefinitions of columns types (we will
% use it to redefine the columns types |w| and |W|).
% \begin{macrocode}
\cs_set_protected:Npn \@@_newcolumntype #1
{
\cs_set:cpn { NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } }
\peek_meaning:NTF [
{ \newcol@ #1 }
{ \newcol@ #1 [ 0 ] }
}
% \end{macrocode}
%
%
% \bigskip
% When the key |renew-dots| is used, the following code will be executed.
% \begin{macrocode}
\cs_set_protected:Npn \@@_renew_dots:
{
\cs_set_eq:NN \ldots \@@_Ldots
\cs_set_eq:NN \cdots \@@_Cdots
\cs_set_eq:NN \vdots \@@_Vdots
\cs_set_eq:NN \ddots \@@_Ddots
\cs_set_eq:NN \iddots \@@_Iddots
\cs_set_eq:NN \dots \@@_Ldots
\cs_set_eq:NN \hdotsfor \@@_Hdotsfor:
}
% \end{macrocode}
%
% \bigskip
% When the key |colortbl-like| is used, the following code will be executed.
% \begin{macrocode}
\cs_new_protected:Npn \@@_colortbl_like:
{
\cs_set_eq:NN \cellcolor \@@_cellcolor_tabular
\cs_set_eq:NN \rowcolor \@@_rowcolor_tabular
\cs_set_eq:NN \columncolor \@@_columncolor_preamble
}
% \end{macrocode}
%
% \bigskip
% The following code |\@@_pre_array_ii:| is used in |{NiceArrayWithDelims}|. It
% exists as a standalone macro only for legibility.
% \label{prearray}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_pre_array_ii:
{
% \end{macrocode}
% For unexplained reason, with XeTeX (and not with the other engines), the
% environments of \pkg{nicematrix} were all composed in black and do not take
% into account the color of the encompassing text. As a workaround, you peek the
% color in force at the beginning of the environment and we will it in each cell.
% \begin{macrocode}
\xglobal \colorlet { nicematrix } { . }
% \end{macrocode}
% The number of letters |X| in the preamble of the array.
% \begin{macrocode}
\int_gzero:N \g_@@_total_X_weight_int
% \end{macrocode}
%
% \begin{macrocode}
\@@_expand_clist:N \l_@@_hlines_clist
\@@_expand_clist:N \l_@@_vlines_clist
% \end{macrocode}
%
% If \pkg{booktabs} is loaded, we have to patch the macro |\@BTnormal| which is
% a macro of \pkg{booktabs}. The macro |\@BTnormal| draws an horizontal rule but
% it occurs after a vertical skip done by a low level TeX command. When this
% macro |\@BTnormal| occurs, the |row| node has yet been inserted by
% \pkg{nicematrix} \emph{before} the vertical skip (and thus, at a wrong place).
% That why we decide to create a new |row| node (for the same row). We patch the
% macro |\@BTnormal| to create this |row| node. This new |row| node will
% overwrite the previous definition of that |row| node and we have managed to
% avoid the error messages of that redefinition
% \footnote{cf. |\nicematrix@redefine@check@rerun|}.
% \begin{macrocode}
\bool_if:NT \c_@@_booktabs_loaded_bool
{ \tl_put_left:Nn \@BTnormal \@@_create_row_node: }
\box_clear_new:N \l_@@_cell_box
\normalbaselines
% \end{macrocode}
% If the option |small| is used, we have to do some tuning. In particular, we
% change the value of |\arraystretch| (this parameter is used in the
% construction of |\@arstrutbox| in the beginning of |{array}|).
% \begin{macrocode}
\bool_if:NT \l_@@_small_bool
{
% \end{macrocode}
% \begin{macrocode}
\cs_set_nopar:Npn \arraystretch { 0.47 }
\dim_set:Nn \arraycolsep { 1.45 pt }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\bool_if:NT \g_@@_recreate_cell_nodes_bool
{
\tl_put_right:Nn \@@_begin_of_row:
{
\pgfsys@markposition
{ \@@_env: - row - \int_use:N \c@iRow - base }
}
}
% \end{macrocode}
%
% \bigskip
% The environment |{array}| uses internally the command |\ialign|. We change the
% definition of |\ialign| for several reasons. In particular, |\ialign| sets
% |\everycr| to |{ }| and we \emph{need} to have to change the value of
% |\everycr|.
% \begin{macrocode}
\cs_set_nopar:Npn \ialign
{
\bool_if:NTF \l_@@_colortbl_loaded_bool
{
\CT@everycr
{
\noalign { \cs_gset_eq:NN \CT@row@color \prg_do_nothing: }
\@@_everycr:
}
}
{ \everycr { \@@_everycr: } }
\tabskip = \c_zero_skip
% \end{macrocode}
%
% The box |\@arstrutbox| is a box constructed in the beginning of the
% environment |{array}|. The construction of that box takes into account the
% current value of |\arraystretch|\footnote{The option |small| of
% \pkg{nicematrix} changes (among others) the value of |\arraystretch|. This is
% done, of course, before the call of |{array}|.} and |\extrarowheight| (of
% \pkg{array}). That box is inserted (via |\@arstrut|) in the beginning of each
% row of the array. That's why we use the dimensions of that box to initialize
% the variables which will be the dimensions of the potential first and last row
% of the environment. This initialization must be done after the creation of
% |\@arstrutbox| and that's why we do it in the |\ialign|.
% \begin{macrocode}
\dim_gzero_new:N \g_@@_dp_row_zero_dim
\dim_gset:Nn \g_@@_dp_row_zero_dim { \box_dp:N \@arstrutbox }
\dim_gzero_new:N \g_@@_ht_row_zero_dim
\dim_gset:Nn \g_@@_ht_row_zero_dim { \box_ht:N \@arstrutbox }
\dim_gzero_new:N \g_@@_ht_row_one_dim
\dim_gset:Nn \g_@@_ht_row_one_dim { \box_ht:N \@arstrutbox }
\dim_gzero_new:N \g_@@_dp_ante_last_row_dim
\dim_gzero_new:N \g_@@_ht_last_row_dim
\dim_gset:Nn \g_@@_ht_last_row_dim { \box_ht:N \@arstrutbox }
\dim_gzero_new:N \g_@@_dp_last_row_dim
\dim_gset:Nn \g_@@_dp_last_row_dim { \box_dp:N \@arstrutbox }
% \end{macrocode}
% After its first use, the definition of |\ialign| will revert
% automatically to its default definition. With this programmation, we will
% have, in the cells of the array, a clean version of |\ialign|.
% \begin{macrocode}
\cs_set_eq:NN \ialign \@@_old_ialign:
\halign
}
% \end{macrocode}
%
% We keep in memory the old versions or |\ldots|, |\cdots|, etc. only because we
% use them inside |\phantom| commands in order that the new commands |\Ldots|,
% |\Cdots|, etc. give the same spacing (except when the option |nullify-dots| is
% used).
% \begin{macrocode}
\cs_set_eq:NN \@@_old_ldots \ldots
\cs_set_eq:NN \@@_old_cdots \cdots
\cs_set_eq:NN \@@_old_vdots \vdots
\cs_set_eq:NN \@@_old_ddots \ddots
\cs_set_eq:NN \@@_old_iddots \iddots
\bool_if:NTF \l_@@_standard_cline_bool
{ \cs_set_eq:NN \cline \@@_standard_cline }
{ \cs_set_eq:NN \cline \@@_cline }
\cs_set_eq:NN \Ldots \@@_Ldots
\cs_set_eq:NN \Cdots \@@_Cdots
\cs_set_eq:NN \Vdots \@@_Vdots
\cs_set_eq:NN \Ddots \@@_Ddots
\cs_set_eq:NN \Iddots \@@_Iddots
\cs_set_eq:NN \Hline \@@_Hline:
\cs_set_eq:NN \Hspace \@@_Hspace:
\cs_set_eq:NN \Hdotsfor \@@_Hdotsfor:
\cs_set_eq:NN \Vdotsfor \@@_Vdotsfor:
\cs_set_eq:NN \Block \@@_Block:
\cs_set_eq:NN \rotate \@@_rotate:
\cs_set_eq:NN \OnlyMainNiceMatrix \@@_OnlyMainNiceMatrix:n
\cs_set_eq:NN \dotfill \@@_old_dotfill:
\cs_set_eq:NN \CodeAfter \@@_CodeAfter:
\cs_set_eq:NN \diagbox \@@_diagbox:nn
\cs_set_eq:NN \NotEmpty \@@_NotEmpty:
\cs_set_eq:NN \RowStyle \@@_RowStyle:n
\seq_map_inline:Nn \l_@@_custom_line_commands_seq
{ \cs_set_eq:cc { ##1 } { nicematrix - ##1 } }
\bool_if:NT \l_@@_colortbl_like_bool \@@_colortbl_like:
\bool_if:NT \l_@@_renew_dots_bool \@@_renew_dots:
% \end{macrocode}
% We redefine |\multicolumn| and, since we want |\multicolumn| to be available
% in the potential environments |{tabular}| nested in the environments of
% \pkg{nicematrix}, we patch |{tabular}| to go back to the original definition.
% \begin{macrocode}
\cs_set_eq:NN \multicolumn \@@_multicolumn:nnn
\hook_gput_code:nnn { env / tabular / begin } { . }
{ \cs_set_eq:NN \multicolumn \@@_old_multicolumn }
% \end{macrocode}
%
%
% The sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells
% of the array where a command |\multicolumn{|$n$|}{...}{...}| with $n>1$ is
% issued. In |\g_@@_multicolumn_sizes_seq|, the ``sizes'' (that is to say the
% values of $n$) correspondant will be stored. These lists will be used for the
% creation of the ``medium nodes'' (if they are created).
% \begin{macrocode}
\seq_gclear:N \g_@@_multicolumn_cells_seq
\seq_gclear:N \g_@@_multicolumn_sizes_seq
% \end{macrocode}
%
% The counter |\c@iRow| will be used to count the rows of the array (its
% incrementation will be in the first cell of the row).
% \begin{macrocode}
\int_gset:Nn \c@iRow { \l_@@_first_row_int - 1 }
% \end{macrocode}
%
% At the end of the environment |{array}|, |\c@iRow| will be the total
% number de rows.
%
% |\g_@@_row_total_int| will be the number or rows excepted the last row (if
% |\l_@@_last_row_bool| has been raised with the option |last-row|).
% \begin{macrocode}
\int_gzero_new:N \g_@@_row_total_int
% \end{macrocode}
%
% The counter |\c@jCol| will be used to count the columns of the array.
% Since we want to know the total number of columns of the matrix, we also
% create a counter |\g_@@_col_total_int|. These counters are updated in the
% command |\@@_cell_begin:w| executed at the beginning of each cell.
% \begin{macrocode}
\int_gzero_new:N \g_@@_col_total_int
% \end{macrocode}
%
% \begin{macrocode}
\cs_set_eq:NN \@ifnextchar \new@ifnextchar
% \end{macrocode}
%
% \begin{macrocode}
\@@_renew_NC@rewrite@S:
% \end{macrocode}
%
% \begin{macrocode}
\bool_gset_false:N \g_@@_last_col_found_bool
% \end{macrocode}
%
% \medskip
% During the construction of the array, the instructions |\Cdots|, |\Ldots|,
% etc. will be written in token lists |\g_@@_Cdots_lines_tl|, etc. which will be
% executed after the construction of the array.
% \begin{macrocode}
\tl_gclear_new:N \g_@@_Cdots_lines_tl
\tl_gclear_new:N \g_@@_Ldots_lines_tl
\tl_gclear_new:N \g_@@_Vdots_lines_tl
\tl_gclear_new:N \g_@@_Ddots_lines_tl
\tl_gclear_new:N \g_@@_Iddots_lines_tl
\tl_gclear_new:N \g_@@_HVdotsfor_lines_tl
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\tl_gclear_new:N \g_nicematrix_code_before_tl
}
% \end{macrocode}
% This is the end of |\@@_pre_array_ii:|.
%
%
% \bigskip
% The command |\@@_pre_array:| will be executed after analyse of the keys of the
% environment.
% \begin{macrocode}
\cs_new_protected:Npn \@@_pre_array:
{
% \end{macrocode}
%
% \begin{macrocode}
\cs_if_exist:NT \theiRow { \int_set_eq:NN \l_@@_old_iRow_int \c@iRow }
\int_gzero_new:N \c@iRow
\cs_if_exist:NT \thejCol { \int_set_eq:NN \l_@@_old_jCol_int \c@jCol }
\int_gzero_new:N \c@jCol
% \end{macrocode}
%
% \bigskip
% We recall that |\l_@@_last_row_int| and |\l_@@_last_column_int| are \emph{not}
% the numbers of the last row and last column of the array. There are only the
% values of the keys |last-row| and |last-column| (maybe the user has provided
% erroneous values). The meaning of that counters does not change during the
% environment of \pkg{nicematrix}. There is only a slight adjustment: if the
% user have used one of those keys without value, we provide now the right value
% as read on the |aux| file (of course, it's possible only after the first compilation).
% \begin{macrocode}
\int_compare:nNnT \l_@@_last_row_int = { -1 }
{
\bool_set_true:N \l_@@_last_row_without_value_bool
\bool_if:NT \g_@@_aux_found_bool
{ \int_set:Nn \l_@@_last_row_int { \seq_item:Nn \g_@@_size_seq 3 } }
}
\int_compare:nNnT \l_@@_last_col_int = { -1 }
{
\bool_if:NT \g_@@_aux_found_bool
{ \int_set:Nn \l_@@_last_col_int { \seq_item:Nn \g_@@_size_seq 6 } }
}
% \end{macrocode}
%
% \bigskip
% If there is a exterior row, we patch a command used in |\@@_cell_begin:w| in order to
% keep track of some dimensions needed to the construction of that ``last row''.
% \begin{macrocode}
\int_compare:nNnT \l_@@_last_row_int > { -2 }
{
\tl_put_right:Nn \@@_update_for_first_and_last_row:
{
\dim_gset:Nn \g_@@_ht_last_row_dim
{ \dim_max:nn \g_@@_ht_last_row_dim { \box_ht:N \l_@@_cell_box } }
\dim_gset:Nn \g_@@_dp_last_row_dim
{ \dim_max:nn \g_@@_dp_last_row_dim { \box_dp:N \l_@@_cell_box } }
}
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\seq_gclear:N \g_@@_cols_vlism_seq
\seq_gclear:N \g_@@_submatrix_seq
% \end{macrocode}
%
% \bigskip
% Now the |\CodeBefore|.
% \begin{macrocode}
\bool_if:NT \l_@@_code_before_bool \@@_exec_code_before:
% \end{macrocode}
%
% \bigskip
% The value of |\g_@@_pos_of_blocks_seq| has been written on the |aux| file and
% loaded before the (potential) execution of the |\CodeBefore|. Now, we clear
% that variable because it will be reconstructed during the creation of the
% array.
% \begin{macrocode}
\seq_gclear:N \g_@@_pos_of_blocks_seq
% \end{macrocode}
% Idem for other sequences written on the |aux| file.
% \begin{macrocode}
\seq_gclear_new:N \g_@@_multicolumn_cells_seq
\seq_gclear_new:N \g_@@_multicolumn_sizes_seq
% \end{macrocode}
%
%
% \interitem
% The code in |\@@_pre_array_ii:| is used only here.
% \begin{macrocode}
\@@_pre_array_ii:
% \end{macrocode}
%
% \medskip
% The array will be composed in a box (named |\l_@@_the_array_box|) because we
% have to do manipulations concerning the potential exterior rows.
% \begin{macrocode}
\box_clear_new:N \l_@@_the_array_box
% \end{macrocode}
%
%
% \bigskip
% The preamble will be constructed in |\g_@@_preamble_tl|.
% \begin{macrocode}
\@@_construct_preamble:
% \end{macrocode}
% Now, the preamble is constructed in |\g_@@_preamble_tl|
%
% \medskip
% We compute the width of both delimiters. We remember that, when the
% environment |{NiceArray}| is used, it's possible to specify the delimiters in
% the preamble (eg |[ccc]|).
% \begin{macrocode}
\dim_zero_new:N \l_@@_left_delim_dim
\dim_zero_new:N \l_@@_right_delim_dim
\bool_if:NTF \l_@@_NiceArray_bool
{
\dim_gset:Nn \l_@@_left_delim_dim { 2 \arraycolsep }
\dim_gset:Nn \l_@@_right_delim_dim { 2 \arraycolsep }
}
{
% \end{macrocode}
% The command |\bBigg@| is a command of \pkg{amsmath}.
% \begin{macrocode}
\hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \g_@@_left_delim_tl $ }
\dim_set:Nn \l_@@_left_delim_dim { \box_wd:N \l_tmpa_box }
\hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \g_@@_right_delim_tl $ }
\dim_set:Nn \l_@@_right_delim_dim { \box_wd:N \l_tmpa_box }
}
% \end{macrocode}
%
% \bigskip
% Here is the beginning of the box which will contain the array. The
% |\hbox_set_end:| corresponding to this |\hbox_set:Nw| will be in the second
% part of the environment (and the closing |\c_math_toggle_token| also).
% \begin{macrocode}
\hbox_set:Nw \l_@@_the_array_box
% \end{macrocode}
%
% \begin{macrocode}
\skip_horizontal:N \l_@@_left_margin_dim
\skip_horizontal:N \l_@@_extra_left_margin_dim
\c_math_toggle_token
\bool_if:NTF \l_@@_light_syntax_bool
{ \use:c { @@-light-syntax } }
{ \use:c { @@-normal-syntax } }
}
% \end{macrocode}
%
% \bigskip
% The following command |\@@_pre_array_i:w| will be used when the keyword
% |\CodeBefore| is present at the beginning of the environment.
% \begin{macrocode}
\cs_new_protected:Npn \@@_pre_array_i:w #1 \Body
{
\tl_put_right:Nn \l_@@_code_before_tl { #1 }
\bool_set_true:N \l_@@_code_before_bool
% \end{macrocode}
% We go on with |\@@_pre_array:| which will (among other) execute the
% |\CodeBefore| (specified in the key |code-before| or after the keyword
% |\CodeBefore|). By definition, the |\CodeBefore| must be executed before the
% body of the array...
% \begin{macrocode}
\@@_pre_array:
}
% \end{macrocode}
%
%
% \bigskip
% \subsection*{The \textbackslash CodeBefore}
%
% The following command will be executed if the |\CodeBefore| has to be actually executed.
% \begin{macrocode}
\cs_new_protected:Npn \@@_pre_code_before:
{
% \end{macrocode}
% First, we give values to the LaTeX counters |iRow| and |jCol|. We remind that,
% in the |\CodeBefore| (and in the |\CodeAfter|) they represent the numbers of
% rows and columns of the array (without the potential last row and last
% column). The value of |\g_@@_row_total_int| is the number of the last row
% (with potentially a last exterior row) and |\g_@@_col_total_int| is the number
% of the last column (with potentially a last exterior column).
% \begin{macrocode}
\int_set:Nn \c@iRow { \seq_item:Nn \g_@@_size_seq 2 }
\int_set:Nn \c@jCol { \seq_item:Nn \g_@@_size_seq 5 }
\int_set_eq:NN \g_@@_row_total_int { \seq_item:Nn \g_@@_size_seq 3 }
\int_set_eq:NN \g_@@_col_total_int { \seq_item:Nn \g_@@_size_seq 6 }
% \end{macrocode}
%
%
% Now, we will create all the |col| nodes and |row| nodes with the informations
% written in the |aux| file. You use the technique described in the page~1229 of
% |pgfmanual.pdf|, version~3.1.4b.
% \begin{macrocode}
\pgfsys@markposition { \@@_env: - position }
\pgfsys@getposition { \@@_env: - position } \@@_picture_position:
\pgfpicture
\pgf@relevantforpicturesizefalse
% \end{macrocode}
% First, the recreation of the |row| nodes.
% \begin{macrocode}
\int_step_inline:nnn \l_@@_first_row_int { \g_@@_row_total_int + 1 }
{
\pgfsys@getposition { \@@_env: - row - ##1 } \@@_node_position:
\pgfcoordinate { \@@_env: - row - ##1 }
{ \pgfpointdiff \@@_picture_position: \@@_node_position: }
}
% \end{macrocode}
% Now, the recreation of the |col| nodes.
% \begin{macrocode}
\int_step_inline:nnn \l_@@_first_col_int { \g_@@_col_total_int + 1 }
{
\pgfsys@getposition { \@@_env: - col - ##1 } \@@_node_position:
\pgfcoordinate { \@@_env: - col - ##1 }
{ \pgfpointdiff \@@_picture_position: \@@_node_position: }
}
% \end{macrocode}
% Now, you recreate the diagonal nodes by using the |row| nodes and the |col|
% nodes.
% \begin{macrocode}
\@@_create_diag_nodes:
% \end{macrocode}
%
% \medskip
% Now, the creation of the cell nodes |(i-j)|, and, maybe also the ``medium
% nodes'' and the ``large nodes''.
% \begin{macrocode}
\bool_if:NT \g_@@_recreate_cell_nodes_bool \@@_recreate_cell_nodes:
\endpgfpicture
% \end{macrocode}
%
% \medskip
% Now, the recreation of the nodes of the blocks \emph{which have a name}.
% \begin{macrocode}
\@@_create_blocks_nodes:
% \end{macrocode}
%
% \begin{macrocode}
\bool_if:NT \c_@@_tikz_loaded_bool
{
\tikzset
{
every~picture / .style =
{ overlay , name~prefix = \@@_env: - }
}
}
\cs_set_eq:NN \cellcolor \@@_cellcolor
\cs_set_eq:NN \rectanglecolor \@@_rectanglecolor
\cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor
\cs_set_eq:NN \rowcolor \@@_rowcolor
\cs_set_eq:NN \rowcolors \@@_rowcolors
\cs_set_eq:NN \rowlistcolors \@@_rowlistcolors
\cs_set_eq:NN \arraycolor \@@_arraycolor
\cs_set_eq:NN \columncolor \@@_columncolor
\cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
\cs_set_eq:NN \SubMatrix \@@_SubMatrix_in_code_before
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_exec_code_before:
{
\seq_gclear_new:N \g_@@_colors_seq
\bool_gset_false:N \g_@@_recreate_cell_nodes_bool
\group_begin:
% \end{macrocode}
%
% We compose the |\CodeBefore| in math mode in order to nullify the spaces put
% by the user between instructions in the |code-before|.
% \begin{macrocode}
\bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
% \end{macrocode}
%
% Here is the |\CodeBefore|. The construction is a bit complicated because
% |\l_@@_code_before_tl| may begin with keys between square brackets. Moreover,
% after the analyze of those keys, we sometimes have to decide to do \emph{not}
% execute the rest of |\l_@@_code_before_tl| (when it is asked for the creation
% of cell nodes in the |\CodeBefore|). That's why we begin with a |\q_stop|: it
% will be used to discard the rest of |\l_@@_code_before_tl|.
% \begin{macrocode}
\exp_last_unbraced:NV \@@_CodeBefore_keys: \l_@@_code_before_tl \q_stop
% \end{macrocode}
% Now, all the cells which are specified to be colored by instructions in the
% |\CodeBefore| will actually be colored. It's a two-stages mechanism because we
% want to draw all the cells with the same color at the same time to absolutely
% avoid thin white lines in some \textsc{pdf} viewers.
% \begin{macrocode}
\@@_actually_color:
\bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
\group_end:
\bool_if:NT \g_@@_recreate_cell_nodes_bool
{ \tl_put_left:Nn \@@_node_for_cell: \@@_patch_node_for_cell: }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / CodeBefore }
{
create-cell-nodes .bool_gset:N = \g_@@_recreate_cell_nodes_bool ,
create-cell-nodes .default:n = true ,
sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } ,
sub-matrix .value_required:n = true ,
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
delimiters / color .value_required:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~CodeAfter }
}
% \end{macrocode}
%
% \begin{macrocode}
\NewDocumentCommand \@@_CodeBefore_keys: { O { } }
{
\keys_set:nn { NiceMatrix / CodeBefore } { #1 }
\@@_CodeBefore:w
}
% \end{macrocode}
%
% We have extracted the options of the keyword |\CodeBefore| in order to see
% whether the key |create-cell-nodes| has been used. Now, you can execute the
% rest of the |\CodeAfter|, excepted, of course, if we are in the first
% compilation.
% \begin{macrocode}
\cs_new_protected:Npn \@@_CodeBefore:w #1 \q_stop
{
\bool_if:NT \g_@@_aux_found_bool
{
\@@_pre_code_before:
#1
}
}
% \end{macrocode}
%
% \bigskip
%
%
% \bigskip
% By default, if the user uses the |\CodeBefore|, only the |col| nodes, |row|
% nodes and |diag| nodes are available in that |\CodeBefore|. With the key
% |create-cell-nodes|, the cell nodes, that is to say the nodes of the form
% |(i-j)| (but not the extra nodes) are also available because those nodes also
% are recreated and that recreation is done by the following command.
% \begin{macrocode}
\cs_new_protected:Npn \@@_recreate_cell_nodes:
{
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
{
\pgfsys@getposition { \@@_env: - ##1 - base } \@@_node_position:
\pgfcoordinate { \@@_env: - row - ##1 - base }
{ \pgfpointdiff \@@_picture_position: \@@_node_position: }
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
{
\cs_if_exist:cT
{ pgf @ sys @ pdf @ mark @ pos @ \@@_env: - ##1 - ####1 - NW }
{
\pgfsys@getposition
{ \@@_env: - ##1 - ####1 - NW }
\@@_node_position:
\pgfsys@getposition
{ \@@_env: - ##1 - ####1 - SE }
\@@_node_position_i:
\@@_pgf_rect_node:nnn
{ \@@_env: - ##1 - ####1 }
{ \pgfpointdiff \@@_picture_position: \@@_node_position: }
{ \pgfpointdiff \@@_picture_position: \@@_node_position_i: }
}
}
}
\int_step_inline:nn \c@iRow
{
\pgfnodealias
{ \@@_env: - ##1 - last }
{ \@@_env: - ##1 - \int_use:N \c@jCol }
}
\int_step_inline:nn \c@jCol
{
\pgfnodealias
{ \@@_env: - last - ##1 }
{ \@@_env: - \int_use:N \c@iRow - ##1 }
}
\@@_create_extra_nodes:
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_blocks_nodes:
{
\pgfpicture
\pgf@relevantforpicturesizefalse
\pgfrememberpicturepositiononpagetrue
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq
{ \@@_create_one_block_node:nnnnn ##1 }
\endpgfpicture
}
% \end{macrocode}
%
% The following command is called |\@@_create_one_block_node:nnnnn| but, in
% fact, it creates a node only if the last argument (|#5|) which is the name of
% the block, is not empty.\footnote{Moreover, there is also in the list
% |\g_@@_pos_of_blocks_seq| the positions of the dotted lines (created by
% |\Cdots|, etc.) and, for these entries, there is, of course, no name (the
% fifth component is empty).}
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_one_block_node:nnnnn #1 #2 #3 #4 #5
{
\tl_if_empty:nF { #5 }
{
\@@_qpoint:n { col - #2 }
\dim_set_eq:NN \l_tmpa_dim \pgf@x
\@@_qpoint:n { #1 }
\dim_set_eq:NN \l_tmpb_dim \pgf@y
\@@_qpoint:n { col - \int_eval:n { #4 + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@x
\@@_qpoint:n { \int_eval:n { #3 + 1 } }
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@y
\@@_pgf_rect_node:nnnnn
{ \@@_env: - #5 }
{ \dim_use:N \l_tmpa_dim }
{ \dim_use:N \l_tmpb_dim }
{ \dim_use:N \l_@@_tmpc_dim }
{ \dim_use:N \l_@@_tmpd_dim }
}
}
% \end{macrocode}
%
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_for_revtex:
{
\cs_set_eq:NN \@addamp \@addamp@LaTeX
\cs_set_eq:NN \insert@column \insert@column@array
\cs_set_eq:NN \@classx \@classx@array
\cs_set_eq:NN \@xarraycr \@xarraycr@array
\cs_set_eq:NN \@arraycr \@arraycr@array
\cs_set_eq:NN \@xargarraycr \@xargarraycr@array
\cs_set_eq:NN \array \array@array
\cs_set_eq:NN \@array \@array@array
\cs_set_eq:NN \@tabular \@tabular@array
\cs_set_eq:NN \@mkpream \@mkpream@array
\cs_set_eq:NN \endarray \endarray@array
\cs_set:Npn \@tabarray { \@ifnextchar [ { \@array } { \@array [ c ] } }
\cs_set:Npn \endtabular { \endarray $\egroup} % $
}
% \end{macrocode}
%
% \bigskip
% \subsection*{The environment \{NiceArrayWithDelims\}}
%
% \begin{macrocode}
\NewDocumentEnvironment { NiceArrayWithDelims }
{ m m O { } m ! O { } t \CodeBefore }
{
\bool_if:NT \c_@@_revtex_bool \@@_patch_for_revtex:
% \end{macrocode}
%
% \begin{macrocode}
\@@_provide_pgfsyspdfmark:
\bool_if:NT \c_@@_footnote_bool \savenotes
% \end{macrocode}
%
% The aim of the following |\bgroup| (the corresponding |\egroup| is, of course,
% at the end of the environment) is to be able to put an exposant to a matrix in
% a mathematical formula.
% \begin{macrocode}
\bgroup
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\tl_gset:Nn \g_@@_left_delim_tl { #1 }
\tl_gset:Nn \g_@@_right_delim_tl { #2 }
\tl_gset:Nn \g_@@_preamble_tl { #4 }
% \end{macrocode}
%
%
% \bigskip
%
% \begin{macrocode}
\int_gzero:N \g_@@_block_box_int
\dim_zero:N \g_@@_width_last_col_dim
\dim_zero:N \g_@@_width_first_col_dim
\bool_gset_false:N \g_@@_row_of_col_done_bool
\str_if_empty:NT \g_@@_name_env_str
{ \str_gset:Nn \g_@@_name_env_str { NiceArrayWithDelims } }
\bool_if:NTF \l_@@_NiceTabular_bool
\mode_leave_vertical:
\@@_test_if_math_mode:
\bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } }
\bool_set_true:N \l_@@_in_env_bool
% \end{macrocode}
% The command |\CT@arc@| contains the instruction of color for the rules of the
% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|}. This command is used by |\CT@arc@| but
% we use it also for compatibility with \pkg{colortbl}. But we want also to be
% able to use color for the rules of the array when \pkg{colortbl} is \emph{not}
% loaded. That's why we do the following instruction which is in the patch of
% the beginning of arrays done by \pkg{colortbl}. Of course, we restore the
% value of |\CT@arc@| at the end of our environment.
% \begin{macrocode}
\cs_gset_eq:NN \@@_old_CT@arc@ \CT@arc@
% \end{macrocode}
%
% We deactivate Tikz externalization because we will use \textsc{pgf} pictures
% with the options |overlay| and |remember picture| (or equivalent forms). We
% deactivate with |\tikzexternaldisable| and not with
% |\tikzset{external/export=false}| which is \emph{not} equivalent.
% \begin{macrocode}
\cs_if_exist:NT \tikz@library@external@loaded
{
\tikzexternaldisable
\cs_if_exist:NT \ifstandalone
{ \tikzset { external / optimize = false } }
}
% \end{macrocode}
%
% We increment the counter |\g_@@_env_int| which counts the environments
% of the package.
% \begin{macrocode}
\int_gincr:N \g_@@_env_int
\bool_if:NF \l_@@_block_auto_columns_width_bool
{ \dim_gzero_new:N \g_@@_max_cell_width_dim }
% \end{macrocode}
%
%
% The sequence |\g_@@_blocks_seq| will contain the carateristics of the blocks
% (specified by |\Block|) of the array. The sequence |\g_@@_pos_of_blocks_seq|
% will contain only the position of the blocks (except the blocks with the key
% |hvlines|).
% \begin{macrocode}
\seq_gclear:N \g_@@_blocks_seq
\seq_gclear:N \g_@@_pos_of_blocks_seq
% \end{macrocode}
% In fact, the sequence |\g_@@_pos_of_blocks_seq| will also contain the
% positions of the cells with a |\diagbox|.
%
% \begin{macrocode}
\seq_gclear:N \g_@@_pos_of_stroken_blocks_seq
\seq_gclear:N \g_@@_pos_of_xdots_seq
\tl_gclear_new:N \g_@@_code_before_tl
\tl_gclear:N \g_@@_row_style_tl
% \end{macrocode}
%
% \bigskip
% We load all the informations written in the |aux| file during previous
% compilations corresponding to the current environment.
% \begin{macrocode}
\bool_gset_false:N \g_@@_aux_found_bool
\tl_if_exist:cT { c_@@ _ \int_use:N \g_@@_env_int _ tl }
{
\bool_gset_true:N \g_@@_aux_found_bool
\use:c { c_@@ _ \int_use:N \g_@@_env_int _ tl }
}
% \end{macrocode}
% Now, we prepare the token list for the instructions that we will have to write
% on the |aux| file at the end of the environment.
% \begin{macrocode}
\tl_gclear:N \g_@@_aux_tl
% \end{macrocode}
%
% \begin{macrocode}
\tl_if_empty:NF \g_@@_code_before_tl
{
\bool_set_true:N \l_@@_code_before_bool
\tl_put_right:NV \l_@@_code_before_tl \g_@@_code_before_tl
}
% \end{macrocode}
%
% The set of keys is not exactly the same for |{NiceArray}| and for the variants
% of |{NiceArray}| (|{pNiceArray}|, |{bNiceArray}|, etc.) because, for
% |{NiceArray}|, we have the options |t|, |c|, |b| and |baseline|.
% \begin{macrocode}
\bool_if:NTF \l_@@_NiceArray_bool
{ \keys_set:nn { NiceMatrix / NiceArray } }
{ \keys_set:nn { NiceMatrix / pNiceArray } }
{ #3 , #5 }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\tl_if_empty:NF \l_@@_rules_color_tl
{ \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop }
% \end{macrocode}
%
% \bigskip
% The argument |#6| is the last argument of |{NiceArrayWithDelims}|. With that
% argument of type ``|t \CodeBefore|'', we test whether there is the keyword
% |\CodeBefore| at the beginning of the body of the environment. If that keyword
% is present, we have now to extract all the content between that keyword
% |\CodeBefore| and the (other) keyword |\Body|. It's the job that will do the
% command |\@@_pre_array_i:w|. After that job, the command |\@@_pre_array_i:w|
% will go on with |\@@_pre_array:|.
% \begin{macrocode}
\IfBooleanTF { #6 } \@@_pre_array_i:w \@@_pre_array:
}
% \end{macrocode}
%
% \begin{macrocode}
{
\bool_if:NTF \l_@@_light_syntax_bool
{ \use:c { end @@-light-syntax } }
{ \use:c { end @@-normal-syntax } }
\c_math_toggle_token
\skip_horizontal:N \l_@@_right_margin_dim
\skip_horizontal:N \l_@@_extra_right_margin_dim
\hbox_set_end:
% \end{macrocode}
% End of the construction of the array (in the box |\l_@@_the_array_box|).
%
% \bigskip
% If the user has used the key |width| without any column |X|, we raise an error.
% \begin{macrocode}
\bool_if:NT \l_@@_width_used_bool
{
\int_compare:nNnT \g_@@_total_X_weight_int = 0
{ \@@_error:n { width~without~X~columns } }
}
% \end{macrocode}
%
% \bigskip
% Now, if there is at least one |X|-column in the environment, we compute the
% width that those columns will have (in the next compilation). In fact,
% |l_@@_X_columns_dim| will be the width of a column of weight $1$. For a
% |X|-column of weight~$n$, the width will be |l_@@_X_columns_dim| multiplied
% by~$n$.
% \begin{macrocode}
\int_compare:nNnT \g_@@_total_X_weight_int > 0
{
\tl_gput_right:Nx \g_@@_aux_tl
{
\bool_set_true:N \l_@@_X_columns_aux_bool
\dim_set:Nn \l_@@_X_columns_dim
{
\dim_compare:nNnTF
{
\dim_abs:n
{ \l_@@_width_dim - \box_wd:N \l_@@_the_array_box }
}
<
{ 0.001 pt }
{ \dim_use:N \l_@@_X_columns_dim }
{
\dim_eval:n
{
( \l_@@_width_dim - \box_wd:N \l_@@_the_array_box )
/ \int_use:N \g_@@_total_X_weight_int
+ \l_@@_X_columns_dim
}
}
}
}
}
% \end{macrocode}
%
% \bigskip
% It the user has used the key |last-row| with a value, we control that the
% given value is correct (since we have just constructed the array, we know the
% real number of rows of the array).
% \begin{macrocode}
\int_compare:nNnT \l_@@_last_row_int > { -2 }
{
\bool_if:NF \l_@@_last_row_without_value_bool
{
\int_compare:nNnF \l_@@_last_row_int = \c@iRow
{
\@@_error:n { Wrong~last~row }
\int_gset_eq:NN \l_@@_last_row_int \c@iRow
}
}
}
% \end{macrocode}
%
% Now, the definition of |\c@jCol| and |\g_@@_col_total_int| change: |\c@jCol|
% will be the number of columns without the ``last column'';
% |\g_@@_col_total_int| will be the number of columns with this ``last
% column''.\footnote{We remind that the potential ``first column'' (exterior)
% has the number~$0$.}
% \begin{macrocode}
\int_gset_eq:NN \c@jCol \g_@@_col_total_int
\bool_if:nTF \g_@@_last_col_found_bool
{ \int_gdecr:N \c@jCol }
{
\int_compare:nNnT \l_@@_last_col_int > { -1 }
{ \@@_error:n { last~col~not~used } }
}
% \end{macrocode}
%
% We fix also the value of |\c@iRow| and |\g_@@_row_total_int| with the
% same principle.
% \begin{macrocode}
\int_gset_eq:NN \g_@@_row_total_int \c@iRow
\int_compare:nNnT \l_@@_last_row_int > { -1 } { \int_gdecr:N \c@iRow }
% \end{macrocode}
%
%
% \bigskip
% \textbf{Now, we begin the real construction in the output flow of TeX}. First, we take
% into account a potential ``first column'' (we remind that this ``first
% column'' has been constructed in an overlapping position and that we have
% computed its width in |\g_@@_width_first_col_dim|: see
% p.~\pageref{overlap-left}).
% \begin{macrocode}
\int_compare:nNnT \l_@@_first_col_int = 0
{
\skip_horizontal:N \col@sep
\skip_horizontal:N \g_@@_width_first_col_dim
}
% \end{macrocode}
%
% The construction of the real box is different when |\l_@@_NiceArray_bool| is
% true (|{NiceArray}| or |{NiceTabular}|) and in the other environments because,
% in |{NiceArray}| or |{NiceTabular}|, we have no delimiter to put (but we have
% tabular notes to put). We begin with this case.
%
% \begin{macrocode}
\bool_if:NTF \l_@@_NiceArray_bool
{
\str_case:VnF \l_@@_baseline_tl
{
b \@@_use_arraybox_with_notes_b:
c \@@_use_arraybox_with_notes_c:
}
\@@_use_arraybox_with_notes:
}
% \end{macrocode}
%
% Now, in the case of an environment |{pNiceArray}|, |{bNiceArray}|, etc. We
% compute |\l_tmpa_dim| which is the total height of the ``first row'' above the
% array (when the key |first-row| is used).
% \begin{macrocode}
{
\int_compare:nNnTF \l_@@_first_row_int = 0
{
\dim_set_eq:NN \l_tmpa_dim \g_@@_dp_row_zero_dim
\dim_add:Nn \l_tmpa_dim \g_@@_ht_row_zero_dim
}
{ \dim_zero:N \l_tmpa_dim }
% \end{macrocode}
%
% We compute |\l_tmpb_dim| which is the total height of the ``last row''
% below the array (when the key |last-row| is used). A value of $-2$ for
% |\l_@@_last_row_int| means that there is no ``last row''.\footnote{A value of
% $-1$ for |\l_@@_last_row_int| means that there is a ``last row'' but the
% the user have not set the value with the option |last row| (and we are in the
% first compilation).}
% \begin{macrocode}
\int_compare:nNnTF \l_@@_last_row_int > { -2 }
{
\dim_set_eq:NN \l_tmpb_dim \g_@@_ht_last_row_dim
\dim_add:Nn \l_tmpb_dim \g_@@_dp_last_row_dim
}
{ \dim_zero:N \l_tmpb_dim }
% \end{macrocode}
%
% \begin{macrocode}
\hbox_set:Nn \l_tmpa_box
{
\c_math_toggle_token
\tl_if_empty:NF \l_@@_delimiters_color_tl
{ \color { \l_@@_delimiters_color_tl } }
\exp_after:wN \left \g_@@_left_delim_tl
\vcenter
{
% \end{macrocode}
% We take into account the ``first row'' (we have previously computed its total
% height in |\l_tmpa_dim|). The |\hbox:n| (or |\hbox|) is necessary here. There
% was a bug in the following line (corrected the 2021/11/23).
% \begin{macrocode}
\skip_vertical:n { -\l_tmpa_dim - \arrayrulewidth }
\hbox
{
\bool_if:NTF \l_@@_NiceTabular_bool
{ \skip_horizontal:N -\tabcolsep }
{ \skip_horizontal:N -\arraycolsep }
\@@_use_arraybox_with_notes_c:
\bool_if:NTF \l_@@_NiceTabular_bool
{ \skip_horizontal:N -\tabcolsep }
{ \skip_horizontal:N -\arraycolsep }
}
% \end{macrocode}
% We take into account the ``last row'' (we have previously computed its total
% height in |\l_tmpb_dim|). There was a bug in the following line (corrected the
% 2021/11/23).
% \begin{macrocode}
\skip_vertical:n { -\l_tmpb_dim + \arrayrulewidth }
}
% \end{macrocode}
% Curiously, we have to put again the following specification of color.
% Otherwise, with XeLaTeX (and not with the other engines), the closing
% delimiter is not colored.
% \begin{macrocode}
\tl_if_empty:NF \l_@@_delimiters_color_tl
{ \color { \l_@@_delimiters_color_tl } }
\exp_after:wN \right \g_@@_right_delim_tl
\c_math_toggle_token
}
% \end{macrocode}
% Now, the box |\l_tmpa_box| is created with the correct delimiters.
%
% \smallskip
% We will put the box in the TeX flow. However, we have a small work to do
% when the option |delimiters/max-width| is used.
% \begin{macrocode}
\bool_if:NTF \l_@@_delimiters_max_width_bool
{
\@@_put_box_in_flow_bis:nn
\g_@@_left_delim_tl \g_@@_right_delim_tl
}
\@@_put_box_in_flow:
}
% \end{macrocode}
%
% We take into account a potential ``last column'' (this ``last column'' has
% been constructed in an overlapping position and we have computed its width in
% |\g_@@_width_last_col_dim|: see p.~\pageref{overlap-right}).
% \begin{macrocode}
\bool_if:NT \g_@@_last_col_found_bool
{
\skip_horizontal:N \g_@@_width_last_col_dim
\skip_horizontal:N \col@sep
}
\bool_if:NF \l_@@_Matrix_bool
{
\int_compare:nNnT \c@jCol < \g_@@_static_num_of_col_int
{ \@@_error:n { columns~not~used } }
}
\group_begin:
\globaldefs = 1
\@@_msg_redirect_name:nn { columns~not~used } { error }
\group_end:
\@@_after_array:
% \end{macrocode}
% The aim of the following |\egroup| (the corresponding |\bgroup| is, of course,
% at the beginning of the environment) is to be able to put an exposant to a matrix in
% a mathematical formula.
% \begin{macrocode}
\egroup
% \end{macrocode}
%
% \bigskip
% We want to write on the |aux| file all the informations corresponding to the
% current environment.
% \begin{macrocode}
\iow_now:Nn \@mainaux { \ExplSyntaxOn }
\iow_now:Nn \@mainaux { \char_set_catcode_space:n { 32 } }
\iow_now:Nx \@mainaux
{
\tl_gset:cn { c_@@_ \int_use:N \g_@@_env_int _ tl }
{ \exp_not:V \g_@@_aux_tl }
}
\iow_now:Nn \@mainaux { \ExplSyntaxOff }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\bool_if:NT \c_@@_footnote_bool \endsavenotes
}
% \end{macrocode}
% This is the end of the environment |{NiceArrayWithDelims}|.
%
% \vspace{1cm}
% \subsection*{We construct the preamble of the array}
%
% The transformation of the preamble is an operation in several steps.
%
% \bigskip
% The preamble given by the final user is in |\g_@@_preamble_tl| and the modified
% version will be stored in |\g_@@_preamble_tl| also.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_construct_preamble:
{
% \end{macrocode}
% First, we will do an ``expansion'' of the preamble with the tools of the
% package \pkg{array} itself. This ``expansion'' will expand all the constructions
% with |*| and with all column types (defined by the user or by various packages
% using |\newcolumntype|).
%
% Since we use the tools of \pkg{array} to do this expansion, we will have a
% programmation which is not in the style of the L3 programming layer.
%
%
% \bigskip
% We redefine the column types |w| and |W|. We use |\@@_newcolumntype| instead
% of |\newcolumtype| because we don't want warnings for column types already
% defined. These redefinitions are in fact \emph{protections} of the letters |w|
% and |W|. We don't want these columns type expanded because we will do the
% patch ourselves after. We want to be able to use the standard column types |w|
% and |W| in potential |{tabular}| of \pkg{array} in some cells of our array.
% That's why we do those redefinitions in a TeX group.
% \begin{macrocode}
\group_begin:
% \end{macrocode}
%
% If we are in an environment without explicit preamble, we have nothing to do
% (excepted the treatment on both sides of the preamble which will be done at
% the end).
% \begin{macrocode}
\bool_if:NF \l_@@_Matrix_bool
{
\@@_newcolumntype w [ 2 ] { \@@_w: { ##1 } { ##2 } }
\@@_newcolumntype W [ 2 ] { \@@_W: { ##1 } { ##2 } }
% \end{macrocode}
%
% \bigskip
% If the package \pkg{varwidth} has defined the column type |V|, we protect from
% expansion by redefining it to |\@@_V:| (which will be catched by our system).
% \begin{macrocode}
\cs_if_exist:NT \NC@find@V { \@@_newcolumntype V { \@@_V: } }
% \end{macrocode}
%
% First, we have to store our preamble in the token register |\@temptokena|
% (those ``token registers'' are \emph{not} supported by the L3 programming layer).
% \begin{macrocode}
\exp_args:NV \@temptokena \g_@@_preamble_tl
% \end{macrocode}
% Initialisation of a flag used by \pkg{array} to detect the end of the expansion.
% \begin{macrocode}
\@tempswatrue
% \end{macrocode}
% The following line actually does the expansion (it's has been copied from
% |array.sty|). The expanded version is still in |\@temptokena|.
% \begin{macrocode}
\@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list }
% \end{macrocode}
%
%
% \bigskip
% Now, we have to ``patch'' that preamble by transforming some columns.
% We will insert in the TeX flow the preamble in its actual form (that is to say
% after the ``expansion'') following by a marker |\q_stop| and we will consume
% these tokens constructing the (new form of the) preamble in
% |\g_@@_preamble_tl|. This is done recursively with the command
% |\@@_patch_preamble:n|. In the same time, we will count the columns with the
% counter |\c@jCol|.
% \begin{macrocode}
\int_gzero:N \c@jCol
\tl_gclear:N \g_@@_preamble_tl
% \end{macrocode}
% |\g_tmpb_bool| will be raised if you have a \verb+|+ at the end of the preamble.
% \begin{macrocode}
\bool_gset_false:N \g_tmpb_bool
\tl_if_eq:NnTF \l_@@_vlines_clist { all }
{
\tl_gset:Nn \g_@@_preamble_tl
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
{
\clist_if_in:NnT \l_@@_vlines_clist 1
{
\tl_gset:Nn \g_@@_preamble_tl
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
}
% \end{macrocode}
% The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns
% where you will to have to draw vertical lines in the potential sub-matrices
% (hence the name |vlism|).
% \begin{macrocode}
\seq_clear:N \g_@@_cols_vlism_seq
% \end{macrocode}
% The counter |\l_tmpa_int| will count the number of consecutive occurrences
% of the symbol \verb+|+.
% \begin{macrocode}
\int_zero:N \l_tmpa_int
% \end{macrocode}
% Now, we actually patch the preamble (and it is constructed in
% |\g_@@_preamble_tl|).
% \begin{macrocode}
\exp_after:wN \@@_patch_preamble:n \the \@temptokena \q_stop
\int_gset_eq:NN \g_@@_static_num_of_col_int \c@jCol
}
% \end{macrocode}
%
% \medskip
% Now, we replace |\columncolor| by |\@@_columncolor_preamble|.
% \begin{macrocode}
\bool_if:NT \l_@@_colortbl_like_bool
{
\regex_replace_all:NnN
\c_@@_columncolor_regex
{ \c { @@_columncolor_preamble } }
\g_@@_preamble_tl
}
% \end{macrocode}
%
% \medskip
% Now, we can close the TeX group which was opened for the redefinition of
% the columns of type |w| and~|W|.
% \begin{macrocode}
\group_end:
% \end{macrocode}
%
% \medskip
% If there was delimiters at the beginning or at the end of the preamble, the
% environment |{NiceArray}| is transformed into an environment |{xNiceMatrix}|.
% \begin{macrocode}
\bool_lazy_or:nnT
{ ! \str_if_eq_p:Vn \g_@@_left_delim_tl { . } }
{ ! \str_if_eq_p:Vn \g_@@_right_delim_tl { . } }
{ \bool_set_false:N \l_@@_NiceArray_bool }
% \end{macrocode}
%
% \medskip
% We want to remind whether there is a specifier \verb+|+ at the end of the preamble.
% \begin{macrocode}
\bool_if:NT \g_tmpb_bool { \bool_set_true:N \l_@@_bar_at_end_of_pream_bool }
% \end{macrocode}
%
% \bigskip
% We complete the preamble with the potential ``exterior columns'' (on both sides).
% \begin{macrocode}
\int_compare:nNnTF \l_@@_first_col_int = 0
{ \tl_gput_left:NV \g_@@_preamble_tl \c_@@_preamble_first_col_tl }
{
\bool_lazy_all:nT
{
\l_@@_NiceArray_bool
{ \bool_not_p:n \l_@@_NiceTabular_bool }
{ \tl_if_empty_p:N \l_@@_vlines_clist }
{ \bool_not_p:n \l_@@_exterior_arraycolsep_bool }
}
{ \tl_gput_left:Nn \g_@@_preamble_tl { @ { } } }
}
\int_compare:nNnTF \l_@@_last_col_int > { -1 }
{ \tl_gput_right:NV \g_@@_preamble_tl \c_@@_preamble_last_col_tl }
{
\bool_lazy_all:nT
{
\l_@@_NiceArray_bool
{ \bool_not_p:n \l_@@_NiceTabular_bool }
{ \tl_if_empty_p:N \l_@@_vlines_clist }
{ \bool_not_p:n \l_@@_exterior_arraycolsep_bool }
}
{ \tl_gput_right:Nn \g_@@_preamble_tl { @ { } } }
}
% \end{macrocode}
% We add a last column to raise a good error message when the user puts more
% columns than allowed by its preamble. However, for technical reasons, it's not
% possible to do that in |{NiceTabular*}| (|\l_@@_tabular_width_dim|=0pt).
% \begin{macrocode}
\dim_compare:nNnT \l_@@_tabular_width_dim = \c_zero_dim
{
\tl_gput_right:Nn \g_@@_preamble_tl
{ > { \@@_error_too_much_cols: } l }
}
}
% \end{macrocode}
%
% \bigskip
% The command |\@@_patch_preamble:n| is the main function for the transformation
% of the preamble. It is recursive.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble:n #1
{
\str_case:nnF { #1 }
{
c { \@@_patch_preamble_i:n #1 }
l { \@@_patch_preamble_i:n #1 }
r { \@@_patch_preamble_i:n #1 }
> { \@@_patch_preamble_ii:nn #1 }
! { \@@_patch_preamble_ii:nn #1 }
@ { \@@_patch_preamble_ii:nn #1 }
| { \@@_patch_preamble_iii:n #1 }
p { \@@_patch_preamble_iv:n #1 }
b { \@@_patch_preamble_iv:n #1 }
m { \@@_patch_preamble_iv:n #1 }
\@@_V: { \@@_patch_preamble_v:n }
V { \@@_patch_preamble_v:n }
\@@_w: { \@@_patch_preamble_vi:nnnn { } #1 }
\@@_W: { \@@_patch_preamble_vi:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
\@@_S: { \@@_patch_preamble_vii:n }
( { \@@_patch_preamble_viii:nn #1 }
[ { \@@_patch_preamble_viii:nn #1 }
\{ { \@@_patch_preamble_viii:nn #1 }
) { \@@_patch_preamble_ix:nn #1 }
] { \@@_patch_preamble_ix:nn #1 }
\} { \@@_patch_preamble_ix:nn #1 }
X { \@@_patch_preamble_x:n }
% \end{macrocode}
% When \pkg{tabularx} is loaded, a local redefinition of the specifier |X| is
% done to replace |X| by |\@@_X|. Thus, our column type |X| will be used in the
% |{NiceTabularX}|.
% \begin{macrocode}
\@@_X { \@@_patch_preamble_x:n }
\q_stop { }
}
{
\str_case_e:nnF { #1 }
{
\l_@@_letter_for_dotted_lines_str
{ \@@_patch_preamble_xii:n #1 }
\l_@@_letter_vlism_tl
{
\seq_gput_right:Nx \g_@@_cols_vlism_seq
{ \int_eval:n { \c@jCol + 1 } }
\tl_gput_right:Nx \g_@@_preamble_tl
{ \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } }
\@@_patch_preamble:n
}
}
% \end{macrocode}
% Now the case of a letter set by the final user for a customized rule. Such
% customized rule is defined by using the key |custom-line| in
% |\NiceMatrixOptions|. That key takes in as value a list of \textsl{key=value}
% pairs. Among the keys avalaible in that list, there is the key |letter|. All
% the letters defined by this way by the final user for such customized rules
% are added in the set of keys |{NiceMatrix/ColumnTypes}|. That set of keys is
% used to store the characteristics of those types of rules for convenience: the
% keys of that set of keys won't never be used as keys by the final user (he
% will use, instead, letters in the preamble of its array).
% \begin{macrocode}
{
\keys_set_known:nnN { NiceMatrix / ColumnTypes } { #1 } \l_tmpa_tl
\tl_if_empty:NTF \l_tmpa_tl
\@@_patch_preamble:n
{ \@@_fatal:nn { unknown~column~type } { #1 } }
}
}
}
% \end{macrocode}
%
%
% \bigskip
% Now, we will list all the auxiliary functions for the different types of
% entries in the preamble of the array.
%
% \medskip
% For |c|, |l| and |r|
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_i:n #1
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
> { \@@_cell_begin:w \str_set:Nn \l_@@_hpos_cell_str { #1 } }
#1
< \@@_cell_end:
}
% \end{macrocode}
%
% We increment the counter of columns and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c@jCol
\@@_patch_preamble_xi:n
}
% \end{macrocode}
%
% \medskip
% For |>|, |!| and |@|
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_ii:nn #1 #2
{
\tl_gput_right:Nn \g_@@_preamble_tl { #1 { #2 } }
\@@_patch_preamble:n
}
% \end{macrocode}
%
%
% \medskip
% For \verb+|+
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_iii:n #1
{
% \end{macrocode}
% |\l_tmpa_int| is the number of successive occurrences of \verb+|+
% \begin{macrocode}
\int_incr:N \l_tmpa_int
\@@_patch_preamble_iii_i:n
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_iii_i:n #1
{
\str_if_eq:nnTF { #1 } |
{ \@@_patch_preamble_iii:n | }
{
\tl_gput_right:Nx \g_@@_preamble_tl
{
\exp_not:N !
{
\skip_horizontal:n
{
% \end{macrocode}
% Here, the command |\dim_eval:n| is mandatory.
% \begin{macrocode}
\dim_eval:n
{
\arrayrulewidth * \l_tmpa_int
+ \doublerulesep * ( \l_tmpa_int - 1)
}
}
}
}
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{
\@@_vline:n
{
position = \int_eval:n { \c@jCol + 1 } ,
multiplicity = \int_use:N \l_tmpa_int ,
}
% \end{macrocode}
% We don't have provided value for |start| nor for |end|, which means that the
% rule will cover (potentially) all the rows of the array.
%
% \begin{macrocode}
}
\int_zero:N \l_tmpa_int
\str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool }
\@@_patch_preamble:n #1
}
}
% \end{macrocode}
%
% \begin{macrocode}
\bool_new:N \l_@@_bar_at_end_of_pream_bool
% \end{macrocode}
%
% \bigskip
% The specifier |p| (and also the specifiers |m| and |b|) have an optional
% argument between square brackets for a list of \emph{key}-\emph{value} pairs.
% Here are the corresponding keys. This set of keys will also be used by the |X|
% columns.
% \begin{macrocode}
\keys_define:nn { WithArrows / p-column }
{
r .code:n = \str_set:Nn \l_@@_hpos_col_str { r } ,
r .value_forbidden:n = true ,
c .code:n = \str_set:Nn \l_@@_hpos_col_str { c } ,
c .value_forbidden:n = true ,
l .code:n = \str_set:Nn \l_@@_hpos_col_str { l } ,
l .value_forbidden:n = true ,
si .code:n = \str_set:Nn \l_@@_hpos_col_str { si } ,
si .value_forbidden:n = true ,
p .code:n = \str_set:Nn \l_@@_vpos_col_str { p } ,
p .value_forbidden:n = true ,
t .meta:n = p ,
m .code:n = \str_set:Nn \l_@@_vpos_col_str { m } ,
m .value_forbidden:n = true ,
b .code:n = \str_set:Nn \l_@@_vpos_col_str { b } ,
b .value_forbidden:n = true ,
}
% \end{macrocode}
%
%
% \medskip
% For |p|, |b| and |m|. The argument |#1| is that value : |p|, |b| or |m|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_iv:n #1
{
\str_set:Nn \l_@@_vpos_col_str { #1 }
% \end{macrocode}
% Now, you look for a potential character |[| after the letter of the specifier
% (for the options).
% \begin{macrocode}
\@@_patch_preamble_iv_i:n
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_iv_i:n #1
{
\str_if_eq:nnTF { #1 } { [ }
{ \@@_patch_preamble_iv_ii:w [ }
{ \@@_patch_preamble_iv_ii:w [ ] { #1 } }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_iv_ii:w [ #1 ]
{ \@@_patch_preamble_iv_iii:nn { #1 } }
% \end{macrocode}
%
% \medskip
% |#1| is the optional argument of the specifier (a list of
% \emph{key}-\emph{value} pairs).
%
% |#2| is the mandatory argument of the specifier: the width of the column.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_iv_iii:nn #1 #2
{
% \end{macrocode}
% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is
% the initial value), |l|, |c| and |r| (when the user has used the corresponding
% key in the optional argument of the specifier).
% \begin{macrocode}
\str_set:Nn \l_@@_hpos_col_str { j }
\keys_set:nn { WithArrows / p-column } { #1 }
\@@_patch_preamble_iv_iv:nn { #2 } { minipage }
}
% \end{macrocode}
%
% \medskip
% The first argument is the width of the column. The second is the type of
% environment: |minipage| or |varwidth|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_iv_iv:nn #1 #2
{
\use:x
{
\@@_patch_preamble_iv_v:nnnnnnnn
{ \str_if_eq:VnTF \l_@@_vpos_col_str { p } { t } { b } }
{ \dim_eval:n { #1 } }
{
% \end{macrocode}
% The parameter |\l_@@_hpos_col_str| (as |\l_@@_vpos_col_str|) exists only
% during the construction of the preamble. During the composition of the array
% itself, you will have, in each cell, the parameter |\l_@@_hpos_cell_str| which
% will provide the horizontal alignment of the column to which belongs the cell.
% \begin{macrocode}
\str_if_eq:VnTF \l_@@_hpos_col_str j
{ \str_set:Nn \exp_not:N \l_@@_hpos_cell_str { c } }
{
\str_set:Nn \exp_not:N \l_@@_hpos_cell_str
{ \l_@@_hpos_col_str }
}
\str_case:Vn \l_@@_hpos_col_str
{
c { \exp_not:N \centering }
l { \exp_not:N \raggedright }
r { \exp_not:N \raggedleft }
}
}
{ \str_if_eq:VnT \l_@@_vpos_col_str { m } \@@_center_cell_box: }
{ \str_if_eq:VnT \l_@@_hpos_col_str { si } \siunitx_cell_begin:w }
{ \str_if_eq:VnT \l_@@_hpos_col_str { si } \siunitx_cell_end: }
{ #2 }
{
\str_case:VnF \l_@@_hpos_col_str
{
{ j } { c }
{ si } { c }
}
{ \l_@@_hpos_col_str }
}
}
% \end{macrocode}
%
% We increment the counter of columns, and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c@jCol
\@@_patch_preamble_xi:n
}
% \end{macrocode}
%
% \medskip
% |#1| is the optional argument of |{minipage}| (or |{varwidth}|): |t| of |b|.
% Indeed, for the columns of type |m|, we use the value |b| here because there
% is a special post-action in order to center vertically the box (see |#4|).
%
% |#2| is the width of the |{minipage}| (or |{varwidth}|), that is to say also
% the width of the column.
%
% |#3| is the coding for the horizontal position of the content of the cell
% (|\centering|, |\raggedright|, |\raggedleft| or nothing). It's also possible
% to put in that |#3| some code to fix the value of |\l_@@_hpos_cell_str| which
% will be available in each cell of the column.
%
% |#4| is an extra-code which contains |\@@_center_cell_box:| (when the column
% is a |m| column) or nothing (in the other cases).
%
% |#5| is a code put just before the |c| (or |r| or |l|: see |#8|).
%
% |#6| is a code put just after the |c| (or |r| or |l|: see |#8|).
%
% |#7| is the type of environment: |minipage| or |varwidth|.
%
% |#8| is the lettre |c| or |r| or |l| which is the basic specificier of column
% which is used \emph{in fine}.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_iv_v:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
> {
% \end{macrocode}
% The parameter |\l_@@_col_width_dim|, which is the width of the current column,
% will be available in each cell of the column. It will be used by the
% mono-column blocks.
% \begin{macrocode}
\dim_set:Nn \l_@@_col_width_dim { #2 }
\@@_cell_begin:w
\begin { #7 } [ #1 ] { #2 }
% \end{macrocode}
% The following lines have been taken from |array.sty|.
% \begin{macrocode}
\everypar
{
\vrule height \box_ht:N \@arstrutbox width \c_zero_dim
\everypar { }
}
% \end{macrocode}
% Now, the potential code for the horizontal position of the content of the cell
% (|\centering|, |\raggedright|, |\raggedleft| or nothing).
% \begin{macrocode}
#3
% \end{macrocode}
% The following code is to allow something like |\centering| in |\RowStyle|.
% \begin{macrocode}
\g_@@_row_style_tl
\arraybackslash
#5
}
#8
< {
#6
% \end{macrocode}
% The following line has been taken from |array.sty|.
% \begin{macrocode}
\@finalstrut \@arstrutbox
% \bool_if:NT \g_@@_rotate_bool { \raggedright \hsize = 3 cm }
\end { #7 }
% \end{macrocode}
% If the letter in the preamble is |m|, |#4| will be equal to
% |\@@_center_cell_box:| (see just below).
% \begin{macrocode}
#4
\@@_cell_end:
}
}
}
% \end{macrocode}
%
% \bigskip
% The following command will be used in |m|-columns in order to center
% vertically the box. In fact, despite its name, the command does not always
% center the cell. Indeed, if there is only one row in the cell, it should not
% be centered vertically. It's not possible to know the number of rows of the
% cell. However, we consider (as in \pkg{array}) that if the height of the cell
% is no more that the height of |\@arstrutbox|, there is only one row.
% \begin{macrocode}
\cs_new_protected:Npn \@@_center_cell_box:
{
% \end{macrocode}
% By putting instructions in |\g_@@_post_action_cell_tl|, we require a
% post-action of the box |\l_@@_cell_box|.
% \begin{macrocode}
\tl_gput_right:Nn \g_@@_post_action_cell_tl
{
\int_compare:nNnT
{ \box_ht:N \l_@@_cell_box }
>
{ \box_ht:N \@arstrutbox }
{
\hbox_set:Nn \l_@@_cell_box
{
\box_move_down:nn
{
( \box_ht:N \l_@@_cell_box - \box_ht:N \@arstrutbox
+ \baselineskip ) / 2
}
{ \box_use:N \l_@@_cell_box }
}
}
}
}
% \end{macrocode}
%
% \medskip
% For |V| (similar to the |V| of \pkg{varwidth}).
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_v:n #1
{
\str_if_eq:nnTF { #1 } { [ }
{ \@@_patch_preamble_v_i:w [ }
{ \@@_patch_preamble_v_i:w [ ] { #1 } }
}
\cs_new_protected:Npn \@@_patch_preamble_v_i:w [ #1 ]
{ \@@_patch_preamble_v_ii:nn { #1 } }
\cs_new_protected:Npn \@@_patch_preamble_v_ii:nn #1 #2
{
\str_set:Nn \l_@@_vpos_col_str { p }
\str_set:Nn \l_@@_hpos_col_str { j }
\keys_set:nn { WithArrows / p-column } { #1 }
\bool_if:NTF \c_@@_varwidth_loaded_bool
{ \@@_patch_preamble_iv_iv:nn { #2 } { varwidth } }
{
\@@_error:n { varwidth~not~loaded }
\@@_patch_preamble_iv_iv:nn { #2 } { minipage }
}
}
% \end{macrocode}
%
% \medskip
% For |w| and |W|
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_vi:nnnn #1 #2 #3 #4
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
> {
% \end{macrocode}
% The parameter |\l_@@_col_width_dim|, which is the width of the current column,
% will be available in each cell of the column. It will be used by the
% mono-column blocks.
% \begin{macrocode}
\dim_set:Nn \l_@@_col_width_dim { #4 }
\hbox_set:Nw \l_@@_cell_box
\@@_cell_begin:w
\str_set:Nn \l_@@_hpos_cell_str { #3 }
}
c
< {
\@@_cell_end:
#1
\hbox_set_end:
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
\@@_adjust_size_box:
\makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
}
}
% \end{macrocode}
% We increment the counter of columns and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c@jCol
\@@_patch_preamble_xi:n
}
% \end{macrocode}
%
% \medskip
% For |\@@_S:|. If the user has used |S[...]|, |S| has been replaced by |\@@_S:|
% during the first expansion of the preamble (done with the tools of standard
% LaTeX and \pkg{array}).
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_vii:n #1
{
\str_if_eq:nnTF { #1 } { [ }
{ \@@_patch_preamble_vii_i:w [ }
{ \@@_patch_preamble_vii_i:w [ ] { #1 } }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_vii_i:w [ #1 ]
{ \@@_patch_preamble_vii_ii:n { #1 } }
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_vii_ii:n #1
{
% \end{macrocode}
% We test whether the version of \pkg{nicematrix} is at least 3.0. We will
% change de programmation of the test further with something like |\VersionAtLeast|.
%
% \begin{macrocode}
\cs_if_exist:NTF \siunitx_cell_begin:w
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
> {
\@@_cell_begin:w
\keys_set:nn { siunitx } { #1 }
\siunitx_cell_begin:w
}
c
< { \siunitx_cell_end: \@@_cell_end: }
}
% \end{macrocode}
% We increment the counter of columns and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c@jCol
\@@_patch_preamble_xi:n
}
{ \@@_fatal:n { Version~of~siunitx~too~old } }
}
% \end{macrocode}
%
%
% \medskip
% For |(|, |[| and |\{|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_viii:nn #1 #2
{
\bool_if:NT \l_@@_small_bool { \@@_fatal:n { Delimiter~with~small } }
% \end{macrocode}
% If we are before the column 1 and not in |{NiceArray}|, we reserve space for
% the left delimiter.
% \begin{macrocode}
\int_compare:nNnTF \c@jCol = \c_zero_int
{
\str_if_eq:VnTF \g_@@_left_delim_tl { . }
{
% \end{macrocode}
% In that case, in fact, the first letter of the preamble must be considered as
% the left delimiter of the array.
% \begin{macrocode}
\tl_gset:Nn \g_@@_left_delim_tl { #1 }
\tl_gset:Nn \g_@@_right_delim_tl { . }
\@@_patch_preamble:n #2
}
{
\tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } }
\@@_patch_preamble_viii_i:nn { #1 } { #2 }
}
}
{ \@@_patch_preamble_viii_i:nn { #1 } { #2 } }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_viii_i:nn #1 #2
{
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_delimiter:nnn #1 { \int_eval:n { \c@jCol + 1 } } \c_true_bool }
\tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 }
{
\@@_error:nn { delimiter~after~opening } { #2 }
\@@_patch_preamble:n
}
{ \@@_patch_preamble:n #2 }
}
% \end{macrocode}
%
% \bigskip
% For |)|, |]| and |\}|. We have two arguments for the following command because
% we directly read the following letter in the preamble (we have to see whether
% we have a opening delimiter following and we also have to see whether we are
% at the end of the preamble because, in that case, our letter must be
% considered as the right delimiter of the environment if the environment is
% |{NiceArray}|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_ix:nn #1 #2
{
\bool_if:NT \l_@@_small_bool { \@@_fatal:n { Delimiter~with~small } }
\tl_if_in:nnTF { ) ] \} } { #2 }
{ \@@_patch_preamble_ix_i:nnn #1 #2 }
{
\tl_if_eq:nnTF { \q_stop } { #2 }
{
\str_if_eq:VnTF \g_@@_right_delim_tl { . }
{ \tl_gset:Nn \g_@@_right_delim_tl { #1 } }
{
\tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } }
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
\@@_patch_preamble:n #2
}
}
{
\tl_if_in:nnT { ( [ \{ } { #2 }
{ \tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } } }
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
\@@_patch_preamble:n #2
}
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_ix_i:nnn #1 #2 #3
{
\tl_if_eq:nnTF { \q_stop } { #3 }
{
\str_if_eq:VnTF \g_@@_right_delim_tl { . }
{
\tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } }
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
\tl_gset:Nn \g_@@_right_delim_tl { #2 }
}
{
\tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } }
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
\@@_error:nn { double~closing~delimiter } { #2 }
}
}
{
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
\@@_error:nn { double~closing~delimiter } { #2 }
\@@_patch_preamble:n #3
}
}
% \end{macrocode}
%
% \bigskip
% For the case of a letter |X|. This specifier may take in an optional argument
% (between square brackets). That's why we test whether there is a |[| after the
% letter |X|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_x:n #1
{
\str_if_eq:nnTF { #1 } { [ }
{ \@@_patch_preamble_x_i:w [ }
{ \@@_patch_preamble_x_i:w [ ] #1 }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_x_i:w [ #1 ]
{ \@@_patch_preamble_x_ii:n { #1 } }
% \end{macrocode}
% |#1| is the optional argument of the |X| specifier (a list of
% \emph{key}-\emph{value} pairs).
%
% \medskip
% The following set of keys is for the specifier |X| in the preamble of the
% array. Such specifier may have as keys all the keys of
% |{ WithArrows / p-column }| but also a key as 1, 2, 3, etc. The following set
% of keys will be used to retrieve that value (in the counter |\l_@@_weight_int|).
% \begin{macrocode}
\keys_define:nn { WithArrows / X-column }
{ unknown .code:n = \int_set:Nn \l_@@_weight_int { \l_keys_key_str } }
% \end{macrocode}
%
%
% \medskip
% In the following command, |#1| is the list of the options of the specifier |X|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_x_ii:n #1
{
% \end{macrocode}
% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is
% the initial value), |l|, |c| and |r| (when the user has used the corresponding
% key in the optional argument of the specifier |X|).
% \begin{macrocode}
\str_set:Nn \l_@@_hpos_col_str { j }
% \end{macrocode}
% The possible values of |\l_@@_vpos_col_str| are |p| (the initial value), |m| and |b|
% (when the user has used the corresponding key in the optional argument of the
% specifier |X|).
% \begin{macrocode}
\tl_set:Nn \l_@@_vpos_col_str { p }
% \end{macrocode}
%
% The integer |\l_@@_weight_int| will be the weight of the |X| column (the
% initial value is $1$). The user may specify a different value (such as $2$,
% $3$, etc.) by putting that value in the optional argument of the specifier.
% The weights of the |X| columns are used in the computation of the actual width
% of those columns as in \pkg{tabu} of \pkg{tabularray}.
% \begin{macrocode}
\int_zero_new:N \l_@@_weight_int
\int_set:Nn \l_@@_weight_int { 1 }
\keys_set_known:nnN { WithArrows / p-column } { #1 } \l_tmpa_tl
\keys_set:nV { WithArrows / X-column } \l_tmpa_tl
\int_compare:nNnT \l_@@_weight_int < 0
{
\@@_error:nx { negative~weight } { \int_use:N \l_@@_weight_int }
\int_set:Nn \l_@@_weight_int { - \l_@@_weight_int }
}
\int_gadd:Nn \g_@@_total_X_weight_int \l_@@_weight_int
% \end{macrocode}
%
% We test whether we know the width of the |X|-columns by reading the |aux| file
% (after the first compilation, the width of the |X|-columns is computed and
% written in the |aux| file).
% \begin{macrocode}
\bool_if:NTF \l_@@_X_columns_aux_bool
{
\@@_patch_preamble_iv_iv:nn
{ \l_@@_weight_int \l_@@_X_columns_dim }
{ minipage }
}
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
> {
\@@_cell_begin:w
\bool_set_true:N \l_@@_X_column_bool
% \end{macrocode}
% The following code will nullify the box of the cell.
% \begin{macrocode}
\tl_gput_right:Nn \g_@@_post_action_cell_tl
{ \hbox_set:Nn \l_@@_cell_box { } }
% \end{macrocode}
% We put a |{minipage}| to give to the user the ability to put a command such as
% |\centering| in the |\RowStyle|.
% \begin{macrocode}
\begin { minipage } { 5 cm } \arraybackslash
}
c
< {
\end { minipage }
\@@_cell_end:
}
}
\int_gincr:N \c@jCol
\@@_patch_preamble_xi:n
}
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_xii:n #1
{
\tl_gput_right:Nn \g_@@_preamble_tl
{ ! { \skip_horizontal:N 2\l_@@_radius_dim } }
% \end{macrocode}
% The command |\@@_vdottedline:n| is protected, and, therefore, won't be
% expanded before writing on |\g_@@_internal_code_after_tl|.
% \begin{macrocode}
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_vdottedline:n { \int_use:N \c@jCol } }
\@@_patch_preamble:n
}
% \end{macrocode}
%
% \bigskip
% After a specifier of column, we have to test whether there is one or several
% |<{..}| because, after those potential |<{...}|, we have to insert
% |!{\skip_horizontal:N ...}| when the key |vlines| is used.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_xi:n #1
{
\str_if_eq:nnTF { #1 } { < }
\@@_patch_preamble_xiii:n
{
\tl_if_eq:NnTF \l_@@_vlines_clist { all }
{
\tl_gput_right:Nn \g_@@_preamble_tl
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
{
\exp_args:NNx
\clist_if_in:NnT \l_@@_vlines_clist { \int_eval:n { \c@jCol + 1 } }
{
\tl_gput_right:Nn \g_@@_preamble_tl
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
}
\@@_patch_preamble:n { #1 }
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_xiii:n #1
{
\tl_gput_right:Nn \g_@@_preamble_tl { < { #1 } }
\@@_patch_preamble_xi:n
}
% \end{macrocode}
%
%
% \bigskip
% \subsection*{The redefinition of \textbackslash multicolumn}
%
% \medskip
% The following command must \emph{not} be protected since it begins with
% |\multispan| (a TeX primitive).
% \begin{macrocode}
\cs_new:Npn \@@_multicolumn:nnn #1 #2 #3
{
% \end{macrocode}
% The following lines are from the definition of |\multicolumn| in \pkg{array}
% (and \emph{not} in standard LaTeX). The first line aims to raise an error if
% the user has put more that one column specifier in the preamble of
% |\multicolumn|.
% \begin{macrocode}
\multispan { #1 }
\begingroup
\cs_set:Npn \@addamp { \if@firstamp \@firstampfalse \else \@preamerr 5 \fi }
% \end{macrocode}
%
% \medskip
% You do the expansion of the (small) preamble with the tools of \pkg{array}.
% \begin{macrocode}
\@temptokena = { #2 }
\@tempswatrue
\@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list }
% \end{macrocode}
%
% \medskip
% Now, we patch the (small) preamble as we have done with the main preamble of
% the array.
% \begin{macrocode}
\tl_gclear:N \g_@@_preamble_tl
\exp_after:wN \@@_patch_m_preamble:n \the \@temptokena \q_stop
% \end{macrocode}
%
% \medskip
% The following lines are an adaptation of the definition of |\multicolumn| in
% \pkg{array}.
% \begin{macrocode}
\exp_args:NV \@mkpream \g_@@_preamble_tl
\@addtopreamble \@empty
\endgroup
% \end{macrocode}
%
% \medskip
% Now, you do a treatment specific to \pkg{nicematrix} which has no equivalent
% in the original definition of |\multicolumn|.
% \begin{macrocode}
\int_compare:nNnT { #1 } > 1
{
\seq_gput_left:Nx \g_@@_multicolumn_cells_seq
{ \int_use:N \c@iRow - \int_eval:n { \c@jCol + 1 } }
\seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 }
\seq_gput_right:Nx \g_@@_pos_of_blocks_seq
{
{
\int_compare:nNnTF \c@jCol = 0
{ \int_eval:n { \c@iRow + 1 } }
{ \int_use:N \c@iRow }
} % modified 2022/01/10
{ \int_eval:n { \c@jCol + 1 } }
{
\int_compare:nNnTF \c@jCol = 0
{ \int_eval:n { \c@iRow + 1 } }
{ \int_use:N \c@iRow }
} % modified 2022/01/10
{ \int_eval:n { \c@jCol + #1 } }
{ } % for the name of the block
}
}
% \end{macrocode}
%
% \medskip
% The following lines were in the original definition of |\multicolumn|.
% \begin{macrocode}
\cs_set:Npn \@sharp { #3 }
\@arstrut
\@preamble
\null
% \end{macrocode}
%
% \medskip
% We add some lines.
% \begin{macrocode}
\int_gadd:Nn \c@jCol { #1 - 1 }
\int_compare:nNnT \c@jCol > \g_@@_col_total_int
{ \int_gset_eq:NN \g_@@_col_total_int \c@jCol }
\ignorespaces
}
% \end{macrocode}
%
% \bigskip
% The following commands will patch the (small) preamble of the |\multicolumn|.
% All those commands have a |m| in their name to recall that they deal with the
% redefinition of |\multicolumn|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_m_preamble:n #1
{
\str_case:nnF { #1 }
{
c { \@@_patch_m_preamble_i:n #1 }
l { \@@_patch_m_preamble_i:n #1 }
r { \@@_patch_m_preamble_i:n #1 }
> { \@@_patch_m_preamble_ii:nn #1 }
! { \@@_patch_m_preamble_ii:nn #1 }
@ { \@@_patch_m_preamble_ii:nn #1 }
| { \@@_patch_m_preamble_iii:n #1 }
p { \@@_patch_m_preamble_iv:nnn t #1 }
m { \@@_patch_m_preamble_iv:nnn c #1 }
b { \@@_patch_m_preamble_iv:nnn b #1 }
\@@_w: { \@@_patch_m_preamble_v:nnnn { } #1 }
\@@_W: { \@@_patch_m_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
\q_stop { }
}
{ \@@_fatal:nn { unknown~column~type } { #1 } }
}
% \end{macrocode}
%
% \medskip
% For |c|, |l| and |r|
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_m_preamble_i:n #1
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
> { \@@_cell_begin:w \str_set:Nn \l_@@_hpos_cell_str { #1 } }
#1
< \@@_cell_end:
}
% \end{macrocode}
%
% We test for the presence of a |<|.
% \begin{macrocode}
\@@_patch_m_preamble_x:n
}
% \end{macrocode}
%
% \medskip
% For |>|, |!| and |@|
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_m_preamble_ii:nn #1 #2
{
\tl_gput_right:Nn \g_@@_preamble_tl { #1 { #2 } }
\@@_patch_m_preamble:n
}
% \end{macrocode}
%
%
% \medskip
% For \verb+|+
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_m_preamble_iii:n #1
{
\tl_gput_right:Nn \g_@@_preamble_tl { #1 }
\@@_patch_m_preamble:n
}
% \end{macrocode}
%
% \medskip
% For |p|, |m| and |b|
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_m_preamble_iv:nnn #1 #2 #3
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
> {
\@@_cell_begin:w
\begin { minipage } [ #1 ] { \dim_eval:n { #3 } }
\mode_leave_vertical:
\arraybackslash
\vrule height \box_ht:N \@arstrutbox depth 0 pt width 0 pt
}
c
< {
\vrule height 0 pt depth \box_dp:N \@arstrutbox width 0 pt
\end { minipage }
\@@_cell_end:
}
}
% \end{macrocode}
% We test for the presence of a |<|.
% \begin{macrocode}
\@@_patch_m_preamble_x:n
}
% \end{macrocode}
%
% \medskip
% For |w| and |W|
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_m_preamble_v:nnnn #1 #2 #3 #4
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
> {
\hbox_set:Nw \l_@@_cell_box
\@@_cell_begin:w
\str_set:Nn \l_@@_hpos_cell_str { #3 }
}
c
< {
\@@_cell_end:
#1
\hbox_set_end:
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
\@@_adjust_size_box:
\makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
}
}
% \end{macrocode}
% We test for the presence of a |<|.
% \begin{macrocode}
\@@_patch_m_preamble_x:n
}
% \end{macrocode}
%
%
% After a specifier of column, we have to test whether there is one or several
% |<{..}| because, after those potential |<{...}|, we have to insert
% |!{\skip_horizontal:N ...}| when the key |vlines| is used.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_m_preamble_x:n #1
{
\str_if_eq:nnTF { #1 } { < }
\@@_patch_m_preamble_ix:n
{
\tl_if_eq:NnTF \l_@@_vlines_clist { all }
{
\tl_gput_right:Nn \g_@@_preamble_tl
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
{
\exp_args:NNx
\clist_if_in:NnT \l_@@_vlines_clist { \int_eval:n { \c@jCol + 1 } }
{
\tl_gput_right:Nn \g_@@_preamble_tl
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
}
\@@_patch_m_preamble:n { #1 }
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_m_preamble_ix:n #1
{
\tl_gput_right:Nn \g_@@_preamble_tl { < { #1 } }
\@@_patch_m_preamble_x:n
}
% \end{macrocode}
%
%
%
% \bigskip
% The command |\@@_put_box_in_flow:| puts the box |\l_tmpa_box| (which contains
% the array) in the flow. It is used for the environments with delimiters.
% First, we have to modify the height and the depth to take back into account
% the potential exterior rows (the total height of the first row has been
% computed in |\l_tmpa_dim| and the total height of the potential last row in
% |\l_tmpb_dim|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_put_box_in_flow:
{
\box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim }
\box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + \l_tmpb_dim }
\tl_if_eq:NnTF \l_@@_baseline_tl { c }
{ \box_use_drop:N \l_tmpa_box }
\@@_put_box_in_flow_i:
}
% \end{macrocode}
%
% \medskip
% The command |\@@_put_box_in_flow_i:| is used when the value of
% |\l_@@_baseline_tl| is different of |c| (which is the initial value and the
% most used).
% \begin{macrocode}
\cs_new_protected:Npn \@@_put_box_in_flow_i:
{
\pgfpicture
\@@_qpoint:n { row - 1 }
\dim_gset_eq:NN \g_tmpa_dim \pgf@y
\@@_qpoint:n { row - \int_eval:n { \c@iRow + 1 } }
\dim_gadd:Nn \g_tmpa_dim \pgf@y
\dim_gset:Nn \g_tmpa_dim { 0.5 \g_tmpa_dim }
% \end{macrocode}
% Now, |\g_tmpa_dim| contains the $y$-value of the center of the array (the
% delimiters are centered in relation with this value).
% \begin{macrocode}
\str_if_in:NnTF \l_@@_baseline_tl { line- }
{
\int_set:Nn \l_tmpa_int
{
\str_range:Nnn
\l_@@_baseline_tl
6
{ \tl_count:V \l_@@_baseline_tl }
}
\@@_qpoint:n { row - \int_use:N \l_tmpa_int }
}
{
\str_case:VnF \l_@@_baseline_tl
{
{ t } { \int_set:Nn \l_tmpa_int 1 }
{ b } { \int_set_eq:NN \l_tmpa_int \c@iRow }
}
{ \int_set:Nn \l_tmpa_int \l_@@_baseline_tl }
\bool_lazy_or:nnT
{ \int_compare_p:nNn \l_tmpa_int < \l_@@_first_row_int }
{ \int_compare_p:nNn \l_tmpa_int > \g_@@_row_total_int }
{
\@@_error:n { bad~value~for~baseline }
\int_set:Nn \l_tmpa_int 1
}
\@@_qpoint:n { row - \int_use:N \l_tmpa_int - base }
% \end{macrocode}
% We take into account the position of the mathematical axis.
% \begin{macrocode}
\dim_gsub:Nn \g_tmpa_dim { \fontdimen22 \textfont2 }
}
\dim_gsub:Nn \g_tmpa_dim \pgf@y
% \end{macrocode}
% Now, |\g_tmpa_dim| contains the value of the $y$ translation we have to to.
% \begin{macrocode}
\endpgfpicture
\box_move_up:nn \g_tmpa_dim { \box_use_drop:N \l_tmpa_box }
\box_use_drop:N \l_tmpa_box
}
% \end{macrocode}
%
% \bigskip
% The following command is \emph{always} used by |{NiceArrayWithDelims}| (even
% if, in fact, there is no tabular notes: in fact, it's not possible to know
% whether there is tabular notes or not before the composition of the blocks).
% \begin{macrocode}
\cs_new_protected:Npn \@@_use_arraybox_with_notes_c:
{
% \end{macrocode}
% With an environment |{Matrix}|, you want to remove the exterior |\arraycolsep|
% but we don't know the number of columns (since there is no preamble) and
% that's why we can't put |@{}| at the end of the preamble. That's why we remove
% a |\arraycolsep| now.
% \begin{macrocode}
\bool_lazy_and:nnT \l_@@_Matrix_bool \l_@@_NiceArray_bool
{
\box_set_wd:Nn \l_@@_the_array_box
{ \box_wd:N \l_@@_the_array_box - \arraycolsep }
}
% \end{macrocode}
% We need a |{minipage}| because we will insert a LaTeX list for the tabular
% notes (that means that a |\vtop{\hsize=...}| is not enough).
% \begin{macrocode}
\begin { minipage } [ t ] { \box_wd:N \l_@@_the_array_box }
% \end{macrocode}
% The |\hbox| avoids that the |pgfpicture| inside |\@@_draw_blocks| adds a extra
% vertical space before the notes.
% \begin{macrocode}
\hbox
{
\box_use_drop:N \l_@@_the_array_box
% \end{macrocode}
% We have to draw the blocks right now because there may be tabular notes in
% some blocks (which are not mono-column: the blocks which are mono-column
% have been composed in boxes yet)... and we have to create (potentially) the
% extra nodes before creating the blocks since there are |medium| nodes to create
% for the blocks.
% \begin{macrocode}
\@@_create_extra_nodes:
\seq_if_empty:NF \g_@@_blocks_seq \@@_draw_blocks:
}
\bool_lazy_or:nnT
{ \int_compare_p:nNn \c@tabularnote > 0 }
{ ! \tl_if_empty_p:V \l_@@_tabularnote_tl }
\@@_insert_tabularnotes:
\end { minipage }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_insert_tabularnotes:
{
\skip_vertical:N 0.65ex
% \end{macrocode}
% The TeX group is for potential specifications in the
% |\l_@@_notes_code_before_tl|.
% \begin{macrocode}
\group_begin:
\l_@@_notes_code_before_tl
\tl_if_empty:NF \l_@@_tabularnote_tl { \l_@@_tabularnote_tl \par }
% \end{macrocode}
% We compose the tabular notes with a list of \pkg{enumitem}. The |\strut| and
% the |\unskip| are designed to give the ability to put a |\bottomrule| at the
% end of the notes with a good vertical space.
% \begin{macrocode}
\int_compare:nNnT \c@tabularnote > 0
{
\bool_if:NTF \l_@@_notes_para_bool
{
\begin { tabularnotes* }
\seq_map_inline:Nn \g_@@_tabularnotes_seq { \item ##1 } \strut
\end { tabularnotes* }
% \end{macrocode}
% The following |\par| is mandatory for the event that the user has put
% |\footnotesize| (for example) in the |notes/code-before|.
% \begin{macrocode}
\par
}
{
\tabularnotes
\seq_map_inline:Nn \g_@@_tabularnotes_seq { \item ##1 } \strut
\endtabularnotes
}
}
\unskip
\group_end:
\bool_if:NT \l_@@_notes_bottomrule_bool
{
\bool_if:NTF \c_@@_booktabs_loaded_bool
{
% \end{macrocode}
% The two dimensions |\aboverulesep| et |\heavyrulewidth| are parameters defined
% by \pkg{booktabs}.
% \begin{macrocode}
\skip_vertical:N \aboverulesep
% \end{macrocode}
% |\CT@arc@| is the specification of color defined by \pkg{colortbl} but you use it
% even if \pkg{colortbl} is not loaded.
% \begin{macrocode}
{ \CT@arc@ \hrule height \heavyrulewidth }
}
{ \@@_error:n { bottomrule~without~booktabs } }
}
\l_@@_notes_code_after_tl
\seq_gclear:N \g_@@_tabularnotes_seq
\int_gzero:N \c@tabularnote
}
% \end{macrocode}
%
% \medskip
% The case of |baseline| equal to |b|. Remember that, when the key |b| is used,
% the |{array}| (of \pkg{array}) is constructed with the option |t| (and not
% |b|). Now, we do the translation to take into account the option |b|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_use_arraybox_with_notes_b:
{
\pgfpicture
\@@_qpoint:n { row - 1 }
\dim_gset_eq:NN \g_tmpa_dim \pgf@y
\@@_qpoint:n { row - \int_use:N \c@iRow - base }
\dim_gsub:Nn \g_tmpa_dim \pgf@y
\endpgfpicture
\dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
\int_compare:nNnT \l_@@_first_row_int = 0
{
\dim_gadd:Nn \g_tmpa_dim \g_@@_ht_row_zero_dim
\dim_gadd:Nn \g_tmpa_dim \g_@@_dp_row_zero_dim
}
\box_move_up:nn \g_tmpa_dim { \hbox { \@@_use_arraybox_with_notes_c: } }
}
% \end{macrocode}
%
% \medskip
% Now, the general case.
% \begin{macrocode}
\cs_new_protected:Npn \@@_use_arraybox_with_notes:
{
% \end{macrocode}
% We convert a value of |t| to a value of |1|.
% \begin{macrocode}
\tl_if_eq:NnT \l_@@_baseline_tl { t }
{ \tl_set:Nn \l_@@_baseline_tl { 1 } }
% \end{macrocode}
% Now, we convert the value of |\l_@@_baseline_tl| (which should represent an
% integer) to an integer stored in |\l_tmpa_int|.
% \begin{macrocode}
\pgfpicture
\@@_qpoint:n { row - 1 }
\dim_gset_eq:NN \g_tmpa_dim \pgf@y
\str_if_in:NnTF \l_@@_baseline_tl { line- }
{
\int_set:Nn \l_tmpa_int
{
\str_range:Nnn
\l_@@_baseline_tl
6
{ \tl_count:V \l_@@_baseline_tl }
}
\@@_qpoint:n { row - \int_use:N \l_tmpa_int }
}
{
\int_set:Nn \l_tmpa_int \l_@@_baseline_tl
\bool_lazy_or:nnT
{ \int_compare_p:nNn \l_tmpa_int < \l_@@_first_row_int }
{ \int_compare_p:nNn \l_tmpa_int > \g_@@_row_total_int }
{
\@@_error:n { bad~value~for~baseline }
\int_set:Nn \l_tmpa_int 1
}
\@@_qpoint:n { row - \int_use:N \l_tmpa_int - base }
}
\dim_gsub:Nn \g_tmpa_dim \pgf@y
\endpgfpicture
\dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
\int_compare:nNnT \l_@@_first_row_int = 0
{
\dim_gadd:Nn \g_tmpa_dim \g_@@_ht_row_zero_dim
\dim_gadd:Nn \g_tmpa_dim \g_@@_dp_row_zero_dim
}
\box_move_up:nn \g_tmpa_dim { \hbox { \@@_use_arraybox_with_notes_c: } }
}
% \end{macrocode}
%
%
%
% \bigskip
% The command |\@@_put_box_in_flow_bis:| is used when the option
% |delimiters/max-width| is used because, in this case, we have to adjust the
% widths of the delimiters. The arguments |#1| and |#2| are the delimiters
% specified by the user.
% \begin{macrocode}
\cs_new_protected:Npn \@@_put_box_in_flow_bis:nn #1 #2
{
% \end{macrocode}
% We will compute the real width of both delimiters used.
% \begin{macrocode}
\dim_zero_new:N \l_@@_real_left_delim_dim
\dim_zero_new:N \l_@@_real_right_delim_dim
\hbox_set:Nn \l_tmpb_box
{
\c_math_toggle_token
\left #1
\vcenter
{
\vbox_to_ht:nn
{ \box_ht_plus_dp:N \l_tmpa_box }
{ }
}
\right .
\c_math_toggle_token
}
\dim_set:Nn \l_@@_real_left_delim_dim
{ \box_wd:N \l_tmpb_box - \nulldelimiterspace }
\hbox_set:Nn \l_tmpb_box
{
\c_math_toggle_token
\left .
\vbox_to_ht:nn
{ \box_ht_plus_dp:N \l_tmpa_box }
{ }
\right #2
\c_math_toggle_token
}
\dim_set:Nn \l_@@_real_right_delim_dim
{ \box_wd:N \l_tmpb_box - \nulldelimiterspace }
% \end{macrocode}
%
% Now, we can put the box in the TeX flow with the horizontal adjustments on
% both sides.
% \begin{macrocode}
\skip_horizontal:N \l_@@_left_delim_dim
\skip_horizontal:N -\l_@@_real_left_delim_dim
\@@_put_box_in_flow:
\skip_horizontal:N \l_@@_right_delim_dim
\skip_horizontal:N -\l_@@_real_right_delim_dim
}
% \end{macrocode}
%
% \interitem
% The construction of the array in the environment |{NiceArrayWithDelims}| is,
% in fact, done by the environment |{@@-light-syntax}| or by the environment
% |{@@-normal-syntax}| (whether the option |light-syntax| is in force or not).
% When the key |light-syntax| is not used, the construction is a standard
% environment (and, thus, it's possible to use verbatim in the array).
% \begin{macrocode}
\NewDocumentEnvironment { @@-normal-syntax } { }
% \end{macrocode}
% First, we test whether the environment is empty. If it is empty, we raise a
% fatal error (it's only a security). In order to detect whether it is empty, we
% test whether the next token is |\end| and, if it's the case, we test if this
% is the end of the environment (if it is not, an standard error will be raised
% by LaTeX for incorrect nested environments).
% \begin{macrocode}
{
\peek_remove_spaces:n
{
\peek_meaning:NTF \end
\@@_analyze_end:Nn
% \end{macrocode}
% Here is the call to |\array| (we have a dedicated macro |\@@_array:| because
% of compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}).
% \begin{macrocode}
{ \exp_args:NV \@@_array: \g_@@_preamble_tl }
}
}
{
\@@_create_col_nodes:
\endarray
}
% \end{macrocode}
%
%
% \bigskip
% When the key |light-syntax| is in force, we use an environment which takes its
% whole body as an argument (with the specifier |b| of \pkg{xparse}).
% % \label{code-light-syntax}
% \begin{macrocode}
\NewDocumentEnvironment { @@-light-syntax } { b }
{
% \end{macrocode}
% First, we test whether the environment is empty. It's only a security. Of
% course, this test is more easy than the similar test for the ``normal syntax''
% because we have the whole body of the environment in |#1|.
% \begin{macrocode}
\tl_if_empty:nT { #1 } { \@@_fatal:n { empty~environment } }
\tl_map_inline:nn { #1 }
{
\str_if_eq:nnT { ##1 } { & }
{ \@@_fatal:n { ampersand~in~light-syntax } }
\str_if_eq:nnT { ##1 } { \\ }
{ \@@_fatal:n { double-backslash~in~light-syntax } }
}
% \end{macrocode}
% Now, you extract the |\CodeAfter| of the body of the environment. Maybe, there
% is no command |\CodeAfter| in the body. That's why you put a marker
% |\CodeAfter| after |#1|. If there is yet a |\CodeAfter| in |#1|, this second
% (or third...) |\CodeAfter| will be catched in the value of
% |\g_nicematrix_code_after_tl|. That doesn't matter because |\CodeAfter| will
% be set to \textsl{no-op} before the execution of
% |\g_nicematrix_code_after_tl|.
% \begin{macrocode}
\@@_light_syntax_i #1 \CodeAfter \q_stop
}
% \end{macrocode}
% Now, the second part of the environment. It is empty. That's not surprising
% because we have caught the whole body of the environment with the specifier
% |b| provided by \pkg{xparse}.
% \begin{macrocode}
{ }
% \end{macrocode}
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_light_syntax_i #1\CodeAfter #2\q_stop
{
\tl_gput_right:Nn \g_nicematrix_code_after_tl { #2 }
% \end{macrocode}
% The body of the array, which is stored in the argument |#1|, is now
% splitted into items (and \emph{not} tokens).
% \begin{macrocode}
\seq_gclear_new:N \g_@@_rows_seq
\tl_set_rescan:Nno \l_@@_end_of_row_tl { } \l_@@_end_of_row_tl
\seq_gset_split:NVn \g_@@_rows_seq \l_@@_end_of_row_tl { #1 }
% \end{macrocode}
% If the environment uses the option |last-row| without value (i.e. without
% saying the number of the rows), we have now the opportunity to know that
% value. We do it, and so, if the token list |\l_@@_code_for_last_row_tl| is not
% empty, we will use directly where it should be.
% \begin{macrocode}
\int_compare:nNnT \l_@@_last_row_int = { -1 }
{ \int_set:Nn \l_@@_last_row_int { \seq_count:N \g_@@_rows_seq } }
% \end{macrocode}
% Here is the call to |\array| (we have a dedicated macro |\@@_array:| because
% of compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}).
% \begin{macrocode}
\exp_args:NV \@@_array: \g_@@_preamble_tl
% \end{macrocode}
% We need a global affectation because, when executing |\l_tmpa_tl|, we will
% exit the first cell of the array.
% \begin{macrocode}
\seq_gpop_left:NN \g_@@_rows_seq \l_tmpa_tl
\@@_line_with_light_syntax_i:V \l_tmpa_tl
\seq_map_function:NN \g_@@_rows_seq \@@_line_with_light_syntax:n
\@@_create_col_nodes:
\endarray
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_line_with_light_syntax:n #1
{ \tl_if_empty:nF { #1 } { \\ \@@_line_with_light_syntax_i:n { #1 } } }
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_line_with_light_syntax_i:n #1
{
\seq_gclear_new:N \g_@@_cells_seq
\seq_gset_split:Nnn \g_@@_cells_seq { ~ } { #1 }
\seq_gpop_left:NN \g_@@_cells_seq \l_tmpa_tl
\l_tmpa_tl
\seq_map_inline:Nn \g_@@_cells_seq { & ##1 }
}
\cs_generate_variant:Nn \@@_line_with_light_syntax_i:n { V }
% \end{macrocode}
%
%
% \bigskip
% The following command is used by the code which detects whether the
% environment is empty (we raise a fatal error in this case: it's only a
% security).
% \begin{macrocode}
\cs_new_protected:Npn \@@_analyze_end:Nn #1 #2
{
\str_if_eq:VnT \g_@@_name_env_str { #2 }
{ \@@_fatal:n { empty~environment } }
% \end{macrocode}
% We reput in the stream the |\end{...}| we have extracted and the user will
% have an error for incorrect nested environments.
% \begin{macrocode}
\end { #2 }
}
% \end{macrocode}
%
% \bigskip
% The command |\@@_create_col_nodes:| will construct a special last row.
% That last row is a false row used to create the |col| nodes and to fix the
% width of the columns (when the array is constructed with an option which
% specifies the width of the columns).
% \begin{macrocode}
\cs_new:Npn \@@_create_col_nodes:
{
\crcr
\int_compare:nNnT \l_@@_first_col_int = 0
{
\omit
\hbox_overlap_left:n
{
\bool_if:NT \l_@@_code_before_bool
{ \pgfsys@markposition { \@@_env: - col - 0 } }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \@@_env: - col - 0 } \pgfpointorigin
\str_if_empty:NF \l_@@_name_str
{ \pgfnodealias { \l_@@_name_str - col - 0 } { \@@_env: - col - 0 } }
\endpgfpicture
\skip_horizontal:N 2\col@sep
\skip_horizontal:N \g_@@_width_first_col_dim
}
&
}
\omit
% \end{macrocode}
% The following instruction must be put after the instruction |\omit|.
% \begin{macrocode}
\bool_gset_true:N \g_@@_row_of_col_done_bool
% \end{macrocode}
% First, we put a |col| node on the left of the first column (of course, we
% have to do that \emph{after} the |\omit|).
% \begin{macrocode}
\int_compare:nNnTF \l_@@_first_col_int = 0
{
\bool_if:NT \l_@@_code_before_bool
{
\hbox
{
\skip_horizontal:N -0.5\arrayrulewidth
\pgfsys@markposition { \@@_env: - col - 1 }
\skip_horizontal:N 0.5\arrayrulewidth
}
}
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \@@_env: - col - 1 }
{ \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim }
\str_if_empty:NF \l_@@_name_str
{ \pgfnodealias { \l_@@_name_str - col - 1 } { \@@_env: - col - 1 } }
\endpgfpicture
}
{
\bool_if:NT \l_@@_code_before_bool
{
\hbox
{
\skip_horizontal:N 0.5\arrayrulewidth
\pgfsys@markposition { \@@_env: - col - 1 }
\skip_horizontal:N -0.5\arrayrulewidth
}
}
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \@@_env: - col - 1 }
{ \pgfpoint { 0.5 \arrayrulewidth } \c_zero_dim }
\str_if_empty:NF \l_@@_name_str
{ \pgfnodealias { \l_@@_name_str - col - 1 } { \@@_env: - col - 1 } }
\endpgfpicture
}
% \end{macrocode}
% We compute in |\g_tmpa_skip| the common width of the columns (it's a skip and
% not a dimension). We use a global variable because we are in a cell of an
% |\halign| and because we have to use this variable in other cells (of the same
% row). The affectation of |\g_tmpa_skip|, like all the affectations, must be
% done after the |\omit| of the cell.
%
% \smallskip
% We give a default value for |\g_tmpa_skip| (|0 pt plus 1 fill|) but it will
% just after be erased by a fixed value in the concerned cases.
% \begin{macrocode}
\skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill }
\bool_if:NF \l_@@_auto_columns_width_bool
{ \dim_compare:nNnT \l_@@_columns_width_dim > \c_zero_dim }
{
\bool_lazy_and:nnTF
\l_@@_auto_columns_width_bool
{ \bool_not_p:n \l_@@_block_auto_columns_width_bool }
{ \skip_gset_eq:NN \g_tmpa_skip \g_@@_max_cell_width_dim }
{ \skip_gset_eq:NN \g_tmpa_skip \l_@@_columns_width_dim }
\skip_gadd:Nn \g_tmpa_skip { 2 \col@sep }
}
\skip_horizontal:N \g_tmpa_skip
\hbox
{
\bool_if:NT \l_@@_code_before_bool
{
\hbox
{
\skip_horizontal:N -0.5\arrayrulewidth
\pgfsys@markposition { \@@_env: - col - 2 }
\skip_horizontal:N 0.5\arrayrulewidth
}
}
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \@@_env: - col - 2 }
{ \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim }
\str_if_empty:NF \l_@@_name_str
{ \pgfnodealias { \l_@@_name_str - col - 2 } { \@@_env: - col - 2 } }
\endpgfpicture
}
% \end{macrocode}
% We begin a loop over the columns. The integer |\g_tmpa_int| will be the
% number of the current column. This integer is used for the Tikz nodes.
% \begin{macrocode}
\int_gset:Nn \g_tmpa_int 1
\bool_if:NTF \g_@@_last_col_found_bool
{ \prg_replicate:nn { \int_max:nn { \g_@@_col_total_int - 3 } 0 } }
{ \prg_replicate:nn { \int_max:nn { \g_@@_col_total_int - 2 } 0 } }
{
&
\omit
\int_gincr:N \g_tmpa_int
% \end{macrocode}
% The incrementation of the counter |\g_tmpa_int| must be done after the |\omit|
% of the cell.
% \begin{macrocode}
\skip_horizontal:N \g_tmpa_skip
\bool_if:NT \l_@@_code_before_bool
{
\hbox
{
\skip_horizontal:N -0.5\arrayrulewidth
\pgfsys@markposition
{ \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } }
\skip_horizontal:N 0.5\arrayrulewidth
}
}
% \end{macrocode}
% We create the |col| node on the right of the current column.
% \begin{macrocode}
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } }
{ \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{ \l_@@_name_str - col - \int_eval:n { \g_tmpa_int + 1 } }
{ \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } }
}
\endpgfpicture
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
&
\omit
% \end{macrocode}
% The two following lines have been added on 2021-12-15 to solve a bug
% mentionned by Joao Luis Soares by mail.
% \begin{macrocode}
\int_compare:nNnT \g_@@_col_total_int = 1
{ \skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill } }
\skip_horizontal:N \g_tmpa_skip
\int_gincr:N \g_tmpa_int
\bool_lazy_all:nT
{
\l_@@_NiceArray_bool
{ \bool_not_p:n \l_@@_NiceTabular_bool }
{ \clist_if_empty_p:N \l_@@_vlines_clist }
{ \bool_not_p:n \l_@@_exterior_arraycolsep_bool }
{ ! \l_@@_bar_at_end_of_pream_bool }
}
{ \skip_horizontal:N -\col@sep }
\bool_if:NT \l_@@_code_before_bool
{
\hbox
{
\skip_horizontal:N -0.5\arrayrulewidth
% \end{macrocode}
% With an environment |{Matrix}|, you want to remove the exterior |\arraycolsep|
% but we don't know the number of columns (since there is no preamble) and
% that's why we can't put |@{}| at the end of the preamble. That's why we remove
% a |\arraycolsep| now.
% \begin{macrocode}
\bool_lazy_and:nnT \l_@@_Matrix_bool \l_@@_NiceArray_bool
{ \skip_horizontal:N -\arraycolsep }
\pgfsys@markposition
{ \@@_env: - col - \int_eval:n {
\g_tmpa_int + 1 } }
\skip_horizontal:N 0.5\arrayrulewidth
\bool_lazy_and:nnT \l_@@_Matrix_bool \l_@@_NiceArray_bool
{ \skip_horizontal:N \arraycolsep }
}
}
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } }
{
\bool_lazy_and:nnTF \l_@@_Matrix_bool \l_@@_NiceArray_bool
{
\pgfpoint
{ - 0.5 \arrayrulewidth - \arraycolsep }
\c_zero_dim
}
{ \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim }
}
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{ \l_@@_name_str - col - \int_eval:n { \g_tmpa_int + 1 } }
{ \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } }
}
\endpgfpicture
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\bool_if:NT \g_@@_last_col_found_bool
{
\hbox_overlap_right:n
{
\skip_horizontal:N \g_@@_width_last_col_dim
\bool_if:NT \l_@@_code_before_bool
{
\pgfsys@markposition
{ \@@_env: - col - \int_eval:n { \g_@@_col_total_int + 1 } }
}
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate
{ \@@_env: - col - \int_eval:n { \g_@@_col_total_int + 1 } }
\pgfpointorigin
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{
\l_@@_name_str - col
- \int_eval:n { \g_@@_col_total_int + 1 }
}
{ \@@_env: - col - \int_eval:n { \g_@@_col_total_int + 1 } }
}
\endpgfpicture
}
}
\cr
}
% \end{macrocode}
%
%
% \interitem
% Here is the preamble for the ``first column'' (if the user uses the key
% |first-col|)
% \begin{macrocode}
\tl_const:Nn \c_@@_preamble_first_col_tl
{
>
{
% \end{macrocode}
% At the beginning of the cell, we link |\CodeAfter| to a command which do
% begins with |\\| (whereas the standard version of |\CodeAfter| begins does
% not).
% \begin{macrocode}
\cs_set_eq:NN \CodeAfter \@@_CodeAfter_i:
\bool_gset_true:N \g_@@_after_col_zero_bool
\@@_begin_of_row:
% \end{macrocode}
% The contents of the cell is constructed in the box |\l_@@_cell_box| because we
% have to compute some dimensions of this box.
% \begin{macrocode}
\hbox_set:Nw \l_@@_cell_box
\@@_math_toggle_token:
\bool_if:NT \l_@@_small_bool \scriptstyle
% \end{macrocode}
% We insert |\l_@@_code_for_first_col_tl|... but we don't insert it in the
% potential ``first row'' and in the potential ``last row''.
% \begin{macrocode}
\bool_lazy_and:nnT
{ \int_compare_p:nNn \c@iRow > 0 }
{
\bool_lazy_or_p:nn
{ \int_compare_p:nNn \l_@@_last_row_int < 0 }
{ \int_compare_p:nNn \c@iRow < \l_@@_last_row_int }
}
{
\l_@@_code_for_first_col_tl
\xglobal \colorlet { nicematrix-first-col } { . }
}
}
% \end{macrocode}
% Be careful: despite this letter |l| the cells of the ``first column'' are
% composed in a |R| manner since they are composed in a |\hbox_overlap_left:n|.
% \begin{macrocode}
l
<
{
\@@_math_toggle_token:
\hbox_set_end:
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
\@@_adjust_size_box:
\@@_update_for_first_and_last_row:
% \end{macrocode}
% We actualise the width of the ``first column'' because we will use this width
% after the construction of the array.
% \begin{macrocode}
\dim_gset:Nn \g_@@_width_first_col_dim
{ \dim_max:nn \g_@@_width_first_col_dim { \box_wd:N \l_@@_cell_box } }
% \end{macrocode}
% The content of the cell is inserted in an overlapping position.
% \label{overlap-left}
% \begin{macrocode}
\hbox_overlap_left:n
{
\dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > \c_zero_dim
\@@_node_for_cell:
{ \box_use_drop:N \l_@@_cell_box }
\skip_horizontal:N \l_@@_left_delim_dim
\skip_horizontal:N \l_@@_left_margin_dim
\skip_horizontal:N \l_@@_extra_left_margin_dim
}
\bool_gset_false:N \g_@@_empty_cell_bool
\skip_horizontal:N -2\col@sep
}
}
% \end{macrocode}
%
%
% Here is the preamble for the ``last column'' (if the user uses the key
% |last-col|).
% \begin{macrocode}
\tl_const:Nn \c_@@_preamble_last_col_tl
{
>
{
% \end{macrocode}
% At the beginning of the cell, we link |\CodeAfter| to a command which do
% begins with |\\| (whereas the standard version of |\CodeAfter| begins does
% not).
% \begin{macrocode}
\cs_set_eq:NN \CodeAfter \@@_CodeAfter_i:
% \end{macrocode}
% With the flag |\g_@@_last_col_found_bool|, we will know that the ``last
% column'' is really used.
% \begin{macrocode}
\bool_gset_true:N \g_@@_last_col_found_bool
\int_gincr:N \c@jCol
\int_gset_eq:NN \g_@@_col_total_int \c@jCol
% \end{macrocode}
% The contents of the cell is constructed in the box |\l_tmpa_box| because we
% have to compute some dimensions of this box.
% \begin{macrocode}
\hbox_set:Nw \l_@@_cell_box
\@@_math_toggle_token:
\bool_if:NT \l_@@_small_bool \scriptstyle
% \end{macrocode}
% We insert |\l_@@_code_for_last_col_tl|... but we don't insert it in the
% potential ``first row'' and in the potential ``last row''.
% \begin{macrocode}
\int_compare:nNnT \c@iRow > 0
{
\bool_lazy_or:nnT
{ \int_compare_p:nNn \l_@@_last_row_int < 0 }
{ \int_compare_p:nNn \c@iRow < \l_@@_last_row_int }
{
\l_@@_code_for_last_col_tl
\xglobal \colorlet { nicematrix-last-col } { . }
}
}
}
l
<
{
\@@_math_toggle_token:
\hbox_set_end:
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
\@@_adjust_size_box:
\@@_update_for_first_and_last_row:
% \end{macrocode}
% We actualise the width of the ``last column'' because we will use this width
% after the construction of the array.
% \begin{macrocode}
\dim_gset:Nn \g_@@_width_last_col_dim
{ \dim_max:nn \g_@@_width_last_col_dim { \box_wd:N \l_@@_cell_box } }
\skip_horizontal:N -2\col@sep
% \end{macrocode}
% The content of the cell is inserted in an overlapping position.
% \label{overlap-right}
% \begin{macrocode}
\hbox_overlap_right:n
{
\dim_compare:nNnT { \box_wd:N \l_@@_cell_box } > \c_zero_dim
{
\skip_horizontal:N \l_@@_right_delim_dim
\skip_horizontal:N \l_@@_right_margin_dim
\skip_horizontal:N \l_@@_extra_right_margin_dim
\@@_node_for_cell:
}
}
\bool_gset_false:N \g_@@_empty_cell_bool
}
}
% \end{macrocode}
%
%
% \interitem
% The environment |{NiceArray}| is constructed upon the environment
% |{NiceArrayWithDelims}| but, in fact, there is a flag |\l_@@_NiceArray_bool|.
% In |{NiceArrayWithDelims}|, some special code will be executed if this flag is
% raised.
% \begin{macrocode}
\NewDocumentEnvironment { NiceArray } { }
{
\bool_set_true:N \l_@@_NiceArray_bool
\str_if_empty:NT \g_@@_name_env_str
{ \str_gset:Nn \g_@@_name_env_str { NiceArray } }
% \end{macrocode}
% We put . and . for the delimiters but, in fact, that doesn't matter because
% these arguments won't be used in |{NiceArrayWithDelims}| (because the flag
% |\l_@@_NiceArray_bool| is raised).
% \begin{macrocode}
\NiceArrayWithDelims . .
}
{ \endNiceArrayWithDelims }
% \end{macrocode}
%
%
% \interitem
% We create the variants of the environment |{NiceArrayWithDelims}|.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_def_env:nnn #1 #2 #3
{
\NewDocumentEnvironment { #1 NiceArray } { }
{
\str_if_empty:NT \g_@@_name_env_str
{ \str_gset:Nn \g_@@_name_env_str { #1 NiceArray } }
\@@_test_if_math_mode:
\NiceArrayWithDelims #2 #3
}
{ \endNiceArrayWithDelims }
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_def_env:nnn p ( )
\@@_def_env:nnn b [ ]
\@@_def_env:nnn B \{ \}
\@@_def_env:nnn v | |
\@@_def_env:nnn V \| \|
% \end{macrocode}
%
%
% \bigskip
% \subsection*{The environment \{NiceMatrix\} and its variants}
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_begin_of_NiceMatrix:nn #1 #2
{
\bool_set_true:N \l_@@_Matrix_bool
\use:c { #1 NiceArray }
{
*
{
\int_compare:nNnTF \l_@@_last_col_int < 0
\c@MaxMatrixCols
{ \int_eval:n { \l_@@_last_col_int - 1 } }
}
{ > \@@_cell_begin:w #2 < \@@_cell_end: }
}
}
\cs_generate_variant:Nn \@@_begin_of_NiceMatrix:nn { n e }
% \end{macrocode}
%
% \begin{macrocode}
\clist_map_inline:nn { { } , p , b , B , v , V }
{
\NewDocumentEnvironment { #1 NiceMatrix } { ! O { } }
{
\str_gset:Nn \g_@@_name_env_str { #1 NiceMatrix }
\tl_set:Nn \l_@@_type_of_col_tl c
\keys_set:nn { NiceMatrix / NiceMatrix } { ##1 }
\@@_begin_of_NiceMatrix:ne { #1 } \l_@@_type_of_col_tl
}
{ \use:c { end #1 NiceArray } }
}
% \end{macrocode}
%
% \bigskip
% The following command will be linked to |\NotEmpty| in the environments of
% \pkg{nicematrix}.
% \begin{macrocode}
\cs_new_protected:Npn \@@_NotEmpty:
{ \bool_gset_true:N \g_@@_not_empty_cell_bool }
% \end{macrocode}
%
% \bigskip
% \subsection*{\{NiceTabular\}, \{NiceTabularX\} and \{NiceTabular*\}}
%
% \begin{macrocode}
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
{
% \end{macrocode}
% If the dimension |\l_@@_width_dim| is equal to $0$~pt, that means that it has
% not be set by a previous use of |\NiceMatrixOptions|.
% \begin{macrocode}
\dim_compare:nNnT \l_@@_width_dim = \c_zero_dim
{ \dim_set_eq:NN \l_@@_width_dim \linewidth }
\str_gset:Nn \g_@@_name_env_str { NiceTabular }
\keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 }
\bool_set_true:N \l_@@_NiceTabular_bool
\NiceArray { #2 }
}
{ \endNiceArray }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_set_protected:Npn \@@_newcolumntype #1
{
\cs_if_free:cT { NC @ find @ #1 }
{ \NC@list \expandafter { \the \NC@list \NC@do #1 } }
\cs_set:cpn {NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } }
\peek_meaning:NTF [
{ \newcol@ #1 }
{ \newcol@ #1 [ 0 ] }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\NewDocumentEnvironment { NiceTabularX } { m O { } m ! O { } }
{
% \end{macrocode}
% The following code prevents the expansion of the `X` columns with the
% definition of that columns in \pkg{tabularx} (this would result in an error in
% |{NiceTabularX}|).
% \begin{macrocode}
\bool_if:NT \c_@@_tabularx_loaded_bool { \newcolumntype { X } { \@@_X } }
\str_gset:Nn \g_@@_name_env_str { NiceTabularX }
\dim_zero_new:N \l_@@_width_dim
\dim_set:Nn \l_@@_width_dim { #1 }
\keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 }
\bool_set_true:N \l_@@_NiceTabular_bool
\NiceArray { #3 }
}
{ \endNiceArray }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\NewDocumentEnvironment { NiceTabular* } { m O { } m ! O { } }
{
\str_gset:Nn \g_@@_name_env_str { NiceTabular* }
\dim_set:Nn \l_@@_tabular_width_dim { #1 }
\keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 }
\bool_set_true:N \l_@@_NiceTabular_bool
\NiceArray { #3 }
}
{ \endNiceArray }
% \end{macrocode}
%
%
% \bigskip
% \subsection*{After the construction of the array}
%
% \medskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_after_array:
{
\group_begin:
% \end{macrocode}
% When the option |last-col| is used in the environments with explicit preambles
% (like |{NiceArray}|, |{pNiceArray}|, etc.) a special type of column is used at
% the end of the preamble in order to compose the cells in an overlapping
% position (with |\hbox_overlap_right:n|) but (if |last-col| has been used), we
% don't have the number of that last column. However, we have to know that
% number for the color of the potential |\Vdots| drawn in that last column.
% That's why we fix the correct value of |\l_@@_last_col_int| in that case.
% \begin{macrocode}
\bool_if:NT \g_@@_last_col_found_bool
{ \int_set_eq:NN \l_@@_last_col_int \g_@@_col_total_int }
% \end{macrocode}
%
% If we are in an environment without preamble (like |{NiceMatrix}| or
% |{pNiceMatrix}|) and if the option |last-col| has been used without value
% we also fix the real value of |\l_@@_last_col_int|.
% \begin{macrocode}
\bool_if:NT \l_@@_last_col_without_value_bool
{ \int_set_eq:NN \l_@@_last_col_int \g_@@_col_total_int }
% \end{macrocode}
%
% \medskip
% It's also time to give to |\l_@@_last_row_int| its real value.
% \begin{macrocode}
\bool_if:NT \l_@@_last_row_without_value_bool
{ \int_set_eq:NN \l_@@_last_row_int \g_@@_row_total_int }
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\tl_gput_right:Nx \g_@@_aux_tl
{
\seq_gset_from_clist:Nn \exp_not:N \g_@@_size_seq
{
\int_use:N \l_@@_first_row_int ,
\int_use:N \c@iRow ,
\int_use:N \g_@@_row_total_int ,
\int_use:N \l_@@_first_col_int ,
\int_use:N \c@jCol ,
\int_use:N \g_@@_col_total_int
}
}
% \end{macrocode}
% We write also the potential content of |\g_@@_pos_of_blocks_seq|. It will be
% used to recreate the blocks with a name in the |\CodeBefore| and also if the
% command |\rowcolors| is used with the key |respect-blocks|).
% \begin{macrocode}
\seq_if_empty:NF \g_@@_pos_of_blocks_seq
{
\tl_gput_right:Nx \g_@@_aux_tl
{
\seq_gset_from_clist:Nn \exp_not:N \g_@@_pos_of_blocks_seq
{ \seq_use:Nnnn \g_@@_pos_of_blocks_seq , , , }
}
}
\seq_if_empty:NF \g_@@_multicolumn_cells_seq
{
\tl_gput_right:Nx \g_@@_aux_tl
{
\seq_gset_from_clist:Nn \exp_not:N \g_@@_multicolumn_cells_seq
{ \seq_use:Nnnn \g_@@_multicolumn_cells_seq , , , }
\seq_gset_from_clist:Nn \exp_not:N \g_@@_multicolumn_sizes_seq
{ \seq_use:Nnnn \g_@@_multicolumn_sizes_seq , , , }
}
}
% \end{macrocode}
%
% \medskip
% Now, you create the diagonal nodes by using the |row| nodes and the |col|
% nodes.
% \begin{macrocode}
\@@_create_diag_nodes:
% \end{macrocode}
%
% \medskip
% We create the aliases using |last| for the nodes of the cells in the last row
% and the last column.
% \begin{macrocode}
\pgfpicture
\int_step_inline:nn \c@iRow
{
\pgfnodealias
{ \@@_env: - ##1 - last }
{ \@@_env: - ##1 - \int_use:N \c@jCol }
}
\int_step_inline:nn \c@jCol
{
\pgfnodealias
{ \@@_env: - last - ##1 }
{ \@@_env: - \int_use:N \c@iRow - ##1 }
}
\str_if_empty:NF \l_@@_name_str
{
\int_step_inline:nn \c@iRow
{
\pgfnodealias
{ \l_@@_name_str - ##1 - last }
{ \@@_env: - ##1 - \int_use:N \c@jCol }
}
\int_step_inline:nn \c@jCol
{
\pgfnodealias
{ \l_@@_name_str - last - ##1 }
{ \@@_env: - \int_use:N \c@iRow - ##1 }
}
}
\endpgfpicture
% \end{macrocode}
%
% By default, the diagonal lines will be parallelized\footnote{It's possible to
% use the option |parallelize-diags| to disable this parallelization.}. There
% are two types of diagonals lines: the $|\Ddots|$ diagonals and the |\Iddots|
% diagonals. We have to count both types in order to know whether a diagonal is
% the first of its type in the current |{NiceArray}| environment.
% \begin{macrocode}
\bool_if:NT \l_@@_parallelize_diags_bool
{
\int_gzero_new:N \g_@@_ddots_int
\int_gzero_new:N \g_@@_iddots_int
% \end{macrocode}
%
% The dimensions |\g_@@_delta_x_one_dim| and |\g_@@_delta_y_one_dim| will
% contain the $\Delta_x$ and $\Delta_y$ of the first |\Ddots| diagonal. We have
% to store these values in order to draw the others |\Ddots| diagonals parallel
% to the first one. Similarly |\g_@@_delta_x_two_dim| and
% |\g_@@_delta_y_two_dim| are the $\Delta_x$ and $\Delta_y$ of the first
% |\Iddots| diagonal.
% \begin{macrocode}
\dim_gzero_new:N \g_@@_delta_x_one_dim
\dim_gzero_new:N \g_@@_delta_y_one_dim
\dim_gzero_new:N \g_@@_delta_x_two_dim
\dim_gzero_new:N \g_@@_delta_y_two_dim
}
% \end{macrocode}
%
% \begin{macrocode}
\int_zero_new:N \l_@@_initial_i_int
\int_zero_new:N \l_@@_initial_j_int
\int_zero_new:N \l_@@_final_i_int
\int_zero_new:N \l_@@_final_j_int
\bool_set_false:N \l_@@_initial_open_bool
\bool_set_false:N \l_@@_final_open_bool
% \end{macrocode}
%
% If the option |small| is used, the values |\l_@@_radius_dim| and
% |\l_@@_inter_dots_dim| (used to draw the dotted lines created by
% |\hdottedline| and |\vdottedline| and also for all the other dotted lines when
% |line-style| is equal to |standard|, which is the initial value) are changed.
% \begin{macrocode}
\bool_if:NT \l_@@_small_bool
{
\dim_set:Nn \l_@@_radius_dim { 0.37 pt }
\dim_set:Nn \l_@@_inter_dots_dim { 0.25 em }
% \end{macrocode}
% The dimension |\l_@@_xdots_shorten_dim| corresponds to the option
% |xdots/shorten| available to the user. That's why we give a new value
% according to the current value, and not an absolute value.
% \begin{macrocode}
\dim_set:Nn \l_@@_xdots_shorten_dim { 0.6 \l_@@_xdots_shorten_dim }
}
% \end{macrocode}
%
% \bigskip
% Now, we actually draw the dotted lines (specified by |\Cdots|, |\Vdots|,
% etc.).
% \begin{macrocode}
\@@_draw_dotted_lines:
% \end{macrocode}
%
% \bigskip
% The following computes the ``corners'' (made up of empty cells) but if there
% is no corner to compute, it won't do anything. The corners are computed
% in |\l_@@_corners_cells_seq| which will contain all the cells which are empty
% (and not in a block) considered in the corners of the array.
% \begin{macrocode}
\@@_compute_corners:
% \end{macrocode}
%
% \bigskip
% The sequence |\g_@@_pos_of_blocks_seq| must be ``adjusted'' (for the case
% where the user have written something like |\Block{1-*}|).
% \begin{macrocode}
\@@_adjust_pos_of_blocks_seq:
% \end{macrocode}
%
% \begin{macrocode}
\tl_if_empty:NF \l_@@_hlines_clist \@@_draw_hlines:
\tl_if_empty:NF \l_@@_vlines_clist \@@_draw_vlines:
% \end{macrocode}
%
% \bigskip
% Now, the internal |code-after| and then, the |\CodeAfter|.
% \begin{macrocode}
\bool_if:NT \c_@@_tikz_loaded_bool
{
\tikzset
{
every~picture / .style =
{
overlay ,
remember~picture ,
name~prefix = \@@_env: -
}
}
}
\cs_set_eq:NN \ialign \@@_old_ialign:
\cs_set_eq:NN \SubMatrix \@@_SubMatrix
\cs_set_eq:NN \UnderBrace \@@_UnderBrace
\cs_set_eq:NN \OverBrace \@@_OverBrace
\cs_set_eq:NN \line \@@_line
\g_@@_internal_code_after_tl
\tl_gclear:N \g_@@_internal_code_after_tl
% \end{macrocode}
% When |light-syntax| is used, we insert systematically a |\CodeAfter| in the
% flow. Thus, it's possible to have two instructions |\CodeAfter| and the second
% may be in |\g_nicematrix_code_after_tl|. That's why we set
% |\Code-after| to be \textsl{no-op} now.
% \begin{macrocode}
\cs_set_eq:NN \CodeAfter \prg_do_nothing:
% \end{macrocode}
%
% We clear the list of the names of the potential |\SubMatrix| that will appear
% in the |\CodeAfter| (unfortunately, that list has to be global).
% \begin{macrocode}
\seq_gclear:N \g_@@_submatrix_names_seq
% \end{macrocode}
%
% \medskip
% And here's the |\CodeAfter|. Since the |\CodeAfter| may begin with an
% ``argument'' between square brackets of the options, we extract and treat that
% potential ``argument'' with the command |\@@_CodeAfter_keys:|.
% \begin{macrocode}
\exp_last_unbraced:NV \@@_CodeAfter_keys: \g_nicematrix_code_after_tl
\scan_stop:
\tl_gclear:N \g_nicematrix_code_after_tl
\group_end:
% \end{macrocode}
%
%
% \medskip
% |\g_nicematrix_code_before_tl| is for instructions in the cells of the array such as
% |\rowcolor| and |\cellcolor| (when the key |colortbl-like| is in
% force). These instructions will be written on the |aux| file to be added to
% the |code-before| in the next run.
% \begin{macrocode}
\tl_if_empty:NF \g_nicematrix_code_before_tl
{
% \end{macrocode}
% The command |\rowcolor| in tabular will in fact use |\rectanglecolor| in order
% to follow the behaviour of |\rowcolor| of \pkg{colortbl}. That's why there may
% be a command |\rectanglecolor| in |\g_nicematrix_code_before_tl|. In order to avoid an
% error during the expansion, we define a protected version of |\rectanglecolor|.
% \begin{macrocode}
\cs_set_protected:Npn \rectanglecolor { }
\cs_set_protected:Npn \columncolor { }
\tl_gput_right:Nx \g_@@_aux_tl
{
\tl_gset:Nn \exp_not:N \g_@@_code_before_tl
{ \exp_not:V \g_nicematrix_code_before_tl }
}
\bool_set_true:N \l_@@_code_before_bool
}
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\str_gclear:N \g_@@_name_env_str
\@@_restore_iRow_jCol:
% \end{macrocode}
% The command |\CT@arc@| contains the instruction of color for the rules of the
% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|}. This command is used by
% |\CT@arc@| but we use it also for compatibility with \pkg{colortbl}. But we
% want also to be able to use color for the rules of the array when
% \pkg{colortbl} is \emph{not} loaded. That's why we do the following
% instruction which is in the patch of the end of arrays done by \pkg{colortbl}.
% \begin{macrocode}
\cs_gset_eq:NN \CT@arc@ \@@_old_CT@arc@
}
% \end{macrocode}
%
% \bigskip
% The following command will extract the potential options (between square
% brackets) at the beginning of the |\CodeAfter| (that is to say, when
% |\CodeAfter| is used, the options of that ``command'' |\CodeAfter|). Idem for
% the |\CodeBefore.|
% \begin{macrocode}
\NewDocumentCommand \@@_CodeAfter_keys: { O { } }
{ \keys_set:nn { NiceMatrix / CodeAfter } { #1 } }
% \end{macrocode}
%
%
%
% \bigskip
% We remind that the first mandatory argument of the command |\Block| is the
% size of the block with the special format $i$|-|$j$. However, the user is
% allowed to omit $i$ or $j$ (or both). This will be interpreted as: the last
% row (resp. column) of the block will be the last row (resp. column) of the
% block (without the potential exterior row---resp. column---of the array). By
% convention, this is stored in |\g_@@_pos_of_blocks_seq| (and
% |\g_@@_blocks_seq|) as a number of rows (resp. columns) for the block equal to
% 100. It's possible, after the construction of the array, to replace these
% values by the correct ones (since we know the number of rows and columns of
% the array).
% \begin{macrocode}
\cs_new_protected:Npn \@@_adjust_pos_of_blocks_seq:
{
\seq_gset_map_x:NNn \g_@@_pos_of_blocks_seq \g_@@_pos_of_blocks_seq
{ \@@_adjust_pos_of_blocks_seq_i:nnnnn ##1 }
}
% \end{macrocode}
%
% The following command must \emph{not} be protected.
% \begin{macrocode}
\cs_new:Npn \@@_adjust_pos_of_blocks_seq_i:nnnnn #1 #2 #3 #4 #5
{
{ #1 }
{ #2 }
{
\int_compare:nNnTF { #3 } > { 99 }
{ \int_use:N \c@iRow }
{ #3 }
}
{
\int_compare:nNnTF { #4 } > { 99 }
{ \int_use:N \c@jCol }
{ #4 }
}
{ #5 }
}
% \end{macrocode}
%
% \bigskip
% We recall that, when externalization is used, |\tikzpicture| and
% |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly
% ``visible''. That's why we have to define the adequate version of
% |\@@_draw_dotted_lines:| whether Tikz is loaded or not (in that case, only
% \textsc{pgf} is loaded).
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\cs_new_protected:Npx \@@_draw_dotted_lines:
{
\c_@@_pgfortikzpicture_tl
\@@_draw_dotted_lines_i:
\c_@@_endpgfortikzpicture_tl
}
}
% \end{macrocode}
%
% The following command \emph{must} be protected because it will appear in the
% construction of the command |\@@_draw_dotted_lines:|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_dotted_lines_i:
{
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\g_@@_HVdotsfor_lines_tl
\g_@@_Vdots_lines_tl
\g_@@_Ddots_lines_tl
\g_@@_Iddots_lines_tl
\g_@@_Cdots_lines_tl
\g_@@_Ldots_lines_tl
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_restore_iRow_jCol:
{
\cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l_@@_old_iRow_int }
\cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l_@@_old_jCol_int }
}
% \end{macrocode}
%
% \bigskip
% We define a new \textsc{pgf} shape for the diag nodes because we want to
% provide a anchor called |.5| for those nodes.
% \begin{macrocode}
\pgfdeclareshape { @@_diag_node }
{
\savedanchor { \five }
{
\dim_gset_eq:NN \pgf@x \l_tmpa_dim
\dim_gset_eq:NN \pgf@y \l_tmpb_dim
}
\anchor { 5 } { \five }
\anchor { center } { \pgfpointorigin }
}
% \end{macrocode}
%
%
%
% \bigskip
% The following command creates the diagonal nodes (in fact, if the matrix is
% not a square matrix, not all the nodes are on the diagonal).
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_diag_nodes:
{
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\int_step_inline:nn { \int_max:nn \c@iRow \c@jCol }
{
\@@_qpoint:n { col - \int_min:nn { ##1 } { \c@jCol + 1 } }
\dim_set_eq:NN \l_tmpa_dim \pgf@x
\@@_qpoint:n { row - \int_min:nn { ##1 } { \c@iRow + 1 } }
\dim_set_eq:NN \l_tmpb_dim \pgf@y
\@@_qpoint:n { col - \int_min:nn { ##1 + 1 } { \c@jCol + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@x
\@@_qpoint:n { row - \int_min:nn { ##1 + 1 } { \c@iRow + 1 } }
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@y
\pgftransformshift { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
% \end{macrocode}
% Now, |\l_tmpa_dim| and |\l_tmpb_dim| become the width and the height of the
% node (of shape |@à_diag_node|) that we will construct.
% \begin{macrocode}
\dim_set:Nn \l_tmpa_dim { ( \l_@@_tmpc_dim - \l_tmpa_dim ) / 2 }
\dim_set:Nn \l_tmpb_dim { ( \l_@@_tmpd_dim - \l_tmpb_dim ) / 2 }
\pgfnode { @@_diag_node } { center } { } { \@@_env: - ##1 } { }
\str_if_empty:NF \l_@@_name_str
{ \pgfnodealias { \l_@@_name_str - ##1 } { \@@_env: - ##1 } }
}
% \end{macrocode}
% Now, the last node. Of course, that is only a |coordinate| because there is
% not |.5| anchor for that node.
% \begin{macrocode}
\int_set:Nn \l_tmpa_int { \int_max:nn \c@iRow \c@jCol + 1 }
\@@_qpoint:n { row - \int_min:nn { \l_tmpa_int } { \c@iRow + 1 } }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\@@_qpoint:n { col - \int_min:nn { \l_tmpa_int } { \c@jCol + 1 } }
\pgfcoordinate
{ \@@_env: - \int_use:N \l_tmpa_int } { \pgfpoint \pgf@x \l_tmpa_dim }
\pgfnodealias
{ \@@_env: - last }
{ \@@_env: - \int_eval:n { \int_max:nn \c@iRow \c@jCol + 1 } }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{ \l_@@_name_str - \int_use:N \l_tmpa_int }
{ \@@_env: - \int_use:N \l_tmpa_int }
\pgfnodealias
{ \l_@@_name_str - last }
{ \@@_env: - last }
}
\endpgfpicture
}
% \end{macrocode}
%
%
% \bigskip
% \subsection*{We draw the dotted lines}
%
% A dotted line will be said \emph{open} in one of its extremities when it stops
% on the edge of the matrix and \emph{closed} otherwise. In the following
% matrix, the dotted line is closed on its left extremity and open on its right.
% \[ \begin{pNiceMatrix}
% a+b+c & a+b & a\\
% a & \Cdots \\
% a & a+b & a+b+c
% \end{pNiceMatrix}\]
%
%
% \bigskip
% The command |\@@_find_extremities_of_line:nnnn| takes four arguments:
%
% \begin{itemize}
% \item the first argument is the row of the cell where the command was issued;
% \item the second argument is the column of the cell where the command was
% issued;
% \item the third argument is the $x$-value of the orientation vector of the
% line;
% \item the fourth argument is the $y$-value of the orientation vector of the
% line.
% \end{itemize}
%
% This command computes:
%
% \begin{itemize}
% \item |\l_@@_initial_i_int| and |\l_@@_initial_j_int| which are the
% coordinates of one extremity of the line;
% \item |\l_@@_final_i_int| and |\l_@@_final_j_int| which are the coordinates of
% the other extremity of the line;
% \item |\l_@@_initial_open_bool| and |\l_@@_final_open_bool| to indicate
% whether the extremities are open or not.
% \end{itemize}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_find_extremities_of_line:nnnn #1 #2 #3 #4
{
% \end{macrocode}
% First, we declare the current cell as ``dotted'' because we forbide
% intersections of dotted lines.
% \begin{macrocode}
\cs_set:cpn { @@ _ dotted _ #1 - #2 } { }
% \end{macrocode}
% Initialization of variables.
% \begin{macrocode}
\int_set:Nn \l_@@_initial_i_int { #1 }
\int_set:Nn \l_@@_initial_j_int { #2 }
\int_set:Nn \l_@@_final_i_int { #1 }
\int_set:Nn \l_@@_final_j_int { #2 }
% \end{macrocode}
% We will do two loops: one when determinating the initial cell and the other
% when determinating the final cell. The boolean |\l_@@_stop_loop_bool| will be
% used to control these loops. In the first loop, we search the ``final''
% extremity of the line.
% \begin{macrocode}
\bool_set_false:N \l_@@_stop_loop_bool
\bool_do_until:Nn \l_@@_stop_loop_bool
{
\int_add:Nn \l_@@_final_i_int { #3 }
\int_add:Nn \l_@@_final_j_int { #4 }
% \end{macrocode}
% We test if we are still in the matrix.
% \begin{macrocode}
\bool_set_false:N \l_@@_final_open_bool
\int_compare:nNnTF \l_@@_final_i_int > \l_@@_row_max_int
{
\int_compare:nNnTF { #3 } = 1
{ \bool_set_true:N \l_@@_final_open_bool }
{
\int_compare:nNnT \l_@@_final_j_int > \l_@@_col_max_int
{ \bool_set_true:N \l_@@_final_open_bool }
}
}
{
\int_compare:nNnTF \l_@@_final_j_int < \l_@@_col_min_int
{
\int_compare:nNnT { #4 } = { -1 }
{ \bool_set_true:N \l_@@_final_open_bool }
}
{
\int_compare:nNnT \l_@@_final_j_int > \l_@@_col_max_int
{
\int_compare:nNnT { #4 } = 1
{ \bool_set_true:N \l_@@_final_open_bool }
}
}
}
\bool_if:NTF \l_@@_final_open_bool
% \end{macrocode}
% If we are outside the matrix, we have found the extremity of the dotted line
% and it's an \emph{open} extremity.
% \begin{macrocode}
{
% \end{macrocode}
% We do a step backwards.
% \begin{macrocode}
\int_sub:Nn \l_@@_final_i_int { #3 }
\int_sub:Nn \l_@@_final_j_int { #4 }
\bool_set_true:N \l_@@_stop_loop_bool
}
% \end{macrocode}
% If we are in the matrix, we test whether the cell is empty. If it's not the
% case, we stop the loop because we have found the correct values for
% |\l_@@_final_i_int| and |\l_@@_final_j_int|.
% \begin{macrocode}
{
\cs_if_exist:cTF
{
@@ _ dotted _
\int_use:N \l_@@_final_i_int -
\int_use:N \l_@@_final_j_int
}
{
\int_sub:Nn \l_@@_final_i_int { #3 }
\int_sub:Nn \l_@@_final_j_int { #4 }
\bool_set_true:N \l_@@_final_open_bool
\bool_set_true:N \l_@@_stop_loop_bool
}
{
\cs_if_exist:cTF
{
pgf @ sh @ ns @ \@@_env:
- \int_use:N \l_@@_final_i_int
- \int_use:N \l_@@_final_j_int
}
{ \bool_set_true:N \l_@@_stop_loop_bool }
% \end{macrocode}
% If the case is empty, we declare that the cell as non-empty. Indeed, we will
% draw a dotted line and the cell will be on that dotted line. All the cells of
% a dotted line have to be marked as ``dotted'' because we don't want
% intersections between dotted lines. We recall that the research of the
% extremities of the lines are all done in the same TeX group (the group of the
% environment), even though, when the extremities are found, each line is
% drawn in a TeX group that we will open for the options of the line.
% \begin{macrocode}
{
\cs_set:cpn
{
@@ _ dotted _
\int_use:N \l_@@_final_i_int -
\int_use:N \l_@@_final_j_int
}
{ }
}
}
}
}
% \end{macrocode}
%
% \interitem
% For |\l_@@_initial_i_int| and |\l_@@_initial_j_int| the programmation is
% similar to the previous one.
% \begin{macrocode}
\bool_set_false:N \l_@@_stop_loop_bool
\bool_do_until:Nn \l_@@_stop_loop_bool
{
\int_sub:Nn \l_@@_initial_i_int { #3 }
\int_sub:Nn \l_@@_initial_j_int { #4 }
\bool_set_false:N \l_@@_initial_open_bool
\int_compare:nNnTF \l_@@_initial_i_int < \l_@@_row_min_int
{
\int_compare:nNnTF { #3 } = 1
{ \bool_set_true:N \l_@@_initial_open_bool }
{
\int_compare:nNnT \l_@@_initial_j_int = { \l_@@_col_min_int -1 }
{ \bool_set_true:N \l_@@_initial_open_bool }
}
}
{
\int_compare:nNnTF \l_@@_initial_j_int < \l_@@_col_min_int
{
\int_compare:nNnT { #4 } = 1
{ \bool_set_true:N \l_@@_initial_open_bool }
}
{
\int_compare:nNnT \l_@@_initial_j_int > \l_@@_col_max_int
{
\int_compare:nNnT { #4 } = { -1 }
{ \bool_set_true:N \l_@@_initial_open_bool }
}
}
}
\bool_if:NTF \l_@@_initial_open_bool
{
\int_add:Nn \l_@@_initial_i_int { #3 }
\int_add:Nn \l_@@_initial_j_int { #4 }
\bool_set_true:N \l_@@_stop_loop_bool
}
{
\cs_if_exist:cTF
{
@@ _ dotted _
\int_use:N \l_@@_initial_i_int -
\int_use:N \l_@@_initial_j_int
}
{
\int_add:Nn \l_@@_initial_i_int { #3 }
\int_add:Nn \l_@@_initial_j_int { #4 }
\bool_set_true:N \l_@@_initial_open_bool
\bool_set_true:N \l_@@_stop_loop_bool
}
{
\cs_if_exist:cTF
{
pgf @ sh @ ns @ \@@_env:
- \int_use:N \l_@@_initial_i_int
- \int_use:N \l_@@_initial_j_int
}
{ \bool_set_true:N \l_@@_stop_loop_bool }
{
\cs_set:cpn
{
@@ _ dotted _
\int_use:N \l_@@_initial_i_int -
\int_use:N \l_@@_initial_j_int
}
{ }
}
}
}
}
% \end{macrocode}
% We remind the rectangle described by all the dotted lines in order to respect
% the corresponding virtual ``block'' when drawing the horizontal and vertical
% rules.
% \begin{macrocode}
\seq_gput_right:Nx \g_@@_pos_of_xdots_seq
{
{ \int_use:N \l_@@_initial_i_int }
% \end{macrocode}
% Be careful: with |\Iddots|, |\l_@@_final_j_int| is inferior to
% |\l_@@_initial_j_int|. That's why we use |\int_min:nn| and |\int_max:nn|.
% \begin{macrocode}
{ \int_min:nn \l_@@_initial_j_int \l_@@_final_j_int }
{ \int_use:N \l_@@_final_i_int }
{ \int_max:nn \l_@@_initial_j_int \l_@@_final_j_int }
{ } % for the name of the block
}
}
% \end{macrocode}
%
% \medskip
% The following commmand (\emph{when it will be written}) will set the four
% counters |\l_@@_row_min_int|, |\l_@@_row_max_int|, |\l_@@_col_min_int| and
% |\l_@@_col_max_int| to the intersections of the sub-matrices which contains
% the cell of row |#1| and column |#2|. As of now, it's only the whole array
% (excepted exterior rows and columns).
% \begin{macrocode}
\cs_new_protected:Npn \@@_adjust_to_submatrix:nn #1 #2
{
\int_set:Nn \l_@@_row_min_int 1
\int_set:Nn \l_@@_col_min_int 1
\int_set_eq:NN \l_@@_row_max_int \c@iRow
\int_set_eq:NN \l_@@_col_max_int \c@jCol
% \end{macrocode}
% We do a loop over all the submatrices specified in the |code-before|. We have
% stored the position of all those submatrices in |\g_@@_submatrix_seq|.
% \begin{macrocode}
\seq_map_inline:Nn \g_@@_submatrix_seq
{ \@@_adjust_to_submatrix:nnnnnn { #1 } { #2 } ##1 }
}
% \end{macrocode}
%
% \medskip
% |#1| and |#2| are the numbers of row and columns of the cell where the command
% of dotted line (ex.: |\Vdots|) has been issued. |#3|, |#4|, |#5| and |#6| are
% the specification (in $i$ and $j$) of the submatrix where are analysing.
% \begin{macrocode}
\cs_set_protected:Npn \@@_adjust_to_submatrix:nnnnnn #1 #2 #3 #4 #5 #6
{
\bool_if:nT
{
\int_compare_p:n { #3 <= #1 }
&& \int_compare_p:n { #1 <= #5 }
&& \int_compare_p:n { #4 <= #2 }
&& \int_compare_p:n { #2 <= #6 }
}
{
\int_set:Nn \l_@@_row_min_int { \int_max:nn \l_@@_row_min_int { #3 } }
\int_set:Nn \l_@@_col_min_int { \int_max:nn \l_@@_col_min_int { #4 } }
\int_set:Nn \l_@@_row_max_int { \int_min:nn \l_@@_row_max_int { #5 } }
\int_set:Nn \l_@@_col_max_int { \int_min:nn \l_@@_col_max_int { #6 } }
}
}
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_set_initial_coords:
{
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
}
\cs_new_protected:Npn \@@_set_final_coords:
{
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y
}
\cs_new_protected:Npn \@@_set_initial_coords_from_anchor:n #1
{
\pgfpointanchor
{
\@@_env:
- \int_use:N \l_@@_initial_i_int
- \int_use:N \l_@@_initial_j_int
}
{ #1 }
\@@_set_initial_coords:
}
\cs_new_protected:Npn \@@_set_final_coords_from_anchor:n #1
{
\pgfpointanchor
{
\@@_env:
- \int_use:N \l_@@_final_i_int
- \int_use:N \l_@@_final_j_int
}
{ #1 }
\@@_set_final_coords:
}
% \end{macrocode}
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_open_x_initial_dim:
{
\dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_initial_j_int }
{
\pgfpointanchor
{ \@@_env: - ##1 - \int_use:N \l_@@_initial_j_int }
{ west }
\dim_set:Nn \l_@@_x_initial_dim
{ \dim_min:nn \l_@@_x_initial_dim \pgf@x }
}
}
% \end{macrocode}
% If, in fact, all the cells of the columns are empty (no PGF/Tikz nodes in
% those cells).
% \begin{macrocode}
\dim_compare:nNnT \l_@@_x_initial_dim = \c_max_dim
{
\@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
\dim_add:Nn \l_@@_x_initial_dim \col@sep
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_open_x_final_dim:
{
\dim_set:Nn \l_@@_x_final_dim { - \c_max_dim }
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_final_j_int }
{
\pgfpointanchor
{ \@@_env: - ##1 - \int_use:N \l_@@_final_j_int }
{ east }
\dim_set:Nn \l_@@_x_final_dim
{ \dim_max:nn \l_@@_x_final_dim \pgf@x }
}
}
% \end{macrocode}
% If, in fact, all the cells of the columns are empty (no PGF/Tikz nodes in
% those cells).
% \begin{macrocode}
\dim_compare:nNnT \l_@@_x_final_dim = { - \c_max_dim }
{
\@@_qpoint:n { col - \int_eval:n { \l_@@_final_j_int + 1 } }
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x
\dim_sub:Nn \l_@@_x_final_dim \col@sep
}
}
% \end{macrocode}
%
%
%
% \interitem
% The first and the second arguments are the coordinates of the cell where the
% command has been issued. The third argument is the list of the options.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Ldots:nnn #1 #2 #3
{
\@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 0 1
% \end{macrocode}
% The previous command may have changed the current environment by marking some
% cells as ``dotted'', but, fortunately, it is outside the group for the options
% of the line.
% \begin{macrocode}
\group_begin:
\int_compare:nNnTF { #1 } = 0
{ \color { nicematrix-first-row } }
{
% \end{macrocode}
% We remind that, when there is a ``last row'' |\l_@@_last_row_int| will always
% be (after the construction of the array) the number of that ``last row'' even
% if the option |last-row| has been used without value.
% \begin{macrocode}
\int_compare:nNnT { #1 } = \l_@@_last_row_int
{ \color { nicematrix-last-row } }
}
\keys_set:nn { NiceMatrix / xdots } { #3 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Ldots:
\group_end:
}
}
% \end{macrocode}
%
%
% \medskip
% The command |\@@_actually_draw_Ldots:| has the following implicit arguments:
% \begin{itemize}
% \item |\l_@@_initial_i_int|
% \item |\l_@@_initial_j_int|
% \item |\l_@@_initial_open_bool|
% \item |\l_@@_final_i_int|
% \item |\l_@@_final_j_int|
% \item |\l_@@_final_open_bool|.
% \end{itemize}
%
% The following function is also used by |\Hdotsfor|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_actually_draw_Ldots:
{
\bool_if:NTF \l_@@_initial_open_bool
{
\@@_open_x_initial_dim:
\@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base }
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
}
{ \@@_set_initial_coords_from_anchor:n { base~east } }
\bool_if:NTF \l_@@_final_open_bool
{
\@@_open_x_final_dim:
\@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base }
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y
}
{ \@@_set_final_coords_from_anchor:n { base~west } }
% \end{macrocode}
% We raise the line of a quantity equal to the radius of the dots because we
% want the dots really ``on'' the line of texte. Of course, maybe we should not
% do that when the option |line-style| is used (?).
% \begin{macrocode}
\dim_add:Nn \l_@@_y_initial_dim \l_@@_radius_dim
\dim_add:Nn \l_@@_y_final_dim \l_@@_radius_dim
\@@_draw_line:
}
% \end{macrocode}
%
% \interitem
% The first and the second arguments are the coordinates of the cell where the
% command has been issued. The third argument is the list of the options.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Cdots:nnn #1 #2 #3
{
\@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 0 1
% \end{macrocode}
% The previous command may have changed the current environment by marking some
% cells as ``dotted'', but, fortunately, it is outside the group for the options
% of the line.
% \begin{macrocode}
\group_begin:
\int_compare:nNnTF { #1 } = 0
{ \color { nicematrix-first-row } }
{
% \end{macrocode}
% We remind that, when there is a ``last row'' |\l_@@_last_row_int| will always
% be (after the construction of the array) the number of that ``last row'' even
% if the option |last-row| has been used without value.
% \begin{macrocode}
\int_compare:nNnT { #1 } = \l_@@_last_row_int
{ \color { nicematrix-last-row } }
}
\keys_set:nn { NiceMatrix / xdots } { #3 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Cdots:
\group_end:
}
}
% \end{macrocode}
%
%
% \medskip
% The command |\@@_actually_draw_Cdots:| has the following implicit arguments:
% \begin{itemize}
% \item |\l_@@_initial_i_int|
% \item |\l_@@_initial_j_int|
% \item |\l_@@_initial_open_bool|
% \item |\l_@@_final_i_int|
% \item |\l_@@_final_j_int|
% \item |\l_@@_final_open_bool|.
% \end{itemize}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_actually_draw_Cdots:
{
\bool_if:NTF \l_@@_initial_open_bool
{ \@@_open_x_initial_dim: }
{ \@@_set_initial_coords_from_anchor:n { mid~east } }
\bool_if:NTF \l_@@_final_open_bool
{ \@@_open_x_final_dim: }
{ \@@_set_final_coords_from_anchor:n { mid~west } }
\bool_lazy_and:nnTF
\l_@@_initial_open_bool
\l_@@_final_open_bool
{
\@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\@@_qpoint:n { row - \int_eval:n { \l_@@_initial_i_int + 1 } }
\dim_set:Nn \l_@@_y_initial_dim { ( \l_tmpa_dim + \pgf@y ) / 2 }
\dim_set_eq:NN \l_@@_y_final_dim \l_@@_y_initial_dim
}
{
\bool_if:NT \l_@@_initial_open_bool
{ \dim_set_eq:NN \l_@@_y_initial_dim \l_@@_y_final_dim }
\bool_if:NT \l_@@_final_open_bool
{ \dim_set_eq:NN \l_@@_y_final_dim \l_@@_y_initial_dim }
}
\@@_draw_line:
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_open_y_initial_dim:
{
\@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base }
\dim_set:Nn \l_@@_y_initial_dim
{ \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch }
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - \int_use:N \l_@@_initial_i_int - ##1 }
{
\pgfpointanchor
{ \@@_env: - \int_use:N \l_@@_initial_i_int - ##1 }
{ north }
\dim_set:Nn \l_@@_y_initial_dim
{ \dim_max:nn \l_@@_y_initial_dim \pgf@y }
}
}
}
% \end{macrocode}
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_open_y_final_dim:
{
\@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base }
\dim_set:Nn \l_@@_y_final_dim
{ \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch }
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - \int_use:N \l_@@_final_i_int - ##1 }
{
\pgfpointanchor
{ \@@_env: - \int_use:N \l_@@_final_i_int - ##1 }
{ south }
\dim_set:Nn \l_@@_y_final_dim
{ \dim_min:nn \l_@@_y_final_dim \pgf@y }
}
}
}
% \end{macrocode}
%
% The first and the second arguments are the coordinates of the cell where the
% command has been issued. The third argument is the list of the options.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Vdots:nnn #1 #2 #3
{
\@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 0
% \end{macrocode}
% The previous command may have changed the current environment by marking some
% cells as ``dotted'', but, fortunately, it is outside the group for the options
% of the line.
% \begin{macrocode}
\group_begin:
\int_compare:nNnTF { #2 } = 0
{ \color { nicematrix-first-col } }
{
\int_compare:nNnT { #2 } = \l_@@_last_col_int
{ \color { nicematrix-last-col } }
}
\keys_set:nn { NiceMatrix / xdots } { #3 }
\tl_if_empty:VF \l_@@_xdots_color_tl
{ \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Vdots:
\group_end:
}
}
% \end{macrocode}
%
% \bigskip
% The command |\@@_actually_draw_Vdots:| has the following implicit arguments:
% \begin{itemize}
% \item |\l_@@_initial_i_int|
% \item |\l_@@_initial_j_int|
% \item |\l_@@_initial_open_bool|
% \item |\l_@@_final_i_int|
% \item |\l_@@_final_j_int|
% \item |\l_@@_final_open_bool|.
% \end{itemize}
%
% The following function is also used by |\Vdotsfor|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_actually_draw_Vdots:
{
% \end{macrocode}
% The boolean |\l_tmpa_bool| indicates whether the column is of type |l| or may
% be considered as if.
% \begin{macrocode}
\bool_set_false:N \l_tmpa_bool
% \end{macrocode}
% First the case when the line is closed on both ends.
% \begin{macrocode}
\bool_lazy_or:nnF \l_@@_initial_open_bool \l_@@_final_open_bool
{
\@@_set_initial_coords_from_anchor:n { south~west }
\@@_set_final_coords_from_anchor:n { north~west }
\bool_set:Nn \l_tmpa_bool
{ \dim_compare_p:nNn \l_@@_x_initial_dim = \l_@@_x_final_dim }
}
% \end{macrocode}
% Now, we try to determine whether the column is of type |c| or may be
% considered as if.
% \begin{macrocode}
\bool_if:NTF \l_@@_initial_open_bool
\@@_open_y_initial_dim:
{ \@@_set_initial_coords_from_anchor:n { south } }
\bool_if:NTF \l_@@_final_open_bool
\@@_open_y_final_dim:
{ \@@_set_final_coords_from_anchor:n { north } }
\bool_if:NTF \l_@@_initial_open_bool
{
\bool_if:NTF \l_@@_final_open_bool
{
\@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
\dim_set_eq:NN \l_tmpa_dim \pgf@x
\@@_qpoint:n { col - \int_eval:n { \l_@@_initial_j_int + 1 } }
\dim_set:Nn \l_@@_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 }
\dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim
% \end{macrocode}
% We may think that the final user won't use a ``last column'' which contains
% only a command |\Vdots|. However, if the |\Vdots| is in fact used to draw, not
% a dotted line, but an arrow (to indicate the number of rows of the matrix), it
% may be really encountered.
% \begin{macrocode}
\int_compare:nNnT \l_@@_last_col_int > { -2 }
{
\int_compare:nNnT \l_@@_initial_j_int = \g_@@_col_total_int
{
\dim_set_eq:NN \l_tmpa_dim \l_@@_right_margin_dim
\dim_add:Nn \l_tmpa_dim \l_@@_extra_right_margin_dim
\dim_add:Nn \l_@@_x_initial_dim \l_tmpa_dim
\dim_add:Nn \l_@@_x_final_dim \l_tmpa_dim
}
}
}
{ \dim_set_eq:NN \l_@@_x_initial_dim \l_@@_x_final_dim }
}
{
\bool_if:NTF \l_@@_final_open_bool
{ \dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim }
{
% \end{macrocode}
% Now the case where both extremities are closed. The first conditional tests
% whether the column is of type |c| or may be considered as if.
% \begin{macrocode}
\dim_compare:nNnF \l_@@_x_initial_dim = \l_@@_x_final_dim
{
\dim_set:Nn \l_@@_x_initial_dim
{
\bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn
\l_@@_x_initial_dim \l_@@_x_final_dim
}
\dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim
}
}
}
\@@_draw_line:
}
% \end{macrocode}
%
% \interitem
% For the diagonal lines, the situation is a bit more complicated because, by
% default, we parallelize the diagonals lines. The first diagonal line is drawn
% and then, all the other diagonal lines are drawn parallel to the first one.
%
% The first and the second arguments are the coordinates of the cell where the
% command has been issued. The third argument is the list of the options.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Ddots:nnn #1 #2 #3
{
\@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 1
% \end{macrocode}
% The previous command may have changed the current environment by marking some
% cells as ``dotted'', but, fortunately, it is outside the group for the options
% of the line.
% \begin{macrocode}
\group_begin:
\keys_set:nn { NiceMatrix / xdots } { #3 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Ddots:
\group_end:
}
}
% \end{macrocode}
%
% \bigskip
% The command |\@@_actually_draw_Ddots:| has the following implicit arguments:
% \begin{itemize}
% \item |\l_@@_initial_i_int|
% \item |\l_@@_initial_j_int|
% \item |\l_@@_initial_open_bool|
% \item |\l_@@_final_i_int|
% \item |\l_@@_final_j_int|
% \item |\l_@@_final_open_bool|.
% \end{itemize}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_actually_draw_Ddots:
{
\bool_if:NTF \l_@@_initial_open_bool
{
\@@_open_y_initial_dim:
\@@_open_x_initial_dim:
}
{ \@@_set_initial_coords_from_anchor:n { south~east } }
\bool_if:NTF \l_@@_final_open_bool
{
\@@_open_x_final_dim:
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x
}
{ \@@_set_final_coords_from_anchor:n { north~west } }
% \end{macrocode}
% We have retrieved the coordinates in the usual way (they are stored in
% |\l_@@_x_initial_dim|, etc.). If the parallelization of the diagonals is set,
% we will have (maybe) to adjust the fourth coordinate.
% \begin{macrocode}
\bool_if:NT \l_@@_parallelize_diags_bool
{
\int_gincr:N \g_@@_ddots_int
% \end{macrocode}
% We test if the diagonal line is the first one (the counter |\g_@@_ddots_int|
% is created for this usage).
% \begin{macrocode}
\int_compare:nNnTF \g_@@_ddots_int = 1
% \end{macrocode}
% If the diagonal line is the first one, we have no adjustment of the line to do
% but we store the $\Delta_x$ and the $\Delta_y$ of the line because these
% values will be used to draw the others diagonal lines parallels to the first
% one.
% \begin{macrocode}
{
\dim_gset:Nn \g_@@_delta_x_one_dim
{ \l_@@_x_final_dim - \l_@@_x_initial_dim }
\dim_gset:Nn \g_@@_delta_y_one_dim
{ \l_@@_y_final_dim - \l_@@_y_initial_dim }
}
% \end{macrocode}
% If the diagonal line is not the first one, we have to adjust the second
% extremity of the line by modifying the coordinate |\l_@@_x_initial_dim|.
% \begin{macrocode}
{
\dim_set:Nn \l_@@_y_final_dim
{
\l_@@_y_initial_dim +
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) *
\dim_ratio:nn \g_@@_delta_y_one_dim \g_@@_delta_x_one_dim
}
}
}
\@@_draw_line:
}
% \end{macrocode}
%
% \bigskip
% We draw the |\Iddots| diagonals in the same way.
%
% The first and the second arguments are the coordinates of the cell where the
% command has been issued. The third argument is the list of the options.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Iddots:nnn #1 #2 #3
{
\@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 }
% \end{macrocode}
% The previous command may have changed the current environment by marking some
% cells as ``dotted'', but, fortunately, it is outside the group for the options
% of the line.
% \begin{macrocode}
\group_begin:
\keys_set:nn { NiceMatrix / xdots } { #3 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Iddots:
\group_end:
}
}
% \end{macrocode}
%
% \bigskip
% The command |\@@_actually_draw_Iddots:| has the following implicit arguments:
% \begin{itemize}
% \item |\l_@@_initial_i_int|
% \item |\l_@@_initial_j_int|
% \item |\l_@@_initial_open_bool|
% \item |\l_@@_final_i_int|
% \item |\l_@@_final_j_int|
% \item |\l_@@_final_open_bool|.
% \end{itemize}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_actually_draw_Iddots:
{
\bool_if:NTF \l_@@_initial_open_bool
{
\@@_open_y_initial_dim:
\@@_open_x_initial_dim:
}
{ \@@_set_initial_coords_from_anchor:n { south~west } }
\bool_if:NTF \l_@@_final_open_bool
{
\@@_open_y_final_dim:
\@@_open_x_final_dim:
}
{ \@@_set_final_coords_from_anchor:n { north~east } }
\bool_if:NT \l_@@_parallelize_diags_bool
{
\int_gincr:N \g_@@_iddots_int
\int_compare:nNnTF \g_@@_iddots_int = 1
{
\dim_gset:Nn \g_@@_delta_x_two_dim
{ \l_@@_x_final_dim - \l_@@_x_initial_dim }
\dim_gset:Nn \g_@@_delta_y_two_dim
{ \l_@@_y_final_dim - \l_@@_y_initial_dim }
}
{
\dim_set:Nn \l_@@_y_final_dim
{
\l_@@_y_initial_dim +
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) *
\dim_ratio:nn \g_@@_delta_y_two_dim \g_@@_delta_x_two_dim
}
}
}
\@@_draw_line:
}
% \end{macrocode}
%
%
% \bigskip
% \subsection*{The actual instructions for drawing the dotted lines with Tikz}
%
% The command |\@@_draw_line:| should be used in a |{pgfpicture}|. It has six
% implicit arguments:
%
% \begin{itemize}
% \item |\l_@@_x_initial_dim|
% \item |\l_@@_y_initial_dim|
% \item |\l_@@_x_final_dim|
% \item |\l_@@_y_final_dim|
% \item |\l_@@_initial_open_bool|
% \item |\l_@@_final_open_bool|
% \end{itemize}
%
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_line:
{
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\bool_lazy_or:nnTF
{ \tl_if_eq_p:NN \l_@@_xdots_line_style_tl \c_@@_standard_tl }
% \end{macrocode}
% The boolean |\l_@@_dotted_bool| is raised for the rules specified by either
% |\hdottedline| or |:| (or the letter specified by |letter-for-dotted-lines|)
% in the preamble of the array.
% \begin{macrocode}
\l_@@_dotted_bool
\@@_draw_standard_dotted_line:
\@@_draw_unstandard_dotted_line:
}
% \end{macrocode}
%
% \medskip
% We have to do a special construction with |\exp_args:NV| to be able to put in
% the list of options in the correct place in the Tikz instruction.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:
{
\begin { scope }
\@@_draw_unstandard_dotted_line:o
{ \l_@@_xdots_line_style_tl , \l_@@_xdots_color_tl }
}
% \end{macrocode}
% We have used the fact that, in \textsc{pgf}, un color name can be put directly
% in a list of options (that's why we have put diredtly |\l_@@_xdots_color_tl|).
%
% \smallskip
% The argument of |\@@_draw_unstandard_dotted_line:n| is, in fact, the list of options.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:n #1
{
\@@_draw_unstandard_dotted_line:nVV
{ #1 }
\l_@@_xdots_up_tl
\l_@@_xdots_down_tl
}
\cs_generate_variant:Nn \@@_draw_unstandard_dotted_line:n { o }
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:nnn #1 #2 #3
{
\draw
[
#1 ,
shorten~> = \l_@@_xdots_shorten_dim ,
shorten~< = \l_@@_xdots_shorten_dim ,
]
( \l_@@_x_initial_dim , \l_@@_y_initial_dim )
% \end{macrocode}
% Be careful: We can't put |\c_math_toggle_token| instead of |$| in the
% following lines because we are in the contents of Tikz nodes (and they will be
% \emph{rescanned} if the Tikz library \pkg{babel} is loaded).
% \begin{macrocode}
-- node [ sloped , above ] { $ \scriptstyle #2 $ }
node [ sloped , below ] { $ \scriptstyle #3 $ }
( \l_@@_x_final_dim , \l_@@_y_final_dim ) ;
\end { scope }
}
\cs_generate_variant:Nn \@@_draw_unstandard_dotted_line:nnn { n V V }
% \end{macrocode}
%
% \bigskip
% The command |\@@_draw_standard_dotted_line:| draws the line with our system of dots
% (which gives a dotted line with real round dots).
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_standard_dotted_line:
{
\bool_lazy_and:nnF
{ \tl_if_empty_p:N \l_@@_xdots_up_tl }
{ \tl_if_empty_p:N \l_@@_xdots_down_tl }
{
\pgfscope
\pgftransformshift
{
\pgfpointlineattime { 0.5 }
{ \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim }
{ \pgfpoint \l_@@_x_final_dim \l_@@_y_final_dim }
}
\pgftransformrotate
{
\fp_eval:n
{
atand
(
\l_@@_y_final_dim - \l_@@_y_initial_dim ,
\l_@@_x_final_dim - \l_@@_x_initial_dim
)
}
}
\pgfnode
{ rectangle }
{ south }
{
\c_math_toggle_token
\scriptstyle \l_@@_xdots_up_tl
\c_math_toggle_token
}
{ }
{ \pgfusepath { } }
\pgfnode
{ rectangle }
{ north }
{
\c_math_toggle_token
\scriptstyle \l_@@_xdots_down_tl
\c_math_toggle_token
}
{ }
{ \pgfusepath { } }
\endpgfscope
}
\group_begin:
% \end{macrocode}
% The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use
% the floating point reals of the L3 programming layer to compute this length.
% \begin{macrocode}
\dim_zero_new:N \l_@@_l_dim
\dim_set:Nn \l_@@_l_dim
{
\fp_to_dim:n
{
sqrt
(
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) ^ 2
+
( \l_@@_y_final_dim - \l_@@_y_initial_dim ) ^ 2
)
}
}
% \end{macrocode}
% It seems that, during the first compilations, the value of |\l_@@_l_dim| may
% be erroneous (equal to zero or very large). We must detect these cases
% because they would cause errors during the drawing of the dotted line. Maybe
% we should also write something in the |aux| file to say that one more
% compilation should be done.
% \begin{macrocode}
\bool_lazy_or:nnF
{ \dim_compare_p:nNn { \dim_abs:n \l_@@_l_dim } > \c_@@_max_l_dim }
{ \dim_compare_p:nNn \l_@@_l_dim = \c_zero_dim }
\@@_draw_standard_dotted_line_i:
\group_end:
}
% \end{macrocode}
%
% \begin{macrocode}
\dim_const:Nn \c_@@_max_l_dim { 50 cm }
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_standard_dotted_line_i:
{
% \end{macrocode}
% The number of dots will be |\l_tmpa_int + 1|.
% \begin{macrocode}
\bool_if:NTF \l_@@_initial_open_bool
{
\bool_if:NTF \l_@@_final_open_bool
{
\int_set:Nn \l_tmpa_int
{ \dim_ratio:nn \l_@@_l_dim \l_@@_inter_dots_dim }
}
{
\int_set:Nn \l_tmpa_int
{
\dim_ratio:nn
{ \l_@@_l_dim - \l_@@_xdots_shorten_dim }
\l_@@_inter_dots_dim
}
}
}
{
\bool_if:NTF \l_@@_final_open_bool
{
\int_set:Nn \l_tmpa_int
{
\dim_ratio:nn
{ \l_@@_l_dim - \l_@@_xdots_shorten_dim }
\l_@@_inter_dots_dim
}
}
{
\int_set:Nn \l_tmpa_int
{
\dim_ratio:nn
{ \l_@@_l_dim - 2 \l_@@_xdots_shorten_dim }
\l_@@_inter_dots_dim
}
}
}
% \end{macrocode}
%
% \medskip
% The dimensions |\l_tmpa_dim| and |\l_tmpb_dim| are the coordinates of the
% vector between two dots in the dotted line.
% \begin{macrocode}
\dim_set:Nn \l_tmpa_dim
{
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) *
\dim_ratio:nn \l_@@_inter_dots_dim \l_@@_l_dim
}
\dim_set:Nn \l_tmpb_dim
{
( \l_@@_y_final_dim - \l_@@_y_initial_dim ) *
\dim_ratio:nn \l_@@_inter_dots_dim \l_@@_l_dim
}
% \end{macrocode}
%
% The length $\ell$ is the length of the dotted line. We note $\Delta$ the
% length between two dots and $n$ the number of intervals between dots. We note
% $\delta = \frac12(\ell - n \Delta)$. The distance between the initial
% extremity of the line and the first dot will be equal to $k\cdot\delta$ where
% $k=0$, $1$ or $2$. We first compute this number $k$ in |\l_tmpb_int|.
% \begin{macrocode}
\int_set:Nn \l_tmpb_int
{
\bool_if:NTF \l_@@_initial_open_bool
{ \bool_if:NTF \l_@@_final_open_bool 1 0 }
{ \bool_if:NTF \l_@@_final_open_bool 2 1 }
}
% \end{macrocode}
% In the loop over the dots, the dimensions |\l_@@_x_initial_dim| and
% |\l_@@_y_initial_dim| will be used for the coordinates of the dots. But,
% before the loop, we must move until the first dot.
%
% \begin{macrocode}
\dim_gadd:Nn \l_@@_x_initial_dim
{
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) *
\dim_ratio:nn
{ \l_@@_l_dim - \l_@@_inter_dots_dim * \l_tmpa_int }
{ 2 \l_@@_l_dim }
* \l_tmpb_int
}
\dim_gadd:Nn \l_@@_y_initial_dim
{
( \l_@@_y_final_dim - \l_@@_y_initial_dim ) *
\dim_ratio:nn
{ \l_@@_l_dim - \l_@@_inter_dots_dim * \l_tmpa_int }
{ 2 \l_@@_l_dim }
* \l_tmpb_int
}
\pgf@relevantforpicturesizefalse
\int_step_inline:nnn 0 \l_tmpa_int
{
\pgfpathcircle
{ \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim }
{ \l_@@_radius_dim }
\dim_add:Nn \l_@@_x_initial_dim \l_tmpa_dim
\dim_add:Nn \l_@@_y_initial_dim \l_tmpb_dim
}
\pgfusepathqfill
}
% \end{macrocode}
%
% \bigskip
% \subsection*{User commands available in the new environments}
%
%
% \interitem
% The commands |\@@_Ldots|, |\@@_Cdots|, |\@@_Vdots|, |\@@_Ddots| and
% |\@@_Iddots| will be linked to |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| and
% |\Iddots| in the environments |{NiceArray}| (the other environments of
% \pkg{nicematrix} rely upon |{NiceArray}|).
%
%
% \medskip
% The syntax of these commands uses the character |_| as embellishment and
% thats' why we have to insert a character |_| in the \emph{arg spec} of these
% commands. However, we don't know the future catcode of |_| in the main
% document (maybe the user will use \pkg{underscore}, and, in that case, the
% catcode is $13$ because \pkg{underscore} activates |_|). That's why these
% commands will be defined in a |\hook_gput_code:nnn { begindocument } { . }|
% and the \emph{arg spec} will be rescanned.
%
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\tl_set:Nn \l_@@_argspec_tl { O { } E { _ ^ } { { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
\exp_args:NNV \NewDocumentCommand \@@_Ldots \l_@@_argspec_tl
{
\int_compare:nNnTF \c@jCol = 0
{ \@@_error:nn { in~first~col } \Ldots }
{
\int_compare:nNnTF \c@jCol = \l_@@_last_col_int
{ \@@_error:nn { in~last~col } \Ldots }
{
\@@_instruction_of_type:nnn \c_false_bool { Ldots }
{ #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l_@@_nullify_dots_bool
{ \phantom { \ensuremath { \@@_old_ldots } } }
\bool_gset_true:N \g_@@_empty_cell_bool
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Cdots \l_@@_argspec_tl
{
\int_compare:nNnTF \c@jCol = 0
{ \@@_error:nn { in~first~col } \Cdots }
{
\int_compare:nNnTF \c@jCol = \l_@@_last_col_int
{ \@@_error:nn { in~last~col } \Cdots }
{
\@@_instruction_of_type:nnn \c_false_bool { Cdots }
{ #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l_@@_nullify_dots_bool
{ \phantom { \ensuremath { \@@_old_cdots } } }
\bool_gset_true:N \g_@@_empty_cell_bool
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Vdots \l_@@_argspec_tl
{
\int_compare:nNnTF \c@iRow = 0
{ \@@_error:nn { in~first~row } \Vdots }
{
\int_compare:nNnTF \c@iRow = \l_@@_last_row_int
{ \@@_error:nn { in~last~row } \Vdots }
{
\@@_instruction_of_type:nnn \c_false_bool { Vdots }
{ #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l_@@_nullify_dots_bool
{ \phantom { \ensuremath { \@@_old_vdots } } }
\bool_gset_true:N \g_@@_empty_cell_bool
}
% \end{macrocode}
%
%
% \bigskip
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Ddots \l_@@_argspec_tl
{
\int_case:nnF \c@iRow
{
0 { \@@_error:nn { in~first~row } \Ddots }
\l_@@_last_row_int { \@@_error:nn { in~last~row } \Ddots }
}
{
\int_case:nnF \c@jCol
{
0 { \@@_error:nn { in~first~col } \Ddots }
\l_@@_last_col_int { \@@_error:nn { in~last~col } \Ddots }
}
{
\keys_set_known:nn { NiceMatrix / Ddots } { #1 }
\@@_instruction_of_type:nnn \l_@@_draw_first_bool { Ddots }
{ #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l_@@_nullify_dots_bool
{ \phantom { \ensuremath { \@@_old_ddots } } }
\bool_gset_true:N \g_@@_empty_cell_bool
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Iddots \l_@@_argspec_tl
{
\int_case:nnF \c@iRow
{
0 { \@@_error:nn { in~first~row } \Iddots }
\l_@@_last_row_int { \@@_error:nn { in~last~row } \Iddots }
}
{
\int_case:nnF \c@jCol
{
0 { \@@_error:nn { in~first~col } \Iddots }
\l_@@_last_col_int { \@@_error:nn { in~last~col } \Iddots }
}
{
\keys_set_known:nn { NiceMatrix / Ddots } { #1 }
\@@_instruction_of_type:nnn \l_@@_draw_first_bool { Iddots }
{ #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l_@@_nullify_dots_bool
{ \phantom { \ensuremath { \@@_old_iddots } } }
\bool_gset_true:N \g_@@_empty_cell_bool
}
}
% \end{macrocode}
% End of the |\AddToHook|.
%
%
% \bigskip
% Despite its name, the following set of keys will be used for |\Ddots| but also
% for |\Iddots|.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Ddots }
{
draw-first .bool_set:N = \l_@@_draw_first_bool ,
draw-first .default:n = true ,
draw-first .value_forbidden:n = true
}
% \end{macrocode}
%
% \bigskip
% The command |\@@_Hspace:| will be linked to |\hspace| in |{NiceArray}|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Hspace:
{
\bool_gset_true:N \g_@@_empty_cell_bool
\hspace
}
% \end{macrocode}
%
% \bigskip
% In the environments of |nicematrix|, the command |\multicolumn| is redefined.
% We will patch the environment |{tabular}| to go back to the previous value of
% |\multicolumn|.
% \begin{macrocode}
\cs_set_eq:NN \@@_old_multicolumn \multicolumn
% \end{macrocode}
%
%
%
% \bigskip
% The command |\@@_Hdotsfor| will be linked to |\Hdotsfor| in
% |{NiceArrayWithDelims}|. Tikz nodes are created also in the implicit cells of
% the |\Hdotsfor| (maybe we should modify that point).
%
% \medskip
% This command must \emph{not} be protected since it begins with |\multicolumn|.
% \begin{macrocode}
\cs_new:Npn \@@_Hdotsfor:
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn \c@jCol = 0 }
{ \int_compare_p:nNn \l_@@_first_col_int = 0 }
{
\bool_if:NTF \g_@@_after_col_zero_bool
{
\multicolumn { 1 } { c } { }
\@@_Hdotsfor_i
}
{ \@@_fatal:n { Hdotsfor~in~col~0 } }
}
{
\multicolumn { 1 } { c } { }
\@@_Hdotsfor_i
}
}
% \end{macrocode}
%
%
% The command |\@@_Hdotsfor_i| is defined with |\NewDocumentCommand| because it
% has an optional argument. Note that such a command defined by
% |\NewDocumentCommand| is protected and that's why we have put the
% |\multicolumn| before (in the definition of |\@@_Hdotsfor:|).
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\tl_set:Nn \l_@@_argspec_tl { O { } m O { } E { _ ^ } { { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
% \end{macrocode}
% We don't put |!| before the last optionnal argument for homogeneity with
% |\Cdots|, etc. which have only one optional argument.
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Hdotsfor_i \l_@@_argspec_tl
{
\tl_gput_right:Nx \g_@@_HVdotsfor_lines_tl
{
\@@_Hdotsfor:nnnn
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ #2 }
{
#1 , #3 ,
down = \exp_not:n { #4 } ,
up = \exp_not:n { #5 }
}
}
\prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { c } { } }
}
}
% \end{macrocode}
% Enf of |\AddToHook|.
%
% \medskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_Hdotsfor:nnnn #1 #2 #3 #4
{
\bool_set_false:N \l_@@_initial_open_bool
\bool_set_false:N \l_@@_final_open_bool
% \end{macrocode}
% For the row, it's easy.
% \begin{macrocode}
\int_set:Nn \l_@@_initial_i_int { #1 }
\int_set_eq:NN \l_@@_final_i_int \l_@@_initial_i_int
% \end{macrocode}
% For the column, it's a bit more complicated.
% \begin{macrocode}
\int_compare:nNnTF { #2 } = 1
{
\int_set:Nn \l_@@_initial_j_int 1
\bool_set_true:N \l_@@_initial_open_bool
}
{
\cs_if_exist:cTF
{
pgf @ sh @ ns @ \@@_env:
- \int_use:N \l_@@_initial_i_int
- \int_eval:n { #2 - 1 }
}
{ \int_set:Nn \l_@@_initial_j_int { #2 - 1 } }
{
\int_set:Nn \l_@@_initial_j_int { #2 }
\bool_set_true:N \l_@@_initial_open_bool
}
}
\int_compare:nNnTF { #2 + #3 -1 } = \c@jCol
{
\int_set:Nn \l_@@_final_j_int { #2 + #3 - 1 }
\bool_set_true:N \l_@@_final_open_bool
}
{
\cs_if_exist:cTF
{
pgf @ sh @ ns @ \@@_env:
- \int_use:N \l_@@_final_i_int
- \int_eval:n { #2 + #3 }
}
{ \int_set:Nn \l_@@_final_j_int { #2 + #3 } }
{
\int_set:Nn \l_@@_final_j_int { #2 + #3 - 1 }
\bool_set_true:N \l_@@_final_open_bool
}
}
% \end{macrocode}
%
% \begin{macrocode}
\group_begin:
\int_compare:nNnTF { #1 } = 0
{ \color { nicematrix-first-row } }
{
\int_compare:nNnT { #1 } = \g_@@_row_total_int
{ \color { nicematrix-last-row } }
}
\keys_set:nn { NiceMatrix / xdots } { #4 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Ldots:
\group_end:
% \end{macrocode}
%
% \medskip
% We declare all the cells concerned by the |\Hdotsfor| as ``dotted'' (for the
% dotted lines created by |\Cdots|, |\Ldots|, etc., this job is done by
% |\@@_find_extremities_of_line:nnnn|). This declaration is done by defining a
% special control sequence (to nil).
% \begin{macrocode}
\int_step_inline:nnn { #2 } { #2 + #3 - 1 }
{ \cs_set:cpn { @@ _ dotted _ #1 - ##1 } { } }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\tl_set:Nn \l_@@_argspec_tl { O { } m O { } E { _ ^ } { { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
\exp_args:NNV \NewDocumentCommand \@@_Vdotsfor: \l_@@_argspec_tl
{
\tl_gput_right:Nx \g_@@_HVdotsfor_lines_tl
{
\@@_Vdotsfor:nnnn
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ #2 }
{
#1 , #3 ,
down = \exp_not:n { #4 } , up = \exp_not:n { #5 }
}
}
}
}
% \end{macrocode}
% Enf of |\AddToHook|.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_Vdotsfor:nnnn #1 #2 #3 #4
{
\bool_set_false:N \l_@@_initial_open_bool
\bool_set_false:N \l_@@_final_open_bool
% \end{macrocode}
% For the column, it's easy.
% \begin{macrocode}
\int_set:Nn \l_@@_initial_j_int { #2 }
\int_set_eq:NN \l_@@_final_j_int \l_@@_initial_j_int
% \end{macrocode}
% For the row, it's a bit more complicated.
% \begin{macrocode}
\int_compare:nNnTF #1 = 1
{
\int_set:Nn \l_@@_initial_i_int 1
\bool_set_true:N \l_@@_initial_open_bool
}
{
\cs_if_exist:cTF
{
pgf @ sh @ ns @ \@@_env:
- \int_eval:n { #1 - 1 }
- \int_use:N \l_@@_initial_j_int
}
{ \int_set:Nn \l_@@_initial_i_int { #1 - 1 } }
{
\int_set:Nn \l_@@_initial_i_int { #1 }
\bool_set_true:N \l_@@_initial_open_bool
}
}
\int_compare:nNnTF { #1 + #3 -1 } = \c@iRow
{
\int_set:Nn \l_@@_final_i_int { #1 + #3 - 1 }
\bool_set_true:N \l_@@_final_open_bool
}
{
\cs_if_exist:cTF
{
pgf @ sh @ ns @ \@@_env:
- \int_eval:n { #1 + #3 }
- \int_use:N \l_@@_final_j_int
}
{ \int_set:Nn \l_@@_final_i_int { #1 + #3 } }
{
\int_set:Nn \l_@@_final_i_int { #1 + #3 - 1 }
\bool_set_true:N \l_@@_final_open_bool
}
}
% \end{macrocode}
%
% \begin{macrocode}
\group_begin:
\int_compare:nNnTF { #2 } = 0
{ \color { nicematrix-first-col } }
{
\int_compare:nNnT { #2 } = \g_@@_col_total_int
{ \color { nicematrix-last-col } }
}
\keys_set:nn { NiceMatrix / xdots } { #4 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Vdots:
\group_end:
% \end{macrocode}
%
% \medskip
% We declare all the cells concerned by the |\Vdotsfor| as ``dotted'' (for the
% dotted lines created by |\Cdots|, |\Ldots|, etc., this job is done by
% |\@@_find_extremities_of_line:nnnn|). This declaration is done by defining a
% special control sequence (to nil).
% \begin{macrocode}
\int_step_inline:nnn { #1 } { #1 + #3 - 1 }
{ \cs_set:cpn { @@ _ dotted _ ##1 - #2 } { } }
}
% \end{macrocode}
%
%
% \vspace{1cm}
% The command |\@@_rotate:| will be linked to |\rotate| in
% |{NiceArrayWithDelims}|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_rotate: { \bool_gset_true:N \g_@@_rotate_bool }
% \end{macrocode}
%
% \bigskip
% \subsection*{The command \textbackslash line accessible in code-after}
%
% In the |\CodeAfter|, the command |\@@_line:nn| will be linked to |\line|. This
% command takes two arguments which are the specifications of two cells in the
% array (in the format $i$-$j$) and draws a dotted line between these cells.
%
% \medskip
% First, we write a command with an argument of the format $i$-$j$ and applies
% the command |\int_eval:n| to $i$ and~$j$ ; this must \emph{not} be protected
% (and is, of course fully expandable).\footnote{Indeed, we want that the user
% may use the command |\line| in |\CodeAfter| with LaTeX counters in the
% arguments --- with the command |\value|.}
% \begin{macrocode}
\cs_new:Npn \@@_double_int_eval:n #1-#2 \q_stop
{ \int_eval:n { #1 } - \int_eval:n { #2 } }
% \end{macrocode}
%
%
% \medskip
% With the following construction, the command |\@@_double_int_eval:n| is
% applied to both arguments before the application of |\@@_line_i:nn| (the
% construction uses the fact the |\@@_line_i:nn| is protected and that
% |\@@_double_int_eval:n| is fully expandable).
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\tl_set:Nn \l_@@_argspec_tl { O { } m m ! O { } E { _ ^ } { { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
\exp_args:NNV \NewDocumentCommand \@@_line \l_@@_argspec_tl
{
\group_begin:
\keys_set:nn { NiceMatrix / xdots } { #1 , #4 , down = #5 , up = #6 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\use:e
{
\@@_line_i:nn
{ \@@_double_int_eval:n #2 \q_stop }
{ \@@_double_int_eval:n #3 \q_stop }
}
\group_end:
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_line_i:nn #1 #2
{
\bool_set_false:N \l_@@_initial_open_bool
\bool_set_false:N \l_@@_final_open_bool
\bool_if:nTF
{
\cs_if_free_p:c { pgf @ sh @ ns @ \@@_env: - #1 }
||
\cs_if_free_p:c { pgf @ sh @ ns @ \@@_env: - #2 }
}
{
\@@_error:nnn { unknown~cell~for~line~in~CodeAfter } { #1 } { #2 }
}
{ \@@_draw_line_ii:nn { #1 } { #2 } }
}
% \end{macrocode}
%
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\cs_new_protected:Npx \@@_draw_line_ii:nn #1 #2
{
% \end{macrocode}
% We recall that, when externalization is used, |\tikzpicture| and
% |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly
% ``visible'' and that why we do this static construction of the command
% |\@@_draw_line_ii:|.
% \begin{macrocode}
\c_@@_pgfortikzpicture_tl
\@@_draw_line_iii:nn { #1 } { #2 }
\c_@@_endpgfortikzpicture_tl
}
}
% \end{macrocode}
%
% \bigskip
% The following command \emph{must} be protected (it's used in the
% construction of |\@@_draw_line_ii:nn|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_line_iii:nn #1 #2
{
\pgfrememberpicturepositiononpagetrue
\pgfpointshapeborder { \@@_env: - #1 } { \@@_qpoint:n { #2 } }
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
\pgfpointshapeborder { \@@_env: - #2 } { \@@_qpoint:n { #1 } }
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y
\@@_draw_line:
}
% \end{macrocode}
%
%
% The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots| don't use
% this command because they have to do other settings (for example, the diagonal
% lines must be parallelized).
%
%
%
% \bigskip
% \subsection*{The command \textbackslash RowStyle}
%
% \medskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / RowStyle }
{
cell-space-top-limit .dim_set:N = \l_tmpa_dim ,
cell-space-top-limit .initial:n = \c_zero_dim ,
cell-space-top-limit .value_required:n = true ,
cell-space-bottom-limit .dim_set:N = \l_tmpb_dim ,
cell-space-bottom-limit .initial:n = \c_zero_dim ,
cell-space-bottom-limit .value_required:n = true ,
cell-space-limits .meta:n =
{
cell-space-top-limit = #1 ,
cell-space-bottom-limit = #1 ,
} ,
color .tl_set:N = \l_tmpa_tl ,
color .value_required:n = true ,
bold .bool_set:N = \l_tmpa_bool ,
bold .default:n = true ,
bold .initial:n = false ,
nb-rows .int_set:N = \l_@@_key_nb_rows_int ,
nb-rows .value_required:n = true ,
nb-rows .initial:n = 1 ,
rowcolor .tl_set:N = \l_@@_tmpc_tl ,
rowcolor .value_required:n = true ,
rowcolor .initial:n = ,
unknown .code:n = \@@_error:n { Unknown~key~for~RowStyle }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\NewDocumentCommand \@@_RowStyle:n { O { } m }
{
\tl_clear:N \l_tmpa_tl
\keys_set:nn { NiceMatrix / RowStyle } { #1 }
% \end{macrocode}
% If the key |rowcolor| has been used.
% \begin{macrocode}
\tl_if_empty:NF \l_@@_tmpc_tl
{
% \end{macrocode}
% First, the end of the current row (we remind that |\RowStyle| applies to the
% \emph{end} of the current row).
% \begin{macrocode}
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
\@@_rectanglecolor
{ \l_@@_tmpc_tl }
{ \int_use:N \c@iRow - \int_use:N \c@jCol }
{ \int_use:N \c@iRow - * }
}
% \end{macrocode}
% Then, the other rows (if there is several rows).
% \begin{macrocode}
\int_compare:nNnT \l_@@_key_nb_rows_int > 1
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
\@@_rowcolor
{ \l_@@_tmpc_tl }
{
\int_eval:n { \c@iRow + 1 }
- \int_eval:n { \c@iRow + \l_@@_key_nb_rows_int - 1 }
}
}
}
}
\tl_gput_right:Nn \g_@@_row_style_tl { \ifnum \c@iRow < }
\tl_gput_right:Nx \g_@@_row_style_tl
{ \int_eval:n { \c@iRow + \l_@@_key_nb_rows_int } }
\tl_gput_right:Nn \g_@@_row_style_tl { #2 }
% \end{macrocode}
% |\l_tmpa_dim| is the value of the key |cell-space-top-limit| of |\RowStyle|.
% \begin{macrocode}
\dim_compare:nNnT \l_tmpa_dim > \c_zero_dim
{
\tl_gput_right:Nx \g_@@_row_style_tl
{
\tl_gput_right:Nn \exp_not:N \g_@@_post_action_cell_tl
{
\dim_set:Nn \l_@@_cell_space_top_limit_dim
{ \dim_use:N \l_tmpa_dim }
}
}
}
% \end{macrocode}
% |\l_tmpb_dim| is the value of the key |cell-space-bottom-limit| of |\RowStyle|.
% \begin{macrocode}
\dim_compare:nNnT \l_tmpb_dim > \c_zero_dim
{
\tl_gput_right:Nx \g_@@_row_style_tl
{
\tl_gput_right:Nn \exp_not:N \g_@@_post_action_cell_tl
{
\dim_set:Nn \l_@@_cell_space_bottom_limit_dim
{ \dim_use:N \l_tmpb_dim }
}
}
}
% \end{macrocode}
% |\l_tmpa_tl| is the value of the key |color| of |\RowStyle|.
% \begin{macrocode}
\tl_if_empty:NF \l_tmpa_tl
{
\tl_gput_right:Nx \g_@@_row_style_tl
{ \mode_leave_vertical: \exp_not:N \color { \l_tmpa_tl } }
}
% \end{macrocode}
% |\l_tmpa_bool| is the value of the key |bold|.
% \begin{macrocode}
\bool_if:NT \l_tmpa_bool
{
\tl_gput_right:Nn \g_@@_row_style_tl
{
\if_mode_math:
\c_math_toggle_token
\bfseries \boldmath
\c_math_toggle_token
\else:
\bfseries \boldmath
\fi:
}
}
\tl_gput_right:Nn \g_@@_row_style_tl { \fi }
\g_@@_row_style_tl
\ignorespaces
}
% \end{macrocode}
%
% \bigskip
% \subsection*{Colors of cells, rows and columns}
%
% We want to avoid the thin white lines that are shown in some \textsc{pdf}
% viewers (eg: with the engine MuPDF used by SumatraPDF). That's why we try to
% draw rectangles of the same color in the same instruction |\pgfusepath { fill }|
% (and they will be in the same instruction |fill|---coded |f|---in the
% resulting \textsc{pdf}).
%
% The commands |\@@_rowcolor|, |\@@_columncolor|, |\@@_rectanglecolor| and
% |\@@_rowlistcolors| don't directly draw the corresponding rectangles. Instead,
% they store their instructions color by color:
% \begin{itemize}
% \item A sequence |\g_@@_colors_seq| will be built containing all the colors
% used by at least one of these instructions. Each \emph{color} may be prefixed
% by its color model (eg: |[gray]{0.5}|).
% \item For the color whose index in |\g_@@_colors_seq| is equal to~$i$, a list of
% instructions which use that color will be constructed in the token list
% |\g_@@_color_|$i$|_tl|. In that token list, the instructions will be written
% using |\@@_cartesian_color:nn| and |\@@_rectanglecolor:nn|.
% \end{itemize}
%
%
% \bigskip
% |#1| is the color and |#2| is an instruction using that color. Despite its
% name, the command |\@@_add_to_colors_seq:nn| doesn't only add a color to
% |\g_@@_colors_seq|: it also updates the corresponding token list
% |\g_@@_color_|$i$|_tl|. We add in a global way because the final user may use
% the instructions such as |\cellcolor| in a loop of \pkg{pgffor} in the
% |\CodeBefore| (and we recall that a loop of \pkg{pgffor} is encapsulated in a
% group).
% \begin{macrocode}
\cs_new_protected:Npn \@@_add_to_colors_seq:nn #1 #2
{
% \end{macrocode}
% Firt, we look for the number of the color and, if it's found, we store it in
% |\l_tmpa_int|. If the color is not present in |\l_@@_colors_seq|,
% |\l_tmpa_int| will remain equal to $0$.
% \begin{macrocode}
\int_zero:N \l_tmpa_int
\seq_map_indexed_inline:Nn \g_@@_colors_seq
{ \tl_if_eq:nnT { #1 } { ##2 } { \int_set:Nn \l_tmpa_int { ##1 } } }
\int_compare:nNnTF \l_tmpa_int = \c_zero_int
% \end{macrocode}
% First, the case where the color is a \emph{new} color (not in the sequence).
% \begin{macrocode}
{
\seq_gput_right:Nn \g_@@_colors_seq { #1 }
\tl_gset:cx { g_@@_color _ \seq_count:N \g_@@_colors_seq _ tl } { #2 }
}
% \end{macrocode}
% Now, the case where the color is \emph{not} a new color (the color is in the
% sequence at the position |\l_tmpa_int|).
% \begin{macrocode}
{ \tl_gput_right:cx { g_@@_color _ \int_use:N \l_tmpa_int _tl } { #2 } }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { x n }
\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { x x }
% \end{macrocode}
%
% \bigskip
% The macro |\@@_actually_color:| will actually fill all the rectangles, color by
% color (using the sequence |\l_@@_colors_seq| and all the token lists of the
% form |\l_@@_color_|$i$|_tl|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_actually_color:
{
\pgfpicture
\pgf@relevantforpicturesizefalse
\seq_map_indexed_inline:Nn \g_@@_colors_seq
{
\color ##2
\use:c { g_@@_color _ ##1 _tl }
\tl_gclear:c { g_@@_color _ ##1 _tl }
\pgfusepath { fill }
}
\endpgfpicture
}
% \end{macrocode}
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_cartesian_color:nn #1 #2
{
\tl_set:Nn \l_@@_rows_tl { #1 }
\tl_set:Nn \l_@@_cols_tl { #2 }
\@@_cartesian_path:
}
% \end{macrocode}
%
% \bigskip
% Here is an example : |\@@_rowcolor {red!15} {1,3,5-7,10-}|
% \begin{macrocode}
\NewDocumentCommand \@@_rowcolor { O { } m m }
{
\tl_if_blank:nF { #2 }
{
\@@_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \@@_cartesian_color:nn { #3 } { - } }
}
}
% \end{macrocode}
%
% \bigskip
% Here an example : |\@@_columncolor:nn {red!15} {1,3,5-7,10-}|
% \begin{macrocode}
\NewDocumentCommand \@@_columncolor { O { } m m }
{
\tl_if_blank:nF { #2 }
{
\@@_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \@@_cartesian_color:nn { - } { #3 } }
}
}
% \end{macrocode}
%
% \bigskip
% Here is an example : |\@@_rectanglecolor{red!15}{2-3}{5-6}|
% \begin{macrocode}
\NewDocumentCommand \@@_rectanglecolor { O { } m m m }
{
\tl_if_blank:nF { #2 }
{
\@@_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \@@_rectanglecolor:nnn { #3 } { #4 } { 0 pt } }
}
}
% \end{macrocode}
%
% \bigskip
% The last argument is the radius of the corners of the rectangle.
% \begin{macrocode}
\NewDocumentCommand \@@_roundedrectanglecolor { O { } m m m m }
{
\tl_if_blank:nF { #2 }
{
\@@_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \@@_rectanglecolor:nnn { #3 } { #4 } { #5 } }
}
}
% \end{macrocode}
%
% \bigskip
% The last argument is the radius of the corners of the rectangle.
% \begin{macrocode}
\cs_new_protected:Npn \@@_rectanglecolor:nnn #1 #2 #3
{
\@@_cut_on_hyphen:w #1 \q_stop
\tl_clear_new:N \l_@@_tmpc_tl
\tl_clear_new:N \l_@@_tmpd_tl
\tl_set_eq:NN \l_@@_tmpc_tl \l_tmpa_tl
\tl_set_eq:NN \l_@@_tmpd_tl \l_tmpb_tl
\@@_cut_on_hyphen:w #2 \q_stop
\tl_set:Nx \l_@@_rows_tl { \l_@@_tmpc_tl - \l_tmpa_tl }
\tl_set:Nx \l_@@_cols_tl { \l_@@_tmpd_tl - \l_tmpb_tl }
% \end{macrocode}
% The command |\@@_cartesian_path:n| takes in two implicit arguments:
% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
% \begin{macrocode}
\@@_cartesian_path:n { #3 }
}
% \end{macrocode}
%
%
% \bigskip
% Here is an example : |\@@_cellcolor[rgb]{0.5,0.5,0}{2-3,3-4,4-5,5-6}|
% \begin{macrocode}
\NewDocumentCommand \@@_cellcolor { O { } m m }
{
\clist_map_inline:nn { #3 }
{ \@@_rectanglecolor [ #1 ] { #2 } { ##1 } { ##1 } }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\NewDocumentCommand \@@_chessboardcolors { O { } m m }
{
\int_step_inline:nn { \int_use:N \c@iRow }
{
\int_step_inline:nn { \int_use:N \c@jCol }
{
\int_if_even:nTF { ####1 + ##1 }
{ \@@_cellcolor [ #1 ] { #2 } }
{ \@@_cellcolor [ #1 ] { #3 } }
{ ##1 - ####1 }
}
}
}
% \end{macrocode}
%
% \bigskip
% The command |\@@_arraycolor| (linked to |\arraycolor| at the beginning of
% the |\CodeBefore|) will color the whole tabular (excepted the potential
% exterior rows and columns) and the cells in the ``corners''.
% \begin{macrocode}
\NewDocumentCommand \@@_arraycolor { O { } m }
{
\@@_rectanglecolor [ #1 ] { #2 }
{ 1 - 1 }
{ \int_use:N \c@iRow - \int_use:N \c@jCol }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / rowcolors }
{
respect-blocks .bool_set:N = \l_@@_respect_blocks_bool ,
respect-blocks .default:n = true ,
cols .tl_set:N = \l_@@_cols_tl ,
restart .bool_set:N = \l_@@_rowcolors_restart_bool ,
restart .default:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~rowcolors }
}
% \end{macrocode}
%
% \medskip
% The command |\rowcolors| (accessible in the |code-before|) is inspired by the
% command |\rowcolors| of the package \pkg{xcolor} (with the option |table|).
% However, the command |\rowcolors| of \pkg{nicematrix} has \emph{not} the
% optional argument of the command |\rowcolors| of \pkg{xcolor}. Here is an
% example: |\rowcolors{1}{blue!10}{}[respect-blocks]|.
%
% |#1| (optional) is the color space ;
% |#2| is a list of intervals of rows ;
% |#3| is the list of colors ;
% |#4| is for the optional list of pairs \textsl{key=value}.
% \begin{macrocode}
\NewDocumentCommand \@@_rowlistcolors { O { } m m O { } }
{
% \end{macrocode}
% The group is for the options. |\l_@@_colors_seq| will be the list of colors.
% \begin{macrocode}
\group_begin:
\seq_clear_new:N \l_@@_colors_seq
\seq_set_split:Nnn \l_@@_colors_seq { , } { #3 }
\tl_clear_new:N \l_@@_cols_tl
\tl_set:Nn \l_@@_cols_tl { - }
\keys_set:nn { NiceMatrix / rowcolors } { #4 }
% \end{macrocode}
% The counter |\l_@@_color_int| will be the rank of the current color in the list of
% colors (modulo the length of the list).
% \begin{macrocode}
\int_zero_new:N \l_@@_color_int
\int_set:Nn \l_@@_color_int 1
\bool_if:NT \l_@@_respect_blocks_bool
{
% \end{macrocode}
% We don't want to take into account a block which is completely in the ``first
% column'' of (number $0$) or in the ``last column'' and that's why we filter
% the sequence of the blocks (in a the sequence |\l_tmpa_seq|).
% \begin{macrocode}
\seq_set_eq:NN \l_tmpb_seq \g_@@_pos_of_blocks_seq
\seq_set_filter:NNn \l_tmpa_seq \l_tmpb_seq
{ \@@_not_in_exterior_p:nnnnn ##1 }
}
\pgfpicture
\pgf@relevantforpicturesizefalse
% \end{macrocode}
% |#2| is the list of intervals of rows.
% \begin{macrocode}
\clist_map_inline:nn { #2 }
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
{ \@@_cut_on_hyphen:w ##1 \q_stop }
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
% \end{macrocode}
% Now, |l_tmpa_tl| and |l_tmpb_tl| are the first row and the last row of the
% interval of rows that we have to treat. The counter |\l_tmpa_int| will be the
% index of the loop over the rows.
% \begin{macrocode}
\int_set:Nn \l_tmpa_int \l_tmpa_tl
\bool_if:NTF \l_@@_rowcolors_restart_bool
{ \int_set:Nn \l_@@_color_int 1 }
{ \int_set:Nn \l_@@_color_int \l_tmpa_tl }
\int_zero_new:N \l_@@_tmpc_int
\int_set:Nn \l_@@_tmpc_int \l_tmpb_tl
\int_do_until:nNnn \l_tmpa_int > \l_@@_tmpc_int
{
% \end{macrocode}
% We will compute in |\l_tmpb_int| the last row of the ``block''.
% \begin{macrocode}
\int_set_eq:NN \l_tmpb_int \l_tmpa_int
% \end{macrocode}
% If the key |respect-blocks| is in force, we have to adjust that value (of
% course).
% \begin{macrocode}
\bool_if:NT \l_@@_respect_blocks_bool
{
\seq_set_filter:NNn \l_tmpb_seq \l_tmpa_seq
{ \@@_intersect_our_row_p:nnnnn ####1 }
\seq_map_inline:Nn \l_tmpb_seq { \@@_rowcolors_i:nnnnn ####1 }
% \end{macrocode}
% Now, the last row of the block is computed in |\l_tmpb_int|.
% \begin{macrocode}
}
\tl_set:Nx \l_@@_rows_tl
{ \int_use:N \l_tmpa_int - \int_use:N \l_tmpb_int }
% \end{macrocode}
% |\l_@@_tmpc_tl| will be the color that we will use.
% \begin{macrocode}
\tl_clear_new:N \l_@@_color_tl
\tl_set:Nx \l_@@_color_tl
{
\@@_color_index:n
{
\int_mod:nn
{ \l_@@_color_int - 1 }
{ \seq_count:N \l_@@_colors_seq }
+ 1
}
}
\tl_if_empty:NF \l_@@_color_tl
{
\@@_add_to_colors_seq:xx
{ \tl_if_blank:nF { #1 } { [ #1 ] } { \l_@@_color_tl } }
{ \@@_cartesian_color:nn { \l_@@_rows_tl } { \l_@@_cols_tl } }
}
\int_incr:N \l_@@_color_int
\int_set:Nn \l_tmpa_int { \l_tmpb_int + 1 }
}
}
\endpgfpicture
\group_end:
}
% \end{macrocode}
%
% \medskip
% The command |\@@_color_index:n| peeks in |\l_@@_colors_seq| the color at the
% index |#1|. However, if that color is the symbol |=|, the previous one is
% poken. This macro is recursive.
% \begin{macrocode}
\cs_new:Npn \@@_color_index:n #1
{
\str_if_eq:eeTF { \seq_item:Nn \l_@@_colors_seq { #1 } } { = }
{ \@@_color_index:n { #1 - 1 } }
{ \seq_item:Nn \l_@@_colors_seq { #1 } }
}
% \end{macrocode}
%
% \bigskip
% The command |\rowcolors| (available in the |\CodeBefore|) is a specialisation
% of the most general command |\rowlistcolors|.
% \begin{macrocode}
\NewDocumentCommand \@@_rowcolors { O { } m m m O { } }
{ \@@_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } [ #5 ] }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_rowcolors_i:nnnnn #1 #2 #3 #4 #5
{
\int_compare:nNnT { #3 } > \l_tmpb_int
{ \int_set:Nn \l_tmpb_int { #3 } }
}
% \end{macrocode}
%
%
% \bigskip
% \begin{macrocode}
\prg_new_conditional:Nnn \@@_not_in_exterior:nnnnn p
{
\bool_lazy_or:nnTF
{ \int_compare_p:nNn { #4 } = \c_zero_int }
{ \int_compare_p:nNn { #2 } = { \int_eval:n { \c@jCol + 1 } } }
\prg_return_false:
\prg_return_true:
}
% \end{macrocode}
%
% \bigskip
% The following command return |true| when the block intersects the row
% |\l_tmpa_int|.
% \begin{macrocode}
\prg_new_conditional:Nnn \@@_intersect_our_row:nnnnn p
{
\bool_if:nTF
{
\int_compare_p:n { #1 <= \l_tmpa_int }
&&
\int_compare_p:n { \l_tmpa_int <= #3 }
}
\prg_return_true:
\prg_return_false:
}
% \end{macrocode}
%
% \bigskip
% The following command uses two implicit arguments: |\l_@@_rows_tl| and
% |\l_@@_cols_tl| which are specifications for a set of rows and a set of
% columns. It creates a path but does \emph{not} fill it. It must be filled by
% another command after. The argument is the radius of the corners. We define
% below a command |\@@_cartesian_path:| which corresponds to a value $0$~pt for
% the radius of the corners.
%
% This command is in particular used in |\@@_rectanglecolor:nnn| (used in
% |\@@_rectanglecolor|, itself used in |\@@_cellcolor|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_cartesian_path:n #1
{
\bool_lazy_and:nnT
{ ! \seq_if_empty_p:N \l_@@_corners_cells_seq }
{ \dim_compare_p:nNn { #1 } = \c_zero_dim }
{
\@@_expand_clist:NN \l_@@_cols_tl \c@jCol
\@@_expand_clist:NN \l_@@_rows_tl \c@iRow
}
% \end{macrocode}
% We begin the loop over the columns.
% \begin{macrocode}
\clist_map_inline:Nn \l_@@_cols_tl
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
{ \@@_cut_on_hyphen:w ##1 \q_stop }
{ \@@_cut_on_hyphen:w ##1 - ##1 \q_stop }
\bool_lazy_or:nnT
{ \tl_if_blank_p:V \l_tmpa_tl }
{ \str_if_eq_p:Vn \l_tmpa_tl { * } }
{ \tl_set:Nn \l_tmpa_tl { 1 } }
\bool_lazy_or:nnT
{ \tl_if_blank_p:V \l_tmpb_tl }
{ \str_if_eq_p:Vn \l_tmpb_tl { * } }
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
\int_compare:nNnT \l_tmpb_tl > \c@jCol
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
% \end{macrocode}
% |\l_@@_tmpc_tl| will contain the number of column.
% \begin{macrocode}
\tl_set_eq:NN \l_@@_tmpc_tl \l_tmpa_tl
% \end{macrocode}
% If we decide to provide the commands |\cellcolor|, |\rectanglecolor|,
% |\rowcolor|, |\columncolor|, |\rowcolors| and |\chessboardcolors| in the
% |code-before| of a |\SubMatrix|, we will have to modify the following line, by
% adding a kind of offset. We will have also some other lines to modify.
% \begin{macrocode}
\@@_qpoint:n { col - \l_tmpa_tl }
\int_compare:nNnTF \l_@@_first_col_int = \l_tmpa_tl
{ \dim_set:Nn \l_@@_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
{ \dim_set:Nn \l_@@_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
\@@_qpoint:n { col - \int_eval:n { \l_tmpb_tl + 1 } }
\dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth }
% \end{macrocode}
% We begin the loop over the rows.
% \begin{macrocode}
\clist_map_inline:Nn \l_@@_rows_tl
{
\tl_set:Nn \l_tmpa_tl { ####1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
{ \@@_cut_on_hyphen:w ####1 \q_stop }
{ \@@_cut_on_hyphen:w ####1 - ####1 \q_stop }
\tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } }
\tl_if_empty:NT \l_tmpb_tl
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
\int_compare:nNnT \l_tmpb_tl > \c@iRow
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
% \end{macrocode}
% Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|.
% \begin{macrocode}
\seq_if_in:NxF \l_@@_corners_cells_seq
{ \l_tmpa_tl - \l_@@_tmpc_tl }
{
\@@_qpoint:n { row - \int_eval:n { \l_tmpb_tl + 1 } }
\dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { row - \l_tmpa_tl }
\dim_set:Nn \l_@@_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth }
\pgfsetcornersarced { \pgfpoint { #1 } { #1 } }
\pgfpathrectanglecorners
{ \pgfpoint \l_@@_tmpc_dim \l_@@_tmpd_dim }
{ \pgfpoint \l_tmpa_dim \l_tmpb_dim }
}
}
}
}
% \end{macrocode}
%
% \bigskip
% The following command corresponds to a radius of the corners equal to $0$~pt.
% This command is used by the commands |\@@_rowcolors|, |\@@_columncolor| and
% |\@@_rowcolor:n| (used in |\@@_rowcolor|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_cartesian_path: { \@@_cartesian_path:n { 0 pt } }
% \end{macrocode}
%
%
% \bigskip
% The following command will be used only with |\l_@@_cols_tl| and |\c@jCol| (first
% case) or with |\l_@@_rows_tl| and |\c@iRow| (second case). For instance, with
% |\l_@@_cols_tl| equal to |2,4-6,8-*| and |\c@jCol| equal to |10|, the clist
% |\l_@@_cols_tl| will be replaced by |2,4,5,6,8,9,10|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_expand_clist:NN #1 #2
{
\clist_set_eq:NN \l_tmpa_clist #1
\clist_clear:N #1
\clist_map_inline:Nn \l_tmpa_clist
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
{ \@@_cut_on_hyphen:w ##1 \q_stop }
{ \@@_cut_on_hyphen:w ##1 - ##1 \q_stop }
\bool_lazy_or:nnT
{ \tl_if_blank_p:V \l_tmpa_tl }
{ \str_if_eq_p:Vn \l_tmpa_tl { * } }
{ \tl_set:Nn \l_tmpa_tl { 1 } }
\bool_lazy_or:nnT
{ \tl_if_blank_p:V \l_tmpb_tl }
{ \str_if_eq_p:Vn \l_tmpb_tl { * } }
{ \tl_set:Nx \l_tmpb_tl { \int_use:N #2 } }
\int_compare:nNnT \l_tmpb_tl > #2
{ \tl_set:Nx \l_tmpb_tl { \int_use:N #2 } }
\int_step_inline:nnn \l_tmpa_tl \l_tmpb_tl
{ \clist_put_right:Nn #1 { ####1 } }
}
}
% \end{macrocode}
%
% \bigskip
% When the user uses the key |colortbl-like|, the following command will
% be linked to |\cellcolor| in the tabular.
% \begin{macrocode}
\NewDocumentCommand \@@_cellcolor_tabular { O { } m }
{
\peek_remove_spaces:n
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
% \end{macrocode}
% We must not expand the color (|#2|) because the color may contain the token
% |!| which may be activated by some packages (ex.: \pkg{babel} with the option
% |french| on latex and pdflatex).
% \begin{macrocode}
\@@_cellcolor [ #1 ] { \exp_not:n { #2 } }
{ \int_use:N \c@iRow - \int_use:N \c@jCol }
}
}
}
% \end{macrocode}
%
% \bigskip
% When the user uses the key |colortbl-like|, the following command will
% be linked to |\rowcolor| in the tabular.
% \begin{macrocode}
\NewDocumentCommand \@@_rowcolor_tabular { O { } m }
{
\peek_remove_spaces:n
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
\@@_rectanglecolor [ #1 ] { \exp_not:n { #2 } }
{ \int_use:N \c@iRow - \int_use:N \c@jCol }
{ \int_use:N \c@iRow - \exp_not:n { \int_use:N \c@jCol } }
}
}
}
% \end{macrocode}
%
%
% \bigskip
% \begin{macrocode}
\NewDocumentCommand \@@_columncolor_preamble { O { } m }
{
% \end{macrocode}
% With the following line, we test whether the cell is the first one we
% encounter in its column (don't forget that some rows may be incomplete).
% \begin{macrocode}
\int_compare:nNnT \c@jCol > \g_@@_col_total_int
{
% \end{macrocode}
% You use |gput_left| because we want the specification of colors for the
% columns drawn before the specifications of color for the rows (and the cells).
% Be careful: maybe this is not effective since we have an analyze of the
% instructions in the |\CodeBefore| in order to fill color by color (to avoid
% the thin white lines).
% \begin{macrocode}
\tl_gput_left:Nx \g_nicematrix_code_before_tl
{
\exp_not:N \columncolor [ #1 ]
{ \exp_not:n { #2 } } { \int_use:N \c@jCol }
}
}
}
% \end{macrocode}
%
%
%
% \bigskip
% \subsection*{The vertical and horizontal rules}
%
%
% \bigskip
% \subsubsection*{OnlyMainNiceMatrix}
%
% We give to the user the possibility to define new types of columns (with
% |\newcolumntype| of \pkg{array}) for special vertical rules (\emph{e.g.} rules
% thicker than the standard ones) which will not extend in the potential
% exterior rows of the array.
%
% We provide the command |\OnlyMainNiceMatrix| in that goal. However, that
% command must be no-op outside the environments of \pkg{nicematrix} (and so the
% user will be allowed to use the same new type of column in the environments
% of \pkg{nicematrix} and in the standard environments of \pkg{array}).
%
% That's why we provide first a global definition of |\OnlyMainNiceMatrix|.
% \begin{macrocode}
\cs_set_eq:NN \OnlyMainNiceMatrix \use:n
% \end{macrocode}
%
% \medskip
% Another definition of |\OnlyMainNiceMatrix| will be linked to the command in
% the environments of \pkg{nicematrix}. Here is that definition, called
% |\@@_OnlyMainNiceMatrix:n|.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_OnlyMainNiceMatrix:n #1
{
\int_compare:nNnTF \l_@@_first_col_int = 0
{ \@@_OnlyMainNiceMatrix_i:n { #1 } }
{
\int_compare:nNnTF \c@jCol = 0
{
\int_compare:nNnF \c@iRow = { -1 }
{ \int_compare:nNnF \c@iRow = { \l_@@_last_row_int - 1 } { #1 } }
}
{ \@@_OnlyMainNiceMatrix_i:n { #1 } }
}
}
% \end{macrocode}
% This definition may seem complicated but we must remind that the number of row
% |\c@iRow| is incremented in the first cell of the row, \emph{after} a
% potential vertical rule on the left side of the first cell.
%
% \smallskip
% The command |\@@_OnlyMainNiceMatrix_i:n| is only a short-cut which is used
% twice in the above command. This command must \emph{not} be protected.
% \begin{macrocode}
\cs_new_protected:Npn \@@_OnlyMainNiceMatrix_i:n #1
{
\int_compare:nNnF \c@iRow = 0
{ \int_compare:nNnF \c@iRow = \l_@@_last_row_int { #1 } }
}
% \end{macrocode}
% Remember that |\c@iRow| is not always inferior to |\l_@@_last_row_int| because
% |\l_@@_last_row_int| may be equal to $-2$ or $-1$ (we can't write
% |\int_compare:nNnT \c@iRow < \l_@@_last_row_int|).
%
%
% \bigskip
% \subsubsection*{General system for drawing rules}
%
% When a command, environment or ``subsystem'' of \pkg{nicematrix} wants to draw
% a rule, it will write in the internal |\CodeAfter| a command |\@@_vline:n| or
% |\@@_hline:n|. Both commands take in as argument a list of \textsl{key=value}
% pairs. That list will first be analyzed with the following set of keys.
% However, unknown keys will be analyzed further with another set of keys.
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Rules }
{
position .int_set:N = \l_@@_position_int ,
position .value_required:n = true ,
start .int_set:N = \l_@@_start_int ,
start .initial:n = 1 ,
end .int_set:N = \l_@@_end_int ,
% \end{macrocode}
% The following keys are no-op because there are keys which may be inherited
% from a list of pairs \textsl{key=value} of a definition of a customized rule
% (with the key |custom-line| of |\NiceMatrixOptions|).
% \begin{macrocode}
% letter .code:n = \prg_do_nothing: ,
% command .code:n = \prg_do_nothing:
}
% \end{macrocode}
%
% \bigskip
% It's possible that the rule won't be drawn continuously from |start| ot |end|
% because of the blocks (created with the command |\Block|), the virtual blocks
% (created by |\Cdots|, etc.), etc. That's why an analyse is done and the rule
% is cut in small rules which will actually be drawn. The small continuous rules
% will be drawn by |\@@_vline_ii:| and |\@@_hline_ii:|. Those commands use the
% following set of keys.
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / RulesBis }
{
multiplicity .int_set:N = \l_@@_multiplicity_int ,
multiplicity .initial:n = 1 ,
dotted .bool_set:N = \l_@@_dotted_bool ,
dotted .initial:n = false ,
dotted .default:n = true ,
color .code:n = \@@_set_CT@arc@: #1 \q_stop ,
color .value_required:n = true ,
sep-color .code:n = \@@_set_CT@drsc@: #1 \q_stop ,
sep-color .value_required:n = true ,
% \end{macrocode}
% If the user uses the key |tikz|, the rule (or more precisely: the different
% sub-rules since a rule may be broken by blocks or others) will be drawn with
% Tikz.
% \begin{macrocode}
tikz .tl_set:N = \l_@@_tikz_rule_tl ,
tikz .value_required:n = true ,
tikz .initial:n = ,
width .dim_set:N = \l_@@_rule_width_dim ,
width .value_required:n = true
}
% \end{macrocode}
%
%
% \subsubsection*{The vertical rules}
%
% The following command will be executed in the internal |\CodeAfter|. The
% argument |#1| is a list of \textsl{key=value} pairs.
% \begin{macrocode}
\cs_new_protected:Npn \@@_vline:n #1
{
% \end{macrocode}
% The group is for the options.
% \begin{macrocode}
\group_begin:
\int_zero_new:N \l_@@_end_int
\int_set_eq:NN \l_@@_end_int \c@iRow
\keys_set_known:nnN { NiceMatrix / Rules } { #1 } \l_@@_other_keys_tl
% \end{macrocode}
% The following test is for the case where the user does not use all the columns
% specified in the preamble of the environment (for instance, a preamble of
% \verb+|c|c|c|+ but only two columns used).
% \begin{macrocode}
\int_compare:nNnT \l_@@_position_int < { \c@jCol + 2 }
\@@_vline_i:
\group_end:
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_vline_i:
{
\int_zero_new:N \l_@@_local_start_int
\int_zero_new:N \l_@@_local_end_int
% \end{macrocode}
% |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. When
% we have found a row corresponding to a rule to draw, we note its number in
% |\l_@@_tmpc_tl|.
% \begin{macrocode}
\tl_set:Nx \l_tmpb_tl { \int_eval:n \l_@@_position_int }
\int_step_variable:nnNn \l_@@_start_int \l_@@_end_int
\l_tmpa_tl
{
% \end{macrocode}
% The boolean |\g_tmpa_bool| indicates whether the small vertical rule will be
% drawn. If we find that it is in a block (a real block, created by |\Block| or
% a virtual block corresponding to a dotted line, created by |\Cdots|, |\Vdots|,
% etc.), we will set |\g_tmpa_bool| to |false| and the small vertical rule won't
% be drawn.
% \begin{macrocode}
\bool_gset_true:N \g_tmpa_bool
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq
{ \@@_test_vline_in_block:nnnnn ##1 }
\seq_map_inline:Nn \g_@@_pos_of_xdots_seq
{ \@@_test_vline_in_block:nnnnn ##1 }
\seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq
{ \@@_test_vline_in_stroken_block:nnnn ##1 }
\clist_if_empty:NF \l_@@_corners_clist \@@_test_in_corner_v:
\bool_if:NTF \g_tmpa_bool
{
\int_compare:nNnT \l_@@_local_start_int = 0
% \end{macrocode}
% We keep in memory that we have a rule to draw. |\l_@@_local_start_int| will be
% the starting row of the rule that we will have to draw.
% \begin{macrocode}
{ \int_set:Nn \l_@@_local_start_int \l_tmpa_tl }
}
{
\int_compare:nNnT \l_@@_local_start_int > 0
{
\int_set:Nn \l_@@_local_end_int { \l_tmpa_tl - 1 }
\@@_vline_ii:
\int_zero:N \l_@@_local_start_int
}
}
}
\int_compare:nNnT \l_@@_local_start_int > 0
{
\int_set_eq:NN \l_@@_local_end_int \l_@@_end_int
\@@_vline_ii:
}
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_in_corner_v:
{
\int_compare:nNnTF \l_tmpb_tl = { \int_eval:n { \c@jCol + 1 } }
{
\seq_if_in:NxT
\l_@@_corners_cells_seq
{ \l_tmpa_tl - \int_eval:n { \l_tmpb_tl - 1 } }
{ \bool_set_false:N \g_tmpa_bool }
}
{
\seq_if_in:NxT
\l_@@_corners_cells_seq
{ \l_tmpa_tl - \l_tmpb_tl }
{
\int_compare:nNnTF \l_tmpb_tl = 1
{ \bool_set_false:N \g_tmpa_bool }
{
\seq_if_in:NxT
\l_@@_corners_cells_seq
{ \l_tmpa_tl - \int_eval:n { \l_tmpb_tl - 1 } }
{ \bool_set_false:N \g_tmpa_bool }
}
}
}
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_vline_ii:
{
\bool_set_false:N \l_@@_dotted_boo
% \end{macrocode}
% We use |\keys_set_known:nV| and not |\keys_set:nV| because there may be the
% keys |letter| and |command| in the list (these keys are present if the rule
% comes from a customized line (created by |custom-line|).
% \begin{macrocode}
\keys_set_known:nV { NiceMatrix / RulesBis } \l_@@_other_keys_tl
\bool_if:NTF \l_@@_dotted_bool
\@@_vline_iv:
{
\tl_if_empty:NTF \l_@@_tikz_rule_tl
\@@_vline_iii:
\@@_vline_v:
}
}
% \end{macrocode}
%
% \bigskip
% First the case of a standard rule, that is to say a rule which is not dotted
% (and the user has not used the key |tikz|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_vline_iii:
{
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_qpoint:n { row - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\@@_qpoint:n { col - \int_use:N \l_@@_position_int }
\dim_set_eq:NN \l_tmpb_dim \pgf@x
\@@_qpoint:n { row - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y
\bool_lazy_all:nT
{
{ \int_compare_p:nNn \l_@@_multiplicity_int > 1 }
{ \cs_if_exist_p:N \CT@drsc@ }
{ ! \tl_if_blank_p:V \CT@drsc@ }
}
{
\group_begin:
\CT@drsc@
\dim_add:Nn \l_tmpa_dim { 0.5 \arrayrulewidth }
\dim_sub:Nn \l_@@_tmpc_dim { 0.5 \arrayrulewidth }
\dim_set:Nn \l_@@_tmpd_dim
{
\l_tmpb_dim - ( \doublerulesep + \arrayrulewidth )
* ( \l_@@_multiplicity_int - 1 )
}
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpb_dim \l_tmpa_dim }
{ \pgfpoint \l_@@_tmpd_dim \l_@@_tmpc_dim }
\pgfusepath { fill }
\group_end:
}
\pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
\pgfpathlineto { \pgfpoint \l_tmpb_dim \l_@@_tmpc_dim }
\prg_replicate:nn { \l_@@_multiplicity_int - 1 }
{
\dim_sub:Nn \l_tmpb_dim \arrayrulewidth
\dim_sub:Nn \l_tmpb_dim \doublerulesep
\pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
\pgfpathlineto { \pgfpoint \l_tmpb_dim \l_@@_tmpc_dim }
}
\CT@arc@
\pgfsetlinewidth { 1.1 \arrayrulewidth }
\pgfsetrectcap
\pgfusepathqstroke
\endpgfpicture
}
% \end{macrocode}
%
%
% \bigskip
% The following code is for the case of a dotted rule (with our system of
% rounded dots).
% \begin{macrocode}
\cs_new_protected:Npn \@@_vline_iv:
{
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_qpoint:n { col - \int_use:N \l_@@_position_int }
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x
\@@_qpoint:n { row - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
\@@_qpoint:n { row - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y
\CT@arc@
\@@_draw_line:
\endpgfpicture
}
% \end{macrocode}
%
% \bigskip
% The following code is for the case when the user uses the key |tikz| (in the
% definition of a customized rule by using the key |custom-line|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_vline_v:
{
\begin {tikzpicture }
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_qpoint:n { row - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\@@_qpoint:n { col - \int_use:N \l_@@_position_int }
\dim_set:Nn \l_tmpb_dim { \pgf@x - 0.5 \l_@@_rule_width_dim }
\@@_qpoint:n { row - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y
\exp_args:NV \tikzset \l_@@_tikz_rule_tl
\use:x { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] }
( \l_tmpb_dim , \l_tmpa_dim ) --
( \l_tmpb_dim , \l_@@_tmpc_dim ) ;
\end { tikzpicture }
}
% \end{macrocode}
%
%
% \bigskip
% The command |\@@_draw_vlines:| draws all the vertical rules excepted in the
% blocks, in the virtual blocks (determined by a command such as |\Cdots|) and in
% the corners (if the key |corners| is used).
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_vlines:
{
\int_step_inline:nnn
{
\bool_if:nTF { \l_@@_NiceArray_bool && ! \l_@@_except_borders_bool }
1 2
}
{
\bool_if:nTF { \l_@@_NiceArray_bool && ! \l_@@_except_borders_bool }
{ \int_eval:n { \c@jCol + 1 } }
\c@jCol
}
{
\tl_if_eq:NnF \l_@@_vlines_clist { all }
{ \clist_if_in:NnT \l_@@_vlines_clist { ##1 } }
{ \@@_vline:n { position = ##1 } }
}
}
% \end{macrocode}
%
%
%
% \subsubsection*{The horizontal rules}
%
% \bigskip
% The following command will be executed in the internal |\CodeAfter|. The
% argument |#1| is a list of \textsl{key=value} pairs of the form
% |{NiceMatrix/Rules}|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_hline:n #1
{
% \end{macrocode}
% The group is for the options.
% \begin{macrocode}
\group_begin:
\int_zero_new:N \l_@@_end_int
\int_set_eq:NN \l_@@_end_int \c@jCol
\keys_set_known:nnN { NiceMatrix / Rules } { #1 } \l_@@_other_keys_tl
\@@_hline_i:
\group_end:
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_hline_i:
{
\int_zero_new:N \l_@@_local_start_int
\int_zero_new:N \l_@@_local_end_int
% \end{macrocode}
% |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. When
% we have found a column corresponding to a rule to draw, we note its number in
% |\l_@@_tmpc_tl|.
% \begin{macrocode}
\tl_set:Nx \l_tmpa_tl { \int_use:N \l_@@_position_int }
\int_step_variable:nnNn \l_@@_start_int \l_@@_end_int
\l_tmpb_tl
{
% \end{macrocode}
% The boolean |\g_tmpa_bool| indicates whether the small horizontal rule will be
% drawn. If we find that it is in a block (a real block, created by |\Block| or
% a virtual block corresponding to a dotted line, created by |\Cdots|, |\Vdots|,
% etc.), we will set |\g_tmpa_bool| to |false| and the small horizontal rule won't
% be drawn.
% \begin{macrocode}
\bool_gset_true:N \g_tmpa_bool
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq
{ \@@_test_hline_in_block:nnnnn ##1 }
\seq_map_inline:Nn \g_@@_pos_of_xdots_seq
{ \@@_test_hline_in_block:nnnnn ##1 }
\seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq
{ \@@_test_hline_in_stroken_block:nnnn ##1 }
\clist_if_empty:NF \l_@@_corners_clist \@@_test_in_corner_h:
\bool_if:NTF \g_tmpa_bool
{
\int_compare:nNnT \l_@@_local_start_int = 0
% \end{macrocode}
% We keep in memory that we have a rule to draw. |\l_@@_local_start_int| will be
% the starting row of the rule that we will have to draw.
% \begin{macrocode}
{ \int_set:Nn \l_@@_local_start_int \l_tmpb_tl }
}
{
\int_compare:nNnT \l_@@_local_start_int > 0
{
\int_set:Nn \l_@@_local_end_int { \l_tmpb_tl - 1 }
\@@_hline_ii:
\int_zero:N \l_@@_local_start_int
}
}
}
\int_compare:nNnT \l_@@_local_start_int > 0
{
\int_set_eq:NN \l_@@_local_end_int \l_@@_end_int
\@@_hline_ii:
}
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_in_corner_h:
{
\int_compare:nNnTF \l_tmpa_tl = { \int_eval:n { \c@iRow + 1 } }
{
\seq_if_in:NxT
\l_@@_corners_cells_seq
{ \int_eval:n { \l_tmpa_tl - 1 } - \l_tmpb_tl }
{ \bool_set_false:N \g_tmpa_bool }
}
{
\seq_if_in:NxT
\l_@@_corners_cells_seq
{ \l_tmpa_tl - \l_tmpb_tl }
{
\int_compare:nNnTF \l_tmpa_tl = 1
{ \bool_set_false:N \g_tmpa_bool }
{
\seq_if_in:NxT
\l_@@_corners_cells_seq
{ \int_eval:n { \l_tmpa_tl - 1 } - \l_tmpb_tl }
{ \bool_set_false:N \g_tmpa_bool }
}
}
}
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_hline_ii:
{
\bool_set_false:N \l_@@_dotted_bool
% \end{macrocode}
% We use |\keys_set_known:nV| and not |\keys_set:nV| because there may be the
% keys |letter| and |command| in the list (these keys are present if the rule
% comes from a customized line (created by |custom-line|).
% \begin{macrocode}
\keys_set_known:nV { NiceMatrix / RulesBis } \l_@@_other_keys_tl
\bool_if:NTF \l_@@_dotted_bool
\@@_hline_iv:
{
\tl_if_empty:NTF \l_@@_tikz_rule_tl
\@@_hline_iii:
\@@_hline_v:
}
}
% \end{macrocode}
%
% \bigskip
% First the case of a standard rule, that is to say a rule which is not dotted.
% \begin{macrocode}
\cs_new_protected:Npn \@@_hline_iii:
{
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_qpoint:n { col - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_tmpa_dim \pgf@x
\@@_qpoint:n { row - \int_use:N \l_@@_position_int }
\dim_set_eq:NN \l_tmpb_dim \pgf@y
\@@_qpoint:n { col - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@x
\bool_lazy_all:nT
{
{ \int_compare_p:nNn \l_@@_multiplicity_int > 1 }
{ \cs_if_exist_p:N \CT@drsc@ }
{ ! \tl_if_blank_p:V \CT@drsc@ }
}
{
\group_begin:
\CT@drsc@
\dim_set:Nn \l_@@_tmpd_dim
{
\l_tmpb_dim - ( \doublerulesep + \arrayrulewidth )
* ( \l_@@_multiplicity_int - 1 )
}
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpa_dim \l_tmpb_dim }
{ \pgfpoint \l_@@_tmpc_dim \l_@@_tmpd_dim }
\pgfusepathqfill
\group_end:
}
\pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
\pgfpathlineto { \pgfpoint \l_@@_tmpc_dim \l_tmpb_dim }
\prg_replicate:nn { \l_@@_multiplicity_int - 1 }
{
\dim_sub:Nn \l_tmpb_dim \arrayrulewidth
\dim_sub:Nn \l_tmpb_dim \doublerulesep
\pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
\pgfpathlineto { \pgfpoint \l_@@_tmpc_dim \l_tmpb_dim }
}
\CT@arc@
\pgfsetlinewidth { 1.1 \arrayrulewidth }
\pgfsetrectcap
\pgfusepathqstroke
\endpgfpicture
}
% \end{macrocode}
%
% \bigskip
% The following code is for the case of a dotted rule (with our system of
% rounded dots).
% The aim is that, by standard the dotted line fits between square brackets
% (|\hline| doesn't).
%
% \smallskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{bNiceMatrix}
% 1 & 2 & 3 & 4 \\
% \hline
% 1 & 2 & 3 & 4 \\
% \hdottedline
% 1 & 2 & 3 & 4
% \end{bNiceMatrix}
% \end{BVerbatim}
% $\begin{bNiceMatrix}
% 1 & 2 & 3 & 4 \\
% \hline
% 1 & 2 & 3 & 4 \\
% \hdottedline
% 1 & 2 & 3 & 4
% \end{bNiceMatrix}$
%
% \smallskip
% But, if the user uses |margin|, the dotted line extends to have the same width
% as a |\hline|.
%
% \smallskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \begin{bNiceMatrix}[margin]
% 1 & 2 & 3 & 4 \\
% \hline
% 1 & 2 & 3 & 4 \\
% \hdottedline
% 1 & 2 & 3 & 4
% \end{bNiceMatrix}
% \end{BVerbatim}
% $\begin{bNiceMatrix}[margin]
% 1 & 2 & 3 & 4 \\
% \hline
% 1 & 2 & 3 & 4 \\
% \hdottedline
% 1 & 2 & 3 & 4
% \end{bNiceMatrix}$
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_hline_iv:
{
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_qpoint:n { row - \int_use:N \l_@@_position_int }
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y
\@@_qpoint:n { col - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
\int_compare:nNnT \l_@@_local_start_int = 1
{
\dim_sub:Nn \l_@@_x_initial_dim \l_@@_left_margin_dim
\bool_if:NT \l_@@_NiceArray_bool
{ \dim_sub:Nn \l_@@_x_initial_dim \arraycolsep }
% \end{macrocode}
% For reasons purely aesthetic, we do an adjustment in the case of a rounded
% bracket. The correction by |0.5 \l_@@_inter_dots_dim| is \emph{ad hoc} for a
% better result.
% \begin{macrocode}
\tl_if_eq:NnF \g_@@_left_delim_tl (
{ \dim_add:Nn \l_@@_x_initial_dim { 0.5 \l_@@_inter_dots_dim } }
}
\@@_qpoint:n { col - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x
\int_compare:nNnT \l_@@_local_end_int = \c@jCol
{
\dim_add:Nn \l_@@_x_final_dim \l_@@_right_margin_dim
\bool_if:NT \l_@@_NiceArray_bool
{ \dim_add:Nn \l_@@_x_final_dim \arraycolsep }
\tl_if_eq:NnF \g_@@_right_delim_tl )
{ \dim_gsub:Nn \l_@@_x_final_dim { 0.5 \l_@@_inter_dots_dim } }
}
\CT@arc@
\@@_draw_line:
\endpgfpicture
}
% \end{macrocode}
%
% \bigskip
% The following code is for the case when the user uses the key |tikz| (in the
% definition of a customized rule by using the key |custom-line|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_hline_v:
{
\begin { tikzpicture }
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_qpoint:n { col - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_tmpa_dim \pgf@x
\@@_qpoint:n { row - \int_use:N \l_@@_position_int }
\dim_set:Nn \l_tmpb_dim { \pgf@y - 0.5 \l_@@_rule_width_dim }
\@@_qpoint:n { col - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@x
\exp_args:NV \tikzset \l_@@_tikz_rule_tl
\use:x { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] }
( \l_tmpa_dim , \l_tmpb_dim ) --
( \l_@@_tmpc_dim , \l_tmpb_dim ) ;
\end { tikzpicture }
}
% \end{macrocode}
%
%
% \bigskip
% The command |\@@_draw_hlines:| draws all the horizontal rules excepted in the
% blocks (even the virtual blocks determined by commands such as |\Cdots| and in
% the corners (if the key |corners| is used)).
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_hlines:
{
\int_step_inline:nnn
{
\bool_if:nTF { \l_@@_NiceArray_bool && ! \l_@@_except_borders_bool }
1 2
}
{
\bool_if:nTF { \l_@@_NiceArray_bool && ! \l_@@_except_borders_bool }
{ \int_eval:n { \c@iRow + 1 } }
\c@iRow
}
{
\tl_if_eq:NnF \l_@@_hlines_clist { all }
{ \clist_if_in:NnT \l_@@_hlines_clist { ##1 } }
{ \@@_hline:n { position = ##1 } }
}
}
% \end{macrocode}
%
%
% \medskip
% The command |\@@_Hline:| will be linked to |\Hline| in the environments of \pkg{nicematrix}.
% \begin{macrocode}
\cs_set:Npn \@@_Hline: { \noalign { \ifnum 0 = `} \fi \@@_Hline_i:n { 1 } }
% \end{macrocode}
%
% \medskip
% The argument of the command |\@@_Hline_i:n| is the number of successive
% |\Hline| found.
% \begin{macrocode}
\cs_set:Npn \@@_Hline_i:n #1
{
\peek_remove_spaces:n
{
\peek_meaning:NTF \Hline
{ \@@_Hline_ii:nn { #1 + 1 } }
{ \@@_Hline_iii:n { #1 } }
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_set:Npn \@@_Hline_ii:nn #1 #2 { \@@_Hline_i:n { #1 } }
% \end{macrocode}
%
% \begin{macrocode}
\cs_set:Npn \@@_Hline_iii:n #1
{
\skip_vertical:n
{
\arrayrulewidth * ( #1 )
+ \doublerulesep * ( \int_max:nn 0 { #1 - 1 } )
}
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{
\@@_hline:n
{
position = \int_eval:n { \c@iRow + 1 } ,
multiplicity = #1
}
}
\ifnum 0 = `{ \fi }
}
% \end{macrocode}
%
% \subsubsection*{Customized rules defined by the final user}
%
% The final user can define a customized rule by using the key |custom-line| in
% |\NiceMatrixOptions|. That key takes in as value a list of \textsl{key=value}
% pairs.
%
%
%
% \medskip
% Among the keys avalaible in that list, there is the key |letter| to specify a
% letter that the final user will use in the preamble of the array. All the
% letters defined by this way by the final user for such customized rules are
% added in the set of keys |{NiceMatrix / ColumnTypes}|. That set of keys is
% used to store the characteristics of those types of rules for convenience: the
% keys of that set of keys won't never be used as keys by the final user (he
% will use, instead, letters in the preamble of its array).
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / ColumnTypes } { }
% \end{macrocode}
%
%
% \medskip
% The following command will create the customized rule (it is executed when the
% final user uses the key |custom-line|, for example in |\NiceMatrixOptions|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_custom_line:n #1
{
\str_clear_new:N \l_@@_command_str
\str_clear_new:N \l_@@_letter_str
\dim_zero_new:N \l_@@_rule_width_dim
% \end{macrocode}
% The token list |\l_tmpa_tl| is for the key |color|.
% \begin{macrocode}
\tl_clear:N \l_tmpa_tl
% \end{macrocode}
% The flag |\l_tmpa_bool| will indicate whether the key |tikz| is present.
% \begin{macrocode}
\bool_set_false:N \l_tmpa_bool
% \end{macrocode}
% The flag |\l_tmpb_bool| will indicate whether the key |width| is present.
% \begin{macrocode}
\bool_set_false:N \l_tmpb_bool
\keys_set_known:nn { NiceMatrix / Custom-Line } { #1 }
\bool_if:NT \l_tmpa_bool
{
% \end{macrocode}
% We can't use |\c_@@_tikz_loaded_bool| to test whether \pkg{tikz} is loaded
% because |\NiceMatrixOptions| may be used in the preamble of the document.
% \begin{macrocode}
\cs_if_exist:NF \tikzpicture
{ \@@_error:n { tikz~in~custom-line~without~tikz } }
\tl_if_empty:NF \l_tmpa_tl
{ \@@_error:n { color~in~custom-line~with~tikz } }
}
\bool_if:NT \l_tmpb_bool
{
\bool_if:NF \l_tmpa_bool
{ \@@_error:n { key~width~without~key~tikz } }
}
% \end{macrocode}
% If the final user only wants to draw horizontal rules, he does not need to
% specify a letter (for the vertical rules in the preamble of the array). On the
% other hand, if he only wants to draw vertical rules, he does not need to
% define a command (which is the tool to draw horizontal rules in the array). Of
% course, a definition of custom lines with no letter and no command would be point-less.
%
% \begin{macrocode}
\bool_lazy_and:nnTF
{ \str_if_empty_p:N \l_@@_letter_str }
{ \str_if_empty_p:N \l_@@_command_str }
{ \@@_error:n { No~letter~and~no~command } }
{
\str_if_empty:NF \l_@@_letter_str
{
\int_compare:nNnTF { \str_count:N \l_@@_letter_str } = 1
{
\exp_args:NnV \tl_if_in:NnTF
\c_@@_forbidden_letters_str \l_@@_letter_str
{ \@@_error:n { Forbidden~letter } }
{
% \end{macrocode}
% The final user can, locally, redefine a letter of column type. That's
% compatible with the use of |\keys_define:nn|: the definition is local and may
% overwrite a previous definition.
% \begin{macrocode}
\keys_define:nx { NiceMatrix / ColumnTypes }
{
\l_@@_letter_str .code:n =
{ \@@_custom_line_i:n { \exp_not:n { #1 } } }
}
}
}
{ \@@_error:n { Several~letters } }
}
\str_if_empty:NF \l_@@_command_str
{
% \end{macrocode}
% The flag |\l_tmpa_bool| means that the key 'tikz' have been used. When the key
% 'tikz' has not been used, the width of the rule is computed with the
% multiplicity of the rule.
% \begin{macrocode}
\bool_if:NF \l_tmpa_bool
{
\dim_set:Nn \l_@@_rule_width_dim
{
\arrayrulewidth * \l_@@_tmpc_int
+ \doublerulesep * ( \l_@@_tmpc_int - 1 )
}
}
\@@_define_h_custom_line:nV { #1 } \l_@@_rule_width_dim
}
}
}
% \end{macrocode}
%
% \begin{macrocode}
\str_const:Nn \c_@@_forbidden_letters_str { lcrpmbVX|()[]!@<> }
% \end{macrocode}
%
% \medskip
% The previous command |\@@_custom_line:n| uses the following set of keys.
% However, the whole definition of the customized lines (as provided by the
% final user as argument of |custom-line|) will also be used further with
% other sets of keys (for instance |{NiceMatrix/Rules}|). That's why the
% following set of keys has only entries for a few keys.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Custom-Line }
{
% here, we will use change in the future to use .tl_set:N
letter .code:n = \str_set:Nn \l_@@_letter_str { #1 } ,
letter .value_required:n = true ,
% here, we will use change in the future to use .tl_set:N
command .code:n = \str_set:Nn \l_@@_command_str { #1 } ,
command .value_required:n = true ,
multiplicity .int_set:N = \l_@@_tmpc_int ,
multiplicity .initial:n = 1 ,
multiplicity .value_required:n = true ,
color .tl_set:N = \l_tmpa_tl ,
color .value_required:n = true ,
% \end{macrocode}
% When the key |tikz| is used, the rule will be drawn with Tikz by using the set
% of keys specified in the value of that key |tikz|.
% \begin{macrocode}
tikz .code:n = \bool_set_true:N \l_tmpa_bool ,
% \end{macrocode}
% The key |width| must be used only when the key |tikz| is used. When used, the
% key |width| specifies the width of the rule: it will be used to reserve space
% (in the preamble of the array or in the command for the horizontal rules).
% \begin{macrocode}
width .code:n = \dim_set:Nn \l_@@_rule_width_dim { #1 }
\bool_set_true:N \l_tmpb_bool ,
width .value_required:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~custom-line }
}
% \end{macrocode}
%
% \bigskip
% The following command will create the command that the final user will use in
% its array to draw a horizontal rule (hence the `|h|` in the name). |#1| is the
% whole set of keys to pass to |\@@_line:n| and |#2| is the widht of the whole
% rule.
% \begin{macrocode}
\cs_new_protected:Npn \@@_define_h_custom_line:nn #1 #2
{
% \end{macrocode}
% We use |\cs_set:cpn| and not |\cs_new:cpn| because we want a local definition.
% Moreover, the command must \emph{not} be protected since it begins with |\noalign|.
% \begin{macrocode}
\cs_set:cpn { nicematrix - \l_@@_command_str }
{
\noalign
{
\skip_vertical:n { #2 }
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_hline:n { #1 , position = \int_eval:n { \c@iRow + 1 } } }
}
}
\seq_put_left:NV \l_@@_custom_line_commands_seq \l_@@_command_str
}
\cs_generate_variant:Nn \@@_define_h_custom_line:nn { n V }
% \end{macrocode}
%
% The flag |\l_tmpa_bool| means that the key 'tikz' have been used. When the key
% 'tikz' has not been used, the width of the rule is computed with the
% multiplicity of the rule.
% \begin{macrocode}
\cs_new_protected:Npn \@@_custom_line_i:n #1
{
\bool_if:NF \l_tmpa_bool
{
\dim_set:Nn \l_@@_rule_width_dim
{
\arrayrulewidth * \l_@@_tmpc_int
+ \doublerulesep * ( \l_@@_tmpc_int - 1)
}
}
\tl_gput_right:Nx \g_@@_preamble_tl
{
\exp_not:N !
{ \skip_horizontal:n { \dim_use:N \l_@@_rule_width_dim } }
}
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_vline:n { #1 , position = \int_eval:n { \c@jCol + 1 } } }
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_custom_line:n { letter = : , command = hdottedline , dotted }
% \end{macrocode}
%
% \subsubsection*{The key hvlines}
%
% The following command tests whether the current position in the array (given by
% |\l_tmpa_tl| for the row and |\l_tmpb_tl| for the column) would provide an
% horizontal rule towards the right in the block delimited by the four arguments
% |#1|, |#2|, |#3| and |#4|. If this rule would be in the block (it must not be
% drawn), the boolean |\l_tmpa_bool| is set to |false|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_hline_in_block:nnnnn #1 #2 #3 #4
{
\bool_lazy_all:nT
{
{ \int_compare_p:nNn \l_tmpa_tl > { #1 } }
{ \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } }
{ \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } }
{ \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } }
}
{ \bool_gset_false:N \g_tmpa_bool }
}
% \end{macrocode}
%
% The same for vertical rules.
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_vline_in_block:nnnnn #1 #2 #3 #4
{
\bool_lazy_all:nT
{
{ \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } }
{ \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } }
{ \int_compare_p:nNn \l_tmpb_tl > { #2 } }
{ \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } }
}
{ \bool_gset_false:N \g_tmpa_bool }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_hline_in_stroken_block:nnnn #1 #2 #3 #4
{
\bool_lazy_all:nT
{
{ \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } }
{ \int_compare_p:nNn \l_tmpa_tl < { #3 + 2 } }
{ \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } }
{ \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } }
}
{ \bool_gset_false:N \g_tmpa_bool }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_vline_in_stroken_block:nnnn #1 #2 #3 #4
{
\bool_lazy_all:nT
{
{ \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } }
{ \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } }
{ \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } }
{ \int_compare_p:nNn \l_tmpb_tl < { #4 + 2 } }
}
{ \bool_gset_false:N \g_tmpa_bool }
}
% \end{macrocode}
%
% \bigskip
% \subsection*{The key corners}
%
% When the key |corners| is raised, the rules are not drawn in the
% corners. Of course, we have to compute the corners before we begin to draw the
% rules.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_compute_corners:
{
% \end{macrocode}
% The sequence |\l_@@_corners_cells_seq| will be the sequence of all the
% empty cells (and not in a block) considered in the corners of the array.
% \begin{macrocode}
\seq_clear_new:N \l_@@_corners_cells_seq
\clist_map_inline:Nn \l_@@_corners_clist
{
\str_case:nnF { ##1 }
{
{ NW }
{ \@@_compute_a_corner:nnnnnn 1 1 1 1 \c@iRow \c@jCol }
{ NE }
{ \@@_compute_a_corner:nnnnnn 1 \c@jCol 1 { -1 } \c@iRow 1 }
{ SW }
{ \@@_compute_a_corner:nnnnnn \c@iRow 1 { -1 } 1 1 \c@jCol }
{ SE }
{ \@@_compute_a_corner:nnnnnn \c@iRow \c@jCol { -1 } { -1 } 1 1 }
}
{ \@@_error:nn { bad~corner } { ##1 } }
}
% \end{macrocode}
% Even if the user has used the key |corners| the list of cells in the corners
% may be empty.
% \begin{macrocode}
\seq_if_empty:NF \l_@@_corners_cells_seq
{
% \end{macrocode}
% You write on the |aux| file the list of the cells which are in the (empty)
% corners because you need that information in the |\CodeBefore| since the
% commands which color the |rows|, |columns| and |cells| must not color the
% cells in the corners.
% \begin{macrocode}
\tl_gput_right:Nx \g_@@_aux_tl
{
\seq_set_from_clist:Nn \exp_not:N \l_@@_corners_cells_seq
{ \seq_use:Nnnn \l_@@_corners_cells_seq , , , }
}
}
}
% \end{macrocode}
%
%
% \bigskip
% ``Computing a corner'' is determining all the empty cells (which are not in a
% block) that belong to that corner. These cells will be added to the sequence
% |\l_@@_corners_cells_seq|.
%
% \medskip
% The six arguments of |\@@_compute_a_corner:nnnnnn| are as follow:
% \begin{itemize}
% \item |#1| and |#2| are the number of row and column of the cell which is
% actually in the corner;
% \item |#3| and |#4| are the steps in rows and the step in columns when moving
% from the corner;
% \item |#5| is the number of the final row when scanning the rows from the
% corner;
% \item |#6| is the number of the final column when scanning the columns from
% the corner.
% \end{itemize}
% \begin{macrocode}
\cs_new_protected:Npn \@@_compute_a_corner:nnnnnn #1 #2 #3 #4 #5 #6
{
% \end{macrocode}
% For the explanations and the name of the variables, we consider that we are
% computing the left-upper corner.
%
% First, we try to determine which is the last empty cell (and not in a block:
% we won't add that precision any longer) in the column of number~$1$. The flag
% |\l_tmpa_bool| will be raised when a non-empty cell is found.
% \begin{macrocode}
\bool_set_false:N \l_tmpa_bool
\int_zero_new:N \l_@@_last_empty_row_int
\int_set:Nn \l_@@_last_empty_row_int { #1 }
\int_step_inline:nnnn { #1 } { #3 } { #5 }
{
\@@_test_if_cell_in_a_block:nn { ##1 } { \int_eval:n { #2 } }
\bool_lazy_or:nnTF
{
\cs_if_exist_p:c
{ pgf @ sh @ ns @ \@@_env: - ##1 - \int_eval:n { #2 } }
}
\l_tmpb_bool
{ \bool_set_true:N \l_tmpa_bool }
{
\bool_if:NF \l_tmpa_bool
{ \int_set:Nn \l_@@_last_empty_row_int { ##1 } }
}
}
% \end{macrocode}
% Now, you determine the last empty cell in the row of number~$1$.
% \begin{macrocode}
\bool_set_false:N \l_tmpa_bool
\int_zero_new:N \l_@@_last_empty_column_int
\int_set:Nn \l_@@_last_empty_column_int { #2 }
\int_step_inline:nnnn { #2 } { #4 } { #6 }
{
\@@_test_if_cell_in_a_block:nn { \int_eval:n { #1 } } { ##1 }
\bool_lazy_or:nnTF
\l_tmpb_bool
{
\cs_if_exist_p:c
{ pgf @ sh @ ns @ \@@_env: - \int_eval:n { #1 } - ##1 }
}
{ \bool_set_true:N \l_tmpa_bool }
{
\bool_if:NF \l_tmpa_bool
{ \int_set:Nn \l_@@_last_empty_column_int { ##1 } }
}
}
% \end{macrocode}
% Now, we loop over the rows.
% \begin{macrocode}
\int_step_inline:nnnn { #1 } { #3 } \l_@@_last_empty_row_int
{
% \end{macrocode}
% We treat the row number |##1| with another loop.
% \begin{macrocode}
\bool_set_false:N \l_tmpa_bool
\int_step_inline:nnnn { #2 } { #4 } \l_@@_last_empty_column_int
{
\@@_test_if_cell_in_a_block:nn { ##1 } { ####1 }
\bool_lazy_or:nnTF
\l_tmpb_bool
{
\cs_if_exist_p:c
{ pgf @ sh @ ns @ \@@_env: - ##1 - ####1 }
}
{ \bool_set_true:N \l_tmpa_bool }
{
\bool_if:NF \l_tmpa_bool
{
\int_set:Nn \l_@@_last_empty_column_int { ####1 }
\seq_put_right:Nn
\l_@@_corners_cells_seq
{ ##1 - ####1 }
}
}
}
}
}
% \end{macrocode}
%
% \bigskip
% The following macro tests whether a cell is in (at least) one of
% the blocks of the array (or in a cell with a |\diagbox|).
%
% The flag |\l_tmpb_bool| will be raised if the cell |#1|-|#2| is in a block (or
% in a cell with a |\diagbox|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_if_cell_in_a_block:nn #1 #2
{
\int_set:Nn \l_tmpa_int { #1 }
\int_set:Nn \l_tmpb_int { #2 }
\bool_set_false:N \l_tmpb_bool
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq
{ \@@_test_if_cell_in_block:nnnnnnn \l_tmpa_int \l_tmpb_int ##1 }
}
% \end{macrocode}
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_if_cell_in_block:nnnnnnn #1 #2 #3 #4 #5 #6 #7
{
\int_compare:nNnT { #3 } < { \int_eval:n { #1 + 1 } }
{
\int_compare:nNnT { #1 } < { \int_eval:n { #5 + 1 } }
{
\int_compare:nNnT { #4 } < { \int_eval:n { #2 + 1 } }
{
\int_compare:nNnT { #2 } < { \int_eval:n { #6 + 1 } }
{ \bool_set_true:N \l_tmpb_bool }
}
}
}
}
% \end{macrocode}
%
%
% \bigskip
% \subsection*{The commands to draw dotted lines to separate columns and rows}
%
% These commands don't use the normal nodes, the medium nor the large nodes.
% They only use the |col| nodes and the |row| nodes.
%
% \textbf{Horizontal dotted lines}\par\nobreak
%
% \medskip
% The following command must \emph{not} be protected because it's meant to be
% expanded in a |\noalign|.
% \begin{macrocode}
\cs_new:Npn \@@_hdottedline:
{
\noalign { \skip_vertical:N 2\l_@@_radius_dim }
\@@_hdottedline_i:
}
% \end{macrocode}
%
% \medskip
% On the other side, the following command should be protected.
% \begin{macrocode}
\cs_new_protected:Npn \@@_hdottedline_i:
{
% \end{macrocode}
% We write in the internal |\CodeAfter| the instruction that will actually draw
% the dotted line. It's not possible to draw this dotted line now because we
% don't know the length of the line (we don't even know the number of columns).
% \begin{macrocode}
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{ \@@_hdottedline:n { \int_use:N \c@iRow } }
}
% \end{macrocode}
%
%
% \medskip
% The command |\@@_hdottedline:n| is the command written in the internal
% |\CodeAfter| that will actually draw the dotted line. Its argument is the
% number of the row \emph{before} which we will draw the row.
% \begin{macrocode}
\cs_new_protected:Npn \@@_hdottedline:n #1
{ \@@_hline:n { position = #1 , end = \int_use:N \c@jCol , dotted } }
% \end{macrocode}
%
%
%
% \bigskip
% \textbf{Vertical dotted lines}\par\nobreak
%
% \medskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_vdottedline:n #1
{ \@@_vline:n { position = \int_eval:n { #1 + 1 } , dotted } }
% \end{macrocode}
%
% \bigskip
% \subsection*{The environment \{NiceMatrixBlock\}}
%
% The following flag will be raised when all the columns of the environments of
% the block must have the same width in ``auto'' mode.
% \begin{macrocode}
\bool_new:N \l_@@_block_auto_columns_width_bool
% \end{macrocode}
%
% \bigskip
% Up to now, there is only one option available for the environment
% |{NiceMatrixBlock}|.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceMatrixBlock }
{
auto-columns-width .code:n =
{
\bool_set_true:N \l_@@_block_auto_columns_width_bool
\dim_gzero_new:N \g_@@_max_cell_width_dim
\bool_set_true:N \l_@@_auto_columns_width_bool
}
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\NewDocumentEnvironment { NiceMatrixBlock } { ! O { } }
{
\int_gincr:N \g_@@_NiceMatrixBlock_int
\dim_zero:N \l_@@_columns_width_dim
\keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 }
\bool_if:NT \l_@@_block_auto_columns_width_bool
{
\cs_if_exist:cT { @@_max_cell_width_ \int_use:N \g_@@_NiceMatrixBlock_int }
{
\exp_args:NNc \dim_set:Nn \l_@@_columns_width_dim
{ @@_max_cell_width _ \int_use:N \g_@@_NiceMatrixBlock_int }
}
}
}
% \end{macrocode}
%
% \medskip
% At the end of the environment |{NiceMatrixBlock}|, we write in the main |aux|
% file instructions for the column width of all the environments of the block
% (that's why we have stored the number of the first environment of the block in
% the counter |\l_@@_first_env_block_int|).
% \begin{macrocode}
{
\bool_if:NT \l_@@_block_auto_columns_width_bool
{
\iow_shipout:Nn \@mainaux \ExplSyntaxOn
\iow_shipout:Nx \@mainaux
{
\cs_gset:cpn
{ @@ _ max _ cell _ width _ \int_use:N \g_@@_NiceMatrixBlock_int }
% \end{macrocode}
% For technical reasons, we have to include the width of a potential rule on the
% right side of the cells.
% \begin{macrocode}
{ \dim_eval:n { \g_@@_max_cell_width_dim + \arrayrulewidth } }
}
\iow_shipout:Nn \@mainaux \ExplSyntaxOff
}
}
% \end{macrocode}
%
%
%
% \subsection*{The extra nodes}
%
% First, two variants of the functions |\dim_min:nn| and |\dim_max:nn|.
% \begin{macrocode}
\cs_generate_variant:Nn \dim_min:nn { v n }
\cs_generate_variant:Nn \dim_max:nn { v n }
% \end{macrocode}
%
%
% \bigskip
% The following command is called in |\@@_use_arraybox_with_notes_c:| just
% before the construction of the blocks (if the creation of medium nodes is
% required, medium nodes are also created for the blocks and that construction
% uses the standard medium nodes).
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_extra_nodes:
{
\bool_if:nTF \l_@@_medium_nodes_bool
{
\bool_if:NTF \l_@@_large_nodes_bool
\@@_create_medium_and_large_nodes:
\@@_create_medium_nodes:
}
{ \bool_if:NT \l_@@_large_nodes_bool \@@_create_large_nodes: }
}
% \end{macrocode}
%
%
% \bigskip
% We have three macros of creation of nodes: |\@@_create_medium_nodes:|,
% |\@@_create_large_nodes:| and |\@@_create_medium_and_large_nodes:|.
%
%
% \bigskip
% We have to compute the mathematical coordinates of the ``medium nodes''. These
% mathematical coordinates are also used to compute the mathematical coordinates
% of the ``large nodes''. That's why we write a command
% |\@@_computations_for_medium_nodes:| to do these computations.
%
% \bigskip
% The command |\@@_computations_for_medium_nodes:| must be used in a
% |{pgfpicture}|.
%
% \medskip
% For each row $i$, we compute two dimensions
% \texttt{l_@@_row_\textsl{i}_min_dim} and \texttt{l_@@_row_\textsl{i}_max_dim}.
% The dimension \texttt{l_@@_row_\textsl{i}_min_dim} is the minimal
% $y$-value of all the cells of the row~$i$. The dimension
% \texttt{l_@@_row_\textsl{i}_max_dim} is the maximal $y$-value of all the cells
% of the row~$i$.
%
% Similarly, for each column $j$, we compute two dimensions
% \texttt{l_@@_column_\textsl{j}_min_dim} and
% \texttt{l_@@_column_\textsl{j}_max_dim}. The dimension
% \texttt{l_@@_column_\textsl{j}_min_dim} is the minimal $x$-value of all the
% cells of the column~$j$. The dimension \texttt{l_@@_column_\textsl{j}_max_dim}
% is the maximal $x$-value of all the cells of the column~$j$.
%
% Since these dimensions will be computed as maximum or minimum, we initialize
% them to |\c_max_dim| or |-\c_max_dim|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_computations_for_medium_nodes:
{
\int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i:
{
\dim_zero_new:c { l_@@_row_\@@_i: _min_dim }
\dim_set_eq:cN { l_@@_row_\@@_i: _min_dim } \c_max_dim
\dim_zero_new:c { l_@@_row_\@@_i: _max_dim }
\dim_set:cn { l_@@_row_\@@_i: _max_dim } { - \c_max_dim }
}
\int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j:
{
\dim_zero_new:c { l_@@_column_\@@_j: _min_dim }
\dim_set_eq:cN { l_@@_column_\@@_j: _min_dim } \c_max_dim
\dim_zero_new:c { l_@@_column_\@@_j: _max_dim }
\dim_set:cn { l_@@_column_\@@_j: _max_dim } { - \c_max_dim }
}
% \end{macrocode}
% We begin the two nested loops over the rows and the columns of the array.
% \begin{macrocode}
\int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i:
{
\int_step_variable:nnNn
\l_@@_first_col_int \g_@@_col_total_int \@@_j:
% \end{macrocode}
% If the cell ($i$-$j$) is empty or an implicit cell (that is to say a cell
% after implicit ampersands |&|) we don't update the dimensions we want to
% compute.
% \begin{macrocode}
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - \@@_i: - \@@_j: }
% \end{macrocode}
% We retrieve the coordinates of the anchor |south west| of the (normal) node of
% the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|.
% \begin{macrocode}
{
\pgfpointanchor { \@@_env: - \@@_i: - \@@_j: } { south~west }
\dim_set:cn { l_@@_row_\@@_i: _min_dim}
{ \dim_min:vn { l_@@_row _ \@@_i: _min_dim } \pgf@y }
\seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: }
{
\dim_set:cn { l_@@_column _ \@@_j: _min_dim}
{ \dim_min:vn { l_@@_column _ \@@_j: _min_dim } \pgf@x }
}
% \end{macrocode}
% We retrieve the coordinates of the anchor |north east| of the (normal) node of
% the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|.
% \begin{macrocode}
\pgfpointanchor { \@@_env: - \@@_i: - \@@_j: } { north~east }
\dim_set:cn { l_@@_row _ \@@_i: _ max_dim }
{ \dim_max:vn { l_@@_row _ \@@_i: _ max_dim } \pgf@y }
\seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: }
{
\dim_set:cn { l_@@_column _ \@@_j: _ max_dim }
{ \dim_max:vn { l_@@_column _ \@@_j: _max_dim } \pgf@x }
}
}
}
}
% \end{macrocode}
% Now, we have to deal with empty rows or empty columns since we don't have
% created nodes in such rows and columns.
% \begin{macrocode}
\int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i:
{
\dim_compare:nNnT
{ \dim_use:c { l_@@_row _ \@@_i: _ min _ dim } } = \c_max_dim
{
\@@_qpoint:n { row - \@@_i: - base }
\dim_set:cn { l_@@_row _ \@@_i: _ max _ dim } \pgf@y
\dim_set:cn { l_@@_row _ \@@_i: _ min _ dim } \pgf@y
}
}
\int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j:
{
\dim_compare:nNnT
{ \dim_use:c { l_@@_column _ \@@_j: _ min _ dim } } = \c_max_dim
{
\@@_qpoint:n { col - \@@_j: }
\dim_set:cn { l_@@_column _ \@@_j: _ max _ dim } \pgf@y
\dim_set:cn { l_@@_column _ \@@_j: _ min _ dim } \pgf@y
}
}
}
% \end{macrocode}
%
%
% \bigskip
% Here is the command |\@@_create_medium_nodes:|. When this command is used, the
% ``medium nodes'' are created.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_medium_nodes:
{
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_computations_for_medium_nodes:
% \end{macrocode}
% Now, we can create the ``medium nodes''. We use a command |\@@_create_nodes:|
% because this command will also be used for the creation of the ``large nodes''.
% \begin{macrocode}
\tl_set:Nn \l_@@_suffix_tl { -medium }
\@@_create_nodes:
\endpgfpicture
}
% \end{macrocode}
%
%
% \medskip
% The command |\@@_create_large_nodes:| must be used when we want to create only
% the ``large nodes'' and not the medium ones\footnote{If we want to create
% both, we have to use |\@@_create_medium_and_large_nodes:|}. However, the
% computation of the mathematical coordinates of the ``large nodes'' needs the
% computation of the mathematical coordinates of the ``medium nodes''. Hence, we
% use first |\@@_computations_for_medium_nodes:| and then the command
% |\@@_computations_for_large_nodes:|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_large_nodes:
{
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_computations_for_medium_nodes:
\@@_computations_for_large_nodes:
\tl_set:Nn \l_@@_suffix_tl { - large }
\@@_create_nodes:
\endpgfpicture
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_medium_and_large_nodes:
{
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_computations_for_medium_nodes:
% \end{macrocode}
% Now, we can create the ``medium nodes''. We use a command |\@@_create_nodes:|
% because this command will also be used for the creation of the ``large nodes''.
% \begin{macrocode}
\tl_set:Nn \l_@@_suffix_tl { - medium }
\@@_create_nodes:
\@@_computations_for_large_nodes:
\tl_set:Nn \l_@@_suffix_tl { - large }
\@@_create_nodes:
\endpgfpicture
}
% \end{macrocode}
%
%
% \bigskip
% For ``large nodes'', the exterior rows and columns don't interfer. That's why
% the loop over the columns will start at 1 and stop at $|\c@jCol|$ (and not
% |\g_@@_col_total_int|). Idem for the rows.
% \begin{macrocode}
\cs_new_protected:Npn \@@_computations_for_large_nodes:
{
\int_set:Nn \l_@@_first_row_int 1
\int_set:Nn \l_@@_first_col_int 1
% \end{macrocode}
% We have to change the values of all the dimensions
% \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim},
% \texttt{l_@@_column_\textsl{j}_min_dim} and
% \texttt{l_@@_column_\textsl{j}_max_dim}.
% \begin{macrocode}
\int_step_variable:nNn { \c@iRow - 1 } \@@_i:
{
\dim_set:cn { l_@@_row _ \@@_i: _ min _ dim }
{
(
\dim_use:c { l_@@_row _ \@@_i: _ min _ dim } +
\dim_use:c { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim }
)
/ 2
}
\dim_set_eq:cc { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim }
{ l_@@_row_\@@_i: _min_dim }
}
\int_step_variable:nNn { \c@jCol - 1 } \@@_j:
{
\dim_set:cn { l_@@_column _ \@@_j: _ max _ dim }
{
(
\dim_use:c { l_@@_column _ \@@_j: _ max _ dim } +
\dim_use:c
{ l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim }
)
/ 2
}
\dim_set_eq:cc { l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim }
{ l_@@_column _ \@@_j: _ max _ dim }
}
% \end{macrocode}
% Here, we have to use |\dim_sub:cn| because of the number 1 in the name.
% \begin{macrocode}
\dim_sub:cn
{ l_@@_column _ 1 _ min _ dim }
\l_@@_left_margin_dim
\dim_add:cn
{ l_@@_column _ \int_use:N \c@jCol _ max _ dim }
\l_@@_right_margin_dim
}
% \end{macrocode}
%
%
%
% \bigskip
% The command |\@@_create_nodes:| is used twice: for the construction
% of the ``medium nodes'' and for the construction of the ``large nodes''. The
% nodes are constructed with the value of all the dimensions
% \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim},
% \texttt{l_@@_column_\textsl{j}_min_dim} and
% \texttt{l_@@_column_\textsl{j}_max_dim}. Between the construction of the
% ``medium nodes'' and the ``large nodes'', the values of these dimensions are
% changed.
%
% The function also uses |\l_@@_suffix_tl| (|-medium| or |-large|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_nodes:
{
\int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i:
{
\int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j:
{
% \end{macrocode}
% We draw the rectangular node for the cell (|\@@_i|-|\@@_j|).
% \begin{macrocode}
\@@_pgf_rect_node:nnnnn
{ \@@_env: - \@@_i: - \@@_j: \l_@@_suffix_tl }
{ \dim_use:c { l_@@_column_ \@@_j: _min_dim } }
{ \dim_use:c { l_@@_row_ \@@_i: _min_dim } }
{ \dim_use:c { l_@@_column_ \@@_j: _max_dim } }
{ \dim_use:c { l_@@_row_ \@@_i: _max_dim } }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{ \l_@@_name_str - \@@_i: - \@@_j: \l_@@_suffix_tl }
{ \@@_env: - \@@_i: - \@@_j: \l_@@_suffix_tl }
}
}
}
% \end{macrocode}
% Now, we create the nodes for the cells of the |\multicolumn|. We recall that
% we have stored in |\g_@@_multicolumn_cells_seq| the list of the cells where a
% |\multicolumn{|$n$|}{...}{...}| with $n$>1 was issued and in
% |\g_@@_multicolumn_sizes_seq| the correspondant values of $n$.
% \begin{macrocode}
\seq_mapthread_function:NNN
\g_@@_multicolumn_cells_seq
\g_@@_multicolumn_sizes_seq
\@@_node_for_multicolumn:nn
}
% \end{macrocode}
%
%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_extract_coords_values: #1 - #2 \q_stop
{
\cs_set_nopar:Npn \@@_i: { #1 }
\cs_set_nopar:Npn \@@_j: { #2 }
}
% \end{macrocode}
%
% The command |\@@_node_for_multicolumn:nn| takes two arguments. The first is
% the position of the cell where the command |\multicolumn{|$n$|}{...}{...}| was
% issued in the format $i$|-|$j$ and the second is the value of~$n$ (the length
% of the ``multi-cell'').
% \begin{macrocode}
\cs_new_protected:Npn \@@_node_for_multicolumn:nn #1 #2
{
\@@_extract_coords_values: #1 \q_stop
\@@_pgf_rect_node:nnnnn
{ \@@_env: - \@@_i: - \@@_j: \l_@@_suffix_tl }
{ \dim_use:c { l_@@_column _ \@@_j: _ min _ dim } }
{ \dim_use:c { l_@@_row _ \@@_i: _ min _ dim } }
{ \dim_use:c { l_@@_column _ \int_eval:n { \@@_j: +#2-1 } _ max _ dim } }
{ \dim_use:c { l_@@_row _ \@@_i: _ max _ dim } }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{ \l_@@_name_str - \@@_i: - \@@_j: \l_@@_suffix_tl }
{ \int_use:N \g_@@_env_int - \@@_i: - \@@_j: \l_@@_suffix_tl}
}
}
% \end{macrocode}
%
% \bigskip
% \subsection*{The blocks}
%
% The code deals with the command |\Block|. This command has no direct link with
% the environment |{NiceMatrixBlock}|.
%
% \bigskip
% The options of the command |\Block| will be analyzed first in the cell of the
% array (and once again when the block will be put in the array).
% Here is the set of keys for the first pass.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Block / FirstPass }
{
l .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
l .value_forbidden:n = true ,
r .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
r .value_forbidden:n = true ,
c .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
c .value_forbidden:n = true ,
L .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
L .value_forbidden:n = true ,
R .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
R .value_forbidden:n = true ,
C .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
C .value_forbidden:n = true ,
t .code:n = \str_set:Nn \l_@@_vpos_of_block_tl t ,
t .value_forbidden:n = true ,
b .code:n = \str_set:Nn \l_@@_vpos_of_block_tl b ,
b .value_forbidden:n = true ,
color .tl_set:N = \l_@@_color_tl ,
color .value_required:n = true ,
respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
respect-arraystretch .default:n = true ,
}
% \end{macrocode}
%
%
% The following command |\@@_Block:| will be linked to |\Block| in the
% environments of \pkg{nicematrix}. We define it with
% |\NewExpandableDocumentCommand| because it has an optional argument between
% |<| and |>|. It's mandatory to use an expandable command.
%
% \begin{macrocode}
\NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } +m }
{
% \end{macrocode}
% If the first mandatory argument of the command (which is the size of the block
% with the syntax $i$|-|$j$) has not be provided by the user, you use |1-1|
% (that is to say a block of only one cell).
% \begin{macrocode}
\peek_remove_spaces:n
{
\tl_if_blank:nTF { #2 }
{ \@@_Block_i 1-1 \q_stop }
{ \@@_Block_i #2 \q_stop }
{ #1 } { #3 } { #4 }
}
}
% \end{macrocode}
%
% \medskip
% With the following construction, we extract the values of $i$ and $j$ in the
% first mandatory argument of the command.
% \begin{macrocode}
\cs_new:Npn \@@_Block_i #1-#2 \q_stop { \@@_Block_ii:nnnnn { #1 } { #2 } }
% \end{macrocode}
%
% \medskip
% Now, the arguments have been extracted: |#1| is $i$ (the number of rows of the
% block), |#2| is $j$ (the number of columns of the block), |#3| is the list of
% \textsl{key=values} pairs, |#4| are the tokens to put before the math mode and
% the beginning of the small array of the block and |#5| is the label of the
% block.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_ii:nnnnn #1 #2 #3 #4 #5
{
% \end{macrocode}
%
% \medskip
% We recall that |#1| and |#2| have been extracted from the first mandatory
% argument of |\Block| (which is of the syntax $i$|-|$j$). However, the user is
% allowed to omit $i$ or $j$ (or both). We detect that situation by replacing a
% missing value by 100 (it's a convention: when the block will actually be drawn
% these values will be detected and interpreted as \emph{maximal possible
% value} according to the actual size of the array).
% \begin{macrocode}
\bool_lazy_or:nnTF
{ \tl_if_blank_p:n { #1 } }
{ \str_if_eq_p:nn { #1 } { * } }
{ \int_set:Nn \l_tmpa_int { 100 } }
{ \int_set:Nn \l_tmpa_int { #1 } }
\bool_lazy_or:nnTF
{ \tl_if_blank_p:n { #2 } }
{ \str_if_eq_p:nn { #2 } { * } }
{ \int_set:Nn \l_tmpb_int { 100 } }
{ \int_set:Nn \l_tmpb_int { #2 } }
% \end{macrocode}
%
% \medskip
% If the block is mono-column.
% \begin{macrocode}
\int_compare:nNnTF \l_tmpb_int = 1
{
\str_if_empty:NTF \l_@@_hpos_cell_str
{ \str_set:Nn \l_@@_hpos_block_str c }
{ \str_set_eq:NN \l_@@_hpos_block_str \l_@@_hpos_cell_str }
}
{ \str_set:Nn \l_@@_hpos_block_str c }
% \end{macrocode}
% The value of |\l_@@_hpos_block_str| may be modified by the keys of the
% command |\Block| that we will analyze now.
%
% \medskip
% \begin{macrocode}
\keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 }
% \end{macrocode}
%
% \begin{macrocode}
\tl_set:Nx \l_tmpa_tl
{
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ \int_eval:n { \c@iRow + \l_tmpa_int - 1 } }
{ \int_eval:n { \c@jCol + \l_tmpb_int - 1 } }
}
% \end{macrocode}
% Now, |\l_tmpa_tl| contains an ``object'' corresponding to the position of the
% block with four components, each of them surrounded by curly brackets:
%
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|.
%
%
% \medskip
% If the block is mono-column or mono-row, we have a special treatment. That's
% why we have two macros: |\@@_Block_iv:nnnnn| and |\@@_Block_v:nnnnn| (the five
% arguments of those macros are provided by curryfication).
% \begin{macrocode}
\bool_if:nTF
{
(
\int_compare_p:nNn { \l_tmpa_int } = 1
||
\int_compare_p:nNn { \l_tmpb_int } = 1
)
&& ! \tl_if_empty_p:n { #5 }
% \end{macrocode}
% For the blocks mono-column, we will compose right now in a box in order to
% compute its width and take that width into account for the width of the
% column. However, if the column is a |X| column, we should not do that since
% the width is determined by another way. This should be the same for the |p|,
% |m| and |b| columns and we should modify that point. However, for the |X|
% column, it's imperative. Otherwise, the process for the determination of the
% widths of the columns will be wrong.
% \begin{macrocode}
&& ! \l_@@_X_column_bool
}
{ \exp_args:Nxx \@@_Block_iv:nnnnn }
{ \exp_args:Nxx \@@_Block_v:nnnnn }
{ \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 }
}
% \end{macrocode}
%
%
% \bigskip
% The following macro is for the case of a |\Block| which is mono-row or
% mono-column (or both). In that case, the content of the block is composed
% right now in a box (because we have to take into account the dimensions of
% that box for the width of the current column or the height and the depth of the
% current row). However, that box will be put in the array \emph{after the
% construction of the array} (by using \textsc{pgf}).
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_iv:nnnnn #1 #2 #3 #4 #5
{
\int_gincr:N \g_@@_block_box_int
\cs_set_protected_nopar:Npn \diagbox ##1 ##2
{
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{
\@@_actually_diagbox:nnnnnn
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ \int_eval:n { \c@iRow + #1 - 1 } }
{ \int_eval:n { \c@jCol + #2 - 1 } }
{ \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
}
}
\box_gclear_new:c
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
\hbox_gset:cn
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
{
% \end{macrocode}
% For a mono-column block, if the user has specified a color for the column in
% the preamble of the array, we want to fix that color in the box we construct.
% We do that with |\set@color| and not |\color_ensure_current:| (in order to use
% |\color_ensure_current:| safely, you should load \pkg{l3backend} before the
% |\documentclass| with |\RequirePackage{expl3}|).
% \begin{macrocode}
\tl_if_empty:NTF \l_@@_color_tl
{ \int_compare:nNnT { #2 } = 1 \set@color }
{ \color { \l_@@_color_tl } }
% \end{macrocode}
% If the block is mono-row, we use |\g_@@_row_style_tl| even if it has yet been
% used in the beginning of the cell where the command |\Block| has been issued
% because we want to be able to take into account a potential instruction of
% color of the font in |\g_@@_row_style_tl|.
% \begin{macrocode}
\int_compare:nNnT { #1 } = 1 \g_@@_row_style_tl
\group_begin:
\bool_if:NF \l_@@_respect_arraystretch_bool
{ \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
#4
% \end{macrocode}
% If the box is rotated (the key |\rotate| may be in the previous |#4|), the
% tabular used for the content of the cell will be constructed with a format
% |c|. In the other cases, the tabular will be constructed with a format equal
% to the key of position of the box. In other words: the alignment internal to
% the tabular is the same as the external alignment of the tabular (that is to
% say the position of the block in its zone of merged cells).
% \begin{macrocode}
\bool_if:NT \g_@@_rotate_bool { \str_set:Nn \l_@@_hpos_block_str c }
\bool_if:NTF \l_@@_NiceTabular_bool
{
\bool_lazy_all:nTF
{
{ \int_compare_p:nNn { #2 } = 1 }
{ \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } }
{ ! \l_@@_respect_arraystretch_bool }
}
% \end{macrocode}
% When the block is mono-column in a column with a fixed width (eg |p{3cm}|).
% \begin{macrocode}
{
\begin { minipage } [ \l_@@_vpos_of_block_tl ]
{ \l_@@_col_width_dim }
\str_case:Vn \l_@@_hpos_block_str
{
c \centering
r \raggedleft
l \raggedright
}
#5
\end { minipage }
}
{
\use:x
{
\exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_tl ]
{ @ { } \l_@@_hpos_block_str @ { } }
}
#5
\end { tabular }
}
}
{
\c_math_toggle_token
\use:x
{
\exp_not:N \begin { array } [ \l_@@_vpos_of_block_tl ]
{ @ { } \l_@@_hpos_block_str @ { } }
}
#5
\end { array }
\c_math_toggle_token
}
\group_end:
}
\bool_if:NT \g_@@_rotate_bool
{
\box_grotate:cn
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
{ 90 }
\bool_gset_false:N \g_@@_rotate_bool
}
% \end{macrocode}
% If we are in a mono-column block, we take into account the width of that block
% for the width of the column.
% \begin{macrocode}
\int_compare:nNnT { #2 } = 1
{
\dim_gset:Nn \g_@@_blocks_wd_dim
{
\dim_max:nn
\g_@@_blocks_wd_dim
{
\box_wd:c
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
}
}
}
% \end{macrocode}
% If we are in a mono-row block, we take into account the height and the
% depth of that block for the height and the depth of the row.
% \begin{macrocode}
\int_compare:nNnT { #1 } = 1
{
\dim_gset:Nn \g_@@_blocks_ht_dim
{
\dim_max:nn
\g_@@_blocks_ht_dim
{
\box_ht:c
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
}
}
\dim_gset:Nn \g_@@_blocks_dp_dim
{
\dim_max:nn
\g_@@_blocks_dp_dim
{
\box_dp:c
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
}
}
}
\seq_gput_right:Nx \g_@@_blocks_seq
{
\l_tmpa_tl
% \end{macrocode}
% In the list of options |#3|, maybe there is a key for the horizontal alignment
% (|l|, |r| or |c|). In that case, that key has been read and stored in
% |\l_@@_hpos_block_str|. However, maybe there were no key of the horizontal
% alignment and that's why we put a key corresponding to the value of
% |\l_@@_hpos_block_str|, which is fixed by the type of current column.
% \begin{macrocode}
{ \exp_not:n { #3 } , \l_@@_hpos_block_str }
{
\box_use_drop:c
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
}
}
}
% \end{macrocode}
%
% \bigskip
% The following macro is for the standard case, where the block is not mono-row
% and not mono-column. In that case, the content of the block is \emph{not}
% composed right now in a box. The composition in a box will be done further,
% just after the construction of the array.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_v:nnnnn #1 #2 #3 #4 #5
{
\seq_gput_right:Nx \g_@@_blocks_seq
{
\l_tmpa_tl
{ \exp_not:n { #3 } }
\exp_not:n
{
{
\bool_if:NTF \l_@@_NiceTabular_bool
{
\group_begin:
\bool_if:NF \l_@@_respect_arraystretch_bool
{ \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
#4
% \end{macrocode}
% If the box is rotated (the key |\rotate| may be in the previous |#4|), the
% tabular used for the content of the cell will be constructed with a format
% |c|. In the other cases, the tabular will be constructed with a format equal
% to the key of position of the box. In other words: the alignment internal to
% the tabular is the same as the external alignment of the tabular (that is to
% say the position of the block in its zone of merged cells).
% \begin{macrocode}
\bool_if:NT \g_@@_rotate_bool
{ \str_set:Nn \l_@@_hpos_block_str c }
\use:x
{
\exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_tl ]
{ @ { } \l_@@_hpos_block_str @ { } }
}
#5
\end { tabular }
\group_end:
}
{
\group_begin:
\bool_if:NF \l_@@_respect_arraystretch_bool
{ \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
#4
\bool_if:NT \g_@@_rotate_bool
{ \str_set:Nn \l_@@_hpos_block_str c }
\c_math_toggle_token
\use:x
{
\exp_not:N \begin { array } [ \l_@@_vpos_of_block_tl ]
{ @ { } \l_@@_hpos_block_str @ { } }
}
#5
\end { array }
\c_math_toggle_token
\group_end:
}
}
}
}
}
% \end{macrocode}
%
% \bigskip
% We recall that the options of the command |\Block| are analyzed twice: first
% in the cell of the array and once again when the block will be put in the
% array \emph{after the construction of the array} (by using \textsc{pgf}).
%
% \medskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Block / SecondPass }
{
tikz .code:n =
\bool_if:NTF \c_@@_tikz_loaded_bool
{ \seq_put_right:Nn \l_@@_tikz_seq { { #1 } } }
{ \@@_error:n { tikz~key~without~tikz } } ,
tikz .value_required:n = true ,
fill .tl_set:N = \l_@@_fill_tl ,
fill .value_required:n = true ,
draw .tl_set:N = \l_@@_draw_tl ,
draw .default:n = default ,
rounded-corners .dim_set:N = \l_@@_rounded_corners_dim ,
rounded-corners .default:n = 4 pt ,
color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } ,
color .value_required:n = true ,
borders .clist_set:N = \l_@@_borders_clist ,
borders .value_required:n = true ,
hvlines .meta:n = { vlines , hlines } ,
vlines .bool_set:N = \l_@@_vlines_block_bool,
vlines .default:n = true ,
hlines .bool_set:N = \l_@@_hlines_block_bool,
hlines .default:n = true ,
line-width .dim_set:N = \l_@@_line_width_dim ,
line-width .value_required:n = true ,
l .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
l .value_forbidden:n = true ,
r .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
r .value_forbidden:n = true ,
c .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
c .value_forbidden:n = true ,
L .code:n = \str_set:Nn \l_@@_hpos_block_str l
\bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
L .value_forbidden:n = true ,
R .code:n = \str_set:Nn \l_@@_hpos_block_str r
\bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
R .value_forbidden:n = true ,
C .code:n = \str_set:Nn \l_@@_hpos_block_str c
\bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
C .value_forbidden:n = true ,
t .code:n = \str_set:Nn \l_@@_vpos_of_block_tl t ,
t .value_forbidden:n = true ,
b .code:n = \str_set:Nn \l_@@_vpos_of_block_tl b ,
b .value_forbidden:n = true ,
name .tl_set:N = \l_@@_block_name_str ,
name .value_required:n = true ,
name .initial:n = ,
respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
respect-arraystretch .default:n = true ,
v-center .bool_set:N = \l_@@_v_center_bool ,
v-center .default:n = true ,
v-center .initial:n = false ,
unknown .code:n = \@@_error:n { Unknown~key~for~Block }
}
% \end{macrocode}
%
% \bigskip
% The command |\@@_draw_blocks:| will draw all the blocks. This command is used
% after the construction of the array. We have to revert to a clean version of
% |\ialign| because there may be tabulars in the |\Block| instructions that will
% be composed now.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_blocks:
{
\cs_set_eq:NN \ialign \@@_old_ialign:
\seq_map_inline:Nn \g_@@_blocks_seq { \@@_Block_iv:nnnnnn ##1 }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_iv:nnnnnn #1 #2 #3 #4 #5 #6
{
% \end{macrocode}
% The integer |\l_@@_last_row_int| will be the last row of the block and
% |\l_@@_last_col_int| its last column.
% \begin{macrocode}
\int_zero_new:N \l_@@_last_row_int
\int_zero_new:N \l_@@_last_col_int
% \end{macrocode}
%
% We remind that the first mandatory argument of the command |\Block| is the
% size of the block with the special format $i$|-|$j$. However, the user is
% allowed to omit $i$ or $j$ (or both). This will be interpreted as: the last
% row (resp. column) of the block will be the last row (resp. column) of the
% block (without the potential exterior row---resp. column---of the array). By
% convention, this is stored in |\g_@@_blocks_seq| as a number of rows (resp.
% columns) for the block equal to 100. That's what we detect now.
% \begin{macrocode}
\int_compare:nNnTF { #3 } > { 99 }
{ \int_set_eq:NN \l_@@_last_row_int \c@iRow }
{ \int_set:Nn \l_@@_last_row_int { #3 } }
\int_compare:nNnTF { #4 } > { 99 }
{ \int_set_eq:NN \l_@@_last_col_int \c@jCol }
{ \int_set:Nn \l_@@_last_col_int { #4 } }
\int_compare:nNnTF \l_@@_last_col_int > \g_@@_col_total_int
{
\int_compare:nTF
{ \l_@@_last_col_int <= \g_@@_static_num_of_col_int }
{
\msg_error:nnnn { nicematrix } { Block~too~large~2 } { #1 } { #2 }
\@@_msg_redirect_name:nn { Block~too~large~2 } { none }
\group_begin:
\globaldefs = 1
\@@_msg_redirect_name:nn { columns~not~used } { none }
\group_end:
}
{ \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } }
}
{
\int_compare:nNnTF \l_@@_last_row_int > \g_@@_row_total_int
{ \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } }
{ \@@_Block_v:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } }
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_v:nnnnnn #1 #2 #3 #4 #5 #6
{
% \end{macrocode}
% The group is for the keys.
% \begin{macrocode}
\group_begin:
\keys_set:nn { NiceMatrix / Block / SecondPass } { #5 }
% \end{macrocode}
%
%
% We restrict the use of the key |v-center| to the case of a mono-row block.
% \begin{macrocode}
\bool_if:NT \l_@@_v_center_bool
{
\int_compare:nNnF { #1 } = { #3 }
{
\@@_error:n { Wrong~use~of~v-center }
\bool_set_false:N \l_@@_v_center_bool
}
}
% \end{macrocode}
%
% \begin{macrocode}
\bool_if:NT \l_@@_vlines_block_bool
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
{
\@@_vlines_block:nnn
{ \exp_not:n { #5 } }
{ #1 - #2 }
{ \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
}
}
\bool_if:NT \l_@@_hlines_block_bool
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
{
\@@_hlines_block:nnn
{ \exp_not:n { #5 } }
{ #1 - #2 }
{ \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
}
}
\bool_if:nT
{ ! \l_@@_vlines_block_bool && ! \l_@@_hlines_block_bool }
{
% \end{macrocode}
% The sequence of the positions of the blocks (excepted the blocks with the key
% |hvlines|) will be used when drawing the rules (in fact, there is also the
% |\multicolumn| and the |\diagbox| in that sequence).
% \begin{macrocode}
\seq_gput_left:Nx \g_@@_pos_of_blocks_seq
{ { #1 } { #2 } { #3 } { #4 } { \l_@@_block_name_str } }
}
% \end{macrocode}
%
% \begin{macrocode}
\tl_if_empty:NF \l_@@_draw_tl
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
{
\@@_stroke_block:nnn
{ \exp_not:n { #5 } }
{ #1 - #2 }
{ \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
}
\seq_gput_right:Nn \g_@@_pos_of_stroken_blocks_seq
{ { #1 } { #2 } { #3 } { #4 } }
}
% \end{macrocode}
%
% \begin{macrocode}
\clist_if_empty:NF \l_@@_borders_clist
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
{
\@@_stroke_borders_block:nnn
{ \exp_not:n { #5 } }
{ #1 - #2 }
{ \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
}
}
% \end{macrocode}
%
% \begin{macrocode}
\tl_if_empty:NF \l_@@_fill_tl
{
% \end{macrocode}
% The command |\@@_extract_brackets| will extract the potential specification of
% color space at the beginning of |\l_@@_fill_tl| and store it in |\l_tmpa_tl|
% and store the color itself in |\l_tmpb_tl|.
% \begin{macrocode}
\exp_last_unbraced:NV \@@_extract_brackets \l_@@_fill_tl \q_stop
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
\exp_not:N \roundedrectanglecolor
[ \l_tmpa_tl ]
{ \exp_not:V \l_tmpb_tl }
{ #1 - #2 }
{ \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
{ \dim_use:N \l_@@_rounded_corners_dim }
}
}
% \end{macrocode}
%
% \begin{macrocode}
\seq_if_empty:NF \l_@@_tikz_seq
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
\@@_block_tikz:nnnnn
{ #1 }
{ #2 }
{ \int_use:N \l_@@_last_row_int }
{ \int_use:N \l_@@_last_col_int }
{ \seq_use:Nn \l_@@_tikz_seq { , } }
}
}
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\cs_set_protected_nopar:Npn \diagbox ##1 ##2
{
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{
\@@_actually_diagbox:nnnnnn
{ #1 }
{ #2 }
{ \int_use:N \l_@@_last_row_int }
{ \int_use:N \l_@@_last_col_int }
{ \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
}
}
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\hbox_set:Nn \l_@@_cell_box { \set@color #6 }
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
% \end{macrocode}
%
% \bigskip
% Let's consider the following |{NiceTabular}|. Because of the instruction
% |!{\hspace{1cm}}| in the preamble which increases the space between the
% columns (by adding, in fact, that space to the previous column, that is to say
% the second column of the tabular), we will create \emph{two} nodes relative to
% the block: the node |1-1-block| and the node |1-1-block-short|.
%
% \begin{Verbatim}
% \begin{NiceTabular}{cc!{\hspace{1cm}}c}
% \Block{2-2}{our block} & & one \\
% & & two \\
% three & four & five \\
% six & seven & eight \\
% \end{NiceTabular}
% \end{Verbatim}
%
% \tikzset{highlight/.style={rectangle,
% fill=red!15,
% blend mode = multiply,
% rounded corners = 0pt,
% inner sep=0pt,
% fit = #1}}
%
% \begin{tabular}{c!{\hspace{1cm}}c}
% We highlight the node |1-1-block|
% & We highlight the node |1-1-block-short| \\[2mm]
% \begin{NiceTabular}{cc!{\hspace{1cm}}c}
% \Block{2-2}{our block} & & one \\
% & & two \\
% three & four & five \\
% six & seven & eight \\
% \CodeAfter
% \tikz \node [highlight = (1-1-block)] { } ;
% \end{NiceTabular}
% &
% \begin{NiceTabular}{cc!{\hspace{1cm}}c}
% \Block{2-2}{our block} & & one \\
% & & two \\
% three & four & five \\
% six & seven & eight \\
% \CodeAfter
% \tikz \node [highlight = (1-1-block-short)] { } ;
% \end{NiceTabular}
% \end{tabular}
%
%
% \bigskip
% The construction of the node corresponding to the merged cells.
% \begin{macrocode}
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_qpoint:n { row - #1 }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\@@_qpoint:n { col - #2 }
\dim_set_eq:NN \l_tmpb_dim \pgf@x
\@@_qpoint:n { row - \int_eval:n { \l_@@_last_row_int + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y
\@@_qpoint:n { col - \int_eval:n { \l_@@_last_col_int + 1 } }
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@x
% \end{macrocode}
%
% We construct the node for the block with the name |(#1-#2-block)|.
%
% The function |\@@_pgf_rect_node:nnnnn| takes in as arguments the name of the node
% and the four coordinates of two opposite corner points of the rectangle.
% \begin{macrocode}
\@@_pgf_rect_node:nnnnn
{ \@@_env: - #1 - #2 - block }
\l_tmpb_dim \l_tmpa_dim \l_@@_tmpd_dim \l_@@_tmpc_dim
\str_if_empty:NF \l_@@_block_name_str
{
\pgfnodealias
{ \@@_env: - \l_@@_block_name_str }
{ \@@_env: - #1 - #2 - block }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
{ \l_@@_name_str - \l_@@_block_name_str }
{ \@@_env: - #1 - #2 - block }
}
}
% \end{macrocode}
%
% \medskip
% Now, we create the ``short node'' which, in general, will be used to put the
% label (that is to say the content of the node). However, if one the keys |L|, |C| or
% |R| is used (that information is provided by the boolean
% |\l_@@_hpos_of_block_cap_bool|), we don't need to create that node since the
% normal node is used to put the label.
%
% \begin{macrocode}
\bool_if:NF \l_@@_hpos_of_block_cap_bool
{
\dim_set_eq:NN \l_tmpb_dim \c_max_dim
% \end{macrocode}
% The short node is constructed by taking into account the \emph{contents} of
% the columns involved in at least one cell of the block. That's why we have to
% do a loop over the rows of the array.
% \begin{macrocode}
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
{
% \end{macrocode}
% We recall that, when a cell is empty, no (normal) node is created in that
% cell. That's why we test the existence of the node before using it.
% \begin{macrocode}
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - ##1 - #2 }
{
\seq_if_in:NnF \g_@@_multicolumn_cells_seq { ##1 - #2 }
{
\pgfpointanchor { \@@_env: - ##1 - #2 } { west }
\dim_set:Nn \l_tmpb_dim { \dim_min:nn \l_tmpb_dim \pgf@x }
}
}
}
% \end{macrocode}
% If all the cells of the column were empty, |\l_tmpb_dim| has still the same
% value |\c_max_dim|. In that case, you use for |\l_tmpb_dim| the value of the
% position of the vertical rule.
% \begin{macrocode}
\dim_compare:nNnT \l_tmpb_dim = \c_max_dim
{
\@@_qpoint:n { col - #2 }
\dim_set_eq:NN \l_tmpb_dim \pgf@x
}
\dim_set:Nn \l_@@_tmpd_dim { - \c_max_dim }
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_last_col_int }
{
\seq_if_in:NnF \g_@@_multicolumn_cells_seq { ##1 - #2 }
{
\pgfpointanchor
{ \@@_env: - ##1 - \int_use:N \l_@@_last_col_int }
{ east }
\dim_set:Nn \l_@@_tmpd_dim { \dim_max:nn \l_@@_tmpd_dim \pgf@x }
}
}
}
\dim_compare:nNnT \l_@@_tmpd_dim = { - \c_max_dim }
{
\@@_qpoint:n { col - \int_eval:n { \l_@@_last_col_int + 1 } }
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@x
}
\@@_pgf_rect_node:nnnnn
{ \@@_env: - #1 - #2 - block - short }
\l_tmpb_dim \l_tmpa_dim \l_@@_tmpd_dim \l_@@_tmpc_dim
}
% \end{macrocode}
%
% \medskip
% If the creation of the ``medium nodes'' is required, we create a ``medium
% node'' for the block. The function |\@@_pgf_rect_node:nnn| takes in as
% arguments the name of the node and two \textsc{pgf} points.
% \begin{macrocode}
\bool_if:NT \l_@@_medium_nodes_bool
{
\@@_pgf_rect_node:nnn
{ \@@_env: - #1 - #2 - block - medium }
{ \pgfpointanchor { \@@_env: - #1 - #2 - medium } { north~west } }
{
\pgfpointanchor
{ \@@_env:
- \int_use:N \l_@@_last_row_int
- \int_use:N \l_@@_last_col_int - medium
}
{ south~east }
}
}
% \end{macrocode}
% \medskip
% Now, we will put the label of the block beginning with the case of a |\Block|
% of one row.
% \begin{macrocode}
\bool_if:nTF
{ \int_compare_p:nNn { #1 } = { #3 } && ! \l_@@_v_center_bool }
{
% \end{macrocode}
% We take into account the case of a block of one row in the ``first row'' or
% the ``last row''.
% \begin{macrocode}
\int_compare:nNnTF { #1 } = 0
{ \l_@@_code_for_first_row_tl }
{
\int_compare:nNnT { #1 } = \l_@@_last_row_int
\l_@@_code_for_last_row_tl
}
% \end{macrocode}
% If the block has only one row, we want the label of the block perfectly
% aligned on the baseline of the row. That's why we have constructed a
% |\pgfcoordinate| on the baseline of the row, in the first column of the array.
% Now, we retrieve the $y$-value of that node and we store it in |\l_tmpa_dim|.
% \begin{macrocode}
\pgfextracty \l_tmpa_dim { \@@_qpoint:n { row - #1 - base } }
% \end{macrocode}
% We retrieve (in |\pgf@x|) the $x$-value of the center of the block.
% \begin{macrocode}
\pgfpointanchor
{
\@@_env: - #1 - #2 - block
\bool_if:NF \l_@@_hpos_of_block_cap_bool { - short }
}
{
\str_case:Vn \l_@@_hpos_block_str
{
c { center }
l { west }
r { east }
}
}
% \end{macrocode}
% We put the label of the block which has been composed in |\l_@@_cell_box|.
% \begin{macrocode}
\pgftransformshift { \pgfpoint \pgf@x \l_tmpa_dim }
\pgfset { inner~sep = \c_zero_dim }
\pgfnode
{ rectangle }
{
\str_case:Vn \l_@@_hpos_block_str
{
c { base }
l { base~west }
r { base~east }
}
}
{ \box_use_drop:N \l_@@_cell_box } { } { }
}
% \end{macrocode}
%
% \medskip
% If the number of rows is different of $1$, we will put the label of the block
% by using the short node (the label of the block has been composed in
% |\l_@@_cell_box|).
% \begin{macrocode}
{
% \end{macrocode}
% If we are in the first column, we must put the block as if it was with the key~|r|.
% \begin{macrocode}
\int_compare:nNnT { #2 } = 0
{ \str_set:Nn \l_@@_hpos_block_str r }
\bool_if:nT \g_@@_last_col_found_bool
{
\int_compare:nNnT { #2 } = \g_@@_col_total_int
{ \str_set:Nn \l_@@_hpos_block_str l }
}
\pgftransformshift
{
\pgfpointanchor
{
\@@_env: - #1 - #2 - block
\bool_if:NF \l_@@_hpos_of_block_cap_bool { - short }
}
{
\str_case:Vn \l_@@_hpos_block_str
{
c { center }
l { west }
r { east }
}
}
}
\pgfset { inner~sep = \c_zero_dim }
\pgfnode
{ rectangle }
{
\str_case:Vn \l_@@_hpos_block_str
{
c { center }
l { west }
r { east }
}
}
{ \box_use_drop:N \l_@@_cell_box } { } { }
}
\endpgfpicture
\group_end:
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\NewDocumentCommand \@@_extract_brackets { O { } }
{
\tl_set:Nn \l_tmpa_tl { #1 }
\@@_store_in_tmpb_tl
}
\cs_new_protected:Npn \@@_store_in_tmpb_tl #1 \q_stop
{ \tl_set:Nn \l_tmpb_tl { #1 } }
% \end{macrocode}
%
% % \bigskip
% The first argument of |\@@_stroke_block:nnn| is a list of options for the
% rectangle that you will stroke. The second argument is the upper-left cell of
% the block (with, as usual, the syntax $i$|-|$j$) and the third is the last
% cell of the block (with the same syntax).
% \begin{macrocode}
\cs_new_protected:Npn \@@_stroke_block:nnn #1 #2 #3
{
\group_begin:
\tl_clear:N \l_@@_draw_tl
\dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth
\keys_set_known:nn { NiceMatrix / BlockStroke } { #1 }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\tl_if_empty:NF \l_@@_draw_tl
{
% \end{macrocode}
% If the user has used the key |color| of the command |\Block| without value,
% the color fixed by |\arrayrulecolor| is used.
% \begin{macrocode}
\str_if_eq:VnTF \l_@@_draw_tl { default }
{ \CT@arc@ }
{ \exp_args:NV \pgfsetstrokecolor \l_@@_draw_tl }
}
\pgfsetcornersarced
{
\pgfpoint
{ \dim_use:N \l_@@_rounded_corners_dim }
{ \dim_use:N \l_@@_rounded_corners_dim }
}
\@@_cut_on_hyphen:w #2 \q_stop
\bool_lazy_and:nnT
{ \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
{ \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
{
\@@_qpoint:n { row - \l_tmpa_tl }
\dim_set:Nn \l_tmpb_dim { \pgf@y }
\@@_qpoint:n { col - \l_tmpb_tl }
\dim_set:Nn \l_@@_tmpc_dim { \pgf@x }
\@@_cut_on_hyphen:w #3 \q_stop
\int_compare:nNnT \l_tmpa_tl > \c@iRow
{ \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } }
\int_compare:nNnT \l_tmpb_tl > \c@jCol
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
\@@_qpoint:n { row - \int_eval:n { \l_tmpa_tl + 1 } }
\dim_set:Nn \l_tmpa_dim { \pgf@y }
\@@_qpoint:n { col - \int_eval:n { \l_tmpb_tl + 1 } }
\dim_set:Nn \l_@@_tmpd_dim { \pgf@x }
\pgfpathrectanglecorners
{ \pgfpoint \l_@@_tmpc_dim \l_tmpb_dim }
{ \pgfpoint \l_@@_tmpd_dim \l_tmpa_dim }
\pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
% \end{macrocode}
% We can't use |\pgfusepathqstroke| because of the key |rounded-corners|.
% \begin{macrocode}
\pgfusepath { stroke }
}
\endpgfpicture
\group_end:
}
% \end{macrocode}
%
% Here is the set of keys for the command |\@@_stroke_block:nnn|.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / BlockStroke }
{
color .tl_set:N = \l_@@_draw_tl ,
draw .tl_set:N = \l_@@_draw_tl ,
draw .default:n = default ,
line-width .dim_set:N = \l_@@_line_width_dim ,
rounded-corners .dim_set:N = \l_@@_rounded_corners_dim ,
rounded-corners .default:n = 4 pt
}
% \end{macrocode}
%
%
% \bigskip
% The first argument of |\@@_vlines_block:nnn| is a list of options for the
% rules that we will draw. The second argument is the upper-left cell of the
% block (with, as usual, the syntax $i$|-|$j$) and the third is the last cell of
% the block (with the same syntax).
% \begin{macrocode}
\cs_new_protected:Npn \@@_vlines_block:nnn #1 #2 #3
{
\dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth
\keys_set_known:nn { NiceMatrix / BlockBorders } { #1 }
\@@_cut_on_hyphen:w #2 \q_stop
\tl_set_eq:NN \l_@@_tmpc_tl \l_tmpa_tl
\tl_set_eq:NN \l_@@_tmpd_tl \l_tmpb_tl
\@@_cut_on_hyphen:w #3 \q_stop
\tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } }
\tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
\int_step_inline:nnn \l_@@_tmpd_tl \l_tmpb_tl
{
\use:x
{
\@@_vline:n
{
position = ##1 ,
start = \l_@@_tmpc_tl ,
end = \int_eval:n { \l_tmpa_tl - 1 }
}
}
}
}
\cs_new_protected:Npn \@@_hlines_block:nnn #1 #2 #3
{
\dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth
\keys_set_known:nn { NiceMatrix / BlockBorders } { #1 }
\@@_cut_on_hyphen:w #2 \q_stop
\tl_set_eq:NN \l_@@_tmpc_tl \l_tmpa_tl
\tl_set_eq:NN \l_@@_tmpd_tl \l_tmpb_tl
\@@_cut_on_hyphen:w #3 \q_stop
\tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } }
\tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
\int_step_inline:nnn \l_@@_tmpc_tl \l_tmpa_tl
{
\use:x
{
\@@_hline:n
{
position = ##1 ,
start = \l_@@_tmpd_tl ,
end = \int_eval:n { \l_tmpb_tl - 1 }
}
}
}
}
% \end{macrocode}
%
% \bigskip
% The first argument of |\@@_stroke_borders_block:nnn| is a list of options for
% the borders that you will stroke. The second argument is the upper-left cell
% of the block (with, as usual, the syntax $i$|-|$j$) and the third is the last
% cell of the block (with the same syntax).
% \begin{macrocode}
\cs_new_protected:Npn \@@_stroke_borders_block:nnn #1 #2 #3
{
\dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth
\keys_set_known:nn { NiceMatrix / BlockBorders } { #1 }
\dim_compare:nNnTF \l_@@_rounded_corners_dim > \c_zero_dim
{ \@@_error:n { borders~forbidden } }
{
\tl_clear_new:N \l_@@_borders_tikz_tl
\keys_set:nV
{ NiceMatrix / OnlyForTikzInBorders }
\l_@@_borders_clist
\@@_cut_on_hyphen:w #2 \q_stop
\tl_set_eq:NN \l_@@_tmpc_tl \l_tmpa_tl
\tl_set_eq:NN \l_@@_tmpd_tl \l_tmpb_tl
\@@_cut_on_hyphen:w #3 \q_stop
\tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } }
\tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
\@@_stroke_borders_block_i:
}
}
% \end{macrocode}
%
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\cs_new_protected:Npx \@@_stroke_borders_block_i:
{
\c_@@_pgfortikzpicture_tl
\@@_stroke_borders_block_ii:
\c_@@_endpgfortikzpicture_tl
}
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_stroke_borders_block_ii:
{
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\CT@arc@
\pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
\clist_if_in:NnT \l_@@_borders_clist { right }
{ \@@_stroke_vertical:n \l_tmpb_tl }
\clist_if_in:NnT \l_@@_borders_clist { left }
{ \@@_stroke_vertical:n \l_@@_tmpd_tl }
\clist_if_in:NnT \l_@@_borders_clist { bottom }
{ \@@_stroke_horizontal:n \l_tmpa_tl }
\clist_if_in:NnT \l_@@_borders_clist { top }
{ \@@_stroke_horizontal:n \l_@@_tmpc_tl }
}
% \end{macrocode}
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / OnlyForTikzInBorders }
{
tikz .code:n =
\cs_if_exist:NTF \tikzpicture
{ \tl_set:Nn \l_@@_borders_tikz_tl { #1 } }
{ \@@_error:n { tikz~in~borders~without~tikz } } ,
tikz .value_required:n = true ,
top .code:n = ,
bottom .code:n = ,
left .code:n = ,
right .code:n = ,
unknown .code:n = \@@_error:n { bad~border }
}
% \end{macrocode}
%
%
% \medskip
% The following command is used to stroke the left border and the right border.
% The argument |#1| is the number of column (in the sense of the |col| node).
% \begin{macrocode}
\cs_new_protected:Npn \@@_stroke_vertical:n #1
{
\@@_qpoint:n \l_@@_tmpc_tl
\dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \l_@@_line_width_dim }
\@@_qpoint:n \l_tmpa_tl
\dim_set:Nn \l_@@_tmpc_dim { \pgf@y + 0.5 \l_@@_line_width_dim }
\@@_qpoint:n { #1 }
\tl_if_empty:NTF \l_@@_borders_tikz_tl
{
\pgfpathmoveto { \pgfpoint \pgf@x \l_tmpb_dim }
\pgfpathlineto { \pgfpoint \pgf@x \l_@@_tmpc_dim }
\pgfusepathqstroke
}
{
\use:x { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] }
( \pgf@x , \l_tmpb_dim ) -- ( \pgf@x , \l_@@_tmpc_dim ) ;
}
}
% \end{macrocode}
%
% \medskip
% The following command is used to stroke the top border and the bottom border.
% The argument |#1| is the number of row (in the sense of the |row| node).
% \begin{macrocode}
\cs_new_protected:Npn \@@_stroke_horizontal:n #1
{
\@@_qpoint:n \l_@@_tmpd_tl
\clist_if_in:NnTF \l_@@_borders_clist { left }
{ \dim_set:Nn \l_tmpa_dim { \pgf@x - 0.5 \l_@@_line_width_dim } }
{ \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \l_@@_line_width_dim } }
\@@_qpoint:n \l_tmpb_tl
\dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \l_@@_line_width_dim }
\@@_qpoint:n { #1 }
\tl_if_empty:NTF \l_@@_borders_tikz_tl
{
\pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y }
\pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y }
\pgfusepathqstroke
}
{
\use:x { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] }
( \l_tmpa_dim , \pgf@y ) -- ( \l_tmpb_dim , \pgf@y ) ;
}
}
% \end{macrocode}
%
% \bigskip
% Here is the set of keys for the command |\@@_stroke_borders_block:nnn|.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / BlockBorders }
{
borders .clist_set:N = \l_@@_borders_clist ,
rounded-corners .dim_set:N = \l_@@_rounded_corners_dim ,
rounded-corners .default:n = 4 pt ,
line-width .dim_set:N = \l_@@_line_width_dim ,
}
% \end{macrocode}
%
% \bigskip
% The following command will be used if the key |tikz| has been used for the
% command |\Block|. The arguments |#1| and |#2| are the coordinates of the first
% cell and |#3| and |#4| the coordinates of the last cell of the block. |#5| is
% a comma-separated list of the Tikz keys used with the path.
% \begin{macrocode}
\cs_new_protected:Npn \@@_block_tikz:nnnnn #1 #2 #3 #4 #5
{
\begin { tikzpicture }
\clist_map_inline:nn { #5 }
{
\path [ ##1 ]
( #1 -| #2 )
rectangle
( \int_eval:n { #3 + 1 } -| \int_eval:n { #4 + 1 } ) ;
}
\end { tikzpicture }
}
% \end{macrocode}
%
%
% \subsection*{How to draw the dotted lines transparently}
% \begin{macrocode}
\cs_set_protected:Npn \@@_renew_matrix:
{
\RenewDocumentEnvironment { pmatrix } { }
{ \pNiceMatrix }
{ \endpNiceMatrix }
\RenewDocumentEnvironment { vmatrix } { }
{ \vNiceMatrix }
{ \endvNiceMatrix }
\RenewDocumentEnvironment { Vmatrix } { }
{ \VNiceMatrix }
{ \endVNiceMatrix }
\RenewDocumentEnvironment { bmatrix } { }
{ \bNiceMatrix }
{ \endbNiceMatrix }
\RenewDocumentEnvironment { Bmatrix } { }
{ \BNiceMatrix }
{ \endBNiceMatrix }
}
% \end{macrocode}
%
%
% \bigskip
% \subsection*{Automatic arrays}
%
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_set_size:n #1-#2 \q_stop
{
\int_set:Nn \l_@@_nb_rows_int { #1 }
\int_set:Nn \l_@@_nb_cols_int { #2 }
}
% \end{macrocode}
%
%
% \bigskip
% We will extract the potential keys |l|, |r| and |c| and pass the other keys to
% the environment |{NiceArrayWithDelims}|.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Auto }
{
l .code:n = \tl_set:Nn \l_@@_type_of_col_tl l ,
r .code:n = \tl_set:Nn \l_@@_type_of_col_tl r ,
c .code:n = \tl_set:Nn \l_@@_type_of_col_tl c
}
% \end{macrocode}
%
% \begin{macrocode}
\NewDocumentCommand \AutoNiceMatrixWithDelims { m m O { } m O { } m ! O { } }
{
\int_zero_new:N \l_@@_nb_rows_int
\int_zero_new:N \l_@@_nb_cols_int
\@@_set_size:n #4 \q_stop
% \end{macrocode}
% The group is for the protection of |\l_@@_type_of_col_tl|.
% \begin{macrocode}
\group_begin:
\tl_set:Nn \l_@@_type_of_col_tl c
\keys_set_known:nnN { NiceMatrix / Auto } { #3, #5, #7 } \l_tmpa_tl
\use:x
{
\exp_not:N \begin { NiceArrayWithDelims } { #1 } { #2 }
{ * { \int_use:N \l_@@_nb_cols_int } { \l_@@_type_of_col_tl } }
[ \exp_not:V \l_tmpa_tl ]
}
\int_compare:nNnT \l_@@_first_row_int = 0
{
\int_compare:nNnT \l_@@_first_col_int = 0 { & }
\prg_replicate:nn { \l_@@_nb_cols_int - 1 } { & }
\int_compare:nNnT \l_@@_last_col_int > { -1 } { & } \\
}
\prg_replicate:nn \l_@@_nb_rows_int
{
\int_compare:nNnT \l_@@_first_col_int = 0 { & }
% \end{macrocode}
% We put |{ }| before |#6| to avoid a hasty expansion of a potential
% |\arabic{iRow}| at the beginning of the row which would result in an incorrect
% value of that |iRow| (since |iRow| is incremented in the first cell of the row
% of the |\halign|).
% \begin{macrocode}
\prg_replicate:nn { \l_@@_nb_cols_int - 1 } { { } #6 & } #6
\int_compare:nNnT \l_@@_last_col_int > { -1 } { & } \\
}
\int_compare:nNnT \l_@@_last_row_int > { -2 }
{
\int_compare:nNnT \l_@@_first_col_int = 0 { & }
\prg_replicate:nn { \l_@@_nb_cols_int - 1 } { & }
\int_compare:nNnT \l_@@_last_col_int > { -1 } { & } \\
}
\end { NiceArrayWithDelims }
\group_end:
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_set_protected:Npn \@@_define_com:nnn #1 #2 #3
{
\cs_set_protected:cpn { #1 AutoNiceMatrix }
{
\str_gset:Nx \g_@@_name_env_str { #1 AutoNiceMatrix }
\AutoNiceMatrixWithDelims { #2 } { #3 }
}
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_define_com:nnn p ( )
\@@_define_com:nnn b [ ]
\@@_define_com:nnn v | |
\@@_define_com:nnn V \| \|
\@@_define_com:nnn B \{ \}
% \end{macrocode}
%
% \bigskip
% We define also a command |\AutoNiceMatrix| similar to the environment |{NiceMatrix}|.
% \begin{macrocode}
\NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } }
{
\group_begin:
\bool_set_true:N \l_@@_NiceArray_bool
\AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ]
\group_end:
}
% \end{macrocode}
%
%
% \bigskip
% \subsection*{The redefinition of the command \textbackslash dotfill }
%
% \begin{macrocode}
\cs_set_eq:NN \@@_old_dotfill \dotfill
\cs_new_protected:Npn \@@_dotfill:
{
% \end{macrocode}
% First, we insert |\@@_dotfill| (which is the saved version of |\dotfill|) in
% case of use of |\dotfill| ``internally'' in the cell (e.g. |\hbox to 1cm {\dotfill}|).
% \begin{macrocode}
\@@_old_dotfill
\bool_if:NT \l_@@_NiceTabular_bool
{ \group_insert_after:N \@@_dotfill_ii: }
{ \group_insert_after:N \@@_dotfill_i: }
}
\cs_new_protected:Npn \@@_dotfill_i: { \group_insert_after:N \@@_dotfill_ii: }
\cs_new_protected:Npn \@@_dotfill_ii: { \group_insert_after:N \@@_dotfill_iii: }
% \end{macrocode}
% Now, if the box if not empty (unfornately, we can't actually test whether the
% box is empty and that's why we only consider it's width), we insert
% |\@@_dotfill| (which is the saved version of |\dotfill|) in the cell of the
% array, and it will extend, since it is no longer in |\l_@@_cell_box|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_dotfill_iii:
{ \dim_compare:nNnT { \box_wd:N \l_@@_cell_box } = \c_zero_dim \@@_old_dotfill }
% \end{macrocode}
%
% \bigskip
% \subsection*{The command \textbackslash diagbox}
%
% The command |\diagbox| will be linked to |\diagbox:nn| in the environments of
% \pkg{nicematrix}. However, there are also redefinitions of |\diagbox| in other
% circonstancies.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_diagbox:nn #1 #2
{
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{
\@@_actually_diagbox:nnnnnn
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ \exp_not:n { #1 } }
{ \exp_not:n { #2 } }
}
% \end{macrocode}
% We put the cell with |\diagbox| in the sequence |\g_@@_pos_of_blocks_seq|
% because a cell with |\diagbox| must be considered as non empty by the key
% |corners|.
% \begin{macrocode}
\seq_gput_right:Nx \g_@@_pos_of_blocks_seq
{
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
% \end{macrocode}
% The last argument is for the name of the block.
% \begin{macrocode}
{ }
}
}
% \end{macrocode}
%
% \medskip
% The command |\diagbox| is also redefined locally when we draw a block.
%
% \medskip
% The first four arguments of |\@@_actually_diagbox:nnnnnn| correspond to the
% rectangle (=block) to slash (we recall that it's possible to use |\diagbox| in
% a |\Block|). The other two are the elements to draw below and above the
% diagonal line.
% \begin{macrocode}
\cs_new_protected:Npn \@@_actually_diagbox:nnnnnn #1 #2 #3 #4 #5 #6
{
\pgfpicture
\pgf@relevantforpicturesizefalse
\pgfrememberpicturepositiononpagetrue
\@@_qpoint:n { row - #1 }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\@@_qpoint:n { col - #2 }
\dim_set_eq:NN \l_tmpb_dim \pgf@x
\pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
\@@_qpoint:n { row - \int_eval:n { #3 + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y
\@@_qpoint:n { col - \int_eval:n { #4 + 1 } }
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@x
\pgfpathlineto { \pgfpoint \l_@@_tmpd_dim \l_@@_tmpc_dim }
{
% \end{macrocode}
% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of
% the rules in the array. The package \pkg{nicematrix} uses it even if \pkg{colortbl} is not
% loaded.
% \begin{macrocode}
\CT@arc@
\pgfsetroundcap
\pgfusepathqstroke
}
\pgfset { inner~sep = 1 pt }
\pgfscope
\pgftransformshift { \pgfpoint \l_tmpb_dim \l_@@_tmpc_dim }
\pgfnode { rectangle } { south~west }
{
\begin { minipage } { 20 cm }
\@@_math_toggle_token: #5 \@@_math_toggle_token:
\end { minipage }
}
{ }
{ }
\endpgfscope
\pgftransformshift { \pgfpoint \l_@@_tmpd_dim \l_tmpa_dim }
\pgfnode { rectangle } { north~east }
{
\begin { minipage } { 20 cm }
\raggedleft
\@@_math_toggle_token: #6 \@@_math_toggle_token:
\end { minipage }
}
{ }
{ }
\endpgfpicture
}
% \end{macrocode}
%
%
%
%
% \bigskip
% \subsection*{The keyword \textbackslash CodeAfter}
%
%
% The |\CodeAfter| (inserted with the key |code-after| or after the keyword
% |\CodeAfter|) may always begin with a list of pairs \textsl{key=value} between
% square brackets. Here is the corresponding set of keys.
% \begin{macrocode}
\keys_define:nn { NiceMatrix }
{
CodeAfter / rules .inherit:n = NiceMatrix / rules ,
CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix
}
\keys_define:nn { NiceMatrix / CodeAfter }
{
sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } ,
sub-matrix .value_required:n = true ,
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
delimiters / color .value_required:n = true ,
rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
rules .value_required:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~CodeAfter }
}
% \end{macrocode}
%
% \medskip
% In fact, in this subsection, we define the user command |\CodeAfter| for the
% case of the ``normal syntax''. For the case of ``light-syntax'', see the
% definition of the environment |{@@-light-syntax}| on
% p.~\pageref{code-light-syntax}.
%
%
% \medskip
% In the environments of \pkg{nicematrix}, |\CodeAfter| will be linked to
% |\@@_CodeAfter:|. That macro must \emph{not} be protected since it begins with
% |\omit|.
% \begin{macrocode}
\cs_new:Npn \@@_CodeAfter: { \omit \@@_CodeAfter_ii:n }
% \end{macrocode}
%
% \medskip
% However, in each cell of the environment, the command |\CodeAfter| will be
% linked to the following command |\@@_CodeAfter_ii:n| which begins
% with |\\|.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_CodeAfter_i: { \\ \omit \@@_CodeAfter_ii:n }
% \end{macrocode}
%
% \smallskip
% We have to catch everything until the end of the current environment (of
% \pkg{nicematrix}). First, we go until the next command |\end|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_CodeAfter_ii:n #1 \end
{
\tl_gput_right:Nn \g_nicematrix_code_after_tl { #1 }
\@@_CodeAfter_iv:n
}
% \end{macrocode}
%
% We catch the argument of the command |\end| (in |#1|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_CodeAfter_iv:n #1
{
% \end{macrocode}
% If this is really the end of the current environment (of \pkg{nicematrix}), we
% put back the command |\end| and its argument in the TeX flow.
% \begin{macrocode}
\str_if_eq:eeTF \@currenvir { #1 } { \end { #1 } }
% \end{macrocode}
% If this is not the |\end| we are looking for, we put those tokens in
% |\g_nicematrix_code_after_tl| and we go on searching for the next command
% |\end| with a recursive call to the command |\@@_CodeAfter:n|.
% \begin{macrocode}
{
\tl_gput_right:Nn \g_nicematrix_code_after_tl { \end { #1 } }
\@@_CodeAfter_ii:n
}
}
% \end{macrocode}
%
%
%
% \subsection*{The delimiters in the preamble}
%
% The command |\@@_delimiter:nnn| will be used to draw delimiters inside the
% matrix when delimiters are specified in the preamble of the array. It does
% \emph{not} concern the exterior delimiters added by |{NiceArrayWithDelims}|
% (and |{pNiceArray}|, |{pNiceMatrix}|, etc.).
%
% A delimiter in the preamble of the array will write an instruction
% |\@@_delimiter:nnn| in the |\g_@@_internal_code_after_tl| (and also
% potentially add instructions in the preamble provided to |\array| in order to
% add space between columns).
%
% \smallskip
% The first argument is the type of delimiter (|(|, |[|, |\{|, |)|, |]| or
% |\}|). The second argument is the number of colummn. The third argument is a
% boolean equal to |\c_true_bool| (resp. |\c_false_true|) when the delimiter
% must be put on the left (resp. right) side.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_delimiter:nnn #1 #2 #3
{
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
% \end{macrocode}
%
% \medskip
% |\l_@@_y_initial_dim| and |\l_@@_y_final_dim| will be the $y$-values of the
% extremities of the delimiter we will have to construct.
% \begin{macrocode}
\@@_qpoint:n { row - 1 }
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
\@@_qpoint:n { row - \int_eval:n { \c@iRow + 1 } }
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y
% \end{macrocode}
%
% \medskip
% We will compute in |\l_tmpa_dim| the $x$-value where we will have to put our
% delimiter (on the left side or on the right side).
% \begin{macrocode}
\bool_if:nTF { #3 }
{ \dim_set_eq:NN \l_tmpa_dim \c_max_dim }
{ \dim_set:Nn \l_tmpa_dim { - \c_max_dim } }
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - ##1 - #2 }
{
\pgfpointanchor
{ \@@_env: - ##1 - #2 }
{ \bool_if:nTF { #3 } { west } { east } }
\dim_set:Nn \l_tmpa_dim
{ \bool_if:nTF { #3 } \dim_min:nn \dim_max:nn \l_tmpa_dim \pgf@x }
}
}
% \end{macrocode}
%
%
% Now we can put the delimiter with a node of \textsc{pgf}.
% \begin{macrocode}
\pgfset { inner~sep = \c_zero_dim }
\dim_zero:N \nulldelimiterspace
\pgftransformshift
{
\pgfpoint
{ \l_tmpa_dim }
{ ( \l_@@_y_initial_dim + \l_@@_y_final_dim + \arrayrulewidth ) / 2 }
}
\pgfnode
{ rectangle }
{ \bool_if:nTF { #3 } { east } { west } }
{
% \end{macrocode}
% Here is the content of the \textsc{pgf} node, that is to say the delimiter,
% constructed with its right size.
% \begin{macrocode}
\nullfont
\c_math_toggle_token
\tl_if_empty:NF \l_@@_delimiters_color_tl
{ \color { \l_@@_delimiters_color_tl } }
\bool_if:nTF { #3 } { \left #1 } { \left . }
\vcenter
{
\nullfont
\hrule \@height
\dim_eval:n { \l_@@_y_initial_dim - \l_@@_y_final_dim }
\@depth \c_zero_dim
\@width \c_zero_dim
}
\bool_if:nTF { #3 } { \right . } { \right #1 }
\c_math_toggle_token
}
{ }
{ }
\endpgfpicture
}
% \end{macrocode}
%
% \subsection*{The command \textbackslash SubMatrix}
%
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / sub-matrix }
{
extra-height .dim_set:N = \l_@@_submatrix_extra_height_dim ,
extra-height .value_required:n = true ,
left-xshift .dim_set:N = \l_@@_submatrix_left_xshift_dim ,
left-xshift .value_required:n = true ,
right-xshift .dim_set:N = \l_@@_submatrix_right_xshift_dim ,
right-xshift .value_required:n = true ,
xshift .meta:n = { left-xshift = #1, right-xshift = #1 } ,
xshift .value_required:n = true ,
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
delimiters / color .value_required:n = true ,
slim .bool_set:N = \l_@@_submatrix_slim_bool ,
slim .default:n = true ,
hlines .clist_set:N = \l_@@_submatrix_hlines_clist ,
hlines .default:n = all ,
vlines .clist_set:N = \l_@@_submatrix_vlines_clist ,
vlines .default:n = all ,
hvlines .meta:n = { hlines, vlines } ,
hvlines .value_forbidden:n = true ,
}
\keys_define:nn { NiceMatrix }
{
SubMatrix .inherit:n = NiceMatrix / sub-matrix ,
CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
NiceMatrix / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
NiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
pNiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
}
% \end{macrocode}
%
% \medskip
% The following keys set is for the command |\SubMatrix| itself (not the tuning
% of |\SubMatrix| that can be done elsewhere).
% \begin{macrocode}
\keys_define:nn { NiceMatrix / SubMatrix }
{
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
delimiters / color .value_required:n = true ,
hlines .clist_set:N = \l_@@_submatrix_hlines_clist ,
hlines .default:n = all ,
vlines .clist_set:N = \l_@@_submatrix_vlines_clist ,
vlines .default:n = all ,
hvlines .meta:n = { hlines, vlines } ,
hvlines .value_forbidden:n = true ,
name .code:n =
\tl_if_empty:nTF { #1 }
{ \@@_error:n { Invalid~name~format } }
{
\regex_match:nnTF { \A[A-Za-z][A-Za-z0-9]*\Z } { #1 }
{
\seq_if_in:NnTF \g_@@_submatrix_names_seq { #1 }
{ \@@_error:nn { Duplicate~name~for~SubMatrix } { #1 } }
{
\str_set:Nn \l_@@_submatrix_name_str { #1 }
\seq_gput_right:Nn \g_@@_submatrix_names_seq { #1 }
}
}
{ \@@_error:n { Invalid~name~format } }
} ,
rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
rules .value_required:n = true ,
code .tl_set:N = \l_@@_code_tl ,
code .value_required:n = true ,
name .value_required:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~SubMatrix }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\NewDocumentCommand \@@_SubMatrix_in_code_before { m m m m ! O { } }
{
\peek_remove_spaces:n
{
\@@_cut_on_hyphen:w #3 \q_stop
\tl_clear_new:N \l_@@_tmpc_tl
\tl_clear_new:N \l_@@_tmpd_tl
\tl_set_eq:NN \l_@@_tmpc_tl \l_tmpa_tl
\tl_set_eq:NN \l_@@_tmpd_tl \l_tmpb_tl
\@@_cut_on_hyphen:w #2 \q_stop
\seq_gput_right:Nx \g_@@_submatrix_seq
{ { \l_tmpa_tl } { \l_tmpb_tl } { \l_@@_tmpc_tl } { \l_@@_tmpd_tl } }
\tl_gput_right:Nn \g_@@_internal_code_after_tl
{ \SubMatrix { #1 } { #2 } { #3 } { #4 } [ #5 ] }
}
}
% \end{macrocode}
%
% \bigskip
% In the internal |code-after| and in the |\CodeAfter| the following command
% |\@@_SubMatrix| will be linked to |\SubMatrix|.
% \begin{itemize}
% \item |#1| is the left delimiter;
% \item |#2| is the upper-left cell of the matrix with the format $i$-$j$;
% \item |#3| is the lower-right cell of the matrix with the format $i$-$j$;
% \item |#4| is the right delimiter;
% \item |#5| is the list of options of the command;
% \item |#6| is the potential subscript;
% \item |#7| is the potential superscript.
% \end{itemize}
% For explanations about the construction with rescanning of the preamble, see
% the documentation for the user command |\Cdots|.
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
\tl_set:Nn \l_@@_argspec_tl { m m m m O { } E { _ ^ } { { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
\exp_args:NNV \NewDocumentCommand \@@_SubMatrix \l_@@_argspec_tl
{
\peek_remove_spaces:n
{
\@@_sub_matrix:nnnnnnn
{ #1 } { #2 } { #3 } { #4 } { #5 } { #6 } { #7 }
}
}
}
% \end{macrocode}
%
% \medskip
% The following macro will compute |\l_@@_first_i_tl|, |\l_@@_first_j_tl|,
% |\l_@@_last_i_tl| and |\l_@@_last_j_tl| from the arguments of the command as
% provided by the user (for example |2-3| and |5-last|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_compute_i_j:nn #1 #2
{
\tl_clear_new:N \l_@@_first_i_tl
\tl_clear_new:N \l_@@_first_j_tl
\tl_clear_new:N \l_@@_last_i_tl
\tl_clear_new:N \l_@@_last_j_tl
\@@_cut_on_hyphen:w #1 \q_stop
\tl_if_eq:NnTF \l_tmpa_tl { last }
{ \tl_set:NV \l_@@_first_i_tl \c@iRow }
{ \tl_set_eq:NN \l_@@_first_i_tl \l_tmpa_tl }
\tl_if_eq:NnTF \l_tmpb_tl { last }
{ \tl_set:NV \l_@@_first_j_tl \c@jCol }
{ \tl_set_eq:NN \l_@@_first_j_tl \l_tmpb_tl }
\@@_cut_on_hyphen:w #2 \q_stop
\tl_if_eq:NnTF \l_tmpa_tl { last }
{ \tl_set:NV \l_@@_last_i_tl \c@iRow }
{ \tl_set_eq:NN \l_@@_last_i_tl \l_tmpa_tl }
\tl_if_eq:NnTF \l_tmpb_tl { last }
{ \tl_set:NV \l_@@_last_j_tl \c@jCol }
{ \tl_set_eq:NN \l_@@_last_j_tl \l_tmpb_tl }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_sub_matrix:nnnnnnn #1 #2 #3 #4 #5 #6 #7
{
\group_begin:
% \end{macrocode}
% The four following token lists correspond to the position of the |\SubMatrix|.
% \begin{macrocode}
\@@_compute_i_j:nn { #2 } { #3 }
\bool_lazy_or:nnTF
{ \int_compare_p:nNn \l_@@_last_i_tl > \g_@@_row_total_int }
{ \int_compare_p:nNn \l_@@_last_j_tl > \g_@@_col_total_int }
{ \@@_error:nn { Construct~too~large } { \SubMatrix } }
{
\str_clear_new:N \l_@@_submatrix_name_str
\keys_set:nn { NiceMatrix / SubMatrix } { #5 }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\pgfset { inner~sep = \c_zero_dim }
\dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim
\dim_set:Nn \l_@@_x_final_dim { - \c_max_dim }
% \end{macrocode}
% The last value of |\int_step_inline:nnn| is provided by currifycation.
% \begin{macrocode}
\bool_if:NTF \l_@@_submatrix_slim_bool
{ \int_step_inline:nnn \l_@@_first_i_tl \l_@@_last_i_tl }
{ \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int }
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_first_j_tl }
{
\pgfpointanchor { \@@_env: - ##1 - \l_@@_first_j_tl } { west }
\dim_set:Nn \l_@@_x_initial_dim
{ \dim_min:nn \l_@@_x_initial_dim \pgf@x }
}
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_last_j_tl }
{
\pgfpointanchor { \@@_env: - ##1 - \l_@@_last_j_tl } { east }
\dim_set:Nn \l_@@_x_final_dim
{ \dim_max:nn \l_@@_x_final_dim \pgf@x }
}
}
\dim_compare:nNnTF \l_@@_x_initial_dim = \c_max_dim
{ \@@_error:nn { impossible~delimiter } { left } }
{
\dim_compare:nNnTF \l_@@_x_final_dim = { - \c_max_dim }
{ \@@_error:nn { impossible~delimiter } { right } }
{ \@@_sub_matrix_i:nnnn { #1 } { #4 } { #6 } { #7 } }
}
\endpgfpicture
}
\group_end:
}
% \end{macrocode}
%
% \bigskip
% |#1| is the left delimiter, |#2| is the right one, |#3| is the subscript and
% |#4| is the superscript.
% \begin{macrocode}
\cs_new_protected:Npn \@@_sub_matrix_i:nnnn #1 #2 #3 #4
{
\@@_qpoint:n { row - \l_@@_first_i_tl - base }
\dim_set:Nn \l_@@_y_initial_dim
{ \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch }
\@@_qpoint:n { row - \l_@@_last_i_tl - base }
\dim_set:Nn \l_@@_y_final_dim
{ \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch }
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - \l_@@_first_i_tl - ##1 }
{
\pgfpointanchor { \@@_env: - \l_@@_first_i_tl - ##1 } { north }
\dim_set:Nn \l_@@_y_initial_dim
{ \dim_max:nn \l_@@_y_initial_dim \pgf@y }
}
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - \l_@@_last_i_tl - ##1 }
{
\pgfpointanchor { \@@_env: - \l_@@_last_i_tl - ##1 } { south }
\dim_set:Nn \l_@@_y_final_dim
{ \dim_min:nn \l_@@_y_final_dim \pgf@y }
}
}
\dim_set:Nn \l_tmpa_dim
{
\l_@@_y_initial_dim - \l_@@_y_final_dim +
\l_@@_submatrix_extra_height_dim - \arrayrulewidth
}
\dim_zero:N \nulldelimiterspace
% \end{macrocode}
%
% \bigskip
% We will draw the rules in the |\SubMatrix|.
% \begin{macrocode}
\group_begin:
\pgfsetlinewidth { 1.1 \arrayrulewidth }
\tl_if_empty:NF \l_@@_rules_color_tl
{ \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop }
\CT@arc@
% \end{macrocode}
% Now, we draw the potential vertical rules specified in the preamble of the
% environments with the letter fixed with the key |vlines-in-sub-matrix|. The
% list of the columns where there is such rule to draw is in |\g_@@_cols_vlism_seq|.
% \begin{macrocode}
\seq_map_inline:Nn \g_@@_cols_vlism_seq
{
\int_compare:nNnT \l_@@_first_j_tl < { ##1 }
{
\int_compare:nNnT
{ ##1 } < { \int_eval:n { \l_@@_last_j_tl + 1 } }
{
% \end{macrocode}
% First, we extract the value of the abscissa of the rule we have to draw.
% \begin{macrocode}
\@@_qpoint:n { col - ##1 }
\pgfpathmoveto { \pgfpoint \pgf@x \l_@@_y_initial_dim }
\pgfpathlineto { \pgfpoint \pgf@x \l_@@_y_final_dim }
\pgfusepathqstroke
}
}
}
% \end{macrocode}
%
% \medskip
% Now, we draw the vertical rules specified in the key |vlines| of |\SubMatrix|.
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given
% by curryfication.
% \begin{macrocode}
\tl_if_eq:NnTF \l_@@_submatrix_vlines_clist { all }
{ \int_step_inline:nn { \l_@@_last_j_tl - \l_@@_first_j_tl } }
{ \clist_map_inline:Nn \l_@@_submatrix_vlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
{
\int_compare_p:nNn
{ ##1 } < { \l_@@_last_j_tl - \l_@@_first_j_tl + 1 } }
{
\@@_qpoint:n { col - \int_eval:n { ##1 + \l_@@_first_j_tl } }
\pgfpathmoveto { \pgfpoint \pgf@x \l_@@_y_initial_dim }
\pgfpathlineto { \pgfpoint \pgf@x \l_@@_y_final_dim }
\pgfusepathqstroke
}
{ \@@_error:nnn { Wrong~line~in~SubMatrix } { vertical } { ##1 } }
}
% \end{macrocode}
%
% \medskip
% Now, we draw the horizontal rules specified in the key |hlines| of
% |\SubMatrix|.
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given
% by curryfication.
% \begin{macrocode}
\tl_if_eq:NnTF \l_@@_submatrix_hlines_clist { all }
{ \int_step_inline:nn { \l_@@_last_i_tl - \l_@@_first_i_tl } }
{ \clist_map_inline:Nn \l_@@_submatrix_hlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
{
\int_compare_p:nNn
{ ##1 } < { \l_@@_last_i_tl - \l_@@_first_i_tl + 1 } }
{
\@@_qpoint:n { row - \int_eval:n { ##1 + \l_@@_first_i_tl } }
% \end{macrocode}
% We use a group to protect |\l_tmpa_dim| and |\l_tmpb_dim|.
% \begin{macrocode}
\group_begin:
% \end{macrocode}
% We compute in |\l_tmpa_dim| the $x$-value of the left end of the rule.
% \begin{macrocode}
\dim_set:Nn \l_tmpa_dim
{ \l_@@_x_initial_dim - \l_@@_submatrix_left_xshift_dim }
\str_case:nn { #1 }
{
( { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } }
[ { \dim_sub:Nn \l_tmpa_dim { 0.2 mm } }
\{ { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } }
}
\pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y }
% \end{macrocode}
% We compute in |\l_tmpb_dim| the $x$-value of the right end of the rule.
% \begin{macrocode}
\dim_set:Nn \l_tmpb_dim
{ \l_@@_x_final_dim + \l_@@_submatrix_right_xshift_dim }
\str_case:nn { #2 }
{
) { \dim_add:Nn \l_tmpb_dim { 0.9 mm } }
] { \dim_add:Nn \l_tmpb_dim { 0.2 mm } }
\} { \dim_add:Nn \l_tmpb_dim { 0.9 mm } }
}
\pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y }
\pgfusepathqstroke
\group_end:
}
{ \@@_error:nnn { Wrong~line~in~SubMatrix } { horizontal } { ##1 } }
}
% \end{macrocode}
%
% \medskip
% If the key |name| has been used for the command |\SubMatrix|, we create a PGF
% node with that name for the submatrix (this node does not encompass the
% delimiters that we will put after).
% \begin{macrocode}
\str_if_empty:NF \l_@@_submatrix_name_str
{
\@@_pgf_rect_node:nnnnn \l_@@_submatrix_name_str
\l_@@_x_initial_dim \l_@@_y_initial_dim
\l_@@_x_final_dim \l_@@_y_final_dim
}
\group_end:
% \end{macrocode}
% The group was for |\CT@arc@| (the color of the rules).
%
% \medskip
% Now, we deal with the left delimiter. Of course, the environment
% |{pgfscope}| is for the |\pgftransformshift|.
% \begin{macrocode}
\begin { pgfscope }
\pgftransformshift
{
\pgfpoint
{ \l_@@_x_initial_dim - \l_@@_submatrix_left_xshift_dim }
{ ( \l_@@_y_initial_dim + \l_@@_y_final_dim ) / 2 }
}
\str_if_empty:NTF \l_@@_submatrix_name_str
{ \@@_node_left:nn #1 { } }
{ \@@_node_left:nn #1 { \@@_env: - \l_@@_submatrix_name_str - left } }
\end { pgfscope }
% \end{macrocode}
%
% \medskip
% Now, we deal with the right delimiter.
% \begin{macrocode}
\pgftransformshift
{
\pgfpoint
{ \l_@@_x_final_dim + \l_@@_submatrix_right_xshift_dim }
{ ( \l_@@_y_initial_dim + \l_@@_y_final_dim ) / 2 }
}
\str_if_empty:NTF \l_@@_submatrix_name_str
{ \@@_node_right:nnnn #2 { } { #3 } { #4 } }
{
\@@_node_right:nnnn #2
{ \@@_env: - \l_@@_submatrix_name_str - right } { #3 } { #4 }
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_set_eq:NN \pgfpointanchor \@@_pgfpointanchor:n
\flag_clear_new:n { nicematrix }
\l_@@_code_tl
}
% \end{macrocode}
%
% \bigskip
% In the key |code| of the command |\SubMatrix| there may be Tikz instructions.
% We want that, in these instructions, the $i$ and $j$ in specifications of
% nodes of the forms $i$|-|$j$, |row-|$i$, |col-|$j$ and $i$\verb+-|+$j$ refer
% to the number of row and columm \emph{relative} of the current |\SubMatrix|.
% That's why we will patch (locally in the |\SubMatrix|) the command
% |\pgfpointanchor|.
% \begin{macrocode}
\cs_set_eq:NN \@@_old_pgfpointanchor \pgfpointanchor
% \end{macrocode}
%
% \bigskip
% The following command will be linked to |\pgfpointanchor| just before the
% execution of the option |code| of the command |\SubMatrix|. In this command,
% we catch the argument |#1| of |\pgfpointanchor| and we apply to it the command
% |\@@_pgfpointanchor_i:nn| before passing it to the original |\pgfpointanchor|.
% We have to act in an expandable way because the command |\pgfpointanchor| is
% used in names of Tikz nodes which are computed in an expandable way.
% \begin{macrocode}
\cs_new_protected:Npn \@@_pgfpointanchor:n #1
{
\use:e
{ \exp_not:N \@@_old_pgfpointanchor { \@@_pgfpointanchor_i:nn #1 } }
}
% \end{macrocode}
%
% \bigskip
% In fact, the argument of |\pgfpointanchor| is always of the form
% |\a_command { name_of_node }| where ``|name_of_node|'' is the name of the Tikz
% node without the potential prefix and suffix. That's why we catch two
% arguments and work only on the second by trying (first) to extract an hyphen |-|.
% \begin{macrocode}
\cs_new:Npn \@@_pgfpointanchor_i:nn #1 #2
{ #1 { \@@_pgfpointanchor_ii:w #2 - \q_stop } }
% \end{macrocode}
%
% \bigskip
% Since |\seq_if_in:NnTF| and |\clist_if_in:NnTF| are not expandable, we will
% use the following token list and |\str_case:nVTF| to test whether we have an
% integer or not.
% \begin{macrocode}
\tl_const:Nn \c_@@_integers_alist_tl
{
{ 1 } { } { 2 } { } { 3 } { } { 4 } { } { 5 } { }
{ 6 } { } { 7 } { } { 8 } { } { 9 } { } { 10 } { }
{ 11 } { } { 12 } { } { 13 } { } { 14 } { } { 15 } { }
{ 16 } { } { 17 } { } { 18 } { } { 19 } { } { 20 } { }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\cs_new:Npn \@@_pgfpointanchor_ii:w #1-#2\q_stop
{
% \end{macrocode}
% If there is no hyphen, that means that the node is of the form of a single
% number (ex.: |5| or |11|). In that case, we are in an analysis which result
% from a specification of node of the form $i$\verb+-|+$j$. In that case, the
% $i$ of the number of row arrives first (and alone) in a |\pgfpointanchor| and,
% the, the $j$ arrives (alone) in the following |\pgfpointanchor|. In order to
% know whether we have a number of row or a number of column, we keep track of
% the number of such treatments by the expandable flag called |nicematrix|.
% \begin{macrocode}
\tl_if_empty:nTF { #2 }
{
\str_case:nVTF { #1 } \c_@@_integers_alist_tl
{
\flag_raise:n { nicematrix }
\int_if_even:nTF { \flag_height:n { nicematrix } }
{ \int_eval:n { #1 + \l_@@_first_i_tl - 1 } }
{ \int_eval:n { #1 + \l_@@_first_j_tl - 1 } }
}
{ #1 }
}
% \end{macrocode}
% If there is an hyphen, we have to see whether we have a node of the form
% $i$|-|$j$, |row-|$i$ or |col-|$j$.
% \begin{macrocode}
{ \@@_pgfpointanchor_iii:w { #1 } #2 }
}
% \end{macrocode}
%
% \bigskip
% There was an hyphen in the name of the node and that's why we have to retrieve
% the extra hyphen we have put (cf. |\@@_pgfpointanchor_i:nn|).
% \begin{macrocode}
\cs_new:Npn \@@_pgfpointanchor_iii:w #1 #2 -
{
\str_case:nnF { #1 }
{
{ row } { row - \int_eval:n { #2 + \l_@@_first_i_tl - 1 } }
{ col } { col - \int_eval:n { #2 + \l_@@_first_j_tl - 1 } }
}
% \end{macrocode}
% Now the case of a node of the form $i$|-|$j$.
% \begin{macrocode}
{
\int_eval:n { #1 + \l_@@_first_i_tl - 1 }
- \int_eval:n { #2 + \l_@@_first_j_tl - 1 }
}
}
% \end{macrocode}
%
% \medskip
% The command |\@@_node_left:nn| puts the left delimiter with the correct size.
% The argument |#1| is the delimiter to put. The argument |#2| is the name we
% will give to this PGF node (if the key |name| has been used in |\SubMatrix|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_node_left:nn #1 #2
{
\pgfnode
{ rectangle }
{ east }
{
\nullfont
\c_math_toggle_token
\tl_if_empty:NF \l_@@_delimiters_color_tl
{ \color { \l_@@_delimiters_color_tl } }
\left #1
\vcenter
{
\nullfont
\hrule \@height \l_tmpa_dim
\@depth \c_zero_dim
\@width \c_zero_dim
}
\right .
\c_math_toggle_token
}
{ #2 }
{ }
}
% \end{macrocode}
%
% \medskip
% The command |\@@_node_right:nn| puts the right delimiter with the correct size.
% The argument |#1| is the delimiter to put. The argument |#2| is the name we
% will give to this PGF node (if the key |name| has been used in |\SubMatrix|).
% The argument |#3| is the subscript and |#4| is the superscript.
% \begin{macrocode}
\cs_new_protected:Npn \@@_node_right:nnnn #1 #2 #3 #4
{
\pgfnode
{ rectangle }
{ west }
{
\nullfont
\c_math_toggle_token
\tl_if_empty:NF \l_@@_delimiters_color_tl
{ \color { \l_@@_delimiters_color_tl } }
\left .
\vcenter
{
\nullfont
\hrule \@height \l_tmpa_dim
\@depth \c_zero_dim
\@width \c_zero_dim
}
\right #1
\tl_if_empty:nF { #3 } { _ { \smash { #3 } } }
^ { \smash { #4 } }
\c_math_toggle_token
}
{ #2 }
{ }
}
% \end{macrocode}
%
%
% \bigskip
% \subsection*{Les commandes \textbackslash UnderBrace et \textbackslash
% OverBrace}
%
% The following commands will be linked to |\UnderBrace| and |\OverBrace| in the
% |\CodeAfter|.
%
% \begin{macrocode}
\NewDocumentCommand \@@_UnderBrace { O { } m m m O { } }
{
\peek_remove_spaces:n
{ \@@_brace:nnnnn { #2 } { #3 } { #4 } { #1 , #5 } { under } }
}
% \end{macrocode}
%
% \begin{macrocode}
\NewDocumentCommand \@@_OverBrace { O { } m m m O { } }
{
\peek_remove_spaces:n
{ \@@_brace:nnnnn { #2 } { #3 } { #4 } { #1 , #5 } { over } }
}
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Brace }
{
left-shorten .bool_set:N = \l_@@_brace_left_shorten_bool ,
left-shorten .default:n = true ,
right-shorten .bool_set:N = \l_@@_brace_right_shorten_bool ,
shorten .meta:n = { left-shorten , right-shorten } ,
right-shorten .default:n = true ,
yshift .dim_set:N = \l_@@_brace_yshift_dim ,
yshift .value_required:n = true ,
yshift .initial:n = \c_zero_dim ,
color .tl_set:N = \l_tmpa_tl ,
color .value_required:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~Brace }
}
% \end{macrocode}
%
% \medskip
% |#1| is the first cell of the rectangle (with the syntax $i$\verb+-|+$j$;
% |#2| is the last cell of the rectangle;
% |#3| is the label of the text;
% |#4| is the optional argument (a list of \textsl{key}-\textsl{value} pairs);
% |#5| is equal to |under| or |over|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_brace:nnnnn #1 #2 #3 #4 #5
{
\group_begin:
% \end{macrocode}
% The four following token lists correspond to the position of the sub-matrix to
% which a brace will be attached.
% \begin{macrocode}
\@@_compute_i_j:nn { #1 } { #2 }
\bool_lazy_or:nnTF
{ \int_compare_p:nNn \l_@@_last_i_tl > \g_@@_row_total_int }
{ \int_compare_p:nNn \l_@@_last_j_tl > \g_@@_col_total_int }
{
\str_if_eq:nnTF { #5 } { under }
{ \@@_error:nn { Construct~too~large } { \UnderBrace } }
{ \@@_error:nn { Construct~too~large } { \OverBrace } }
}
{
\tl_clear:N \l_tmpa_tl % added the 2022-02-25
\keys_set:nn { NiceMatrix / Brace } { #4 }
\tl_if_empty:NF \l_tmpa_tl { \color { \l_tmpa_tl } } % added the 2022-02-25
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\bool_if:NT \l_@@_brace_left_shorten_bool
{
\dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim
\int_step_inline:nnn \l_@@_first_i_tl \l_@@_last_i_tl
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_first_j_tl }
{
\pgfpointanchor { \@@_env: - ##1 - \l_@@_first_j_tl } { west }
\dim_set:Nn \l_@@_x_initial_dim
{ \dim_min:nn \l_@@_x_initial_dim \pgf@x }
}
}
}
\bool_lazy_or:nnT
{ \bool_not_p:n \l_@@_brace_left_shorten_bool }
{ \dim_compare_p:nNn \l_@@_x_initial_dim = \c_max_dim }
{
\@@_qpoint:n { col - \l_@@_first_j_tl }
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
}
\bool_if:NT \l_@@_brace_right_shorten_bool
{
\dim_set:Nn \l_@@_x_final_dim { - \c_max_dim }
\int_step_inline:nnn \l_@@_first_i_tl \l_@@_last_i_tl
{
\cs_if_exist:cT
{ pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_last_j_tl }
{
\pgfpointanchor { \@@_env: - ##1 - \l_@@_last_j_tl } { east }
\dim_set:Nn \l_@@_x_final_dim
{ \dim_max:nn \l_@@_x_final_dim \pgf@x }
}
}
}
\bool_lazy_or:nnT
{ \bool_not_p:n \l_@@_brace_right_shorten_bool }
{ \dim_compare_p:nNn \l_@@_x_final_dim = { - \c_max_dim } }
{
\@@_qpoint:n { col - \int_eval:n { \l_@@_last_j_tl + 1 } }
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x
}
\pgfset { inner~sep = \c_zero_dim }
\str_if_eq:nnTF { #5 } { under }
{ \@@_underbrace_i:n { #3 } }
{ \@@_overbrace_i:n { #3 } }
\endpgfpicture
}
\group_end:
}
% \end{macrocode}
%
% \medskip
% The argument is the text to put above the brace.
% \begin{macrocode}
\cs_new_protected:Npn \@@_overbrace_i:n #1
{
\@@_qpoint:n { row - \l_@@_first_i_tl }
\pgftransformshift
{
\pgfpoint
{ ( \l_@@_x_initial_dim + \l_@@_x_final_dim) / 2 }
{ \pgf@y + \l_@@_brace_yshift_dim }
}
\pgfnode
{ rectangle }
{ south }
{
\vbox_top:n
{
\group_begin:
\everycr { }
\halign
{
\hfil ## \hfil \crcr
\@@_math_toggle_token: #1 \@@_math_toggle_token: \cr
\noalign { \skip_vertical:n { 4.5 pt } \nointerlineskip }
\hbox_to_wd:nn
{ \l_@@_x_final_dim - \l_@@_x_initial_dim }
{ \downbracefill } \cr
}
\group_end:
}
}
{ }
{ }
}
% \end{macrocode}
%
%
% \medskip
% The argument is the text to put under the brace.
% \begin{macrocode}
\cs_new_protected:Npn \@@_underbrace_i:n #1
{
\@@_qpoint:n { row - \int_eval:n { \l_@@_last_i_tl + 1 } }
\pgftransformshift
{
\pgfpoint
{ ( \l_@@_x_initial_dim + \l_@@_x_final_dim) / 2 }
{ \pgf@y - \l_@@_brace_yshift_dim }
}
\pgfnode
{ rectangle }
{ north }
{
\group_begin:
\everycr { }
\vbox:n
{
\halign
{
\hfil ## \hfil \crcr
\hbox_to_wd:nn
{ \l_@@_x_final_dim - \l_@@_x_initial_dim }
{ \upbracefill } \cr
\noalign { \skip_vertical:n { 4.5 pt } \nointerlineskip }
\@@_math_toggle_token: #1 \@@_math_toggle_token: \cr
}
}
\group_end:
}
{ }
{ }
}
% \end{macrocode}
%
%
%
% \bigskip
% \subsection*{We process the options at package loading}
%
%
% We process the options when the package is loaded (with |\usepackage|) but we
% recommend to use |\NiceMatrixOptions| instead.
%
% We must process these options after the definition of the environment
% |{NiceMatrix}| because the option |renew-matrix| executes the code
% |\cs_set_eq:NN \env@matrix \NiceMatrix|.
%
% Of course, the command |\NiceMatrix| must be defined before such an
% instruction is executed.
%
% \medskip
% The boolean |\g_@@_footnotehyper_bool| will indicate if the option
% |footnotehyper| is used.
% \begin{macrocode}
\bool_new:N \c_@@_footnotehyper_bool
% \end{macrocode}
%
% \medskip
% The boolean |\c_@@_footnote_bool| will indicate if the option |footnote| is
% used, but quicky, it will also be set to |true| if the option |footnotehyper|
% is used.
% \begin{macrocode}
\bool_new:N \c_@@_footnote_bool
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~package }
{
The~key~'\l_keys_key_str'~is~unknown. \\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
allow-letter-for-dotted-lines,~
footnote,~
footnotehyper,~
renew-dots,~and
renew-matrix.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Package }
{
renew-dots .bool_set:N = \l_@@_renew_dots_bool ,
renew-dots .value_forbidden:n = true ,
renew-matrix .code:n = \@@_renew_matrix: ,
renew-matrix .value_forbidden:n = true ,
transparent .code:n = \@@_fatal:n { Key~transparent } ,
transparent .value_forbidden:n = true,
footnote .bool_set:N = \c_@@_footnote_bool ,
footnotehyper .bool_set:N = \c_@@_footnotehyper_bool ,
allow-letter-for-dotted-lines .code:n =
{
\group_begin:
\globaldefs = 1
\@@_msg_redirect_name:nn { letter-for-dotted-lines } { none }
\group_end:
} ,
allow-letter-for-dotted-lines .value_forbidden:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~package }
}
\ProcessKeysOptions { NiceMatrix / Package }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
\@@_msg_new:nn { footnote~with~footnotehyper~package }
{
You~can't~use~the~option~'footnote'~because~the~package~
footnotehyper~has~already~been~loaded.~
If~you~want,~you~can~use~the~option~'footnotehyper'~and~the~footnotes~
within~the~environments~of~nicematrix~will~be~extracted~with~the~tools~
of~the~package~footnotehyper.\\
If~you~go~on,~the~package~footnote~won't~be~loaded.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { footnotehyper~with~footnote~package }
{
You~can't~use~the~option~'footnotehyper'~because~the~package~
footnote~has~already~been~loaded.~
If~you~want,~you~can~use~the~option~'footnote'~and~the~footnotes~
within~the~environments~of~nicematrix~will~be~extracted~with~the~tools~
of~the~package~footnote.\\
If~you~go~on,~the~package~footnotehyper~won't~be~loaded.
}
% \end{macrocode}
%
% \medskip
% \begin{macrocode}
\bool_if:NT \c_@@_footnote_bool
{
% \end{macrocode}
% The class \cls{beamer} has its own system to extract footnotes and that's why
% we have nothing to do if \cls{beamer} is used.
% \begin{macrocode}
\@ifclassloaded { beamer }
{ \bool_set_false:N \c_@@_footnote_bool }
{
\@ifpackageloaded { footnotehyper }
{ \@@_error:n { footnote~with~footnotehyper~package } }
{ \usepackage { footnote } }
}
}
% \end{macrocode}
%
% \begin{macrocode}
\bool_if:NT \c_@@_footnotehyper_bool
{
% \end{macrocode}
% The class \cls{beamer} has its own system to extract footnotes and that's why
% we have nothing to do if \cls{beamer} is used.
% \begin{macrocode}
\@ifclassloaded { beamer }
{ \bool_set_false:N \c_@@_footnote_bool }
{
\@ifpackageloaded { footnote }
{ \@@_error:n { footnotehyper~with~footnote~package } }
{ \usepackage { footnotehyper } }
}
\bool_set_true:N \c_@@_footnote_bool
}
% \end{macrocode}
% The flag |\c_@@_footnote_bool| is raised and so, we will only have to test
% |\c_@@_footnote_bool| in order to know if we have to insert an environment
% |{savenotes}|.
%
%
% \bigskip
% \subsection*{Error messages of the package}
%
%
%
% \begin{macrocode}
\seq_new:N \g_@@_types_of_matrix_seq
\seq_gset_from_clist:Nn \g_@@_types_of_matrix_seq
{
NiceMatrix ,
pNiceMatrix , bNiceMatrix , vNiceMatrix, BNiceMatrix, VNiceMatrix
}
\seq_gset_map_x:NNn \g_@@_types_of_matrix_seq \g_@@_types_of_matrix_seq
{ \tl_to_str:n { #1 } }
% \end{macrocode}
%
% \bigskip
% If the user uses too much columns, the command |\@@_error_too_much_cols:| is
% executed. This command raises an error but try to give the best information to
% the user in the error message. The command |\seq_if_in:NVTF| is not expandable
% and that's why we can't put it in the error message itself. We have to do the
% test before the |\@@_fatal:n|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_error_too_much_cols:
{
\seq_if_in:NVTF \g_@@_types_of_matrix_seq \g_@@_name_env_str
{
\int_compare:nNnTF \l_@@_last_col_int = { -2 }
{ \@@_fatal:n { too~much~cols~for~matrix } }
{
\bool_if:NF \l_@@_last_col_without_value_bool
{ \@@_fatal:n { too~much~cols~for~matrix~with~last~col } }
}
}
{ \@@_fatal:n { too~much~cols~for~array } }
}
% \end{macrocode}
%
% The following command must \emph{not} be protected since it's used in an error message.
% \begin{macrocode}
\cs_new:Npn \@@_message_hdotsfor:
{
\tl_if_empty:VF \g_@@_HVdotsfor_lines_tl
{ ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.}
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { negative~weight }
{
The~weight~of~the~'X'~columns~must~be~positive~and~you~have~used~
the~value~'#1'.~If~you~go~on,~the~absolute~value~will~be~used.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { too~much~cols~for~matrix~with~last~col }
{
You~try~to~use~more~columns~than~allowed~by~your~
\@@_full_name_env:.\@@_message_hdotsfor:\ The~maximal~number~of~
columns~is~\int_eval:n { \l_@@_last_col_int - 1 }~(plus~the~
exterior~columns).~This~error~is~fatal.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { too~much~cols~for~matrix }
{
You~try~to~use~more~columns~than~allowed~by~your~
\@@_full_name_env:.\@@_message_hdotsfor:\ Recall~that~the~maximal~
number~of~columns~for~a~matrix~is~fixed~by~the~LaTeX~counter~
'MaxMatrixCols'.~Its~actual~value~is~\int_use:N \c@MaxMatrixCols.~
This~error~is~fatal.
}
% \end{macrocode}
%
% \medskip
% For the following message, remind that the test is not done after the
% construction of the array but in each row. That's why we have to put
% |\c@jCol-1| and not |\c@jCol|.
% \begin{macrocode}
\@@_msg_new:nn { too~much~cols~for~array }
{
You~try~to~use~more~columns~than~allowed~by~your~
\@@_full_name_env:.\@@_message_hdotsfor:\ The~maximal~number~of~columns~is~
\int_use:N \g_@@_static_num_of_col_int\
~(plus~the~potential~exterior~ones).~
This~error~is~fatal.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { hvlines-except-corners }
{
The~key~'hvlines-except-corners'~is~now~obsolete.~You~should~instead~use~the~
keys~'hvlines'~and~'corners'.\\
However,~you~can~go~on~for~this~time.~This~message~won't~be~shown~anymore~
in~this~document.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { last~col~not~used }
{
The~key~'last-col'~is~in~force~but~you~have~not~used~that~last~column~
in~your~\@@_full_name_env:.~However,~you~can~go~on.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { columns~not~used }
{
The~preamble~of~your~\@@_full_name_env:\ announces~\int_use:N
\g_@@_static_num_of_col_int\ columns~but~you~use~only~\int_use:N \c@jCol.\\
You~can~go~on~but~the~columns~you~did~not~used~won't~be~created.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { in~first~col }
{
You~can't~use~the~command~#1 in~the~first~column~(number~0)~of~the~array.\\
If~you~go~on,~this~command~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { in~last~col }
{
You~can't~use~the~command~#1 in~the~last~column~(exterior)~of~the~array.\\
If~you~go~on,~this~command~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { in~first~row }
{
You~can't~use~the~command~#1 in~the~first~row~(number~0)~of~the~array.\\
If~you~go~on,~this~command~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { in~last~row }
{
You~can't~use~the~command~#1 in~the~last~row~(exterior)~of~the~array.\\
If~you~go~on,~this~command~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { double~closing~delimiter }
{
You~can't~put~a~second~closing~delimiter~"#1"~just~after~a~first~closing~
delimiter.~This~delimiter~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { delimiter~after~opening }
{
You~can't~put~a~second~delimiter~"#1"~just~after~a~first~opening~
delimiter.~This~delimiter~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { bad~option~for~line-style }
{
Since~you~haven't~loaded~Tikz,~the~only~value~you~can~give~to~'line-style'~
is~'standard'.~If~you~go~on,~this~key~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~custom-line }
{
The~key~'\l_keys_key_str'~is~unknown~in~a~'custom-line'.~
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
color,~
command,~
dotted,~
letter,~
multiplicity,~
sep-color,~
tikz,~and~width.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Unknown~key~for~xdots }
{
As~for~now,~there~is~only~three~keys~available~here:~'color',~'line-style'~
and~'shorten'~(and~you~try~to~use~'\l_keys_key_str').~If~you~go~on,~
this~key~will~be~ignored.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { Unknown~key~for~rowcolors }
{
As~for~now,~there~is~only~two~keys~available~here:~'cols'~and~'respect-blocks'~
(and~you~try~to~use~'\l_keys_key_str').~If~you~go~on,~
this~key~will~be~ignored.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { ampersand~in~light-syntax }
{
You~can't~use~an~ampersand~(\token_to_str:N &)~to~separate~columns~because~
~you~have~used~the~key~'light-syntax'.~This~error~is~fatal.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Construct~too~large }
{
Your~command~\token_to_str:N #1
can't~be~drawn~because~your~matrix~is~too~small.\\
If~you~go~on,~this~command~will~be~ignored.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { double-backslash~in~light-syntax }
{
You~can't~use~\token_to_str:N \\~to~separate~rows~because~you~have~used~
the~key~'light-syntax'.~You~must~use~the~character~'\l_@@_end_of_row_tl'~
(set~by~the~key~'end-of-row').~This~error~is~fatal.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { standard-cline~in~document }
{
The~key~'standard-cline'~is~available~only~in~the~preamble.\\
If~you~go~on~this~command~will~be~ignored.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { bad~value~for~baseline }
{
The~value~given~to~'baseline'~(\int_use:N \l_tmpa_int)~is~not~
valid.~The~value~must~be~between~\int_use:N \l_@@_first_row_int\ and~
\int_use:N \g_@@_row_total_int\ or~equal~to~'t',~'c'~or~'b'.\\
If~you~go~on,~a~value~of~1~will~be~used.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Invalid~name~format }
{
You~can't~give~the~name~'\l_keys_value_tl'~to~a~\token_to_str:N
\SubMatrix.\\
A~name~must~be~accepted~by~the~regular~expression~[A-Za-z][A-Za-z0-9]*.\\
If~you~go~on,~this~key~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Wrong~line~in~SubMatrix }
{
You~try~to~draw~a~#1~line~of~number~'#2'~in~a~
\token_to_str:N \SubMatrix\ of~your~\@@_full_name_env:\ but~that~
number~is~not~valid.~If~you~go~on,~it~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { impossible~delimiter }
{
It's~impossible~to~draw~the~#1~delimiter~of~your~
\token_to_str:N \SubMatrix\ because~all~the~cells~are~empty~
in~that~column.
\bool_if:NT \l_@@_submatrix_slim_bool
{ ~Maybe~you~should~try~without~the~key~'slim'. } \\
If~you~go~on,~this~\token_to_str:N \SubMatrix\ will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { width~without~X~columns }
{
You~have~used~the~key~'width'~but~you~have~put~no~'X'~column. \\
If~you~go~on,~that~key~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { empty~environment }
{ Your~\@@_full_name_env:\ is~empty.~This~error~is~fatal. }
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Wrong~use~of~v-center }
{
You~should~not~use~the~key~'v-center'~here~because~your~block~is~not~
mono-row.~However,~you~can~go~on.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { No~letter~and~no~command }
{
Your~use~of~'custom-line'~is~no-op~since~you~don't~have~used~the~
key~'letter'~(for~a~letter~for~vertical~rules)~nor~the~key~'command'~
(to~draw~horizontal~rules).\\
However,~you~can~go~on.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { letter-for-dotted-lines }
{
The~key~'letter-for-dotted-lines'~is~now~obsolete~(you~should~
use~'custom-line'~instead).~However,~you~can~go~on~for~this~time.~
If~you~don't~want~to~see~that~message~again,~you~should~
load~'nicematrix'~with~the~key~'allow-letter-for-dotted-lines'.~
However,~'letter-for-dotted-lines'~will~be~deleted~in~a~future~
version~of~'nicematrix'.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Forbidden~letter }
{
You~can't~use~the~letter~'\l_@@_letter_str'~for~a~customized~line.\\
If~you~go~on,~it~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { key~width~without~key~tikz }
{
In~'custom-line',~you~have~used~'width'~without~'tikz'.~That's~not~correct.~
If~you~go~on,~that~key~'width'~will~be~discarded.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Several~letters }
{
You~must~use~only~one~letter~as~value~for~the~key~'letter'~(and~
have~used~'\l_@@_letter_str').\\
If~you~go~on,~it~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Delimiter~with~small }
{
You~can't~put~a~delimiter~in~the~preamble~of~your~\@@_full_name_env:\
because~the~key~'small'~is~in~force.\\
This~error~is~fatal.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { unknown~cell~for~line~in~CodeAfter }
{
Your~command~\token_to_str:N\line\{#1\}\{#2\}~in~the~'code-after'~
can't~be~executed~because~a~cell~doesn't~exist.\\
If~you~go~on~this~command~will~be~ignored.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nnn { Duplicate~name~for~SubMatrix }
{
The~name~'#1'~is~already~used~for~a~\token_to_str:N \SubMatrix\
in~this~\@@_full_name_env:.\\
If~you~go~on,~this~key~will~be~ignored.\\
For~a~list~of~the~names~already~used,~type~H~<return>.
}
{
The~names~already~defined~in~this~\@@_full_name_env:\ are:~
\seq_use:Nnnn \g_@@_submatrix_names_seq { ~and~ } { ,~ } { ~and~ }.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { r~or~l~with~preamble }
{
You~can't~use~the~key~'\l_keys_key_str'~in~your~\@@_full_name_env:.~
You~must~specify~the~alignment~of~your~columns~with~the~preamble~of~
your~\@@_full_name_env:.\\
If~you~go~on,~this~key~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Hdotsfor~in~col~0 }
{
You~can't~use~\token_to_str:N \Hdotsfor\ in~an~exterior~column~of~
the~array.~This~error~is~fatal.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { bad~corner }
{
#1~is~an~incorrect~specification~for~a~corner~(in~the~keys~
'corners'~and~'except-corners').~The~available~
values~are:~NW,~SW,~NE~and~SE.\\
If~you~go~on,~this~specification~of~corner~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { bad~border }
{
\l_keys_key_str\space~is~an~incorrect~specification~for~a~border~
(in~the~key~'borders'~of~the~command~\token_to_str:N \Block).~
The~available~values~are:~left,~right,~top~and~bottom~(and~you~can~
also~use~the~key~'tikz'
\bool_if:nF \c_@@_tikz_loaded_bool
{~if~you~load~the~LaTeX~package~'tikz'}).\\
If~you~go~on,~this~specification~of~border~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { tikz~key~without~tikz }
{
You~can't~use~the~key~'tikz'~for~the~command~'\token_to_str:N
\Block'~because~you~have~not~loaded~Tikz.~
If~you~go~on,~this~key~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { last-col~non~empty~for~NiceArray }
{
In~the~\@@_full_name_env:,~you~must~use~the~key~
'last-col'~without~value.\\
However,~you~can~go~on~for~this~time~
(the~value~'\l_keys_value_tl'~will~be~ignored).
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions }
{
In~\NiceMatrixoptions,~you~must~use~the~key~
'last-col'~without~value.\\
However,~you~can~go~on~for~this~time~
(the~value~'\l_keys_value_tl'~will~be~ignored).
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { Block~too~large~1 }
{
You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~
too~small~for~that~block. \\
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Block~too~large~2 }
{
The~preamble~of~your~\@@_full_name_env:\ announces~\int_use:N
\g_@@_static_num_of_col_int\
columns~but~you~use~only~\int_use:N \c@jCol\ and~that's~why~a~block~
specified~in~the~cell~#1-#2~can't~be~drawn.~You~should~add~some~ampersands~
(&)~at~the~end~of~the~first~row~of~your~
\@@_full_name_env:.\\
If~you~go~on,this~block~and~maybe~others~will~be~ignored.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { unknown~column~type }
{
The~column~type~'#1'~in~your~\@@_full_name_env:\
is~unknown. \\
This~error~is~fatal.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { colon~without~arydshln }
{
The~column~type~':'~in~your~\@@_full_name_env:\
is~unknown.~If~you~want~to~use~':'~of~'arydshln',~you~should~
load~that~package.~If~you~want~a~dotted~line~of~'nicematrix',~you~
should~use~'\l_@@_letter_for_dotted_lines_str'.\\
This~error~is~fatal.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { tabularnote~forbidden }
{
You~can't~use~the~command~\token_to_str:N\tabularnote\
~in~a~\@@_full_name_env:.~This~command~is~available~only~in~
\{NiceTabular\},~\{NiceArray\}~and~\{NiceMatrix\}. \\
If~you~go~on,~this~command~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { borders~forbidden }
{
You~can't~use~the~key~'borders'~of~the~command~\token_to_str:N \Block\
because~the~option~'rounded-corners'~
is~in~force~with~a~non-zero~value.\\
If~you~go~on,~this~key~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { bottomrule~without~booktabs }
{
You~can't~use~the~key~'tabular/bottomrule'~because~you~haven't~
loaded~'booktabs'.\\
If~you~go~on,~this~key~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { enumitem~not~loaded }
{
You~can't~use~the~command~\token_to_str:N\tabularnote\
~because~you~haven't~loaded~'enumitem'.\\
If~you~go~on,~this~command~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { tikz~in~custom-line~without~tikz }
{
You~have~used~the~key~'tikz'~in~the~definition~of~a~
customized~line~(with~'custom-line')~but~Tikz~is~not~loaded.~
You~can~go~on~but~you~will~have~another~error~if~you~actually~
use~that~custom~line.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { tikz~in~borders~without~tikz }
{
You~have~used~the~key~'tikz'~in~a~key~'borders'~(of~a~
command~'\token_to_str:N\Block')~but~Tikz~is~not~loaded.~
If~you~go~on,~that~key~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { color~in~custom-line~with~tikz }
{
In~a~'custom-line',~you~have~used~both~'tikz'~and~'color',~
which~is~forbidden~(you~should~use~'color'~inside~the~key~'tikz').~
If~you~go~on,~the~key~'color'~will~be~discarded.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Wrong~last~row }
{
You~have~used~'last-row=\int_use:N \l_@@_last_row_int'~but~your~
\@@_full_name_env:\ seems~to~have~\int_use:N \c@iRow \ rows.~
If~you~go~on,~the~value~of~\int_use:N \c@iRow \ will~be~used~for~
last~row.~You~can~avoid~this~problem~by~using~'last-row'~
without~value~(more~compilations~might~be~necessary).
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nn { Yet~in~env }
{ Environments~of~nicematrix~can't~be~nested.\\ This~error~is~fatal. }
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Outside~math~mode }
{
The~\@@_full_name_env:\ can~be~used~only~in~math~mode~
(and~not~in~\token_to_str:N \vcenter).\\
This~error~is~fatal.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { One~letter~allowed }
{
The~value~of~key~'\l_keys_key_str'~must~be~of~length~1.\\
If~you~go~on,~it~will~be~ignored.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { varwidth~not~loaded }
{
You~can't~use~the~column~type~'V'~because~'varwidth'~is~not~
loaded.\\
If~you~go~on,~your~column~will~behave~like~'p'.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~Block }
{
The~key~'\l_keys_key_str'~is~unknown~for~the~command~\token_to_str:N
\Block.\\ If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~b,~borders,~c,~draw,~fill,~
hlines,~hvlines,~l,~line-width,~name,~rounded-corners,~r,~respect-arraystretch,
~t,~tikz~and~vlines.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Version~of~siunitx~too~old }
{
You~can't~use~'S'~columns~because~your~version~of~'siunitx'~
is~too~old.~You~need~at~least~v~3.0.\\
This~error~is~fatal.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~Brace }
{
The~key~'\l_keys_key_str'~is~unknown~for~the~commands~\token_to_str:N
\UnderBrace\ and~\token_to_str:N \OverBrace.\\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~color,~left-shorten,~
right-shorten,~shorten~(which~fixes~both~left-shorten~and~
right-shorten)~and~yshift.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~CodeAfter }
{
The~key~'\l_keys_key_str'~is~unknown.\\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~available~keys~in~\token_to_str:N
\CodeAfter,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
delimiters/color,~
rules~(with~the~subkeys~'color'~and~'width'),~
sub-matrix~(several~subkeys)~
and~xdots~(several~subkeys).~
The~latter~is~for~the~command~\token_to_str:N \line.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~SubMatrix }
{
The~key~'\l_keys_key_str'~is~unknown.\\
If~you~go~on,~this~key~will~be~ignored. \\
For~a~list~of~the~available~keys~in~\token_to_str:N
\SubMatrix,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
'delimiters/color',~
'extra-height',~
'hlines',~
'hvlines',~
'left-xshift',~
'name',~
'right-xshift',~
'rules'~(with~the~subkeys~'color'~and~'width'),~
'slim',~
'vlines'~and~'xshift'~(which~sets~both~'left-xshift'~
and~'right-xshift').\\
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~notes }
{
The~key~'\l_keys_key_str'~is~unknown.\\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~available~keys~about~notes,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
bottomrule,~
code-after,~
code-before,~
detect-duplicates,~
enumitem-keys,~
enumitem-keys-para,~
para,~
label-in-list,~
label-in-tabular~and~
style.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~RowStyle }
{
The~key~'\l_keys_key_str'~is~unknown~for~the~command~
\token_to_str:N \RowStyle. \\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
'bold',~
'cell-space-top-limit',~
'cell-space-bottom-limit',~
'cell-space-limits',~
'color',~
'nb-rows'~and~
'rowcolor'.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~NiceMatrixOptions }
{
The~key~'\l_keys_key_str'~is~unknown~for~the~command~
\token_to_str:N \NiceMatrixOptions. \\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~*principal*~available~keys,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
allow-duplicate-names,~
cell-space-bottom-limit,~
cell-space-limits,~
cell-space-top-limit,~
code-for-first-col,~
code-for-first-row,~
code-for-last-col,~
code-for-last-row,~
corners,~
custom-key,~
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
delimiters~(several~subkeys),~
end-of-row,~
first-col,~
first-row,~
hlines,~
hvlines,~
last-col,~
last-row,~
left-margin,~
light-syntax,~
notes~(several~subkeys),~
nullify-dots,~
renew-dots,~
renew-matrix,~
respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
sub-matrix~(several~subkeys),
vlines,~
xdots~(several~subkeys).
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~NiceArray }
{
The~key~'\l_keys_key_str'~is~unknown~for~the~environment~
\{NiceArray\}. \\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~*principal*~available~keys,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
b,~
baseline,~
c,~
cell-space-bottom-limit,~
cell-space-limits,~
cell-space-top-limit,~
code-after,~
code-for-first-col,~
code-for-first-row,~
code-for-last-col,~
code-for-last-row,~
colortbl-like,~
columns-width,~
corners,~
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
delimiters/color,~
extra-left-margin,~
extra-right-margin,~
first-col,~
first-row,~
hlines,~
hvlines,~
last-col,~
last-row,~
left-margin,~
light-syntax,~
name,~
notes/bottomrule,~
notes/para,~
nullify-dots,~
renew-dots,~
respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
t,~
tabularnote,~
vlines,~
xdots/color,~
xdots/shorten~and~
xdots/line-style.
}
% \end{macrocode}
%
% \medskip
% This error message is used for the set of keys |NiceMatrix/NiceMatrix| and
% |NiceMatrix/pNiceArray| (but not by |NiceMatrix/NiceArray| because, for this
% set of keys, there is also the keys |t|, |c| and~|b|).
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~NiceMatrix }
{
The~key~'\l_keys_key_str'~is~unknown~for~the~
\@@_full_name_env:. \\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~*principal*~available~keys,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
b,~
baseline,~
c,~
cell-space-bottom-limit,~
cell-space-limits,~
cell-space-top-limit,~
code-after,~
code-for-first-col,~
code-for-first-row,~
code-for-last-col,~
code-for-last-row,~
colortbl-like,~
columns-width,~
corners,~
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
delimiters~(several~subkeys),~
extra-left-margin,~
extra-right-margin,~
first-col,~
first-row,~
hlines,~
hvlines,~
l,~
last-col,~
last-row,~
left-margin,~
light-syntax,~
name,~
nullify-dots,~
r,~
renew-dots,~
respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
t,~
vlines,~
xdots/color,~
xdots/shorten~and~
xdots/line-style.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~key~for~NiceTabular }
{
The~key~'\l_keys_key_str'~is~unknown~for~the~environment~
\{NiceTabular\}. \\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~*principal*~available~keys,~type~H~<return>.
}
{
The~available~keys~are~(in~alphabetic~order):~
b,~
baseline,~
c,~
cell-space-bottom-limit,~
cell-space-limits,~
cell-space-top-limit,~
code-after,~
code-for-first-col,~
code-for-first-row,~
code-for-last-col,~
code-for-last-row,~
colortbl-like,~
columns-width,~
corners,~
custom-line,~
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
extra-left-margin,~
extra-right-margin,~
first-col,~
first-row,~
hlines,~
hvlines,~
last-col,~
last-row,~
left-margin,~
light-syntax,~
name,~
notes/bottomrule,~
notes/para,~
nullify-dots,~
renew-dots,~
respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
t,~
tabularnote,~
vlines,~
xdots/color,~
xdots/shorten~and~
xdots/line-style.
}
% \end{macrocode}
%
%
% \begin{macrocode}
\@@_msg_new:nnn { Duplicate~name }
{
The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~
the~same~environment~name~twice.~You~can~go~on,~but,~
maybe,~you~will~have~incorrect~results~especially~
if~you~use~'columns-width=auto'.~If~you~don't~want~to~see~this~
message~again,~use~the~key~'allow-duplicate-names'~in~
'\token_to_str:N \NiceMatrixOptions'.\\
For~a~list~of~the~names~already~used,~type~H~<return>. \\
}
{
The~names~already~defined~in~this~document~are:~
\seq_use:Nnnn \g_@@_names_seq { ~and~ } { ,~ } { ~and~ }.
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Option~auto~for~columns-width }
{
You~can't~give~the~value~'auto'~to~the~key~'columns-width'~here.~
If~you~go~on,~the~key~will~be~ignored.
}
% \end{macrocode}
%
%
%
% \vspace{1cm}
% \section{History}
%
% The successive versions of the file |nicematrix.sty| provided by TeXLive are available on the
% \textsc{svn} server of TeXLive:\par\nobreak
%
% \smallskip
% {
% \small
% \nolinkurl{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty}
% }
%
%
% \subsection*{Changes between versions 1.0 and 1.1}
%
% The dotted lines are no longer drawn with Tikz nodes but with Tikz circles
% (for efficiency).
%
% Modification of the code which is now twice faster.
%
% \subsection*{Changes between versions 1.1 and 1.2}
%
% New environment |{NiceArray}| with column types |L|, |C| and |R|.
%
% \subsection*{Changes between version 1.2 and 1.3}
%
% New environment |{pNiceArrayC}| and its variants.
%
% Correction of a bug in the definition of |{BNiceMatrix}|, |{vNiceMatrix}| and
% |{VNiceMatrix}| (in fact, it was a typo).
%
% Options are now available locally in |{pNiceMatrix}| and its variants.
%
% The names of the options are changed. The old names were names in ``camel
% style''.
%
% \subsection*{Changes between version 1.3 and 1.4}
%
% The column types |w| and |W| can now be used in the environments
% |{NiceArray}|, |{pNiceArrayC}| and its variants with the same meaning as in
% the package \pkg{array}.
%
% New option |columns-width| to fix the same width for all the columns of the
% array.
%
%
% \subsection*{Changes between version 1.4 and 2.0}
%
% The versions 1.0 to 1.4 of \pkg{nicematrix} were focused on the continuous
% dotted lines whereas the version 2.0 of \pkg{nicematrix} provides different
% features to improve the typesetting of mathematical matrices.
%
% \subsection*{Changes between version 2.0 and 2.1}
%
% New implementation of the environment |{pNiceArrayRC}|. With this new
% implementation, there is no restriction on the width of the columns.
%
% The package \pkg{nicematrix} no longer loads \pkg{mathtools} but only
% \pkg{amsmath}.
%
% Creation of ``medium nodes'' and ``large nodes''.
%
% \subsection*{Changes between version 2.1 and 2.1.1}
%
% Small corrections: for example, the option |code-for-first-row| is now
% available in the command |\NiceMatrixOptions|.
%
% Following a discussion on
% TeX StackExchange\footnote{cf.
% |tex.stackexchange.com/questions/450841/tikz-externalize-and-nicematrix-package|},
% Tikz externalization is now deactivated in the environments of the
% package \pkg{nicematrix}.\footnote{Before this version, there was an error
% when using \pkg{nicematrix} with Tikz externalization. In any case, it's not
% possible to externalize the Tikz elements constructed by \pkg{nicematrix}
% because they use the options |overlay| and |remember picture|.}
%
%
% \subsection*{Changes between version 2.1.2 and 2.1.3}
%
% When searching the end of a dotted line from a command like |\Cdots| issued in
% the ``main matrix'' (not in the exterior column), the cells in the exterior
% column are considered as outside the matrix. That means that it's possible to
% do the following matrix with only a |\Cdots| command (and a single |\Vdots|).
% \[\begin{pNiceArray}{Wc{5mm}cWc{5mm}}[first-row,last-col]
% & C_j & \\
% \mbox{\Large $0$} & \Vdots & \mbox{\Large $0$} \\
% \strut & a & \Cdots & L_i \\
% \mbox{\Large $0$} & & \mbox{\Large $0$} \\
% \end{pNiceArray}\]
%
% \subsection*{Changes between version 2.1.3 and 2.1.4}
%
% Replacement of some options |O { }| in commands and environments defined with
% \pkg{xparse} by |! O { }| (because a recent version of \pkg{xparse} introduced
% the specifier |!| and modified the default behaviour of the last optional
% arguments).
%
% See |www.texdev.net/2018/04/21/xparse-optional-arguments-at-the-end|
%
% \subsection*{Changes between version 2.1.4 and 2.1.5}
%
% Compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}.
%
% Option |allow-duplicate-names|.
%
% \subsection*{Changes between version 2.1.5 and 2.2}
%
% Possibility to draw horizontal dotted lines to separate rows with the command
% |\hdottedline| (similar to the classical command |\hline| and the command
% |\hdashline| of \pkg{arydshln}).
%
% Possibility to draw vertical dotted lines to separate columns with the
% specifier ``|:|'' in the preamble (similar to the classical specifier
% ``"|"'' and the specifier ``|:|'' of \pkg{arydshln}).
%
% \subsection*{Changes between version 2.2 and 2.2.1}
%
% Improvment of the vertical dotted lines drawn by the specifier ``:'' in the
% preamble.
%
% Modification of the position of the dotted lines drawn by |\hdottedline|.
%
% \subsection*{Changes between version 2.2.1 and 2.3}
%
% Compatibility with the column type |S| of \pkg{siunitx}.
%
% Option |hlines|.
%
%
% \subsection*{Changes between version 2.3 and 3.0}
%
% Modification of |\Hdotsfor|. Now |\Hdotsfor| erases the |\vlines| (of ``"|"'')
% as |\hdotsfor| does.
%
% Composition of exterior rows and columns on the four sides of the matrix (and
% not only on two sides) with the options |first-row|, |last-row|, |first-col|
% and |last-col|.
%
% \subsection*{Changes between version 3.0 and 3.1}
%
% Command |\Block| to draw block matrices.
%
% Error message when the user gives an incorrect value for |last-row|.
%
% A dotted line can no longer cross another dotted line (excepted the dotted
% lines drawn by |\cdottedline|, the symbol ``|:|'' (in the preamble of the
% array) and |\line| in |code-after|).
%
% The starred versions of |\Cdots|, |\Ldots|, etc. are now deprecated because,
% with the new implementation, they become pointless. These starred versions
% are no longer documented.
%
% The vertical rules in the matrices (drawn by ``"|"'') are now compatible with
% the color fixed by \pkg{colortbl}.
%
% Correction of a bug: it was not possible to use the colon ``|:|'' in the
% preamble of an array when |pdflatex| was used with \pkg{french-babel} (because
% \pkg{french-babel} activates the colon in the beginning of the document).
%
%
% \subsection*{Changes between version 3.1 and 3.2 (and 3.2a)}
%
% Option |small|.
%
% \subsection*{Changes between version 3.2 and 3.3}
%
% The options |first-row|, |last-row|, |first-col| and |last-col| are now
% available in the environments |{NiceMatrix}|, |{pNiceMatrix}|,
% |{bNiceMatrix}|, etc.
%
% The option |columns-width=auto| doesn't need any more a second compilation.
%
% The options |renew-dots|, |renew-matrix| and |transparent| are now available
% as package options (as said in the documentation).
%
% The previous version of \pkg{nicematrix} was incompatible with a recent
% version of \pkg{expl3} (released 2019/09/30). This version is compatible.
%
%
% \subsection*{Changes between version 3.3 and 3.4}
%
% Following a discussion on TeX StackExchange\footnote{cf.
% |tex.stackexchange.com/questions/510841/nicematrix-and-tikz-external-optimize|},
% optimization of Tikz externalization is disabled in the environments of
% \pkg{nicematrix} when the class \cls{standalone} or the package
% \pkg{standalone} is used.
%
% \subsection*{Changes between version 3.4 and 3.5}
%
% Correction on a bug on the two previous versions where the |code-after| was
% not executed.
%
% \subsection*{Changes between version 3.5 and 3.6}
%
% LaTeX counters |iRow| and |jCol| available in the cells of the array.
%
% Addition of |\normalbaselines| before the construction of the array: in
% environments like |{align}| of \pkg{amsmath} the value of |\baselineskip| is
% changed and if the options |first-row| and |last-row| were used in an
% environment of \pkg{nicematrix}, the position of the delimiters was wrong.
%
% A warning is written in the |.log| file if an obsolete environment is used.
%
% There is no longer artificial errors |Duplicate~name| in the environments of
% \pkg{amsmath}.
%
% \subsection*{Changes between version 3.6 and 3.7}
%
% The four ``corners'' of the matrix are correctly protected against the four
% codes: |code-for-first-col|, |code-for-last-col|, |code-for-first-row| and
% |code-for-last-row|.
%
% New command |\pAutoNiceMatrix| and its variants (suggestion of Christophe
% Bal).
%
% \subsection*{Changes between version 3.7 and 3.8}
%
% New programmation for the command |\Block| when the block has only one row.
% With this programmation, the vertical rules drawn by the specifier
% ``\verb+|+'' at the end of the block is actually drawn. In previous versions,
% they were not because the block of one row was constructed with
% |\multicolumn|.
%
% An error is raised when an obsolete environment is used.
%
%
% \subsection*{Changes between version 3.8 and 3.9}
%
% New commands |\NiceMatrixLastEnv| and |\OnlyMainNiceMatrix|.
%
% New options |create-medium-nodes| and |create-large-nodes|.
%
% \subsection*{Changes between version 3.9 and 3.10}
%
% New option |light-syntax| (and |end-of-row|).
%
% New option |dotted-lines-margin| for fine tuning of the dotted lines.
%
% \subsection*{Changes between versions 3.10 and 3.11}
%
% Correction of a bug linked to |first-row| and |last-row|.
%
% \subsection*{Changes between versions 3.11 and 3.12}
%
% Command |\rotate| in the cells of the array.
%
% Options |vlines|, |hlines| and |hvlines|.
%
% Option |baseline| pour |{NiceArray}| (not for the other environments).
%
% The name of the Tikz nodes created by the command |\Block| has changed: when
% the command has been issued in the cell $i$|-|$j$, the name is
% $i$|-|$j$|-block| and, if the creation of the ``medium nodes'' is required, a
% node $i$|-|$j$|-block-medium| is created.
%
% If the user tries to use more columns than allowed by its environment, an error
% is raised by nicematrix (instead of a low-level error).
%
% The package must be loaded with the option |obsolete-environments| if we want
% to use the deprecated environments.
%
% \subsection*{Changes between versions 3.12 and 3.13}
%
% The behaviour of the command |\rotate| is improved when used in the ``last
% row''.
%
% The option |dotted-lines-margin| has been renamed in |xdots/shorten| and the
% options |xdots/color| and |xdots/line-style| have been added for a complete
% customisation of the dotted lines.
%
% In the environments without preamble (|{NiceMatrix}|, |{pNiceMatrix}|, etc.),
% it's possible to use the options |l| (=|L|) or |r| (=|R|) to specify the type
% of the columns.
%
% The starred versions of the commands |\Cdots|, |\Ldots|, |\Vdots|, |\Ddots|
% and |\Iddots| are deprecated since the version 3.1 of \pkg{nicematrix}. Now,
% one should load \pkg{nicematrix} with the option |starred-commands| to avoid
% an error at the compilation.
%
% The code of \pkg{nicematrix} no longer uses Tikz but only \textsc{pgf}. By
% default, Tikz is \emph{not} loaded by \pkg{nicematrix}.
%
% \subsection*{Changes between versions 3.13 and 3.14}
%
% Correction of a bug (question 60761504 on |stackoverflow|).
%
% Better error messages when the user uses |&| or |\\| when |light-syntax| is in
% force.
%
% \subsection*{Changes between versions 3.14 and 3.15}
%
% It's possible to put labels on the dotted lines drawn by |\Ldots|, |\Cdots|,
% |\Vdots|, |\Ddots|, |\Iddots|, |\Hdotsfor| and the command |\line| in the
% |code-after| with the tokens |_| and |^|.
%
% The option |baseline| is now available in all the environments of
% \pkg{nicematrix}. Before, it was available only in |{NiceArray}|.
%
% New keyword |\CodeAfter| (in the environments of \pkg{nicematrix}).
%
%
% \subsection*{Changes between versions 3.15 and 4.0}
%
% New environment |{NiceTabular}|
%
% Commands to color cells, rows and columns with a perfect result in the \textsc{pdf}.
%
% \subsection*{Changes between versions 4.0 and 4.1}
%
% New keys |cell-space-top-limit| and |cell-space-bottom-limit|
%
% New command |\diagbox|
%
% The key |hvline| don't draw rules in the blocks (commands |\Block|) and in the
% virtual blocks corresponding to the dotted lines.
%
% \subsection*{Changes between versions 4.1 and 4.2}
%
% It's now possible to write |\begin{pNiceMatrix}a&b\\c&d\end{pNiceMatrix}^2|
% with the expected result.
%
% \subsection*{Changes between versions 4.2 and 4.3}
%
% The horizontal centering of the content of a |\Block| is correct even when an
% instruction such as |!{\qquad}| is used in the preamble of the array.
%
% It's now possible to use the command |\Block| in the ``last row''.
%
% \subsection*{Changes between versions 4.3 and 4.4}
%
% New key |hvlines-except-corners|.
%
% \subsection*{Changes between versions 4.4 and 5.0}
%
% Use of the standard column types |l|, |c| and |r| instead of |L|, |C| and |R|.
%
% It's now possible to use the command |\diagbox| in a |\Block|.
%
% Command |\tabularnote|
%
% \subsection*{Changes between versions 5.0 and 5.1}
%
% The vertical rules specified by \verb+|+ in the preamble are not broken by
% |\hline\hline| (and other).
%
% Environment |{NiceTabular*}|
%
% Command |\Vdotsfor| similar to |\Hdotsfor|
%
% The variable |\g_nicematrix_code_after_tl| is now public.
%
% \subsection*{Changes between versions 5.1 and 5.2}
%
% The vertical rules specified by \verb+|+ or \verb+||+ in the preamble respect
% the blocks.
%
% Key |respect-blocks| for |\rowcolors| (with a \emph{s}) in the |code-before|.
%
% The variable |\g_nicematrix_code_before_tl| is now public.
%
% The key |baseline| may take in as value an expression of the form
% \textsl{line-i} to align the |\hline| in the row \textsl{i}.
%
% The key |hvlines-except-corners| may take in as value a list of corners (eg: NW,SE).
%
% \subsection*{Changes between versions 5.2 and 5.3}
%
% Keys |c|, |r| and |l| for the command |\Block|.
%
% It's possible to use the key |draw-first| with |\Ddots| and |\Iddots| to
% specify which dotted line will be drawn first (the other lines will be drawn
% parallel to that one if parallelization is activated).
%
% \subsection*{Changes between versions 5.3 and 5.4}
%
% Key |tabularnote|.
%
% Different behaviour for the mono-column blocks.
%
% \subsection*{Changes between versions 5.4 and 5.5}
%
% The user must never put |\omit| before |\CodeAfter|.
%
% Correction of a bug: the tabular notes |\tabularnotes| were not composed when
% present in a block (except a mono-column block).
%
% \subsection*{Changes between versions 5.5 and 5.6}
%
% Different behaviour for the mono-row blocks.
%
% New command |\NotEmpty|.
%
% \subsection*{Changes between versions 5.6 and 5.7}
%
% New key |delimiters-color|
%
% Keys |fill|, |draw| and |line-width| for the command |\Block|.
%
% \subsection*{Changes between versions 5.7 and 5.8}
%
% Keys |cols| and |restart| of the command |\rowcolors| in the |code-before|.
%
% Modification of the behaviour of |\\| in the columns of type |p|, |m| or |b|
% (for a behaviour similar to the environments of \pkg{array}).
%
% Better error messages for the command |\Block|.
%
% \subsection*{Changes between versions 5.8 and 5.9}
%
% Correction of a bug: in the previous versions, it was not possible to use the
% key |line-style| for the continuous dotted lines when the Tikz library |babel|
% was loaded.
%
% New key |cell-space-limits|.
%
% \subsection*{Changes between versions 5.9 and 5.10}
%
% New command |\SubMatrix| available in the |\CodeAfter|.
%
% It's possible to provide options (between brackets) to the keyword |\CodeAfter|.
%
% A (non fatal) error is raised when the key |transparent|, which is
% deprecated, is used.
%
% \subsection*{Changes between versions 5.10 and 5.11}
%
% It's now possible, in the |code-before| and in the |\CodeAfter|, to use the
% syntax \verb+|(i-|j)+ for the Tikz node at the intersection of the (potential)
% horizontal rule number~$i$ and the (potential) vertical rule number~$j$.
%
% \subsection*{Changes between versions 5.11 and 5.12}
%
% Keywords |\CodeBefore| and |\Body| (alternative syntax to the key
% |code-before|).
%
% New key |delimiters/max-width|.
%
% New keys |hlines|, |vlines| and |hvlines| for the command |\SubMatrix| in the
% |\CodeAfter|.
%
% New key |rounded-corners| for the command |\Block|.
%
% \subsection*{Changes between versions 5.12 and 5.13}
%
% New command |\arraycolor| in the |\CodeBefore| (with its key
% |except-corners|).
%
% New key |borders| for the command |\Block|.
%
% New command |\Hline| (for horizontal rules not drawn in the blocks).
%
% The keys |vlines| and |hlines| takes in as value a (comma-separated) list of
% numbers (for the rules to draw).
%
%
% \subsection*{Changes between versions 5.13 and 5.14}
%
% Nodes of the form |(1.5)|, |(2.5)|, |(3.5)|, etc.
%
% Keys |t| and |b| for the command |\Block|.
%
% Key |corners|.
%
% \subsection*{Changes between versions 5.14 and 5.15}
%
% Key |hvlines| for the command |\Block|.
%
% The commands provided by \pkg{nicematrix} to color cells, rows and columns
% don't color the cells which are in the ``corners'' (when the key |corner| is
% used).
%
% It's now possible to specify delimiters for submatrices in the preamble of an
% environment.
%
% The version 5.15b is compatible with the version 3.0+ of \pkg{siunitx}
% (previous versions were not).
%
% \subsection*{Changes between versions 5.15 and 5.16}
%
% It's now possible to use the cells corresponding to the contents of the nodes
% (of the form |i-j|) in the |\CodeBefore| when the key |create-cell-nodes| of
% that |\CodeBefore| is used. The medium and the large nodes are also available
% if the corresponding keys are used.
%
% \subsection*{Changes between versions 5.16 and 5.17}
%
% The key |define-L-C-R| (only available at load-time) now raises a (non fatal)
% error.
%
% Keys |L|, |C| and |R| for the command |\Block|.
%
% Key |hvlines-except-borders|.
%
% It's now possible to use a key |l|, |r| or |c| with the command
% |\pAutoNiceMatrix| (and the similar ones).
%
% \subsection*{Changes between versions 5.17 and 5.18}
%
% New command |\RowStyle|
%
% \subsection*{Changes between versions 5.18 and 5.19}
%
% New key |tikz| for the command |\Block|.
%
%
% \subsection*{Changes between versions 5.19 and 6.0}
%
% Columns |X| and environment |{NiceTabularX}|.
%
% Command |\rowlistcolors| available in the |\CodeBefore|.
%
% In columns with fixed width, the blocks are composed as paragraphs (wrapping
% of the lines).
%
% The key |define-L-C-R| has been deleted.
%
%
% \subsection*{Changes between versions 6.0 and 6.1}
%
% Better computation of the widths of the |X| columns.
%
% Key |\color| for the command |\RowStyle|.
%
% \subsection*{Changes between versions 6.1 and 6.2}
%
% Better compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}.
%
% Key |vlines-in-sub-matrix|.
%
% \subsection*{Changes between versions 6.2 and 6.3}
%
% Keys |nb-rows|, |rowcolor| and |bold| for the command |\RowStyle|
%
% Key |name| for the command |\Block|.
%
% Support for the columns |V| of \pkg{varwidth}.
%
% \subsection*{Changes between versions 6.3 and 6.4}
%
% New commands |\UnderBrace| and |\OverBrace| in the |\CodeAfter|.
%
% Correction of a bug of the key |baseline| (cf. question 623258 on TeX StackExchange).
%
% Correction of a bug with the columns |V| of \pkg{varwidth}.
%
% Correction of a bug: the use of |\hdottedline| and |:| in the preamble of the
% array (of another letter specified by |letter-for-dotted-lines|) was
% incompatible with the key |xdots/line-style|.
%
% \subsection*{Changes between versions 6.4 and 6.5}
%
% Key |custom-line| in |\NiceMatrixOptions|.
%
% Key |respect-arraystretch|.
%
%
% \subsection*{Changes between version 6.5 and 6.6}
%
% Keys |tikz| and |width| in |custom-line|.
%
% \subsection*{Changes between version 6.6 and 6.7}
%
% Key |color| for |\OverBrace| and |\UnderBrace| in the |\CodeAfter|
%
% Key |tikz| in the key |borders| of a command |\Block|
%
% \subsection*{Changes between version 6.7 and 6.8}
%
% In the notes of a tabular (with the command |\tabularnote|), the duplicates
% are now detected: when several commands |\tabularnote| are used with the same
% argument, only one note is created at the end of the tabular (but all the
% labels are present, of course).
%
% \PrintIndex
%
% \tableofcontents
%
% \endinput
% Local Variables:
% TeX-fold-mode: t
% TeX-fold-preserve-comments: nil
% flyspell-mode: nil
% fill-column: 80
% End:
|