summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/koma-script/tocbasic.dtx
blob: 9afd1be9a2dc8f867aaa92874fca114cbcd47447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
% \CheckSum{1455}
% \iffalse meta-comment
% ======================================================================
% tocbasic.dtx
% Copyright (c) Markus Kohm, 2008-2015
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of files `tocbasic.dtx' and `scrlogo.dtx' at least.
%
% This work consists of all files listed in manifest.txt.
% ----------------------------------------------------------------------
% tocbasic.dtx
% Copyright (c) Markus Kohm, 2008-2015
%
% Dieses Werk darf nach den Bedingungen der LaTeX Project Public Lizenz,
% Version 1.3c, verteilt und/oder veraendert werden.
% Die neuste Version dieser Lizenz ist
%   http://www.latex-project.org/lppl.txt
% und Version 1.3c ist Teil aller Verteilungen von LaTeX
% Version 2005/12/01 oder spaeter und dieses Werks.
%
% Dieses Werk hat den LPPL-Verwaltungs-Status "author-maintained"
% (allein durch den Autor verwaltet).
%
% Der Aktuelle Verwalter und Autor dieses Werkes ist Markus Kohm.
%
% Dieses Werk besteht aus den in manifest.txt aufgefuehrten Dateien.
% ======================================================================
% \fi
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \iffalse
%%% From File: $Id: tocbasic.dtx 2041 2015-03-25 08:42:54Z kohm $
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\begingroup
  \def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
  \filedate$Date: 2015-03-25 09:42:54 +0100 (Wed, 25 Mar 2015) $
  \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
  \filerevision$Revision: 1962 $
\endgroup
\ProvidesFile{tocbasic.dtx}[\filedate\space\filerevision\space
%</dtx>
%<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%<doc>\ProvidesFile{tocbasic.tex}[%
%<package>\ProvidesPackage{tocbasic}[%
%<*dtx|package|driver|doc>
%!KOMAScriptVersion
  package
%</dtx|package|driver|doc>
%<driver>  (driver)%
%<package|doc>  (handling toc-files)%
%<*dtx>
  (dtx)%
%</dtx>
%<*dtx|package|driver|doc>
]
%</dtx|package|driver|doc>
%<*dtx>
\ifx\documentclass\undefined
  \input scrdocstrip.tex
  \@@input scrkernel-version.dtx
  \@@input scrstrip.inc
  \KOMAdefVariable{COPYRIGHTFROM}{2008}
  \generate{\usepreamble\defaultpreamble
    \useWarning\@gobbletwo
    \file{tocbasic.tex}{%
      \from{tocbasic.dtx}{doc}%
    }%
  }
  \generate{\usepreamble\defaultpreamble
    \file{tocbasic.sty}{%
      \from{tocbasic.dtx}{package}%
      \from{scrlogo.dtx}{logo}%
    }%
  }%
  \@@input scrstrop.inc
\else
  \let\endbatchfile\relax
\fi
\endbatchfile
%</dtx>
%<*driver>
\documentclass[halfparskip-]{scrdoc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{array}
\usepackage{listings}
\lstset{breaklines,prebreak=\mbox{$\hookleftarrow$},language=[LaTeX]TeX,
  basicstyle=\small}
\lstnewenvironment{lstcode}[1][]{%
  \lstset{breaklines,prebreak=\mbox{$\hookleftarrow$},language=[LaTeX]TeX,
    basicstyle=\ttfamily\small,#1}%
}{}
\lstnewenvironment{lstoutput}[1][]{}{}
\CodelineIndex
\RecordChanges
\GetFileInfo{tocbasic.dtx}
\sloppy
\DocInput{\filename}
\end{document}
%</driver>
% \fi
%
% \providecommand*{\DescribeCounter}{\DescribeMacro}
% \let\Macro\cs
% \let\Class\textsf
% \let\Package\textsf
% \let\File\texttt
% \let\Environment\texttt
% \let\Parameter\marg
% \let\OParameter\oarg
% \let\PName\meta
% \let\PValue\texttt
% \let\Option\texttt
% \newenvironment{Example}{\quote
%   \hspace*{-\leftmargin}\textbf{Example:}\enskip\ignorespaces
% }{\endquote}
% \newlength\descwidth
% \newenvironment{desctabular}{
%   \setlength{\descwidth}{\linewidth}
%   \addtolength{\descwidth}{-1em}
%   \addtolength{\descwidth}{-2\tabcolsep}
%   \tabular{@{}lp{\descwidth}@{}}
%   \hline
% }{%
%   \hline
%   \endtabular
% }
% \newcommand{\pventry}[2]{\multicolumn{2}{@{}l@{}}{\PValue{#1}}\\
%   ~ & #2 \\ }
% \providecommand*{\autoref}[1]{\expandafter\AUTOREF#1:}
% \newcommand*{\AUTOREF}{}
% \makeatletter
% \def\AUTOREF#1:#2:{\edef\@tempa{#1}\edef\@tempb{tab}\ifx\@tempa\@tempb 
%   table~\fi
%   \edef\@tempb{sec}\ifx\@tempa\@tempb section~\fi
%   \ref{#1:#2}}
% \makeatother
% \providecommand*{\BeginIndex}[2]{}
% \providecommand*{\IndexPackage}[2][]{\index{#2 (package)}}
% \providecommand*{\IndexCmd}[2][]{\index{\cs{#2}}}
% \providecommand*{\Index}[1][]{\index}
% \providecommand*{\IndexOption}[2][]{\index{#2 (option)}}
% \providecommand*{\IndexLength}[2][]{\index{\cs{#2} (length)}}
% \providecommand*{\textnote}[2][]{}
% \providecommand*{\important}[2][]{}
% \providecommand*{\KOption}[1]{\texttt{#1=}}
% \providecommand*{\OptionValue}[2]{\texttt{#1=#2}}
% \providecommand*{\ChangedAt}[2]{}
%
% \begin{document}
% \title{\KOMAScript{} \partname\ \texttt{\filename}%
%   \thanks{Diese Datei ist Version \fileversion\ von \texttt{\filename}.}}
% \date{\filedate}
% \author{Markus Kohm\thanks{mailto:komascript(at)gmx.info}}
% \maketitle
% \begin{abstract}
% \iffalse
%<*doc>

\translator{Markus Kohm}

% Date of the translated German file: 2012/03/14

\chapter[{Management of Tables and Lists of Contents Using
  \Package{tocbasic}}]
  {Management of Tables and Lists of Contents Using
  \Package{tocbasic}\protect\footnote{This chapter has been generated from the
 source of the package. It's not a 1-to-1 translation of the German
 manual. Currently translation has not been finished}}
\labelbase{tocbasic}

\BeginIndex{Package}{tocbasic}%
\BeginIndex{}{table of contents}%
\BeginIndex{}{list>of contents}%
\BeginIndex{}{file>extension}%
%</doc>
%<*doc|dtx>
% \fi
The main purpose of package \Package{tocbasic} is to provide features for
authors of classes and packages to create own tables or lists of contents like
the list of figures and the list of tables and thereby allow other classes or
packages some types of control over these. For examples package
\Package{tocbasic} delegates language control of all these tables and lists of
contents to package \Package{babel}\IndexPackage{babel}%^^A
%\iffalse^^A
\ (see \cite{package:babel})%^^A
%\fi^^A
. So automatic change of language will be provided inside
all these tables and lists of contents. Using \Package{tocbasic} will
exculpate authors of classes and packages from implementation of such
features.

\KOMAScript{} itself uses \Package{tocbasic} not only for the table of
contents but also for the already mentioned lists of figures and tables.
% \iffalse
%<*dtx>
% \fi
% \end{abstract}
%
% \tableofcontents
% 
% \section{Legal Note}
% \label{sec:tocbasic.legalnote}
% 
% You are allowed to destribute this part of \KOMAScript{} without the main
% part of \KOMAScript{}. The files ``\File{scrlogo.dtx}'' and
% ``\File{tocbasic.dtx}'' may be distributed together under the conditions
% of the \LaTeX{} Project Public License, either version~1.3c of this license
% or (at your option) any later version.
%
% The latest version of this license is in
% \mbox{http://www.latex-project.org/lppl.txt} and version~1.3c or later is
% part of all distributions of \LaTeX{} version~2005/12/01 or later.
%
% The \KOMAScript{} bundle may be found at
% CTAN:/\mbox{macros}/\linebreak[3]\mbox{latex}/\linebreak[3]\mbox{contrib}/%
% \linebreak[3]\mbox{koma-script}/. 
% ``CTAN:'' is a shortcut for every ``tex-archive'' directory at every
% CTAN-server or CTAN-mirror. See \mbox{http://www.ctan.org} for a list of all
% those servers and mirrors.
%
% \section{Using Package \Package{tocbasic}}
% \label{sec:tocbasic.usage}
%
% This package was made to be used by class and package authors.  Because of
% this the package has no options.  If different packages would load it with
% different options a option clash would be the result.  So using options
% wouldn't be a good idea.
%
% This package may be used by by other class and package authors.  It is also
% allowed to distribute it without the main part of \KOMAScript{} (see
% section~\ref{sec:tocbasic.legalnote}.  Because of this, it does not use any
% \KOMAScript{} package, that isn't allowed to be distributed without the main
% part of \KOMAScript{}, too.  Currently \Package{tocbasic} does only need
% package \Package{keyval} from the graphics bundle.
%
% There are two kind of commands.  The first kind are basic command.  Those
% are used to inform other packages about the extensions used for files that
% represent a list of something.  Classes or packages may use this information
% e.\,g, for putting something to every of those files.  Packages may also ask,
% if an extension is already in use.  This does even work, if \Macro{nofiles}
% was used. The second kind are commands to create the list of something.
% \iffalse
%</dtx>
% \fi

\section{Basic Commands}
\label{sec:tocbasic.basics}

Basic commands are used to handle a list of all extensions\textnote{file
  extension, table or list of contents} known for files representing a table
of contents or list of something.  Entries to such files are typically written
using \Macro{addtocontents}\important{\Macro{addtocontents},
  \Macro{addcontentsline}} or \Macro{addcontentsline}.  There are also
commands to do something for all known extensions.  And there are commands to
set or unset features of an extension or the file represented by the
extension.  Typically an extension also has an owner\textnote{file owner}.
This owner may be a class or package or a term decided by the author of the
class or package using \Package{tocbasic}, e.\,g., \KOMAScript{} uses the
owner \texttt{float} for list of figures and list of tables, and the file name
of the class file as owner for the table of contents.

% \iffalse
\begin{Declaration}
  \Macro{ifattoclist}\Parameter{extension}\Parameter{true
    part}\Parameter{false part}
\end{Declaration}
\BeginIndex{Cmd}{ifattoclist}%
This command
%<*dtx>
%\fi
\DescribeMacro{\ifattoclist}
Command \Macro{ifattoclist}\Parameter{extension}\Parameter{true
  instructions}\Parameter{false instructions}
% \iffalse
%</dtx>
% \fi
may be used to ask, wether or not an \PName{extension} is already a known
extension.  If the \PName{extension} is already known the \PName{true
  instructions} will be used, otherwise the \PName{false instructions} will be
used.
\begin{Example}
  Maybe you want to know if the extension ``\File{foo}'' is already in use to
  report an error, if you can not use it:
\begin{lstcode}
  \ifattoclist{foo}{%
    \PackageError{bar}{%
      extension `foo' already in use%
    }{%
      Each extension may be used only 
      once.\MessageBreak
      The class or another package already 
      uses extension `foo'.\MessageBreak
      This error is fatal!\MessageBreak  
      You should not continue!}%
  }{%
    \PackageInfo{bar}{using extension `foo'}%
  }
\end{lstcode}
\end{Example}
% \iffalse
\EndIndex{Cmd}{ifattoclist}%

\begin{Declaration}
  \Macro{addtotoclist}\OParameter{owner}\Parameter{extension}
\end{Declaration}
\BeginIndex{Cmd}{addtotoclist}%
This command
%<*dtx>
%\fi
\DescribeMacro{\addtotoclist}
Command \Macro{addtotoclist}\OParameter{owner}\Parameter{extension}
% \iffalse
%</dtx>
% \fi
adds the \PName{extension} to the list of known extensions. But if the
\PName{extension} is a known one already, then an error will be reported to
avoid double usage of the same \PName{extension}.

If the optional argument, \OParameter{owner}, was given this \PName{owner}
will be stored to be the owner of the \PName{extension}.  If the optional
argument has been omitted, \Package{tocbasic} tries to find out the file name
of the current processed class or package and stores this as owner.
This\textnote{Attention!} will fail if \Macro{addtotoclist} was not used,
loading a class or package but using a command of a class or package after
loading this class or package.  In this case the owner will be set to
``\PValue{.}''.  

Please note\textnote{Attention!} that an empty \PName{owner} is not the same
like omitting the optional argument with the braces. An empty argument would
result in an empty owner.
\begin{Example}
  You want to add the extension ``\File{foo}'' to the list of known extension,
  while loading your package with file name ``\File{bar.sty}'':
\begin{lstcode}
  \addtotoclist{foo}
\end{lstcode}%
  This will add the extension ``\PValue{foo}'' with owner ``\PValue{bar.sty}''
  to the list of known extensions, if it was not already on the list of known
  extensions. If the class or another package already added the extension you
  will get the error:
\begin{lstoutput}
  Package tocbasic Error: file extension `foo' cannot be used twice

  See the tocbasic package documentation for explanation.
  Type  H <return>  for immediate help.
\end{lstoutput}
  and after typing \texttt{H} and pressing the return key you will get the
  help:
\begin{lstoutput}
  File extension `foo' is already used by a toc-file, while bar.sty
  tried to use it again for a toc-file.
  This may be either an incompatibility of packages, an error at a package,
  or a mistake by the user.
\end{lstoutput}
  
  Maybe your package has a command, that creates list of files dynamically.  In
  this case you should use the optional argument of \Macro{addtotoclist} to
  set the owner.
\begin{lstcode}
  \newcommand*{\createnewlistofsomething}[1]{%
    \addtotoclist[bar.sty]{#1}%
    % Do something more to make this list of something available
  }
\end{lstcode}
  If the user calls now, e.\,g.,
\begin{lstcode}
  \createnewlistofsomething{foo}
\end{lstcode}
  this would add the extension ``\PValue{foo}'' with the owner
  ``\PValue{bar.sty}'' to the list of known extension or report an error, if the
  extension is already in use.
\end{Example}
You may use any owner you want.  But it should be unique!  So, if you would
be, e.\,g., the author of package \Package{float} you could use for example
owner ``\PValue{float}'' instead of owner ``\PValue{float.sty}'', so the
\KOMAScript{} options for the list of figures and the list of tables will also
handle the lists of this package. Those are already added to the known
extensions when the option is used. This is because \KOMAScript{} already
registers file extension ``\PValue{lof}'' for the list of figures and file
extension ``\PValue{lot}'' for the list of tables with owner
``\PValue{float}'' and sets options for this owner.
% \iffalse
\EndIndex{Cmd}{addtotoclist}%
% \fi

% \iffalse
\begin{Declaration}
  \Macro{AtAddToTocList}\OParameter{owner}\Parameter{instructions}
\end{Declaration}
\BeginIndex{Cmd}{AtAddToTocList}%
This command
%<*dtx>
%\fi
\DescribeMacro{\AtAddtoTocList}
Command \Macro{AtAddToTocList}\OParameter{owner}\Parameter{instructions}
% \iffalse
%</dtx>
% \fi
adds the \PName{instructions} to a internal list of instructions that will be
processed whenever a file extension with the given \PName{owner} will be
added to the list of known extensions using \Macro{addtotoclist}.  The
optional argument is handled in the same way as with the command
\Macro{addtotoclist}. With an empty \PName{owner} you may
add \Parameter{instructions}, that will be processed at every successful
\Macro{addtotoclist}, after processing the instructions for the individual
owner.  While processing the \PValue{instructions},
\Macro{@currext}\IndexCmd{@currext}\important{\Macro{@currext}} will be set to
the extension of the currently added extension.
\begin{Example}
  \Package{tocbasic} itself uses
\begin{lstcode}
  \AtAddToTocList[]{%
    \expandafter\tocbasic@extend@babel
    \expandafter{\@currext}%
  }
\end{lstcode}
  to add every extension to the \Package{tocbasic}-internal babel handling of
  files.
\end{Example}

The two \Macro{expandafter} commands are needed, because the argument of
\Macro{tocbasic@extend@babel} has to be expanded!  See the description of
\Macro{tocbasic@extend@babel} at \autoref{sec:tocbasic.internals}%
% \iffalse
, \autopageref{desc:tocbasic.cmd.tocbasic@extend@babel}
% \fi
for more information.
% \iffalse
\EndIndex{Cmd}{AtAddToTocList}%
% \fi

% \iffalse
\begin{Declaration}
  \Macro{removefromtoclist}\OParameter{owner}\Parameter{extension}
\end{Declaration}
\BeginIndex{Cmd}{removefromtoclist}%
This command
%<*dtx>
%\fi
\DescribeMacro{\removefromtoclist}
Command \Macro{removefromtotoclist}\OParameter{owner}\Parameter{extension}
% \iffalse
%</dtx>
% \fi
removes the \PName{extension} from the list of known extensions.  If the
optional argument, \OParameter{owner}, was given, the \PName{extension} will
only be removed if it was added by this \PName{owner}. See description of
\Macro{addtotoclist} for information of omitting optional argument. Note that
an empty \PName{owner} is not the same like omitting the optional argument,
but removes the \PName{extension} without any owner test.%
% \iffalse
\EndIndex{Cmd}{removefromtoclist}%
% \fi

% \iffalse
\begin{Declaration}
  \Macro{doforeachtocfile}\OParameter{owner}\Parameter{instructions}
\end{Declaration}
\BeginIndex{Cmd}{doforeachtocfile}%
%<*dtx>
% \fi
\DescribeMacro{\doforeachtocfile}
% \iffalse
%</dtx>
% \fi
Until now you've learned to know commands that result in more safety in
handling file extensions, but also needs some additional effort. With
\Macro{doforeachtocfile}%^^A
% \iffalse
%<*dtx>
% \fi
\OParameter{owner}\Parameter{instructions}%^^A
% \iffalse
%</dtx>
% \fi
\ you will win for this. The command provides to processes \PName{instructions}
for every known file extension of the given \PName{owner}.  While processing
the \PName{instructions} \Macro{@currext} is the extension of the current
file.  If you omit the optional argument, \OParameter{owner}, every known file
extensions independent from the owner will be used. If the optional argument
is empty, only file extensions with an empty owner will be processed.
\begin{Example}
  If you want to type out all known extensions, you may simply write:
\begin{lstcode}
  \doforeachtocfile{\typeout{\@currext}}
\end{lstcode}
  and if only the extensions of owner ``\PValue{foo}'' should be typed out:
\begin{lstcode}
  \doforeachtocfile[foo]{\typeout{\@currext}}
\end{lstcode}
\end{Example}
% \iffalse
\EndIndex{Cmd}{doforeachtocfile}%
% \fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\tocbasicautomode}
Command
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{tocbasicautomode}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{tocbasicautomode}%
This command
% \fi
redefines \LaTeX{} kernel macro \Macro{@starttoc} to add all not yet added
extensions to the list of known extensions and use \Macro{tocbasic@starttoc}
instead of \Macro{@starttoc}. See \autoref{sec:tocbasic.internals}%^^A
% \iffalse
, \autopageref{desc:tocbasic.cmd.tocbasic@starttoc}
% \fi
for more information about \Macro{tocbasic@starttoc} and \Macro{@starttoc}.

This means that after using \Macro{tocbasicautomode} every table of contents
or list of something, that will be generated using \Macro{@starttoc} will be
at least partially under control of \Package{tocbasic}. Whether or not this will
make the wanted result, depends on the individual table of contents and lists
of something. At least the \Package{babel} control extension for
all those tables of contents and lists of something will work. Nevertheless,
it would be better if the author of the corresponding class or package will
use \Package{tocbasic} explicitly. In that case additional advantages of
\Package{tocbasic} may be used that will be described at the following
sections.%
% \iffalse
\EndIndex{Cmd}{tocbasicautomode}%
% \fi

\section{Creating a Table of Contents or List of Something}
\label{sec:tocbasic.toc}

In the previous section you've seen commands to handle a list of known
extensions and to trigger commands while adding a new extension to this
list. You've also seen a command to do something for all known extensions or
all known extensions of one owner. In this section you will see commands to
handle the file corresponding with an extension or the list of known
extensions.

% \iffalse
\begin{Declaration}
  \Macro{addtoeachtocfile}\OParameter{owner}\Parameter{content}
\end{Declaration}
\BeginIndex{Cmd}{addtoeachtocfile}%
This command
%<*dtx>
% \fi
\DescribeMacro{\addtoeachtocfile}
Command \Macro{addtoeachtocfile}\OParameter{owner}\Parameter{content}
% \iffalse
%</dtx>
% \fi
writes \PName{content} to the files of every known file extension of
\PName{owner} using \LaTeX{} kernel command \Macro{addtocontents}. If you omit
the optional argument, \PName{content} is written to the files of every known
file extension. Furthermore, the practical file name is built from
\Macro{jobname} and the file extension. While writing the \PName{content},
\Macro{@currext}\IndexCmd{@currext}\important{\Macro{@currext}} is the
extension of the currently handled file.
\begin{Example}
  You may add a vertical space of one text line to all toc-files.
\begin{lstcode}
    \addtoeachtocfile{%
      \protect\addvspace{\protect\baselineskip}%
    }
\end{lstcode}
  And if you want to do this, only for the toc-files of owner
  ``\PValue{foo}'':
\begin{lstcode}
    \addtoeachtocfile[foo]{%
      \protect\addvspace{\protect\baselineskip}%
    }
\end{lstcode}
\end{Example}
Commands, that shouldn't be expanded while writing, should be prefixed by
\Macro{protect} in the same way like they should be in the argument of
\Macro{addtocontents}.
% \iffalse
\EndIndex{Cmd}{addtoeachtocfile}%
% \fi


%\iffalse^^A meta-comment
\begin{Declaration}
%\fi^^A meta-comment
% \DescribeMacro{\addxcontentsline}
% The command
  \Macro{addxcontentsline}%
  \Parameter{extension}\Parameter{level}\OParameter{number}%^^A
  \Parameter{text}
%\iffalse^^A meta-comment
\end{Declaration}
\BeginIndex{Cmd}{addxcontentsline}%
The command \Macro{addxcontentsline}
%\fi^^A meta-comment
adds an entry of given \PName{level} to toc-file with \PName{extension}. If
the \Parameter{number} is empty or omitted the entry won't have a number for
the entry with the given \PName{text}. Entries without number may be left
aligned to the number of the numbered entries of the same \PName{level} or
indented like the text of the numbered entries of the same \PName{level},
depending on the \PValue{numberline} feature.

\begin{Example}
  Maybe you are not using a \KOMAScript{} class but need a not numbered
  chapter with entry to the table of contents. This may be done using
\begin{lstcode}
  \cleardoublepage
  \csname phantomsection\endcsname
  \addxcontentsline{toc}{chapter}
             {Chapters without Numbers}
  \chapter*{Chapters without Numbers}
  \markboth{Chapters without Numbers}{}
\end{lstcode}
  As you can see, you simply have to replace usual \Macro{addcontentsline} by
  \Macro{addxcontentsline} to support the \Package{tocbasic} feature
  \PValue{numberline}.
\end{Example}

Note, that \Macro{addxcontentsline} uses
\Macro{add\PName{level}\PName{extension}entry} if such a macro exists and
\Macro{tocbasic@addxcontentsline} otherwise. Therefore you cannot define
a macro \Macro{add\PName{level}\PName{extension}entry} using
\Macro{addxcontentsline} but \Macro{tocbasic@addxcontentsline}.

It is recommended to use \Macro{addxcontentsline} instead of
\Macro{addcontentsline} whenever possible.%
%\iffalse^^A meta-comment
\EndIndex{Cmd}{addxcontentsline}
%\fi^^A meta-comment


% \iffalse
\begin{Declaration}
% \fi
% \DescribeMacro{\addcontentslinetoeachfile}
% \DescribeMacro{\addxcontentslinetoeachfile}
% The command
  \Macro{addcontentslinetoeachtocfile}\OParameter{owner}\Parameter{level}%^^A
  \Parameter{contentsline}\\
% \iffalse
  \Macro{addxcontentslinetoeachtocfile}\OParameter{owner}%^^A
  \Parameter{level}\OParameter{number}\Parameter{text}
\end{Declaration}
\BeginIndex{Cmd}{addcontentslinetoeachtocfile}%
\BeginIndex{Cmd}{addxcontentslinetoeachtocfile}%
The first command
% \fi
is something like \Macro{addcontentsline} from \LaTeX{} kernel. In difference
to that it writes the \PName{contentsline} not only
into one file, but into all files of all known file extensions or of all known
file extensions of a given owner.

The Command \Macro{addxcontentslinetoeachtocfile}%^^A
% \OParameter{owner}\Parameter{level}\OParameter{number}\Parameter{text}%^^A
\ is similar but uses
\Macro{addxcontentsline} instead of \Macro{addcontentsline} and
therefore supports \Package{tocbasic} feature \PValue{numberline}. 
\begin{Example}
  You are a class author and want to write the chapter entry not only to the
  table of contents toc-file but to all toc-files, while \texttt{\#1} is the
  title, that should be written to the files.
\begin{lstcode}
    \addxcontentslinetoeachtocfile
              {chapter}[\thechapter]{#1}%
\end{lstcode}
  In this case the current chapter number should be expanded while writing
  into the file. So it isn't protected from expansion using \Macro{protect}.
\end{Example}
While writing \Macro{@currext}\IndexCmd{@currext}\important{\Macro{@currext}}
is the file extension of the file into which \PName{contentsline} will be
written.

It is recommended to use \Macro{addxcontentslinetoeachtocfile} instead
of \Macro{addcontentslinetoeachtocfile} whenever possible.
% \iffalse
\EndIndex{Cmd}{addxcontentslinetoeachtocfile}%
\EndIndex{Cmd}{addcontentslinetoeachtocfile}%
% \fi


% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\listoftoc}%^^A
\DescribeMacro{\listoftoc*}%^^A
\DescribeMacro{\listofeachtoc}%^^A
Commands
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{listoftoc}\OParameter{list of title}\Parameter{extension}%^^A
% \iffalse
\\
%<*dtx>
% \fi
,
% \iffalse
%</dtx>
% \fi
  \Macro{listoftoc*}\Parameter{extension}%^^A
% \iffalse
\\
%<*dtx>
% \fi
,
% \iffalse
%</dtx>
% \fi
  \Macro{listofeachtoc}\OParameter{owner}%^^A
% \iffalse
\\
%<*dtx>
% \fi
, and
% \iffalse
%</dtx>
% \fi
  \Macro{listof\PName{file-extension}name}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{listoftoc*}%
\BeginIndex{Cmd}{listoftoc}%
\BeginIndex{Cmd}{listofeachtoc}%
\BeginIndex{Cmd}{listof\PName{file-extension}name}%
These commands
% \fi
may be used to set the ``list of'' corresponding to file
extension. The\important{\Macro{listoftoc*}} star version \Macro{listoftoc*}
needs only one argument, the extension of the file. It does setup the vertical
and horizontal spacing of paragraphs, calls before hooks, reads the file, and
last but not least calls the after hooks.  You may interpret it as direct
replacement of the \LaTeX{} kernel macro
\Macro{@starttoc}\IndexCmd{@starttoc}\important{\Macro{@starttoc}}.

The\important{\Macro{listoftoc}} version without star, sets the whole file
with title, optional table of contents entry, and running heads. If the
optional argument \OParameter{list of title} was given, it will be used as
title term, optional table of contents entry and running head. Please
note\textnote{Attention!}: If the optional argument is empty, this term will
be empty, too! If you omit the optional argument, but
\Macro{listof\PName{extension}name} was defined, that will be used. If that is
also not defined, a standard ersatz name will be used and reported by a
warning message.

The\important{\Macro{listofeachtoc}} command \Macro{listofeachtoc} outputs all
lists of something of the given \PName{owner} or of all known file
extensions. Thereby\textnote{Attention!}
\Macro{listof\PName{file-extension}name} should be defined to get the correct
titles.

It\textnote{Hint!} is recommended to define
\Macro{listof\PName{file-extension}name} for all used file extensions, because
the user itself may use \Macro{listofeachtoc}.
\begin{Example}
  Assumed, you have a new ``list of algorithms'' with extension \PValue{loa}
  and want to show it:
\begin{lstcode}
  \listoftoc[List of Algorithms]{loa}
\end{lstcode}
  will do it for you. But maybe the ``list of algorithms'' should not be set
  with a title. So you may use
\begin{lstcode}
  \listof*{loa}
\end{lstcode}
  Note that in this case no entry at the table of contents will be created,
  even if you'd used the setup command above.
  See command \Macro{setuptoc}
%\iffalse
  at \autopageref{desc:tocbasic.cmd.setuptoc}
%\fi
  for more information about the
  attribute of generating entries into the table of contents using
  \Macro{setuptoc}.

  If you've defined
\begin{lstcode}
  \newcommand*{\listofloaname}{%
    List of Algorithms%
  }
\end{lstcode}
  before, then
\begin{lstcode}
  \listoftoc{loa}
\end{lstcode}
  would be enough to print the list of algorithms with the wanted heading. For
  the user it may be easier to operate, if you'd define
\begin{lstcode}
  \newcommand*{\listofalgorithms}{\listoftoc{loa}}
\end{lstcode}
  additionally.
\end{Example}

Because\textnote{Attention!} \LaTeX{} normally opens a new file for each of
those lists of something immediately, the call of each of those commands may
result in an error like:
\begin{lstoutput}
  ! No room for a new \write .
  \ch@ck ...\else \errmessage {No room for a new #3}
                                                    \fi   
\end{lstoutput}
if there are no more write handles left. Loading package
\Package{scrwfile}\important{\Package{scrwfile}}\IndexPackage{scrwfile}
%\iffalse
(see \autoref{cha:scrwfile})
%\fi
may solve this problem.
%\iffalse
\EndIndex{Cmd}{listof\PName{Dateierweiterung}name}%
\EndIndex{Cmd}{listofeachtoc}%
\EndIndex{Cmd}{listoftoc*}%
\EndIndex{Cmd}{listoftoc}%
%\fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\BeforeStartingTOC}
\DescribeMacro{\AfterStartingTOC}
The Commands
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{BeforeStartingTOC}\OParameter{extension}\Parameter{instructions}
% \iffalse
\\
%<*dtx>
% \fi
and
% \iffalse
%</dtx>
% \fi
  \Macro{AfterStartingTOC}\OParameter{extension}\Parameter{instructions}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{BeforeStartingTOC}%
\BeginIndex{Cmd}{AfterStartingTOC}%
Sometimes it's useful, to process \PName{instructions} immediately before
reading the helper file of a list of something.
These commands
% \fi
may be used to process \PName{instructions} before or after loading the file
with given \PName{extension} using \Macro{listoftoc*}, \Macro{listoftoc}, or
\Macro{listofeachtoc}.  If you omit the optional argument (or set an empty
one) the general hooks will be set. The general before hook will be called
before the individuel one and the general after hook will be called after the
individuel one. While calling the hooks
\Macro{@currext}\IndexCmd{@currext}\important{\Macro{@currext}} is the
extension of the toc-file and should not be changed.
% \iffalse

An example\textnote{Example} for usage of \Macro{AfterStartingTOC} may be
found in \autoref{sec:scrwfile.clonefilefeature} at
\autopageref{example:scrwfile.AfterStartingTOC}.
\EndIndex{Cmd}{AfterStartingTOC}%
\EndIndex{Cmd}{BeforeStartingTOC}%
% \fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\BeforeTOCHead}
\DescribeMacro{\AfterTOCHead}
The Commands
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{BeforeTOCHead}\OParameter{file extension}\Parameter{instructions}
% \iffalse
\\
%<*dtx>
% \fi
and
% \iffalse
%</dtx>
% \fi
  \Macro{AfterTOCHead}\OParameter{file extension}\Parameter{instructions}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{BeforeTOCHead}%
\BeginIndex{Cmd}{AfterTOCHead}%
This commands
% \fi
may be used to process \PName{instructions} before or after setting the title
of a list of something corresponding to given \PName{file extension} using
\Macro{listoftoc*} or \Macro{listoftoc}. If you omit the optional argument (or
set an empty one) the general hooks will be set. The general before hook will
be called before the individuel one and the general after hook will be called
after the individuel one. While calling the hooks
\Macro{@currext}IndexCmd{@currext}\important{\Macro{@currext}} is the
extension of the corresponding file and should not be changed.
% \iffalse
\EndIndex{Cmd}{AfterTOCHead}%
\EndIndex{Cmd}{BeforeTOCHead}%
% \fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\MakeMarkcase}
% \iffalse
%</dtx>
\begin{Declaration}
  \Macro{MakeMarkcase}\Parameter{text}
\end{Declaration}
\BeginIndex{Cmd}{MakeMarkcase}%
% \fi
Whenever \Package{tocbasic} sets a mark for a running head, The text of the
mark will be an argument of \Macro{MakeMarkcase}%^^A
%\Parameter{text}^^A
. This command may be used, to change the case of the letters at the running
head if wanted. The default is, to use
\Macro{@firstofone}\IndexCmd{@firstofone}\important{\Macro{@firstofone}} for
\KOMAScript{} classes. This means the text of the running head will be set
without change of case.
\Macro{MakeUppercase}\IndexCmd{MakeUppercase}\important{\Macro{MakeUppercase}}
will be used for all other classes. If you are the class author you may define
\Macro{MakeMarkcase} on your own. If \Package{scrlayer} or another package,
that defines \Macro{MakeMarkcase} will be used, \Package{tocbasic} will not
overwrite that definition.
\begin{Example}
  For incomprehensible reasons, you want to set the running heads in lower
  case letters only. To make this automatically for all running heads, that
  will be set by \Package{tocbasic}, you define:
\begin{lstcode}
  \let\MakeMarkcase\MakeLowercase
\end{lstcode}
\end{Example}
Please\textnote{Hint!} allow me some words about \Macro{MakeUppercase}, First
of all this command isn't fully expandable. This means, that problems may
occur using it in the context of other commands. Beyond that typographers
accord, that whenever setting whole words or phrases in capitals, letter
spacing is absolutely necessary. But correct letter spacing of capitals
shouldn't be done with a fix white space between all letters. Different pairs
of letters need different space between each other. Additional some letters
build holes in the text, that have to be taken into account. Packages like
\Package{ulem} or \Package{soul} doesn't provide this and
\Macro{MakeUppercase} doesn't do anything like this. Also automatic letter
spacing using package \Package{microtype} is only one step to a less-than-ideal
solution, because it cannot recognize and take into account the glyphs of the
letters. Because of this\textnote{Attention!} typesetting whole words and
phrases is expert work and almost ever must be hand made. So average users are
recommended to not do that or to use it only spare and not at exposed places
like running heads.%
% \iffalse
\EndIndex{Cmd}{MakeMarkcase}%
% \fi

% \DescribeMacro{\deftocheading}
% \iffalse
\begin{Declaration}
  \Macro{deftocheading}\Parameter{file extension}\Parameter{definition}
\end{Declaration}
\BeginIndex{Cmd}{deftocheading}%
% \fi
The package \Package{tocbasic} contains a standard definition for typesetting
headings of tables of contents or lists of something. This standard definition
is configurable by several features, described at \Macro{setuptoc} next. But
if all those features are not enough, an alternative heading command may be
defined using \Macro{deftocheading}%^^A
%\Parameter{file extension}\Parameter{definition}%^^A
. Thereby \PName{file extension} is the file extension of the corresponding
helper file. The \PName{definition} of the heading command may use one single
parameter \PValue{\#1}. While calling the newly defined command inside of
\Macro{listoftoc} or \Macro{listofeachtoc} that \PValue{\#1} will be replaced by the
corresponding heading term.
% \iffalse
\EndIndex{Cmd}{deftocheading}%
% \fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\setuptoc}
\DescribeMacro{\unsettoc}
The Commands
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{setuptoc}\Parameter{file extension}\Parameter{feature list}
% \iffalse
\\
%<*dtx>
% \fi
and
% \iffalse
%</dtx>
% \fi
  \Macro{unsettoc}\Parameter{file extension}\Parameter{feature list}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{setuptoc}%
\BeginIndex{Cmd}{unsettoc}%
This commands
% \fi
set up and unset features bound to an \PName{file extension}. The
\PName{feature list} is a comma seperated list of single
features. \Package{tocbasic} does know following features:
\begin{description}
\item[\texttt{leveldown}] uses not the top level heading below
  \Macro{part}\,---\,\Macro{chapter} if available, \Macro{section}
  otherwise\,---\,but the first sub level. This feature will be evaluated by
  the internal heading command. On the other hand, if an user defined heading
  command has been made with \Macro{deftocheading}, that user is responsible
  for the evaluation of the feature. The \KOMAScript{} classes set this
  feature using option
  \OptionValue{listof}{leveldown}important{\OptionValue{listof}{leveldown}}%
  \IndexOption{listof~=\PValue{leveldown}} for all file extensions of the
  owner \PValue{float}.
\item[\texttt{nobabel}] prevents usage of the language switch of
  \Package{babel}\IndexPackage{babel} at the helper file with the
  corresponding \PName{file extension}. This feature should be used only for
  helper files, that contain text in one language only. Changes of the
  language inside of the document will not longer regarded at the helper
  file. Package
  \Package{scrwfile}\important{\Package{scrwfile}}\IndexPackage{scrwfile} uses
  this feature also for clone destinations, because those will get the
  language change from the clone source already.
\item[\texttt{noparskipfake}] prevents\ChangedAt{v3.17}{\Package{tocbasic}}
  usage of an extra \Length{parskip} before switching \Length{parskip} off. In
  general, the consequence of this feature for documents using paragraph
  distance is less vertical space between heading and first entry than between
  normal headings and normal text.
\item[\texttt{noprotrusion}] prevents\ChangedAt{v3.10}{\Package{tocbasic}}
  disabling character protrusion at the lists of something. Character
  protrusion at the lists will be disabled by default if package
  \Package{microtype}\IndexPackage{microtype} or another package, that
  supports \Macro{microtypesetup}\IndexCmd{microtypesetup}, was loaded. So if
  you want protrusion at the lists, you have to set this feature. But
  note\textnote{Attention!}, that with character protrusion entries at the
  list may be set wrong. This is a known issue of character protrusion.
\item[\texttt{numbered}] uses a numbered heading for the table of contents or
  list of something and because of this also generates an entry to the table
  of contents. This feature will be evaluated by the internal heading
  command. On the other hand, if an user defined heading command has been made
  with \Macro{deftocheading}, that user is responsible for the evaluation of
  the feature. The \KOMAScript{} classes set this feature using option
  \OptionValue{listof}{numbered}\important{\OptionValue{listof}{numbered}}%
  \IndexOption{listof~=\PValue{numbered}} for all file extensions of the owner
  \PValue{float}.
\item[\texttt{numberline}] \leavevmode\ChangedAt{v3.12}{\Package{tocbasic}}%
  redefines \Macro{nonumberline} to use \Macro{numberline}. With this the not
  numbered entries generated by \KOMAScript{} or using \Macro{nonumberline} at
  the very beginning of the last argument of \Macro{addcontentline} will also
  be indented like numbered entries of the same type.
\item[\texttt{onecolumn}] \leavevmode\ChangedAt{v3.01}{\Package{tocbasic}}%
  typesets the corresponding table of contents or list of something with
  internal one column mode of
  \Macro{onecolumn}\IndexCmd{onecolumn}. This\textnote{Attention!} will be
  done only, if the corresponding table of contents or list of something
  doesn't use feature \PValue{leveldown}\important{\PValue{leveldown}}. The
  \KOMAScript{} classes \Class{scrbook} and \Class{scrreprt} activate this
  feature with \Macro{AtAddToTocList} (see \autoref{sec:tocbasic.basics}%^^A
% \iffalse
  , \autopageref{desc:tocbasic.cmd.AtAddToTocList}%^^A
% \fi
  ) for all lists of something with owner \PValue{float} or with themselves as
  owner. With this, e.\,g., the table of contents, the list of figures and the
  list of tables of both classes will be single columned automatically. The
  multiple-column-mode of package \Package{multicol}\IndexPackage{multicol}
  will not be recognized or changed by this option.
\item[\texttt{totoc}] writes the title of the corresponding table of contents
  or the list of something to the table of contents. This feature will be
  evaluated by the internal heading command. On the other hand, if an user
  defined heading command has been made with \Macro{deftocheading}, that user
  is responsible for the evaluation of the feature. The \KOMAScript{} classes
  set this feature using option
  \OptionValue{listof}{totoc}\important{\OptionValue{listof}{totoc}}%
  \IndexOption{listof~=\PValue{totoc}} for all file extensions of the owner
  \PValue{float}.
\end{description}
Classes and packages may know features, too, e.\,g, the \KOMAScript{} classes
know following additional features:
\begin{description}
\item[\texttt{chapteratlist}] activates special code to be put into the list
  at start of a new chapter. This code may either be vertical space or the
  heading of the chapter.
% \iffalse
  See \Option{listof}\IndexOption{listof}\important{\Option{listof}} in
  \autoref{sec:maincls.floats}, \autopageref{desc:maincls.option.listof} for
  more information about such features.
% \fi
\end{description}
\begin{Example}
  Because \KOMAScript{} classes use \Package{tocbasic} for the list of figures
  and list of tables, there's one more way to remove chapter structuring at
  those:
\begin{lstcode}
  \unsettoc{lof}{chapteratlist}
  \unsettoc{lot}{chapteratlist}
\end{lstcode}

  And if you want to have the chapter structuring of the \KOMAScript{} classes 
  at your own list of algorithms with \PName{file extension} ``\PValue{load}''
  from the previous examples, you may use
\begin{lstcode}
  \setuptoc{loa}{chapteratlist}
\end{lstcode}
  And if classes with \Macro{chapter} should also force single column mode for
  the list of algorithms you may use
\begin{lstcode}
  \ifundefinedorrelax{chapter}{}{%
    \setuptoc{loa}{onecolumn}%
  }
\end{lstcode}
  Usage of \Macro{ifundefinedorrelax} presumes package \Package{scrbase}%^^A
%\iffalse
  \ (see \autoref{sec:scrbase.if},
  \autopageref{desc:scrbase.cmd.ifundefinedorrelax})%^^A
%\fi
  .

  It\textnote{Hint!} doesn't matter if you're package would be used with
  another class. You should never the less set this feature. And if the other
  class would also recognize the feature your package would automatically use
  the feature of that class.
\end{Example}
As you may see, packages, that use \Package{tocbasic}, already provide several
interesting features, without the need of a lot of implementation effort. Such
an effort would be needed only without \Package{tocbasic} and because of this,
most packages currently lack of such features.%
% \iffalse
\EndIndex{Cmd}{unsettoc}%
\EndIndex{Cmd}{setuptoc}%
% \fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\iftocfeature}
Command
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{iftocfeature}\Parameter{file extension}\Parameter{feature}%^^A
  \Parameter{true-instructions}%^^A
%\linebreak[1]^^A
  \Parameter{false-instructions}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{iftocfeature}%
This command
% \fi
may be used, to test, if a \PName{feature} was set for \PName{file
  extension}. If so the \PName{true-instructions} will be processed, otherwise
the \PName{false-instruction} will be. This may be useful, e.\,g., if you
define your own heading command using \Macro{deftocheading} but want to
support the features \PValue{totoc}, \PValue{numbered} or \PValue{leveldown}.
% \iffalse
\EndIndex{Cmd}{iftocfeature}%
% \fi


\section{Internal Commands for Class and Package Authors}
\label{sec:tocbasic.internals}

Commands with prefix \Macro{tocbasic@} are internal but class and package
authors may use them. But even if you are a class or package author you
should not change them!

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\tocbasic@extend@babel}
% \iffalse
%</dtx>
\begin{Declaration}
  \Macro{tocbasic@extend@babel}\Parameter{file extension}
\end{Declaration}
\BeginIndex{Cmd}{tocbasic@extend@babel}%
% \fi
The Package \Package{babel}\IndexPackage{babel} 
% \iffalse
(see \cite{package:babel})
% \fi
respectively a \LaTeX{} kernel that has been extended by the language
management of \Package{babel} writes instructions to change the language
inside of the files with the file extensions \File{toc}, \File{lof}, and
\File{lot} into those files at every change of the current language
either at the begin of the document or inside the document. Package
\Package{tocbasic} extends this mechanism with
\Macro{tocbasic@extend@babel}
%\unskip\Parameter{file extension}
to be used for other file extensions too. Argument \PName{file extension} has
to be expandable! Otherwise the meaning of the argument may change until it
will be used really.

Normally this command will be used by default for every \PName{file extension}
that will be added to the list of known extensions using
\Macro{addtotoclist}. The may be suppressed using feature
\PValue{nobabel}\important{\PValue{nobabel}} (see \Macro{setuptoc},
\autoref{sec:tocbasic.toc}%^^A
% \iffalse
, \autopageref{desc:tocbasic.cmd.setuptoc}%^^A
% \fi
). For the file extensions \File{toc}, \File{lof}, and \File{lot} this will be
done automatically by \Package{tocbasic} to avoid double language switching in
the corresponding files.

Normally there isn't any reason to call this command yourself. But there may
by lists of something, that should not be under control of \Package{tocbasic},
and to are not in \Package{tocbasic}'s list of known file extensions, but
nevertheless should be handled by the language change mechanism of
\Package{babel}. The command may be used explicitly for those files. But pleas
note, that this should be done only once per file extension!%
% \iffalse
\EndIndex{Cmd}{tocbasic@extend@babel}%
% \fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\tocbasic@starttoc}
Command
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{tocbasic@starttoc}\Parameter{extension}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{tocbasic@starttoc}
This command
% \fi
is something like the \LaTeX{} kernel macro
\Macro{@starttoc}\IndexCmd{@starttoc}\important{\Macro{@starttoc}}.  It's the
command behind \Macro{listoftoc*} (siehe \autoref{sec:tocbasic.toc}%^^A
% \iffalse
, \autopageref{desc:tocbasic.cmd.listoftoc*}%^^A
% \fi
). Authors of classes or packages who want to participate from the advantages
of \Package{tocbasic} should at least use this command. Nevertheless it's
recommended to use \Macro{listoftoc}. Command \Macro{tocbasic@starttoc}
internally uses \Macro{\@starttoc}, but sets
% \expandafter\Macro\iffalse
\Length
% \fi
{parskip}\IndexLength{parskip}\important{\Length{parskip}\\
  \Length{parindent}\\
  \Length{parfillskip}} and 
% \expandafter\Macro\iffalse
\Length
% \fi
{parindent}\IndexLength{parindent} to 0 and
% \expandafter\Macro\iffalse
\Length
% \fi
{parfillskip} to 0 until infinite before. Moreover,
\Macro{@currext}\important{\Macro{@currext}}\IndexCmd{@currext} will be set to
the file extension of the current helper file, so this will be available while
the execution of the hooks, that will be done before and after reading the
helper files.

Because\textnote{Attention!} of \LaTeX{} will immediately open a new helper
file for writing after reading that file, the usage of
\Macro{tocbasic@starttoc} may result in an error message like
\begin{lstoutput}
  ! No room for a new \write .
  \ch@ck ...\else \errmessage {No room for a new #3}
                                                    \fi   
\end{lstoutput}
if there are no more unused write handles. This may be solved, e.\,g., using
package
\Package{scrwfile}\important{\Package{scrwfile}}\IndexPackage{scrwfile}.
% \iffalse
See \autoref{cha:scrwfile} for more information about that package.%
\EndIndex{Cmd}{tocbasic@starttoc}
% \fi
%

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\tocbasic@@before@hook}
\DescribeMacro{\tocbasic@@after@hook}
% \iffalse
%</dtx>
\begin{Declaration}
  \Macro{tocbasic@@before@hook}\\
  \Macro{tocbasic@@after@hook}
\end{Declaration}
\BeginIndex{Cmd}{tocbasic@@before@hook}%
\BeginIndex{Cmd}{tocbasic@@after@hook}%
% \fi
The hook \Macro{tocbasic@@before@hook} will be executed immediately before
reading a helper file for a table of contents or list of something even
before execution of the instructions of a \Macro{BeforeStartingTOC}
command. It is permitted to extend this hook using
\Macro{g@addto@macro}\IndexCmd{g@addto@macro}.

Similarly \Macro{tocbasic@@after@hook} will be executed immediately after
reading such a helper file and before execution of instructions of
\Macro{AfterStartingTOC}. It is permitted to extend this hook using
\Macro{g@addto@macro}\IndexCmd{g@addto@macro}.

\KOMAScript{} uses these hooks, to provide the automatic width calculation of
the place needed by heading numbers. Only classes and packages should use
these hooks. Users\textnote{Attention!} should really use
\Macro{BeforeStartingTOC} and \Macro{AfterStartingTOC} instead. Authors of
packages should also favor those commands! These hooks shouldn't be used to
generate any output!

If neither\textnote{Attention!} \Macro{listofeachtoc} nor \Macro{listoftoc}
nor \Macro{listoftoc*} are used for the output of a table of contents or list
of something, the hooks should be executed explicitly.%
% \iffalse
\EndIndex{Cmd}{tocbasic@@before@hook}%
\EndIndex{Cmd}{tocbasic@@after@hook}%
% \fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\tocbasic@\PName{extension}@before@hook}
\DescribeMacro{\tocbasic@\PName{extension}@after@hook}
% \iffalse
%</dtx>
\begin{Declaration}
  \Macro{tocbasic@\PName{extension}@before@hook}\\
  \Macro{tocbasic@\PName{extension}@after@hook}
\end{Declaration}
\BeginIndex{Cmd}{tocbasic@\PName{extension}@before@hook}%
\BeginIndex{Cmd}{tocbasic@\PName{extension}@after@hook}%
% \fi
These hooks are processed after \Macro{tocbasic@@before@hook}, respectively
before \Macro{tocbasic@@after@hook} before and after loading the helper file
with the corresponding file \PName{extension}. Authors\textnote{Attention!}
of classes and packages should never manipulate them! But if
neither\textnote{Attention!} \Macro{listofeachtoc} nor \Macro{listoftoc} nor
\Macro{listoftoc*} are used for the output of a table of contents or list of
something, the hooks should be executed explicitly, if they are
defined. Please note, that they even can be undefined.%
% \iffalse
\EndIndex{Cmd}{tocbasic@\PName{extension}@after@hook}%
\EndIndex{Cmd}{tocbasic@\PName{extension}@before@hook}%
% \fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\tocbasic@listhead}
Command
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{tocbasic@listhead}\Parameter{title}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{tocbasic@listhead}%
This command
% \fi
is used by \Macro{listoftoc} to set the heading of the list, either the
default heading or the individually defined heading. If you define your own
list command not using \Macro{listoftoc} you may use
\Macro{tocbasic@listhead}. In this case you should define
\Macro{@currext}\important{\Macro{@currext}}\IndexCmd{@currext} to be the file
extension of the corresponding helper file before using
\Macro{tocbasic@listhead}.
% \iffalse
\EndIndex{Cmd}{tocbasic@listhead}%
% \fi

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\tocbasic@listhead@\PName{extension}}
Command
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{tocbasic@listhead@\PName{extension}}\Parameter{title}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{tocbasic@listhead@\PName{extension}}%
This command
% \fi
is used in \Macro{tocbasic@listhead} to set the individual headings, optional
toc-entry, and running head, if it was defined. If it was not defined it will
be defined and used in \Macro{tocbasic@listhead} automatically.
% \iffalse
\EndIndex{Cmd}{tocbasic@listhead@\PName{extension}}%
% \fi

%\iffalse^^A meta-comment
\begin{Declaration}
%\fi^^A meta-comment
% \DescribeMacro{\tocbasic@addxcontentsline}
% The command
  \Macro{tocbasic@addxcontentsline}%
  \Parameter{extension}\Parameter{level}\Parameter{number}\Parameter{text}
%\iffalse^^A meta-comment
\end{Declaration}
\BeginIndex{Cmd}{tocbasic@addxcontentsline}%
This command
%\fi^^A meta-comment
uses \Macro{addcontentsline} to either create a numbered or not numbered text
entry to toc-file with given \PName{extension}. Note, that all parameters of
\Macro{tocbasic@addxcontentsline} are mandatory. But you may use an
empty \PName{number} argument, if you don't want a number.
%\iffalse^^A meta-comment
\EndIndex{Cmd}{tocbasic@addxcontentsline}
%\fi^^A meta-comment


\section{A Complete Example}
\label{sec:tocbasic.example}

This section will show you a complete example of a user defined floating
environment with list of that kind of floats and \KOMAScript{} integration
using \Package{tocbasic}. This example uses internal commands, that have a
``\texttt{@}'' in their name. This means\textnote{Attention}, that the code
has to be put into a own package or class, or has to be placed between
\Macro{makeatletter}\important[i]{\Macro{makeatletter}\\\Macro{makeatother}}%
\IndexCmd{makeatletter} and \Macro{makeatother}\IndexCmd{makeatother}.

First\textnote{environment} of all, a new floating environment will be
needed. This could simply be done using:
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newenvironment{remarkbox}{%
    \@float{remarkbox}%
  }{%
    \end@float
  }
\end{lstcode}
To the new environment is named \Environment{remarkbox}.

Each\textnote{placement} floating environment has a default
placement. This is build by some of the well known placement options:
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newcommand*{\fps@remarkbox}{tbp}
\end{lstcode}
So, the new floating environment should be placed by default only either at
the top of a page, at the bottom of a page, or on a page on its own.

Floating\textnote{type} environments have a numerical floating
type. Environments with the same active bit at the floating type cannot change
their order. Figures and table normally use type~1 and 2. So a figure that
comes later at the source code than a table, may be output earlier than the
table and vica versa.
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newcommand*{\ftype@remarkbox}{4}
\end{lstcode}
The new environment has floating type~4, so it may pass figures and floats and
may be passed by those.

The\textnote{number} captions of floating environment also have numbers.
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newcounter{remarkbox}
  \newcommand*{\remarkboxformat}{%
    Remark~\theremarkbox\csname autodot\endcsname}
  \newcommand*{\fnum@remarkbox}{\remarkboxformat}
\end{lstcode}
Here first a new counter has been defined, that is independent from chapters
or the counters of other structural levels. \LaTeX{} itself also defines
\Macro{theremarkbox} with the default Arabic representation of the counter's
value. Afterwards this has been used defining the formatted output of the
counter. Last this formatted output has been used for the output of the
environment number of the \Macro{caption} command.

Floating\textnote{file extension} environments have lists of themselves and
those need a helper file with name \Macro{jobname} and a file extension.
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newcommand*{\ext@remarkbox}{lor}
\end{lstcode}
The file extension of the helper file for the list of
\Environment{remarkbox}es is ``\File{lor}''.

This was the definition of the floating environment. But the list of this new
environment's captions is still missing. To reduce the implementation effort
package \Package{tocbasic} will be used for this. This will be loaded using
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \usepackage{tocbasic}
\end{lstcode}
inside of document preambles. Authors of classes or packages would use
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \RequirePackage{tocbasic}
\end{lstcode}
instead.

Now\textnote{extension} we register the file name extension for package
\Package{tocbasic}:
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \addtotoclist[float]{lor}
\end{lstcode}
Thereby the owner \PValue{float} has been used, to allude all further
\KOMAScript{} options for lists of something also to the new one.

Next\textnote{title} we define a title or heading for the list of
\Environment{remarkbox}es:
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newcommand*{\listoflorname}{List of Remarks}
\end{lstcode}
You may use package \Package{scrbase} to additionally support titles in other
languages than English.

Also\textnote{entry} a command is needed to define the layout of the entries
to the list of remarks:
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newcommand*{\l@remarkbox}{\l@figure}
\end{lstcode}
Here simply the entries to the list of remarks get the same layout like the
entries to the list of figure. This would be the easiest solution. A more
explicit would be, e.\,g.,
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newcommand*{\l@remarkbox}{\@dottedtocline{1}{1em}{1.5em}}
\end{lstcode}

Additionally\textnote{chapter entry} you may want structure the list of
remarks depending on chapters.
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \setuptoc{lor}{chapteratlist}
\end{lstcode}
The \KOMAScript{} classes provide that feature and may other classes do so
too. Unfortunately the standard classes do not.

This\textnote{list of remarks} would already be enough. Now, users may already
select different kinds of headings either using the corresponding options of
the \KOMAScript{} classes, or \Macro{setuptoc}, e.\,g., with or without entry
in the table of contents, with or without number. But a simply
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newcommand*{\listofremarkboxes}{\listoftoc{lor}}
\end{lstcode}
may make the usage a little bit easier again.

As you've seen only five commands refers to the list of remarks. Only three of
them are necessary. Nevertheless the new list of remarks already provides
optional numbering of the heading and optional not numbered entry into the
table of contents. Optional even a lower document structure level may be used
for the heading. Running headers are provides with the \KOMAScript{} classes,
the standard classes, and all classes that explicitly support
\Package{tocbasic}. Supporting classes even pay attention to this new list of
remarks at every new \Macro{chapter}. Even changes of the current language are
handled inside the list of remarks like they will inside the list of figures
or inside the list of tables.

Moreover.\textnote{additional features} an author of a package may add more
features. For example, options to hide \Macro{setuptoc} from the users may be
added. On the other hand, the \Package{tocbasic} manual may be referenced to
describe the corresponding features. The advantage of this would be that user
would get information about new features provides by \Package{tocbasic}. But
if the user should be able to set the features of the remarks even without
knowledge about the file extension \File{lor} a simple
\begin{lstcode}[belowskip=\dp\strutbox plus 1pt]
  \newcommand*{\setupremarkboxes}{\setuptoc{lor}}
\end{lstcode}
would be enough to use a list of features argument to
\Macro{setupremarkboxes} as list of features of file extension \File{lor}.


\section{Everything with One Command Only}
\label{sec:tocbasic.highlevel}

The example from the previous section shows, that using \Package{tocbasic} to
define floating environments and lists with the captions of those floating
environments is easy. The following example will show, that is may be even
easier.

% \iffalse
%<*dtx>
% \fi
\DescribeMacro{\DeclareNewTOC}
Command
% \iffalse
%</dtx>
\begin{Declaration}
% \fi
  \Macro{DeclareNewTOC}\OParameter{options}\Parameter{extension}
% \iffalse
\end{Declaration}
\BeginIndex{Cmd}{DeclareNewTOC}%
This command
% \fi
declares\ChangedAt{v3.06}{\Package{tocbasic}} in one step only a new list of
something, the heading of that list, the term used for the entries to the
list, and to manage the file name \PName{extension}. Additionally optional
floating and non-floating environments may be defined, and inside of both such
environments \Macro{caption}\important{\Macro{caption}}\IndexCmd{caption} may
be used. The additional features \Macro{captionabove}\important[i]{%
  \Macro{captionabove}\\
  \Macro{captionbelow}}, \Macro{captionbelow}, and \Environment{captionbeside}
of the \KOMAScript{} classes
% \iffalse
(see \autoref{sec:maincls.floats})
% \fi
may also be used inside of those environments.

Argument \PName{extension} is the file name extension of the helper file, that
represents the list of something. See \autoref{sec:tocbasic.basics} for more
information about this. This argument is mandatory and must not be empty!

Argument \PName{options} is a comma separated list, like you know it from,
e.\,g., \Macro{KOMAoptions}%
% \iffalse
\ (see \autoref{sec:typearea.options})%^^A
% \fi
. Nevertheless\textnote{Attention!}, those options cannot be set using
\Macro{KOMAoptions}\IndexCmd{KOMAoptions}! An overview of all available
options
% is shown next.
% \iffalse
may be found in \autoref{tab:tocbasic.DeclareNewTOC-options}.
% \fi

% \iffalse
\begin{desclist}
  \renewcommand*{\abovecaptionskipcorrection}{-\normalbaselineskip}%
  \desccaption[{Options for command \Macro{DeclareNewTOC}}]{%
    Options for command
    \Macro{DeclareNewTOC}\ChangedAt{v3.06}{\Package{tocbasic}}%
    \label{tab:tocbasic.DeclareNewTOC-options}%
  }{%
    Options for command \Macro{DeclareNewTOC} (continuation)%
  }%
% \fi
%\begin{description}
%  \newcommand{\entry}[2]{\item[\normalfont#1]\hfill\\* #2}
  \entry{\KOption{atbegin}\PName{instructions}}{%
    The \PName{instructions} will be executed at the begin of the floating or
    non-floating environment.%
  }%
  \entry{\KOption{atend}\PName{instructions}}{%
    The \PName{instructions} will be executed at the end of the floating or
    non-floating environment.%
  }%
  \entry{\KOption{counterwithin}\PName{\LaTeX{} counter}}{%
    If you define a float or non-float, the captions will be numbered and a
    counter \PName{type} (see option \Option{type}) will be defined. You may
    declare another counter to be the parent \LaTeX{} counter. In this case,
    the parent counter will be set before the float counter and the float
    counter will be reset whenever the parent counter is increased using
    \Macro{stepcounter} or \Macro{refstepcounter}.%
  }%
%^^A not yet implemented:
%^^A \entry{\KOption{captionpos}\PName{position}}{%
%^^A   If \PName{position} is \PValue{top} or \PValue{above} the spacing above
%^^A   and below the caption will be done for captions above objects. If
%^^A   \PName{position} is \PValue{bot}, \PValue{bottom}, or \PValue{below} the
%^^A   spacing above and below the caption will be done for captions below
%^^A   objects.
%^^A }
  \entry{\Option{float}}{%
    If set, float environments for that type will be defined. The names of the
    environments are the value of \PName{type} and for double column floats
    the value of \PName{type} with addendum ``\PValue{*}''.%
  }%
  \entry{\KOption{floatpos}\PName{float positions}}{%
    The default floating position of the float. If no float position was
    given, ``tbp'' will be used like the standard classes do for figures and
    tables.%
  }%
  \entry{\KOption{floattype}\PName{number}}{%
    The numerical float type of the defined floats. Float types with common
    bits cannot be reordered. At the standard classes figures has float type 1
    and tables has float type 2. If no float type was given, 16 will be used.%
  }%
  \entry{\Option{forcenames}}{%
    If set, the names will be even defined, if they where already defined
    before.%
  }%
  \entry{\KOption{hang}\PName{length}}{%
    The amount of the hanging indent of the entries for that list. If not
    given, 1.5\,em will be used like standard classes use for entries to list
    of figures or list of tables.%
  }%
  \entry{\KOption{indent}\PName{length}}{%
    The indent value for the entries of that list. If not given, 1\,em will be
    used like standard classes use for entries to list of figures or list of
    tables.%
  }%
  \entry{\KOption{level}\PName{number}}{%
    The level of the entries of that list. If not given level 1 will be used
    like standard classes use for entries to list of figures or list of
    tables.%
  }%
  \entry{\KOption{listname}\PName{string}}{%
    The name of the list of foo. If not given the value of \PValue{types} with
    upper case first char prefixed by ``List of '' will be used.%
  }%
  \entry{\KOption{name}\PName{string}}{%
    The name of an element. If no name is given, the value of \PValue{type}
    with upper case first char will be used.%
  }%
  \entry{\Option{nonfloat}}{%
    If set, a non floating environment will be defined. The name of the
    environment is the value of \PName{type} with postfix ``\PValue{-}''.%
  }%
  \entry{\KOption{owner}\PName{string}}{%
    The owner as described in the sections before. If no owner was given owner
    \PValue{float} will be used.%
  }%
  \entry{\KOption{type}\PName{string}}{%
    sets the type of the new declared list. The type will be used e.\,g. to
    defined a \Macro{listof}\PName{string}. If no type is set up the extension
    from the mandatory argument will be used.%
  }%
  \entry{\KOption{types}\PName{string}}{%
    the plural of the type. If no plural was given the value of \PValue{type}
    with addendum ``s'' will be used.%
  }%
% \end{description}
% \iffalse
\end{desclist}
% \fi

\begin{Example}
  Using \Macro{DeclareNewTOC} reduces the example from
  \autoref{sec:tocbasic.example} to:
\begin{lstcode}
  \DeclareNewTOC[%
    type=remarkbox,%
    types=remarkboxes,%
    float,% define a floating environment
    floattype=4,%
    name=Remark,%
    listname={List of Remarks}%
  ]{lor}
  \setuptoc{lor}{chapteratlist}
\end{lstcode}
  Beside environments \Environment{remarkbox} and \Environment{remarkbox*} the
  counter 
% \expandafter\texttt\iffalse
\Counter
% \fi
  {remarkbox}, the commands \Macro{theremarkbox},
  \Macro{remarkboxname}, and \Macro{remarkboxformat} that are used for
  captions; the commands \Macro{listremarkboxnames} and
  \Macro{listofremarkboxes} that are used at the list of remarks; and some
  internal commands that depends on the file name extension \File{lor} are
  defined. If the package should use a default for the floating type, option
  Option{floattype} may be omitted. If option \Option{nonfloat} will be used
  additionally, then a non-floating environment \Environment{remarkbox-} will
  be also defined. You may use \Macro{caption}\IndexCmd{caption} inside of
  that non-floating environment as usual for floating environments.
%\iffalse
  \hyperref[tab:tocbasic.comparison]{Figure~\ref*{tab:tocbasic.comparison}}
  showes a comparison of the commands, counters and environments of the
  example environment \Environment{remarkbox} and of the commands, counters
  and environments for figures.%
  \begin{table}
    \centering
    \caption{Comparison of example environment \Environment{remarkbox}
      and environment \Environment{figure}}
    \label{tab:tocbasic.comparison}
    \begin{tabularx}{\textwidth}{ll>{\raggedright}p{6em}X}
      \toprule
      \Environment{remarkbox} & \Environment{figure}
      & options of \Macro{DeclareNewTOC} & short description \\[1ex]
      \midrule
      \Environment{remarkbox} & \Environment{figure} 
      & \Option{type}, \Option{float} 
      & floating environments of the respective types\\[1ex]
      \Environment{remarkbox*} & \Environment{figure*} 
      & \Option{type}, \Option{float} 
      & columns spanning floating environments of the respective types\\[1ex]
      \Counter{remarkbox} & \Counter{figure} 
      & \Option{type}, \Option{float} 
      & counter used by \Macro{caption}\\[1ex]
      \Macro{theremarkbox} & \Macro{thefigure} 
      & \Option{type}, \Option{float} 
      & output command to the respective counters\\[1ex]
      \Macro{remarkboxformat} & \Macro{figureformat}
      & \Option{type}, \Option{float}
      & formating command to the respective counters used by
        \Macro{caption}\\[1ex]
      \Macro{remarkboxname} & \Macro{figurename}
      & \Option{type}, \Option{float}, \Option{name}
      & names used in the label of \Macro{caption}\\[1ex]
      \Macro{listofremarkboxes} & \Macro{listoffigures}
      & \Option{types}, \Option{float}
      & command to show the list of the respective environments\\[1ex]
      \Macro{listremarboxname} & \Macro{listfigurename}
      & \Option{type}, \Option{float}, \Option{listname}
      & heading text of the respective list \\[1ex]
      \Macro{fps@remarkbox} & \Macro{fps@figure}
      & \Option{type}, \Option{float}, \Option{floattype}
      & numeric float type for order perputation\\[1ex]
      \File{lor} & \File{lof}
      &
      & file extension of the helper file of the respective list \\
      \bottomrule
    \end{tabularx}
  \end{table}
%\fi

  And now a possible usage of the example environment:
\begin{lstcode}
  \begin{remarkbox}
    \centering
    Equal should be typeset equally
    and with equal formatting.
    \caption{First theorem of typography}
    \label{rem:typo1}
  \end{remarkbox}
\end{lstcode}
  A segment of an example page with this environment could be:
  \begin{center}\footnotesize
    \begin{tabular}
      {|!{\hspace{.1\linewidth}}p{.55\linewidth}!{\hspace{.1\linewidth}}|}
      \\
      \centering
      Equal should be typeset equally
      and with equal formatting.\\[\abovecaptionskip]
      {%
        \usekomafont{caption}\footnotesize{\usekomafont{captionlabel}%
          Remark 1: }First theorem of typography
      }\\
    \end{tabular}%
  \end{center}%
\end{Example}
% \iffalse
\EndIndex{Cmd}{DeclareNewTOC}%
%
\EndIndex{Package}{tocbasic}%
\EndIndex{}{table of contents}%
\EndIndex{}{list>of contents}%
\EndIndex{}{file>extension}%
% \fi
%
% \iffalse
%</doc|dtx>
% \fi
%
% \StopEventually{\PrintIndex\PrintChanges}
%
%
% \section{Implementation}
% \label{sec:implementation}
%
% All macros with prefix \texttt{tb@} or \texttt{@} are internal macros and
% should not be used by package and class authors. Macros with prefix
% \texttt{tocbasic@} are internal macros, that may be used by class and
% packages authors. Macros without \texttt{@} are interface macros and may be
% used by class and package authors and users.
%
% \iffalse
%<*package>
% \fi
%
% \subsection{Options}
% \label{sec:options}
%
% There are no options because the package should be used by class and package
% authors not by users. So the package will be loaded using
% \Macro{RequiresPackage}. Using different options by different packages would
% result in an option clash.
%    \begin{macrocode}
\ProcessOptions\relax
%    \end{macrocode}
%
%
% \subsection{Required Packages}
% \label{sec:packages}
%
% Currently only graphics bundle's package \Package{keyval} is needed.
%    \begin{macrocode}
\RequirePackage{keyval}
%    \end{macrocode}
% We load it after processing the options, because we don't need it for
% processing options.
%
%
% \subsection{Having a List of All Tocs}
% \label{sec:listoftocs}
%
% If we have a list of all toc-files we may do commands for all
% toc-files. Somethimes it may be usefull to known the package, that created
% the toc-file, so this information will be stored additionally.
%
% \begin{macro}{\tb@listoftocs}
%   This is the list of toc-files. The list will be:
%   \begin{quote}
%   \cs{do}\marg{extension}\marg{class or
%   package}\cs{do}\marg{extension}\marg{class or package}\dots
%   \end{quote}
%   With this, adding and processing the list will be very fast but removing
%   an element will be very slow.
%
%   The initial state of the list will be \emph{empty}.
%    \begin{macrocode}
\newcommand*{\tb@listoftocs}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifattoclist}
%   This command tests, if an extension is already at the list of
%   toc-files. The extension has to be the first argument. The second argument
%   will be done, if the extension is already at the list of toc-files. The
%   third argument will be done, if the extension is at the list of toc-files
%   not yet.
%    \begin{macrocode}
\newcommand{\ifattoclist}[1]{%
  \begingroup
    \def\do##1##2{%
      \edef\reserved@a{##1}%
      \ifx\reserved@a\reserved@b\@tempswatrue\fi
    }%
    \edef\reserved@b{#1}\@tempswafalse\tb@listoftocs
    \if@tempswa\aftergroup\@firstoftwo\else\aftergroup\@secondoftwo\fi
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\addtotoclist}
%   \changes{v1.0a}{2008/11/11}{internal \cs{@addtotoclist} renamed to
%     \cs{scr@addtotoclist} because of package \textsf{floatfram}}.%
%   \changes{v1.0a}{2008/11/11}{internal \cs{@@addtotoclist} renamed to
%     \cs{scr@@addtotoclist} because of package \textsf{floatfram}}.%
%   \changes{v3.06a}{2010/09/14}{expand the arguments while adding them to the
%     internal list}
%   This command adds an extension to the list of toc-files. The first,
%   optional argument is the class or package name with the corresponding
%   extension of class or package files. If this argument was omitted
%   \textsf{tocbasic} tries to get it automatically. This should be
%   successfull while loading a class or package but not while processing any
%   command of a class or package after loading the class or package. The
%   second, mandatory argument is the extension of the toc-file. NOTE: An
%   empty first argument is not the same like omitting the first argument!
%    \begin{macrocode}
\newcommand*{\addtotoclist}{%
  \@ifnextchar [%]
    \scr@@addtotoclist\scr@addtotoclist
}
\newcommand*{\scr@addtotoclist}{%
  \ifx\@currname\@empty
    \def\reserved@a{\scr@@addtotoclist[]}%
  \else
    \edef\reserved@a{\noexpand\scr@@addtotoclist[\@currname.\@currext]}%
  \fi
  \reserved@a
}
\newcommand*{\scr@@addtotoclist}[2][]{%
  \ifattoclist{#2}{%
    \PackageError{tocbasic}{%
      file extension `#2' cannot be used twice
    }{%
      File extension `#2' is already used by a toc-file, while
      \ifx\relax#1\relax someone\else #2\fi\MessageBreak
      tried to use it again for a toc-file.\MessageBreak
      This may be either an incompatibility of packages, an error at a
      package,\MessageBreak
      or a mistake by the user.\MessageBreak
    }%
  }{%
    \begingroup
      \protected@edef\reserved@a{%
        \noexpand\g@addto@macro\noexpand\tb@listoftocs{%
          \noexpand\do{#2}{#1}}}\reserved@a
    \endgroup
    \ifx\relax #1\relax\else
      \@ifundefined{tb@#1@add@hook}{}{%
        \edef\reserved@a{%
          \noexpand\def\noexpand\@currext{#2}%
          \noexpand\@nameuse{tb@#1@add@hook}%
          \noexpand\def\noexpand\@currext{\@currext}%
        }\reserved@a
      }%
    \fi
    \edef\reserved@a{%
      \noexpand\def\noexpand\@currext{#2}%
      \noexpand\@nameuse{tb@@add@hook}%
      \noexpand\def\noexpand\@currext{\@currext}%
    }\reserved@a
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\AtAddToTocList}
%   Action to be done, when adding a toc-file of a known owner. The first
%   optional argument is the owner. The second, mandatory argument is the
%   action. While doing the action \cs{@currext} will be the extension of the
%   added toc-file. If the first argument was omitted \textsf{tocbasic} tries
%   to get it automatically. This should be successfull while loading a class
%   or package but not while processing any command of a class or package
%   after loading the class or package. The second, mandatory argument is the
%   extension of the toc-file. NOTE: An empty first argument is not the same
%   like omitting the first argument, but set's up the general hook. The
%   general hook will be done for every adding after the individual hook (this
%   means, you may dactivate features at the individual hook before processing
%   the general hook). But the individual hook will not be processed for
%   toc-files without any owner!
%    \begin{macrocode}
\newcommand*{\AtAddToTocList}{%
  \@ifnextchar [%]
    \@@AtAddToTocList\@AtAddToTocList
}
\newcommand*{\@AtAddToTocList}{%
  \ifx\@currname\@empty
    \def\reserved@a{\@@AtAddToTocList[]}%
  \else
    \edef\reserved@a{\noexpand\@@AtAddToTocList[\@currname.\@currext]}%
  \fi
  \reserved@a
}
\newcommand*{\@@AtAddToTocList}[1][]{%
  \@ifundefined{tb@#1@add@hook}{\@namedef{tb@#1@add@hook}{}}{}%
  \expandafter\g@addto@macro\csname tb@#1@add@hook\endcsname
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tocbasic@extend@babel}
%   NOTE: To extend the original \cs{bbl@set@language} the argument of
%   \cs{tocbasic@extend@babel} must not be a local macro (like \cs{@currext})
%    \begin{macrocode}
\newcommand*{\tocbasic@extend@babel}[1]{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \ifx\csname bbl@set@language\endcsname\relax
    \PackageInfo{tocbasic}{babel extension for `#1' omitted\MessageBreak
      because of missing \string\bbl@set@language}%
  \else
    \iftocfeature{#1}{nobabel}{%
      \PackageInfo{tocbasic}{omitting babel extension for `#1'\MessageBreak
        because of feature `nobabel' available\MessageBreak
        for `#1'}%
    }{%
      \PackageInfo{tocbasic}{setting babel extension for `#1'}%
      \expandafter\gdef\expandafter\bbl@set@language\expandafter##\expandafter1%
      \expandafter{%
        \bbl@set@language{##1}%
        \addtocontents{#1}{\xstring\select@language{\languagename}}%
      }%
    }%
  \fi
}
%    \end{macrocode}
%   This feature should be used for all toc-files (unless feature
%   \texttt{nobabel} was set for the toc-file.
%    \begin{macrocode}
\AtAddToTocList[]{\expandafter\tocbasic@extend@babel\expandafter{\@currext}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\removefromtoclist}
%   This command will remove an extension from the list of toc-files. If the
%   first, optional argument is given, the extension will only be removed, if
%   it was added by the given owner. NOTE: An empty first argument is not the
%   same like omitting the first argument!
%    \begin{macrocode}
\newcommand*{\removefromtoclist}{%
  \@ifnextchar [%]
    \@removefromtoclist\@@removefromtoclist
}
\newcommand*{\@removefromtoclist}[2][]{%
  \begingroup
    \let\tb@oldlist\tb@listoftocs
    \def\do##1##2{%
      \edef\reserved@a{##1}%
      \ifx\reserved@a\reserved@b
        \begingroup
          \edef\reserved@a{##2}%
          \edef\reserved@b{#1}%
          \ifx\reserved@a\reserved@b\else
            \g@addto@macro\tb@listoftocs{\do{##1}{##2}}%
          \fi
        \endgroup
      \else
        \g@addto@macro\tb@listoftocs{\do{##1}{##2}}%
      \fi
    }%
    \edef\reserved@b{#2}\let\tb@listoftocs\@empty
    \tb@oldlist
  \endgroup
}
\newcommand*{\@@removefromtoclist}[1]{%
  \begingroup
    \let\tb@oldlist\tb@listoftocs
    \def\do##1##2{%
      \edef\reserved@a{##1}%
      \ifx\reserved@a\reserved@b\else
        \g@addto@macro\tb@listoftocs{\do{##1}{##2}}%
      \fi
    }%
    \edef\reserved@b{#1}\let\tb@listoftocs\@empty
    \tb@oldlist
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\doforeachtocfile}
%   \changes{v3.09}{2011/03/01}{\cs{@currext} defined using \cs{edef} instead
%     of \cs{def}}
%   This command does the second, mandatory argument for each toc-file at the
%   list of toc-files. If the first, optional argument was given this will be
%   done only for the toc-files of that owner. NOTE: An empty first argument
%   is not the same like omitting the first argument!
%
%   While processing the second argument \cs{@currext} is the extension of
%   the toc-file. The second argument will be processed with increased group
%   level!
%
%   See \cs{addtoeachtocfile} for an example of usage of
%   \cs{doforeachtocfile}.
%    \begin{macrocode}
\newcommand{\doforeachtocfile}{%
  \@ifnextchar [%]
    \@doforeachtocfile\@@doforeachtocfile
}
\newcommand{\@doforeachtocfile}[2][]{%
  \def\do##1##2{%
    \edef\reserved@a{#1}\edef\reserved@b{##2}\ifx\reserved@a\reserved@b
      \edef\@currext{##1}#2%
    \fi
  }%
  \edef\reserved@a{%
    \noexpand\tb@listoftocs
    \noexpand\def\noexpand\@currext{\@currext}%
  }\reserved@a
  \let\do\relax
}
\newcommand{\@@doforeachtocfile}[1]{%
  \def\do##1##2{%
    \edef\@currext{##1}#1%
  }%
  \edef\reserved@a{%
    \noexpand\tb@listoftocs
    \noexpand\def\noexpand\@currext{\@currext}%
  }\reserved@a
  \let\do\relax
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\addtoeachtocfile}
% \begin{macro}{\@addtoeachtocfile}
% \begin{macro}{\@@addtoeachtocfile}
%   \changes{v3.03b}{2009/06/08}{typo fix at usage of \cs{doforeachtocfile}}
%   This command calls \cs{addtocontents} with the section, mandatory
%   argument for each toc-file at the list of toc-files. If the first,
%   optional argument was given this will be done only for the toc-files of
%   that owener. NOTE: An empty first argument is not the same like omitting
%   the first argument! And don't forget to protect the commands, that should
%   not be expanded, at the mandatory argument.
%    \begin{macrocode}
\newcommand{\addtoeachtocfile}{%
  \@ifnextchar [%]
    \@addtoeachtocfile\@@addtoeachtocfile
}
\newcommand{\@addtoeachtocfile}[2][]{%
  \doforeachtocfile[{#1}]{\addtocontents{\@currext}{#2}}%
}
\newcommand{\@@addtoeachtocfile}[1]{%
  \doforeachtocfile{\addtocontents{\@currext}{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Adding Entries into Toc-Files}
%
% We have a new general command to add entries to several toc-files at
% once. And we have some special commands for the table of contents.
%
% \begin{macro}{\addcontentslinetoeachtocfile}
%   Something like a combination of \cs{addtoeachtocfile} and
%   \cs{addcontentsline}.
%    \begin{macrocode}
\newcommand{\addcontentslinetoeachtocfile}{%
  \@ifnextchar [%]
    \@addcontentslinetoeachtocfile\@@addcontentslinetoeachtocfile
}
\newcommand{\@addcontentslinetoeachtocfile}[3][]{%
  \doforeachtocfile[{#1}]{\addcontentsline{\@currext}{#2}{#3}}%
}
\newcommand{\@@addcontentslinetoeachtocfile}[2]{%
  \doforeachtocfile{\addcontentsline{\@currext}{#1}{#2}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\addxcontentsline}
%   \changes{v3.12}{2013/09/24}{new}
%   \changes{v3.12}{2013/09/24}{Take care of new feature \texttt{numberline}}
% \begin{macro}{\@addxcontentsline}
%   \changes{v3.12}{2013/09/24}{new (internal)}
% This will be used instead of \cs{addcontentsline} to generate numbered or
% not numbered entries to a toc-file. First argument is the toc-file, second
% the entry type, e.g., \texttt{chapter}, the third is the entry number or
% empty and the fourth and last is the entry text.
%    \begin{macrocode}
\newcommand*{\addxcontentsline}[2]{%
  \@ifnextchar [%]
  {\@addxcontentsline{#1}{#2}}%
  {\@addxcontentsline{#1}{#2}[]}%
}
\newcommand*{\@addxcontentsline}{}
\def\@addxcontentsline#1#2[#3]#4{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname add#2#1entry\endcsname\relax
    \tocbasic@addxcontentsline{#1}{#2}{#3}{#4}%
  \else
    \@nameuse{add#2#1entry}{#3}{#4}%
  \fi
}
%    \end{macrocode}
% \begin{macro}{\nonumberline}
%   \changes{v3.12}{2013/09/24}{new}
% Either \cs{relax} or \cs{numberline} depending on the feature
% \texttt{numberline}.
%    \begin{macrocode}
\newcommand*{\nonumberline}{}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\addxcontentsline}
% This may be used to either use a heading type command or the general default
% one. You are not allowed to use it in the definition of a heading type
% command like \cs{addchaptertocentry}! You may use
% \cs{tocbasic@addxcontentsline} at the definition of those commands.
%    \begin{macrocode}
\newcommand*{\tocbasic@addxcontentsline}[4]{%
  \if\relax\detokenize{#3}\relax
    \addcontentsline{#1}{#2}{\protect\nonumberline#4}%
  \else
    \addcontentsline{#1}{#2}{\protect\numberline{#3}#4}%
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\addxcontentslinetoeachtocfile}
%   \changes{v3.12}{2013/09/24}{new}
% \begin{macro}{\@addxcontentslinetoeachtocfile}
%   \changes{v3.12}{2013/09/24}{new (internal)}
% \begin{macro}{\@@addxcontentslinetoeachtocfile}
%   \changes{v3.12}{2013/09/24}{new (internal)}
% \begin{macro}{\@@@addxcontentslinetoeachtocfile}
%   \changes{v3.12}{2013/09/24}{new (internal)}
% \begin{macro}{\@@@@addxcontentslinetoeachtocfile}
%   \changes{v3.12}{2013/09/24}{new (internal)}
% Similar to \cs{addcontentslinetoeachtocfile} using
% \cs{addxcontentsline} instead of \cs{addcontentsline}.
%    \begin{macrocode}
\newcommand{\addxcontentslinetoeachtocfile}{%
  \@ifnextchar [%]
    \@addxcontentslinetoeachtocfile\@@addxcontentslinetoeachtocfile
}
\newcommand{\@addxcontentslinetoeachtocfile}[2][]{%
  \@ifnextchar [%]
    {\@@@addxcontentslinetoeachtocfile[{#1}]{#2}}%
    {\@@@addxcontentslinetoeachtocfile[{#1}]{#2}[]}
}
\newcommand*{\@@@addxcontentslinetoeachtocfile}{}
\def\@@@addxcontentslinetoeachtocfile[#1]#2[#3]#4{%
  \doforeachtocfile[{#1}]{\addxcontentsline{\@currext}{#2}[#3]{#4}}%
}
\newcommand{\@@addxcontentslinetoeachtocfile}[1]{%
  \@ifnextchar [%]
    {\@@@@addxcontentslinetoeachtocfile{#1}}%
    {\@@@@addxcontentslinetoeachtocfile{#1}[]}%
}
\newcommand*{\@@@@addxcontentslinetoeachtocfile}{}
\def\@@@@addxcontentslinetoeachtocfile#1[#2]#3{%
  \doforeachtocfile{\addxcontentsline{\@currext}{#1}[{#2}]{#3}}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Show List of Toc-File}
% \label{sec:showlistoftocfile}
%
% If you have a toc-file you want a list-of-command for this toc-file,
% too. Here are basics and high level commands for this.
%
% \begin{macro}{\tocbasic@starttoc}
%   \changes{v3.17}{2015/03/23}{usage of feature \texttt{noparskipfake}}^^A
%   Some basics are done like setting up \cs{parskip}, \cs{parindent} and
%   \cs{parfillskip}, a general hook will be called, an individual hook will
%   be called, the toc will be started, an individual hook will be called, an
%   general hook wil be called, that's it.
%    \begin{macrocode}
\newcommand*{\tocbasic@starttoc}[1]{%
  \begingroup
    \edef\@currext{#1}%
    \iftocfeature{\@currext}{noparskipfake}{}{%
      \ifvmode
        \@tempskipa\lastskip
        \vskip-\lastskip
        \addtolength{\@tempskipa}{\parskip}%
        \vskip\@tempskipa
      \fi
    }%
    \setlength{\parskip}{\z@}%
    \setlength{\parindent}{\z@}%
    \setlength{\parfillskip}{\z@\@plus 1fil}%
    \csname tocbasic@@before@hook\endcsname
    \csname tb@#1@before@hook\endcsname
    \@starttoc{#1}%
    \csname tb@#1@after@hook\endcsname
    \csname tocbasic@@after@hook\endcsname
  \endgroup
}
%    \end{macrocode}
% \begin{macro}{\tocbasic@@before@hook}
% \begin{macro}{\tocbasic@@after@hook}
%   These are the general hooks. They may be used by classes and packages for
%   commands, that should be used for all lists of not only the own lists of,
%   e.\,g., \KOMAScript{} may use it to handle option \texttt{tocleft}.
%    \begin{macrocode}
\newcommand*{\tocbasic@@before@hook}{}
\newcommand*{\tocbasic@@after@hook}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\BeforeStartingTOC}
%   \changes{v3.04b}{2010/01/05}{fix: define the hook if not already defined}
%   \changes{v3.06}{2010/06/09}{fix: using \cs{@ifundefined} instead of
%     undefined \cs{scr@ifundefinedorrelax}}
% \begin{macro}{\AfterStartingTOC}
%   \changes{v3.04b}{2010/01/05}{fix:define the hook if not already defined}
%   \changes{v3.06}{2010/06/09}{fix: using \cs{@ifundefined} instead of
%     undefined \cs{scr@ifundefinedorrelax}}
%   These are the commands to add code to the general or individual hooks. If
%   the first, optional argument was given, the second, mandatory argument
%   will be added to the individual hook, otherwise the general hook will be
%   extended.
%    \begin{macrocode}
\newcommand{\BeforeStartingTOC}[2][]{%
  \ifx\relax#1\relax
    \g@addto@macro\tocbasic@@before@hook{#2}%
  \else
    \@ifundefined{tb@#1@before@hook}{%
      \PackageInfo{tocbasic}{defining new hook before starting `#1'}%
      \expandafter\global\expandafter\let\csname tb@#1@before@hook\endcsname
      \@empty
    }{}%
    \expandafter\g@addto@macro\csname tb@#1@before@hook\endcsname{#2}%
  \fi
}
\newcommand{\AfterStartingTOC}[2][]{%
  \ifx\relax#1\relax
    \g@addto@macro\tocbasic@@after@hook{#2}%
  \else
    \@ifundefined{tb@#1@after@hook}{%
      \PackageInfo{tocbasic}{defining new hook after starting `#1'}%
      \expandafter\global\expandafter\let\csname tb@#1@after@hook\endcsname
      \@empty
    }{}%
    \expandafter\g@addto@macro\csname tb@#1@after@hook\endcsname{#2}%
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\listoftoc}
% \begin{macro}{\listoftoc*}
%   \changes{v1.0a}{2008/11/12}{\cs{twocolumn} fixed}%
%   \changes{v1.01}{2008/11/13}{new feature \texttt{onecolumn}}
%   \changes{v3.09}{2011/03/01}{\cs{@currext} defined using \cs{edef} instead
%     of \cs{def}}
%   Command to handle the hole list of something. There are additional hooks
%   for this. The first optional argument is the title for this list. If the
%   optional argument was omitted \cs{listof\#2name} will be used. The star
%   version does not set up a heading or switch the column number!
%    \begin{macrocode}
\newcommand*{\listoftoc}{%
  \@ifstar \tocbasic@starttoc\@listoftoc
}
\newcommand*{\@listoftoc}[2][\list@fname]{%
  \begingroup
    \@ifundefined{listof#2name}{%
      \let\list@fname\relax
      \ifx\relax#1\relax
        \PackageWarning{tocbasic}{%
          You should either define \expandafter\string\csname
          listof#2name\endcsname\MessageBreak
          or use the optional argument of \string\listoftoc\space\MessageBreak
          to set the term to be used for the\MessageBreak
          heading of list of #2}%
        \def\list@fname{\listofname~#2}%
      \fi
    }{%
      \expandafter\let\expandafter\list@fname\csname listof#2name\endcsname
    }%
    \edef\@currext{#2}%
    \iftocfeature{\@currext}{onecolumn}{%
      \iftocfeature{\@currext}{leveldown}{}{%
        \if@twocolumn
          \aftergroup\twocolumn\onecolumn
        \fi
      }%
    }{}%
    \iftocfeature{\@currext}{numberline}{\def\nonumberline{\numberline{}}}{}%
    \tocbasic@listhead{#1}%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname microtypesetup\endcsname\relax
    \else
      \iftocfeature{\@currext}{noprotrusion}{}{%
        \microtypesetup{protrusion=false}%
        \PackageInfo{tocbasic}{character protrusion at \@currext\space deactivated}%
      }%
    \fi
    \tocbasic@starttoc{#2}%
  \endgroup
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\listofname}
%   While this is only an emergancy command, we don't support languages.
%    \begin{macrocode}
\newcommand*{\listofname}{List of}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listofeachtoc}
% \begin{macro}{\@listofeachtoc}
% \begin{macro}{\@@listofeachtoc}
%   \changes{v3.03b}{2009/06/08}{typo fix at usage of \cs{doforeachtocfile}}
%   Another example of using \cs{doforeachtocfile}.
%    \begin{macrocode}
\newcommand*{\listofeachtoc}{%
  \@ifnextchar [%]
    \@listofeachtoc\@@listofeachtoc
}
\newcommand{\@listofeachtoc}[1][]{%
  \doforeachtocfile[{#1}]{\listoftoc{\@currext}}%
}
\newcommand{\@@listofeachtoc}[1]{%
  \doforeachtocfile{\listoftoc{\@currext}}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocbasic@listhead}
%   \changes{v3.02a}{2009/01/20}{no explicite marks if ``numbered''}%
%   \changes{v3.09a}{2011/04/12}{again no explicite marks if ``numbered''}%
%   \changes{v3.12}{2013/09/24}{usage of new
%     \cs{tocbasic@addxcontentsline}}%
%   \changes{v3.15}{2014/12/10}{moved \cs{@mkboth} inside \cs{chapter*}}^^A
%   \changes{v3.15}{2014/12/10}{usage of \cs{addsec} if available}^^A
%   \changes{v3.15}{2014/12/10}{usage of \cs{@mkright} if available}^^A
%   \changes{v3.17}{2015/03/08}{moved \cs{@mkboth} outside \cs{chapter*}}^^A
%   \changes{v3.17}{2015/03/08}{usage of \cs{@mkdouble} if available}^^A
%   \changes{v3.17}{2015/03/25}{penalty and skip reconstruction after
%     \cs{@mkright}, \cs{@mkboth}, or \cs{@mkdouble}}^^A
%   Setting the headings of a list of something. The heading is the only
%   argument.
%    \begin{macrocode}
\newcommand*{\tocbasic@listhead}[1]{%
  \@ifundefined{tocbasic@listhead@\@currext}{%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname chapter\endcsname\relax
      \expandafter\def\csname tocbasic@listhead@\@currext\endcsname##1{%
        \iftocfeature{\@currext}{leveldown}{%
          \iftocfeature{\@currext}{numbered}{%
            \subsection[##1]{##1}%
          }{%
            \subsection*{##1}%
            \ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi
            \begingroup
              \iftocfeature{\@currext}{totoc}{%
                \addxcontentsline{toc}{subsection}{##1}%
              }{}%
              \@ifundefined{@mkright}{%
                \ifx\@mkboth\@gobbletwo\else\markright{\MakeMarkcase{##1}}\fi
              }{%
                \@mkright{\MakeMarkcase{##1}}%
              }%
            \endgroup
            \ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi
          }%
        }{%
          \iftocfeature{\@currext}{numbered}{%
            \section[##1]{##1}%
          }{%
            \section*{##1}%
            \ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi
            \begingroup
              \iftocfeature{\@currext}{totoc}{%
                \addxcontentsline{toc}{section}{##1}%
              }{}%
              \@ifundefined{@mkdouble}{%
                \@mkboth{\MakeMarkcase{##1}}{\MakeMarkcase{##1}}%
              }{%
                \@mkdouble{\MakeMarkcase{##1}}%
              }%
            \endgroup
            \ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi
          }%
        }%
      }%
    \else
      \expandafter\def\csname tocbasic@listhead@\@currext\endcsname##1{%
        \iftocfeature{\@currext}{leveldown}{%
          \iftocfeature{\@currext}{numbered}{%
            \section{##1}%
          }{%
            \iftocfeature{\@currext}{totoc}{%
              \begingroup
                \@ifundefined{addsec}{%
                  \section*{##1}%
                  \ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi
                  \begingroup
                    \@ifundefined{@mkright}{%
                      \ifx\@mkboth\@gobbletwo
                      \else\markright{\MakeMarkcase{##1}}\fi
                    }{%
                      \@mkright{\MakeMarkcase{##1}}%
                    }%
                    \addxcontentsline{toc}{section}{##1}%
                  \endgroup
                  \ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi
                }{%
                  \addsec{##1}%
                }%
              \endgroup
            }{%
              \section*{##1}%
              \ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi
              \begingroup
                \@ifundefined{@mkright}{%
                  \ifx\@mkboth\@gobbletwo
                  \else\markright{\MakeMarkcase{##1}}\fi
                }{%
                  \@mkright{\MakeMarkcase{##1}}%
                }%
              \endgroup
              \ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi
            }%
          }%
        }{%
          \iftocfeature{\@currext}{numbered}{%
            \chapter[##1]{##1}%
          }{%
            \chapter*{##1}%
            \ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi
            \begingroup
              \@ifundefined{@mkdouble}{%
                \@mkboth{\MakeMarkcase{##1}}{\MakeMarkcase{##1}}%
              }{%
                \@mkdouble{\MakeMarkcase{##1}}%
              }%
              \iftocfeature{\@currext}{totoc}{%
                \addxcontentsline{toc}{chapter}{##1}%
              }{}%
            \endgroup
            \ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi
          }%
        }%
      }%
    \fi
  }{}%
  \csname tb@@beforehead@hook\endcsname
  \csname tb@\@currext @beforehead@hook\endcsname
  \csname tocbasic@listhead@\@currext\endcsname{#1}%
  \csname tb@\@currext @afterhead@hook\endcsname
  \csname tb@@afterhead@hook\endcsname
}
%    \end{macrocode}
% \begin{macro}{\BeforeTOCHead}
%   \changes{v3.04b}{2010/01/05}{fix: define the hook if not already defined}
%   \changes{v3.06}{2010/06/09}{fix: using \cs{@ifundefined} instead of
%     undefined \cs{scr@ifundefinedorrelax}}
% \begin{macro}{\AfterTOCHead}
%   \changes{v3.04b}{2010/01/05}{fix: define the hook if not already defined}
%   \changes{v3.06}{2010/06/09}{fix: using \cs{@ifundefined} instead of
%     undefined \cs{scr@ifundefinedorrelax}}
%   These are the commands to add code to the general or individual hooks. If
%   the first, optional argument was given, the second, mandatory argument
%   will be added to the individual hook, otherwise the general hook will be
%   extended.
%    \begin{macrocode}
\newcommand{\BeforeTOCHead}[2][]{%
  \@ifundefined{tb@#1@beforehead@hook}{%
    \PackageInfo{tocbasic}{defining new hook before heading of `#1'}%
    \expandafter\global\expandafter\let\csname tb@#1@beforehead@hook\endcsname
    \@empty
  }{}%
  \expandafter\g@addto@macro\csname tb@#1@beforehead@hook\endcsname{#2}%
}
\newcommand{\AfterTOCHead}[2][]{%
  \@ifundefined{tb@#1@afterhead@hook}{%
    \PackageInfo{tocbasic}{defining new hook after heading of `#1'}%
    \expandafter\global\expandafter\let\csname tb@#1@afterhead@hook\endcsname
    \@empty
  }{}%
  \expandafter\g@addto@macro\csname tb@#1@afterhead@hook\endcsname{#2}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\MakeMarkcase}
%   Use upper-case or not?
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifundefined{MakeMarkcase}{%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname KOMAClassName\endcsname\relax
      \let\MakeMarkcase\MakeUppercase
    \else
      \let\MakeMarkcase\@firstofone
    \fi
  }{}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\deftocheading}
%   Define a toc headings command with one argument (the title).
%    \begin{macrocode}
\newcommand*{\deftocheading}[1]{%
  \@namedef{tocbasic@listhead@#1}##1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setuptoc}
% \begin{macro}{\unsettoc}
%   Known features are:
%   \begin{description}
%   \item[\texttt{totoc}] writes the title of the list of to the table of
%     contents
%   \item[\texttt{numberline}] redefines \cs{nonumberline} to use
%     \cs{numberline}
%   \item[\texttt{numbered}] uses a numbered headings for the list of
%   \item[\texttt{leveldown}] uses not the top level heading (e.\,g.,
%     \cs{chapter} with book) but the first sub level (e.\,g., \cs{section} with
%     book).
%   \item[\texttt{nobabel}] prevents the extension to be added to the babel
%     handling of toc-files.  To make this work, you have to set the feature
%     before adding the extension to the list of known extension.
%   \item[[\texttt{noprotrusion}]] prevents disabling character protrusion at
%     the toc.
%   \end{description}
%   Other features may be package dependent. You may test the feature using:
%   \begin{quote}
%   \cs{@ifundefined}\texttt{\{tocbasic@\meta{toc}@feature@\meta{feature}\}}\\
%   \phantom{\cs{@ifundefined}}\marg{do if feature not set}\\
%   \phantom{\cs{@ifundefined}}\marg{do if feature set}
%   \end{quote}
%   See \cs{tocbasic@listhead} for an example of this.
%    \begin{macrocode}
\newcommand*{\setuptoc}[2]{%
  \@for\@tempa:=#2\do{%
    \expandafter\tb@@sp@def\expandafter\@tempa\expandafter{\@tempa}%
    \@namedef{tocbasic@#1@feature@\@tempa}{}%
  }%
}
\newcommand*{\unsettoc}[2]{%
  \@for\@tempa:=#2\do{%
    \expandafter\tb@@sp@def\expandafter\@tempa\expandafter{\@tempa}%
    \expandafter\let\csname tocbasic@#1@feature@\@tempa\endcsname\relax
  }%
}
\def\@tempa#1{%
  \def\tb@@sp@def##1##2{%
    \futurelet\tb@sp@tempa\tb@@sp@d##2\@nil\@nil#1\@nil\relax##1}%
  \def\tb@@sp@d{%
    \ifx\tb@sp@tempa\@sptoken
      \expandafter\tb@@sp@b
    \else
      \expandafter\tb@@sp@b\expandafter#1%
    \fi}%
  \def\tb@@sp@b#1##1 \@nil{\tb@@sp@c##1}%
}
\@tempa{ }
\def\tb@@sp@c#1\@nil#2\relax#3{\@temptokena{#1}\edef#3{\the\@temptokena}}
%    \end{macrocode}
%   Do not add the files, that babel handles by default.
%    \begin{macrocode}
\setuptoc{toc}{nobabel}
\setuptoc{lof}{nobabel}
\setuptoc{lot}{nobabel}
%    \end{macrocode}
% \begin{macro}{\iftocfeature}
%   We need a test for the features
%    \begin{macrocode}
\newcommand*{\iftocfeature}[2]{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname tocbasic@#1@feature@#2\endcsname\relax
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tocbasicautomode}
%   \changes{v1.0a}{2008/11/11}{use of \cs{addtotoclist} instead of internal}%
%   \changes{v3.07a}{2010/11/25}{fix: added missing
%     \cs{let}\cs{@starttoc}\cs{tocbasic@starttoc}}%
% \Package{tocbasic} can overtake \Macro{@starttoc} to automaticly add all
% used extensions to the list of known extensions and use
% \Macro{tocbasic@starttoc} instead of \Macro{@starttoc} from \LaTeX{}
% kernel. Please note, that we don't need a fix for the unfriendly
% redefinition of \Macro{@starttoc} by \Package{hyperref}, because hyperref
% does it only at the first \LaTeX{} run. So this action of \Package{hyperref}
% may only result in the need of one more \LaTeX{} run, but not in a permanent
% mistake.
%    \begin{macrocode}
\newcommand*{\tocbasicautomode}{%
  \let\tb@saved@starttoc\@starttoc
  \let\@starttoc\tocbasic@starttoc
  \BeforeStartingTOC{%
    \let\@starttoc\tb@saved@starttoc
    \expandafter\ifattoclist\expandafter{\@currext}{}{%
      \addtotoclist[tocbasicautomode]{\@currext}%
    }%
  }%
}
%    \end{macrocode}
% \end{macro}
%
%
% \section{High Level Interface for Generating New TOCs and Floats}
% \label{sec:newfloats}
%
% \begin{macro}{\DeclareNewTOC}
%   \changes{v3.06}{2010/06/01}{new high level command}%
%   This command defines only a new TOC and a new caption command for this
%   TOC.  It does not define a new foat unless option float was set!  It does
%   not define a new nonfloat unless option nonfloat was set!  The optional
%   argument is used to set up several settings using \Package{keyval}.  The
%   mandatory argument is the shortcut.  The default type is the shortcut.
%   The extension is the shortcut.  The default owner is ``\texttt{float}''.
%
%   But first of all, we define the options used by the optional argument:
%   The type of list is used for environment and counter names and as part of
%   several internal and user macros.
%    \begin{macrocode}
\define@key{tocbasic}{type}{%
  \tb@ifvalueisnotempty{type}{#1}{\edef\tb@nt@type{#1}}%
}
%    \end{macrocode}
% \begin{macro}{\tb@nt@counterwithin}
%   If a counter will be defined, this counter may depend on another counter
%   (like figure counter depends on chapter counter at book classes). If the
%   value is empty, the counter does not depend on any other counter.
%    \begin{macrocode}
\define@key{tocbasic}{counterwithin}{%
  \edef\tb@nt@counterwithin{#1}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@types}
%   Sometimes the plural of the type is needed and may be defined by a
%   seperate option.
%    \begin{macrocode}
\define@key{tocbasic}{types}{%
  \tb@ifvalueisnotempty{types}{#1}{\edef\tb@nt@types{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@ext}
%   Don't tell the user, that the mandatory argument of the command may be
%   overloaded by this option. This was only done to simplify the definition.
%    \begin{macrocode}
\define@key{tocbasic}{extension}{%
  \tb@ifvalueisnotempty{extension}{#1}{\edef\tb@nt@ext{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@owner}
%   The owner of the new list extension.
%    \begin{macrocode}
\define@key{tocbasic}{owner}{%
  \tb@ifvalueisnotempty{owner}{#1}{\edef\tb@nt@owner{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@name}
%   We need a name/term for the entries of the new list. This may e.\,g. be used
%   for |caption| output. A |\<type>name| will also be defined.
%    \begin{macrocode}
\define@key{tocbasic}{name}{%
  \tb@ifvalueisnotempty{name}{#1}{\edef\tb@nt@name{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@listname}
%   The list itself has a heading. A |\list<type>name| will also be defined.
%    \begin{macrocode}
\define@key{tocbasic}{listname}{%
  \tb@ifvalueisnotempty{listname}{#1}{\edef\tb@nt@listname{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\iftb@forcenames}
%   \changes{v3.06}{2010/06/01}{new internal}
%   The |\...name| commands will only be defined, if they are not already
%   defined. But some users may want to define their own names even if there
%   are already definitions. So this boolean option may switch to force the
%   definition.
%    \begin{macrocode}
\newif\iftb@forcenames
\define@key{tocbasic}{forcenames}[true]{%
  \lowercase{\tb@boolkey{#1}}{forcenames}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@level}
%   Each entry to a TOC/list of has a numeric level. You may set up your own
%   level.
%    \begin{macrocode}
\define@key{tocbasic}{level}{%
  \tb@ifvalueisnotempty{level}{#1}{\tb@numkey\tb@nt@level{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@indent}
%   Earch entry of a TOC/list of is idented on the left side. This is the
%   amount of the indention of the number part.
%    \begin{macrocode}
\define@key{tocbasic}{indent}{%
  \tb@ifvalueisnotempty{indent}{#1}{\tb@dimkey\tb@nt@indent{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@hang}
%   Earch entry of a TOC/list of is idented on the left side. This is the
%   amount of the indention of the text of the entry.
%    \begin{macrocode}
\define@key{tocbasic}{hang}{%
  \tb@ifvalueisnotempty{hang}{#1}{\tb@dimkey\tb@nt@hang{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\iftb@float}
%   \changes{v3.06}{2010/06/01}{new internal}
%   This boolean indicates, that float environments should also be defined.
%    \begin{macrocode}
\newif\iftb@float
\define@key{tocbasic}{float}[true]{%
  \lowercase{\tb@boolkey{#1}}{float}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\iftb@nonfloat}
%   \changes{v3.06}{2010/06/01}{new internal}
%   This boolean indicates, that non-float environment should also be
%   defined. The environment has the postfix ``-''.
%    \begin{macrocode}
\newif\iftb@nonfloat
\define@key{tocbasic}{nonfloat}[true]{%
  \lowercase{\tb@boolkey{#1}}{nonfloat}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@floattype}
%   Simply the value for the |\ftype@...| macro. It has to be
%   $1<=\textrm{value}<=31$.
%    \begin{macrocode}
\define@key{tocbasic}{floattype}{%
  \tb@ifvalueisnotempty{floattype}{#1}{\tb@numkey\tb@nt@floattype{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@floatpos}
%   Simply the value for the |\fps@...| macro.
%    \begin{macrocode}
\define@key{tocbasic}{floatpos}{%
  \tb@ifvalueisnotempty{floatpos}{#1}{\edef\tb@nt@floatpos{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@atbegin}
%   \changes{v3.09}{2011/03/01}{new optional identifier \texttt{atbegin}}
%   \changes{v3.11c}{2013/02/01}{\texttt{atbegin} argument may be empty}
%   Additional code executed at the begin of a new defined environment.
%    \begin{macrocode}
\define@key{tocbasic}{atbegin}{%
  \def\tb@nt@atbegin{#1}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@atend}
%   \changes{v3.09}{2011/03/01}{new optional identifier \texttt{atbend}}
%   \changes{v3.11c}{2013/02/01}{\texttt{atend} argument may be empty}
%   Additional code executed at the end of a new defined environment.
%    \begin{macrocode}
\define@key{tocbasic}{atend}{%
  \def\tb@nt@atend{#1}%
}
%    \end{macrocode}
% \end{macro}
%  Now the command to define a new list and maybe float or nonfloat.
%    \begin{macrocode}
\newcommand*{\DeclareNewTOC}[2][]{%
  \tb@floatfalse
  \tb@nonfloatfalse
  \tb@forcenamesfalse
  \def\tb@nt@floattype{\tb@nt@autofloattype}%
  \def\tb@nt@floatpos{tbp}%
  \def\tb@nt@ext{#2}%
  \def\tb@nt@type{#2}%
  \def\tb@nt@types{\tb@nt@type s}%
  \def\tb@nt@owner{float}%
  \def\tb@nt@name{\expandafter\MakeUppercase\tb@nt@type}%
  \def\tb@nt@listname{List of \expandafter\MakeUppercase\tb@nt@types}%
  \def\tb@nt@level{1}%
  \def\tb@nt@indent{1em}%
  \def\tb@nt@hang{1.5em}%
  \let\tb@nt@counterwithin\@empty
  \let\tb@nt@atbegin\@empty
  \let\tb@nt@atend\@empty
  \setkeys{tocbasic}{#1}%
%    \end{macrocode}
%   First of all, every TOC needs a extension, that should be added to the
%   list of known extensions.
%    \begin{macrocode}
  \expandafter\newcommand\csname ext@\tb@nt@type\endcsname{}%
  \expandafter\let\csname ext@\tb@nt@type\endcsname\tb@nt@ext
  \addtotoclist[\tb@nt@owner]{\csname ext@\tb@nt@type\endcsname}%
%    \end{macrocode}
% Then we need the TOC itself with a name:
%    \begin{macrocode}
  \@ifundefined{\tb@nt@type name}{%
    \expandafter\let\csname \tb@nt@type name\endcsname\tb@nt@name
  }{%
    \iftb@forcenames
      \expandafter\let\csname \tb@nt@type name\endcsname\tb@nt@name
    \fi
  }%
  \@ifundefined{list\tb@nt@type name}{%
    \expandafter\let\csname list\tb@nt@type name\endcsname\tb@nt@listname
  }{%
    \iftb@forcenames
      \expandafter\let\csname list\tb@nt@type name\endcsname\tb@nt@listname
    \fi
  }%
  \expandafter\newcommand\csname listof\tb@nt@ext name\expandafter\endcsname
    \expandafter{\csname list\tb@nt@type name\endcsname}%
  \begingroup\edef\@tempa{\endgroup
    \noexpand\newcommand*\csname listof\tb@nt@types\endcsname{%
      \noexpand\listoftoc{\tb@nt@ext}%
    }%
  }\@tempa
%    \end{macrocode}
% The list entry:
%    \begin{macrocode}
  \begingroup\edef\@tempa{\endgroup
    \noexpand\newcommand*\csname l@\tb@nt@type\endcsname{%
      \noexpand\@dottedtocline{\tb@nt@level}{\tb@nt@indent}{\tb@nt@hang}%
    }%
  }\@tempa
%    \end{macrocode}
% \changes{v3.12}{2013/05/03}{fixed: definition of
%   \cs{listof\meta{type}entryname} added as explained in the manual}
%    \begin{macrocode}
  \@ifundefined{listof\tb@nt@ext entryname}{%
    \expandafter\let\csname listof\tb@nt@ext entryname\endcsname\tb@nt@name
  }{}%
%    \end{macrocode}
% The setup command:
%    \begin{macrocode}
  \begingroup\edef\@tempa{\endgroup
    \noexpand\newcommand*\csname setup\tb@nt@types\endcsname{%
      \noexpand\setuptoc{\tb@nt@ext}%
    }%
  }\@tempa
  \@tempswafalse
%    \end{macrocode}
% The float environments:
% \changes{v3.09a}{2011/05/30}{fixed: floats may have an optional argument}
% \changes{v3.12}{2013/12/10}{fixed: usage of default placement}
%    \begin{macrocode}
  \iftb@float
    \expandafter\newcommand\expandafter*\csname fps@\tb@nt@type\expandafter
    \endcsname\expandafter{\tb@nt@floatpos}%
    \expandafter\newcommand\expandafter*\csname ftype@\tb@nt@type\expandafter
    \endcsname\expandafter{\tb@nt@floattype}%
    \begingroup
      \edef\@tempa{%
        \noexpand\endgroup
        \noexpand\newenvironment{\tb@nt@type}{%
          \noexpand\@ifnextchar[%]
          {\noexpand\tb@atbegin@after\noexpand\@float{\tb@nt@type}}%
          {\noexpand\edef\noexpand\reserved@a{%
              \noexpand\noexpand\noexpand\tb@atbegin@after
              \noexpand\noexpand\noexpand\@float{\tb@nt@type}%
              [\noexpand\csname fps@\tb@nt@type\noexpand\endcsname]}%
            \noexpand\reserved@a}%
        }{%
          \noexpand\csname \tb@nt@type @atend\noexpand\endcsname
          \noexpand\end@float
        }%
        \noexpand\newenvironment{\tb@nt@type*}{%
          \noexpand\@ifnextchar[%]
          {\noexpand\tb@atbegin@after\noexpand\@dblfloat{\tb@nt@type}}%
          {\noexpand\edef\noexpand\reserved@a{%
              \noexpand\noexpand\noexpand\tb@atbegin@after
              \noexpand\noexpand\noexpand\@dblfloat{\tb@nt@type}%
              [\noexpand\csname fps@\tb@nt@type\noexpand\endcsname]}%
            \noexpand\reserved@a}%
        }{%
          \noexpand\csname \tb@nt@type @atend\noexpand\endcsname
          \noexpand\end@dblfloat
        }%
      }%
    \@tempa
    \@tempswatrue
  \fi
%    \end{macrocode}
% The nonfloat environment:
%    \begin{macrocode}
  \iftb@nonfloat
    \begingroup
      \edef\@tempa{%
        \noexpand\endgroup
        \noexpand\newenvironment{\tb@nt@type-}{%
          \noexpand\trivlist\noexpand\item\noexpand\relax
          \noexpand\minipage{\noexpand\linewidth}%
          \noexpand\def\noexpand\@captype{\tb@nt@type}%
          \noexpand\csname \tb@nt@type @atbegin\noexpand\endcsname
        }{%
          \noexpand\csname \tb@nt@type @atend\noexpand\endcsname
          \noexpand\endminipage\noexpand\endtrivlist
        }%
      }%
    \@tempa
    \@tempswatrue
  \fi
%    \end{macrocode}
% The counter and hooks of float and nonfloat environments:
%   \changes{v3.10b}{2012/04/04}{\cs{noexpand} added to fix problems using
%     \cs{autodot}}%^^A
%   \changes{v3.13}{2014/07/31}{add \cs{autodot} only to hierachical
%     counters}%^^A
%    \begin{macrocode}
  \if@tempswa
    \@ifundefined{c@\tb@nt@type}{%
      \newcounter{\tb@nt@type}%
    }{%
      \PackageWarning{tocbasic}{using already defined counter `\tb@nt@type'}%
    }%
    \ifx\tb@nt@counterwithin\@empty\else
      \@addtoreset{\tb@nt@type}{\tb@nt@counterwithin}%
      \begingroup\edef\@tempa{%
        \noexpand\endgroup
        \noexpand\renewcommand*\expandafter\noexpand
        \csname the\tb@nt@type\endcsname{%
          \expandafter\noexpand\csname the\tb@nt@counterwithin\endcsname
          .\noexpand\arabic{\tb@nt@type}%
        }%
      }\@tempa
    \fi
    \begingroup
      \edef\@tempa{%
        \noexpand\endgroup
        \noexpand\newcommand*\expandafter\noexpand
        \csname \tb@nt@type format\endcsname{%
          \expandafter\noexpand\csname \tb@nt@type name\endcsname
          \noexpand\nobreakspace
          \expandafter\noexpand\csname the\tb@nt@type\endcsname
          \ifx\tb@nt@counterwithin\@empty\else
            \noexpand\csname autodot\endcsname
          \fi
        }%
        \noexpand\newcommand*\expandafter\noexpand
        \csname fnum@\tb@nt@type\endcsname{%
          \expandafter\noexpand\csname \tb@nt@type format\endcsname
        }%
      }%
    \@tempa
    \expandafter\newcommand\expandafter*\csname \tb@nt@type @atbegin\expandafter
    \endcsname\expandafter{\tb@nt@atbegin}%
    \expandafter\newcommand\expandafter*\csname \tb@nt@type @atend\expandafter
    \endcsname\expandafter{\tb@nt@atend}%
  \fi
}
%    \end{macrocode}
% \begin{macro}{\tb@atbegin@after}
%   \changes{v3.09a}{2011/05/30}{new internal}%
%   Processes command \#1 with argument \#2 and optional argument \#3 and than
%   \verb|\csname #2@atbegin\endcsname|. This is used to add
%   \verb|csname #2@atbegin\endcsname| at begin part of a float (but after
%   optional argument of the float).
%    \begin{macrocode}
\newcommand*{\tb@atbegin@after}[3]{}
\def\tb@atbegin@after#1#2[#3]{%
  #1{#2}[#3]%
  \csname #2@atbegin\endcsname
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@ifvalueisnotempty}
%   \changes{v3.06}{2010/05/21}{new internal}%
%   This is only a helper for defining some of the keys.
%    \begin{macrocode}
\newcommand*{\tb@ifvalueisnotempty}[2]{%
  \begingroup
    \edef\@tempa{#2}\ifx\@tempa\@empty
      \PackageError{tocbasic}{empty value for key `#1'}{%
        The argument of key `#1' may not by empty!}%
      \aftergroup\@gobble
    \else
      \aftergroup\@firstofone
    \fi
  \endgroup
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@boolkey}
%   \changes{v3.06}{2010/05/21}{new internal}%
%   This is only a helper for boolean keys.
%    \begin{macrocode}
\newcommand*{\tb@boolkey}[2]{%
  \csname tb@#2\ifx\relax#1\relax true\else#1\fi\endcsname
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@dimkey}
%   \changes{v3.06}{2010/05/21}{new internal}%
%   This is only a helper for dimension keys.
%    \begin{macrocode}
\newcommand*{\tb@dimkey}[2]{%
  \begingroup
    \@defaultunits\@tempdima#2pt\relax\@nnil
    \edef\@tempa{\noexpand\endgroup\noexpand\def\noexpand#1{\the\@tempdima}}
  \@tempa
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@dimkey}
%   \changes{v3.06}{2010/05/21}{new internal}%
%   This is only a helper for numerical keys.
%    \begin{macrocode}
\newcommand*{\tb@numkey}[2]{%
  \begingroup
    \afterassignment\remove@to@nnil\@tempcnta#2\relax\@nnil
    \edef\@tempa{\noexpand\endgroup\noexpand\def\noexpand#1{\the\@tempcnta}}
  \@tempa
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tb@nt@autofloattype}
%   \changes{v3.06}{2010/06/01}{new internal}
%   This macro saves the float type for auto generated float types.
%    \begin{macrocode}
\newcommand*{\tb@nt@autofloattype}{16}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \iffalse
%</package>
%<*load>
% Used at \KOMAScript{} packages and classes to load the package.
%    \begin{macrocode}
\RequirePackage{tocbasic}[%
%!KOMAScriptVersion
]
%    \end{macrocode}
%
%<*class>
% \KOMAScript{} classes need some additional initialization.
%
% \changes{v1.00}{auto-activation of feature \texttt{onecolumn}}
% Set feature \texttt{onecolumn} for every toc file if feature
% \texttt{leveldown} was not used.
%    \begin{macrocode}
%<*chapter>
\AtAddToTocList[\@currname.\@currext]{\setuptoc{\@currext}{onecolumn}}%
\AtAddToTocList[float]{\setuptoc{\@currext}{onecolumn}}%
%</chapter>
%    \end{macrocode}
% Tell the package, what files are used:
%    \begin{macrocode}
\addtotoclist{toc}
\addtotoclist[float]{lof}
\addtotoclist[float]{lot}
%    \end{macrocode}
%</class>
%</load>
% \fi
%
% \Finale
%
\endinput
%
% end of file `tocbasic.dtx'
%%% Local Variables:
%%% mode: doctex
%%% coding: iso-latin-1
%%% TeX-master: t
%%% End: