summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tocloft/tocloft.dtx
blob: 1d1573eee04563bec14a7c7ebce2a9a6935814e9 (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
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
% \iffalse meta-comment
%
% tocloft.dtx
% Author: Peter Wilson, Herries Press
% Maintainer: Will Robertson (will dot robertson at latex-project dot org)
% Copyright 1998-2003 Peter R. Wilson
% Copyright 2009-2017 Will Robertson
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. <http://www.latex-project.org/lppl.txt>
%
% This work has the LPPL maintenance status "maintained".
% The Current Maintainer of this work is Will Robertson.
%
% This work consists of the files listed in the README file.
%
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{hypdoc}
\EnableCrossrefs
\CodelineIndex
\setcounter{StandardModuleDepth}{1}
\begin{document}
  \DocInput{tocloft.dtx}
\end{document}
%</driver>
%
%<*usc>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tocloft}[2017/08/31 v2.3i parameterised ToC, etc., typesetting]
%</usc>
%
% \fi
%
% \changes{v0.1}{1998/12/31}{First public (alpha) release}
% \changes{v0.1a}{1999/01/15}{Improved documentation}
% \changes{v0.2}{1999/01/17}{Uses the stdclsdv package}
% \changes{v0.2a}{1999/01/17}{Interfaced with the tocbibind package}
% \changes{v0.2b}{1999/03/07}{Corrected failure when used with float package}
% \changes{v0.2c}{1999/06/30}{Added raggedright example}
% \changes{v0.3}{1999/08/22}{Added option to prevent ToC head change}
% \changes{v1.0}{1999/09/19}{Added PackageNote reporting}
% \changes{v1.1}{2000/02/11}{Added cftXpresnum commands}
% \changes{v1.1}{2000/02/11}{Added support for subfigure package}
% \changes{v1.1a}{2000/02/11}{Changed X to Z in section 2.2}
% \changes{v2.0}{2001/03/03}{Added command for new list of...}
% \changes{v2.0}{2001/03/03}{Removed requirement for stdclsdv package}
% \changes{v2.0}{2001/03/15}{Removed requirement for hyperref option}
% \changes{v2.1}{2001/04/08}{Added control over parskip in ToC etc.}
% \changes{v2.2}{2001/04/17}{Another fix for hyperref}
% \changes{v2.3}{2002/06/15}{Made to work with the koma classes}
% \changes{v2.3a}{2002/10/03}{Partial fix for Part changes}
% \changes{v2.3b}{2003/01/20}{More fixes for Part changes}
% \changes{v2.3c}{2003/09/26}{More fixes for hyperref}
% \changes{v2.3d}{2009/09/04}{New maintainer and tiny bug fix}
% \changes{v2.3e}{2010/10/13}{Remove a message from the console output}
%
% \def\dtxfile{\texttt{tocloft.dtx}}
% \def\fileversion{v1.1a} \def\filedate{2000/02/11}
% \def\fileversion{v2.0}  \def\filedate{2001/03/15}
% \def\fileversion{v2.1}  \def\filedate{2001/04/08}
% \def\fileversion{v2.2}  \def\filedate{2001/04/17}
% \def\fileversion{v2.3}  \def\filedate{2002/06/15}
% \def\fileversion{v2.3a} \def\filedate{2002/10/03}
% \def\fileversion{v2.3b} \def\filedate{2003/01/20}
% \def\fileversion{v2.3c} \def\filedate{2003/09/26}
% \def\fileversion{v2.3d} \def\filedate{2009/09/04}
% \def\fileversion{v2.3e} \def\filedate{2010/10/13}
% \def\fileversion{v2.3f} \def\filedate{2013/05/02}
% \def\fileversion{v2.3g} \def\filedate{2014/06/14}
% \def\fileversion{v2.3h} \def\filedate{2017/08/29}
% \def\fileversion{v2.3i} \def\filedate{2017/08/31}
% \def\fileversion{v2.3j} \def\filedate{2020/01/10}
%
% \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
% \DoNotIndex{\@centercr,\@cite}
% \DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue}
% \DoNotIndex{\@input,\@ixpt,\@m}
% \DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
% \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
% \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
% \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
% \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
% \DoNotIndex{\advance,\Alph,\alph}
% \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
% \DoNotIndex{\bullet}
% \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
% \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
% \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
% \DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup}
% \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
% \DoNotIndex{\fbox}
% \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
% \DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule}
% \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi}
% \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
% \DoNotIndex{\input}
% \DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark}
% \DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright}
% \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
% \DoNotIndex{\NeedsTeXFormat,\newdimen}
% \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
% \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
% \DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip}
% \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
% \DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright}
% \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
% \DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman}
% \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
% \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
% \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
% \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
% \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
% \DoNotIndex{\wd,\xiipt,\year,\z@}
%
% \newcommand*{\Lpack}[1]{\textsf {#1}}           ^^A typeset a package
% \newcommand*{\Lopt}[1]{\textsf {#1}}            ^^A typeset an option
% \newcommand*{\file}[1]{\texttt {#1}}            ^^A typeset a file
% \newcommand*{\Lcount}[1]{\textsl {\small#1}}    ^^A typeset a counter
% \newcommand*{\pstyle}[1]{\textsl {#1}}          ^^A typeset a pagestyle
% \newcommand*{\Lenv}[1]{\texttt {#1}}            ^^A typeset an environment
% \providecommand{\bs}{\textbackslash}
%
% \title{The \Lpack{tocloft} package\thanks{This
%        file (\dtxfile) has version number \fileversion, last revised
%        \filedate.}}
%
% \author{
%   Author: Peter Wilson, Herries Press \\
%   Maintainer: Will Robertson \\
%   \texttt{will dot robertson at latex-project dot org}
% }
% \date{\filedate}
% \maketitle
% \begin{abstract}
%    The \Lpack{tocloft} package provides means of controlling the
% typographic design of the Table of Contents, List of Figures and List of
% Tables. New kinds of `List of \ldots' can be defined.
%
% The package has been tested with the
% \Lpack{tocbibind},
% \Lpack{minitoc},
% \Lpack{ccaption},
% \Lpack{subfigure},
% \Lpack{float},
% \Lpack{fncychap}, and
% \Lpack{hyperref}
% packages.
% \end{abstract}
% \tableofcontents
% \makeatletter \renewcommand{\@dotsep}{9.0} \makeatother
% \listoffigures
% \listoftables
% \StopEventually{}
%
%
%
% \section{Introduction}
%
% In the standard classes the typographic design of the Table of Contents
% (ToC), the List of Figures (LoF) and List of Tables (LoT) is fixed or,
% more precisely, it is buried within the class definitions.
% The \Lpack{tocloft} package provides handles for an author to
% change the design to meet the needs of the particular document.
%
% Elements of the package were developed as part of a class
% and package bundle for typesetting ISO standards~\cite{PRW96i}.
% This manual is typeset according to the conventions of the
% \LaTeX{} \textsc{docstrip} utility which enables the automatic
% extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
%
%    Section~\ref{sec:usc} describes the usage of the package.
% Commented source code for the package is in Section~\ref{sec:code}.
%
% The package has been tested in combination with at least
% the \Lpack{tocbibind} package~\cite{TOCBIBIND},
% the \Lpack{minitoc} package~\cite{MINITOC},
% the \Lpack{ccaption} package~\cite{CCAPTION},
% the \Lpack{subfigure} package~\cite{SUBFIGURE} (versions 2.0 and 2.1),
% the \Lpack{algorithm} package~\cite{ALGORITHM} (which, in turn, calls the
% \Lpack{float} package~\cite{FLOAT}) and the \Lpack{fncychap} package~\cite{FNCYCHAP}.
% It also works with the \Lpack{hyperref} package.
% Please send me any comments as to how you think
% that the package can be improved, or of any interesting examples of
% how you have used
% it.\footnote{Thanks to Rowland (\texttt{rebecca@astrid.u-net.com}),
%   John Foster (\texttt{john@isjf.demon.co.uk}),
%   Kasper (\texttt{kbg@dkik.dk}),
%   Lee Nave (\texttt{nave@math.washington.edu}),
%   and Andrew Thurber (\texttt{athurber@emba.uvm.edu})
%   for their suggestions.}
%
% \subsection{\LaTeX 's methods}
%
%    This is a general description of how \LaTeX{} does the processing
% for a Table of Contents. As the processing for List of Figures and
% List of Tables is similar I will, without loss of generality, just
% discuss the ToC.
%
% \DescribeMacro{\addcontentsline}
%    \LaTeX{} generates a \file{.toc} file if the document contains a
% |\tableofcontents| command. The sectioning
% commands\footnote{For figures and tables it is the \texttt{\bs caption} command
% that populates the \file{.lof} and \file{.lot} files.}
% put entries into the \file{.toc} file by calling the \LaTeX{}
% |\addcontentsline{|\meta{file}|}{|\meta{kind}|}{|\meta{title}|}|
% command, where \meta{file} is the file extension (e.g., |toc|),
% \meta{kind} is the kind of entry (e.g., |section| or |subsection|),
% and \meta{title} is the (numberered) title text. In the cases where
% there is a number, the \meta{title} argument is given in the
% form |{\numberline{number} title-text}|.
%
% NOTE: The \Lpack{hyperref} package dislikes authors using
% |\addcontentsline|. To get it to work properly with \Lpack{hyperref}
% you normally have to put |\phantomsection| (a macro defined within
% the \Lpack{hyperref} package) immediately
% before |\addcontentsline|.
%
% \DescribeMacro{\contentsline}
%     The |\addcontentsline| command writes an entry to the given file
% in the form |\contentsline{|\meta{kind}|}{|\meta{title}|}{|\meta{page}|}|
% where \meta{page} is the page number.
%     For each \meta{kind}, \LaTeX{} provides a command
% |\l@kind{|\meta{title}|}{|\meta{page}|}| which performs the actual
% typesetting of the |\contentsline| entry.
%
% \newcommand{\maxx}{120}       ^^A picture width
% \newcommand{\maxxm}{118}      ^^A \maxx - 2\
% \newcommand{\maxy}{55}        ^^A picture height
% \newcommand{\maxym}{53}       ^^A \maxy - 2
% \newcommand{\findent}{20}     ^^A indent
% \newcommand{\findentp}{22}    ^^A \findent + 2
% \newcommand{\fnumwidth}{10}   ^^A numwidth
% \newcommand{\ftocrmarg}{30}   ^^A \@tocrmarg
% \newcommand{\fpnumwidth}{20}  ^^A \@pnumwidth
% \newcommand{\fipn}{30}        ^^A \findent + \fnumwidth
% \newcommand{\frmarg}{90}      ^^A \maxx - \ftocrmarg
% \newcommand{\frnum}{100}      ^^A \maxx - \fpnumwidth
% \newcommand{\fyi}{10}         ^^A 1st y height
% \newcommand{\fyim}{8}         ^^A \fyi - 2
% \newcommand{\fyii}{20}        ^^A 2nd y height
% \newcommand{\fyiii}{25}       ^^A 3rd y height
% \newcommand{\fyiv}{30}        ^^A 4th y height
% \newcommand{\fyv}{40}         ^^A 5th y height
% \newcommand{\fyvp}{42}        ^^A \fyv + 2
% \newcommand{\flin}{4}         ^^A length of leader lines
% \newcommand{\frmargm}{89}     ^^A \frmarg (90) - a little bit
%
% \providecommand{\bs}{\textbackslash}
% \begin{figure}
% \centering
% \setlength{\unitlength}{1mm}
% \begin{picture}(\maxx,\maxy)
%     ^^A side lines and linewidth
%   \put(0,0){\line(0,1){\maxy}}
%   \put(\maxx,0){\line(0,1){\maxy}}
%   \put(0,\maxy){\vector(1,0){\maxx}}
%   \put(2,\maxym){\makebox(0,0)[tl]{\texttt{\bs linewidth}}}
%     ^^A \@pnumwidth
%   \put(\maxx,\fyi){\vector(-1,0){\fpnumwidth}}
%   \put(\maxxm,\fyim){\makebox(0,0)[tr]{\texttt{\bs @pnumwidth}}}
%   \put(\frnum,\fyi){\line(0,1){\flin}}
%     ^^A \@tocrmarg
%   \put(\maxx,\fyv){\vector(-1,0){\ftocrmarg}}
%   \put(\maxxm,\fyvp){\makebox(0,0)[br]{\texttt{\bs @tocrmarg}}}
%   \put(\frmarg,\fyv){\line(0,-1){\flin}}
%     ^^A indent
%   \put(0,\fyv){\vector(1,0){\findent}}
%   \put(2,\fyvp){\makebox(0,0)[bl]{\textit{indent}}}
%   \put(\findent,\fyv){\line(0,-1){\flin}}
%     ^^A numwidth
%   \put(\findent,\fyv){\vector(1,0){\fnumwidth}}
%   \put(\findentp,\fyvp){\makebox(0,0)[bl]{\textit{numwidth}}}
%   \put(\fipn,\fyv){\line(0,-1){\flin}}
%     ^^A last title line
%   \put(\maxx,\fyii){\makebox(0,0)[br]{487}}
%   \put(\fipn,\fyii){title end}
%     ^^A second title line
%   \put(\fipn,\fyiii){continue\ldots}
%   \put(\frmarg,\fyiii){\makebox(0,0)[br]{\ldots title}}
%     ^^A first title line
%   \put(\findent,\fyiv){\textbf{3.5}}
%   \put(\fipn,\fyiv){Heading\ldots}
%   \put(\frmarg,\fyiv){\makebox(0,0)[br]{\ldots title}}
%     ^^A dotted leader
%   \multiput(\frmargm,\fyii)(-\flin,0){12}{.}
%   \multiput(\frmarg,\fyi)(-\flin,0){2}{\line(0,1){\flin}}
%   \put(\frmarg,\fyi){\vector(-1,0){\flin}}
%   \put(\frmarg,\fyi){\vector(1,0){0}}
%   \put(\frmarg,\fyim){\makebox(0,0)[tr]{\texttt{\bs @dotsep}}}
%
% \end{picture}
% \setlength{\unitlength}{1pt}
% \caption{Layout of a ToC (LoF, LoT) entry} \label{fig:ltoc}
% \end{figure}
%
%
% \DescribeMacro{\@pnumwidth}
% \DescribeMacro{\@tocrmarg}
% \DescribeMacro{\@dotsep}
% The general layout of a
% typeset entry is illustrated in Figure~\ref{fig:ltoc}. There are three
% internal \LaTeX{} commands that are used in the typesetting. The page
% number is typeset flushright in a box of width |\@pnumwidth|, and the box
% is at the righthand margin. If the page number is too long to fit into
% the box it will stick out into the righthand margin. The title text
% is indented from the righthand margin by an amount given by |\@tocrmarg|.
% Note that |\@tocrmarg| should be greater than |\@pnumwidth|. Some
% entries are typeset with a dotted leader between the end of the title
% title text and the righthand margin indentation. The distance, in
% \emph{math units}\footnote{There are 18mu to 1em.} between the dots
% in the leader is given by the value of |\@dotsep|. In the standard
% classes the same values are used for the ToC, LoF and the LoT.
%
%    The standard values for these internal commands are:
% \begin{itemize}
% \item |\@pnumwidth| = 1.55em
% \item |\@tocrmarg| = 2.55em
% \item |\@dotsep| = 4.5
% \end{itemize}
% The values can be changed by using |\renewcommand|, in spite of the
% fact that the first two appear to be lengths.
%
%    Dotted leaders are not available for Part and Chapter ToC entries
% (nor for Section entries in the \Lpack{article} class and its derivatives).
%
% \DescribeMacro{\numberline}
%    Each |\l@kind| macro is responsible for setting the general
% \textit{indent} from the lefthand margin, and the \textit{numwidth}.
% The |\numberline{|\meta{number}|}| macro is responsible for typesetting
% the number flushleft in a box of width
% \textit{numwidth}. If the number is too long for the box then it will
% protrude into the title text. The title text is indented by
% (\textit{indent + numwidth}) from the lefthand margin. That is, the title
% text is typeset in a block of width \\
% (|\linewidth| - \textit{indent} - \textit{numwidth} - |\@tocrmarg|).
%
% \begin{table}
% \centering
% \caption[Indents and Numwidths]{Indents and Numwidths (in ems)} \label{tab:indents}
% \begin{tabular}{lcrrrr} \hline
% Entry & Level & \multicolumn{2}{c}{Chaptered} & \multicolumn{2}{c}{Otherwise} \\
%       &       & indent & numwidth & indent & numwidth \\ \hline
% part          & -1 & 0    & --- & 0    & --- \\
% chapter       & 0  & 0    & 1.5 &      &     \\
% section       & 1  & 1.5  & 2.3 & 0    & 1.5 \\
% subsection    & 2  & 3.8  & 3.2 & 1.5  & 2.3 \\
% subsubsection & 3  & 7.0  & 4.1 & 3.8  & 3.2 \\
% paragraph     & 4  & 10.0 & 5.0 & 7.0  & 4.1 \\
% subparagraph  & 5  & 12.0 & 6.0 & 10.0 & 5.0 \\
% figure/table  & (1) & 1.5 & 2.3 & 1.5  & 2.3 \\ \hline
% \end{tabular}
% \end{table}
%
% Table~\ref{tab:indents} lists the standard values for the \textit{indent}
% and \textit{numwidth}. There is no explicit \textit{numwidth} for a
% part; instead a gap of 1em is put between the number and the title text.
% Note that for a sectioning command the values
% depend on whether or not the document class provides the |\chapter|
% command. Also, which somewhat surprises me, the table and figure entries
% are all indented.
%
% \DescribeMacro{\@dottedtocline}
%    Most of the |\l@kind| commands are defined in terms of the
% |\@dottedtocline| command. This command takes three arguments: \\
% |\@dottedtocline{|\meta{seclevel}|}{|\meta{indent}|}{|\meta{numwidth}|}|. \\
% For example, one definition of the |\l@section| command is: \\
% |\newcommand*{\l@section}{\@dottedtocline{1}{1.5em}{2.3em}}| \\
% If it is necessary to change the default typesetting of the entries,
% then it is usually necessary to change these definitions (but the
% \Lpack{tocloft} package gives you handles to easily alter things without
% having to know the \LaTeX{} internals).
%
%    You can use the |\addcontentsline| command to add |\contentsline|
% commands to a file.
%
% \DescribeMacro{\addtocontents}
%    \LaTeX{} also provides the |\addtocontents{|\meta{file}|}{|\meta{text}|}|
% command that will insert \meta{text} into \meta{file}. You can use
% this for adding extra text and/or macros into the file, for processing
% when the file is typeset by |\tableofcontents| (or whatever other
% command is used for \meta{file} processing, such as |\listoftables|
% for a \file{.lot} file).
%
% As |\addcontentsline| and |\addtocontents| write their arguments to a
% file, any fragile commands used in their arguments must be |\protect|ed.
%
%    You can make certain adjustments to the ToC etc., layout without
% using any package. Some examples are:
% \begin{itemize}
% \item If your page numbers stick out into the righthand margin
%  \begin{verbatim}
%  \renewcommand{\@pnumwidth}{3em} \renewcommand{\@tocrmarg}{4em}
%  \end{verbatim}
% but using lengths appropriate to your document.
%
% \item To have the (sectional) titles in the ToC, etc., typeset ragged right with no
% hyphenation
% \begin{verbatim}
% \renewcommand{\@tocrmarg}{2.55em plus1fil}
% \end{verbatim}
% where the value |2.55em| can be changed for whatever margin space you want.
%
% \item The dots in the leaders can be eliminated by increasing |\@dotsep|
% to a large value:
%  \begin{verbatim}
%  \renewcommand{\@dotsep}{10000}
%  \end{verbatim}
%
% \item To have dotted leaders in your ToC and LoF but not in your LoT:
% \begin{verbatim}
% ...
% \tableofcontents
% \makeatletter \renewcommand{\@dotsep}{10000} \makeatother
% \listoftables
% \makeatletter \renewcommand{\@dotsep}{4.5} \makeatother
% \listoffigures
% ...
% \end{verbatim}
% For this document I used this method to double the dot spacing for
% the LoF with respect to that for the ToC. As you can see, it is much
% better that all dot leaders have the same spacing.
%
% \item To add a horizontal line across the whole width of the ToC below
% an entry for a Part:
% \begin{verbatim}
% \part{Part title}
% \addtocontents{toc}{\protect\mbox{}\protect\hrulefill\par}
% \end{verbatim}
% Note that as both |\addtocontents| and |\addcontentsline| write their
% arguments to a file, it means that any \emph{fragile} commands in
% their arguments must be protected
% by preceding each fragile command with |\protect|.
% The result of the example above
% would be the following two lines in the \file{.toc} file (assuming that it
% is the second Part and is on page 34):
% \begin{verbatim}
% \contentsline {part}{II\hspace {1em}Part title}{34}
% \mbox {}\hrulefill \par
% \end{verbatim}
% If the |\protect|s were not used, then the second line would instead be:
% \begin{small}
% \begin{verbatim}
% \unhbox \voidb@x \hbox {}\unhbox \voidb@x \leaders \hrule \hfill \kern \z@ \par
% \end{verbatim}
% \end{small}
%
% \item You may get undesired page breaks in the ToC. For example you
% may have a long multiline section title and in the ToC there is a page
% break between the lines. After your document is stable you can use
% |\addtocontents| at appropriate places in the body of the document
% to adjust the page breaking in the ToC. As examples:
%  \begin{itemize}
%  \item |\addtocontents{toc}{\protect\newpage}| to force a page break.
%  \item |\addtocontents{toc}{\protect\enlargethispage{2\baselineskip}}| to
%        make the page longer.
%  \item |\addtocontents{toc}{\protect\needspace{2\baselineskip}}| to specify
%        that if there is not a vertical space of two baselines left on
%        the page then start a new page (the |\needspace| macro is defined
%        in the \Lpack{needspace} package).
%  \end{itemize}
%
% \end{itemize}
% Remember, if you are modifying any command that includes an |@| sign then this
% must be done in either a \file{.sty} file or if in the document itself
% it must be
% surrounded by |\makeatletter| and |\makeatother|. For example, if you
% want to modify |\@dotsep| in the preamble to your document you have
% to do it like this:
% \begin{verbatim}
% \makeatletter
% \renewcommand{\@dotsep}{9.0}
% \makeatother
% \end{verbatim}
%
%
% \section{The \Lpack{tocloft} package} \label{sec:usc}
%
% The \Lpack{tocloft} package provides means of specifying the
% typography of the Table of Contents (ToC), the List of Figures (LoF)
% and the List of Tables (LoT).
%
% \DescribeMacro{\tableofcontents}
% \DescribeMacro{\listoffigures}
% \DescribeMacro{\listoftables}
% The ToC, LoF, and LoT are printed at the point in the document where
% these commands are called, as per normal \LaTeX. However, there is
% one difference between the standard \LaTeX{} behaviour and the behaviour
% with the \Lpack{tocloft} package. In the standard \LaTeX{} classes
% that have |\chapter| headings, the ToC, LoF and LoT each appear on
% a new page. With the \Lpack{tocloft} package they do not necessarily
% start new pages; if you want them to be on new pages you may have to
% specifically issue an appropriate command beforehand. For example:
% \begin{verbatim}
%  ...
% \clearpage
% \tableofcontents
% \clearpage
% \listoftables
% ...
% \end{verbatim}
%
% \DescribeMacro{\tocloftpagestyle}
% The |\thispagestyle| page style of the ToC, LoF and/or LoT is set
% by the command
% |\tocloftpagestyle{|\meta{style}|}|, where \meta{style} is one of
% the available page styles. The package initially
% sets |\tocloftpagestyle{plain}|.
%
% \subsection{Package options}
%
%    The package takes the following options:
% \begin{itemize}
% \item[\Lopt{subfigure}] This option is required if, and only if,
% the \Lpack{tocloft} and
% \Lpack{subfigure} packages are being used together. The two packages
% can be specified in any order.
%
% \item[\Lopt{titles}]
% The \Lopt{titles} option causes
% the titles of the ToC, LoF, and LoT lists to be typeset using the
% default \LaTeX{} methods. This can be useful, for example, when the
% \Lpack{tocloft} and \Lpack{fncychap} packages are used together and
% the `fancy' chapter styles should be used for the ToC, etc., titles.
%
% \end{itemize}
%
% If you use the \Lopt{titles} option you can ignore the next
% section and continue reading at section~\ref{sec:entries}.
%
% \subsection{Changing the titles} \label{sec:titles}
%
%    Commands are provided for controlling the appearance of the
% titles. Following \LaTeX{} custom, the title texts are the values
% of the |\contentsname|, |\listfigurename| and |\listtablename| commands.
%
% Similar sets of commands are provided for ToC, LoF and LoT title
% typsetting control. For convenience (certainly mine, and hopefully yours)
% in the following
% descriptions I will use |Z| to stand for `toc' or `lof' or `lot'. For
% example, |\cftmarkZ| stands for |\cftmarktoc| or |\cftmarklof| or
% |\cftmarklot|.
%
% \DescribeMacro{\cftmarkZ}
% These macros set the appearance of the running heads on the ToC, LoF, and
% LoT pages. You probably don't need to change these.
%
% \DescribeMacro{\cftbeforeZtitleskip}
% \DescribeMacro{\cftafterZtitleskip}
% These lengths control the vertical spacing before and after the titles.
% You can change them from their default values by using |\setlength|.
%
% \DescribeMacro{\cftZtitlefont}
% \DescribeMacro{\cftafterZtitle}
% The code used for typesetting the ToC title looks like
% \begin{verbatim}
% {\cfttoctitlefont \contentsname}{\cftaftertoctitle}\par
% \end{verbatim}
% By default, |\cftZtitlefont| is defined as a font specification
% (e.g., |\Large\bfseries|), and |\cftafterZtitle| is empty.
% These commands can be changed (via |\renewcommand|) to change
% the typesetting. As examples:
% \begin{itemize}
% \item |\renewcommand{\cftZtitlefont}{\hfill\Large\itshape}| will
%       result in a Large italic title typeset flushright.
% \item |\renewcommand{\cftZtitlefont}{\hfill\Large\bfseries}| together
%       with |\renewcommand{\cftafterZtitle}{\hfill}| will give
%       a centered Large bold title.
% \item Doing
% \begin{verbatim}
% \renewcommand{\cftafterZtitle}{%
%   \\[\baselineskip]\mbox{}\hfill{\normalfont Page}}
% \end{verbatim}
%       will put the word `Page' flushright on the line following the title.
%       (If you do this, then you may need to decrease
%        |\cftafterZtitleskip|).
% \item |\renewcommand{\cftafterZtitle}{\thispagestyle{empty}}| will
%       make the page with the title empty (i.e., the page
%       number will not be printed).
% \end{itemize}
%
%
% \subsection{Typesetting the entries} \label{sec:entries}
%
% Commands are also provided to enable finer control over the typesetting
% of the different kinds of entries. The parameters defining the default
% layout of the entries are illustrated as part of the \Lpack{layouts}
% package or in~\cite[page 34]{GOOSSENS94}, and are repeated in
% Figure~\ref{fig:ltoc}.
%
% \DescribeMacro{\Zdepth}
% The command |\Zdepth{|\meta{number}|}| is analogous to the standard
% |\tocdepth{|\meta{number}|}| command, in that it specifies that entries
% in the new listing should not be typeset if their numbering level
% is greater
% than \meta{number}. The default definition is
% |\setcounter{Zdepth}{1}|.
% These commands are needed, for instance by users of packages such as |subcaption|,
% which will generate subfigure and subtable captions corresponding to a |lofdepth| and
% |lotdepth| of |2|.
%
% \DescribeMacro{\cftdot}
%  In the default ToC typesetting only the more minor entries have dotted
% leader lines between the sectioning title and the page number. The
% \Lpack{tocloft} package provides for general leaders for all entries.
% The `dot' in a leader is given by the value of |\cftdot|. Its default
% definition is |\newcommand{\cftdot}{.}| which gives the default
% dotted leader. By changing |\cftdot| you can use symbols other than
% a period in the leader. For example
% \begin{verbatim}
% \renewcommand{\cftdot}{\ensuremath{\ast}}
% \end{verbatim}
% will result in a dotted leader using asterisks as the symbol.
%
% \DescribeMacro{\cftdotsep}
% \DescribeMacro{\cftnodots}
%    Each kind of entry can control the separation between the dots
% in its leader (see below). For consistency though, all dotted leaders
% should use the same spacing. The macro |\cftdotsep| specifies the
% default spacing. Its value is a number.
% However, if the separation is too large
% then no dots will be actually typeset. The macro |\cftnodots| is
% a separation value that is `too large'.
%
% \DescribeMacro{\cftsetpnumwidth}
% \DescribeMacro{\cftsetrmarg}
% The page numbers are typeset in a fixed width box. The command
% |\cftsetpnumwidth{|\meta{length}|}| can be used to change the width
% of the box (\LaTeX 's internal |\@pnumwidth|).
% The title texts will end before reaching the righthand margin.
% |\cftsetrmarg{|\meta{length}|}| can be used to set this distance
% (\LaTeX 's internal |\@tocrmarg|).
% Note that the length used in |\cftsetrmarg| should be greater
% than the length set in |\cftsetpnumwidth|. These values should remain
% constant in any given document.
%
% \DescribeMacro{\cftpnumalign}
% The page numbers are typeset in a box as described above.
% By default they are right-aligned which is suitable when the page numbers are aligned vertically on the page so their digits line up.
% For a design with fixed width between a ToC entry and its page number, say, a left alignment may be more suitable.
% This can be controlled by setting the \cs{cftpnumalign} macro to \verb|l|, \verb|c|, or \verb|r| (just like \cs{makebox}):
% \begin{verbatim}
%   \renewcommand{\cftpnumalign}{l}
% \end{verbatim}
%
% \DescribeMacro{\cftparskip}
% Normally the |\parskip| in the ToC, etc., is zero. This may be changed
% by changing the |\cftparskip| length. Note that the current value
% of |\cftparskip| is used for the ToC, LoF and LoT, but you can change
% the value before calling |\tableofcontents| or |\listoffigures| or
% |\listoftables| if one or other of these should have different values
% (which is not a good idea).
%
%
%    In the following I will use |X| to stand for the following:
% \begin{itemize}
% \item |part| for |\part| titles
% \item |chap| for |\chapter| titles
% \item |sec| for |\section| titles
% \item |subsec| for |\subsection| titles
% \item |subsubsec| for |\subsubsection| titles
% \item |para| for |\paragraph| titles
% \item |subpara| for |\subparagraph| titles
% \item |fig| for figure |\caption| titles
% \item |subfig| for subfigure |\caption| titles
% \item |tab| for table |\caption| titles
% \item |subtab| for subtable |\caption| titles
% \end{itemize}
%
% \DescribeMacro{\cftbeforeXskip}
% This controls the vertical space before an entry. It can be changed
% by using |\setlength|.
%
% \DescribeMacro{\cftXindent}
% This controls the indentation of an entry from the left margin
% (\textit{indent} in Figure~\ref{fig:ltoc}). It
% can be changed using |\setlength|.
%
% \DescribeMacro{\cftXnumwidth}
% This controls the space allowed for typesetting title numbers
% (\textit{numwidth} in Figure~\ref{fig:ltoc}). It can
% be changed using |\setlength|. Second and subsequent lines of a multiline
% title will be indented by this amount.
%
% The remaining commands are related to the specifics of typesetting
% an entry.
% This is a simplified pseudo-code version for the typesetting of numbered
% and unnumbered entries.
% \begin{verbatim}
% {\cftXfont {\cftXpresnum SNUM\cftXaftersnum\hfil} \cftXaftersnumb TITLE}%
%         {\cftXleader}{\cftXpagefont PAGE}\cftXafterpnum\par
%
% {\cftXfont TITLE}{\cftXleader}{\cftXpagefont PAGE}\cftXafterpnum\par
% \end{verbatim}
% where |SNUM| is the section number, |TITLE| is the title text and |PAGE|
% is the page number. In the numbered entry the pseudo-code \\
% |{\cftXpresnum SNUM\cftaftersnum\hfil}| \\
% is typeset within a box of width |\cftXnumwidth|.
%
% \DescribeMacro{\cftXfont}
% This controls the appearance of the title (and its preceding number,
% if any). It may be changed using |\renewcommand|.
%
% \DescribeMacro{\cftXpresnum}
% \DescribeMacro{\cftXaftersnum}
% \DescribeMacro{\cftXaftersnumb}
% \changes{v1.1}{2000/02/11}{Added description of \cs{cftXpresnum}}
% Normally the section number is typeset within a box of width |\cftXnumwidth|.
% Within the box the macro |\cftXpresnum| is first called, then the
% number is typeset, and next the |\cftXaftersnum|
% macro is called after the number is typeset. The last command
% within the box is |\hfil| to make the box contents flushleft.
% After the box is
% typeset the |\cftXaftersnumb| macro is called before typesetting
% the title text. All three of these can be changed by |\renewcommand|.
% By default they are defined to do nothing.
%
% In the standard classes the ToC entry for a |\part| is just typeset as
% the number and title, followed by the page number, with the
% |\cftpartpresnum|
% macro being called before typesetting the number and title.
% Due to \LaTeX\ ideosyncracies, |\cftpartpresnum| may become doubled in the output
% if a third-party package behaves differently to that of the default internal \LaTeX\ commands.
% The |tocloft| package contains specific code to prevent this in the case of
% the KomaScript classes and for the |titlesec| package; please contact the maintainer
% to add further corrections if you discover other packages which also exhibit this mis-behaviour.
%
% When a standard class is used the |\cftpartaftersnum| and
% |\cftpartaftersnumb| macros have no effect, but they may do something
% if a non-standard class is used.
%
%
% \DescribeMacro{\cftXleader}
% \DescribeMacro{\cftXdotsep}
% |\cftXleader| defines the leader between the title and the page number;
% it can be changed by |\renewcommand|.
% The spacing between any dots in the leader is controlled by |\cftXdotsep|
% (|\@dotsep| in Figure~\ref{fig:ltoc}).
% It can be changed by |\renewcommand| and its value must be either a
% number (e.g., 6.6 or |\cftdotsep|) or |\cftnodots| (to disable the dots).
% The spacing
% is in terms of \emph{math units} where there are 18mu to 1em.
%
% \DescribeMacro{\cftXpagefont}
% This defines the font to be used for typesetting the page number. It
% can be changed by |\renewcommand|.
%
% \DescribeMacro{\cftXafterpnum}
% This macro is called after the page number has been typeset. Its default
% is to do nothing. It can be changed by |\renewcommand|.
%
% \DescribeMacro{\cftsetindents}
% The command
% |\cftsetindents{|\meta{entry}|}{|\meta{indent}|}{|\meta{numwidth}|}|
% sets the \meta{entry}'s \textit{indent} to the length \meta{indent} and its
% \textit{numwidth} to the length \meta{numwidth}. The \meta{entry} argument
% is the name of one of the standard entries (e.g., |subsection|) or the name of
% entry that has been defined with the \Lpack{tocloft} package.
% For example \\
% |\cftsetindents{figure}{0em}{1.5em}| \\
% will make figure entries left justified.
%
%
% Various effects can be achieved by changing the definitions of |\cftXfont|,
% |\cftXaftersnum|, |\cftXaftersnumb|, |\cftXleader| and |\cftXafterpnum|,
% either singly or in combination.
% For the sake of some examples, assume that we have the following initial
% definitions
% \begin{verbatim}
% \newcommand{\cftXfont}{}
% \newcommand{\cftXaftersnum}{}
% \newcommand{\cftXaftersnumb}{}
% \newcommand{\cftXleader}{\cftdotfill{\cftXdotsep}}
% \newcommand{\cftXdotsep}{\cftdotsep}
% \newcommand{\cftXpagefont}{}
% \newcommand{\cftXafterpnum}{}
% \end{verbatim}
% (Note that the same font should be used for the title, leader and page
% number to provide a coherent appearance).
%
% \begin{itemize}
% \item To eliminate the dots in the leader:
% \begin{verbatim}
% \renewcommand{\cftXdotsep}{\cftnodots}
% \end{verbatim}
%
% \item To put something (e.g., a name) before the title (number):
% \begin{verbatim}
% \renewcommand{\cftXpresnum}{SOMETHING }
% \end{verbatim}
%
% \item To add a colon after the section number:
% \begin{verbatim}
% \renewcommand{\cftXaftersnum}{:}
% \end{verbatim}
%
% \item To put something before the title number, add a colon after the
%    the title number, set everything in bold font,
% and start the title text on the following line:
% \begin{verbatim}
% \renewcommand{\cftXfont}{\bfseries}
% \renewcommand{\cftXleader}{\bfseries\cftdotfill{\cftXdotsep}}
% \renewcommand{\cftXpagefont}{\bfseries}
% \renewcommand{\cftXpresnum}{SOMETHING }
% \renewcommand{\cftXaftersnum}{:}
% \renewcommand{\cftXaftersnumb}{\\}
% \end{verbatim}
%
%    If you are adding text in the number box in addition to the number,
% then you will probably have to increase the width of the box so that
% multiline titles have a neat vertical alignment; changing box widths
% usually implies that the indents will require modification as
% well.\footnote{Lyndon Dudding (\texttt{lyndon.dudding@totalise.co.uk})
% discovered this.}
% One possible method of adjusting the box width for the above example
% is:
% \begin{verbatim}
% \newlength{\mylen}   % a "scratch" length
% \settowidth{\mylen}{\bfseries\cftXpresnum\cftXaftersnum} % extra space
% \addtolength{\cftXnumwidth}{\mylen} % add the extra space
% \end{verbatim}
%
% \item To set the section numbers flushright:\footnote{With thanks to
% David Holz (\texttt{lbda@earthlink.net}) for requesting this.}
% \begin{verbatim}
% \setlength{\mylen}{0.5em}   % need some extra space at end of number
% \renewcommand{\cftXpresnum}{\hfill}  % note the double `l'
% \renewcommand{\cftXaftersnum}{\hspace*{\mylen}}
% \addtolength{\cftXnumwidth}{\mylen}
% \end{verbatim}
% In the above, the added initial |\hfill| in the box overrides the
% final |\hfil| in the box, thus shifting everything to the right hand
% end of the box. The extra space is so that the number is not typeset
% immediately at the left of the title text.
%
% \item To set the entry ragged left (but this only looks good for single
%       line titles):
% \begin{verbatim}
% \renewcommand{\cftXfont}{\hfill\bfseries}
% \renewcommand{\cftXleader}{}
% \end{verbatim}
%
% \item To set the page number immediately after the entry text instead of at
%       the righthand margin:
% \begin{verbatim}
% \renewcommand{\cftXleader}{}
% \renewcommand{\cftXafterpnum}{\cftparfillskip}
% \renewcommand{\cftpnumalign}{l}
% \end{verbatim}
% By default the |\parfillskip| value is locally set to fill up the last
% line of a paragraph. Just changing |\cftXleader| puts horrible interword
% spaces into the last line of the title. The |\cftparfillskip|
% command
% is part of the \Lpack{tocloft} package and is provided just so that
% the above effect can be achieved.
% In addition, this is a good example of when it would be suitable to change the alignment of the page number box.
%
% \item To remove the space inserted between table and figure caption entries between chapters:
% \begin{verbatim}
% \begingroup
%   \renewcommand*{\addvspace}[1]{}
%   \listoftables
%   \listoffigures
% \endgroup
% \end{verbatim}
% \end{itemize}
%
% \DescribeMacro{\cftpagenumbersoff}
% \DescribeMacro{\cftpagenumberson}
% The command |\cftpagenumbersoff{|\meta{entry}|}| will
% eliminate the page numbers for \meta{entry} in the listing, where
% \meta{entry} is the name of one of the standard
% kinds of entries (e.g., |subsection|, or |figure| --- including |subfigure|
% if the \Lpack{subfigure} package is used --- etc.), or the name of a
% new entry defined with the \Lpack{tocloft} package.
%
%    The command |\cftpagenumberson{|\meta{entry}|}| reverses
% the effect of a corresponding |\cftpagenumbersoff|.
%
% One question that appeared on the \file{comp.text.tex} newsgroup asked
% how to get the titles of Appendices list in the ToC \emph{without}
% page numbers. Here is a simple way of doing it, assuming the document
% has chapters
% \begin{verbatim}
% ...
% \appendix
% \addtocontents{toc}{\cftpagenumbersoff{chapter}}
% \chapter{First appendix}
% \end{verbatim}
% If there are other chaptered headings to go into the ToC after the
% appendices, then it will be necessary to do a similar \\
% |\addtocontents{toc}{\cftpagenumberson{chapter}}| \\
% to restore the page numbering in the ToC.
%
%    Similarly, if you are using the \Lpack{subfigure} package you may
% want to eliminate the page numbers for the subfigure captions. This
% can be accomplished by: \\
% |\cftpagenumbersoff{subfigure}|
%
% At this point, I leave it up to your ingenuity as to other effects that
% you can achieve. However, if you come up with further examples, let me
% know for possible inclusion in a later version of this document.
%
% \subsection{New list of\ldots}
%
% \DescribeMacro{\newlistof}
% The command |\newlistof[|\meta{within}|]{|\meta{entry}|}{|\meta{ext}|}{|\meta{listofname}|}|
% creates a new List of \ldots, and assorted commands to go along with it.
%
% The first required argument, \meta{entry} is used to define a new
% counter called |entry|. The optional \meta{within} argument can
% be used so that |entry| gets reset to one every time the counter called
% |within| is changed. That is, the first two arguments are equivalent to
% calling |\newcounter{|\meta{entry}|}[|\meta{within}|]|.
%
% The next argument, \meta{ext}, is the file extension for the new List of.
% The last argument, \meta{listofname}, is the text for the heading of the
% new List of. As an example:
% \begin{verbatim}
% \newcommand{\listanswername}{List of Answers}
% \newlistof[chapter]{answer}{ans}{\listanswername}
% \end{verbatim}
% will create a new |answer| counter that will be reset at the start of each
% |\chapter{...}|. Any answer titles will be written to the file
% \file{jobname.ans} and |\listanswername| will be used as the list heading.
% A command |\listofanswer| is created which can be used just like the
% |\listoftables| or |tableofcontents| commands to generate a listing.
% It is up to you to specify how the entries are put into the
% new List of Answers. Here is a very simple example, remembering that an
% |answer| counter has been created.
% \begin{verbatim}
% \newcommand{\answer}[1]{%
%   \refstepcounter{answer}
%   \par\noindent\textbf{Answer \theanswer. #1}
%   \addcontentsline{ans}{answer}{\protect\numberline{\theanswer}#1}\par}
% \end{verbatim}
% which, when used like: \\
% |\answer{Hard} The \ldots|  will print as:
% \par\noindent\textbf{Answer 1. Hard}\par The \ldots
%
%    As mentioned above, the |\newlistof| command creates several new
% commands, most of which you should now be familiar with. For convenience,
% assume that |\newlistof{X}{Z}{...}| has been issued; so |X| is the name
% of the new counter and corresponds to the |X| in section~\ref{sec:entries},
% and |Z| is the new file extension and corresponds to the |Z| in
% section~\ref{sec:titles}. Then, among others, the following new commands
% will be made available.
%
% The five commands, |\cftmarkZ|,
% |\cftbeforeZtitleskip|,
% |\cftafterZtitleskip|,
% |\cftZtitlefont|, and
% |\cftafterZtitle|,
% are analogous to the commands of the same names
% described in section~\ref{sec:titles}.
%
% \DescribeMacro{\listofX}
% The command |\listofX| is similar to |\listoftables|, etc.,
% in that it typesets
% the new listing at the point where it is called.
%
% \DescribeMacro{\Zdepth}
% The command |\Zdepth{|\meta{number}|}| is analogous to the standard
% |\tocdepth{|\meta{number}|}| command, in that it specifies that entries
% in the new listing should not be typeset if their numbering level
% is greater
% than \meta{number}. The default definition is
% |\setcounter{Zdepth}{1}|.
%
% \DescribeMacro{\newlistentry}
% The command
% |\newlistentry[|\meta{within}|]{|\meta{entry}|}{|\meta{ext}|}{|\meta{level-1}|}| creates
% new commands for typesetting a new kind of entry in a listing. It is used
% internally by the |\newlistof| command but may be used independently.
%
% The first required argument, \meta{entry} is used to define a new
% counter called |entry|. The optional \meta{within} argument can
% be used so that |entry| gets reset to one every time the counter called
% |within| is changed. That is, the first two arguments are equivalent to
% calling |\newcounter{|\meta{entry}|}[|\meta{within}|]|.
% The second required argument, \meta{ext}, is the file extension for the
% entry listing.
% The last argument, \meta{level-1}, is a number specifying the numbering
% level minus one,
% of the entry in a listing.
% For example, the command \\
% |\newlistof[chapter]{answer}{ans}{\listanswername}| \\
% will call the command: \\
% |\newlistentry[chapter]{answer}{ans}{0}| \\
%
%
%    Calling |\newlistentry| creates several new commands. Assuming that
% it is called as |\newlistentry[within]{X}{Z}{N}|, where |X| and |Z| are
% similar to the
% previous uses of them, and |N| is an integer number, then the following
% commands are made available.
%
%  The set of commands |\cftbeforeXskip|,
% |\cftXfont|,
% |\cftXpresnum|,
% |\cftXaftersnum|,
% |\cftXaftersnumb|,
% |\cftXleader|,
% |\cftXdotsep|,
% |\cftXpagefont|, and
% |\cftXafterpnum|,
%  are analogous to the commands of the same names
% described in section~\ref{sec:entries}. Their default values are also
% as described earlier.
%
% The default values of |\cftXindent| and |\cftXnumwidth| are set according
% to the value of the \meta{level-1} argument (i.e., |N| in this example).
% For |N=0| the settings correspond to those for
% sections in non-chaptered documents, as listed in Table~\ref{tab:indents}.
% For |N=4| the settings correspond
% to subparagraphs in non-chaptered documents, and for intermediate values
% correspond to the matching sectional division in chaptered documents.
% For values of |N| less than zero or greater than four,
% or for non-default values, use the
% |\cftsetindents| command to set the values.
%
%
% \DescribeMacro{\l@X}
%  |\l@X| is an internal command that typesets an entry in the list, and
% is defined in terms of the above |\cft*X*| commands. It will not typeset
% an entry if |\Zdepth| is |N| or less, where |Z| is the listing's file
% extension.
%
% \DescribeMacro{\theX}
% The command |\theX| prints the value of the |X| counter. It is initially
% defined so that it prints arabic numerals. If the optional \meta{within}
% argument is used, |\theX| is defined as \\
% |\renewcommand{\theX}{\thewithin.\arabic{X}}| otherwise as \\
% |\renewcommand{\theX}{\arabic{X}}|.
%
%
% As an example of the independent use of |\newlistentry|, the following
% will set up for sub-answers.
% \begin{verbatim}
% \newlistentry[answer]{subanswer}{1}
% \cftsetindents{subanswer}{1.5em}{3.0em}
% \renewcommand{\thesubanswer}{\theanswer.\alph{subanswer}}
% \newcommand{\subanswer}[1]{%
%    \refstepcounter{subanswer}
%    \par\textbf{\thesubanswer) #1}
%    \addcontentsline{ans}{subanswer{\protect\numberline{\thesubanswer}#1}}
% \setcounter{ansdepth}{2}
% \end{verbatim}
% And then:
% \begin{verbatim}
% \answer{Harder} The \ldots
%   \subanswer{Reformulate the problem} It assists \ldots
% \end{verbatim}
% will be typeset as:
% \par\noindent\textbf{Answer 2. Harder}\par The \ldots
% \par\textbf{2.a) Reformulate the problem} It assists \ldots
%
% By default the answer entries will appear in the List of Answers listing
% (typeset by the |\listofanswer| command).
% In order to get the subanswers to appear,
% the |\setcounter{ansdepth}{2}| command was used above.
%
% To turn off page numbering for the subanswers, do \\
% |\cftpagenumbersoff{subanswer}|
%
%    As another example of |\newlistentry|, suppose that an extra sectioning
% division below |subparagraph| is required, called |subsubpara|.
% The |\subsubpara| command itself can be defined via the LaTeX kernel
% |\@startsection| command.
% Also it is necessary to define a |\subsubparamark| macro,
% a new |subsubpara| counter, a |\thesubsubpara| macro and a |\l@subsubpara|
% macro. Using the \Lpack{tocloft} package's |\newlistentry|
% takes care of most of these as shown below (remember
% the caveats about commands with |@| signs in them).
% \begin{verbatim}
% \newcommand{\subsubpara}{\@startsection{subpara}%
%    {6}%                                                level
%    {\parindent}%                     indent from left margin
%    {3.25ex \@plus1ex \@minus .2ex}%       skip above heading
%    {-1em}%       runin heading with 1em between title & text
%    {\normalfont\normalsize\itshape}% italic number and title
% }
% \newlistentry[subparagraph]{subsubpara}{toc}{5}
% \cftsetindents{subsubpara}{14.0em}{7.0em}
% \newcommand*{\subsubparamark}[1]{}     % gobble heading mark
% \end{verbatim}
%
%
%     Each List of\ldots uses a file to store the list entries, and these
% files must remain open for writing throughout the document processing.
% TeX has only a limited number of files that it can keep open, and this
% puts a limit on the number of listings that can be used. For a document
% that includes a ToC but no other extra ancillary files (e.g., no
% index or bibliography output files) the maximum number of LoX's, including
% a LoF and LoT, is no more than about eleven. If you try and create too many
% new listings LaTeX will respond with the error message:
% \begin{center}
% |No room for a new write|
% \end{center}
% If you get such a message the only recourse is to redesign your document.
%
%    The \Lpack{tocloft} package does not provide a simple means of specifying
% new Lists of Floats or float environments.
% For those, I recommend the \Lpack{ccaption} package~\cite{CCAPTION}.
%
% \subsection{Experimental utilities}
%
% The macros described in this section are even more experimental than
% those described previously.
%
% \DescribeMacro{\cftchapterprecis}
%   Some old style novels, and even some modern text
% books,\footnote{For example, Robert Sedgewick, \textit{Algorithms},
% Addison-Wesley, 1983.} include a short synopsis of the contents of
% the chapter either immediately
% after the chapter heading or in the Toc, or in both places.
%
%     The command |\cftchapterprecis{|\meta{text}|}| prints its argument
% both at the
% point in the document where it is called, and also adds it to the \file{.toc}
% file. For example:
% \begin{verbatim}
% ...
% \chapter{} % first chapter
% \cftchapterprecis{Our hero is introduced; family tree; early days.}
% ...
% \end{verbatim}
%
% \DescribeMacro{\cftchapterprecishere}
% \DescribeMacro{\cftchapterprecistoc}
% The |\cftchapterprecis| command calls these two commands to print the
% text in the document (the |\...here{|\meta{text}|}| command)
% and to put it into the ToC (the |\...toc{|\meta{text}|}| command).
% These can be used individually if required.
%
% Sometimes it may be desirable to make a change to the global parameters
% for an individual entry. For example, a figure might be placed on
% the end paper of a book (the inside of the front or back cover), and
% this needs to be placed in a LoF with the page number set as, say
% `inside front cover'. If `inside front cover' is typeset as an ordinary
% page number it will stick out into the margin. Therefore, the parameters
% for this particular entry need to be changed.
%
% \DescribeMacro{\cftlocalchange}
% The command |\cftlocalchange{|\meta{file}|}{|\meta{pnumwidth}|}{|\meta{tocrmarg}|}|
% will write an entry into \meta{file} to reset the global parameters.
% The command should be called again after any special entry to reset
% the parameters back to their usual values. Any fragile commands used
% in the arguments must be protected.
%
% \DescribeMacro{\cftaddtitleline}
% The command |\cftaddtitleline{|\meta{file}|}{|\meta{kind}|}{|\meta{title}|}{|\meta{page}|}|
% will write a |\contentsline| entry into \meta{file} for a \meta{kind}
% entry with title \meta{title} and page number \meta{page}. That is,
% an entry is made of the form: \\
% |\contentsline{kind}{title}{page}| \\
% Any fragile commands used in the arguments must be protected.
%
% \DescribeMacro{\cftaddnumtitleline}
% The command |\cftaddnumtitleline{|\meta{file}|}{|\meta{kind}|}{|\meta{num}|}{|\meta{title}|}{|\meta{page}|}|
% is similar except that it also includes \meta{num} as the argument to
% the |\numberline|. That is, an entry is made of the form: \\
% |\contentsline{kind}{\numberline{num} title}{page}| \\
% Any fragile commands used in the arguments must be protected.
%
% As an example of the use of these commands,
% noting that the default \LaTeX{} values for
% |\@pnumwidth| and |\@tocrmarg| are 1.55em and 2.55em respectively,
% one might do the
% following for a figure on the frontispiece page.
% \begin{verbatim}
% ...
% % this is the frontispiece page with no number
% % draw or import the picture (with no \caption)
% \cftlocalchange{lof}{4em}{5em} % make pnumwidth big enough for
%                                % frontispiece and change margin to suit
% \cftaddtitleline{lof}{figure}{The title}{frontispiece}
% \cftlocalchange{lof}{1.55em}{2.55em} % return to normal settings
% ...
% \end{verbatim}
%    Recall that a |\caption| command will put an entry in the \file{.lof}
% file, which is not wanted here. If a caption is required, then you can
% either craft one yourself or, assuming that your general captions are not
% too exotic, use the |\legend| command from the
% \Lpack{ccaption} package. If the illustration is numbered, use the
% |\cftaddnumtitleline| command instead of |\cftaddtitleline|.
%
% \DescribeMacro{\cftZprehook}
% \DescribeMacro{\cftZposthook}
% It's surprisingly difficult to achieve multicolumn ToCs; can you guess what the problem is to write the following?
% \begin{verbatim}
% \begin{multicols}{2}
% \tableofcontents
% \end{multicols}
% \end{verbatim}
% Probably the easiest way to do it in regular \LaTeX{} is something like
% \begin{verbatim}
% \RequirePackage{multicol}
% \AtBeginDocument{\addtocontents{toc}{\protect\begin{multicols}{2}}}
% \AtEndDocument  {\addtocontents{toc}{\protect\end  {multicols}}}
% \end{verbatim}
% This method of writing to the |.toc| file is most flexible for trying to control the typesetting output within the table of contents.
%
% To make this \emph{slightly} easier with \Lpack{tocloft}, the following macros are available: \cs{cftZprehook} and \cs{cftZprehook}, where |Z| is |toc|, |lof|, |lot|, etc.
% If these are defined, they insert material just before the actual typesetting of the entries of the table of contents and so on.
% A multicolumn ToC can therefore be achieved with this:
% \begin{verbatim}
% \RequirePackage{multicol}
% \renewcommand\cfttocprehook{\begin{multicols}{2}}
% \renewcommand\cfttocposthook{\end{multicols}}
% \end{verbatim}
%
% \subsection{Usage with other packages}
%
%    The \Lpack{tocloft} and \Lpack{tocbibind} packages can be used together
% in the same document. The \Lpack{tocbibind} package provides easy means
% of adding document elements like the bibliography or the index to the
% Table of Contents. However there is one known potential problem:
% \begin{itemize}
% \item If the argument to the |\tocotherhead| command is other than one
% of the normal sectioning divisions (i.e., part through to sub-paragraph)
% such as |\tocotherhead{clause}|,
% then this will almost certainly cause a problem (as the \Lpack{tocloft}
% package will not know how to define the corresponding |\l@clause| command).
% In such a case you will have to supply the appropriate macros yourself.
% \end{itemize}
%
% \DescribeMacro{\@cftbsnum}
% \DescribeMacro{\@cftasnum}
% \DescribeMacro{\@cftasnumb}
%    Some packages, like the \Lpack{float} package by Anselm Lingnau,
% enable the creation of other kinds of \textit{List of \ldots}.
% The \Lpack{tocloft} package is only minimally able to change the
% formatting of these,
% principally because the packages are independent of each other and, in
% the case of the \Lpack{float} package, new kinds of float environments
% and their associated lists can be created on the fly at any point in
% a document. Some aspects of the typesetting
% are controlled by |\@cftbsnum|, |\@cftasnum| and |\@cftasnumb| commands.
% These are equivalent to the |\cftXpresnum|, |\cftXaftersnum| and |\cftXaftersnumb|
% commands described earlier. By default they are defined to do nothing, but
% may be renewed to do something.
%
%   The \Lpack{tocloft} and \Lpack{minitoc} packages have an unfortunate
% interaction,\footnote{Discovered by Lyndon Dudding
% (\texttt{lyndon.dudding@totalise.co.uk}).} which fortunately can be fixed.
% In the normal course of events, when \Lpack{minitoc} is used in a chaptered
% document it will typeset section
% entries in the minitocs in bold font. If \Lpack{tocloft} is used in
% conjunction with \Lpack{minitoc}, then the minitoc section entries are
% typeset in the normal font, except for the page numbers which are in
% bold font, while the ToC section entries are all in normal font.
%
%    One cure, if you want the minitoc section entries to be all in normal
% font is to put:
% \begin{verbatim}
% \renewcommand{\mtcSfont}{\small\normalfont}
% \end{verbatim}
% in the preamble.
%
%    Otherwise, the cure is the following incantation:
% \begin{verbatim}
% \renewcommand{\cftsecfont}{\bfseries}
% \renewcommand{\cftsecleader}{\bfseries\cftdotfill{\cftdotsep}}
% \renewcommand{\cftsecpagefont}{\bfseries}
% \end{verbatim}
% To have the section entries in both the ToC and the minitocs in bold then
% put the incantation in the preamble. To have only the minitoc section
% entries in bold while the ToC entries are in the normal font,
% put the incantation between the |\tableofcontents|
% command and the first |\chapter| command.
%
%
% In general, use with other packages that redefine any of the macros that
% \Lpack{tocloft} also modifies is likely to be problematic.
%
% \section{The package code} \label{sec:code}
%
%    \begin{macrocode}
%<*usc>
%    \end{macrocode}
%
% In order to try and avoid name clashes with other packages, each internal
% name will include the character string \texttt{@cft}.
%
% \begin{macro}{\@cftifundefined}
% \changes{v2.3h}{2017/08/29}{Use internal ifundefined macro to fix conflict with fancyhdr}
% Due to a conflict with how this package and fancyhdr checked for undefinedness.
%    \begin{macrocode}
\newcommand\@cftifundefined[1]{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname #1\endcsname\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftquit}
% \begin{macro}{\if@cfthaschapter}
% We will be using either chapter or section type headings for the ToC, etc.,
% so we need to know which of these the document class supports.
% \changes{v2.0}{2001/03/03}{Revamped chapter checking so the stdclsdv package no longer required}
%    \begin{macrocode}
\newcommand{\@cftquit}{}
\newif\if@cfthaschapter
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@cftkoma}
% The \Lpack{koma} classes have different defaults than the standard classes,
% so we need to know if a \Lpack{koma} class has been loaded.
% \changes{v2.3}{2002/06/15}{Added check for a koma class}
%    \begin{macrocode}
\newif\if@cftkoma
\@cftkomafalse
\@ifclassloaded{scrartcl}{\@cftkomatrue}{}
\@ifclassloaded{scrreprt}{\@cftkomatrue}{}
\@ifclassloaded{scrbook}{\@cftkomatrue}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@cfttitlesec}
% \changes{v2.3f}{2013/04/30}{Added check for titlesec package}
%    \begin{macrocode}
\newif\if@cfttitlesec
\AtBeginDocument{\@ifpackageloaded{titlesec}{\@cfttitlesectrue}{}}
%    \end{macrocode}
% \end{macro}
%
% Issue a warning if there are no recognised sectional divisions
% and then skip the rest of the package code.
%    \begin{macrocode}
\@cftifundefined{chapter}{%
  \@cfthaschapterfalse
  \@cftifundefined{section}{%
    \PackageWarning{tocloft}%
      {I don't recognize any sectional divisions so I'll do nothing}
    \renewcommand{\@cftquit}{\endinput}
    }{\PackageInfo{tocloft}{The document has section divisions}}
  }{\@cfthaschaptertrue
    \PackageInfo{tocloft}{The document has chapter divisions}}
%    \end{macrocode}
% Perhaps quit now.
%    \begin{macrocode}
\@cftquit
%    \end{macrocode}
%
% Use chapter style if |\if@cfthaschapter| is TRUE, otherwise section style.
%
% \begin{macro}{\if@cfttocbibind}
% A flag that is set TRUE iff the \Lpack{tocbibind} package has been loaded.
% The 1998/11/15 version of \Lpack{tocbibind} does not necessarily work well
% with \Lpack{tocloft}.
%    \begin{macrocode}
\newif\if@cfttocbibind
\AtBeginDocument{%
  \@ifpackageloaded{tocbibind}{\@cfttocbibindtrue}{\@cfttocbibindfalse}
  \if@cfttocbibind
    \@ifpackagelater{tocbibind}{1998/11/16}{}{%
      \PackageWarning{tocloft}{%
You are using a version of the tocbibind package\MessageBreak
that is not compatible with tocloft.\MessageBreak
The results may be surprising.\MessageBreak
Consider installing the current version of tocbibind.}}
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@cftnctoc}
% A boolean used to implement the \Lopt{titles} option. It is TRUE
% if the ToC, LoT, LoF titles should use the default styles.
%    \begin{macrocode}
\newif\if@cftnctoc\@cftnctocfalse
\DeclareOption{titles}{\@cftnctoctrue}
  %% \ProcessOptions\relax
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@cftsubfigopt}
% A boolean used to implement the \Lopt{subfigure} option.
%    \begin{macrocode}
\newif\if@cftsubfigopt\@cftsubfigoptfalse
\DeclareOption{subfigure}{\@cftsubfigopttrue}
%    \end{macrocode}
% \end{macro}
%
% Process the options.
%
%    \begin{macrocode}

\ProcessOptions\relax

%    \end{macrocode}
%
% \begin{macro}{\tocloftpagestyle}
% \begin{macro}{\@cftpagestyle}
% A user-level macro to set the pagestyle for the first page of the ToC, etc.
% The default is the |plain| pagestyle.
% \changes{v2.3}{2002/06/15}{Added \cs{tocloftpagestyle}}
%    \begin{macrocode}
\newcommand{\tocloftpagestyle}[1]{%
  \def\@cftpagestyle{\thispagestyle{#1}}}
\tocloftpagestyle{plain}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftmarktoc}
% \begin{macro}{\cftmarklof}
% \begin{macro}{\cftmarklot}
%  These three macros set the style for running heads. They are initialised
% to give the default appearance.
% \changes{v2.3}{2002/06/15}{Marking commands are different for koma}
%    \begin{macrocode}
\newcommand{\cftmarktoc}{%
  \@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}
\newcommand{\cftmarklof}{%
  \@mkboth{\MakeUppercase\listfigurename}{\MakeUppercase\listfigurename}}
\newcommand{\cftmarklot}{%
  \@mkboth{\MakeUppercase\listtablename}{\MakeUppercase\listtablename}}
\if@cftkoma
  \renewcommand{\cftmarktoc}{%
    \@mkboth{\contentsname}{\contentsname}}
  \renewcommand{\cftmarklof}{%
    \@mkboth{\listfigurename}{\listfigurename}}
  \renewcommand{\cftmarklot}{%
    \@mkboth{\listtablename}{\listtablename}}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@cfttocstart}
% \begin{macro}{\@cfttocfinish}
% Two macros to perform the actions at the beginning and end of the
% |\tableofcontents| command (and friends). |\@cfttocstart| deals with
% chaptered documents, ensuring that the ToC is typeset in a single
% column (see \file{classes.dtx} for the original code).
% These macros are also provided by the \Lpack{ccaption} package.
%    \begin{macrocode}
\providecommand{\@cfttocstart}{%
  \if@cfthaschapter
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
  \fi}
%    \end{macrocode}
% |\@cfttocfinish| resets, if required, twocolumn typesetting.
%    \begin{macrocode}
\providecommand{\@cfttocfinish}{%
  \if@cfthaschapter
    \if@restonecol\twocolumn\fi
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\phantomsection}
% This is provided because the \Lopt{hyperref} package screws with
% |\addcontentsline|.
% \changes{v2.2}{2001/04/17}{Provided \cs{phantomsection}}
% \changes{v2.2}{2001/04/17}{Added \cs{phantomsection} before \cs{addcontentsline} commands}
%    \begin{macrocode}
\providecommand{\phantomsection}{}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftdobibtoc}
% If the \Lpack{tocbibind} package has been used and it has
% redefined |\tableofcontents| we need to cater for that. The contents
% of the definition are defined in \Lpack{tocbibind}.
%    \begin{macrocode}
\newcommand{\@cftdobibtoc}{%
  \if@dotoctoc
    \if@bibchapter
      \phantomsection
      \addcontentsline{toc}{chapter}{\contentsname}
    \else
      \phantomsection
      \addcontentsline{toc}{\@tocextra}{\contentsname}
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftparskip}
% The |\parskip| local to the ToC, etc., is set to the length |\cftparskip|.
% \changes{v2.1}{2001/04/08}{Added \cs{cftparskip} for local parskip in ToC, etc.}
%    \begin{macrocode}
\newlength{\cftparskip}
\setlength{\cftparskip}{0pt}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\tableofcontents}
% This is a parameterised version of the default |\tableofcontents| command.
% Each class has its own definition, but we have to cater for all classes
% in one definition, hence some of the checks. The definition is
% modified after all packages have been loaded.
%
% If the \Lopt{titles} option has been used, then the command is not modified.
%
%    \begin{macrocode}
\AtBeginDocument{%
\if@cftnctoc
  % ensure \cftparskip is still set properly
  \let\OLD@starttoc\@starttoc
  \renewcommand{\@starttoc}[1]{%
    \begingroup
      \parskip=\cftparskip
      \OLD@starttoc{#1}%
    \endgroup
  }
\else
  \renewcommand{\tableofcontents}{%
    \@cfttocstart
%    \end{macrocode}
% Ensure that any previous paragraph has been finished. Within a group set
% the local paragraphing style and typeset the title.
%    \begin{macrocode}
    \par
    \begingroup
      \parindent\z@ \parskip\cftparskip
      \@cftmaketoctitle
%    \end{macrocode}
% If \Lpack{tocbibind} has been used, then add the ToC
% name to the ToC.
%    \begin{macrocode}
      \if@cfttocbibind
        \@cftdobibtoc
      \fi
%    \end{macrocode}
% Finally, read the \file{.toc} file and finish up.
%    \begin{macrocode}
      \@starttoc{toc}%
    \endgroup
    \@cfttocfinish}
\fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftmaketoctitle}
% This command typesets the title for the ToC.
% \changes{v2.3}{2002/06/15}{Added \cs{@secpenalty} to \cs{@cftmaketoctitle}}
% \changes{v2.3}{2002/06/15}{Added \cs{@cftpagestyle} to \cs{@cftmaketoctitle}}
%    \begin{macrocode}
\newcommand{\@cftmaketoctitle}{%
  \addpenalty\@secpenalty
  \if@cfthaschapter
    \vspace*{\cftbeforetoctitleskip}%
  \else
    \vspace{\cftbeforetoctitleskip}%
  \fi
  \@cftpagestyle
  {\interlinepenalty\@M
  {\cfttoctitlefont\contentsname}{\cftaftertoctitle}%
  \cftmarktoc
  \par\nobreak
  \vskip \cftaftertoctitleskip
  \@afterheading}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforetoctitleskip}
% \begin{macro}{\cftaftertoctitleskip}
%  These two lengths control the vertical spacing before and after the
%  ToC title.
%    \begin{macrocode}
\newlength{\cftbeforetoctitleskip}
\newlength{\cftaftertoctitleskip}
%    \end{macrocode}
% Their values depend on whether the document has chapters or not. In
% chaptered documents the default ToC title is typeset as a |\chapter*|,
% otherwise as a |\section*|.
%    \begin{macrocode}
\if@cfthaschapter
  \setlength{\cftbeforetoctitleskip}{50pt}
  \setlength{\cftaftertoctitleskip}{40pt}
\else
  \setlength{\cftbeforetoctitleskip}{3.5ex \@plus 1ex \@minus .2ex}
  \setlength{\cftaftertoctitleskip}{2.3ex \@plus.2ex}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cfttoctitlefont}
% \begin{macro}{\cftaftertoctitle}
% The ToC title is typeset in the style given by |\cfttoctitlefont|.
% The macro |\cftaftertoctitle| is called after typesetting the title.
% This is initialised to do nothing.
% Both these macros can be redefined to do other things (e.g., adding
% an |\hfill| to |\cfttoctitlefont| will make the title flushright).
% \changes{v2.3}{2002/06/15}{koma changes the title fonts}
%    \begin{macrocode}
\if@cfthaschapter
  \newcommand{\cfttoctitlefont}{\normalfont\Huge\bfseries}
  \if@cftkoma\renewcommand{\cfttoctitlefont}{\size@chapter\sectfont}\fi
\else
  \newcommand{\cfttoctitlefont}{\normalfont\Large\bfseries}
  \if@cftkoma\renewcommand{\cfttoctitlefont}{\size@section\sectfont}\fi
\fi
\newcommand{\cftaftertoctitle}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftsetpnumwidth}
% \begin{macro}{\cftsetrmarg}
%  Users commands for setting |\@pnumwidth| and |\@tocrmarg|.
%    \begin{macrocode}
\newcommand{\cftsetpnumwidth}[1]{\renewcommand{\@pnumwidth}{#1}}
\newcommand{\cftsetrmarg}[1]{\renewcommand{\@tocrmarg}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftpnumalign}
% \changes{v2.3f}{2013/05/02}{Add \cs{cftpnumalign} for page number alignment}
% Alignment string (as input to \cs{makebox} for the page number box.
%    \begin{macrocode}
\newcommand{\cftpnumalign}{r}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftdot}
% \begin{macro}{\cftdotfill}
% In the default ToC, a dotted line can be used to provide a leader between
% a title and the page number. The definition of this leader is buried
% in the |\@dottedtocline| command. The |\cftdotfill{|\meta{sep}|}|
% command provides a parameterised version of the leader code, where
% \meta{sep} is the separation between the dots in mu units.
% The symbol used for the `dots' in the leader is given by the value
% of |\cftdot|. These macros are also provided by the \Lpack{ccaption} package.
%    \begin{macrocode}
\providecommand{\cftdot}{.}
\providecommand{\cftdotfill}[1]{%
  \def\@tempa{#1}%
  \def\@tempb{\cftnodots}%
  \ifx\@tempa\@tempb
    \hfill
  \else
    \leaders\hbox{$\m@th\mkern #1 mu\hbox{\cftdot}\mkern #1 mu$}\hfill
  \fi
}
%    \end{macrocode}
% \changes{v2.3f}{2013/04/30}{Specifically avoid placing dots when \cs{cftnodots} is used}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftdotsep}
% \begin{macro}{\cftnodots}
% |\cftdotsep| holds the default dot separation, and is also provided
% by the \Lpack{ccaption} package.
% If the kerns in |\cftdotfill| are large enough, then no dots will
% be printed. |\cftnodots| should be `large enough'.
% (Actually, |\cftnodots| is now used as a flag for a conditional branch, so its numerical value isn't as important now.)
%    \begin{macrocode}
\providecommand{\cftdotsep}{4.5}
\newcommand{\cftnodots}{5000}
%    \end{macrocode}
% \changes{v2.3f}{2013/04/30}{Reduce \cs{cftnodots} to avoid very large dotsep sizes.}
% \end{macro}
% \end{macro}
%
%     Now for the trickier bits regarding the typesetting of the ToC
% entries.
%
%     A \file{.toc} (also \file{.lof} and \file{.lot}) file consists
% of a list of
% |\contentsline{|\meta{kind}|}{|\meta{title}|}{|\meta{page}|}|
% commands, where \meta{kind} is the kind of heading (e.g., |part| or
% |section| or |figure|), \meta{title} is the title text (including the number),
% and \meta{page} is the page number. The entries are inserted into the
% file by calling the
% |\addcontentsline{|\meta{file}|}{|\meta{kind}|}{|\meta{title}|}|
% command, where \meta{file} is the file extension (e.g., |toc|, |lot|)
% and the other arguments are the same as for the |\contentsline|
% command. (Arbitrary stuff may also be put into the file via the
% |\addtocontents{|\meta{file}|}{|\meta{text}|}| command).
% The typesetting of the |\contentsline| entries is performed by
% commands of the form |\l@kind|. The sectioning and captioning commands
% call |\addcontentsline| to insert their titles into the \file{.toc}
% etc., files.
%
%     For the purposes at hand it is generally impossible to treat
% the typesetting
% of a title and its number separately, as both are bundled into the
% \meta{title} argument within |\contentsline|. They could be handled
% separately if the |\contentsline| command was suitably modified. If
% this was done, then the |\addtocontentsline| command would also need
% to be changed which would then require the sectioning and captioning
% commands to be modified as well. This is certainly possible, but would
% cause problems if any other package also modified the sectioning or
% captioning commands, and there are several packages which do this.
%
%     Having said this, for all but Part entries, the sectional number
% is typeset via the |\numberline| command. We can take advantage of
% this fact.
%
%     I have taken the decision to not touch the |\contentsline| macro
% and instead to do what can be done with it as it exists. That is, I will
% modify the |\l@kind| commands. Essentially, my new definitions
% consist of inlined versions of the code for |\@dottedtocline|.
%
% \begin{macro}{\cftparfillskip}
% The |\l@kind| commands modify (locally) the value of |\parfillskip|.
% |\cftparfillskip| is a copy of the default \textit{\TeX book}
% |\parfillskip| definition.
%    \begin{macrocode}
\newcommand{\cftparfillskip}{\parfillskip=0pt plus1fil}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\numberline}
% \changes{v1.1}{2000/02/11}{Added \cs{@cftbsnum} to \cs{numberline}}
% The purpose of the |\numberline{|\meta{secnum}|}| command is to typeset
% \meta{secnum} left justified in a box of width |\@tempdima|. I redefine
% it to add three additional parameters, namely |\@cftbsnum|,
% |\@cftasnum| and |\@cftasnumb|
% (see \file{ltsect.dtx} for the original
% definition).
%    \begin{macrocode}
\renewcommand{\numberline}[1]{%
  \hb@xt@\@tempdima{\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftbsnum}
% \begin{macro}{\@cftasnum}
% \begin{macro}{\@cftasnumb}
% \changes{v0.2b}{1999/03/07}{Added empty definitions for @cftasnum and @cftasnumb commands}
% \changes{v1.1}{2000/02/11}{Added empty definition of \cs{@cftbsnum}}
% Originally these were not defined but were |\let| to appropriate commands
% in the |\l@...| commands, but they
% have to be defined in case something unexpected calls |\numberline|,
% for example through use of the \Lpack{float} package.\footnote{This bug
% was discovered by Andrew Thurber when using the \Lpack{tocloft} and
% \Lpack{algorithm} packages together.}
%    \begin{macrocode}
\newcommand{\@cftbsnum}{}
\newcommand{\@cftasnum}{}
\newcommand{\@cftasnumb}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \begin{macro}{\l@part}
% \begin{macro}{\if@cftdopart}
% \changes{v1.1}{2000/02/11}{Added \cs{@cftbsnum} and \cs{cftXpresnum} to
%                            all \cs{\l@X} commands}
% \changes{v1.1}{2000/02/11}{Added \cs{cftXpresnum} commands}
%  |\l@part{|\meta{title}|}{|\meta{page}|}| typesets the ToC entry for
% a |part| heading. It is a parameterised copy of the default |\l@part|
% (see \file{classes.dtx} for the original definition and the code
%  below for |\l@subsection| for an explanation of most of this
%  code). By default, Parts
% (and Chapters) do not have dotted leaders. This package provides
% for all entries to have dotted leaders.
% \changes{v0.2a}{1999/01/24}{In article class, Part level is 0 not -1}
% \changes{v2.0}{2001/03/03}{Checked directly for \cs{part} definition}
% \changes{v2.3a}{2002/10/03}{Added \cs{cftpartpresnum} to \cs{l@part}}
%
%    \begin{macrocode}
\newif\if@cftdopart
\newif\if@cfthaspart
\@cftifundefined{part}{\@cfthaspartfalse}{\@cfthasparttrue}
\if@cfthaspart
\renewcommand*{\l@part}[2]{%
  \@cftdopartfalse
  \ifnum \c@tocdepth >-2\relax
    \if@cfthaschapter
      \@cftdoparttrue
    \fi
    \ifnum \c@tocdepth >\m@ne
      \if@cfthaschapter\else
        \@cftdoparttrue
      \fi
    \fi
  \fi
  \if@cftdopart
    \if@cfthaschapter
      \addpenalty{-\@highpenalty}%
    \else
      \addpenalty\@secpenalty
    \fi
    \addvspace{\cftbeforepartskip}%
    \begingroup
      {\leftskip \cftpartindent\relax
       \rightskip \@tocrmarg
       \parfillskip -\rightskip
       \parindent \cftpartindent\relax\@afterindenttrue
       \interlinepenalty\@M
       \leavevmode
       \@tempdima \cftpartnumwidth\relax
       \let\@cftbsnum \cftpartpresnum
       \let\@cftasnum \cftpartaftersnum
       \let\@cftasnumb \cftpartaftersnumb
       \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
%    \end{macrocode}
% In default \LaTeX, the part ToC entry is written without \verb|\numberline|
% and hence the `presnum' needs to be inserted manually.
% In Koma-Script and titlesec (and probably others---let me know!), however, this is not the case.
%    \begin{macrocode}
       {\cftpartfont \if@cftkoma\else\if@cfttitlesec\else\cftpartpresnum\fi\fi #1}%
       \cftpartfillnum{#2}}
      \nobreak
      \if@cfthaschapter
        \global\@nobreaktrue
        \everypar{\global\@nobreakfalse\everypar{}}%
      \else
        \if@compatibility
          \global\@nobreaktrue
          \everypar{\global\@nobreakfalse\everypar{}}%
        \fi
      \fi
    \endgroup
  \fi}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftbeforepartskip}
% \begin{macro}{\cftpartnumwidth}
% \begin{macro}{\cftpartfont}
% \begin{macro}{\cftpartpresnum}
% \begin{macro}{\cftpartaftersnum}
% \begin{macro}{\cftpartaftersnumb}
% \begin{macro}{\cftpartleader}
% \begin{macro}{\cftpartdotsep}
% \begin{macro}{\cftpartpagefont}
% \begin{macro}{\cftpartafterpnum}
% \begin{macro}{\cftpartindent}
% \begin{macro}{\cftpartfillnum}
%  These are the user commands to control the typesetting of Part entries.
%  They are initialised to give the standard appearance.
% \changes{v2.3a}{2002/10/03}{Deleted \cs{cftpartaftersnum} and \cs{cftpartaftersnumb}}
% \changes{v2.3b}{2003/01/20}{Reinstated \cs{cftpartaftersnum} and \cs{cftpartaftersnumb}}
%    \begin{macrocode}
\if@cfthaspart
  \newlength{\cftbeforepartskip}
    \setlength{\cftbeforepartskip}{2.25em \@plus\p@}
  \newlength{\cftpartnumwidth}
    \setlength{\cftpartnumwidth}{0em}
  \newcommand{\cftpartfont}{\large\bfseries}
  \newcommand{\cftpartpresnum}{}
  \newcommand{\cftpartaftersnum}{}
  \newcommand{\cftpartaftersnumb}{}
  \newcommand{\cftpartleader}{\large\bfseries\cftdotfill{\cftpartdotsep}}
  \newcommand{\cftpartdotsep}{\cftnodots}
  \newcommand{\cftpartpagefont}{\large\bfseries}
  \newcommand{\cftpartafterpnum}{}
  \newlength{\cftpartindent}
    \setlength{\cftpartindent}{0em}
  \newcommand{\cftpartfillnum}[1]{%
    {\cftpartleader}%
    {\makebox[\@pnumwidth][\cftpnumalign]{\cftpartpagefont #1}\cftpartafterpnum\par}%
  }
%    \end{macrocode}
% \Lpack{koma} classes use some different settings.
% \changes{v2.3}{2002/06/15}{koma has different part settings}
%    \begin{macrocode}
  \if@cftkoma
    \setlength{\cftpartnumwidth}{2em}
    \renewcommand{\cftpartfont}{\sectfont\large}
    \renewcommand{\cftpartpagefont}{\sectfont\large}
  \fi
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@chapter}
%  |\l@chapter{|\meta{title}|}{|\meta{page}|}| typesets the ToC entry for
% a |chapter| heading. It is a parameterised copy of the default |\l@chapter|
% (see \file{classes.dtx} for the original definition). This only applies
% to chaptered documents.
%    \begin{macrocode}
\if@cfthaschapter
\renewcommand*{\l@chapter}[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip \cftbeforechapskip
    {\leftskip \cftchapindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftchapindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftchapnumwidth\relax
     \let\@cftbsnum \cftchappresnum
     \let\@cftasnum \cftchapaftersnum
     \let\@cftasnumb \cftchapaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftchapfont #1}\nobreak
     \cftchapfillnum{#2}}%
  \fi}%
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforechapskip}
% \begin{macro}{\cftchapindent}
% \begin{macro}{\cftchapnumwidth}
% \begin{macro}{\cftchapfont}
% \begin{macro}{\cftchappresnum}
% \begin{macro}{\cftchapaftersnum}
% \begin{macro}{\cftchapaftersnumb}
% \begin{macro}{\cftchapleader}
% \begin{macro}{\cftchapdotsep}
% \begin{macro}{\cftchappagefont}
% \begin{macro}{\cftchapafterpnum}
% \begin{macro}{\cftchapfillnum}
%  These are the user commands to control the typesetting of Chapter entries.
%  They are initialised to give the standard appearance.
%    \begin{macrocode}
\if@cfthaschapter
  \newlength{\cftbeforechapskip}
    \setlength{\cftbeforechapskip}{1.0em \@plus\p@}
  \newlength{\cftchapindent}
    \setlength{\cftchapindent}{0em}
  \newlength{\cftchapnumwidth}
    \setlength{\cftchapnumwidth}{1.5em}
  \newcommand{\cftchapfont}{\bfseries}
  \newcommand{\cftchappresnum}{}
  \newcommand{\cftchapaftersnum}{}
  \newcommand{\cftchapaftersnumb}{}
  \newcommand{\cftchapleader}{\bfseries\cftdotfill{\cftchapdotsep}}
  \newcommand{\cftchapdotsep}{\cftnodots}
  \newcommand{\cftchappagefont}{\bfseries}
  \newcommand{\cftchapafterpnum}{}
  \newcommand{\cftchapfillnum}[1]{%
    {\cftchapleader}\nobreak
    \makebox[\@pnumwidth][\cftpnumalign]{\cftchappagefont #1}\cftchapafterpnum\par
  }
%    \end{macrocode}
% \Lpack{koma} classes have different chapter settings.
% \changes{v2.3}{2002/06/15}{koma has different chapter settings}
%    \begin{macrocode}
  \if@cftkoma
    \renewcommand{\cftchapfont}{\sectfont}
  \fi
\fi

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@section}
%  |\l@section{|\meta{title}|}{|\meta{page}|}| typesets the ToC entry for
% a |section| heading. It is a parameterised copy of the default |\l@section|
% (see \file{classes.dtx} for the original definition).
%    \begin{macrocode}
\renewcommand*{\l@section}[2]{%
  \ifnum \c@tocdepth >\z@
    \if@cfthaschapter
      \vskip \cftbeforesecskip
    \else
      \addpenalty\@secpenalty
      \addvspace{\cftbeforesecskip}
    \fi
    {\leftskip \cftsecindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftsecindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftsecnumwidth\relax
     \let\@cftbsnum \cftsecpresnum
     \let\@cftasnum \cftsecaftersnum
     \let\@cftasnumb \cftsecaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftsecfont #1}\nobreak
     \cftsecfillnum{#2}}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforesecskip}
% \begin{macro}{\cftsecindent}
% \begin{macro}{\cftsecnumwidth}
% \begin{macro}{\cftsecfont}
% \begin{macro}{\cftsecpresnum}
% \begin{macro}{\cftsecaftersnum}
% \begin{macro}{\cftsecaftersnumb}
% \begin{macro}{\cftsecleader}
% \begin{macro}{\cftsecdotsep}
% \begin{macro}{\cftsecpagefont}
% \begin{macro}{\cftsecafterpnum}
% \begin{macro}{\cftsecfillnum}
%  These are the user commands to control the typesetting of Section entries.
%  They are initialised to give the standard appearance.
%    \begin{macrocode}
\newlength{\cftbeforesecskip}
\newlength{\cftsecindent}
\newlength{\cftsecnumwidth}
\newcommand{\cftsecpresnum}{}
\newcommand{\cftsecaftersnum}{}
\newcommand{\cftsecaftersnumb}{}
\if@cfthaschapter
  \setlength{\cftbeforesecskip}{\z@ \@plus.2\p@}
  \setlength{\cftsecindent}{1.5em}
  \setlength{\cftsecnumwidth}{2.3em}
  \newcommand{\cftsecfont}{\normalfont}
  \newcommand{\cftsecleader}{\normalfont\cftdotfill{\cftsecdotsep}}
  \newcommand{\cftsecdotsep}{\cftdotsep}
  \newcommand{\cftsecpagefont}{\normalfont}
\else
  \setlength{\cftbeforesecskip}{1.0em \@plus\p@}
  \setlength{\cftsecindent}{0em}
  \setlength{\cftsecnumwidth}{1.5em}
  \newcommand{\cftsecfont}{\bfseries}
  \newcommand{\cftsecleader}{\bfseries\cftdotfill{\cftsecdotsep}}
  \newcommand{\cftsecdotsep}{\cftnodots}
  \newcommand{\cftsecpagefont}{\bfseries}
\fi
\newcommand{\cftsecafterpnum}{}
\newcommand{\cftsecfillnum}[1]{%
  {\cftsecleader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cftsecpagefont #1}\cftsecafterpnum\par
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@subsection}
%  |\l@subsection{|\meta{title}|}{|\meta{page}|}| typesets the ToC entry for
% a |subsection| heading. It is a parameterised copy of the default
% |\l@subsection|
% (see \file{classes.dtx} for the original definition).
%    \begin{macrocode}
\renewcommand*{\l@subsection}[2]{%
%    \end{macrocode}
% Only typeset the entry if it falls within the |tocdepth|.
%    \begin{macrocode}
  \ifnum \c@tocdepth >\@ne
%    \end{macrocode}
% Add some vertical space.
%    \begin{macrocode}
    \vskip \cftbeforesubsecskip
%    \end{macrocode}
% Start a group to keep paragraphing changes local. Set the |\leftskip|
% to the entry's indentation.
%    \begin{macrocode}
    {\leftskip \cftsubsecindent\relax
%    \end{macrocode}
% Set the |\rightskip| to |\@tocrmarg| to leave room for the page number.
%    \begin{macrocode}
     \rightskip \@tocrmarg
%    \end{macrocode}
% Ensure that the last line of the entry will be filled. Setting
% |\parfillskip| to a negative number prevents any overfull box messages.
%    \begin{macrocode}
     \parfillskip -\rightskip
%    \end{macrocode}
% Set the paragraph indent to the entry's indentation.
%    \begin{macrocode}
     \parindent \cftsubsecindent\relax\@afterindenttrue
%    \end{macrocode}
% Try and prevent breaks between lines in a multiple line entry.
%    \begin{macrocode}
     \interlinepenalty\@M
%    \end{macrocode}
% Make sure that we have left vertical mode.
%    \begin{macrocode}
     \leavevmode
%    \end{macrocode}
% Our version of |\numberline| expects that the width of the number box
% is in |\@tempdima|, and that the three macros |\@cftbsnum|,
% |\@cftasnum| and |\@cftasnumb|
% are defined. We set all these to the values for this entry.
%    \begin{macrocode}
     \@tempdima \cftsubsecnumwidth\relax
     \let\@cftbsnum \cftsubsecpresnum
     \let\@cftasnum \cftsubsecaftersnum
     \let\@cftasnumb \cftsubsecaftersnumb
%    \end{macrocode}
% Arrange that the (section number and) first line of the title is set
% at the current indent, and any further lines are further indented.
%    \begin{macrocode}
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
%    \end{macrocode}
% Print the (number and) title, prohibiting any breaking.
%    \begin{macrocode}
     {\cftsubsecfont #1}\nobreak
%    \end{macrocode}
% Print the leader and the page number, and close the group.
%    \begin{macrocode}
     \cftsubsecfillnum{#2}}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforesubsecskip}
% \begin{macro}{\cftsubsecindent}
% \begin{macro}{\cftsubsecnumwidth}
% \begin{macro}{\cftsubsecfont}
% \begin{macro}{\cftsubsecpresnum}
% \begin{macro}{\cftsubsecaftersnum}
% \begin{macro}{\cftsubsecaftersnumb}
% \begin{macro}{\cftsubsecleader}
% \begin{macro}{\cftsubsecdotsep}
% \begin{macro}{\cftsubsecpagefont}
% \begin{macro}{\cftsubsecafterpnum}
%  These are the user commands to control the typesetting of Sub-section entries.
%  They are initialised to give the standard appearance.
%    \begin{macrocode}
\newlength{\cftbeforesubsecskip}
  \setlength{\cftbeforesubsecskip}{\z@ \@plus.2\p@}
\newlength{\cftsubsecindent}
\newlength{\cftsubsecnumwidth}
\if@cfthaschapter
  \setlength{\cftsubsecindent}{3.8em}
  \setlength{\cftsubsecnumwidth}{3.2em}
\else
  \setlength{\cftsubsecindent}{1.5em}
  \setlength{\cftsubsecnumwidth}{2.3em}
\fi
\newcommand{\cftsubsecfont}{\normalfont}
\newcommand{\cftsubsecpresnum}{}
\newcommand{\cftsubsecaftersnum}{}
\newcommand{\cftsubsecaftersnumb}{}
\newcommand{\cftsubsecleader}{\normalfont\cftdotfill{\cftsubsecdotsep}}
\newcommand{\cftsubsecdotsep}{\cftdotsep}
\newcommand{\cftsubsecpagefont}{\normalfont}
\newcommand{\cftsubsecafterpnum}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftsubsecfillnum}
% |\cftsubsecfillnum{|\meta{page}|}| typesets the leader and the \meta{page}
% number of a |subsection| entry.
% First print the leader and then, with no break, set the page number
% flushright in  a box of width |\@pnumwidth|,
% not forgetting to finish the paragraph.
%    \begin{macrocode}
\newcommand{\cftsubsecfillnum}[1]{%
  {\cftsubsecleader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cftsubsecpagefont #1}\cftsubsecafterpnum\par
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@subsubsection}
%  |\l@subsubsection{|\meta{title}|}{|\meta{page}|}| typesets the ToC entry for
% a |subsubsection| heading. It is a parameterised copy of the default
% |\l@subsubsection|
% (see \file{classes.dtx} for the original definition).
%    \begin{macrocode}
\renewcommand*{\l@subsubsection}[2]{%
  \ifnum \c@tocdepth >\tw@
    \vskip \cftbeforesubsubsecskip
    {\leftskip \cftsubsubsecindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftsubsubsecindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftsubsubsecnumwidth\relax
     \let\@cftbsnum \cftsubsubsecpresnum
     \let\@cftasnum \cftsubsubsecaftersnum
     \let\@cftasnumb \cftsubsubsecaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftsubsubsecfont #1}\nobreak
     \cftsubsubsecfillnum{#2}}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforesubsubsecskip}
% \begin{macro}{\cftsubsubsecindent}
% \begin{macro}{\cftsubsubsecnumwidth}
% \begin{macro}{\cftsubsubsecfont}
% \begin{macro}{\cftsubsubsecpresnum}
% \begin{macro}{\cftsubsubsecaftersnum}
% \begin{macro}{\cftsubsubsecaftersnumb}
% \begin{macro}{\cftsubsubsecleader}
% \begin{macro}{\cftsubsubsecdotsep}
% \begin{macro}{\cftsubsubsecpagefont}
% \begin{macro}{\cftsubsubsecafterpnum}
% \begin{macro}{\cftsubsubsecfillnum}
%  These are the user commands to control the typesetting of Sub-sub-section entries.
%  They are initialised to give the standard appearance.
%    \begin{macrocode}
\newlength{\cftbeforesubsubsecskip}
  \setlength{\cftbeforesubsubsecskip}{\z@ \@plus.2\p@}
\newlength{\cftsubsubsecindent}
\newlength{\cftsubsubsecnumwidth}
\if@cfthaschapter
  \setlength{\cftsubsubsecindent}{7.0em}
  \setlength{\cftsubsubsecnumwidth}{4.1em}
\else
  \setlength{\cftsubsubsecindent}{3.8em}
  \setlength{\cftsubsubsecnumwidth}{3.2em}
\fi
\newcommand{\cftsubsubsecfont}{\normalfont}
\newcommand{\cftsubsubsecpresnum}{}
\newcommand{\cftsubsubsecaftersnum}{}
\newcommand{\cftsubsubsecaftersnumb}{}
\newcommand{\cftsubsubsecleader}{\normalfont\cftdotfill{\cftsubsubsecdotsep}}
\newcommand{\cftsubsubsecdotsep}{\cftdotsep}
\newcommand{\cftsubsubsecpagefont}{\normalfont}
\newcommand{\cftsubsubsecafterpnum}{}
\newcommand{\cftsubsubsecfillnum}[1]{%
  {\cftsubsubsecleader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cftsubsubsecpagefont #1}\cftsubsubsecafterpnum\par
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@paragraph}
%  |\l@paragraph{|\meta{title}|}{|\meta{page}|}| typesets the ToC entry for
% a |paragraph| heading. It is a parameterised copy of the default
% |\l@paragraph|
% (see \file{classes.dtx} for the original definition).
%    \begin{macrocode}
\renewcommand*{\l@paragraph}[2]{%
  \ifnum \c@tocdepth >3\relax
    \vskip \cftbeforeparaskip
    {\leftskip \cftparaindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftparaindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftparanumwidth\relax
     \let\@cftbsnum \cftparapresnum
     \let\@cftasnum \cftparaaftersnum
     \let\@cftasnumb \cftparaaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftparafont #1}\nobreak
     \cftparafillnum{#2}}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforeparaskip}
% \begin{macro}{\cftparaindent}
% \begin{macro}{\cftparanumwidth}
% \begin{macro}{\cftparafont}
% \begin{macro}{\cftparapresnum}
% \begin{macro}{\cftparaaftersnum}
% \begin{macro}{\cftparaaftersnumb}
% \begin{macro}{\cftparaleader}
% \begin{macro}{\cftparadotsep}
% \begin{macro}{\cftparapagefont}
% \begin{macro}{\cftparaafterpnum}
% \begin{macro}{\cftparafillnum}
%  These are the user commands to control the typesetting of Paragraph entries.
%  They are initialised to give the standard appearance.
%    \begin{macrocode}
\newlength{\cftbeforeparaskip}
  \setlength{\cftbeforeparaskip}{\z@ \@plus.2\p@}
\newlength{\cftparaindent}
\newlength{\cftparanumwidth}
\if@cfthaschapter
  \setlength{\cftparaindent}{10em}
  \setlength{\cftparanumwidth}{5em}
\else
  \setlength{\cftparaindent}{7.0em}
  \setlength{\cftparanumwidth}{4.1em}
\fi
\newcommand{\cftparafont}{\normalfont}
\newcommand{\cftparapresnum}{}
\newcommand{\cftparaaftersnum}{}
\newcommand{\cftparaaftersnumb}{}
\newcommand{\cftparaleader}{\normalfont\cftdotfill{\cftparadotsep}}
\newcommand{\cftparadotsep}{\cftdotsep}
\newcommand{\cftparapagefont}{\normalfont}
\newcommand{\cftparaafterpnum}{}
\newcommand{\cftparafillnum}[1]{%
  {\cftparaleader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cftparapagefont #1}\cftparaafterpnum\par
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@subparagraph}
%  |\l@subparagraph{|\meta{title}|}{|\meta{page}|}| typesets the ToC entry for
% a |subparagraph| heading. It is a parameterised copy of the default
% |\l@subparagraph|
% (see \file{classes.dtx} for the original definition).
%    \begin{macrocode}
\renewcommand*{\l@subparagraph}[2]{%
  \ifnum \c@tocdepth >4\relax
    \vskip \cftbeforesubparaskip
    {\leftskip \cftsubparaindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftsubparaindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftsubparanumwidth\relax
     \let\@cftbsnum \cftsubparapresnum
     \let\@cftasnum \cftsubparaaftersnum
     \let\@cftasnumb \cftsubparaaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftsubparafont #1}\nobreak
     \cftsubparafillnum{#2}}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforesubparaskip}
% \begin{macro}{\cftsubparaindent}
% \begin{macro}{\cftsubparanumwidth}
% \begin{macro}{\cftsubparafont}
% \begin{macro}{\cftsubparapresnum}
% \begin{macro}{\cftsubparaaftersnum}
% \begin{macro}{\cftsubparaaftersnumb}
% \begin{macro}{\cftsubparaleader}
% \begin{macro}{\cftsubparadotsep}
% \begin{macro}{\cftsubparapagefont}
% \begin{macro}{\cftsubparaafterpnum}
% \begin{macro}{\cftsubparafillnum}
%  These are the user commands to control the typesetting of Sub-paragraph entries.
%  They are initialised to give the standard appearance.
%    \begin{macrocode}
\newlength{\cftbeforesubparaskip}
  \setlength{\cftbeforesubparaskip}{\z@ \@plus.2\p@}
\newlength{\cftsubparaindent}
\newlength{\cftsubparanumwidth}
\if@cfthaschapter
  \setlength{\cftsubparaindent}{12em}
  \setlength{\cftsubparanumwidth}{6em}
\else
  \setlength{\cftsubparaindent}{10em}
  \setlength{\cftsubparanumwidth}{5em}
\fi
\newcommand{\cftsubparafont}{\normalfont}
\newcommand{\cftsubparapresnum}{}
\newcommand{\cftsubparaaftersnum}{}
\newcommand{\cftsubparaaftersnumb}{}
\newcommand{\cftsubparaleader}{\normalfont\cftdotfill{\cftsubparadotsep}}
\newcommand{\cftsubparadotsep}{\cftdotsep}
\newcommand{\cftsubparapagefont}{\normalfont}
\newcommand{\cftsubparaafterpnum}{}
\newcommand{\cftsubparafillnum}[1]{%
  {\cftsubparaleader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cftsubparapagefont #1}\cftsubparaafterpnum\par
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@cftdobiblof}
% If the \Lpack{tocbibind} package has been used and it has
% redefined |\listoffigures| we need to cater for that. The contents
% of the definition are defined in \Lpack{tocbibind}.
%    \begin{macrocode}
\newcommand{\@cftdobiblof}{%
  \if@dotoclof
    \if@bibchapter
      \phantomsection
      \addcontentsline{toc}{chapter}{\listfigurename}
    \else
      \phantomsection
      \addcontentsline{toc}{\@tocextra}{\listfigurename}
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\listoffigures}
% This is a parameterised version of the default |\listoffigures| command.
% The changes are postponed until after all packages have been loaded.
% Each class has its own definition, but we have to cater for all classes
% in one definition, hence some of the checks. First, perform the default
% checks for multicolumns. (Do nothing if \Lopt{titles} option is used).
%    \begin{macrocode}
\AtBeginDocument{%
\if@cftnctoc\else
\renewcommand{\listoffigures}{%
  \@cfttocstart
%    \end{macrocode}
% Ensure that any previous paragraph has been finished. Within a group set
% the local paragraphing style. Typeset the title and then do the contents
% of the \file{.lof} file.
%    \begin{macrocode}
  \par
  \begingroup
    \parindent\z@ \parskip\cftparskip
    \@cftmakeloftitle
    \if@cfttocbibind
      \@cftdobiblof
    \fi
    \@starttoc{lof}%
  \endgroup
%    \end{macrocode}
% Finally, restore any multicolumn typesetting.
%    \begin{macrocode}
  \@cfttocfinish}%
\fi
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftmakeloftitle}
% This command typesets the title for the LoF.
% \changes{v2.3}{2002/06/15}{Added \cs{@secpenalty} to \cs{cftmakeloftitle}}
% \changes{v2.3}{2002/06/15}{Added \cs{@cftpagestyle} to \cs{cftmakeloftitle}}
%    \begin{macrocode}
\newcommand{\@cftmakeloftitle}{%
  \addpenalty\@secpenalty
  \if@cfthaschapter
    \vspace*{\cftbeforeloftitleskip}
  \else
    \vspace{\cftbeforeloftitleskip}
  \fi
  \@cftpagestyle
  {\interlinepenalty\@M
  {\cftloftitlefont\listfigurename}{\cftafterloftitle}
  \cftmarklof
  \par\nobreak
  \vskip \cftafterloftitleskip
  \@afterheading}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforeloftitleskip}
% \begin{macro}{\cftafterloftitleskip}
%  These two lengths control the vertical spacing before and after the
%  LoF title.
%    \begin{macrocode}
\newlength{\cftbeforeloftitleskip}
\newlength{\cftafterloftitleskip}
%    \end{macrocode}
% Their values depend on whether the document has chapters or not. In
% chaptered documents the default LoF title is typeset as a |\chapter*|,
% otherwise as a |\section*|.
%    \begin{macrocode}
\if@cfthaschapter
  \setlength{\cftbeforeloftitleskip}{50pt}
  \setlength{\cftafterloftitleskip}{40pt}
\else
  \setlength{\cftbeforeloftitleskip}{3.5ex \@plus 1ex \@minus .2ex}
  \setlength{\cftafterloftitleskip}{2.3ex \@plus.2ex}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftloftitlefont}
% \begin{macro}{\cftafterloftitle}
% The LoF title is typeset in the style given by |\cftloftitlefont|.
% The macro |\cftafterloftitle| is called after typesetting the title.
% This is initialised to do nothing.
% Both these macros can be redefined to do other things (e.g., adding
% an |\hfill| to |\cftloftitlefont| will make the title flushright).
% \changes{v2.3}{2002/06/15}{koma has different settings for LoF titles}
%    \begin{macrocode}
\if@cfthaschapter
  \newcommand{\cftloftitlefont}{\normalfont\Huge\bfseries}
  \if@cftkoma\renewcommand{\cftloftitlefont}{\size@chapter\sectfont}\fi
\else
  \newcommand{\cftloftitlefont}{\normalfont\Large\bfseries}
  \if@cftkoma\renewcommand{\cftloftitlefont}{\size@section\sectfont}\fi
\fi
\newcommand{\cftafterloftitle}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@figure}
%  |\l@figure{|\meta{title}|}{|\meta{page}|}| typesets the LoF entry for
% a |figure| caption heading. It is a parameterised copy of the default
% |\l@figure|
% (see \file{classes.dtx} for the original definition).
%    \begin{macrocode}
\renewcommand*{\l@figure}[2]{%
  \ifnum \c@lofdepth >\z@
    \vskip \cftbeforefigskip
    {\leftskip \cftfigindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftfigindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftfignumwidth\relax
     \let\@cftbsnum \cftfigpresnum
     \let\@cftasnum \cftfigaftersnum
     \let\@cftasnumb \cftfigaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftfigfont #1}\nobreak
     \cftfigfillnum{#2}}%
   \fi
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforefigskip}
% \begin{macro}{\cftfigindent}
% \begin{macro}{\cftfignumwidth}
% \begin{macro}{\cftfigfont}
% \begin{macro}{\cftfigpresnum}
% \begin{macro}{\cftfigaftersnum}
% \begin{macro}{\cftfigaftersnumb}
% \begin{macro}{\cftfigleader}
% \begin{macro}{\cftfigdotsep}
% \begin{macro}{\cftfigpagefont}
% \begin{macro}{\cftfigafterpnum}
% \begin{macro}{\cftfigfillnum}
%  These are the user commands to control the typesetting of Figure caption entries.
%  They are initialised to give the standard appearance.
%    \begin{macrocode}
\newlength{\cftbeforefigskip}
  \setlength{\cftbeforefigskip}{\z@ \@plus.2\p@}
\newlength{\cftfigindent}
  \setlength{\cftfigindent}{1.5em}
\newlength{\cftfignumwidth}
  \setlength{\cftfignumwidth}{2.3em}
\newcommand{\cftfigfont}{\normalfont}
\newcommand{\cftfigpresnum}{}
\newcommand{\cftfigaftersnum}{}
\newcommand{\cftfigaftersnumb}{}
\newcommand{\cftfigleader}{\normalfont\cftdotfill{\cftfigdotsep}}
\newcommand{\cftfigdotsep}{\cftdotsep}
\newcommand{\cftfigpagefont}{\normalfont}
\newcommand{\cftfigafterpnum}{}
\newcommand{\cftfigfillnum}[1]{%
  {\cftfigleader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cftfigpagefont #1}\cftfigafterpnum\par
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{lofdepth}
% \begin{macro}{lotdepth}
% The counters |lofdepth| and |lotdepth| are defined by the
% \Lpack{subfigure} package.
% Define them here if that package is not used.
%    \begin{macrocode}
\if@cftsubfigopt\else
  \newcounter{lofdepth}\setcounter{lofdepth}{1}
  \newcounter{lotdepth}\setcounter{lotdepth}{1}
\fi

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@cftdobiblot}
% If the \Lpack{tocbibind} package has been used and it has
% redefined |\listoftables| we need to cater for that. The contents
% of the definition are defined in \Lpack{tocbibind}.
%    \begin{macrocode}
\newcommand{\@cftdobiblot}{%
  \if@dotoclot
    \if@bibchapter
      \phantomsection
      \addcontentsline{toc}{chapter}{\listtablename}
    \else
      \phantomsection
      \addcontentsline{toc}{\@tocextra}{\listtablename}
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\listoftables}
% This is a parameterised version of the default |\listoftables| command.
% The changes are postponed until after all packages have been loaded.
% Each class has its own definition, but we have to cater for all classes
% in one definition, hence some of the checks. First, perform the default
% checks for multicolumns. (Do nothing if the \Lopt{titles} option has
%  been used).
%    \begin{macrocode}
\AtBeginDocument{%
\if@cftnctoc\else
\renewcommand{\listoftables}{%
  \@cfttocstart
%    \end{macrocode}
% Ensure that any previous paragraph has been finished. Within a group set
% the local paragraphing style. Typeset the title and then do the contents
% of the \file{.lot} file.
%    \begin{macrocode}
  \par
  \begingroup
    \parindent\z@ \parskip\cftparskip
    \@cftmakelottitle
    \if@cfttocbibind
      \@cftdobiblot
    \fi
    \@starttoc{lot}%
  \endgroup
%    \end{macrocode}
% Finally, restore any multicolumn typesetting.
%    \begin{macrocode}
  \@cfttocfinish}%
\fi
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftmakelottitle}
% This command typesets the title for the LoT.
% \changes{v2.3}{2002/06/15}{Added \cs{@secpenalty} to \cs{@cftmakelottitle}}
% \changes{v2.3}{2002/06/15}{Added \cs{@cftpagestyle} to \cs{@cftmakelottitle}}
%    \begin{macrocode}
\newcommand{\@cftmakelottitle}{%
  \addpenalty\@secpenalty
  \if@cfthaschapter
    \vspace*{\cftbeforelottitleskip}
  \else
    \vspace{\cftbeforelottitleskip}
  \fi
  \@cftpagestyle
  {\interlinepenalty\@M
  {\cftlottitlefont\listtablename}{\cftafterlottitle}
  \cftmarklot
  \par\nobreak
  \vskip \cftafterlottitleskip
  \@afterheading}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforelottitleskip}
% \begin{macro}{\cftafterlottitleskip}
%  These two lengths control the vertical spacing before and after the
%  LoT title.
%    \begin{macrocode}
\newlength{\cftbeforelottitleskip}
\newlength{\cftafterlottitleskip}
%    \end{macrocode}
% Their values depend on whether the document has chapters or not. In
% chaptered documents the default LoT title is typeset as a |\chapter*|,
% otherwise as a |\section*|.
%    \begin{macrocode}
\if@cfthaschapter
  \setlength{\cftbeforelottitleskip}{50pt}
  \setlength{\cftafterlottitleskip}{40pt}
\else
  \setlength{\cftbeforelottitleskip}{3.5ex \@plus 1ex \@minus .2ex}
  \setlength{\cftafterlottitleskip}{2.3ex \@plus.2ex}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftlottitlefont}
% \begin{macro}{\cftafterlottitle}
% The LoT title is typeset in the style given by |\cftlottitlefont|.
% The macro |\cftafterlottitle| is called after typesetting the title.
% This is initialised to do nothing.
% Both these macros can be redefined to do other things (e.g., adding
% an |\hfill| to |\cftlottitlefont| will make the title flushright).
% \changes{v2.3}{2002/06/15}{koma has different settings for LoT titles}
%    \begin{macrocode}
\if@cfthaschapter
  \newcommand{\cftlottitlefont}{\normalfont\Huge\bfseries}
  \if@cftkoma\renewcommand{\cftlottitlefont}{\size@chapter\sectfont}\fi
\else
  \newcommand{\cftlottitlefont}{\normalfont\Large\bfseries}
  \if@cftkoma\renewcommand{\cftlottitlefont}{\size@section\sectfont}\fi
\fi
\newcommand{\cftafterlottitle}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@table}
%  |\l@table{|\meta{title}|}{|\meta{page}|}| typesets the LoT entry for
% a |table| caption heading. It is a parameterised copy of the default
% |\l@table|
% (see \file{classes.dtx} for the original definition).
%    \begin{macrocode}
\renewcommand*{\l@table}[2]{%
  \ifnum\c@lotdepth >\z@
    \vskip \cftbeforetabskip
    {\leftskip \cfttabindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cfttabindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cfttabnumwidth\relax
     \let\@cftbsnum \cfttabpresnum
     \let\@cftasnum \cfttabaftersnum
     \let\@cftasnumb \cfttabaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cfttabfont #1}\nobreak
     \cfttabfillnum{#2}}%
   \fi
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforetabskip}
% \begin{macro}{\cfttabindent}
% \begin{macro}{\cfttabnumwidth}
% \begin{macro}{\cfttabfont}
% \begin{macro}{\cfttabpresnum}
% \begin{macro}{\cfttabaftersnum}
% \begin{macro}{\cfttabaftersnumb}
% \begin{macro}{\cfttableader}
% \begin{macro}{\cfttabdotsep}
% \begin{macro}{\cfttabpagefont}
% \begin{macro}{\cfttabafterpnum}
% \begin{macro}{\cfttabfillnum}
%  These are the user commands to control the typesetting of Table caption entries.
%  They are initialised to give the standard appearance.
%    \begin{macrocode}
\newlength{\cftbeforetabskip}
  \setlength{\cftbeforetabskip}{\z@ \@plus.2\p@}
\newlength{\cfttabindent}
  \setlength{\cfttabindent}{1.5em}
\newlength{\cfttabnumwidth}
  \setlength{\cfttabnumwidth}{2.3em}
\newcommand{\cfttabfont}{\normalfont}
\newcommand{\cfttabpresnum}{}
\newcommand{\cfttabaftersnum}{}
\newcommand{\cfttabaftersnumb}{}
\newcommand{\cfttableader}{\normalfont\cftdotfill{\cfttabdotsep}}
\newcommand{\cfttabdotsep}{\cftdotsep}
\newcommand{\cfttabpagefont}{\normalfont}
\newcommand{\cfttabafterpnum}{}
\newcommand{\cfttabfillnum}[1]{%
  {\cfttableader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cfttabpagefont #1}\cfttabafterpnum\par
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Support for the \Lpack{subfigure} package}
% \changes{v1.1}{2000/02/12}{Added subfigure support}
%
%  The code for supporting the \Lpack{subfigure} package is, in all
% essentials, the same as that for the figure and table captions; only the
% names are changed. However, the code need only be executed if the
% \Lpack{subfigure} package is actually loaded.
%
% \begin{macro}{\@cftl@subfig}
%    This command redefines the |\l@subfigure| command.
%    \begin{macrocode}
\newcommand{\@cftl@subfig}{%
%    \end{macrocode}
% \begin{macro}{\l@subfigure}
%  |\l@subfigure{|\meta{title}|}{|\meta{page}|}| typesets the LoF entry for
% a |subfigure| caption heading. It is essentially the same as the
% parameterised code for |\l@figure| except that account has to be taken
% of |lofdepth|.
%    \begin{macrocode}
\renewcommand*{\l@subfigure}[2]{%
  \ifnum \c@lofdepth > \toclevel@subfigure
    \vskip \cftbeforesubfigskip
    {\leftskip \cftsubfigindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftsubfigindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftsubfignumwidth\relax
     \let\@cftbsnum \cftsubfigpresnum
     \let\@cftasnum \cftsubfigaftersnum
     \let\@cftasnumb \cftsubfigaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftsubfigfont ##1}\nobreak
     \cftsubfigfillnum{##2}}%
  \fi
  }%
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@cftsetsubfig}
% This command initialises the setup for subfigure captions in the LoF.
%    \begin{macrocode}
\newcommand{\@cftsetsubfig}{%
%    \end{macrocode}
% \begin{macro}{\cftbeforesubfigskip}
% \begin{macro}{\cftsubfigindent}
% \begin{macro}{\cftsubfignumwidth}
% \begin{macro}{\cftsubfigfont}
% \begin{macro}{\cftsubfigpresnum}
% \begin{macro}{\cftsubfigaftersnum}
% \begin{macro}{\cftsubfigaftersnumb}
% \begin{macro}{\cftsubfigleader}
% \begin{macro}{\cftsubfigdotsep}
% \begin{macro}{\cftsubfigpagefont}
% \begin{macro}{\cftsubfigafterpnum}
% \begin{macro}{\toclevel@subfig}
% \begin{macro}{\cftsubfigfillnum}
%    \begin{macrocode}
\newlength{\cftbeforesubfigskip}
  \setlength{\cftbeforesubfigskip}{\z@ \@plus.2\p@}
\newlength{\cftsubfigindent}
  \setlength{\cftsubfigindent}{3.8em}
\newlength{\cftsubfignumwidth}
  \setlength{\cftsubfignumwidth}{2.5em}
\newcommand{\cftsubfigfont}{\normalfont}
\newcommand{\cftsubfigpresnum}{}
\newcommand{\cftsubfigaftersnum}{}
\newcommand{\cftsubfigaftersnumb}{}
\newcommand{\cftsubfigleader}{\normalfont\cftdotfill{\cftsubtabdotsep}}
\newcommand{\cftsubfigdotsep}{\cftdotsep}
\newcommand{\cftsubfigpagefont}{\normalfont}
\newcommand{\cftsubfigafterpnum}{}
\providecommand{\toclevel@subfigure}{1}
\newcommand{\cftsubfigfillnum}[1]{%
  {\cftsubfigleader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cftsubfigpagefont ##1}\cftsubfigafterpnum\par
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% This is the end of |\@cftsetsubfig|.
%    \begin{macrocode}
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftl@subtab}
%    This code redefines the code for |\l@subtable|.
%    \begin{macrocode}
\newcommand{\@cftl@subtab}{%
%    \end{macrocode}
% \begin{macro}{\l@subtable}
%  |\l@subtable{|\meta{title}|}{|\meta{page}|}| typesets the LoT entry for
% a |subtable| caption heading. It is essentially the same as the
% parameterised code for |\l@table| except account has to be taken of
% |lotdepth|.
%    \begin{macrocode}
\renewcommand*{\l@subtable}[2]{%
  \ifnum \c@lotdepth > \toclevel@subtable
    \vskip \cftbeforesubtabskip
    {\leftskip \cftsubtabindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftsubtabindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftsubtabnumwidth\relax
     \let\@cftbsnum \cftsubtabpresnum
     \let\@cftasnum \cftsubtabaftersnum
     \let\@cftasnumb \cftsubtabaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftsubtabfont ##1}\nobreak
     \cftsubtabfillnum{##2}}%
  \fi
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@cftsetsubtab}
% This command sets up the defaults for subtable entries in the LoT.
%    \begin{macrocode}
\newcommand{\@cftsetsubtab}{%
%    \end{macrocode}
% \begin{macro}{\cftbeforesubtabskip}
% \begin{macro}{\cftsubtabindent}
% \begin{macro}{\cftsubtabnumwidth}
% \begin{macro}{\cftsubtabfont}
% \begin{macro}{\cftsubtabpresnum}
% \begin{macro}{\cftsubtabaftersnum}
% \begin{macro}{\cftsubtabaftersnumb}
% \begin{macro}{\cftsubtableader}
% \begin{macro}{\cftsubtabdotsep}
% \begin{macro}{\cftsubtabpagefont}
% \begin{macro}{\cftsubtabafterpnum}
% \begin{macro}{\toclevel@subtable}
% \begin{macro}{\cftsubtabfillnum}
%  These are the user commands to control the typesetting of Subtable
% caption entries.
%  They are initialised to give the standard appearance.
%    \begin{macrocode}
\newlength{\cftbeforesubtabskip}
  \setlength{\cftbeforesubtabskip}{\z@ \@plus.2\p@}
\newlength{\cftsubtabindent}
  \setlength{\cftsubtabindent}{3.8em}
\newlength{\cftsubtabnumwidth}
  \setlength{\cftsubtabnumwidth}{2.5em}
\newcommand{\cftsubtabfont}{\normalfont}
\newcommand{\cftsubtabpresnum}{}
\newcommand{\cftsubtabaftersnum}{}
\newcommand{\cftsubtabaftersnumb}{}
\newcommand{\cftsubtableader}{\normalfont\cftdotfill{\cftsubtabdotsep}}
\newcommand{\cftsubtabdotsep}{\cftdotsep}
\newcommand{\cftsubtabpagefont}{\normalfont}
\newcommand{\cftsubtabafterpnum}{}
\providecommand{\toclevel@subtable}{1}
\newcommand{\cftsubtabfillnum}[1]{%
  {\cftsubtableader}\nobreak
  \makebox[\@pnumwidth][\cftpnumalign]{\cftsubtabpagefont ##1}\cftsubtabafterpnum\par
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% This is the end of |\@cftsetsubtab|.
%    \begin{macrocode}
}

%    \end{macrocode}
% \end{macro}
%
%    Call the \Lpack{subfigure} package setup code only if the
% \Lopt{subfigure} option is specified. The |\l@...| redefinitions have to
% come after the \Lpack{subfigure} package is loaded.
%    \begin{macrocode}

\if@cftsubfigopt
  \@cftsetsubfig\@cftsetsubtab
  \AtBeginDocument{\@cftl@subfig\@cftl@subtab}
\fi
%%  \AtBeginDocument{\if@cftsubfigopt
%%    \@cftsetsubfig\@cftsetsubtab
%%    \@cftl@subfig\@cftl@subtab
%%  \fi}

%    \end{macrocode}
%
%
% \subsection{New list of\ldots}
% \changes{v2.0}{2001/03/03}{Added \cs{newlistof} and \cs{newlistentry}}
%
% \begin{macro}{\newlistentry}
% |\newlistentry[|\meta{within}|]{|\meta{counter}|}{|\meta{ext}|}{|\meta{level-1}|}| creates a set of commands for a new kind of entry into a List of.
%    \begin{macrocode}
\newcommand{\newlistentry}[4][\@empty]{%
%    \end{macrocode}
% \begin{macro}{\c@X}
% \begin{macro}{\theX}
% Check if \meta{within} and \meta{counter} have been defined. It is
% an error if \meta{within} has not been defined, and an error if
% \meta{counter} has been defined. Set the default counter values.
%    \begin{macrocode}
  \@ifundefined{c@#2}{%    check & set the counter
    \ifx \@empty#1\relax
      \newcounter{#2}
    \else
      \@ifundefined{c@#1}{\PackageWarning{tocloft}%
                          {#1 has no counter for use as a `within'}
        \newcounter{#2}}%
      {\newcounter{#2}[#1]%
       \expandafter\edef\csname the#2\endcsname{%
         \expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}}}
    \fi
    \setcounter{#2}{0}
  }
  {\PackageError{tocloft}{#2 has been previously defined}{\@eha}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% That finishes off the error checking. No matter what the result, the
% rest of the new commands are defined.
%
% \begin{macro}{\l@X}
% |\l@X{|\meta{title}|}{|\meta{page}|}| typesets the entry.
%    \begin{macrocode}
  \@namedef{l@#2}##1##2{%
%    \end{macrocode}
% Only typeset if the |\Zdepth| is greater than \meta{level-1}.
%    \begin{macrocode}
    \ifnum \@nameuse{c@#3depth} > #4\relax
      \vskip \@nameuse{cftbefore#2skip}
      {\leftskip \@nameuse{cft#2indent}\relax
       \rightskip \@tocrmarg
       \parfillskip -\rightskip
       \parindent \@nameuse{cft#2indent}\relax\@afterindenttrue
       \interlinepenalty\@M
       \leavevmode
       \@tempdima \@nameuse{cft#2numwidth}\relax
       \expandafter\let\expandafter\@cftbsnum\csname cft#2presnum\endcsname
       \expandafter\let\expandafter\@cftasnum\csname cft#2aftersnum\endcsname
       \expandafter\let\expandafter\@cftasnumb\csname cft#2aftersnumb\endcsname
       \advance\leftskip\@tempdima \null\nobreak\hskip -\leftskip
       {\@nameuse{cft#2font}##1}\nobreak
       \@nameuse{cft#2fillnum}{##2}}%
    \fi
  }  % end of \l@#2

%    \end{macrocode}
% \end{macro}
%
% Now define all the layout commands used by |\l@X|. The default
% values of these correspond to those for section entries in
% non-chaptered documents.
% \begin{macro}{\cftbeforeXskip}
%    \begin{macrocode}
  \expandafter\newlength\csname cftbefore#2skip\endcsname
    \setlength{\@nameuse{cftbefore#2skip}}{\z@ \@plus .2\p@}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\cftXindent}
% \begin{macro}{\cftXnumwidth}
%    \begin{macrocode}
  \expandafter\newlength\csname cft#2indent\endcsname
  \expandafter\newlength\csname cft#2numwidth\endcsname
%    \end{macrocode}
% Set the default values for the indent and numwidth depending on
% the entry's level. A level of 1 corresponds to a figure entry.
%    \begin{macrocode}
  \ifcase #4\relax  % 0
    \setlength{\@nameuse{cft#2indent}}{0em}
    \setlength{\@nameuse{cft#2numwidth}}{1.5em}
  \or               % 1
    \setlength{\@nameuse{cft#2indent}}{1.5em}
    \setlength{\@nameuse{cft#2numwidth}}{2.3em}
  \or               % 2
    \setlength{\@nameuse{cft#2indent}}{3.8em}
    \setlength{\@nameuse{cft#2numwidth}}{3.2em}
  \or               % 3
    \setlength{\@nameuse{cft#2indent}}{7.0em}
    \setlength{\@nameuse{cft#2numwidth}}{4.1em}
  \else             % anything else
    \setlength{\@nameuse{cft#2indent}}{10.0em}
    \setlength{\@nameuse{cft#2numwidth}}{5.0em}
  \fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\cftXfont}
% \begin{macro}{\cftXpresnum}
% \begin{macro}{\cftXaftersnum}
% \begin{macro}{\cftXaftersnumb}
% \begin{macro}{\cftXdotsep}
% \begin{macro}{\cftXleader}
% \begin{macro}{\cftXpagefont}
% \begin{macro}{\cftXafterpnum}
% And the remaining commands.
%    \begin{macrocode}
  \@namedef{cft#2font}{\normalfont}
  \@namedef{cft#2presnum}{}
  \@namedef{cft#2aftersnum}{}
  \@namedef{cft#2aftersnumb}{}
  \@namedef{cft#2dotsep}{\cftdotsep}
  \@namedef{cft#2leader}{\normalfont\cftdotfill{\@nameuse{cft#2dotsep}}}
  \@namedef{cft#2pagefont}{\normalfont}
  \@namedef{cft#2afterpnum}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\toclevel@X}
% The hyperref package needs a command |\toclevel@X|, holding
% the \meta{level-1} value.
%    \begin{macrocode}
  \@namedef{toclevel@#2}{#4}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftXfillnum}
% Typeset the leader and page number.
%    \begin{macrocode}
  \@namedef{cft#2fillnum}##1{%
    {\@nameuse{cft#2leader}}\nobreak
    \makebox[\@pnumwidth][\cftpnumalign]{\@nameuse{cft#2pagefont}##1}\@nameuse{cft#2afterpnum}\par
  }
%    \end{macrocode}
% \end{macro}
% This ends the definition of |\newlistentry|.
%    \begin{macrocode}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newlistof}
% |\newlistof[|\meta{within}|]{|\meta{entry}|}{|\meta{ext}|}{|\meta{listofname}|}|
% creates the commands for a new List of.
%    \begin{macrocode}
\newcommand{\newlistof}[4][\@empty]{%
%    \end{macrocode}
% Call |\newlistentry| to set up the first level entry.
%    \begin{macrocode}
  \ifx \@empty#1\relax
    \newlistentry{#2}{#3}{0}
  \else
    \newlistentry[#1]{#2}{#3}{0}
  \fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ext@Z}
% \begin{macro}{\Zdepth}
% The file extension and listing depth.
%    \begin{macrocode}
  \@namedef{ext@#2}{#3}
  \newcounter{#3depth}
  \setcounter{#3depth}{1}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftmarkZ}
% The heading marks for the listing.
% \changes{v2.3}{2002/06/15}{different koma settings in \cs{newlistof}}
%    \begin{macrocode}
  \if@cftkoma
    \@namedef{cftmark#3}{%
      \@mkboth{#4}{#4}}
  \else
    \@namedef{cftmark#3}{%
      \@mkboth{\MakeUppercase{#4}}{\MakeUppercase{#4}}}
  \fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listofX}
% Typeset the listing title and entries.
%    \begin{macrocode}
 \if@cftnctoc
%    \end{macrocode}
% For the \Lopt{titles} option, basically copy the code from
% the standard |\tableofcontents| command.
%    \begin{macrocode}
  \@namedef{listof#2}{%
    \@cfttocstart
    \if@cfthaschapter
      \chapter*{#4}
    \else
      \section*{#4}
    \fi
    \@nameuse{cftmark#3}
    \@starttoc{#3}%
    \@cfttocfinish}
 \else
%    \end{macrocode}
% Otherwise use the fully parameterised definition.
%    \begin{macrocode}
  \@namedef{listof#2}{%
    \@cfttocstart
    \par
    \begingroup
      \parindent\z@ \parskip\cftparskip
      \@nameuse{@cftmake#3title}
      \@starttoc{#3}%
    \endgroup
    \@cfttocfinish}
 \fi

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftmakeZtitle}
% Typeset the title.
% \changes{v2.3}{2002/06/15}{Added \cs{@secpenalty} to \cs{@cftmakeZtitle}}
% \changes{v2.3}{2002/06/15}{Added \cs{@cftpagestyle} to \cs{@cftmakeZtitle}}
%    \begin{macrocode}
  \@namedef{@cftmake#3title}{%
    \addpenalty\@secpenalty
    \if@cfthaschapter
      \vspace*{\@nameuse{cftbefore#3titleskip}}%
    \else
      \vspace{\@nameuse{cftbefore#3titleskip}}%
    \fi
    \@cftpagestyle
    {\interlinepenalty\@M
    {\@nameuse{cft#3titlefont}#4}{\@nameuse{cftafter#3title}}%
    \@nameuse{cftmark#3}%
    \par\nobreak
    \vskip \@nameuse{cftafter#3titleskip}%
    \@afterheading}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftbeforeZtitleskip}
% \begin{macro}{\cftafterZtitleskip}
% \begin{macro}{\cftZtitlefont}
% The skips before and after the title heading, and the title font.
% The default values depend on whether or not the document class
% has chapters.
%    \begin{macrocode}
   \expandafter\newlength\csname cftbefore#3titleskip\endcsname
   \expandafter\newlength\csname cftafter#3titleskip\endcsname
   \if@cfthaschapter
      \setlength{\@nameuse{cftbefore#3titleskip}}{50pt}
      \setlength{\@nameuse{cftafter#3titleskip}}{40pt}
      \if@cftkoma
        \@namedef{cft#3titlefont}{\size@chapter\sectfont}
      \else
        \@namedef{cft#3titlefont}{\normalfont\Huge\bfseries}
      \fi
    \else
      \setlength{\@nameuse{cftbefore#3titleskip}}{3.5ex \@plus 1ex \@minus .2ex}
      \setlength{\@nameuse{cftafter#3titleskip}}{2.3ex \@plus .2ex}
      \if@cftkoma
        \@namedef{cft#3titlefont}{\size@section\sectfont}
      \else
        \@namedef{cft#3titlefont}{\normalfont\Huge\bfseries}
      \fi
    \fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftafterZtitle}
% Something to go after the title.
%    \begin{macrocode}
    \@namedef{cftafter#3title}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftZprehook}
% \begin{macro}{\cftZposthook}
% Hooks before and after the list of entries.
%    \begin{macrocode}
    \@namedef{cft#3prehook}{}
    \@namedef{cft#3posthook}{}
%    \end{macrocode}
% \end{macro}
%
% This is the end of the definition of |\newlistof|.
%    \begin{macrocode}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftsetindents}
% \changes{v2.0}{2001/03/15}{Added \cs{cftsetindents}}
% |\cftsetindents{|\meta{entry}|}{|\meta{indent}|}{|\meta{numwidth}|}| sets
% the \textit{indent} and \textit{numwidth} for entry \meta{entry}. The macro
% has to map between the external entry name and the internal shorthand.
%    \begin{macrocode}
\newcommand{\cftsetindents}[3]{%
  \def\@cftemp{#1}
  \ifx\@cftemp\cftchapname
    \@cftsetindents{chap}{#2}{#3}
  \else
    \ifx\@cftemp\cftsecname \@cftsetindents{sec}{#2}{#3}
    \else
      \ifx\@cftemp\cftsubsecname \@cftsetindents{subsec}{#2}{#3}
      \else
        \ifx\@cftemp\cftsubsubsecname \@cftsetindents{subsubsec}{#2}{#3}
        \else
          \ifx\@cftemp\cftparaname \@cftsetindents{para}{#2}{#3}
          \else
            \ifx\@cftemp\cftsubparaname \@cftsetindents{subpara}{#2}{#3}
            \else
              \ifx\@cftemp\cftfigname \@cftsetindents{fig}{#2}{#3}
              \else
                \ifx\@cftemp\cftsubfigname \@cftsetindents{subfig}{#2}{#3}
                \else
                  \ifx\@cftemp\cfttabname \@cftsetindents{tab}{#2}{#3}
                  \else
                    \ifx\@cftemp\cftsubtabname \@cftsetindents{subtab}{#2}{#3}
                    \else
                      \@cftsetindents{#1}{#2}{#3}
                    \fi
                  \fi
                \fi
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@cftsetindents}
% |\@cftsetindents{|\meta{X}|}{|\meta{indent}|}{|\meta{numwidth}|}| is
% the internal version of |\cftsetindents|, where in this case \meta{X}
% is the internal (shorthand) name of the entry.
%    \begin{macrocode}
\newcommand{\@cftsetindents}[3]{%
  \setlength{\@nameuse{cft#1indent}}{#2}
  \setlength{\@nameuse{cft#1numwidth}}{#3}
}

%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Switching page numbering}
% \changes{v2.0}{2001/03/03}{Added page number switching off/on}
%
% \begin{macro}{\@cftpnumoff}
% |\@cftpnumoff{|\meta{shorthand}|}| is the workhorse
% for switching page numbering off. The \meta{shorthand} argument is the
% shorthand name of the entry (e.g. |subsec| for |subsection|).
% The macro redefines the |\cftXnumfill| command so that there is no leader
% and the page number is ignored.
%    \begin{macrocode}
\newcommand{\@cftpnumoff}[1]{%
  \@namedef{cft#1fillnum}##1{%
    \cftparfillskip\@nameuse{cft#1afterpnum}\par}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftchapname}
% \begin{macro}{\cftsecname}
% \begin{macro}{\cftsubsecname}
% \begin{macro}{\cftsubsubsecname}
% \begin{macro}{\cftparaname}
% \begin{macro}{\cftsubparaname}
% \begin{macro}{\cftfigname}
% \begin{macro}{\cftsubfigname}
% \begin{macro}{\cfttabname}
% \begin{macro}{\cftsubtabname}
%  Unfortunately an early design decision was the use shorthands like |sec|
% for |section|. For the page switching I need to be able to correlate the
% shorthands and longhands.
%    \begin{macrocode}
\newcommand*{\cftchapname}{chapter}
\newcommand*{\cftsecname}{section}
\newcommand*{\cftsubsecname}{subsection}
\newcommand*{\cftsubsubsecname}{subsubsection}
\newcommand*{\cftparaname}{paragraph}
\newcommand*{\cftsubparaname}{subparagraph}
\newcommand*{\cftfigname}{figure}
\newcommand*{\cftsubfigname}{subfigure}
\newcommand*{\cfttabname}{table}
\newcommand*{\cftsubtabname}{subtable}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cftpagenumbersoff}
% The user level command for switching off page numbers is
% |\cftpagenumbersoff{|\meta{entry}|}| where \meta{entry} is the longhand
% name of the entry. The principal task opf this macro is to determine
% the corresponding shorthand name of the \meta{entry} and then call
% |\@cftpnumoff| to do the work. For |part| and user-defined entries
% the long- and short-hand entry names are identical.
%    \begin{macrocode}
\DeclareRobustCommand{\cftpagenumbersoff}[1]{%
  \def\@cftemp{#1}
  \ifx\@cftemp\cftchapname
    \@cftpnumoff{chap}
  \else
    \ifx\@cftemp\cftsecname \@cftpnumoff{sec}
    \else
      \ifx\@cftemp\cftsubsecname \@cftpnumoff{subsec}
      \else
        \ifx\@cftemp\cftsubsubsecname \@cftpnumoff{subsubsec}
        \else
          \ifx\@cftemp\cftparaname \@cftpnumoff{para}
          \else
            \ifx\@cftemp\cftsubparaname \@cftpnumoff{subpara}
            \else
              \ifx\@cftemp\cftfigname \@cftpnumoff{fig}
              \else
                \ifx\@cftemp\cftsubfigname \@cftpnumoff{subfig}
                \else
                  \ifx\@cftemp\cfttabname \@cftpnumoff{tab}
                  \else
                    \ifx\@cftemp\cftsubtabname \@cftpnumoff{subtab}
                    \else
                      \@cftpnumoff{#1}
                    \fi
                  \fi
                \fi
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftpagenumberson}
% |\cftpagenumberson{|\meta{entry}|}| is the user level command for
% reversing the corresponding |\cftpagenumbersoff|.
%    \begin{macrocode}
\DeclareRobustCommand{\cftpagenumberson}[1]{%
  \def\@cftemp{#1}
  \ifx\@cftemp\cftchapname
    \@cftpnumon{chap}
  \else
    \ifx\@cftemp\cftsecname \@cftpnumon{sec}
    \else
      \ifx\@cftemp\cftsubsecname \@cftpnumon{subsec}
      \else
        \ifx\@cftemp\cftsubsubsecname \@cftpnumon{subsubsec}
        \else
          \ifx\@cftemp\cftparaname \@cftpnumon{para}
          \else
            \ifx\@cftemp\cftsubparaname \@cftpnumon{subpara}
            \else
              \ifx\@cftemp\cftfigname \@cftpnumon{fig}
              \else
                \ifx\@cftemp\cftsubfigname \@cftpnumon{subfig}
                \else
                  \ifx\@cftemp\cfttabname \@cftpnumon{tab}
                  \else
                    \ifx\@cftemp\cftsubtabname \@cftpnumon{subtab}
                    \else
                      \@cftpnumon{#1}
                    \fi
                  \fi
                \fi
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@cftpnumon}
% |\@cftpnumon{|\meta{shorthand}|}| is the workhorse
% for switching page numbering off. The \meta{shorthand} argument is the
% shorthand name of the entry (e.g. |subsec| for |subsection|).
% The macro defines the |\cftXnumfill| command to correspond to
% the default definition.
%    \begin{macrocode}
\newcommand{\@cftpnumon}[1]{%
  \@namedef{cft#1fillnum}##1{%
    {\@nameuse{cft#1leader}}\nobreak
    \makebox[\@pnumwidth][\cftpnumalign]{\@nameuse{cft#1pagefont}##1}\@nameuse{cft#1afterpnum}\par
  }%
}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
%
% \subsection{Experimental utilities}
%
%    The code in this section is experimental but in the sense that the
% capabilities might be modified in the future rather than that the code
% does not work.
%
% \begin{macro}{\cftchapterprecis}
% This is experimental. |\cftchapterprecis{|\meta{text}|}| typesets
% \meta{text} at the point where it is called, and also adds \meta{text}
% to the \file{.toc} file. It is expects to be called immediately after
% a |\chapter| command.
%    \begin{macrocode}
\newcommand{\cftchapterprecis}[1]{%
  \cftchapterprecishere{#1}
  \cftchapterprecistoc{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftchapterprecishere}
% |\cftchapterprecishere{|\meta{text}|}| typesets \meta{text}. It expects
% to be called immediately after a |\chapter| command. First add some
% negative vertical space to move it closer to the chapter heading.
%    \begin{macrocode}
\newcommand{\cftchapterprecishere}[1]{%
  \vspace*{-2\baselineskip}
%    \end{macrocode}
% Typeset its argument using italic font in a |quote| environment.
%    \begin{macrocode}
  \begin{quote}\textit{#1}\end{quote}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftchapterprecistoc}
% |\cftchapterprecistoc{|\meta{text}|}| adds \meta{text} to the \file{.toc}
% file. The \meta{text} will be typeset within the same margins as the
% the title text of a |\chapter| heading, using an italic font.
%    \begin{macrocode}
\newcommand{\cftchapterprecistoc}[1]{\addtocontents{toc}{%
%    \end{macrocode}
% Start a group to localize changes to the paragraphing. Set the
% left margin to the chapter indent plus the chapter number width.
%    \begin{macrocode}
  {\leftskip \cftchapindent\relax
   \advance\leftskip \cftchapnumwidth\relax
%    \end{macrocode}
% Set the right hand margin to |\@tocrmarg|.
%    \begin{macrocode}
   \rightskip \@tocrmarg\relax
%    \end{macrocode}
% Typeset \meta{text} using an italic font, then ensure that the paragraph
% is finished (to use the local skips). Finally close the group and we
% are done.
%    \begin{macrocode}
   \textit{#1}\protect\par}}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftlocalchange}
% |\cftmakelocalchange{|\meta{file}|}{|\meta{pnumwidth}|}{|\meta{tocrmarg}|}|
% makes an entry into \meta{file} to change the |\@pnumwidth| and
% the |\@tocrmarg| values.
%    \begin{macrocode}
\newcommand{\cftlocalchange}[3]{%
  \addtocontents{#1}{\protect\cftsetpnumwidth{#2} \protect\cftsetrmarg{#3}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftaddtitleline}
% |\cftaddtitleline{|\meta{file}|}{|\meta{kind}|}{|\meta{title}|}{|\meta{page}|}|
% adds a |\contentsline| entry to \meta{file} with the given information.
%    \begin{macrocode}
\newcommand{\cftaddtitleline}[4]{\addtocontents{#1}{%
  \protect\contentsline{#2}{#3}{#4}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cftaddnumtitleline}
% |\cftaddtitleline{|\meta{file}|}{|\meta{kind}|}{|\meta{num}|}{|\meta{title}|}{|\meta{page}|}|
% adds a |\contentsline| entry to \meta{file} with the given information.
% \changes{v2.3c}{2003/09/26}{Removed \cs{ignorespaces} from \cs{cftaddnumtitleline}}
%    \begin{macrocode}
\newcommand{\cftaddnumtitleline}[5]{\addtocontents{#1}{%
    \protect\contentsline{#2}{\protect\numberline{#3}#4}{#5}}}
%    \end{macrocode}
% \end{macro}
%
% And, if dear old \Lpack{hyperref} has been used, we have to fix up these
% two macros.
% \changes{2003/09/26}{v2.3c}{Hyperref fix for \cs{cftaddtitleline} and
%                             \cs{cftaddnumtitleline}}
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{hyperref}{%
    \renewcommand{\cftaddtitleline}[4]{\addtocontents{#1}{%
      \protect\contentsline{#2}{#3}{#4}{\@currentHref}}}
    \renewcommand{\cftaddnumtitleline}[5]{\addtocontents{#1}{%
      \protect\contentsline{#2}{\protect\numberline{#3}#4}{#5}{\@currentHref}}}
  }{}
}

%    \end{macrocode}
%
%
% \begin{macro}{\@starttoc}
%
% Okay, here's a roughly-comprehensive list where \cs{@starttoc} is redefined in \TeX{} Live 2014.
% \begin{itemize}
% \item amsart, amsbook, amsdtx, amsproc
% \item asect
% \item latx.ltx (of course)
% \item newfloat
% \item flowfram
% \item gmampulex (?), gmtypos
% \item hyperref, memhfixc
% \item ijmart
% \item scrartcl, scrbook, scrreprt
% \item scrwtfile
% \item tocbasic
% \item tocstyle
% \item memoir
% \item multitoc
% \item nccsect
% \item notoccite
% \item artikel3, boek3, rapport3,
% \item rerunfilecheck
% \item parskip
% \item pdfwin
% \item revtex4
% \item devanagari
% \end{itemize}
% This makes things difficult if we want to redefine \cs{@starttoc} here.
% Many of the packages/classes above will not be used in conjunction with tocloft; on the other hand, we don't want to trample too much on others' code.
%
% So for our own work here, let's be extra conservative, at least for now, and only hook into \cs{starttoc} if it's the standard \LaTeX{} version.
%    \begin{macrocode}
\def\@starttoc@latex@orig#1{%
 \begingroup
   \makeatletter
   \@input{\jobname.#1}%
   \if@filesw
     \expandafter\newwrite\csname tf@#1\endcsname
     \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
   \fi
  \@nobreakfalse
\endgroup}
\ifx\@starttoc\@starttoc@latex@orig
  \def\@starttoc#1{%
    \csname cft#1prehook\endcsname
    \begingroup
      \makeatletter
      \@input{\jobname.#1}%
      \if@filesw
        \expandafter\newwrite\csname tf@#1\endcsname
        \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
      \fi
      \@nobreakfalse
    \endgroup
    \csname cft#1posthook\endcsname}
  \newcommand\cfttocprehook{}
  \newcommand\cftlofprehook{}
  \newcommand\cftlotprehook{}
  \newcommand\cfttocposthook{}
  \newcommand\cftlofposthook{}
  \newcommand\cftlotposthook{}
\else
  \PackageWarning{tocloft}{\string\@starttoc\space has already been redefined; tocloft bailing out.}
\fi
%    \end{macrocode}
% \end{macro}
%
%
%
%
%    The end of this package.
%    \begin{macrocode}
%</usc>
%    \end{macrocode}
%
%
% \bibliographystyle{alpha}
%
% \begin{thebibliography}{GMS94}
%
% \bibitem[Coc95]{SUBFIGURE}
% Steven Douglas Cochran.
% \newblock \emph{{The subfigure package}}.
% \newblock March 1995.
% \newblock (Available from CTAN as file \texttt{subfigure.dtx})
%
% \bibitem[Dru99]{MINITOC}
% Jean-Pierre Drucbert.
% \newblock \emph{{The minitoc package}}.
% \newblock August 1999.
% \newblock (Available from CTAN in subdirectory \texttt{/minitoc})
%
% \bibitem[GMS94]{GOOSSENS94}
% Michel Goossens, Frank Mittelbach, and Alexander Samarin.
% \newblock {\em The LaTeX Companion}.
% \newblock Addison-Wesley Publishing Company, 1994.
%
% \bibitem[Lin97]{FNCYCHAP}
% Ulf~A. Lindgren.
% \newblock \emph{{FncyChap V1.11}}.
% \newblock April 1997.
% \newblock (Available from CTAN in subdirectory \texttt{/fncychap})
%
% \bibitem[Lin95]{FLOAT}
% Anselm Lingnau.
% \newblock \emph{{An Improved Environment for Floats}}.
% \newblock March 1995.
% \newblock (Available from CTAN in subdirectory \texttt{/float})
%
% \bibitem[Wil96a]{ALGORITHM}
% Peter Williams.
% \newblock \emph{{Algorithms}}.
% \newblock April 1996.
% \newblock (Available from CTAN in subdirectory \texttt{/algorithm})
%
% \bibitem[Wil96b]{PRW96i}
% Peter~R. Wilson.
% \newblock \emph{{LaTeX for standards: The LaTeX package files user manual}}.
% \newblock NIST Report NISTIR, June 1996.
%
% \bibitem[Wil00]{TOCBIBIND}
% Peter~R. Wilson.
% \newblock \emph{{The tocbibind package}}.
% \newblock March 2000.
% \newblock (Available from CTAN as file \texttt{tocbibind.dtx})
%
% \bibitem[Wil01]{CCAPTION}
% Peter~R. Wilson.
% \newblock \emph{{The ccaption package}}.
% \newblock March 2001.
% \newblock (Available from CTAN as file \texttt{ccaption.dtx})
%
% \end{thebibliography}
%
%
% \Finale
% \PrintIndex
%
\endinput

%% \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         \~}