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
|
%% LaTeX package xassoccnt - version 1.4 (2017/04/30 -- 00:47:05)
%% Documentation file for xassoccnt.sty
%%
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2015 -- 2017 by Dr. Christian Hupfer <typography dot with dot latex at gmail dot com>
%% -------------------------------------------------------------------------------------------
%%
%% This work 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.
%%
%%
%% This work has the LPPL maintenance status `author-maintained`
%%
%%
\documentclass[12pt,a4paper,oneside]{article}
\usepackage[lmargin=2cm,rmargin=2cm,headheight=15pt]{geometry}
\usepackage{savesym}
\usepackage{bbding}
\savesymbol{Cross}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage[x11names]{xcolor}
\usepackage{imakeidx}
\usepackage{fontawesome}
\usepackage[most,documentation]{tcolorbox}
\usepackage[tikz]{bclogo}
\usepackage{marginnote}
\usepackage{fancyhdr}
\usepackage{datetime}
\usepackage{array}
\usepackage{xkeyval}
\usepackage{xparse}
\usepackage{totcount}
\usepackage{enumitem}
\usepackage{microtype}
\usepackage{caption}
\usepackage[T1]{fontenc}
\usepackage[scaled=0.92]{helvet}
\newlist{codeoptionsenum}{enumerate}{1}
\setlist[codeoptionsenum,1]{label={\textcolor{blue}{\#\arabic*}}}
\renewcommand{\rmdefault}{\sfdefault}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\makeatletter
\define@key{chdoc}{packageauthor}{%
\def\KVchdocpackageauthor{#1}%
}
\define@key{chdoc}{packageauthormail}{%
\def\KVchdocpackageauthormail{#1}%
}
\define@key{chdoc}{filepurpose}{%
\def\KVchdocfilepurpose{#1}%
}
\newcommand{\chdocextractversion}[1]{%
\@nameuse{#1}%
}
\@namedef{xassoccntversion0.1}{v0.1 2016-11-07}
\@namedef{xassoccntversion0.2}{v0.2 2016-11-14}
\@namedef{xassoccntversion0.3}{v0.3 2016-01-08}
\@namedef{xassoccntversion0.4}{v0.4 2016-01-26}
\@namedef{xassoccntversion0.5}{v0.5 2016-02-27}
\@namedef{xassoccntversion0.6}{v0.6 2016-03-05}
\@namedef{xassoccntversion0.7}{v0.7 2016-05-10}
\@namedef{xassoccntversion0.8}{v0.8 2016-06-10}
\@namedef{xassoccntversion0.9}{v0.9 2016-06-19}
\@namedef{xassoccntversion1.0}{v1.0 2016-07-28}
\@namedef{xassoccntversion1.1}{v1.1 2016-10-29}
\@namedef{xassoccntversion1.2}{v1.2 2017-03-03}
\@namedef{xassoccntversion1.3}{v1.3 2017-03-04}
\@namedef{xassoccntversion1.4}{v1.4 2017-04-07}
\newcommand{\authorname}{Autor}
\makeatother
\fancypagestyle{plain}{%
\fancyfoot[L]{\begin{tabular}[t]{l}\PackageDocName\ \packageversion \tabularnewline \textcopyright\ Dr. Christian Hupfer\end{tabular}}%
\fancyfoot[C]{\thepage}%
\fancyfoot[R]{\today}%
\renewcommand{\headrule}{{\color{blue}%
\hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}
\renewcommand{\footrule}{{\color{blue}\vskip-\footruleskip\vskip-\footrulewidth
\hrule width\headwidth height\footrulewidth\vskip\footruleskip}}
\renewcommand{\footrulewidth}{2pt}
\renewcommand{\headrulewidth}{2pt}
}
\newtcolorbox{CHPackageTitleBox}[1][]{%
enhanced jigsaw,
drop lifted shadow,
colback=yellow!30!white,
width=0.8\textwidth,
#1
}
\presetkeys{chdoc}{packageauthor={Christian Hupfer}}{}%
\NewDocumentCommand{\CHPackageTitlePage}{O{}mO{}}{%
\setkeys{chdoc}{packageauthor={Christian Hupfer},filepurpose={Documentation},#1}%
\begin{center}
\begin{CHPackageTitleBox}[#3]
\large \bfseries%
\begin{center}%
\begin{tabular}{C{0.9\textwidth}}%
\scshape \PackageDocName \tabularnewline
\tabularnewline
#2 \tabularnewline
\tabularnewline
\KVchdocfilepurpose \tabularnewline
\tabularnewline
Version \packageversion \tabularnewline
\tabularnewline
\today \tabularnewline
\tabularnewline
\addtocounter{footnote}{2}
\authorname: \KVchdocpackageauthor\(^\mathrm{\fnsymbol{footnote}}\)
\tabularnewline
\end{tabular}
\end{center}
\end{CHPackageTitleBox}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}%
\footnotetext{\mymailtoaddress}%
\end{center}
}
\newtcolorbox{docCommandArgs}[1]{colbacktitle={blue},coltitle={white},title={Description of arguments of command \cs{#1}}}
\newcommand{\tcolorboxdoclink}{http://mirrors.ctan.org/macros/latex/contrib/tcolorbox/tcolorbox.pdf}
% 'Stolen' from tcolorbox documentation ;-)
\newtcolorbox{marker}[1][]{enhanced,
before skip=2mm,after skip=3mm,
boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
colback=yellow!50,
colframe=yellow!20!black,
sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
underlay={%
\path[fill=tcbcol@back!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
\path[draw=tcbcol@frame,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
\path[fill=yellow!50!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=4mm]interior.north west);
},
drop fuzzy shadow,#1}
%%%% Documentation macros
\NewDocumentCommand{\packagename}{sm}{%
\textcolor{blue}{\textbf{\faEnvelopeO~#2}}%
\IfBooleanF{#1}{%
\index{Package!#2}
}%
}
\NewDocumentCommand{\classname}{sm}{%
\textcolor{brown}{\textbf{\faBriefcase~#2}}%
\IfBooleanF{#1}{%
\index{Package!#2}%
}%
}
\NewDocumentCommand{\CHDocPackage}{sm}{%
\textcolor{blue}{\textbf{\faEnvelopeO~#2}}%
\IfBooleanF{#1}{%
\index{Package!#2}
}%
}
\NewDocumentCommand{\CHDocClass}{sm}{%
\textcolor{brown}{\textbf{\faBriefcase~#2}}%
\IfBooleanF{#1}{%
\index{Package!#2}%
}%
}
\NewDocumentCommand{\CHDocKey}{sm}{%
\textcolor{red}{\textbf{\faKey~#2}}%
\IfBooleanF{#1}{%
\index{Option!#2}%
}%
}
\newcommand{\handrightnote}{\tcbdocmarginnote{\ding{43}}}
\NewDocumentCommand{\CHDocCounter}{sm}{%
\textcolor{Green4}{\textbf{\faCalculator~#2}}%
\IfBooleanF{#1}{%
\index{Counter!#2}%
}%
}
\NewDocumentCommand{\CHDocTag}{sm}{%
\textcolor{violet}{\faTag~#2}%
\IfBooleanF{#1}{%
\index{Feature!#2}%
}%
}
\NewDocumentCommand{\CHDocFileExt}{sm}{%
\faFile~#2%
}
\NewDocumentCommand{\CHDocFiles}{sm}{%
\faFilesO~#2%
}
\NewDocumentCommand{\CHDocConventions}{}{%
\section*{\centering Typographical conventions}
Throughout this documentation following symbols and conventions are used:
\begin{itemize}
\item \CHDocClass*{foo} means a the class \texttt{foo}
\item \CHDocPackage*{foo} names a package \texttt{foo}
\item \CHDocCounter*{foo} indicates a counter named \texttt{foo}
\item \CHDocFileExt*{foo} will indicate either a file named \texttt{foo} or a file extension \texttt{foo}
\item \CHDocFiles*{foo} will indicate some files
\item \CHDocTag*{foo} names a special feature or tag \texttt{foo}
\item \CHDocKey*{foo} deals with a command or package option named \texttt{foo}
\end{itemize}
}
\renewcommand{\tcbdocnew}[1]{#1}%
\renewcommand{\tcbdocupdated}[1]{#1}%
\newcommand{\CHDocNew}[1]{%
\tcbdocmarginnote[doclang/new={N},
colframe=blue,
halign=left,
colback={blue!20!white},
fontupper={\tiny}
]{%
\chdocextractversion{xassoccntversion#1}%
}%
}
\newcommand{\CHDocUpdate}[1]{\tcbdocmarginnote[doclang/updated={},colback={yellow},colframe={yellow!50!red}, fontupper={\tiny}
]{%
\tcbdocupdated{\chdocextractversion{xassoccntversion#1}}%
}%
}
\newcommand{\CHDocFullVersion}[1]{Version \chdocextractversion{xassoccntversion#1}}
\newcommand{\CHDocExpCommand}[1][Expandable]{%
\tcbdocmarginnote[doclang/new={N},
colframe=green!50!blue,
halign=left,
colback={green!90!blue},
fontupper={\tiny}
]{%
#1%
}%
}
\newcommand{\CHDocExperimentalFeature}[1][Experimental]{%
\tcbdocmarginnote[doclang/new={N},
colframe=yellow!50!blue,
halign=left,
colback={blue!10!yellow},
fontupper={\tiny}
]{%
#1%
}%
}
\usepackage[T1]{fontenc}
\usepackage{graphicx}%
\usepackage[autodefinecounters=true]{xassoccnt}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{minitoc}
\usepackage{tocbibind}
\usepackage{bookmark}
\usepackage{cleveref}
\usetikzlibrary{mindmap}
\usepackage{url}
\setcounter{tocdepth}{3}
\newcommand{\PackageDocName}{xassoccnt}%
\newcommand{\mymailtoaddress}{%
typography.with.latex@gmail.com%
}
\doparttoc
\let\DeclareAssociatedCountersOrig\DeclareAssociatedCounters % -> for use in examples only
\def\packageversion{\xassoccntpackageversion}%
\makeindex[intoc]
\renewcommand{\rmdefault}{\sfdefault}
\newcounter{foobar}
\newtotcounter{totalpages}%
\newtotcounter{anothertotalpages}%
\newtotcounter{totalproofs}%
\newtotcounter{totalsections}%
\newtotcounter{totalequations}
\newtotcounter{totalsubsections}%
\newtotcounter{othertotalsubsections}%
\DeclareDocumentCounter{foocntr}%
\DeclareDocumentCounter{foobarcntr}%
%%%% Declare all the counters here --
\DeclareAssociatedCounters{subsection}{totalsubsections}%
\DeclareAssociatedCounters{equation}{totalequations}%
\DeclareAssociatedCounters{section}{totalsections}%
\DeclareAssociatedCounters{proof}{totalproofs}
\DeclareAssociatedCounters{page}{totalpages,anothertotalpages}%
\DeclareTotalDocumentCounter{foototal}%
\RegisterTotalDocumentCounter{section}%
\hypersetup{breaklinks=true,
pdftitle={\jobname.pdf -- version \packageversion},
pdfauthor={PACKAGEAUTHOR},
pdfsubject={Documentation of \PackageDocName\ package},
pdfkeywords={LaTeX, counters},
bookmarksopen=true,
bookmarksopenlevel=2,
bookmarksnumbered=true,
pdfcreator={LaTeX}
}
\begin{document}
\yyyymmdddate
\setlength{\parindent}{0em}
\pagestyle{empty}%
\begin{tikzpicture}[mindmap,concept color=red,black,scale=1]
\bfseries
\node [concept] {Counters}
child[concept color=red!30!yellow,grow=30] { node [concept] {Associated counters}}
child[grow=85,white,concept color=red!80!blue] { node [concept] {Backup \& Restore of counters}}
child[grow=300,concept color=yellow!90!red] { node [concept] {Extensions to \LaTeXe} child[grow=230,concept color={yellow!20!green}] {node [concept] {Query macros}}
child[grow=290,concept color={yellow!30!cyan}] {node [concept] {Document counters}}
}
child[grow=-20,white] { node [concept] {Periodically resetting counters}}
child[grow=130,concept color=red!20!green] { node [concept] {Suspension \\ \& Resuming of counters} child[grow=160,concept color=green!10!yellow] {node[concept] {Cascaded suspension}}}
child[grow=170,concept color=red!30!yellow] { node [concept] {Total} child[concept color=yellow!30!,grow=150] {node[concept] {Super total counters}}}
child[grow=260,concept color=red!30!green] { node [concept] {Loops on counters}}
child[grow=200,concept color=red!30!green] { node [concept] {Counter output}}
child[grow=230,concept color=red!20!cyan] { node [concept] {Coupled counters} child [grow=250,concept color=cyan!50!blue] {node[concept] {Coupled counter groups}}}
child[grow=57,concept color=red!20!yellow] { node [concept] {Label}};
\end{tikzpicture}
\CHPackageTitlePage[packageauthor={Christian Hupfer}]{Associated counters stepping simultaneously\\ (and other gadgets)}
\clearpage
\tableofcontents
\clearpage
\CHDocConventions
\clearpage
\pagestyle{plain}
\setcounter{footnote}{0}
\part{Introduction}
\parttoc
\section*{Preface}
This package is the successor and a complete rewrite of \CHDocPackage{assoccnt}. Not all features of that package are implemented yet -- if some functionality of your document depends on \CHDocPackage{assoccnt}, continue using the older version and shift gradually to \CHDocPackage{\PackageDocName} please.
\begin{marker}
Most times class and package authors will benefit of this package, but there might be usual documents that need the features of |\PackageDocName||
\end{marker}
\section{Introduction}
The aim of this package is to provide some additional support for example for a package like \CHDocPackage{totcount}.
For example, the total number of pages in a document could be achieved by using
\begin{dispExample}%
\regtotcounter{page}
...
The number of pages in the document is \number\totvalue{page} page(s) -- but in fact it has \total{totalpages} pages.
\end{dispExample}%
This will work, as long there is no reset of the page counter, as it might happen in the case of \cs{setcounter} or \cs{pagenumbering} being applied in the document. The result is a false page counter total value.
This package provides associate counters, i.e. counters that are increased simultaneously with a driver counter and are not influenced by a a resetting of the driver counter, as long as not being added to the reset list by definition of the counter or explicitly by \cs{@addtoreset}.
This package defines some macros to handle associated counters. The only interception to the standard behaviour is within the redefined commands \cs{addtocounter} and \cs{stepcounter}. The usual commands still work, as there is code added to their definition. In a previous version \cs{refstepcounter} was redefined, but since these use \cs{addtocounter} effectively, it was decided to use the basic command.
Internally, the associated counters are stored in one list per counter -- it is not recommended to operate on those lists directly.
Please note that this package does not provide means for simultaneous stepping of counters defined by plain \TeX{} \cs{newcount} command.\marginnote{\bcbombe}
\section{Requirements, loading and incompatibilities}%
\subsection{Required packages and \TeX\ engine}
The package does not require features from Xe\LaTeX\ or Lua\LaTeX\ but can be run with those features as well as with \LaTeX\ or pdf\LaTeX. The compilation documentation requires however pdf\LaTeX\ as of version \packageversion.
\begin{itemize}
\item \CHDocPackage{xcolor}
\item \CHDocPackage{xparse}
\item \CHDocPackage{l3keys2e}
\end{itemize}
The documentation file requires some more packages such as \CHDocPackage{tcolorbox} but those packages are widely available on CTAN, MikTeX and TeXLive as well.
\subsection{Loading of the package}
Loading is done with
\begin{tcblisting}{listing only}
\usepackage[options]{xassoccnt}
\end{tcblisting}
For the relevant options see \cref{subsection:packageoptions}
Concerning the packages \CHDocPackage{hyperref} and \CHDocPackage{cleveref}: The preferred loading order is the usually recommended on:
\begin{itemize}
\item other packages
\item \CHDocPackage{xassoccnt}
\item \CHDocPackage{hyperref}
\item \CHDocPackage{cleveref}
\end{itemize}
For potential problems see \cref{subsection:incompatibilities}
\subsection{Incompatibilities}\label{subsection:incompatibilities}
\begin{itemize}
\item This package cannot be used with plain \TeX\ and will not provide support for counters (or better counter registers) that have defined with the \TeX\ primitive \cs{countdef} directly in a \LaTeXe\ document nor will it hook into plain \TeX\ \cs{advance} commands used otherwise than in the usual \LaTeXe\ wrappers \cs{addtocounter} etc.
\item This package does not work really well with the \CHDocPackage{calc} package if that one is loaded after \CHDocPackage{\PackageDocName}. Load \CHDocPackage{calc} \textbf{before} \CHDocPackage{\PackageDocName}!
Especially the \CHDocPackage{tcolorbox} bundle loads \CHDocPackage{calc} indirectly, so placing any loading of \CHDocPackage{tcolorbox} modules before \CHDocPackage{\PackageDocName} is mandatory!
\begin{marker}
\tcbdocmarginnote{\bcbombe\tcbdocupdated{2015-11-10}}
As of version \packageversion\ \CHDocPackage{\PackageDocName} will abort compilation if \CHDocPackage{calc} is loaded after this package, but will issue a warning only if \CHDocPackage{calc} is loaded first.
\end{marker}
\begin{marker}
\CHDocUpdate{0.7}
Of course any package other that loads \CHDocPackage{calc} must be loaded before \PackageDocName, i.e. \CHDocPackage{mathtools}.
\end{marker}
\item \CHDocPackage{\PackageDocName} and \CHDocPackage{perpage} are not compatible completely. As of version \packageversion\ it is not possible to use the command \cs{AddAbsoluteCounter} from \CHDocPackage{perpage} -- this feature is provided already by this package.
\tcbdocmarginnote{\tcbdocnew{2015-11-10}}
\begin{marker}
It is not recommended to use counters under control of \CHDocPackage{perpage} with the association method!
\end{marker}
% is somewhat similar to \refCom{AddAssociatedCounters} from this package but unless changed manually, the values of and \texttt{perpage} - absolute counter and an associated counter by this package differ by one, since \cs{AddAbsoluteCounter} initializes the counter value to the value of 1.
%\item This package does not work together when the Package \CHDocPackage{xifthen} is included. As of version \packageversion~I could not figure out, where the strange behaviour comes in. It's most likely an incompatibility between \CHDocPackage{etoolbox} and \CHDocPackage{xifthen}
%\marginnote{\bcbombe}
\end{itemize}
\subsection{Package options}\label{subsection:packageoptions}
As of version \packageversion\ \CHDocPackage{\PackageDocName} supports the package options
\begin{docKey}{autodefinecounters}{=\meta{true,false}}{initially false}
Setting this package option to \texttt{true}, all counters used with the special package macros will be autodefined, unless disabled locally. See the commands
\begin{itemize}
\item \refCom{DeclareAssociatedCounters}
\item \refCom{AddAssociatedCounters}
\end{itemize}
\end{docKey}
\begin{docKey}{nonumberofruns}{}{initially not set}\CHDocNew{0.6}
Using this package option the super total counter \CHDocCounter{numberofruns} counter will not be defined. See \cref{subsection:numberofruns} about this feature.
\end{docKey}
\begin{docKey}{redefinelabel}{=\meta{true,false}}{initially \meta{true}}\CHDocNew{1.2}
\CHDocExperimentalFeature This is an experimental feature as of version \packageversion.
Enables the redefinition of the \refCom{label} command and takes care of the optional argument of \refCom{label} if \CHDocPackage{cleveref} is used. This will provide \refCom{label} with a final optional argument that can be used to allow labels for associated counters (either all or only a specified list of counters), for more on this see \refCom{label} in \namecref{subsec::associated_counters_experimental} \nameref{subsec::associated_counters_experimental}.
\end{docKey}
\begin{docKey}{standardcounterformats}{=\meta{choice=on/off}}{initially \meta{on}}\CHDocNew{1.4}
This key enables (\meta{on}) or disables (\meta{off}) the definition of the standard counter formats to be used in the macro \refCom{CounterFormat}.
\end{docKey}
\clearpage
\part{Tools for counters}
\parttoc
\section[Additions to standard commands]{Additions and extensions to standard counter related commands}\label{section::additions_to_l2e}
\subsection{Extension of \LaTeXe\ commands}\label{subsection::extension_of_l2e_commands}
\begin{docCommand}[before={\CHDocNew{0.9}}]{addtocounter}{\marg{counter}\marg{increment value}\oarg{options}}
The \refCom{addtocounter} macro behaves like the usual \cs{addtocounter} counter, but takes care to specific counter features such as \CHDocTag{periodic counters} and has an optional argument in order to perform special settings.
As of \packageversion, there is only one option used:
\begin{docKey}[][after={\CHDocNew{0.9}}]{wrap}{=\meta{true/false}}{initially true}
This key determines whether addition of values to a periodic counter (see \nameref{section:periodic_counters}) will lead to a modulo part addition.
\end{docKey}
\end{docCommand}
\subsection[\LaTeXe\ additions]{Additions to \LaTeXe\ commands}
\begin{docCommand}{NewDocumentCounter}{\oarg{options}\marg{counter1,counter2,\dots}\oarg{resetting counter}}
This command is a new interface to \cs{newcounter} and behaves effectively the same. %The first optional argument is reserved for later purposes but not used as of version \packageversion.
\begin{docKey}{initial}{=\meta{integer value}}{initially 0}
This is used for the start value of the new counter.
\end{docKey}
\CHDocUpdate{1.2}This command allows multiple counters (specified as a comma separated list) to be defined at once, but all have the same resetting counter then and initial value is the same for all those counters (if those options are given).
\end{docCommand}%
\begin{docCommand}{DeclareDocumentCounter}{\oarg{options}\marg{counter}\oarg{resetting counter}}
This command is the preamble-only version of \refCom{NewDocumentCounter}.
\CHDocUpdate{1.2}This command allows multiple counters (specified as a comma separated list) to be defined at once, but all have the same resetting counter then and initial value is the same for all those counters (if those options are given), i.e. the behaviour is like in \refCom{NewDocumentCounter}.
\end{docCommand}%
\begin{docCommand}{SetDocumentCounter}{\oarg{options}\marg{counter}\marg{counter value}}
This command behaves like the standard macro \cs{setcounter}, but has an additional optional 1st argument. %which is not used as of version \packageversion.
% This optional argument can be used to enable the setting of the driver counter value as well as the associated counter values at once.
\begin{docCommandArgs}{SetDocumentCounter}%
\begin{codeoptionsenum}
\item \oarg{options}: %As of version \packageversion, this option is not used% the key value argument
\begin{docKey}{associatedtoo}{=\meta{true/false}}{initially false}
If enabled (\meta{true}), \refCom{SetDocumentCounter} will use the counter value for \underline{all} counters associated to this driver counter as well. Initially, this option is set to \meta{false}.
\end{docKey}
\begin{docKey}{onlycounters}{=\meta{comma separated list of counters}}{initially empty}
If this key is used, only those associated counters are set as well that are given in the comma separated list.
Names, that are either not referring to counters at all or to counters that are not associated to the given driver counter will be ignored silently.
\end{docKey}
\item \marg{counter}
Holds the name of the (driver) counter to be set.
\item \marg{counter value}
Holds the value to be set
\end{codeoptionsenum}
\end{docCommandArgs}
Some notes on \refCom{SetDocumentCounter}
\begin{itemize}
\item The option keys \refKey{associatedtoo} and \refKey{onlycounters} are mutually exclusive! %
\item The counter to be set can be either a driver counter or an otherwise associated counter.
\end{itemize}
\end{docCommand}%
\begin{docCommand}{StepDownCounter}{\oarg{options}\marg{counter}}\CHDocNew{0.4}
This macro subtracts the value of 1 from the counter and is the counterpart of \cs{stepcounter}.
\begin{docCommandArgs}{StepDownCounter}%
\begin{codeoptionsenum}
\item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
\item \marg{counter}
Holds the name of the first counter.
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}%
\begin{docCommand}{SubtractFromCounter}{\oarg{options}\marg{counter}\marg{delta value}}\CHDocNew{0.4}
This macro subtracts the (positive) delta value from the counter and is the counterpart of \cs{addtocounter}
\begin{docCommandArgs}{SubtractFromCounter}%
\begin{codeoptionsenum}
\item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
\item \marg{counter 1}
Holds the name of the first counter.
\item \marg{delta value}
Holds the (positive) value to be subtracted from the counter value.
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}%
\begin{docCommand}{CopyDocumentCounters}{\oarg{options}\marg{source counter}\marg{target counter}}
This document copies the counter value from the source counter in argument 2 to the target counter in argument 3.
\begin{docCommandArgs}{CopyDocumentCounters}%
\begin{codeoptionsenum}
\item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
\item \marg{source counter}
Holds the name of the source counter.
\item \marg{target counter}
Holds the name of the target counter.
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}%
\begin{docCommand}{SwapDocumentCounters}{\oarg{options}\marg{counter 1}\marg{counter 2}}
This macro swaps the values of the counters given in arguments 2 and 3
\begin{docCommandArgs}{SwapDocumentCounters}%
\begin{codeoptionsenum}
\item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
\item \marg{counter 1}
Holds the name of the first counter.
\item \marg{counter 2}
Holds the name of the second counter.
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}%
\begin{docCommand}{SyncCounters}{\oarg{options}\marg{driver counter}}
This document synchronizes the driver counter value to the associated values. It has the same options as \refCom{SetDocumentCounter}. If the given counter is no driver counter, nothing is done.
\begin{docCommandArgs}{SyncCounters}%
\begin{codeoptionsenum}
\item \oarg{options}: see \refCom{SetDocumentCounter}
\item \marg{source counter}
Holds the name of the source counter.
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}%
\begin{dispExample}%[breakable=true]
\SetDocumentCounter{foocntr}{17}
\SetDocumentCounter{foobarcntr}{20}
\begin{itemize}
\item Displaying counters
\thefoocntr\ and \thefoobarcntr
\item Swapping counters
\SwapDocumentCounters{foocntr}{foobarcntr}
\thefoocntr\ and \thefoobarcntr
\item Step down counters
\StepDownCounter{foocntr}
\StepDownCounter{foobarcntr}
\thefoocntr\ and \thefoobarcntr
\item Subtracting some value from the counters
\SubtractFromCounter{foocntr}{5}
\SubtractFromCounter{foobarcntr}{10}
\thefoocntr\ and \thefoobarcntr
\end{itemize}
\end{dispExample}
\subsection[\protect\cs{IfIsDocumentCounter}-Queries]{Commands checking whether a name refers to a counter}
\CHDocPackage{\PackageDocName}\ provides three commands that are quite similar -- all check whether \marg{name} is an already defined \LaTeXe\ counter (name), in good tradition with the \CHDocPackage{xparse} - syntax:
\begin{itemize}
\item \begin{docCommand}{IfIsDocumentCounterTF}{\oarg{}\marg{name}\marg{true branch}\marg{false branch}}
This macro performs the full branching
\end{docCommand}
\item
\begin{docCommand}{IfIsDocumentCounterT}{\oarg{}\marg{name}\marg{\meta{long} true branch}}
This command executes only if the name is a counter.
\end{docCommand}
\begin{docCommand}{IfIsDocumentCounterF}{\oarg{}\marg{name}\marg{true branch}}
This command executes only if the name is not a counter.
\end{docCommand}
\end{itemize}
The optional argument is not used as of version \packageversion\ for none of those three commands.
\subsection[Information macros]{Information on counters} \label{subsection::informationcmds}
On occasions it might be important to have some information which counter has been changed last. Since there are four commands manipulating counter values, there are four corresponding routines for this:
\begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{LastAddedToCounter}{}
This command has no arguments and expands to the name of the counter which was used last in \cs{addtocounter}. There is no further typesetting done with the countername.
\begin{dispExample}
\newcounter{SomeCounter}
\addtocounter{SomeCounter}{10}
The last counter something added to was \LastAddedToCounter.
\end{dispExample}%
\end{docCommand}%
\begin{marker}
Please note that \refCom{LastAddedToCounter} might fail!
\end{marker}
\begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{LastSteppedCounter}{}
This command has no arguments and expands to the name of the counter which was stepped last using \cs{stepcounter}. There is no further typesetting done with the countername.
\begin{dispExample}
\stepcounter{SomeCounter}
The last counter being stepped was \LastSteppedCounter.
\end{dispExample}%
\end{docCommand}%
\begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{LastRefSteppedCounter}{}
This macro gives the last counter being used in \cs{refstepcounter} and is expandable.%{\ChDocVersion{1.3}}
\begin{dispExample}
\begin{equation}
E = mc^2 \label{eq::einstein}
\end{equation}
% \stepcounter{SomeCounter}
The last counter being refstepped was \LastRefSteppedCounter.
\end{dispExample}%
\end{docCommand}%
\begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{LastSetCounter}{}
This command has no arguments and expands to the name of the counter which was set last using \cs{setcounter}. There is no further typesetting done with the countername.
\begin{dispExample}
\setcounter{SomeCounter}{21}%
The last counter being set was \LastSetCounter.
\end{dispExample}%
\end{docCommand}%
\begin{docCommand}{LastCounterValue}{}
This command has no arguments and expands to the value of the very last change of a counter, i.e. using \cs{setcounter} etc.
\begin{dispExample}
\setcounter{SomeCounter}{100}%
The last counter being set was \LastSetCounter and it had the value \LastCounterValue{} then, where as \stepcounter{equation} will yield \fbox{\LastSteppedCounter} and \LastCounterValue!
\end{dispExample}%
The usage of \refCom{LastSetCounter} is best together with one of the other \cs{Last...} macros.
\end{docCommand}%
\begin{marker}
All of the \cs{Last...} macros are expandable, i.e. it is possible to store the value to an macro defined with \cs{edef}
\end{marker}
\begin{dispExample}
\setcounter{SomeCounter}{50}%
\edef\lastcounterset{\LastSetCounter}
\edef\lastcountervalue{\LastCounterValue}
\setcounter{equation}{81}%
The last counter being set was \fbox{\LastSetCounter} and it had the value \LastCounterValue{} then, but we changed \lastcounterset{} earlier and it had the value \lastcountervalue{} then.
\end{dispExample}%
\setcounter{equation}{1}
\begin{marker}
Please note, that all of this commands are only working in the current run of compilation, i.e. \underline{after} there has been some operation on the counters. They can't be used for information on the last changed counter in a previous run.
\end{marker}
\section{Counter reset lists}
The package \CHDocPackage{chngcntr} offers the possibility of add or remove counters to the reset list of a driver counter with the commands \cs{counterwithin} and \cs{counterwithout}, whereas the package \CHDocPackage{remreset} provides \cs{@removefromreset} as a counterpart to the \LaTeXe\ core command \cs{@addtoreset} macro.
\subsection[Addition and Removal]{Addition and Removal of counters from the reset list}\CHDocNew{1.0}
\begin{docCommand}[before={\CHDocNew{1.0}\CHDocUpdate{1.4}}\par]{RemoveFromReset}{\marg{counter name1, counter name2,\dots}\marg{driver counter name}}
This macro removes the counters given in the comma separated list in the first argument from the reset list of the driver counter given in the 2nd argument.
If the 2nd argument does not point to a \LaTeXe\ counter name an error message is shipped and the compilation fails.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0},\CHDocUpdate{1.4}}\par]{RemoveFromFullReset}{\marg{counter name1, counter name2,\dots}\marg{driver counter name}}
This macro removes the counters given in the comma separated list in the first argument and all of its own reset list from the reset list of the driver counter given in the 2nd argument.
If the 2nd argument does not point to a \LaTeXe\ counter name an error message is shipped and the compilation fails.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.4}}]{ClearCounterResetList}{\marg{driver counter name}}
This macro removes all counters of the given driver counter reset list. The individual counter formatting macros \cs{theX} are reset both for the driver counter as well as the counters in the reset list to use the \cs{arabic} standard output macro. \texttt{X} means some arbitray \LaTeX2e\ counter name.
If the resetting shall not be applied, use \refCom{ClearCounterResetList*} instead.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.4}}]{ClearCounterResetList*}{\marg{driver counter name}}
This behaves like \refCom{ClearCounterResetList} but does \textbf{not} reset the relevant \cs{theX} macros.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0}\CHDocUpdate{1.4}}]{AddToReset}{\marg{counter name1, counter name2,\dots}\marg{driver counter name}}
This macro adds the counters given in the comma separated list in the first argument to the reset list of the driver counter given in the 2nd argument.
If the 2nd argument does not point to a \LaTeXe\ counter name an error message is shipped and the compilation fails.
An accidental specificiation of the driver counter to be added to its own reset list is ignored internally.
\end{docCommand}
\subsection[Information macros about the reset list]{Information macros about the counter reset list}
Sometimes it might be necessary or convenient to know how many counters are on a reset list of some other counters, i.e. added by \cs{newcounter}\textbraceleft counter\textbraceright[resetting counter] or \refCom{NewDocumentCounter}.
There are some macros that provide this information:
\begin{docCommand}{countersresetlistcount}{\marg{counter name}}
This macro determines the number of counters being in the reset list of the counter specified as mandatory argument.
Please note: This command isn't expandable. The number is stored internally to another macro, which can be accessed with \refCom{getresetlistcount}, which returns a pure integer number.
\end{docCommand}
\begin{docCommand}{getresetlistcount}{}
This macro returns the number of counters being in the reset list of the counter specified as mandatory argument. It needs a previous call of \refCom{countersresetlistcount} first!
If the counter has no other counters in its reset list, the value of 0 is returned.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0}}\par]{CounterFullResetList}{\marg{counter name}}
This macro determines the full reset list of a counter as well of the counters being on the reset list, i.e. the list is tracked down until there are no counters left in a recursion.
The counter names are stored internally in \CHDocPackage{expl3} - \cs{seq} - variable named \cs{xy\_fullresetlist\_seq} -- the \meta{xy} is replaced by the counter name, e.g. if the counter is named \CHDocCounter*{foo}, the identifier would be \cs{foo\_fullresetlist\_seq}. Unless \CHDocTag{expl3} features are not applied, the \refCom{CounterFullResetList} is not really useful on a document or package/class developing level. However, to loop through the full reset list with some action performed on the members of the sequence, the command \refCom{LoopFullCounterResetList} may be very useful.
\begin{marker}
\begin{itemize}
\item The driver counter \CHDocCounter*{foo} is not added to the relevant sequence.
\item If the name given to \refCom{CounterFullResetList} does not indicate a \LaTeXe\ counter an error message is shipped and the compilation fails.
\end{itemize}
\end{marker}
\end{docCommand}
\begin{docCommand}{IfInResetListTF}{\oarg{}\marg{resetting counter}\marg{reset counter}\marg{true branch}\marg{false branch}}
This command sequence tests whether the counter \meta{reset counter} is in the reset list of \meta{resetting counter} and expands the relevant branch then.
See the short-circuit commands \refCom{IfInResetListT} and \refCom{IfInResetListF} as well.
\end{docCommand}
\begin{docCommand}{IfInResetListT}{\oarg{}\marg{resetting counter}\marg{reset counter}\marg{true branch}}
This command sequence tests whether the counter \meta{reset counter} is in the reset list of \meta{resetting counter} and expands to the true branch.
See the related commands \refCom{IfInResetListTF} and \refCom{IfInResetListF} as well.
\end{docCommand}
\begin{docCommand}{IfInResetListF}{\oarg{}\marg{resetting counter}\marg{reset counter}\marg{false branch}}
This command sequence tests whether the counter \meta{reset counter} is not in the reset list of \meta{resetting counter} and expands to the false branch.
See the related commands \refCom{IfInResetListTF} and \refCom{IfInResetListT} as well.
\end{docCommand}
\begin{docCommand}{DisplayResetList}{\oarg{separator={,}}\marg{resetting counter}}\CHDocNew{0.8}
This command displays the reset list of a counter as a separated list. If the counter has no resetting list, nothing is shown.
\begin{docCommandArgs}{DisplayResetList}%
\begin{codeoptionsenum}
\item \oarg{separator}%
This separator is used for display, it defaults to a comma character.
\item \marg{resetting counter}%
Contains the name of counter whose resetting list should be displayed.
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}
\begin{docCommand}{ShowResetList}{\marg{resetting counter}}\CHDocNew{0.8}
This command displays the reset list of a counter on the terminal as the \cs{show} command would do. This is rather useful for debugging purposes only.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.3}}]{GetAllResetLists}{}
This determines all reset lists and stores the information internally. It should be called right before \cs{begin{document}} or at any time inside the document environment, when new counters are added there (which is not recommended)
The information can be retrieved with \refCom{GetParentCounter}.
\end{docCommand}
\begin{docCommand}[before={\CHDocExpCommand\par\CHDocNew{1.3}}]{GetParentCounter}{\marg{counter}}
This macro tries to detect the counter that was responsible for the resetting of the counter named \marg{counter} and is expandable.
In order to minimize the amount of searching and maintaining expandability, the counter reset data must be stored beforehand, i.e. with \refCom{GetAllResetLists}.
\begin{marker}
If a counter has been added to more than one parent counter as their resetting driver counter, only the most recent addition is in action. This may be correct in some occasions but there is no guarantee that the given counter name really caused the last reset of the counter given as argument.
\end{marker}
\end{docCommand}
\section[Loops on multiple counters]{Performing the same action for many counters} \CHDocNew{0.7}
Sometimes it might be necessary to set the values of many counters at once. This can be done with consecutive \cs{setcounter} statements, for example. This poses no problem, but might become tedious if there are more than three counters or if this task occurs more than once. \CHDocPackage{\PackageDocName} provides some macros that can do the usual operations like stepping, refstepping, adding to, resetting or setting counter values.
All macros concerning this feature use the first macro argument having a comma-separated list of counters. Whether there's a second argument depends on the specific nature of the operation that should be performed.
\begin{marker}
\begin{itemize}
\item As of version \packageversion\ \PackageDocName\ does not check whether the names given in the first argument refer to counters.
\item All macros use the extended counter macros, i.e. are aware of associated counters and step them too if their driver counter is given in the argument list. If an associated counter itself is given in the list, this one is stepped or operated on too!
\end{itemize}
\end{marker}
\begin{docCommand}[before={\CHDocNew{0.7}}]{LoopAddtoCounters}{\marg{counter1, counter2,\dots}\marg{counter increment/decrement}}
%\begin{docCommandArgs}{LoopAddToCounters}%
The 2nd argument value is added (or subtracted) to the counters given in the list of the 1st argument using the \cs{addtocounter}.
\begin{codeoptionsenum}
\item \marg{counter1, counter2,\dots}
Holds the comma separated list of counter names
\item \marg{counter increment/decrement}
Specifies the value to be added or subtracted.
No check is performed whether \#2 \textbf{is} or \textbf{expands} to an integer value.
\end{codeoptionsenum}
%\end{docCommandArgs}
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{0.7}}]{LoopResetCounters}{\marg{counter1, counter2,\dots}}
%\begin{docCommandArgs}{LoopResetCounters}%
All counters given in the first argument are set to zero using the regular \cs{setcounter}. This is a shorthand version of \refCom{LoopSetCounters} for this specific case.
\begin{codeoptionsenum}
\item \marg{counter1, counter2,\dots}
Holds the comma separated list of counter names
\end{codeoptionsenum}
%\end{docCommandArgs}
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{0.7}}]{LoopRefstepCounters}{\marg{counter1, counter2,\dots}}
%\begin{docCommandArgs}{LoopStepCounters}%
All counters given in the first argument are stepped using the regular \cs{refstepcounter} to allow labels -- however, only the last counter will have the correct label reference.
\begin{marker}
This macro is meant only to complete the number of \cs{Loop...Counters} but is not regarded as being really useful.
\end{marker}
\begin{codeoptionsenum}
\item \marg{counter1, counter2,\dots}
Holds the comma separated list of counter names
\end{codeoptionsenum}
%\end{docCommandArgs}
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{0.7}}]{LoopSetCounters}{\marg{counter1, counter2,\dots}\marg{new counter value}}
%\begin{docCommandArgs}{LoopAddToCounters}%
The 2nd argument value is used as new counter value added (or subtracted) to the counters given in the list of the 1st argument using the \cs{addtocounter}.
\begin{codeoptionsenum}
\item \marg{counter1, counter2,\dots}
Holds the comma separated list of counter names
\item \marg{new counter value}
Specifies the value to be set.
No check is performed whether \textbf{is} or \textbf{expands} to an integer value.
\end{codeoptionsenum}
%\end{docCommandArgs}
\end{docCommand}
\begin{docCommand}{LoopStepCounters}{\marg{counter1, counter2,\dots}} \CHDocNew{0.7}
\begin{docCommandArgs}{LoopStepCounters}%
All counters given in the first argument are stepped using the regular \cs{stepcounter}.
\begin{codeoptionsenum}
\item \marg{counter1, counter2,\dots}
Holds the comma separated list of counter names
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}
A more general command for doing "arbitrary" operations with counters (and more setup, for example) is
\begin{docCommand}{LoopCountersFunction}{\marg{counter1, counter2,\dots}\marg{counter operation macro}} \CHDocNew{0.7}
\begin{docCommandArgs}{LoopAddToCounters}%
The 2nd argument value should hold a macro with any number of arguments, but the last mandatory argument of this macro is reserved for counter name.
\begin{codeoptionsenum}
\item \marg{counter1, counter2,\dots}
Holds the comma separated list of counter names
\item A macro name that is to be called and that operates on a counter.
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}
\begin{dispExample}
% We assume we have the counters foocntr and foobarcntr
\newcommand{\showcountervalues}[2]{%
\textcolor{#1}{\csname the#2\endcsname}% Now, an extra empty line to show the values in rows
}
% Note that the 2nd argument is not given here -- it's added by the \LoopCountersFunction macro
\LoopCountersFunction{foocntr,foobarcntr}{\showcountervalues{blue}}
\end{dispExample}
\begin{docCommand}[before={\CHDocNew{1.4}}\par]{LoopCounterResetList}{\marg{counter name}\marg{counter operation macro}}
This macro will perform the same action on the reset list of a the counter name given as first argument, the action is a control sequence name specified by the in the second mandatory argument. The loop provides all counters on the reset list of a counter.
As of version \packageversion\ the counter operation macro must have two mandatory arguments, the second one is meant for the current counter in the loop.
Do not confuse this command with \refCom{LoopFullCounterResetList} which tracks all counters recursively on the reset list, so \refCom{LoopCounterResetList} steeps only level down in the reset list hierarchy.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0}}\par]{LoopFullCounterResetList}{\marg{counter name}\marg{counter operation macro}}
This macro determines the full reset list of a counter, i.e. it cascades down the reset list and tracks the reset lists of all 'sub'-counters too and performs the counter operation macro on this.
\begin{codeoptionsenum}
\item \marg{counter name}
Holds the comma separated list of counter names
\item \marg{counter operation macro}
A macro name that is to be called and that expects the name of a counter as the last argument.
\end{codeoptionsenum}
See the macro \refCom{CounterFullResetList} for more information about the internal storage of the full reset list.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.4}}\par]{CounterWithin}{\marg{counter nameA, counter nameB,\dots}\marg{drivercounter}}
This macro sets all counters nameA, nameB, \dots to the reset list of the \marg{drivercounter} and redefines the corresponding macros \cs{thenameA}, etc. to be prepended with \cs{thedrivercounter}, i.e. \verb!\CounterWithin{equation}{section}! would mean that \verb!\theequation! expands to \verb!\thesection.\arabic{section}!
The default format for the counter output is arabic numbers, i.e. \cs{arabic} will be used.
If the macros \cs{thenameA} etc. should not be changed, use the starred version of this command: \refCom{CounterWithin*}.
\begin{marker}
Please note that the redefinition of \cs{thenameA} etc. is only local, i.e. it is group safe.
\end{marker}
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.4}}\par]{CounterWithin*}{\marg{counter nameA, counter nameB,\dots}\marg{drivercounter}}
This macro sets all counters nameA, nameB, \dots to the reset list of the \marg{drivercounter}, but does not change the corresponding macros \cs{thenameA}, etc. at all.
The default format for the counter output is arabic numbers, i.e. \cs{arabic} will be used.
If the macros \cs{thenameA} etc. should be changed, use non-starred version of this command: \refCom{CounterWithin}.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.4}}\par]{CounterWithout}{\marg{counter nameA, counter nameB,\dots}\marg{drivercounter}}
This macro removes all counters nameA, nameB, \dots from the reset list of the \marg{drivercounter} and redefines the corresponding macros \cs{thenameA}, etc. without \cs{thedrivercounter}, i.e. \verb!\CounterWithout{equation}{section}! would mean that \verb!\theequation! expand to \verb!\arabic{section!
The default format for the counter output is arabic numbers, i.e. \cs{arabic} will be used.
If the macros \cs{thenameA} etc. should not be changed, use the starred version of this command: \refCom{CounterWithout*}.
\begin{marker}
Please note that the redefinition of \cs{thenameA} etc. is only local, i.e. it is group safe.
\end{marker}
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.4}}\par]{CounterWithout*}{\marg{counter nameA, counter nameB,\dots}\marg{drivercounter}}
This macro removes all counters nameA, nameB, \dots from the reset list of the \marg{drivercounter}, but does not redefine the corresponding macros \cs{thenameA}, etc.
If the macros \cs{thenameA} etc. should be changed, use the non-starred version of this command: \refCom{CounterWithout}.
\end{docCommand}
\section{Counter output}\CHDocNew{0.7}
Once in a while it might be necessary to provide counter output not only as integer numbers, letters or Roman figures but also using binary, octal or hexdecimal number output. The \CHDocPackage{fmtcount} package has support for this already -- here are some alternatives.
\subsection{Extra counter output types}
\begin{marker}
None of the commands checks whether the argument refers to counter name.
\end{marker}
\begin{docCommand}[doc new={\chdocextractversion{xassoccntversion0.7}}]{BinaryValue}{\marg{counter name}}
This command will print the value of the counter using binary digits.
\end{docCommand}
\begin{docCommand}{hexValue}{\marg{counter name}} \CHDocNew{0.7}
This command will print the value of the counter using lowercase hexadecimal digits.
\end{docCommand}
\begin{docCommand}{HexValue}{\marg{counter name}} \CHDocNew{0.7}
This command will print the value of the counter using uppercase hexadecimal digits.
\end{docCommand}
\begin{docCommand}{OctalValue}{\marg{counter name}} \CHDocNew{0.7}
This command will print the value of the counter using octal digits.
\end{docCommand}
\begin{docCommand}{xalphalph}{\marg{counter name}}\CHDocNew{1.4}
This is allows to use more than 26 characters for the usual alphabet and prints the counter value with style \texttt{aa} etc. in the same manner as the \CHDocPackage{alphalph} does, but with the \cs{int\_to\_alph:n} macro from the \CHDocPackage{expl3} bundle. For usage with uppercase characters see \refCom{xAlphAlph}.
\end{docCommand}
\begin{docCommand}{xAlphAlph}{\marg{counter name}}\CHDocNew{1.4}
This is allows to use more than 26 characters for the usual alphabet and prints the counter value with style \texttt{AA} etc. in the same manner as the \CHDocPackage{alphalph} does, but with the \cs{int\_to\_Alph:n} macro from the \CHDocPackage{expl3} bundle. For usage with uppercase characters see \refCom{xalphalph}.
\end{docCommand}
\subsection{Quick counter output changes}\CHDocNew{1.4}
\begin{docCommand}{CounterFormat}{\oarg{options}\marg{counter1!formatname1,counter2!formatname2,\dots }}\CHDocNew{1.4}
\begin{marker}
This macro needs the package option \refKey{standardcounterformats} to be activated with \meta{standardcounterformats=on}, which is the default.
\end{marker}
\begin{codeoptionsenum}
\item \oarg{options}
\begin{docKey}[][]{recursive}{=\meta{true/false}}{default: false}
If this key is set, the same counter format is used for the relevant counter and its resetting counters, i.e. the macro will pursue the reset counter list chain and recursively adds \cs{the...} to the output format of \cs{thenameA} etc.
\begin{marker}
Since the \meta{recursive} option needs information on the parent counters, the macro \refCom{GetAllResetLists} must have been called before \refCom{CounterFormat} with this option can be applied. In order to provide the most recent information (which includes recently added counters or changed resetting levels), use \refCom{GetAllResetLists} just before \refCom{CounterFormat}.
\end{marker}
\end{docKey}
\begin{docKey}[][]{separator}{=\meta{separator character/string}}{default: !}
Specifies the separator that is used to split the counter name from the format, e.g. \meta{chapter!R} where \meta{chapter} is the counter name and \meta{R} will be recognized as a counter format, meaning \cs{Roman} here, see \cref{table--predefined-counter-formats} for a list of predefined counter formats.
\begin{marker}
The chosen separator must be the same for all counters in the given list of the 2nd argument (see below) and mustn't occur in the counter name itself\footnote{It is not recommended to use counter names with non alphabetic characters anyway.}.
\end{marker}
\end{docKey}
\item \marg{counter1!formatname1,counter2!formatname2,\dots}
A comma separated list of counters with a given format name, each separated with a separator charactor, default is \meta{!}. If the format is omitted, the default format is \cs{arabic}, i.e. arabic numbers are used.
\end{codeoptionsenum}
\end{docCommand}
\begin{table}[htpb]
Currently following counter formats shorthands and their output macros are stored in \cs{AtBeginDocument} if the package option \refKey{standardcounterformats} is set to on, which is the default behaviour of the package.
\centering
\begin{tabular}{ll}
a & \cs{alph} \tabularnewline
A & \cs{Alph} \tabularnewline
aa & \refCom{xalphalph} \tabularnewline
AA & \refCom{xAlphAlph} \tabularnewline
b & \refCom{BinaryValue} \tabularnewline
h & \refCom{hexValue} \tabularnewline
H & \refCom{HexValue} \tabularnewline
n & \cs{arabic} \tabularnewline
o & \refCom{OctalValue} \tabularnewline
r & \cs{roman} \tabularnewline
R & \cs{Roman} \tabularnewline
\end{tabular}
\caption[List of predefined counter formats]{List of predefined counter format shorthands -- please note that \meta{n} has been used in order to allow \meta{a} to be used for output with lowercase characters.}\label{table--predefined-counter-formats}
\end{table}
\begin{dispExample*}{title=Simple usages of \refCom{CounterFormat},breakable}
% Assume foobar is a defined counter
\setcounter{foobar}{17}
\CounterFormat{foobar!b}
\thefoobar
\CounterFormat{foobar!h}
\thefoobar
\CounterFormat{foobar!H}
\thefoobar
\CounterFormat{foobar!R}
\thefoobar
\setcounter{foobar}{30}
\CounterFormat{foobar!aa}
\thefoobar
\CounterFormat{foobar!o}
\thefoobar
\CounterFormat{foobar!AA}
\thefoobar
\end{dispExample*}
\begin{dispExample*}{title={Showing the \meta{recursive} option of \refCom{CounterFormat}},breakable}
% All counters are using \arabic by default from \newcounter or \NewDocumentCounter
\NewDocumentCounter{foolevelzero}
\NewDocumentCounter{foolevelone}[foolevelzero]
\NewDocumentCounter{fooleveltwo}[foolevelone]
% Get the current reset lists! (Important}
\GetAllResetLists
% Now change to Hex format (!H) for all counters in the hierarchy.
\CounterFormat[recursive]{fooleveltwo!H}
\setcounter{foolevelzero}{20}% Should be 14
\setcounter{foolevelone}{15}% Should be F
\setcounter{fooleveltwo}{10}% Should be A
\thefoolevelzero % -> 14
\thefoolevelone % 14.F
\thefooleveltwo % 14.F.A
\end{dispExample*}
\begin{docCommand}{StoreCounterFormats}{\oarg{options}\marg{formatshorthandA!formatmacroA,formatshorthandB!formatmacroB,\dots}}\CHDocNew{1.4}
Stores the counter formats separated by the separator charactor as given in the option to the global list. Existing formats will be overwritten if the format shorthand already exists. There is no warning about this!
The only handled option is \refKey{separator} and has the same meaning as in \refCom{CounterFormat}.
The formatmacro must be a command sequence with exactly one mandatory argument, which may not be specified in the format storage process.
\begin{marker}
This macro will become a preamble-only command most likely.
\end{marker}
\end{docCommand}
\begin{dispExample}
\StoreCounterFormats{foo!\Roman,foobarnice!\OctalValue}
\setcounter{foobar}{17}
\CounterFormat{foobar!foo}
\thefoobar
\CounterFormat{foobar!foobarnice}
\thefoobar
\end{dispExample}
\begin{docCommand}{AddCounterFormats}{\oarg{options}\marg{formatshorthandA!formatmacroA,formatshorthandB!formatmacroB,\dots}}\CHDocNew{1.4}
Adds the counter formats separated by the separator charactor as given in the option to the global list, similar to \refCom{StoreCounterFormats}. Existing formats will be overwritten if the format shorthand already exists. There is no warning about this!
The only handled option is \refKey{separator} and has the same meaning as in \refCom{CounterFormat}.
The formatmacro must be a command sequence with exactly one mandatory argument, which may not be specified in the format storage process.
\end{docCommand}
\begin{docCommand}{RemoveCounterFormats}{\oarg{options}\marg{formatshorthandA,formatshorthandB,\dots}}\CHDocNew{1.4}
Removes the given counter formats from the global list.
The optional argument is ignored as of version \packageversion.
\end{docCommand}
\clearpage
\part{Features}
\parttoc
\section{Associated counters}
\tcbset{color command={blue}}
The main purpose of this package is co-stepping of counters, but there are some helper commands in addition to macros provided \LaTeXe\ already, see section \nameref{section::additions_to_l2e}.
\begin{itemize}
\item Section \nameref{subsection::associatedcounterscmds} describes the most important macros for setting up associated counters
\item Section \nameref{subsection::drivercounterscmds} informs about the macros for setting up, removing or clearing driver counters
\item Section \nameref{subsection::querycmds} deals with query command sequences about counters being a driver or an associated counters
\item Section \nameref{subsection::informationcmds} contains routines that show which counters have been changed last
\end{itemize}
\subsection[Association macros]{Associated counters commands}\label{subsection::associatedcounterscmds}
All macros have the general rule, that the driver counter is specified as 1st mandatory argument to the macro, which is in almost all cases the 2nd argument of the macro.
\begin{docCommand}{DeclareAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
This command is the main macro of the package. It declares the counter names being specified in comma - separated - list (CSV) which should be stepped simultaneously when the driver counter is increased by \cs{stepcounter}. If only counter is to be associated, omit a trailing ","!
%\begin{docCommandArgs}{DeclareAssociatedCounters}
\begin{codeoptionsenum}
\item \oarg{options}: %As of \packageversion, the optional argument \oarg{options} is not used so far, but is reserved for later purposes.
\begin{docKey}[][]{autodefine}{=\meta{choice}}{initially none}
This choice - key can be specified if the specified counters should be defined if they not already available.
Possible values are
\begin{itemize}
\item \texttt{none} -- no counter is autodefined
\item \texttt{all} -- all counters will be autodefined
\item \texttt{driver} -- only driver counters will be autodefined
\item \texttt{associated} -- only associated counters will be autodefined
\end{itemize}
\end{docKey}
Default is \texttt{none}
\begin{docKey}[][]{sloppy}{}{}
If \refKey{autodefine} key is used, the \texttt{sloppy} key disables the check whether a counter is defined already.
\end{docKey}
\item \marg{driver counter}
Holds the name of the driver counter to which the list of counters should be associated
\item \marg{associated counters list}
A comma separated list of counter names that should be associated to the driver counter
\end{codeoptionsenum}
%\end{docCommandArgs}
\begin{itemize}
\item This command is a preamble command, i.e. it can be used in the preamble of the document or within other packages or class files only.
\item This command should be used as early as possible, i.e. in the preamble of the document, since the driven counters are not increased as long as they are not associated to the driver counter. On the hand, it is possible or may be required to control the starting point of the association at any position in the body of the document, when the association should start later on. Use the command \refCom{AddAssociatedCounters} if counters should be associated within the document body.
\end{itemize}
% Relax for documentation purposes
\renewcommand{\DeclareAssociatedCounters}[3][]{\relax}%
\begin{dispExample}
%%%% The association of anothertotalpages in this example just takes place here, so the stepping of the counter will start from here and providing a 'wrong' value.
%%%%
\DeclareAssociatedCounters{page}{totalpages,anothertotalpages}%
This document has \number\totvalue{totalpages} (note: \number\totvalue{anothertotalpages}) pages.
\end{dispExample}
\begin{itemize}
\item Current version (\packageversion) rules:
\begin{itemize}
\item No checking whether the 2nd and 3rd arguments hold counter names is applied.
\item Mutually cross - association of two counters is not supported! The compilation will stop on this!
\CHDocUpdate{0.6}
A driver counter, say, \CHDocCounter{foo}) of, say \CHDocCounter{foobar} can not be an associated counter of \CHDocCounter{foobar}, which in turn can be a driver counter of other counters, of course.
A contrary feature are the \CHDocTag{coupled counters} -- If some counters should share a common base, i.e. increasing one arbitrary member counter of a group of counters then all should be increased, this called coupling of counters -- all group members are on an equal footing. See \cref{sec::coupledcounters} about this feature.
On the other side, \CHDocTag{associated counters} belong to a hierarchy. The driver counter dominates the associated counters.
\end{itemize}
\item A self-association of the driver counter to itself is ignored internally as this would lead to inconsistent counter values.
\item The order of the specification of associated counters in the 2nd arguments is of no importance.
\item Specifing an associated counter name multiple times has no effect, only the first occurence of the name will be used.
\end{itemize}
\end{docCommand}
\begin{docCommand}{AddAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
The usage of this macro is similar to \refCom{DeclareAssociatedCounters}; if it is called in the document preamble (or in package file), \refCom{AddAssociatedCounters} falls back to
\begin{center}\refCom{DeclareAssociatedCounters},\end{center} having the same optional argument functionality with \refKey{autodefine} and \refKey{sloppy}; if it is called in the document body, this command adds some counters to the associated counter list for a specific driver counter -- if this list does not exists, the \LaTeX{} run will issue a warning, but add the driver counter to the driver list and the associated counters analogously.
\marginnote{\bcbombe}
Using \refCom{AddAssociatedCounters} in the document body automated generation of counters is disabled.
\begin{docCommandArgs}{AddAssociatedCounters}
\begin{codeoptionsenum}
\item \oarg{options}: As of version \packageversion, the optional argument \oarg{options} are the same as for \refCom{DeclareAssociatedCounters}, see \refKey{autodefine} and \refKey{sloppy}.
\item \marg{driver counter}
Holds the name of the driver counter to which the list of counters should be associated
\item \marg{associated counters list}
A comma separated list of counter names that should be associated to the driver counter
\end{codeoptionsenum}
\end{docCommandArgs}
% macro of the package. It declares the counter names being specified in comma - separated - list (CSV) which should be stepped simultaneously when the driver counter is increased by \cs{stepcounter}.
\end{docCommand}%
\begin{docCommand}{RemoveAssociatedCounter}{\marg{driver counter}\marg{associated counter}}
This command removes a counter from the existing list for a driver counter, i.e. the counter will not be increased any longer by \cs{stepcounter}. It can be increased however manually, of course.
\end{docCommand}
\begin{dispExample}
\RemoveAssociatedCounter{page}{anothertotalpages}
This document has \number\totvalue{totalpages} (beware: \number\totvalue{anothertotalpages}) pages.
\end{dispExample}
\begin{docCommand}{RemoveAssociatedCounters}{\marg{driver counter}\marg{list of associated counters}}
This command removes the comma-separated-value list of counters from the existing list for a driver counter, i.e. the counters will not be increased any longer by \cs{stepcounter}. They can be increased however manually, of course.
Take care not to confuse the commands \refCom{RemoveAssociatedCounters}
and{}\linebreak \refCom{RemoveAssociatedCounter}
\end{docCommand}
\begin{docCommand}{ClearAssociatedCounters}{\oarg{options}\marg{driver counter}}
This command clears the internal list for all counters associated to the \marg{driver counter}. The counters will not be increased automatically any longer.
The optional argument is not used as of version \packageversion.
Please note that the driver counter is not removed from the list of driver counters -- this simplifies reassociating of (other) counters to this one later on with the macro \refCom{AddAssociatedCounters} and suppress the relevant warning.
If the driver counter and all its associated counters should be removed, use \refCom{RemoveDriverCounter} instead.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.2}}]{DeclareTotalAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
This command combines the features of \CHDocTag{associated counters} and \CHDocTag{total counters}, i.e. the associated counters are defined with \refCom{NewTotalDocumentCounter} and associated to the driver counter.
See \cref{sec::totalcounters} for more information on \CHDocTag{total counters}.
\end{docCommand}
\clearpage
\subsection[Driver macros]{Driver counter commands} \label{subsection::drivercounterscmds}
\begin{docCommand}{AddDriverCounter}{\oarg{options}\marg{driver counter name}}
\begin{docCommandArgs}{AddDriverCounter}%
\begin{codeoptionsenum}
\item \oarg{options}: As of \packageversion, the optional argument \oarg{options} is not used so far, but is reserved for later purposes.
\item \marg{driver counter name}
Holds the name of the driver counter that should be added to the list of driver counters.
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}%
\begin{docCommand}{RemoveDriverCounter}{\oarg{options}\marg{driver counter}}
This command clears the internal list for all counters associated to the \marg{driver counter}. The counters will not be increased automatically any longer.
The optional argument is not used as of version \packageversion.
If all driver counters should be unregistered, use \refCom{ClearDriverCounters} instead!
\end{docCommand}
\begin{docCommand}{ClearDriverCounters}{\oarg{options}}%
This clears completely the list of driver counters, such that no counters are regarded as being associated -- i.e. no driver is hold as being a driver counter.
The optional argument is not used as of version \packageversion.
\end{docCommand}
\subsection[Query macros]{Commands for queries} \label{subsection::querycmds}
Sometimes it might be necessary to get information, whether a counter is regarded as a driver or as an associated counter. This section describes some query macros in order to obtain this information.
\begin{docCommand}{IsAssociatedToCounter}{\marg{driver counter}\marg{associated counter}\marg{True branch}\marg{False branch}}
This macro checks, whether a counter is associated to a particular given driver counter and expands the corresponding branch. If the internal driver counter list does not exist, the false branch will be used, since this also means, that the possibly associated counter is not associated at all.
\begin{docCommandArgs}{IsAssociatedToCounter}%
\begin{codeoptionsenum}
\item \marg{driver counter}
Holds the name of the driver counter to which \marg{associated counter} the could possibly be associated.
\item \marg{associated counter}
Contains the name of the possibly associated counter.
\item \marg{True branch}
This code is expanded if the counter is associated to the driver, otherwise it is ignored.
\item \marg{True branch}
This code is expanded if the counter is \textbf{not} associated to the driver, otherwise it is ignored.
\end{codeoptionsenum}
\end{docCommandArgs}
\begin{dispExample}
% Remove associated counter first for demonstration purposes
\RemoveAssociatedCounter{page}{anothertotalpages}
\IsAssociatedToCounter{page}{totalpages}{Yes, totalpages is associated}{No, totalpages is not associated}
\IsAssociatedToCounter{page}{anothertotalpages}{Yes, anothertotalpages is associated}{No, anotherpages is not associated}
\end{dispExample}
See also
\begin{itemize}
\item \refCom{IsAssociatedCounter} for checking whether a counter is associated
\item \refCom{IsDriverCounter} in order to check whether a counter is a driver.
\item \refCom{GetDriverCounter} returns the driver counter name for a given associated counter name
\end{itemize}
\end{docCommand}
\begin{docCommand}{GetDriverCounter}{\marg{counter name}}%
This commands returns the driver counter to which the counter name of the first argument is connected to. If the counter is not defined, the macro returns nothing.
\begin{itemize}
\item No check whether the counter name is defined is performed
\item No check whether the counter is associated at all is performed. Usage of this command in conjunction with \refCom{IsAssociatedCounter} is strongly encouraged.
\end{itemize}
\begin{dispExample}%
totalpages is associated to the \textcolor{blue}{\textbf{\GetDriverCounter{totalpages}}} counter.
% Try with an undefined counter name
humptydumpty is associated to the \textcolor{blue}{\textbf{\GetDriverCounter{humptydumpty}}} counter.
\end{dispExample}%
\end{docCommand}%
\begin{docCommand}{IsAssociatedCounter}{\marg{counter name}\marg{True branch}\marg{False branch}}%
This commands tests, whether a given counter name is an associated counter and expands correspondingly the true or the false branch. The command does not tell to which driver the counter it is associated -- this information can be obtained by \refCom{GetDriverCounter}.
\begin{docCommandArgs}{IfAssociatedCounter}%
\begin{codeoptionsenum}
\item \marg{counter name}%
Contains the name of the possibly associated counter
\item \marg{True branch}
This code is expanded if the counter is associated to a driver, otherwise it is ignored
\item \marg{True branch}
This code is expanded if the counter is \textbf{not} associated a driver, otherwise it is ignored
\end{codeoptionsenum}
\end{docCommandArgs}
\begin{dispExample}
\IsAssociatedCounter{section}{Yes, section is an associated counter}{No, section counter does not have the associated counter properties}
\IsAssociatedCounter{totalpages}{Yes, totalpages is an associated counter}{No, totalpages counter does not have the associated counter properties}
\end{dispExample}
\end{docCommand}%
\begin{docCommand}{IsDriverCounter}{\marg{driver counter name}\marg{True branch}\marg{False branch}}%
This commands tests, whether a given counter name is a driver counter and expands correspondingly the true or the false branch.
\begin{docCommandArgs}{IfDriverCounter}%
\begin{codeoptionsenum}
\item \marg{driver counter name}%
Contains the name of the possible driver counter
\item \marg{True branch}
This code is expanded if the counter is a driver, otherwise it is ignored
\item \marg{True branch}
This code is expanded if the counter is \textbf{not} a driver, otherwise it is ignored
\end{codeoptionsenum}
\end{docCommandArgs}
\begin{dispExample}
\IsDriverCounter{section}{Yes, section is a driver counter}{No, section counter does not have driver properties}
\end{dispExample}
\end{docCommand}%
\section[Counter backup/restoration]{Backup and restore of counter values}\CHDocNew{1.0}\label{section::new_backuprestore}
It might be necessary to interrupt the current sectioning, e.g. including another document's structure (an external paper, for example) such that the counting should start again and after finishing of the external structure the old values should be restored.
\begin{marker}
Since version \CHDocFullVersion{1.0} the commands and feature behaviour of backup and restoration of counter values has changed.
The old behaviour is still available using the macros \cs{Former...} prefixed macros, see \cref{section::old_backuprestore} for this.
\end{marker}
\subsection{Key philosophy in backup/restore}
The basic idea is to provide a scheme that allows easy storage and restoration of counter values. For a single counter this is quite easy, using some other temporary counter, storing the old value there and copy the values back at the right position -- if many counters should be controlled to have a backup this procedure might get tedious, however.
\CHDocPackage{xassoccnt} provides some tools to define groups of counters that should be under control of backup and restoration. A backup counter group can be used multiple times, each using an individual ID, this allows maintaining 'complete' counter states and reinjecting them at any position later on.
Those are the basic steps (in pseudo code) to use the backup feature:
\begin{enumerate}
\item Define a symbolic backup counter group name
Note that counter group names are providing something like a namespace. A group of coupled counters (see \namecref{sec::coupledcounters} \nameref{sec::coupledcounters}) may have the same name as a group of counters designed to be backed up -- however, each feature has its own namespace. In each namespace there can be only one counter group with a specific name, duplicates are not allowed within the same feature namespace.
\item Populate the counter group name with counter names
\item Define a backup state and a corresponding id
\item Restore at any place
\end{enumerate}
\subsection{The default counter group "scratch"}
There is a default counter group for backup named "scratch", if no specific counter group name is given using the \refKey{name} option (see \cref{subsubsec::common_options_backuprestore} for a detailed description of available backup/restore options).
\subsection{Description of basic backup/restore macros}
\subsubsection{Common options to (most) of the backup/restore macros} \label{subsubsec::common_options_backuprestore}
\begin{itemize}
\item
\begin{docKey}[][]{resetbackup}{=\meta{true/false}}{initially true}
This key decides whether \textbf{all} counters in the backup list should be reset to zero or should keep the current value when the backup command is given. The default value is \meta{true}.
\end{docKey}
\item \begin{docKey}[][]{cascading}{=\meta{true/false}}{initially false}
This key decides whether all counters in the reset list of a driver counter shall be added to the counter group -- the driver counter is added itself too. If the driver counter has no reset list, it is added nevertheless.
Please note that the reset lists of the individual counters are tracked as well -- this is done recursively.
This provides a very convenient feature to backup and restore the value of a certain sectioning level, say \cs{chapter}. Using \refKey{cascading} this would mean\footnote{Assuming \CHDocClass{book} is used, for example!} that \CHDocCounter{chapter}, \CHDocCounter{section}, \CHDocCounter{subsection},\CHDocCounter{subsubsection}, \CHDocCounter{paragraph}, \CHDocCounter{subparagraph}, \CHDocCounter{equation}, \CHDocCounter{figure} and \CHDocCounter{table} would be added to the counter group.
\end{docKey}
\item \begin{docKey}[][]{backup-id}{=string}{no default value}
This key declares a string-like backup id under which the backup of a certain group is stored and can be retrieved later on. The id should be a string containing only alphanumeric characters.
\end{docKey}
\item
\begin{docKey}[][]{restore-id}{=string}{no default value}
This key declares a string-like restore id for unique \CHDocPackage{hyperref} names. The id should be a string containing only alphanumeric characters. \end{docKey}
This key is only needed if the same backup-id should be restored more than once and the package \CHDocPackage{hyperref} is used in order to provide unique hyper anchors.
\item \begin{docKey}[][]{keep-after-restore}{=\meta{true/false}}{initially false}
This key decides whether the values of a certain backup id (see \refKey{backup-id}) shall be kept after a restore has been issued. The default operation is to remove the \refKey{backup-id} and the values of the counters belonging to the given \refKey{backup-id}.
This option is useful if the same backup state (i.e. \refKey{backup-id}) is to be used more than once.
Reusing the same counter group for restore after having restored them already with the \refKey{keep-after-restore} option being false will be ignored, i.e. the counter values are not changed.
\end{docKey}
\item \refKey{name}
The meaning of this key is basically the same as for the \nameref{sec::coupledcounters} feature. However, depending on the stage of the backup/restore process the precise action differs:
\begin{itemize}
\item If \refKey{name} is used in \refCom{AssignBackupCounters} the counters are added to group indicated by the value of \refKey{name}.
\item If \refKey{name} is used either for \refCom{BackupCounterGroup} or in \refCom{RestoreBackupCounterGroup} to indicate the counter group for a certain backup state, either for storing or restoring.
\end{itemize}
\end{itemize}
\subsubsection{Core backup/restore macros}
\begin{docCommand}[before={\CHDocNew{1.0}}]{BackupCounterGroup}{\oarg{options}\marg{counter group name}}
Concerning the backup feature this performs the storing of counter values at the position where the command is expanded!
A backup operation needs
\begin{itemize}
\item \refKey{backup-id} to be able to refer to a certain backup state
\item \refKey{name} to identify the group of counters
\end{itemize}
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0}}]{RestoreBackupCounterGroup}{\oarg{options}\marg{counter group name}}
This command restores the value of the given counter group.
Useful options are (see \nameref{subsubsec::common_options_backuprestore})
\begin{itemize}
\item \refKey{backup-id}
\item \refKey{keep-after-restore}
\item \refKey{restore-id}
\item \refKey{name}
\end{itemize}
\end{docCommand}
\subsubsection{Declaring counter groups}
\begin{docCommand}[before={\CHDocNew{1.0}}]{DeclareBackupCountersGroupName}{\oarg{}\marg{counter group name}}
This command declares (better: reserves a name for a backup counter group) -- the name has to be specified as first mandatory argument.
A counter group name consists of alphanumeric characters, special symbols etc. are not allowed. The name must not contain commas!
As of version \packageversion\ the optional argument is not used and reserved for later purposes.
\end{docCommand}
\subsubsection{Populating counter groups}
\begin{docCommand}[before={\CHDocNew{1.0}}]{AssignBackupCounters}{\oarg{options}\marg{counter name1,counter name2,\dots}}
This macro populates the counter group (given as optional key - value \refKey{name}) with the comma separated list of counters from the first mandatory argument. The meaning of \refKey{name} is the same as in \nameref{sec::coupledcounters}, but the counter group names are not related to that feature -- the namespace is safe then.
Some important notes about the behaviour of \refCom{AssignBackupCounters}
\begin{itemize}
\item If \refKey{name} is not given or empty, the default counter group "scratch" is used.
\item If the counter group given to \refKey{name} does not exist, it will be created automatically.
\end{itemize}
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0}}]{AddBackupCounter}{\oarg{options}\marg{counter name1,counter name2,\dots}}
This command is similar to \refCom{AssignBackupCounters}, adding counters to a counter group named by \refKey{name} option. If the counter group name does not exist, no action is performed, i.e. the adding operation is ignored.
\end{docCommand}
\subsubsection[Clearing backup states]{Clearing backup states}\label{subsubsec::clearingbackupstates}
It might be necessary to remove a certain backup state, i.e. a collection of counter values to be referred to with a \refKey{backup-id}. This can be done either for a certain counter (with \refCom{ClearCounterBackupState}) in a counter group only or for all counters in group (with \refCom{ClearBackupState}).
\begin{docCommand}[before={\CHDocNew{1.0}}]{ClearCounterBackupState}{\oarg{options}\marg{countergroup name}\marg{counter name}}
This macro removes the given backup-id state value for a specific counter only. Use the \refKey{backup-id} option in the first optional argument to specify which backup-id should be cleared.
\begin{itemize}
\item If the backup-id does not exist, the operation is ignored silently.
\item The counter is still part of the group, but can't be restored to the previous state that was identified with \refKey{backup-id}.
\end{itemize}
\marginnote{\bcbombe}Use this macro with care!
\smallskip
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0}}]{ClearBackupState}{\oarg{options}\marg{countergroup name}}
This macro removes the given backup-id state value for a whole counter group. Use the \refKey{backup-id} option in the first optional argument to specify which backup-id should be cleared.
\begin{itemize}
\item If the backup-id does not exist, the operation is ignored silently.
\item The \refKey{backup-id} is removed from the list of possible backup-ids for the relevant countergroup.
\end{itemize}
\end{docCommand}
\subsubsection[Clearing backup groups]{Clearing and deleting backup counter groups}\label{subsubsec::clearingdeletingbackupcountergroups}
From time to time it might be necessary to remove counters from a group or to clear the whole group or remove even the whole group. Those operations can be achieved with \refCom{RemoveCountersFromBackupGroup}, \refCom{ClearBackupCounterGroups} and \refCom{DeleteBackupCounterGroups}. All macros remove at least all stored values belonging to a counter group. A \refCom{RestoreBackupCounterGroup} call does nothing after any of the mentioned macros have been issued.
\begin{docCommand}[before={\CHDocNew{1.0}}]{RemoveCountersFromBackupGroup}{\oarg{options}\marg{countergroup name}\marg{counter name 1, counter name 2,\dots}}
This command removes the given counter names from a counter group. The stored values are deleted completely and are lost afterwards. A non-existing counter group name is ignored as well as counters that do not belong to the given group name.
As of version \packageversion\ the optional argument is not used and reserved for later purposes.
If complete counter groups shall be deleted and be unavailable afterwards, use
\refCom{DeleteBackupCounterGroups} instead.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0}}]{ClearBackupCounterGroups}{\oarg{options}\marg{countergroup name 1, countergroup name 2,\dots}}
This command removes all names of the counter groups given as comma separated list in the 2nd argument, the internal storage of counter values is removed as well, i.e. older counter values aren't available any longer. The counter group names remain valid, any subsequent call to \refCom{BackupCounterGroup} or \refCom{RestoreBackupCounterGroup} with one of the provided group names will be ignored.
As of version \packageversion\ the optional argument is not used and reserved for later purposes.
If counter groups shall be deleted and be unavailable, use \refCom{DeleteBackupCounterGroups}.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0}}]{DeleteBackupCounterGroups}{\oarg{options}\marg{countergroup name 1, countergroup name 2,\dots}}
This command clears the counter groups given as comma separated list in the 2nd argument with \refCom{ClearBackupCounterGroups} and removes the names as well, i.e. those names are not available any longer.
As of version \packageversion\ the optional argument is not used and reserved for later purposes.
\end{docCommand}
\subsection{Query for backup features}\label{subsec::querybackupmacros}\CHDocNew{1.0}
As usual, some macros to ask whether a certain counter is under backup control or whether a certain \refKey{backup-id} exists might be useful!
\subsubsection{Querying for backup counter group existence}\label{subsec::querybackupcountergroup}
\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterGroupTF}{\marg{counter group name}\marg{true branch}\marg{false branch}}
This macro tests if the given name is a backup counter group and expands to the \meta{true}/\meta{false} branch accordingly. There are two short-circuit commands: \refCom{IsBackupCounterGroupT} and \refCom{IsBackupCounterGroupF}.
\end{docCommand}
\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterGroupT}{\marg{counter group name}\marg{true branch}}
This macro tests if the given name is a backup counter group and expands to the \meta{true} branch accordingly. There are two related macros: \refCom{IsBackupCounterGroupF} and \refCom{IsBackupCounterGroupTF}.
\end{docCommand}
\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterGroupF}{\marg{counter group name}\marg{false branch}}
This macro tests if the given name is a backup counter group and expands to the \meta{false} branch accordingly. There are two related macros: \refCom{IsBackupCounterGroupT} and \refCom{IsBackupCounterGroupTF}.
\end{docCommand}
\subsubsection{Querying for backup counter entity}\label{subsec::querybackupmacros}
\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
This macro tests if a counter is under the administration of the backup counter commands and expands to the relevant \meta{true}/\meta{false} branch then. There are two short-circuit commands: \refCom{IsBackupCounterT} and \refCom{IsBackupCounterF}.
\end{docCommand}
\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterT}{\marg{counter name}\marg{true branch}}
This macro tests if a counter is under the administration of the backup counter commands and expands to the \meta{true} branch then. There are related commands: \refCom{IsBackupCounterTF} and \refCom{IsBackupCounterF}.
\end{docCommand}
\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterF}{\marg{counter name}\marg{false branch}}
This macro tests if a counter is under the administration of the backup counter commands and expands to the \meta{false} branch if this not the case. There are related commands: \refCom{IsBackupCounterTF} and \refCom{IsBackupCounterT}.
\end{docCommand}
\subsubsection{Querying for backup state entity}\label{subsec::querybackupstate}
\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupStateTF}{\marg{counter group name}\marg{counter backup-id}\marg{true branch}\marg{false branch}}
This macro tests if the backup-id exists for the given counter group and executes the relevant \meta{true}/\meta{false} branch accordingly. There are two short-circuit commands: \refCom{IsBackupStateT} and \refCom{IsBackupStateF}.
\end{docCommand}
\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupStateT}{\marg{counter group name}\marg{counter backup-id}\marg{true branch}}
This macro tests if the backup-id exists for the given counter group and executes the relevant \meta{true} branch accordingly. There are two related: \refCom{IsBackupStateTF} and \refCom{IsBackupStateF}.
\end{docCommand}
\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupStateF}{\marg{counter group name}\marg{counter backup-id}\marg{false branch}}
This macro tests if the backup-id exists for the given counter group and executes the relevant \meta{false} branch accordingly. There are two related: \refCom{IsBackupStateTF} and \refCom{IsBackupStateT}.
\end{docCommand}
\subsection{Some notes on the backup features} \label{subsec::backup_and_hyperref}
Principally backing up counter values and restoring them later on is not really difficult -- with one exception: If the \CHDocPackage{hyperref} package is used, the counter values form up the hypertarget anchors, for example \texttt{chapter.1} for the first chapter. If the chapter counter is reset, there would be a chapter with number one again and as well an anchor name \texttt{chapter.1} -- \CHDocPackage{hyperref} will complain 'only' about this but it will put the wrong hyperlink as well, for example for the table of contents and the bookmarks -- this is an undesirable feature.
However, there is a solution to this problem: The hypertarget anchors are built up from the specifications of a macro \cs{theH...} where the ellipses stands for the counter name. If for example \cs{theHchapter} is changed after a counter was reset the hypertargets will again be correct, since this will provide a different target name. \refCom{BackupCounterGroup} does this resetting automatically in an unique way and \refCom{RestoreBackupCounterGroup} restores as well the old \cs{theH...} macros of all counters that are in the backup list. It tracks the number of calls to \refCom{BackupCounterGroup} and changes the relevant \cs{theH...} macro definitions to use unique anchor names then -- this way multiple \refCom{BackupCounterGroup} calls are possible without destroying the hyperlink facilities with \CHDocPackage{hyperref}.
\section{Coupled counters}\label{sec::coupledcounters}\CHDocNew{0.5}
\begin{marker}
The features described here are very experimental and not fully implemented so far.
\end{marker}
Occasionally there are requests where the figure or table environment should use the same counter in the sense of using continued counter values, e.g figure 1 is followed by table 2, the next figure is numbered as 3 etc.
This can be achieved with the concept of coupled counters. As usual, those counters belonging to a 'group' should be declared first in the preamble. In some sense coupled counters are similar to associated counters.
\subsection[Common options for coupled counters]{Common options for most of the coupled counter macros}\label{subsection:options_coupledcounters}
\begin{docKey}{name}{=\meta{name of a group}}{}\CHDocNew{0.6}
This option has the name of the counter group that should be coupled, say ``figuretablegroup'' etc.
\end{docKey}
\begin{docKey}{multiple}{=\meta{true,false}}{initially false}\CHDocNew{0.6}
This option allows to add a counter multiple times to a counter group. In general, using this style is not recommended.
\end{docKey}
\subsection[Macros for coupled counters]{Macros for declaring, adding and removing coupled counters}
\begin{docCommand}{DeclareCoupledCounters}{\oarg{options}\marg{counter name1, counter name2, \dots}}\CHDocNew{0.5}
\begin{codeoptionsenum}
\item \oarg{options}: See \cref{subsection:options_coupledcounters} for a explanation about available options.
\item \marg{counter name 1, counter name2, \dots}: The list of counters that should should be stepped together for the given counter group.
\end{codeoptionsenum}
This macro is a preamble-only command.
\end{docCommand}
\begin{docCommand}{DeclareCoupledCountersGroup}{\marg{counter group name}}\CHDocNew{0.5}
This macro defines a name for a counter group and allocates a new group list for the counter names. If the name already exists, nothing is done.
\begin{codeoptionsenum}
\item \marg{counter group name}: The name of the counter group.
\end{codeoptionsenum}
This macro is a preamble-only command and does not add counters to the group container. Use \refCom{DeclareCoupledCounters} or \refCom{AddCoupledCounters} to add counters to the relevant group.
\end{docCommand}
\begin{docCommand}{RemoveCoupledCounters}{\oarg{options}\marg{counter name1, counter name2, \dots}}\CHDocNew{0.5}
This removes the comma separated counter names from the coupled counter list given in the \refKey{name} option.
\begin{codeoptionsenum}
\item \oarg{options}: As of version \packageversion{} the only recognized option is \refKey{name}.
\item \marg{counter name 1, counter name2, \dots}: The list of counters that should should removed from the given counter group.
\end{codeoptionsenum}
\begin{marker}
\begin{itemize}
\item The list name itself is still available
\item If the list given by the \refKey{name} option does not exist, \refCom{RemoveCoupledCounters} issues a warning on the console and ignores this list then.
\end{itemize}
\end{marker}
If all counters from a group name should be removed, this is equal to clearing -- just use \refCom{ClearCoupledCounters} for simpler usage of this feature.
\end{docCommand}
\begin{docCommand}{AddCoupledCounters}{\oarg{options}\marg{counter name1, counter name2, \dots}}\CHDocNew{0.5}
\CHDocUpdate{0.6}
This adds the listed counter names to coupled counter list. It acts like \refCom{DeclareCoupledCounters}, but does not setup new counter groups. Please use \refCom{DeclareCoupledCounters} first, then apply \cs{AddCoupledCounters} later on.
\begin{codeoptionsenum}
\item \oarg{options}: See \cref{subsection:options_coupledcounters} for a explanation about available options.
\item \marg{counter name 1, counter name2, \dots}: The list of counters that should should be stepped together for the given counter group.
\end{codeoptionsenum}
\begin{marker}
If the list given by the \refKey{name} option does not exist, \refCom{AddCoupledCounters} issues a warning on the console and ignores this list then. The counters are not added to any list at all.
\end{marker}
\end{docCommand}
\begin{docCommand}{ClearCoupledCounters}{\marg{options}}\CHDocNew{0.6}
This removes all names from the given name of a group of coupled counters.
\begin{codeoptionsenum}
\item \oarg{options}: As of version \packageversion{} the only recognized option is \refKey{name}.
\end{codeoptionsenum}
After clearing a list, the coupling stops for the counters on that list (unless they are part of another list, which is possible, but not recommended). using \refCom{AddCoupledCounters} with the relevant \refKey{name} option adds counters again to the list and the coupling is active again, however, for different counters (eventually).
In order to clear all coupled counter lists, use \refCom{ClearAllCoupledCounters} instead.
\begin{marker}
\begin{itemize}
\item The list name itself is still available
\item If the list given by the \refKey{name} option does not exist, \refCom{ClearCoupledCounters} issues a warning on the console and ignores this list then.
\end{itemize}
\end{marker}
\end{docCommand}
\begin{docCommand}{ClearAllCoupledCounters}{}\CHDocNew{0.6}
This removes all coupled counter groups, but not the group names, i.e. the list names can be used later on to add counter names again. In order to clear a specific list, use \refCom{ClearCoupledCounters}.
\end{docCommand}
\begin{docCommand}{IsCoupledCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}\CHDocNew{0.6}
This macro tests if a counter is under the administration of the coupled counter commands and expands to the relevant branch then. There are two short-circuit commands \refCom{IsCoupledCounterT} and \refCom{IsCoupledCounterF}.
\end{docCommand}
\begin{docCommand}{IsCoupledCounterT}{\marg{counter name}\marg{true branch}}\CHDocNew{0.6}
This macro tests if a counter is under the administration of the coupled counter commands and executes the true branch then. There are two related commands \refCom{IsCoupledCounterTF} and \refCom{IsCoupledCounterF}.
\end{docCommand}
\begin{docCommand}{IsCoupledCounterF}{\marg{counter name}\marg{false branch}}\CHDocNew{0.6}
This macro tests if a counter is under the administration of the coupled counter commands and executes the false branch then if this is not the case. There are two related commands \refCom{IsCoupledCounterTF} and \refCom{IsCoupledCounterT}.
\end{docCommand}
\clearpage
\section{Periodic counters}\label{section:periodic_counters}\CHDocNew{0.9}
It might be very convenient to have counters that are automatically reset not only by a driving counter such as \CHDocCounter*{chapter} but also periodically, i.e. after a certain amount of steps -- this can be achieved with the concept of periodic counters.
\subsection{Commands related to periodic counters setup}
\begin{docCommand}[before={\CHDocNew{0.9}}]{DeclarePeriodicCounter}{\oarg{}\marg{counter name}\marg{counter treshold value}}
This defines the counter given in the first mandatory argument as a periodic counter and is automatically reset if the treshold value is reached.
\begin{marker}
The command \refCom{DeclarePeriodicCounter} does not define a new counter, however but is the preamble-only version of \refCom{AddPeriodicCounter}.
\end{marker}
Please note that in case of \cs{addtocounter} applied to a periodic counter the value to be added leads to a modulo division such that the counter might be reset if the addition would increase the counter beyond the treshold value, the module part will be added then. In order to prevent this wrapping, use the \refKey{wrap} option to \refCom{addtocounter}:
\begin{dispExample}
\setcounter{foocntr}{3}%
\AddPeriodicCounter{foocntr}{8}%
Value of foocntr is: \thefoocntr % Should be 3
\addtocounter{foocntr}{20} % Is it 23? No, it is 23 % 8 = 7
Value of foocntr is \thefoocntr\ now!
Adding a value of 4 again:
\addtocounter{foocntr}{4} % Is it 11? No, it is 11 % 8 = 3
Value of foocntr is \thefoocntr\ now!
Now prevent the wrapping
\addtocounter{foocntr}{10}[wrap=false] % Is it 13? Yes, it is!
Value of foocntr is \thefoocntr\ now!
\end{dispExample}
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{0.9}}]{AddPeriodicCounter}{\oarg{}\marg{counter name}\marg{counter treshold value}}
This defines the counter given in the first mandatory argument as a periodic counter and is automatically reset if the treshold value is reached.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{0.9}}]{RemovePeriodicCounter}{\oarg{options}\marg{counter name}}
This removes the counter given in the first mandatory argument as a periodic counter. The counter is reset unless the \refKey{reset} is set to \meta{false}.
\begin{codeoptionsenum}
\item \oarg{options}
As of version \packageversion, there is only one option:
\begin{docKey}[][before={\CHDocNew{0.9}}]{reset}{=\meta{true/false}}{initially true}
Use `false` to prevent the resetting of the relevant counter after removal!
\end{docKey}
\item \marg{counter name} -- the name of the counter that should be no periodic counter any longer.
\end{codeoptionsenum}
If all periodic counters should be removed, use the macro \refCom{RemoveAllPeriodicCounters} instead.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.0}}]{RemoveAllPeriodicCounters}{\oarg{options}}
This command removes all counters given in the first mandatory argument as a periodic counter. All counters are reset unless the \refKey{reset} option is set to \meta{false}.
\begin{codeoptionsenum}
\item \oarg{options}
As of version \packageversion, there is only one option: \refKey{reset}, having the same meaning as in \refCom{RemovePeriodicCounter}.
\item \marg{counter name} -- the name of the counter that should be no periodic counter any longer.
\end{codeoptionsenum}
If only a specific counter shall be removed from the periodic counter property use the command \refCom{RemovePeriodicCounter} instead.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{0.9}}]{ChangePeriodicCounterCondition}{\oarg{options}\marg{counter name}\marg{new counter treshold value}}
This changes the counter treshold condition -- the counter is reset automatically if not specified otherwise with the \refKey{reset} option.
\begin{codeoptionsenum}
\item \oarg{options}
As of version \packageversion, there is only one option: \refKey{reset}, which serves the same functionality as in \refCom{RemovePeriodicCounter}.
\item \marg{counter name} -- the name of the counter that should be no periodic counter any longer.
\item \marg{new counter value treshold} -- the new value after which an automatic resetting will occur.
\end{codeoptionsenum}
\end{docCommand}
\subsection{Commands to query for periodic counter feature}
\begin{docCommand}[after={\CHDocNew{0.9}\par}]{IsPeriodicCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
This macro tests if a counter is under the administration of the periodic counter commands and expands to the relevant branch then. There are two short-circuit commands: \refCom{IsPeriodicCounterT} and \refCom{IsPeriodicCounterF}.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{0.9}}]{IsPeriodicCounterT}{\marg{counter name}\marg{true branch}}
This macro tests if a counter is under the administration of the periodic counter commands and expands to the \meta{true} branch then. There are two related commands: \refCom{IsPeriodicCounterTF} and \refCom{IsPeriodicCounterF}.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{0.9}}]{IsPeriodicCounterF}{\marg{counter name}\marg{false branch}}
This macro tests if a counter is under the administration of the periodic counter commands and expands to the \meta{false} branch then if this is not the case. There are two related commands: \refCom{IsPeriodicCounterTF} and \refCom{IsPeriodicCounterT}.
\end{docCommand}
\section[Suspending and Resuming]{Suspending and resuming (associated) counters}\label{section::suspendedresumedcounters}
Rather than removing an associated counter from the list, it is possible to suspend the automatic stepping for a while and then resume it (or completely drop it), for example, if the value of a counter should not be stepped within a specific chapter etc.
\begin{marker}[before=\CHDocNew{0.8}\par]
Suspension and resuming counters can cause wrong hyper links if \CHDocPackage{hyperref} is used.
\end{marker}
\subsection{Macros for suspension and resume}
\begin{docCommand}{SuspendCounters}{\oarg{options}\marg{counters list}}%
\begin{docCommandArgs}{SuspendCounters}%
\begin{codeoptionsenum}
\item \oarg{options}%
Not used so far, reserved for later usage.
\item \marg{counters list}%
Contains the name of counters to be suspended, separated by commas (CSV - list)
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}%
\begin{docCommand}{CascadeSuspendCounters}{\oarg{options}\marg{counters list}}\CHDocNew{0.8}
This macro is more powerful than \refCom{SuspendCounters}, since it tries to detect whether a counter has a reset list and 'mutes' the counters on this list as well and checks whether those counters themselves have reset lists and cascades down to the final state.
\begin{marker}
Stated differently: All counters anyhow connected to a counter named \CHDocCounter{foo} will be suspended, e.g. for the \CHDocClass{book} class and \CHDocCounter{chapter}, this means in a standard setup, that \CHDocCounter*{section,figure,table,equation,footnote} will be suspended, as well as in consequence \CHDocCounter*{subsection,subsubsection,paragraph,subparagraph}, assuming hereby no other counters have been added to the reset lists.
\end{marker}
\begin{docCommandArgs}{CascadeSuspendCounters}%
\begin{codeoptionsenum}
\item \oarg{options}%
Not used so far, reserved for later usage.
\item \marg{counters list}%
Contains the name of counters to be suspended, separated by commas (CSV - list)
\end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}%
\begin{docCommand}{ResumeSuspendedCounters}{\oarg{options}\marg{counters list}}
As of version \packageversion\ the optional argument is not used and reserved for later purposes.
This command revokes the suspension of the counters in the \marg{counters} list.
\end{docCommand}
\begin{docCommand}{ResumeAllSuspendedCounters}{\oarg{options}} \CHDocNew{0.8}
As of version \packageversion\ the optional argument is not used and reserved for later purposes.
This command revokes all suspended counters.
\end{docCommand}
\subsection{Query suspension}
\begin{docCommand}[before={\CHDocNew{0.1}}\par]{IsSuspendedCounter}{\marg{counter name}\marg{true branch}\marg{false branch}}
See \nameref{section::suspendedresumedcounters} on this topic.
This command checks, whether a counter is suspended, i.e. not updated at all and expands the corresponding branches.
%\begin{docCommandArgs}{IfSuspendedCounter}%
\begin{codeoptionsenum}
\item \marg{counter name}%
Contains the name of counter presumed to be suspended
\item \marg{True branch}
This code is expanded if the counter is suspended, otherwise it is ignored
\item \marg{True branch}
This code is expanded if the counter is \textbf{not} suspended, otherwise it is ignored
\end{codeoptionsenum}
%\end{docCommandArgs}
\end{docCommand}
\begin{marker}
If a driver counter is suspended, all counters associated to it are suspended too!
\end{marker}
\setcounter{totalequations}{0}
\setcounter{equation}{0}
\renewcommand{\DeclareAssociatedCounters}[3][]{\relax}%
\begin{dispExample}
\textbf{This example shows 4 equations, but only two of them are counted}
\begin{equation}
E_{0} = mc^2
\end{equation}
Now suspend the equations:
\SuspendCounters{equation}
\begin{equation}
E^2 = \left({ pc}\right)^2 + E^{2}_{0}
\end{equation}
\begin{equation}
m(v) = \frac{m_{0}}{\sqrt{1-\frac{v^2}{c^2}}}
\end{equation}
And resume it: \ResumeSuspendedCounters{equation}
\begin{equation}
E = h \nu
\end{equation}
There are \number\totvalue{totalequations}~equations in here!
\end{dispExample}
\section{Total counters}\tcbdocmarginnote{\tcbdocnew{2015-11-27}}\label{sec::totalcounters}
Similarly to the package \CHDocPackage{totcount} or the features of \CHDocPackage{totalcount} by Axel Sommerfeldt this package provides the possibility of defining a counter that stores its finally value to the auxiliary file and starts from this value then, if not set otherwise to another value.
The declaration of a total counter is a preamble - only event and \refCom{DeclareTotalDocumentCounter} is a preamble-only command in order to prevent counter register confusion. If a certain existing counter should be treated with total counter features, use \refCom{RegisterTotalDocumentCounter} instead.
Use \refCom{NewTotalDocumentCounter} only in rare cases, if a total counter must be defined within the document body.
\begin{marker}
\tcbdocmarginnote{\bcbombe}The standard \LaTeXe\ commands \cs{stepcounter}, \cs{addtocounter} and \cs{setcounter} support the specification of a total counter, but \cs{refstepcounter} will fail since the usage of a total counter for labelling purposes is most probably of no use (as of version \packageversion)
\end{marker}
\subsection{Defining total counters}
\begin{docCommand}{RegisterTotalDocumentCounter}{\oarg{options}\marg{total counter name}}\CHDocNew{0.5}
\begin{codeoptionsenum}
\item \oarg{options}: As of version \packageversion, only this option is used
\begin{docKey}{supertotal}{=\meta{true,false}}{false}
Set this key to switch the super total counter on or off.
\end{docKey}
\item \marg{total counter name}: The name of the total counter. This must be the same like the name of an already existing counter. Internally another counter is defined which has a prefix to prevent name clashes with counter names defined by the package \CHDocPackage{totalcount}. If the counter name does not exist, the compilation exits with an error message.
\end{codeoptionsenum}
\end{docCommand}
\begin{docCommand}{TotalCounterInternalName}{\marg{counter name}}
This command reports the internal name of a total counter or the usual name if this counter is not a total one.
\end{docCommand}
\begin{dispExample}
\TotalCounterInternalName{chapter}
\TotalCounterInternalName{foototal}
\end{dispExample}
\begin{docCommand}[before={\CHDocExpCommand\par\CHDocNew{1.0}}]{TotalCounterInternalNameExp}{\marg{counter name}}
This command is the expandable version of \refCom{TotalCounterInternalName}
\end{docCommand}
\stepcounter{foototal}
\begin{docCommand}[before={\CHDocExpCommand}]{TotalValue}{\marg{counter name}}\CHDocUpdate{0.9}%
This command prints the value of a total counter or falls back to the value of the counter if this is not a total counter.
\begin{dispExample}
``Total'' value of the section non-total counter: \TotalValue{section}
Total value of the foototal total counter: \TotalValue{foototal}
\end{dispExample}
\end{docCommand}
\subsection{Queries about total counters}
\begin{docCommand}{IsTotalCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
This macro tests if a counter is under the administration of the total counter commands and expands to the relevant branch then. There are two short-circuit commands \refCom{IsTotalCounterT} and \refCom{IsTotalCounterF}.
\end{docCommand}
\begin{docCommand}{IsTotalCounterT}{\marg{counter name}\marg{true branch}}
This macro checks if a counter is under the administration of the total counter commands and expands to the code in the second argument if this is true.
\end{docCommand}
\begin{docCommand}{IsTotalCounterF}{\marg{counter name}\marg{false branch}}
This macro checks if a counter is under the administration of the total counter commands and expands to the code in the second argument if this is not the case.
\end{docCommand}
\begin{dispExample}
\IsTotalCounterTF{foototal}{Yes, this is a total counter}{No, this is no total counter}
\IsTotalCounterTF{section}{Yes, this is a total counter}{No, this is no total counter}
\IsTotalCounterT{foototal}{Yes, this is a total counter}
\IsTotalCounterF{page}{No, page isn't a total counter}
\end{dispExample}
\begin{marker}
The features of using other \CHDocFiles{aux} files or a different external file as provided by \CHDocPackage{totcount} is not (yet) support as of version \packageversion.
\end{marker}
\section{Super total counters}\label{section:supertotalcounters} \tcbdocmarginnote{\tcbdocnew{2015-11-25}}
In addition to the concept of a total counter, there is also the possibility of using super total counters -- those counters survive the reset at the beginning of a compilation, i.e. the value of a super total counter might be stepped in each run and as such the number of compilation runs etc. can be tracked. The values of the last run are persistent as long as the \CHDocFileExt{.aux} file isn't deleted.
\subsection{Defining super total counters}
\begin{docCommand}{NewTotalDocumentCounter}{\oarg{options}\marg{total counter name1, total counter name2,\dots}}
This macro defines a new counter (which mustn't exist before of course) and puts it under control of the total counter features.
\begin{codeoptionsenum}
\item \oarg{options}: As of version \packageversion, only this option is used
\refKey{supertotal} -- this has the same meaning as in \refCom{RegisterTotalDocumentCounter} and defaults to \texttt{false}.
\item \marg{total counter name1, total counter name2,\dots}: The names of the total counter, separated by a comma. This must not be the same like the name of any already existing counter. Internally another counter is defined which has a prefix to prevent name clashes with counter names defined by the package \CHDocPackage{totcount}.
\end{codeoptionsenum}
\end{docCommand}
\begin{docCommand}{DeclareTotalDocumentCounter}{\oarg{options}\marg{total counter name1, total counter name2,\dots}}
This is the preamble - only version of \refCom{NewTotalDocumentCounter} and should be preferred in most cases over that command.
If an already existing counter should be tracked with total counter features,
use \refCom{RegisterTotalDocumentCounter} instead.
\CHDocUpdate{1.2}This command allows multiple counters (specified as a comma separated list) to be defined at once.
\end{docCommand}
\subsection{Queryies about super total counters}
\begin{docCommand}{IsSuperTotalCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
This macro tests if a counter is under the administration of the super total counter commands and expands to the relevant branch then. There are two short-circuit commands \refCom{IsSuperTotalCounterT} and \refCom{IsSuperTotalCounterF}.
\end{docCommand}
\begin{docCommand}{IsSuperTotalCounterT}{\marg{counter name}\marg{true branch}}
This macro checks if a counter is under the administration of the super total counter commands and expands to the code in the second argument if this is true.
\end{docCommand}
\begin{docCommand}{IsSuperTotalCounterF}{\marg{counter name}\marg{false branch}}
This macro checks if a counter is under the administration of the super total counter commands and expands to the code in the second argument if this is not the case.
\end{docCommand}
\begin{dispExample}
\IsSuperTotalCounterTF{numberofruns}{Yes, this is a super total counter}{No, this is no super total counter}
\IsSuperTotalCounterT{numberofruns}{Yes, this is a super total counter}
\IsSuperTotalCounterTF{chapter}{Yes, this is a total counter}{No, this is no super total counter}
\end{dispExample}
\subsection{The \CHDocCounter{numberofruns} counter}\label{subsection:numberofruns}
This package adds a counter of its own: \CHDocCounter{numberofruns} which is a super total counter and is stepped each compilation run. It's added in \cs{AtBeginDocument} and can be retrieved with \refCom{TotalValue}. Use the \refKey{nonumberofruns} package option to prevent the definition of this counter.
\section{Experimental features}\label{subsec::associated_counters_experimental}
\begin{marker}
\marginnote{\bcbombe}
The content here is only of experimental nature and there is no guarantee that the feature will be maintained in future releases.
\end{marker}
\subsection{Labels}
\begin{marker}
To enable the redefined \refCom{label} macro, specify the package option \refKey{redefinelabel}
\end{marker}
\begin{docCommand}[before={\CHDocNew{1.2}}]{label}{\oarg{cleveref-counter-overrule}\marg{label name}\oarg{options for associated counters}}
\begin{docKey}{all}{=\meta{true,false}}{initially \meta{false}}\CHDocNew{1.2}
This will enable that all associated counters to a driver counter will cause the generation of a label too. By default this option is \meta{false}.
This option deliberately overrules \refKey{select}, the value of the option \refKey{prefix} is disregarded.
\end{docKey}
\begin{docKey}{select}{={counter1, counter2,\dots}}{initially empty}\CHDocNew{1.2}
Select only some of the associated counters to be able to be labeled.
As of version \packageversion{} there is no check whether the given names refer to counters at all or are associated counters to the last counter that has been used with \cs{refstepcounter}.
\end{docKey}
\begin{docKey}{prefix}{=\meta{text}}{initially empty}\CHDocNew{1.2}
This gives the prefix of the label of the associated counter. If the option \refKey{all} is enabled, the label name is generated from the name of the associated counter, the value of \refKey{prefix-sep} and the value of the 2nd argument.
\newcounter{morefoobar}
\begin{dispExample*}{listing only}
% Assume that some counter has the associated counters foobar, morefoobar and yetanotherfoobar
\label{foo}[prefix=assoc,all]
\end{dispExample*}
will cause a label named \texttt{foobar::foo}, \texttt{morefoobar::foo} and \texttt{yetanotherfoobar::foo}, whereas
\begin{dispExample*}{listing only}
\label{foo}[prefix=assoc,select=morefoobar]
\end{dispExample*}
would generate the label \texttt{assocc::foobar} only and will be tied to the value of the counter \texttt{morefoobar}
\end{docKey}
\begin{docKey}{prefix-sep}{=\meta{text}}{initially ::}\CHDocNew{1.2}
Defines the separator between the \refKey{prefix} and the label name for the driver counter, i.e. the 2nd argument of the \refCom{label} command.
\end{docKey}
\end{docCommand}
\begin{marker}
\marginnote{\bcbombe}
If the package option \refKey{redefinelabel} is set to \meta{false}, the usage of the third optional argument will leave spurious content at the position \cs{label} was used. The reason is that the content of third optional argument with \texttt{[]} is not recognized as an argument any longer.
\end{marker}
\begin{docCommand}[before={\CHDocNew{1.3}}]{LaTeXLabel}{\oarg{cleveref-counter-overrule}\marg{label name}}
This is the default label macro, either with the \CHDocPackage{cleveref} extension or the classical \LaTeX2e\ macro (eventually modified by \CHDocPackage{hyperref}) and is not modified by this package.
The feature of label hooks from \refCom{RegisterPreLabelHook} or \refCom{RegisterPostLabelHook} is not used here.
\end{docCommand}
\subsection{Hooks}
This feature is experimental and only realized for the modified \refCom{label} command until now. See \nolinkurl{xassoccnt_getparentcounter_example.tex} as an example of usage.
\begin{docCommand}[before={\CHDocNew{1.3}}]{RegisterPreLabelHook}{\marg{command name1, command name2,\dots}}
This macro declares a possible list of hooks (commands) that should be executed \textbf{before} the traditional \cs{label} command is applied. If the hook name refers to some unknown macro, nothing is done.
The hook names must be given with the \textbackslash\ as command sequence indicator, i.e. \cs{zlabel}, more than one macro name is possible by using comma as separator.
As of version \packageversion\ the hook macro does not allow more than one argument, which is automatically used from the surrounding \cs{label} call and is the usual label name.
\end{docCommand}
\begin{docCommand}[before={\CHDocNew{1.3}}]{RegisterPostLabelHook}{\marg{command name1, command name2,\dots}}
This macro declares a possible list of hooks (commands) that should be executed after the traditional \cs{label} command is applied. If the hook name refers to some unknown macro, nothing is done.
The hook names must be given with the \textbackslash\ as command sequence indicator, i.e. \cs{zlabel}, more than one macro name is possible by using comma as separator.
As of version \packageversion\ the hook macro does not allow more than one argument, which is automatically used from the surrounding \cs{label} call and is the usual label name.
\end{docCommand}
\clearpage
\part{Meta-Information}
\parttoc
\clearpage
\section{To - Do list}
\begin{itemize}
\item Merging of counter groups, removing counters from counter groups
\item Backup and restoration of individual counters not being member of a counter group
\item Switch to the container support for all features -- this is a major task and will be done in (tiny) steps.
\item Better counter definition/copy counter routines \(\longrightarrow\) another package perhaps
\item More examples
\item Some macro names might be non-intuitive
\item Improve documentation
\item Hooks for conditionals on \CHDocCounter*{numberofruns} (see \cref{subsection:numberofruns})
\end{itemize}
Some issues that have been addressed partially are:
\begin{itemize}
\item \CHDocNew{1.0} Add counter group support for the \CHDocTag{backup} feature, i.e. define a symbolic name for a group of counters that should be controlled by the backup feature. This will allow multiple backup groups, which might be necessary.
\end{itemize}
If you
\begin{itemize}
\item find bugs
\item errors in the documentation
\item have suggestions
\item have feature requests
\end{itemize}
don't hesitate and contact me using my mail address: \mymailtoaddress.
\clearpage
\section{Acknowledgments}
I would like to express my gratitudes to the developpers of fine \LaTeX{} packages and of course
to the users at tex.stackexchange.com, especially to
\begin{itemize}
\item Paulo Roberto Massa Cereda
\item Enrico Gregorio
\item Joseph Wright
\item David Carlisle
\item Werner Grundlingh
\item Gonzalo Medina
\item Cosmo Huber (for providing the bug report with the \CHDocPackage{calc} package.)
\end{itemize}
for their invaluable help on many questions on macros.
\vspace{2\baselineskip}
\begin{marker}
A special gratitude goes to Prof. Dr. Dr. Thomas Sturm for providing the wonderful \CHDocPackage{tcolorbox} package which was used to
write this documentation.
\end{marker}
\clearpage
\section{Version history}
\begin{itemize}[itemsep=15pt]
\item \CHDocFullVersion{1.4}
\begin{itemize}
\item Improved the core macros \cs{refstepcounter} and \cs{stepcounter} in order to fit the \CHDocPackage{expl3} and \CHDocPackage{xparse} changes of Februar - April 2017.
\item Added following experimental features:
\item \refCom{CounterFormat} with quick and possible recursive change of the counter output
\item \refCom{StoreCounterFormats}, \refCom{AddCounterFormats} and \refCom{RemoveCounterFormats} for defining own short hand counter formats.
\item Provided the macros \refCom{xalphalph} and \refCom{xAlphAlph} in order to allow counter output in the same manner as the \CHDocPackage{alphalph} does.
\item Added the macros \refCom{CounterWithin}, \refCom{CounterWithin*}, \refCom{CounterWithout} and \refCom{CounterWithout*} which provides a quicker access to add or remove counters from the reset list and changing the corresponding \cs{the...} macros.
\item Provided the \refCom{LoopCounterResetList} to perform the same action on all counters being in the reset list of a given counter.
\item New macros \refCom{ClearCounterResetList} and \refCom{ClearCounterResetList*} to remove all counters on first level of a driver counter.
\item Added the explanation (missing in previous versions) to the documentation that the \refCom{AddToReset}, \refCom{RemoveFromReset} and \refCom{RemoveFromFullReset} macros actually support a comma separated list of counter names for the first argument.
\end{itemize}
\item \CHDocFullVersion{1.3}
\begin{itemize}
\item Provided the \refCom{LaTeXLabel} macro to access the non-xassoccnt version of the \refCom{label} command.
\item \CHDocExperimentalFeature Added the concept of label hooks, see \cref{subsec::associated_counters_experimental} for more information.
\item The macros \cs{Last...} are defined with \CHDocPackage{expl3} methods.
\item Added \refCom{GetAllResetLists} and \refCom{GetParentCounter} for information on parent (or driver) counters.
\end{itemize}
\item \CHDocFullVersion{1.2}
\begin{itemize}
\item Corrected some typos in the manual.
\item The macros \refCom{NewDocumentCounter}, \refCom{DeclareDocumentCounter} and \refCom{NewTotalDocumentCounter} allow multiple counters to be specified and defined.
\item Added the macro \refCom{DeclareTotalAssociatedCounters} in order to combine total counters and the associated feature, i.e. the counters are total ones and associated to a driver counter.
\item \CHDocExperimentalFeature An extended version of \refCom{label} is provided to allow labels also for associated counters during the stepping process of the driver counter.
\end{itemize}
\item \CHDocFullVersion{1.1}
\begin{itemize}
\item Added some missing basic functions needed after the more restrictive \CHDocPackage{expl3} update from 2016/10/19
\item Added a statement about the requirement to load \CHDocPackage{tcolorbox} before \CHDocPackage{xassoccnt} in the documentation (i.e. this file!)
\end{itemize}
\item \CHDocFullVersion{1.0}
\begin{itemize}
\item \CHDocNew{1.0} Restructured the \CHDocPackage{xassoccnt} manual file.
\item \CHDocNew{1.0} Added some improvements for counter reset lists macros
\item \CHDocNew{1.0} Added new backup/restore features, with cascading counters possibility -- the old backup/restore macros are still available but renamed with a prefix \cs{Former...}
\item \CHDocNew{1.0} Added the \refCom{RemoveAllPeriodicCounters} -- it was missing in the \CHDocTag{periodic counter} features -- see \nameref{section:periodic_counters} for more information on this.
\item \CHDocNew{1.0} Added the expandable version of \refCom{TotalCounterInternalName} named
\refCom{TotalCounterInternalNameExp}.
\end{itemize}
\item \CHDocFullVersion{0.9}
\begin{itemize}
\item \CHDocUpdate{0.9}\refCom{TotalValue} is an expandable command now.
\item \CHDocNew{0.9} Added the \CHDocTag{periodic counter} features -- see \nameref{section:periodic_counters} for more information on this.
\end{itemize}
\item \CHDocFullVersion{0.8}
\begin{itemize}[label={$\checkmark$}]
\item \CHDocUpdate{0.8}Fixed the \refCom{SuspendCounters} and \refCom{ResumeSuspendedCounters} macros -- the comma separated list of counters was not used (contrary to the purpose and the documentation description).
\item \CHDocNew{0.8}Additions of commands
\begin{itemize}[label={$\triangleright$}]
\item \refCom{ResumeAllSuspendedCounters}
\item \refCom{CascadeSuspendCounters}
\item \refCom{DisplayResetList}
\item \refCom{ShowResetList}
\end{itemize}
\end{itemize}
\item \CHDocFullVersion{0.7}
\leavevmode
\begin{itemize}[label={$\checkmark$}]
\item\CHDocUpdate{0.7} Fixed a small bug in the \CHDocPackage{\PackageDocName} version of \cs{stepcounter}
\item Added some macros that support the output of binary, octal or hexadecimal (both lower/uppercase) values of counters. \CHDocNew{0.7}
\item Added the \cs{Loop...Counters} macros that perform an action in loop on all given counter names. \CHDocNew{0.7}
\end{itemize}
\item \CHDocFullVersion{0.6}
\begin{itemize}[label={$\checkmark$}]
\item The coupled counters allow to specify a counter group to which all relevant counters belong, this allows several coupled counter groups then \CHDocNew{0.6}
\item Fixed a small bug within backup counter support -- the resetting was not done any more \CHDocNew{0.6}
\item Added the \CHDocKey{nonumberofruns}\ package option.
\end{itemize}
\item
\CHDocFullVersion{0.5}
\begin{itemize}[label={$\checkmark$}]
\item Added support (very experimental!) for the \CHDocTag{coupled counters} feature, see \cref{sec::coupledcounters} about this feature! \CHDocNew{0.5}
\item Added \cs{RegisterTotalDocumentCounter} and improved \cs{TotalValue} support\CHDocNew{0.5}
\end{itemize}
\item
\CHDocFullVersion{0.4}
\begin{itemize}[label={$\checkmark$}]
\item Added \cs{BackupCounterValues} and \cs{RestoreCounterValues} support\CHDocNew{0.4}
\item Added \cs{StepDownCounter} and \cs{SubtractFromCounter} macros\CHDocNew{0.4}
\end{itemize}
\item
\CHDocFullVersion{0.3}\CHDocUpdate{0.3}
\begin{itemize}[label={$\checkmark$}]
\item Added the \CHDocTag{totalcounter} features similar to the packages \CHDocPackage{totcount} or \CHDocPackage{totalcount} \tcbdocmarginnote{\tcbdocnew{2015-11-11}}
\item Added the \CHDocTag{super total counter} features \tcbdocmarginnote{\tcbdocnew{2015-25-11}}
\item Added the \CHDocCounter*{numberofruns} counter \tcbdocmarginnote{\tcbdocnew{2015-25-11}}
\end{itemize}
\item \CHDocFullVersion{0.2}\CHDocUpdate{0.2}
Improved \cs{stepcounter} to remove some incompatibilities with the \CHDocPackage{perpage}. This is only partially managed so far.
\item
\CHDocFullVersion{0.1}
A major bug fixed due to some error in usage together with \CHDocPackage{calc} when the driven counters are not stepped any longer.
The culprit was in \CHDocPackage{assoccnt} that the counter reset list was not really disabled.
Thanks to this question \url{http://tex.stackexchange.com/questions/269731/calc-breaks-assoccnt} this bug was detected.
This however lead to some internal inconsistencies and it was decided to rewrite \CHDocPackage{assoccnt} with \CHDocPackage{expl3} and the features of the new \LaTeX\ 3 - Syntax.
\end{itemize}
\clearpage
\phantomsection
\part{Appendix}\label{examplesappendix}
\setcounter{section}{0}
\renewcommand{\theHsection}{appendix.\thesection}
\renewcommand{\thesection}{\Alph{section}}
Note: The \cs{DeclareAssociatedCounters} command has to be used in the preamble of the document. It's missing here for the sake of a compact example.
\section[Total number of sections]{Example: Total number of sections}
In this example, all sections of this document are counted, i.e. the current one as well as all following ones.
\begin{dispExample}
This document has \total{totalsections} section(s)%
\end{dispExample}
\section[Subsection with suspension]{Example: Total number of subsections with suspension}
In this example, the subsections of this document are counted but later on, the associatedcounter is removed from the list, so it is frozen.
\begin{dispExample}
\subsection{First dummy subsection}
SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
\subsection{Second dummy subsection}
SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
\RemoveAssociatedCounter{subsection}{totalsubsections}%
\subsection{Third dummy subsection after removing the associated counter}
SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
\end{dispExample}
\subsection{Suspension of a non-associated counter}
This example will show the suspension of a non-associated counter
\begin{dispExample}
\setcounter{equation}{0}%
\SuspendCounters{equation}%
\begin{equation}
E_{0} = mc^2
\end{equation}
\begin{equation}
E^2 = \left({ pc}\right)^2 + E^{2}_{0}
\end{equation}
\begin{equation}
m(v) = \frac{m_{0}}{\sqrt{1-\frac{v^2}{c^2}}}
\end{equation}
There are \number\value{equation}~equations in here!
\end{dispExample}
\section[Former Backup/Restore Feature]{Former backup and restore of counter values}\label{section::old_backuprestore} \CHDocUpdate{1.0}
\subsection[Macros for backup/restoration]{Description of backup and restoring macros for counter values}
\begin{docCommand}{FormerBackupCounterValues}{\oarg{options}\marg{counter name1, counter name2,...}}
This macro adds counter names (separated by a comma) to a list and stores the current values of the counters to another list. The values are used from the current state where this command is used, not a previous or a later state is stored.
\begin{itemize}
\item All counters in the list will be reset to zero (after storing the values) for the next usage, unless the \refKey{resetbackup} key is set to \meta{false}.
\item Multiple specification of the same counter name is possible, but only the first occurence will be regarded -- consecutive occurences of the same counter name are not taken into account. \CHDocNew{0.5}
\end{itemize}
\begin{docKey}[][]{resetbackup}{=\meta{true/false}}{initially true}
This key decides whether \textbf{all} counters in the backup list should be reset to zero or should keep the current value. The default value is \meta{true}.
\end{docKey}
Please note: If a name does not belong to a counter register the compilation aborts with an error message!
Some remarks
\begin{marker}
If a specific counter name is suffixed with an \textasteriskcentered\ at its end the resetting is disabled for this particular counter, regardless whether \refKey{resetbackup} is set to true or not.\CHDocNew{0.4}
\end{marker}
\begin{marker}
Strangely enough, a counter name like \CHDocCounter{foo*} is possible, but \cs{thefoo*} would fail. Be careful about choosing counter names for new counters -- just restrict yourself to the usual letters (and if really needed, using \makeatletter @\makeatother)
\end{marker}
\end{docCommand}%
\begin{docCommand}{FormerRestoreAllCounterValues}{\oarg{options}} \CHDocNew{0.5}
This macro restores all stored counter values corresponding to the counter names.
As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
The backup list is cleared after the restoring has been finished.
\end{docCommand}
\begin{marker}
The command \refCom{FormerRestoreAllCounterValues} was previously called \refCom{FormerRestoreCounterValues} -- that macro is now reserved for updating only particular
counters, not all in a row.
\end{marker}
\begin{docCommand}{FormerRestoreCounterValues}{\oarg{options}\marg{counter name1,counter name2,...}} \CHDocUpdate{0.5}
This macro restores only the stored counter values given by the counter names.
As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
%The backup list is cleared after the restoring has been finished.
\end{docCommand}
\begin{dispExample}
\captionof{figure}{A dummy figure}
\captionof{table}{A dummy table}
\FormerBackupCounterValues{figure,table*}
\captionof{figure}{Another dummy figure}
\captionof{table}{Another dummy table}
\captionof{figure}{Even another dummy figure}
\captionof{table}{Even another dummy table}
Before restoring: \thefigure\ and \thetable
\FormerRestoreAllCounterValues
Restored the values: \thefigure\ and \thetable
\captionof{figure}{Yet another dummy figure}
\captionof{table}{Yet another dummy table}
\end{dispExample}
\begin{docCommand}{FormerAddBackupCounter}{\oarg{options}\marg{counter name1,counter name2,...}} \CHDocNew{0.5}
This is similar to \refCom{FormerBackupCounterValues}, but adds the counter names to an existing global list and can be applied after \refCom{FormerBackupCounterValues}.
\end{docCommand}
\begin{docCommand}{FormerRemoveBackupCounters}{\oarg{options}\marg{counter name1, counter name2,...}} \CHDocNew{0.5}
This macro removes the counters from the list of backup counters and immediately restores the counter value unless the starred version \refCom{FormerRemoveBackupCounters*} is used.
If the package \CHDocPackage{hyperref} is used, the macro \cs{theH...} (see \nameref{subsec::backup_and_hyperref} on this) is restored to the original meaning.
As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
\end{docCommand}
\begin{docCommand}{FormerRemoveBackupCounters*}{\oarg{options}\marg{counter name}} \CHDocNew{0.5}
This command is basically similar to \refCom{FormerRemoveBackupCounters}, but does not restore the counter value right at the place the macro is used.
As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
\end{docCommand}
\clearpage
\markboth{\indexname}{\indexname}
%%%% Index of commands etc.
\printindex
\end{document}
|