summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/etoc/etoc.dtx
blob: 137286d7c522cb7fe6644efb27b39f14c6691f5c (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
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
% -*- coding: utf-8; -*-
%<*none>
{\def\doctimestamp {Time-stamp: <18-03-2015 22:41:13 CET>}% 
 \def\getdtxtimestamp #1 <#2 #3 #4>{#2 at #3 #4}%
 \xdef\etocdtxtimestamp {\expandafter\getdtxtimestamp\doctimestamp }}%
%</none>
%<*!readme>
%%
%% Package: etoc
%% Version: 1.08b (2015/03/18)
%% License: LPPL 1.3c or later (see etoc.dtx)
%% Copyright (C) 2012-2015 Jean-Francois Burnol 
%%                         <jfbu at free dot fr>
%% Copyright (C) 2014-2015 Christine Roemer 
%%                         <Christine_Roemer at t-online dot de>
%% and collaborators for the translation into German of the documentation
%%
%</!readme>
%<*insfile>
\def\etocpkgdate        {2015/03/18} 
\def\etocdocdate        {2015/03/18}
\def\etocpkgversion     {v1.08b}
\def\etocpkgdescription {Completely customisable TOCs (jfB)}
%</insfile>
%<*none>
% Now the date and version which are specific to the German translation.
% Replace \let by suitable \def's in case this lags behing English version.
\let\etocDEpkgdate   \etocpkgdate    %
\let\etocDEdocdate   \etocdocdate    %
\let\etocDEpkgversion\etocpkgversion %
% Definition of \etocLicense
% --------------------------
\begingroup
    \long\def\firstofone #1{#1}\catcode1=14\catcode2=0
    \catcode`\%=12\catcode`\_=12\endlinechar13\catcode13=13 ^^A
    \catcode32=13\catcode`\\=12^^Brelax^^A
^^Bfirstofone{^^Bendgroup^^Bdef^^BetocLicense^^A
{% Package: etoc
% Version: 1.08b (2015/03/18)
% License: LPPL 1.3c or later
% Copyright (C) 2012-2015 Jean-Francois Burnol <jfbu at free dot fr>
% Copyright (C) 2014-2015 Christine Roemer <Christine_Roemer at t-online dot de>
% and collaborators for the translation into German of the documentation
%
%     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. This version of this license is in 
%          http://www.latex-project.org/lppl/lppl-1-3c.txt
%     and the latest version of this license is in
%          http://www.latex-project.org/lppl.txt
%     and version 1.3 or later is part of all distributions of
%     LaTeX version 2005/12/01 or later. 
%
% The Authors of this Work are:
% Jean-Francois Burnol <jfbu at free dot fr> 
%     for the source code and English documentation, and
% Christine Roemer <Christine_Roemer at t-online dot de> and collaborators
%     for the translation into German of the documentation.
% 
% This Work consists of the main source file etoc.dtx and the derived
% files etoc.sty, etoc.ins, etoc.tex, etoc-DE.tex, etoc.pdf, etoc-DE.pdf, 
% etoc.dvi, etoc-DE.dvi, README.md.
%
% Running etex (or latex or pdflatex) on etoc.dtx extracts etoc.sty,
% etoc.ins, etoc.etex, etoc-DE.tex, and README.md. See README.md for
% further instructions.
}}%
\iffalse
%</none>
%<*readme>
<!-- -->

    Source:  etoc.dtx (v1.08b 2015/03/18)
    Author:  Jean-Francois Burnol
    Author for German tranlation: Christine Roemer
    Info:    Completely customisable TOCs
    License: LPPL 1.3c or later

Copyright (C) 2012-2015 Jean-Francois Burnol `<jfbu at free dot fr>`

Copyright (C) 2014-2015 Christine Roemer `<Christine_Roemer at t-online dot de>` 
and collaborators for the translation into German of the documentation.

ABSTRACT
========

The etoc package gives to the user complete control on how the entries
of the table of contents should be constituted from the *name*,
*number*, and *page number* of each sectioning unit. This goes via the
definition of *line styles* for each sectioning level used in the
document. The package provides its own custom line styles. Simpler
ones are given as examples in the documentation. The simplest usage
will be to take advantage of the layout facilities of packages dealing
with list environments.

Regarding the *global toc display*, etoc provides pre-defined styles
based on a multi-column format, with, optionally, a ruled title or
framed contents.

The `\tableofcontents` command may be used arbitrarily many times and
it has a variant `\localtableofcontents` which prints tables of
contents 'local' to the current surrounding document unit. An
extension of the `\label/\ref` syntax allows to reproduce (with
another layout) a local table of contents defined somewhere else in
the document.

Via *depth tags*, one gets an even finer control for each table of
contents of which sectioning units it should, or not, display.

The formatting inherited (and possibly customized by other packages)
from the document class will be used when in compatibility mode.

The assignment of levels to the sectioning units can be changed at any
time, and etoc can thus be used in a quite general manner to create
custom ''lists of'', additionally to the tables of contents related to
the document sectioning units. No auxiliary file is used additionally
to the standard `.toc` file.

INSTALLATION
============

The simplest is to download

>  <http://mirrors.ctan.org/install/macros/latex/contrib/etoc.tds.zip>

and then run `unzip etoc.tds.zip -d <DEST>` where `<DEST>` is a
TDS-compliant repertory.

Else, to extract the package (.sty) and driver (.tex) files from etoc.dtx:

- if etoc.ins is present:   etex etoc.ins
- without etoc.ins:         etex etoc.dtx

It is also possible to run latex or pdflatex directly on etoc.dtx.

At least three ways to produce etoc.pdf (method (3) is preferred):

1. latex etoc.dtx (four times), then dvips, then ps2pdf
2. pdflatex etoc.dtx (four times)
3. latex etoc.tex (four times), then dvipdfmx

Method (3) produces the smallest pdf files.
Options can be set in etoc.tex:

- scrdoc class options (paper size, font size, ...)
- with or without source code,
- with dvipdfmx or with latex+dvips or pdflatex.

To produce etoc-DE.pdf (German documentation) run etex on etoc.ins
or etoc.dtx to produce etoc-DE.tex, then compile etoc-DE.tex with
latex (thrice) then dvipdmx, or set first to 0 `\Withdvipdfmx` in
etoc-DE.tex to allow compilation with pdflatex.

Um etoc-DE.pdf zu erzeugen ist latex dreimal mit etoc-DE.tex laufen
zu lassen, dann dvipdfmx mit etoc-DE.dvi. Im Falle von Problemen
mit dvipdfmx ist `\Withdvidpdfmx` auf 0 in etoc-DE.tex zu setzen,
dann ist pdflatex dreimal mit etoc-DE.tex laufen zu lassen.

Installation:

    etoc.sty    -> TDS:tex/latex/etoc/etoc.sty
    etoc.dtx    -> TDS:source/latex/etoc/etoc.dtx
    etoc.pdf    -> TDS:doc/latex/etoc/etoc.pdf
    etoc-DE.pdf -> TDS:doc/latex/etoc/etoc-DE.pdf
    README.md   -> TDS:doc/latex/etoc/README.md

The other files may be discarded.

LICENSE
=======

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. This version of this license is in

> <http://www.latex-project.org/lppl/lppl-1-3c.txt>

and the latest version of this license is in

> <http://www.latex-project.org/lppl.txt>

and version 1.3 or later is part of all distributions of
LaTeX version 2005/12/01 or later.

The Authors of this Work are:

- Jean-Francois Burnol `<jfbu at free dot fr>` for the source code
  and English documentation, and
- Christine Roemer `<Christine_Roemer at t-online dot de>` and
  collaborators for the translation into German of the documentation.

This Work consists of the main source file etoc.dtx and the
derived files etoc.sty, etoc.ins, etoc.tex, etoc-DE.tex,
etoc.pdf, etoc-DE.pdf, etoc.dvi, etoc-DE.dvi.

RECENT CHANGES
==============

v1.08b [2015/03/18]
-------------------

Bug fixes: 

- extra space token removed from `\localtableofcontents` (showed
  only for inline TOCs.)
- `\etocpartname` (a macro used by the package own default line
  styles) was defined to be `\partname`, but this is not compatible
  at least with `babel+french` context. Now simply expands to Part.
- some problems fixed in the German documentation.

v1.08a [2015/03/13]
-------------------

`\etocname`, `\etocnumber` and `\etocpage` are now the robust
variants of `\etocthelinkedname`, `\etocthelinkednumber` and
`\etocthelinkedpage`. This should arguably have been done since
the addition of the latter to etoc with v1.07f [2013/03/07]. The
earlier `\etocname` etc... contained the hyperlink destination
only in an unexpanded form.

The documentation has a brand new title page and a new section
*The TOC as a TikZ mind map* both illustrating further uses of
etoc to display tables of contents as trees in an automatic
manner.

v1.08 [2015/03/10]
------------------

`\etocskipfirstprefix` may now appear anywhere in the `<start>`
part of a level style.

New commands `\etociffirst`, `\etocxiffirst`, `\etocxifnumbered`.

It is now possible to issue line style specifications directly
with `&` and `\\` tokens, in order to typeset a TOC as a tabular
or longtable with the opening for example in the first argument of
`\etocsettocstyle` and the closing in its second argument.

It is mandatory for such uses to issue `\etocglobaldefs` which
tells etoc to proceed globally for certain definitions. This is
also useful in the context of the inline environments of package
enumitem.

On this occasion, various old parts of the code have been improved.

v1.07n [2015/03/05]
-------------------

No more use of `\toks@` when etoc constructs `\etocthelinkedname`
etc... Thus `\toks@` can be put in the line styles in order to
accumulate information. Only useful if it is certain nothing else
will change `\toks@` either.

In the documentation: list of main commands now in alphabetic order.

v1.07m [2015/01/23]
-------------------

Reading of .toc file is delayed to `\begin{document}` to account for
possible Babel active characters used therein. Thanks to Denis
Bitouzé who reported a Babel related problem.

Improved global toc display emulation under KOMA-script classes.

New command `\etocbeforetitlehook`. New command `\etocdisplay`.

v1.07l [doc of 2014/04/29]
--------------------------

Added to the documentation an example of use of `\etocthelinkedname`
together with an enumitem inline itemize\* environment; moved main
TOC to immediately after the title, and license to the first pages.

Incorporation of the translation into German done on the initiative
of Christine Römer by Felix Baral-Weber, Jenny Rothkrämer-Vogt,
Daniel Büttner, Claudia Dahl, Christian Otto and Christine Römer (FSU
Jena). My grateful thanks to all!
%</readme>
%<*tex>-------------------------------------------------------------------------
%% run latex four times on this file etoc.tex then dvipdfmx on etoc.dvi 
%% to produce the documentation etoc.pdf, with source code included.  
%%
%% possible dvipdfmx warnings may be ignored, but in case of a too
%% old dvipdfmx, it may be preferable to use pdflatex. For this set
%% \Withdvipdfmx to 0 first here or run directly pdflatex on etoc.dtx.
%%
\chardef\Withdvipdfmx 1 % replace 1 by 0 for using latex+dvips or pdflatex
\chardef\NoSourceCode 0 % replace 0 by 1 for the doc *without* the source code
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile {etoc.tex}[Driver for etoc documentation]%
\PassOptionsToClass   {a4paper,fontsize=11pt,twoside}{scrdoc}
\PassOptionsToPackage {ngerman,english}{babel}
\chardef\ForEnglish 1 % (ForEnglish and ForDeutsch flags can NOT both be 1 ..)
\chardef\ForDeutsch 0 %
\input etoc.dtx
%%% Local Variables:
%%% mode: latex
%%% End:
%</tex>-------------------------------------------------------------------------
%<*DEtex>-----------------------------------------------------------------------
%% run latex thrice on this file etoc-DE.tex then dvipdfmx on etoc-DE.dvi 
%% to produce the German documentation etoc-DE.pdf (without source code).
%%
%% possible dvipdfmx warnings may be ignored, but in case of a too
%% old dvipdfmx, it may be preferable to use pdflatex. For this set
%% \Withdvipdfmx to 0 first here.
%%
%% Um etoc-DE.pdf zu erzeugen ist latex dreimal mit etoc-DE.tex laufen
%% zu lassen, dann dvipdfmx mit etoc-DE.dvi. Im Falle von Problemen
%% mit dvipdfmx ist \Withdvidpdfmx auf 0 zu setzen, dann ist pdflatex
%% dreimal mit etoc-DE.tex laufen zu lassen.
%%
\chardef\Withdvipdfmx 1 % replace 1 by 0 for using latex+dvips or pdflatex
\chardef\NoSourceCode 1 % replace 1 by 0 for the doc *with* the source code
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile {etoc-DE.tex}[Driver for etoc German documentation]%
%% or with german rather than ngerman in the two lines below
\PassOptionsToClass   {a4paper,fontsize=11pt,twoside,ngerman}{scrdoc}
\PassOptionsToPackage {english,ngerman}{babel}
\chardef\ForEnglish 0 % (can NOT be both 1..)
\chardef\ForDeutsch 1 %
\input etoc.dtx
%%% Local Variables:
%%% mode: latex
%%% End:
%</DEtex>-----------------------------------------------------------------------
%<*insfile>---------------------------------------------------------------------
%% Run etex on this file to extract from etoc.dtx:
%%        etoc.sty, etoc.tex, etoc-DE.tex and README.md
%%
%% At least three ways to produce etoc.pdf (method (3) is preferred):
%%  (1) latex etoc.dtx (four times), then dvips, then ps2pdf
%%  (2) pdflatex etoc.dtx (four times)
%%  (3) latex etoc.tex (four times), then dvipdfmx
%%
%% Method (3) produces the smallest pdf files.
%% Options can be set in etoc.tex (and etoc-DE.tex):
%%  - scrdoc class options (paper size, font size, ...) 
%%  - with or without source code, 
%%  - with dvipdfmx or with latex/pdflatex. 
%%
%% To produce the German documentation etoc-DE.pdf run tex on etoc.ins
%% or etoc.dtx to produce etoc-DE.tex, then compile etoc-DE.tex with
%% latex (thrice) then dvipdmx, or edit the suitable toggle in
%% etoc-DE.tex to allow compilation to proceed with pdflatex.
%%
%% Um etoc-DE.pdf zu erzeugen ist latex dreimal mit etoc-DE.tex laufen
%% zu lassen, dann dvipdfmx mit etoc-DE.dvi. Im Falle von Problemen
%% mit dvipdfmx ist \Withdvidpdfmx auf 0 in etoc-DE.tex zu setzen,
%% dann ist pdflatex dreimal mit etoc-DE.tex laufen zu lassen.
%%
%% Installation:
%%
%%   etoc.sty    -> TDS:tex/latex/etoc/etoc.sty
%%   etoc.dtx    -> TDS:source/latex/etoc/etoc.dtx
%%   etoc.pdf    -> TDS:doc/latex/etoc/etoc.pdf
%%   etoc-DE.pdf -> TDS:doc/latex/etoc/etoc-DE.pdf
%%   README.md   -> TDS:doc/latex/etoc/README.md
%%
\input docstrip.tex
\askforoverwritefalse
\def\etocpkgpreamble{\defaultpreamble^^J\MetaPrefix^^J%
\string\NeedsTeXFormat{LaTeX2e}^^J%
\string\ProvidesPackage{etoc}^^J%
\space[\etocpkgdate\space\etocpkgversion\space\etocpkgdescription]}%
\generate{\nopreamble\nopostamble
\file{README.md}{\from{etoc.dtx}{readme}}%
\usepostamble\defaultpostamble
\file{etoc.tex}{\from{etoc.dtx}{tex}}%
\file{etoc-DE.tex}{\from{etoc.dtx}{DEtex}}%
\usepreamble\etocpkgpreamble
\file{etoc.sty}{\from{etoc.dtx}{package}}}%
\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{*     etoc.sty} 
\Msg{*}
\Msg{* To produce the documentation run latex thrice on file etoc.tex}
\Msg{* (or etoc-DE.tex) and then run dvipdfmx on file etoc.dvi, resp.}
\Msg{* etoc-DE.dvi}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
\ifx\numexpr\undefined
\Msg{* warning: to get correct utf-8 encoded README.md }%
\Msg{* do etex etoc.ins and not as here tex etoc.ins   }%
\Msg{************************************************************************}
\fi
\endbatchfile
%</insfile>---------------------------------------------------------------------
%<*none>------------------------------------------------------------------------
\fi
%
\chardef\noetex 0
\ifx\numexpr\undefined\chardef\noetex 1 \fi
\ifnum\noetex=1 \chardef\extractfiles 0 % extract files, then stop
\else
    \ifx\ProvidesFile\undefined
      \chardef\extractfiles 0 % etex etc.. on etoc.dtx, only file extraction.
    \else % latex/pdflatex on etoc.tex or on etoc.dtx
      \ifx\Withdvipdfmx\undefined
        % latex/pdflatex run is on etoc.dtx
        \chardef\extractfiles 1 % 1 = extract files and typeset manual, 2 = only typeset
        \chardef\Withdvipdfmx 0 % 0 = pdflatex or latex+dvips, 1 = dvipdfmx
        \chardef\NoSourceCode 1 % 0 =  include source code, 1 = do not
        \chardef\ForEnglish 1 
        \chardef\ForDeutsch 0
        \NeedsTeXFormat {LaTeX2e}%
        \PassOptionsToClass   {a4paper,fontsize=11pt,twoside}{scrdoc}% 
        \PassOptionsToPackage {ngerman,english}{babel}%
      \else % latex run is on etoc.tex or etoc-DE.tex
        \chardef\extractfiles 2 % do not extract files, only typeset
      \fi
      \ProvidesFile{etoc.dtx}%
        [etoc source and documentation (\etocdtxtimestamp)]%
    \fi
\fi
\ifnum\extractfiles<2 % extract files
\def\MessageDeFin{\newlinechar10 \let\Msg\message
\Msg{********************************************************************^^J}%
\Msg{*^^J}%
\Msg{* To finish the installation you have to move the following^^J}%
\Msg{* file into a directory searched by TeX:^^J}%
\Msg{*^^J}%
\Msg{*\space\space\space\space etoc.sty^^J}%
\Msg{*^^J}%
\Msg{* To produce the documentation with source code included run latex^^J}%
\Msg{* thrice on file etoc.tex and then dvipdfmx on etoc.dvi^^J}%
\Msg{*^^J}%
\Msg{* To produce the German documentation run latex thrice on file^^J}%
\Msg{* etoc-DE.tex and then dvipdfmx on etoc-DE.dvi^^J}%
\Msg{*^^J}%
\Msg{* Happy TeXing!^^J}%
\Msg{*^^J}%
\Msg{********************************************************************^^J}%
}%
\begingroup
    \input docstrip.tex
    \askforoverwritefalse
    \def\etocpkgpreamble{\defaultpreamble^^J\MetaPrefix^^J%
    \string\NeedsTeXFormat{LaTeX2e}^^J%
    \string\ProvidesPackage{etoc}^^J%
    \space[\etocpkgdate\space\etocpkgversion\space\etocpkgdescription]}%
    \generate{\nopreamble\nopostamble
    \file{README.md}{\from{etoc.dtx}{readme}}%
    \usepostamble\defaultpostamble
    \file{etoc.ins}{\from{etoc.dtx}{insfile}}%
    \file{etoc.tex}{\from{etoc.dtx}{tex}}%
    \file{etoc-DE.tex}{\from{etoc.dtx}{DEtex}}%
    \usepreamble\etocpkgpreamble
    \file{etoc.sty}{\from{etoc.dtx}{package}}}%
\endgroup
\fi % end of file extraction (from etex/latex/pdflatex run on etoc.dtx)
\ifnum\noetex=1 % warning for README.md
    \expandafter\def\expandafter\MessageDeFin\expandafter 
{\MessageDeFin
\Msg{* warning: to get correct utf-8 encoded README.md ^^J}%
\Msg{* do etex etoc.dtx and not as here tex etoc.dtx   ^^J}%
\Msg{********************************************************************^^J}}%
\fi
\ifnum\extractfiles=0 % tex/etex/xetex/etc on etoc.dtx, files extracted, stop
      \MessageDeFin\expandafter\end
\fi
% From this point on, run is necessarily with e-TeX.
% Check if \MessageDeFin got defined, if yes put it at end of run.
\ifdefined\MessageDeFin\AtEndDocument{\MessageDeFin}\fi
%-------------------------------------------------------------------------------
% START OF USER MANUAL TEX SOURCE
\documentclass[abstract]{scrdoc}

\ifnum\NoSourceCode=1 \OnlyDescription\fi

\usepackage{ifpdf}
\ifpdf\chardef\Withdvipdfmx 0 \fi

\makeatletter
\ifnum\Withdvipdfmx=1
   \@for\@tempa:=hyperref,bookmark,graphicx,xcolor,pict2e\do
            {\PassOptionsToPackage{dvipdfmx}\@tempa}
   %
   \PassOptionsToPackage{dvipdfm}{geometry}
   \PassOptionsToPackage{bookmarks=true}{hyperref}
   \PassOptionsToPackage{dvipdfmx-outline-open}{hyperref}
   \PassOptionsToPackage{dvipdfmx-outline-open}{bookmark}
   %
   \def\pgfsysdriver{pgfsys-dvipdfm.def}
\else
   \PassOptionsToPackage{bookmarks=true}{hyperref}
\fi
\makeatother

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[hscale=0.66,vscale=0.75]{geometry}
\pagestyle{headings}
% \usepackage{layout}

% January 2014. work-around a bug in KOMA 3.12 (December 2013):
\makeatletter
\def\buggysectionmark #1{% KOMA 3.12 as released to CTAN December 2013
    \if@twoside\expandafter\markboth\else\expandafter\markright\fi
    {\MakeMarkcase{\ifnumbered{section}{\sectionmarkformat\fi}{}#1}}{}}
\ifx\buggysectionmark\sectionmark
\def\sectionmark #1{%
    \if@twoside\expandafter\markboth\else\expandafter\markright\fi
    {\MakeMarkcase{\ifnumbered{section}{\sectionmarkformat}{}#1}}{}}
\fi
\makeatother

\makeatletter
% 2013/03/07. 
% This macro allows to conveniently center a line inside a paragraph and still
% use therein \verb or other commands changing catcodes.
% Note: \centerline in LaTeX still uses \hsize and not \linewidth/\columnwidth
    \def\@centeredline {\hbox to \linewidth
                        \bgroup \hss \bgroup
                        \aftergroup\centeredline@ }
    \newcommand*\centeredline {%
      \ifhmode
        \\\relax
        \def\centeredline@{\hss\egroup\hskip\z@skip}%
      \else
        \def\centeredline@{\hss\egroup}%
      \fi
      \afterassignment\@centeredline
      \let\next=}

% pour maintenir les % en début de ligne dans les blocs verbatim
%

   \let\original@check@percent\check@percent
   \let\check@percent\relax
\makeatother


% pour les environnements verbatim
% uniformisé finalement, avec quelques exceptions, pour dtx du 3 déc 2013
\def\MacroFont{\ttfamily\small\hyphenchar\font45 \baselineskip11pt\relax}

% ATTENTION: (avec doc.sty ou les classes scrdoc ou ltxdoc)
%
% - l'environnement macrocode se fait avec \macro@font qui est le
% \MacroFont du \begin{document}.
%
% - les environnements verbatim utilisent le \MacroFont courant.
%
% - \verb utilise un \ttfamily !! et non pas \verbatim@font que l'on
% peut customiser.
%
% - (9 mars 2015) il ne faut PAS commencer des macrocode directement après
% un \section, il faut un paragraphe (par exemple un \indent\par)

%----
% better \verb pour doc.
% 12 octobre 2013, importé de xint.dtx
% je rajoute pour { afin que truc{machin puisse avoir hyphénation
% retire \leavemmode, pas nécessaire pour emploi ici

% NOTE 9 mars 2015. J'ai depuis une version plus aboutie dans xint.dtx
% mais je laisse ici tel quel.

\def\MicroFont{\ttfamily\hyphenchar\font45 }
% modif de \do@noligs: \char`#1} --> \char`#1 }
\makeatletter 
\def\do@noligs #1%
{%
    \catcode `#1\active 
    \begingroup \lccode `\~=`#1\relax 
    \lowercase {\endgroup \def ~{\kern \z@ \char `#1 }}%
}% 
\def\dobackslash
{%
    \catcode92 \active 
    \begingroup \lccode `\~=92\relax 
    \lowercase {\endgroup \def ~{\kern \z@ \char 92 }}%
}% 
\def\dobraces
{%
    \catcode123 \active 
    \begingroup \lccode `\~=123\relax 
    \lowercase {\endgroup \def ~{\hskip \z@\@plus.1pt\@minus.1pt
                                 \char 123 }}%
    \catcode125 \active 
    \begingroup \lccode `\~=125\relax 
    \lowercase {\endgroup \def ~{\char 125 \hskip \z@\@plus.1pt\@minus.1pt }}%
}% 
\def\verb 
{%
  \relax \ifmmode\hbox\else\leavevmode\null\fi
  \bgroup \MicroFont
  \let\do\do@noligs  \verbatim@nolig@list
  \let\do\@makeother \dospecials 
  \catcode32 10 
  \dobackslash \dobraces \makestarlowast 
  \@jfverb 
}% 
\def\@jfverb #1{\catcode`#1\active
                \lccode`\~`#1\lowercase{\def~{\egroup\unskip}}}%
% (\unskip ajouté le 14 octobre)
% \lowast est défini plus loin
\begingroup
   \lccode`\~=`\*
\lowercase{%
\endgroup
\def\makestarlowast {\catcode`\*\active\let~\lowast}}%
\makeatother
%
\usepackage{txfonts}

% m'occuper de la taille de txtt:
% au passage je supprime le \hyphenchar \font\m@ne

% avril 2013
% ATTENTION ATTENTION ATTENTION Un changement de taille comme \small semble
% déclencher (peut-être) la relecture de t1txtt.fd et quoi qu'il en soit le
% \hyphenchar est REMIS à -1 !

% update: 13 octobre 2013 
% et pourtant tailles sont ok, donc au moins cette information est
% maintenue je ne sais donc pas exactement ce qui se passe.

\DeclareFontFamily{T1}{txtt}{\hyphenchar\font 45\relax}
\DeclareFontShape{T1}{txtt}{m}{n}{  %medium
     <->s*[.96] t1xtt%
}{}
\DeclareFontShape{T1}{txtt}{m}{sc}{ %cap & small cap
     <->s*[.96] t1xttsc%
}{}
\DeclareFontShape{T1}{txtt}{m}{sl}{ %slanted
     <->s*[.96] t1xttsl%
}{}
\DeclareFontShape{T1}{txtt}{m}{it}{ %italic
     <->ssub * txtt/m/sl%
}{}
\DeclareFontShape{T1}{txtt}{m}{ui}{     %unslanted italic
     <->ssub * txtt/m/sl%
}{}
\DeclareFontShape{T1}{txtt}{bx}{n}{ %bold extended
     <->t1xbtt%
}{}
\DeclareFontShape{T1}{txtt}{bx}{sc}{    %bold extended cap & small cap
     <->t1xbttsc%
}{}
\DeclareFontShape{T1}{txtt}{bx}{sl}{    %bold extended slanted
     <->t1xbttsl%
}{}
\DeclareFontShape{T1}{txtt}{bx}{it}{    %bold extended italic
     <->ssub * txtt/bx/sl%
}{}
\DeclareFontShape{T1}{txtt}{bx}{ui}{    %bold extended unslanted italic
     <->ssub * txtt/bx/sl%
}{}
\DeclareFontShape{T1}{txtt}{b}{n}{  %bold
     <->ssub * txtt/bx/n%
}{}
\DeclareFontShape{T1}{txtt}{b}{sc}{ %bold cap & small cap
     <->ssub * txtt/bx/sc%
}{}
\DeclareFontShape{T1}{txtt}{b}{sl}{ %bold slanted
     <->ssub * txtt/bx/sl%
}{}
\DeclareFontShape{T1}{txtt}{b}{it}{     %bold italic
     <->ssub * txtt/bx/it%
}{}
\DeclareFontShape{T1}{txtt}{b}{ui}{     %bold unslanted italic
     <->ssub * txtt/bx/ui%
}{}

\usepackage{xspace}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage[inline]{enumitem}
\usepackage{array}
\usepackage{longtable}

\definecolor{joli}{RGB}{225,95,0}
\definecolor{JOLI}{RGB}{225,95,0}
\definecolor{BLUE}{RGB}{0,0,255}
\colorlet{niceone}{green!35!blue!75}

\usepackage {babel} % ngerman and english options have been passed to babel
\AtBeginDocument {
  \ifnum\ForEnglish=1 \renewcommand\partname{Part}\fi
  \addto\captionsenglish {\renewcommand\partname{Part}}
  \addto\captionsgerman  {\renewcommand\partname{Teil}}
%% ATTENTION À CE QUE FAIT LA CLASSE scrdoc !!!
%% je l'avais oublié et pour 1.08 je suis passé à ngerman
%% mais il fallait alors ceci sinon scrdoc utilise Datei !!!
  \addto\captionsngerman {\renewcommand\partname{Teil}}
}

\usepackage{tikz}
\usetikzlibrary{trees}    % added for "cyclic" grow function 2013/03/02
\usepackage{forest}       % switched from tikz-qtree to forest 2013/09/09
% No problem with hyperlinks then, contrarily to tikz-qtree.

% NOTE: (12 octobre 2013)
%  - si compilation pour dvipdfmx, les arbres dans le dvi visualisés par xdvi
%  montrent correctement les textes, mais rien au point de vue graphique,
%  - si compilation pour dvips, l'arbre fait par forest est tout empilé, celui
%  fait par tikz sans forest est presque correct, les labels débordent.
% Dans les deux cas, le résultat final dans le pdf est bon.
% grosso modo dans l'état actuel le pdf fait 250K (dvipdfmx), 340K (pdflatex) et
% 1M pour dvips+ps2pdf.

% 9 octobre 2013, je me décide à ne plus utiliser hidelinks, mais il est tout de
% même ajouté au .toc

% 12 mars 2015, pour 1.08a, see http://tex.stackexchange.com/a/232584/4686
\usetikzlibrary{mindmap} 

%18 mai 2014: pdfinfo différent suivant anglais ou allemand
\ifnum\ForEnglish=1
\usepackage[pdfencoding=pdfdoc]{hyperref}
\hypersetup{%
linktoc=all,%      why is the important stuff
%% bookmarksdepth=3,% (not needeed anymore now, v1.07g)
breaklinks=true,%
colorlinks,%   
linkcolor=RoyalBlue,% Orchid
urlcolor=OliveGreen,%
pdfauthor={Jean-Fran\c cois Burnol},%
pdftitle={The etoc package},%
pdfsubject={Tables of contents with LaTeX},%
pdfkeywords={LaTeX, table of contents},%
pdfstartview=FitH,%
pdfpagemode=UseOutlines}
\fi

\ifnum\ForDeutsch=1
\usepackage[pdfencoding=pdfdoc]{hyperref}
\hypersetup{%
linktoc=all,%
breaklinks=true,%
colorlinks,%   
linkcolor=RoyalBlue,% Orchid
urlcolor=OliveGreen,%
pdfauthor={Jean-Fran\c cois Burnol, Christine Römer},%
pdftitle={Das etoc Paket},%
pdfsubject={Inhaltsverzeichnisse mit LaTeX},%
pdfkeywords={LaTeX, Inhaltsverzeichnis},%
pdfstartview=FitH,%
pdfpagemode=UseOutlines}
\fi

% added usage of package bookmark 2013/10/10
\usepackage{bookmark} 

\usepackage{framed}
\usepackage{varioref}

\usepackage{etoc}  % loads multicol
% for etoc's own default line styles. <1.08b had \partname by default but this
% does not work well with babel+frenchb hence the default is now simply Part.
% Here we can use \partname as we do the documentation for English or German.
% Careful with the customization of \partname done by scrdoc class !
\renewcommand{\etocpartname}{\partname}
% see the \AtBeginDocuments with \addto\captionsngerman etc...

\ifnum\ForDeutsch=1
  \renewcommand*{\etocabbrevpagename}{S.~}
\fi


%--------
% 10 octobre 2013:
\AtBeginDocument{\addtocontents{toc}{\protect\hypersetup{hidelinks}}}
% mieux que de passer hidelinks comme option à hyperref.
% Comme toutes les tocs sont faites dans un groupe, c'est très
% bien. (et j'utilise \etocaftertitlehook pour autre chose)

%--------
% add-ons for the new section `surprising uses of etoc' (2013/01/24)
\newcounter{visibletoc}
\renewcommand{\etocaftertitlehook}
   {\stepcounter{visibletoc}%
    \phantomsection
    \etoctoccontentsline{visibletoc}{\thevisibletoc}}
\etocsetlevel{visibletoc}{6}
%--------
% add-ons for the `fancy TOC' (2013/01/25)
    \newcounter{dummypart}
    \newcounter{dummychapter}
    \newcounter{dummysection}
    \etocsetlevel{dummypart}{6}
    \etocsetlevel{dummychapter}{6}
    \etocsetlevel{dummysection}{6}
%--------
% for "Another compatibility mode"  (2013/02/21):
% attention au 5 qui est hard-coded 
% (pour 1.07f c'était 3, maintenant 5 pour 1.07g; et 4 maintenant pour 1.07h...)
% (et pour 1.07i.. à nouveau 3 faudra vraiment que je change cela)
% et maintenant =4 pour version de la doc du 28 avril 2014... faudra vraiment qu
% je mette un mécanisme plus robuste pour cette TOC.
\makeatletter
\newcommand*{\MyQuasiStandardTOC}[1]{%
  \begingroup
  \let\savedsectionline\l@section
  \let\savedsubsectionline\l@subsection 
  \etocsetstyle{section}{}
    {\ifnum\etocthenumber=4 % <- check this if new sections added to user manual
      \etocsetstyle{subsection}
        {\par\nopagebreak\begingroup
         \leftskip1.5em \rightskip\@tocrmarg
         \parfillskip \@flushglue 
         \parindent 0pt
         \normalfont\normalsize\rmfamily\itshape
         \etocskipfirstprefix}
        {\allowbreak\,--\,}
        {\etocname\ \textup{(\etocnumber)}}
        {.\par\endgroup}%
     \else
        \etocsetstyle{subsection}{}{}
        {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
     \fi} 
    {\savedsectionline
      {\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}
    {}%
  \etocstandarddisplaystyle
  \etocsetnexttocdepth {2}%
  \tableofcontents #1
  \endgroup}
\makeatother
%--------
% Statistics on sections and subsections in a part \thispartstats:
% 2 mars 2013
% cette version utilise des box, plutôt que des macros.
% mais on ne peut plus alors changer de police etc...

% 11 octobre 2013, je retire les \color{teal}.

\newsavebox\firstnamei
\newsavebox\firstnumberi
\newsavebox\lastnamei
\newsavebox\lastnumberi
\newsavebox\firstnameii
\newsavebox\firstnumberii
\newsavebox\lastnameii
\newsavebox\lastnumberii
\newcounter{mycounti}
\newcounter{mycountii}

\newcommand*{\thispartstatsauxi}{}
\newcommand*{\thispartstatsauxii}{}
\newcommand*{\oldtocdepth}{}

\newcommand*{\thispartstats}{%
  \setcounter{mycounti}{0}%
  \setcounter{mycountii}{0}%
  \def\thispartstatsauxi{%
         \sbox{\firstnamei}{\etocname}%
         \sbox{\firstnumberi}{\etocnumber}%
         \def\thispartstatsauxi{}}%
  \def\thispartstatsauxii{%
         \sbox{\firstnameii}{\etocname}%
         \sbox{\firstnumberii}{\etocnumber}%
         \def\thispartstatsauxii{}}%
  \begingroup
  \etocsetstyle{subsection}
    {}
    {}
    {\thispartstatsauxii
     \stepcounter{mycountii}%
     \sbox{\lastnameii}{\etocname}%
     \sbox{\lastnumberii}{\etocnumber}}
    {}
\ifnum\ForEnglish=1
  \etocsetstyle{section}
    {}
    {}
    {\thispartstatsauxi
     \stepcounter{mycounti}%
     \sbox{\lastnamei}{\etocname}%
     \sbox{\lastnumberi}{\etocnumber}}
    {Here are some statistics for this part: it contains \arabic{mycounti}
      section\ifnum\value{mycounti}>1 s\fi{} and
      \arabic{mycountii} subsection\ifnum\value{mycountii}>1 s\fi. The name of
     the first section is 
     ``\unhbox\firstnamei{}'' and the corresponding number is 
     ``\unhbox\firstnumberi''. The name of the last section is 
     ``\unhbox\lastnamei{}'' and its number is
     ``\unhbox\lastnumberi''. 
     \ifnum\value{mycountii}>0 The name of
     the first subsection is 
     ``\unhbox\firstnameii{}'' and the corresponding number is 
     ``\unhbox\firstnumberii''. The name of the last subsection is 
     ``\unhbox\lastnameii{}'' and its number is
     ``\unhbox\lastnumberii''.\fi }
\fi
\ifnum\ForDeutsch=1 
  \etocsetstyle{section}
    {}
    {}
    {\thispartstatsauxi
     \stepcounter{mycounti}%
     \sbox{\lastnamei}{\etocname}%
     \sbox{\lastnumberi}{\etocnumber}}
% Hier wird ein Befehl definiert, der fuer jedes Teil ein paar Fakten sammelt
% und ausgibt. 
    {Zu Beginn wollen wir ein paar Fakten zu diesem Teil nennen. Er enthält
     \arabic{mycounti} Abschnitt\ifnum\value{mycounti}>1 e\fi{} und 
      \arabic{mycountii} Unterabschnitt\ifnum\value{mycountii}>1 e\fi. Der Name des ersten 
      Abschnitts lautet
     \glqq\unhbox\firstnamei{}\grqq~und er hat die Gliederungsnummer 
     \glqq\unhbox\firstnumberi\grqq. Der Name des letzten Abschnitts lautet 
     \glqq\unhbox\lastnamei{}\grqq~und er hat die Nummer
     \glqq\unhbox\lastnumberi\grqq. 
     \ifnum\value{mycountii}>0  Der erste 
     Unterabschnitt heißt 
     \glqq\unhbox\firstnameii{}\grqq~und er hat die Nummer 
     \glqq\unhbox\firstnumberii\grqq. Der Name des letzten Unterabschnitts ist 
     \glqq\unhbox\lastnameii{}\grqq~und dessen Nummer ist
     \glqq\unhbox\lastnumberii\grqq.\fi }% 
\fi
  \etocinline 
% october 10, 2013. 
  \etocsetnexttocdepth {2}%
  \etocsettocstyle {\pdfbookmark[1]{Statistics}{\thepart.STATS}}{}
  \localtableofcontents
  \endgroup
}
%%
% pour les TOC à la TikZ
\newtoks\treetok
\newtoks\parttok
\newtoks\sectiontok
\newtoks\subsectiontok
\newtoks\tmptok

\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
  #1\expandafter\expandafter\expandafter{\expandafter\the\expandafter #1#2}}

% 12 et 13 mars 2015 pour la mind map de title page
% pour les Mindmap avec branch color
\def\appendpart #1#2#3{% 
   \edef\tmpstuff {\the#1 child [branch color = #3]{\the#2}}%
   #1\expandafter {\tmpstuff }%
}

% Vendredi 13 mars 2015 à 18:10:40
% POUR LA TOC DE TITLE PAGE
\usepackage{eso-pic}
\usepackage{picture}

\newcount\tikznumberofcurrentgrandchild

\def\tikzmycustomgrowth {%
  \pgftransformreset
  \ifnum\tikztreelevel=1
    \pgftransformrotate {(\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild-1)}%
  \fi
  \ifnum\tikztreelevel=2
    \pgftransformrotate {(\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentgrandchild-4)}%
    \global\advance\tikznumberofcurrentgrandchild by 1
 \fi
 \pgftransformxshift {\the\tikzleveldistance}%
}

\newcounter{partco}
% 1,2,3,4,5,... -> 1,2,3,1,2,3,1,2,3
\def\pseudomodthree #1{\numexpr #1 + 3 - 3*((#1+1)/3)\relax}

% For etoc.toctree file was used to test the Mind map separately
%\newwrite\TOCasTree

\newbox\TitlePageMindmapTOC


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\etoc{%
        \texorpdfstring{{\color{joli}\ttfamily\bfseries etoc}}{etoc}\xspace}

\DeclareRobustCommand\csa [1] {{\ttfamily\hyphenchar\font45 \char`\\ #1}}

\DeclareRobustCommand\csb [1] 
                {\hyperref[#1] {\ttfamily\hyphenchar\font45 \char`\\ #1}}

\newcommand\cshyp[1]{\texorpdfstring{\csa{#1}}{\textbackslash #1}}

\newcommand\csbhyp[1]{\texorpdfstring{\csa{#1}}{\textbackslash #1}}

\newcommand\toc{\csa{table\-of\-con\-tents}\xspace}
\newcommand\localtoc{\csa{local\-table\-of\-con\-tents}\xspace}

\newcommand\lowast{\raisebox{-.25\height}{*}}
\newcommand\starit[1]{\csa{#1\lowast}}
\newcommand\staritb[1]{\csb{#1}\lowast}

\hyphenation{toc-depth sec-num-depth con-tents-line}
\hyphenation{etoc-tan-dard-lines
etoc-de-fault-lines
etoc-toc-lines
etoc-set-style
etoc-name
etoc-page
etoc-skip-first-pre-fix
etoc-num-ber
etoc-if-first
etoc-if-num-bered
etoc-the-name
etoc-the-num-ber
etoc-the-page
etoc-link
etoc-the-linked-name
etoc-the-linked-num-ber
etoc-the-linked-page
etoc-the-link
etoc-set-level
etoc-set-toc-depth
etoc-set-next-toc-depth
etoc-set-toc-depth
etoc-obey-toc-toc-depth
etoc-ig-nore-toc-depth
etoc-depth-tag
etoc-set-tag-depth
etoc-obey-depth-tags
etoc-ig-nore-depth-tags
etoc-stan-dard-dis-playstyle
etoc-set-toc-style
etoc-mul-ti-col-style
etoc-mul-ti-col
etoc-lo-cal-mul-ti-col
etoc-toc-style
etoc-toc-style-with-marks
etoc-toc-style-with-marks-nouc
etoc-ruled-style
etoc-ruled
etoc-lo-cal-ruled
etoc-framed-style
etoc-framed
etoc-lo-cal-framed
etoc-in-line
etoc-af-ter-ti-tle-hook
etoc-af-ter-con-tents-hook
etoc-af-ter-toc-hook
etoc-skip-first-pre-fix
etoc-only-on-first}

\hyphenation{ 
etoc-font-mi-nus-two 
etoc-font-mi-nus-one 
etoc-font-zero 
etoc-font-one 
etoc-font-two 
etoc-font-three 
etoc-sep-mi-nus-two 
etoc-sep-mi-nus-one 
etoc-sep-zero 
etoc-sep-one 
etoc-sep-two 
etoc-sep-three 
etoc-mi-nus-two-left-mar-gin 
etoc-mi-nus-two-right-mar-gin 
etoc-mi-nus-one-left-mar-gin 
etoc-mi-nus-one-right-mar-gin 
etoc-base-line-spread-mi-nus-two 
etoc-base-line-spread-mi-nus-one 
etoc-base-line-spread-zero 
etoc-base-line-spread-one 
etoc-base-line-spread-two 
etoc-base-line-spread-three 
etoc-toc-line-lead-ers 
etoc-ab-brev-page-name 
etoc-part-name 
etoc-book-name 
etoc-above-toc-skip 
etoc-be-low-toc-skip 
etoc-column-sep 
etoc-mul-ti-col-sep 
etoc-mul-ti-col-pre-tol-er-ance 
etoc-mul-ti-col-tol-er-ance 
etoc-de-fault-nb-col 
etoc-in-ner-top-sep 
etoc-top-rule 
etoc-top-rule-col-or-cmd 
etoc-in-ner-left-sep 
etoc-in-ner-right-sep 
etoc-in-ner-bot-tom-sep 
etoc-left-rule 
etoc-right-rule 
etoc-bot-tom-rule 
etoc-left-rule-col-or-cmd 
etoc-right-rule-col-or-cmd 
etoc-bot-tom-rule-col-or-cmd 
etoc-bkg-col-or-cmd 
etoc-framed-mp-hook}

\hyphenation{next-toc-with-tags}
\frenchspacing

\renewcommand\familydefault\sfdefault

% for illustration only. Not to be recommended in general.
\setcounter{secnumdepth}{4}

\begin{document}%\layout
\rmfamily
\thispagestyle{empty}

%-------------------------------------------------------------------------------
% THIS IS TO AVOID TEX BEING CONFUSED BY CONDITIONALS IN FALSE BRANCHES
\catcode1 0
\catcode92 12

^^Aifnum^^AForEnglish=1

    ^^Acatcode92 0 

% START ENGLISH VERSION
\bookmark[named=FirstPage,level=1]{Title page}

\begingroup
\etocsetstyle{part}
  {\etocskipfirstprefix}
  {\ifcase\pseudomodthree{\value{partco}}%
   \or  \appendpart\treetok\parttok {teal!60}%   first
   \or  \appendpart\treetok\parttok {yellow!80}% second
   \else\appendpart\treetok\parttok {green!50}%  third and next ...
   \fi
   }
  {\stepcounter{partco}%
   \edef\treenode{node
                  {\unexpanded\expandafter{\etocthelinkednumber}. 
                   \unexpanded\expandafter{\etocthelinkedname}}}%
% grosse astuce: la première Partie ne sera pas embêtée par les trois sections
% avant car ce qu'elles auront mis dans \parttok va être effacé.
   \parttok\expandafter{\treenode}}
  {\ifcase\pseudomodthree{\value{partco}}%
   \or  \appendpart\treetok\parttok {teal!60}%   first
   \or  \appendpart\treetok\parttok {yellow!80}% second
   \else\appendpart\treetok\parttok {green!50}%  third and next ...
   \fi
   }

\etocsetstyle{section}
  {}
  {}
  {% define the section node
   \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber} 
                        \unexpanded\expandafter{\etocthelinkedname}}}}%
   \appendtotok\parttok\childnode }
  {}

\etocsetnexttocdepth{section}

\etocsettocstyle
  {\setcounter{partco}{0}%
   \treetok{\node [root concept]{\normalfont{The \etoc package}\par {\normalsize\textsc
    {Jean-François Burnol}\par \ttfamily jfbu (at) free (dot) fr}\par
  {\normalsize Package
    version:\par \etocpkgversion{} (\etocpkgdate )\par}}}}
  {\global\appendtotok\treetok{ ;}}

\etocinline\tableofcontents\label{toc:mindmaptitlepage}

% \immediate\openout\TOCasTree=\jobname.toctree
% \immediate\write\TOCasTree{\the\treetok}%

\tikzset {branch color/.style={concept color=#1!white,
             every child/.append style={concept color=#1!white!30!white}}%
         }%

\global
\setbox\TitlePageMindmapTOC\hbox {\begingroup
\resizebox{.9\paperwidth}{!}{%
\begin{tikzpicture}[mindmap,
                    text width=2cm,
                    align = flush center,
                    growth function=\tikzmycustomgrowth,
                    nodes={concept},
                    concept color=orange!60,
                    root concept/.append style={font=\huge, text width = 6cm},
                    level 1/.append style={level distance=7cm, sibling angle=360/8},% 8 hard-coded mais je pourrais aussi le calculer
                    level 1 concept/.append style={font=\Large, text width = 3cm},
                    level 2/.append style={level distance=12.5cm, sibling angle=360/35},% 35 hard coded mais je pourrais aussi le calculer
                    % distance par rapport au CENTRE ! (avec le code tel qu'en ce moment)
                   ]
\the\treetok
\end{tikzpicture}}\endgroup }
\endgroup

\indent\null
\begingroup
 \let\thefootnote\empty
 \footnote{Documentation (\etocdocdate) generated from the source file
  with timestamp ``\etocdtxtimestamp''.}
\endgroup
\setcounter{footnote}{0}

\AddToShipoutPictureFG*{\put(10.5cm,16.85cm)
                        {\makebox(0,0){\box\TitlePageMindmapTOC}}}

\clearpage

\etocdepthtag.toc {preamble}

%----
% MAIN TOC
%
\etocsettocdepth {subsubsection}
\etoctoclines
\etocmarkboth\contentsname
\etocmulticolstyle[1]
     {\pdfbookmark[1]{Table of contents}{MAINTOC}%
      \noindent\bfseries\Large
      \leaders\hrule height1pt\hfill
      \MakeUppercase{Table of Contents}}

\begingroup
  \etocsetlevel{subsection}{3}
  \etocsetlevel{subsubsection}{6}
  \tableofcontents \label{toc:main}
\endgroup

\phantomsection\addcontentsline{toc}{section}{\abstractname}
\begin{abstract}
  The \etoc package gives to the user complete control on how
  the entries of the table of contents should be constituted
  from the \emph{name}, \emph{number}, and \emph{page number}
  of each sectioning unit. This goes via the definition of
  \emph{line styles} for each sectioning level used in the
  document. The package provides its own custom line styles.
  Simpler ones are given as examples in the documentation. The
  simplest usage will be to take advantage of the layout facilities
  of packages dealing with list environments.
  
  Regarding the \emph{global toc display}, \etoc provides pre-defined styles
  based on a multi-column format, with, optionally, a ruled title or framed
  contents.

  The \csa{tableofcontents} command may be used arbitrarily many times and it
  has a variant \csa{localtableofcontents} which prints tables of contents
  `local' to the current surrounding document unit. An extension of the
  \csa{label}/\csa{ref} syntax allows to reproduce (with another layout) a local
  table of contents defined somewhere else in the document.

  Via ``depth tags'', one gets an even finer control for each table of contents
  of which sectioning units it should, or not, display.

  The formatting inherited (and possibly customized by other
  packages) from the document class will be used when in
  \emph{compatibility mode}.

  The assignment of levels to the sectioning units can be changed at any
  time, and \etoc can thus be used in a quite general manner to
  create custom ``lists of'', additionally to the tables of contents
  related to the document sectioning units. No auxiliary file is used
  additionally to the standard |.toc| file.
\end{abstract}

\section{Foreword}

Popular packages dealing with TOCs include |tocloft|, |titletoc|
and |minitoc|. Why another one? I started \etoc
for my own use, and found out only later about these mentioned
packages.

As is well explained in the |tocloft| package documentation,
the standard \LaTeX{} layout for the Table of Contents is
buried in the class definitions. In particular, most of the
lengths therein are hardcoded, and the only way for the user
to change them is to recopy the class definitions into the
document and then change them to obtain what is desired
(within suitable \csa{makeatletter} and \csa{makeatother}).
The more reasonable alternative is to use a dedicated package such as
|tocloft| or to use another flexible document class.

However, although now things are hopefully not hard-coded, one
still has to go through the package or class interface. This
means one has to memorize a (possibly large) number of macros
which will serve only to this task, and one will always be
constrained to customizing one initially given layout.

The spirit of \etoc is something else. The user will deal with
the \emph{name}, the \emph{number} and the \emph{page number}
corresponding to each document sectional division (and
found in a line of the |.toc| file) in a completely arbitrary
manner: they are made available via the \csb{etocname},
\csb{etocnumber}, and \csb{etocpage} commands. 

\etoc appears to be (at least partially) compatible with the
|article|, |book|, |report|, |scrartcl|, |scrbook|, |scrreprt| and
|memoir| classes. Starting with release |1.07k| it is possible to
use \etoc concurrently with  package |tocloft|.

\section{License}

\begingroup\ttfamily\small\hyphenchar\font -1
           \parindent0pt 
           \obeyspaces\obeylines %
\etocLicense\endgroup


\clearpage

\etocsettocdepth {subsection}

\etocdepthtag.toc{overview}

\part{Overview}\label{part:overview}

\thispartstats

\invisiblelocaltableofcontents \label{toc:overview}

\section{Do I need to be a geek to use \etoc?}

Not quite. The simplest way is to use |enumerate| environments,
with the customizing facilities of packages such as
|enumitem|,\footnote{\url{http://ctan.org/pkg/enumitem}} to
display the data fetched by \etoc from the |.toc| file. The data
consists of the \emph{name} (\csb{etocname}), \emph{number}
(\csb{etocnumber}), and \emph{page number} (\csb{etocpage}) as
extracted
% \footnote{although \LaTeX{} has been promoted as
%   separating contents from form, there are some areas where its
%   real implementation is very far from this ideal. And the |.toc|
%   file is a case in point; not to mention the hard-coded
%   dimensions, with use of the @ sign,
%   in the macros responsible for constructing the typeset table of
%   contents.} 
from the |.toc| file.

This is
illustrated \hyperref[toc:a]{at the start} of
\autoref{part:linestyles}. More
sophisticated examples would use more sophisticated |enumitem|
options. One may say then that again the user has to memorize some
customizing! indeed, but the syntax and option names to memorize
are in no way related only to matters of tables of contents, hence
an economy of use of the poor brain.

% People who
% know the internals of \LaTeX2e well (which is not my case) could
% happily use directly a |\list| command;  

Next in ease of use, perhaps, is the method explained
\hyperref[sec:firstexample]{later in this part} (\autoref{sec:firstexample}).
For this some knowledge of |\leftskip|, |\rightskip|, etc... is necessary. And a
slight elaboration of this method, whose code is to be found in
\autoref{ssec:tocwithdepthtags}, allows to mimick very well, if so desired, the
standard looks.

As will be amply illustrated in this manual, \etoc is quite
versatile (especially as it allows to re-define at any point in
the document the hierarchy of sectioning units) and one can
achieve surprising effects with it: \autoref{part:surprising} is
devoted to this, and some more is to be found in
\autoref{part:tipsandtricks}.

\begin{framed}
\setcounter{mycounti}{0}%
  \etocinline
\etocsetlevel{part}{1}
\etocsetlevel{chapter}{1}
\etocsetlevel{visibletoc}{0}
\etocsetstyle{visibletoc}
    {}
    {\stepcounter{mycounti}}
    {}
    {}
\etocsettocstyle{}{}
\etocsetnexttocdepth{0}
\tableofcontents
A very important aspect of \etoc is that it is geared towards making many TOCs
in the same document, \emph{using only one |.toc| file}! The present
documentation contains \arabic{mycounti} visible tables of contents (and a few
invisible ones) and uses only one |.toc| file!\footnotemark{} So one should
think 
twice before adding manually extra commands to the |.toc| file (see
\autoref{sec:addingtotoc}).
\end{framed}

\footnotetext{and the counting itself has been achieved by a table of contents
  which was inserted in the framed paragraph! \dots the technique for this kind
  of effect will be explained later.}


\subsection{Limitations in the use of list environments for
  tables of contents}
\label{ssec:limitations}

There are some limitations to the use of list environments
for typesetting TOCs. One of them is intrinsic to the scope
limitations created by the groups associated to the
environments: the |.toc| file
may contain, besides the information to be typeset in the
TOCs, some other commands, such as language changing
commands, which do not expect to see their scope limited in
this way inside a group (\LaTeX's environments create groups).

Therefore the built-in ``line styles'' proposed by \etoc as an example (and
which are illustrated\footnote{with a twist, subsections having been downgraded
  to the subsubsection style\dots} by the \hyperref[toc:main]{main table of
  contents} in this document) do not make use of environments. Actually, in this
user manual, only the \hyperref[toc:a]{table of contents} at the start of
\autoref{part:linestyles} and the \autoref{toc:allsubsections} (which is a TOC!)
have their line styles expressed in terms of enumerate environments.

\section{Line styles and toc display style}

A distinction shall be made between the \emph{line styles},
\emph{i.e.} the way the name, number and page numbers are
used at each level, and the \emph{toc display style} (for
lack of a better name) which tells how the title should be
set, whether an entry in the |.toc| file should be made,
whether the contents should be typeset with multiple columns,
etc... the latter is governed by the command
\csa{etocsettocstyle} (or some higher-level commands) and the
former by the command \csa{etocsetstyle}.


\subsection{\csbhyp{etocsetstyle} for the line styles}

The command to inform \etoc of what to do with \csa{etocname}, \csa{etocnumber},
and \csa{etocpage} is called \csb{etocsetstyle}. It has five mandatory
arguments. The first one is the name of the sectional unit: a priori known names
are |book|, |part|, |chapter|, |section|, |subsection|, |subsubsection|,
|paragraph|, and |subparagraph|, and any other name can be declared and assigned
to a (numeric) level via the \csb{etocsetlevel} command.\footnote{under the
  \texttt{memoir} class, \etoc knows \texttt{appendix} as a sectioning
  name.} 

The four other arguments of \csb{etocsetstyle} specify: 1) \emph{what to do when
  this level is first encountered, down from a more general one,} then 2) \& 3)
(two arguments, a `prefix' and a `contents') \emph{what to do when a new entry
  of that type is found,} and 4) \emph{the last argument is the code to execute
  when a division unit of higher importance is again hit upon.}

\subsection{\csbhyp{etocsettocstyle} for the toc display}

The \csb{etocsettocstyle} command allows to specify what
should be done before and after the line entries of the TOC
are typeset, and in particular how the title should be
printed. It has two arguments, the first one is executed
before the TOC contents (typically it will print
``Contents'' and define suitable marks for the page headings) and
the second is executed after the TOC contents.

\etoc provides four (customizable) higher level toc styles:
\csb{etocmulticolstyle}, \csb{etoctocstyle},
\csb{etocruledstyle}, and \csb{etocframedstyle}. All use the
|multicol| package with a default of two columns
(single-column mode is obtained with the optional argument |[1]|).

These commands must be followed either by \toc or \localtoc.

\subsection{Compatibility mode}\label{ssub:compat}
\label{etoctoclines}
\label{etocstandardlines}

Both for the ``line styles'' and the ``toc display style'', it is
possible to switch into a compatibility mode which uses the
defaults from the
document class.\footnote{for the ``toc display style''
  \etoc checks if it knows the class, and if not defaults to
  the |article| class layout. It will also check if
  \texttt{tocloft} has customized the TOC title.} 
This is activated by:\\
\makebox[5.2cm][l]{\csb{etocstandardlines}}
 |% `line entries' as without \usepackage{etoc}|\\
\makebox[5.2cm][l]{\csb{etocstandarddisplaystyle}}
 |% `toc display'  as without \usepackage{etoc}|


If the command \csa{etocsetstyle} has \emph{not been used in the
preamble} the package will be at |\begin{document}| in this
  compatibility mode: hence just adding \csa{usepackage\{etoc\}}
  should hopefully not change anything to the look of a
  previously existing document, under the |article|, |book|,
  |report|, |scrartcl|, |scrbook|, |scrreprt| and |memoir|
  classes.

  Any use of \csa{etocsetstyle} in the \emph{preamble or body} of
  the document turns off from that point on the compatibility mode
  for line styles, but maintains the compatibility mode for the
  TOC title. One re-activates the compatibility mode for line
  styles with \csb{etocstandardlines}; and 
  \csb{etoctoclines} will re-activate the line styles as defined
  with the help of \csa{etocsetstyle}, if their scope was not
  limited to a group or environment.

  The command \csb{etocdefaultlines} resets the line styles as
  pre-defined internally by \etoc and described in
  \autoref{etocdefaultlines}.

Even if \csb{etocsetstyle} has been used, the global display style
remains initially as defined by the document class (or the
|tocloft| package); one needs to use the command
\csb{etocsettocstyle} or its variants to exit from this
compatibility mode at the ``toc display style'' level. It will be
re-activated if use if made of \csb{etocstandarddisplaystyle}.

\section{A first example}
\label{sec:firstexample}

Let us present a first example of specification for line styles.
Immediately after the start of \autoref{part:overview} we inserted in the
source file:
\centeredline{|\invisiblelocaltableofcontents \label{toc:overview}|} This
sets-up the label |toc:overview|, and we can use it at any location in the
document: \centeredline{|\tableofcontents \ref{toc:overview}|} And as we used
|\invisible...|,\footnote{this is a shortcut for setting temporarily the
  |tocdepth| to |-3|, which has the effect to tell \etoc not to print the TOC,
  and not even the heading.} the local TOC will exist only through its clones
elsewhere in the document. 

We could use the line styles defined by \etoc, with \csb{etocdefaultlines}, or
the default document class styles with \csb{etocstandardlines}, but we were a
bit more ambitious here and wanted to design our own. The technique is a simple
one: each heading is in its own paragraph, which may extend on multiple lines;
it is responsible for setting its own |\leftskip|.



\begingroup
\parindent 0pt
\parfillskip 0pt
\leftskip 0cm
\rightskip 1cm
\etocsetstyle {section}
              {}
              {\leavevmode\leftskip 0cm\relax}
              {\bfseries\normalsize\makebox[.5cm][l]{\etocnumber.}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\mdseries\etocpage}}\par}
              {}
\etocsetstyle {subsection}
              {}
              {\leavevmode\leftskip .5cm\relax }
              {\mdseries\normalsize\makebox[1cm][l]{\etocnumber}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\etocpage}}\par}
              {}
\etocsetstyle {subsubsection}
              {}
              {\leavevmode\leftskip 1.5cm\relax }
              {\mdseries\normalsize\makebox[1cm][l]{\etocnumber}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\etocpage}}\par}
              {}
\etocruledstyle[1]{\bfseries \Large My first \etoc: TOC of
  \autoref{part:overview} (\nameref{part:overview})}
\tableofcontents \ref {toc:overview}
\endgroup


This is a simple design which does not make provisions for page breaks
which should be discouraged in-between a section and a subsection
etc\dots{} as we only used it for the table of contents of this part, thus
with sections as top levels, there was no need to specify a style for
parts too (we defined a subsubsection line style but as it turns
out there are no subsubsections in this part). The two commands used are
\csb{etocsetstyle} for specifying the line styles, and
\csb{etocruledstyle} for the TOC global style.

The |\rightskip| is shared by all, and creates space where the page
numbers get printed. For an elaboration of this technique see the next
\autoref{sec:secondexample} as well as \autoref{ssec:tocwithdepthtags}
which provides a TOC with parts and paragraphs. Both allow multi-line
headings and employ a technique for putting page numbers in the right margin
which was inspired from what \LaTeX2e's |\@dottedtocline| macro does.



\begin{verbatim}
\begingroup\parindent 0pt \parfillskip 0pt \leftskip 0cm \rightskip 1cm
\etocsetstyle {section}
              {}
              {\leavevmode\leftskip 0cm\relax}
              {\bfseries\normalsize\makebox[.5cm][l]{\etocnumber.}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\mdseries\etocpage}}\par}
              {}
\etocsetstyle {subsection}
              {}
              {\leavevmode\leftskip .5cm\relax }
              {\mdseries\normalsize\makebox[1cm][l]{\etocnumber}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\etocpage}}\par}
              {}
\etocsetstyle {subsubsection}
              {}
              {\leavevmode\leftskip 1.5cm\relax }
              {\mdseries\normalsize\makebox[1cm][l]{\etocnumber}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\etocpage}}\par}
              {}
\etocruledstyle[1]{\bfseries \Large My first \etoc: TOC of
  \autoref{part:overview} (\nameref{part:overview})}
\tableofcontents \ref {toc:overview}
\endgroup
\end{verbatim}

\section{A second example}
\label{sec:secondexample}

This second example displays only the contents from
\autoref{part:linestyles} and \autoref{part:globalcmds}. This selection
is done via the technique of \emph{depth tags}, described in
\autoref{etocsettagdepth} and \autoref{ssec:tocwithdepthtags}. Its
layout is a bit like the one of the \hyperref[toc:main]{main document
  TOC}, although the line styles are coded very differently.

\begingroup
\newcommand*{\DotsAndPage}
{\nobreak\leaders\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}%
         \hfill\nobreak
         \makebox[\rightskip][r]{\bfseries\normalsize\etocpage}\par}

\etocsetstyle {part}
{\parindent 0pt
 \nobreak
 \etocskipfirstprefix}
{\pagebreak[3]\bigskip}
{\large\rmfamily\bfseries\scshape\centering
 \etocifnumbered{Part \etocnumber{} -- }{}\etocname\par}
{}

\etocsetstyle {section}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
 \nobreak\medskip
 \etocskipfirstprefix}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
 \pagebreak[1]\smallskip}
{\normalsize\rmfamily\bfseries\scshape
 \etocnumber. \etocname\DotsAndPage }
{\parfillskip 0pt plus 1fil\relax }

\etocsetstyle {subsection}
{\leftskip1cm\rightskip .75cm \parfillskip 0pt plus 1fil\relax 
 \nobreak\smallskip}
{}
{\footnotesize\sffamily\mdseries\itshape
 \etocname{} (\etocnumber, p. \etocpage). }
{\par\medskip}

\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {none}
\etocsettagdepth {arbitrarily}{none}
\etocsettagdepth {surprising} {none}
\etocsettagdepth {linestyles} {subsection}
\etocsettagdepth {globalcmds} {subsection}
\etocsettagdepth {custom}     {none}
\etocsettagdepth {tips}       {none}
\etocsettagdepth {code}       {none}

\etocsettocstyle {\centering\LARGE\textsc{\contentsname}\par\nobreak\medskip}{}
\etocsetnexttocdepth {subsection}
\tableofcontents
\endgroup

The code:
\begin{verbatim}
\begingroup
\newcommand*{\DotsAndPage}
{\nobreak\leaders\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}%
         \hfill\nobreak
         \makebox[\rightskip][r]{\bfseries\normalsize\etocpage}\par}

\etocsetstyle {part}
{\parindent 0pt
 \nobreak
 \etocskipfirstprefix}
{\pagebreak[3]\bigskip}
{\large\rmfamily\bfseries\scshape\centering
 \etocifnumbered{Part \etocnumber{} -- }{}\etocname\par}
{}

\etocsetstyle {section}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
 \nobreak\medskip
 \etocskipfirstprefix}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
 \pagebreak[1]\smallskip}
{\normalsize\rmfamily\bfseries\scshape
 \etocnumber. \etocname\DotsAndPage }
{\parfillskip 0pt plus 1fil\relax }

\etocsetstyle {subsection}
{\leftskip1cm\rightskip .75cm \parfillskip 0pt plus 1fil\relax 
 \nobreak\smallskip}
{}
{\footnotesize\sffamily\mdseries\itshape
 \etocname{} (\etocnumber, p. \etocpage). }
{\par\medskip}

\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {none}
\etocsettagdepth {arbitrarily}{none}
\etocsettagdepth {surprising} {none}
\etocsettagdepth {linestyles} {subsection}
\etocsettagdepth {globalcmds} {subsection}
\etocsettagdepth {custom}     {none}
\etocsettagdepth {tips}       {none}
\etocsettagdepth {code}       {none}

\etocsettocstyle {\centering\LARGE\textsc{\contentsname}\par\nobreak\medskip}{}
\etocsetnexttocdepth {subsection}
\tableofcontents
\endgroup
\end{verbatim}

\section{Linked list of the main package commands}

\begingroup\raggedcolumns
\advance\linewidth18pt
\begin{multicols}{3}\parindent0pt\relax
  \csb{etocaftercontentshook}\par
  \csb{etocaftertitlehook}\par
  \csb{etocaftertochook}\par
  \csb{etocbeforetitlehook}\par
  \csb{etocdefaultlines}\par
  \csb{etocdepthtag.toc}\par
  \csb{etocdisplay}\par
  \csb{etocframedstyle}\par
  \csb{etocframed}\par
  \csb{etociffirst}\par
  \csb{etocifnumbered}\par
  \csb{etocignoredepthtags}\par
  \csb{etocignoretoctocdepth}\par
  \csb{etocinline}\par
  \csb{etoclink}\par
  \csb{etoclocalframed}\par
  \csb{etoclocalmulticol}\par
  \csb{etoclocalruled}\par
  \csb{etocmulticolstyle}\par
  \csb{etocmulticol}\par
  \csb{etocname}\par
  \csb{etocnumber}\par
  \csb{etocobeydepthtags}\par
  \csb{etocobeytoctocdepth}\par
  \csb{etocpage}\par
  \csb{etocruledstyle}\par
  \csb{etocruled}\par
  \csb{etocsetlevel}\par
  \csb{etocsetnexttocdepth}\par
  \csb{etocsetstyle}\par
  \csb{etocsettagdepth}\par
  \csb{etocsettocdepth.toc}\par
  \csb{etocsettocdepth}\par
  \csb{etocsettocstyle}\par
  \csb{etocskipfirstprefix}\par
  \csb{etocstandarddisplaystyle}\par
  \csb{etocstandardlines}\par
  \csb{etocthelinkedname}\par
  \csb{etocthelinkednumber}\par
  \csb{etocthelinkedpage}\par
  \csb{etocthelink}\par
  \csb{etocthename}\par
  \csb{etocthenumber}\par
  \csb{etocthepage}\par
  \csb{etoctoccontentsline}\par
  \csb{etoctoclines}\par
%\vspace{5\baselineskip}\hrule height 0pt
\end{multicols}
\endgroup


\clearpage
% 15 octobre, je teste les tags
\etocdepthtag.toc {arbitrarily}

\part{Arbitrarily many TOCs, and local ones too}
% 13 octobre, ceci était une section avant

\thispartstats

\etocsettocstyle{}{}
\etocstandardlines
\localtableofcontents

\section{Labeling and reusing elsewhere}

\etoc allows arbitrarily many \csa{tableofcontents} commands in
your document. The line styles and the toc display style may of
course be changed in-between. Furthermore 
\csa{localtableofcontents} will print local tables of
contents: \emph{i.e.} all sections and sub-units inside a
given chapter, or all subsubsections and lower inside a given
subsection, etc . . .

\etoc allows the labeling of a TOC with (for example)
\csa{label\{toc:A\}} and will redisplay it elsewhere when
told \csa{tableofcontents}\csa{ref\{toc:A\}}. The actual
layout (title inclusive) used for the cloned TOC will be
decided locally. The line styles and toc display style
(including the title) will be the current ones and the
current value of the |tocdepth| counter is obeyed. As an
example the table of contents of 
\autoref{part:custom} is in a \hyperref[toc:d]{float} which appears
\vpageref{toc:d}. 
\begin{figure}[ht!]
  \centering
  \begingroup
  \etocstandardlines 
  \renewcommand{\etocbkgcolorcmd}{\color{green!5}}
  \renewcommand{\etocbelowtocskip}{0pt\relax}
  \fboxsep1ex 
  \etocframedstyle [1]{\fbox{\makebox[.5\linewidth]{\etocfontminusone
        \hyperref[toc:c]{I am from far away}}}}
  \tableofcontents \label{toc:d} \ref{toc:c}
  \endgroup
%%  \centeredline{The original is \hyperref[toc:c]{there}.}
\end{figure}

We used this:
\begin{verbatim}
\begin{figure}[ht!]
  \centering
  \begingroup
  \etocstandardlines 
  \renewcommand{\etocbkgcolorcmd}{\color{green!5}}
  \renewcommand{\etocbelowtocskip}{0pt\relax}
  \fboxsep1ex 
  \etocframedstyle [1]{\fbox{\makebox[.5\linewidth]{\etocfontminusone
        \hyperref[toc:c]{I am from far away}}}}
  \tableofcontents \label{toc:d} \ref{toc:c}
  \endgroup
\end{figure}
\end{verbatim}
Important: one should not use elsewhere \toc|\ref{toc:d}|. To clone again, one
must use a reference to the original label: \toc|\ref{toc:c}|.

\section{A powerful functionality of \etoc: the
  re-assignment of levels with \csbhyp{etocsetlevel}}

The intrinsic levels manipulated by \etoc are numeric: from
|-2| (which corresponds to |book| in the |memoir| class)
down (from the big to the small)
to |5| (|subparagraph|). But the assignment of a numeric level
to a given name can be modified at any time with the command
\csb{etocsetlevel}\marg{level\_name}\marg{number}. In conjunction
with the use of the \LaTeX{} |tocdepth| counter, this has
powerful applications: \meta{level\_name} does not have to
coincide with an actual document sectioning command, and \etoc
can be used to print arbitrary ``lists of things'', using no
other auxiliary file than the |.toc| file. This is
explained further in \autoref{part:surprising}.

\begin{framed}
  It is often said that in the standard classes, the sectioning
  level of |\part| is |0| in the classes not having a |\chapter|
  command, and |-1| in classes having a |\chapter| command. This
  is \emph{correct} for what regards the \emph{automatic
    numbering}, as is governed by the value of the |secnumdepth|
  counter; but it is \emph{wrong} for what regards the effect of
  the |tocdepth| counter: setting the |tocdepth| to |-1| in the
  |article| class just before |\tableofcontents| does \emph{not}
  prevent Parts from appearing in the Table of Contents. One has
  to set it to |-2| for that, whether in the |article| or in the
  |book| class.

  The canonical levels, a priori known to \etoc, are those of
  relevance to the \textbf{|tocdepth|} counter in the standard
  classes and are recapitulated in this table: \centeredline{
    \fbox{\begin{tabular}{rc}
        (|memoir| class) book&-2\\ part&-1\\ chapter&0 \\
        section&1\\ subsection&2 \\
        subsubsection&3 \\ paragraph&4 \\ subparagraph& 5
    \end{tabular}}}

\smallskip With \etoc, the user can easily print a local table of
contents inside a given subsection, where subsubsections will be
printed in the style of sections, paragraphs in the style of
subsections, and subparagraphs in the style of subsubsections, if
so desired. One can also decide to set everything to be at the level
|6| (never displayed by \etoc), except for example
paragraphs, promoted to be at level |1|, and then one obtains a nice
table of contents of all the paragraphs from the document! 
(|tocdepth| at least |1|)\footnotemark
\end{framed}

\footnotetext{and one should naturally not print this TOC of paragraphs in
  compatibility mode, which would insist on inserting a gigantic left
  margin.}

\section{The \csbhyp{etoc\-set\-toc\-depth} and  
  \csbhyp{etoc\-set\-next\-toc\-depth} commands} 
\label{etocsettocdepth}
\label{etocsetnexttocdepth}

The |tocdepth| counter has no bearing on what gets written to the |.toc| file;
its action is only on the actual typesetting of the table of contents: in the
standard classes there is only one |\tableofcontents| possible, whereas with
\etoc, arbitrarily many are allowed, so one may change |tocdepth| to the
appropriate value (which decides the finest sectioning level displayed) again
and again each time a table of contents needs to be typeset.

\etoc provides \csb {etocsettocdepth}\marg{level} whose mandatory argument is
either 
numeric (from |-3| to |5|) or a division name such as |subsection| or
|subsubsection| or any name previously declared to \etoc with
\csb{etocsetlevel} (the keywords |all| and |none| are recognized, although not
corresponding to a document division). 
This does the appropriate |\setcounter{tocdepth}{numeric_level}|.

As is explained in the next subsection, |tocdepth| is used by |hyperref|, and
one must take steps to prevent its changes from influencing the bookmarks, too.
So, \etoc has \csb {etocsetnexttocdepth}\marg{level} whose influence ceases
immediately after the next table of contents. Thus, |\invisibletableofcontents|
is essentially |\etocsetnexttocdepth{none}\tableofcontents|.

The simplest course is thus to have after |\begin{document}| and before the
  first |\tableofcontents| a single instance of the \csb{etocsettocdepth}
  command, with argument the deepest level (or most commonly used deepest level)
  among the tables of contents of the document, and to use locally,
  where needed, \csb{etocsetnexttocdepth} before |\tableofcontents| or
  |\localtableofcontents|.

\subsection{The hyperref option \emph{bookmarksdepth}}
\label{ssec:bookmarksdepth}

When modifying the counter |tocdepth| for the purposes of
multiple uses of \toc or \localtoc, one should be aware that
package |hyperref| by default takes into account the
\emph{current} value of the |tocdepth| counter to decide
whether the |pdf| file will contain a bookmark corresponding
to sectioning commands encountered in the source file. Thus,
one typically needs to reset |tocdepth| to its previous
value after having temporarily modified it for a given table of
contents.

Or, there is the \emph{bookmarksdepth=n} option of package
|hyperref|, with \emph{n} the desired document bookmarks
maximal depth, which can be numeric or the name of a level known to
|hyperref|. This documentation previously passed |bookmarksdepth=3| as
option to |hyperref|, so even if |tocdepth| was left to |1|
by inadvertance after printing a certain table of contents 
this did not modify the bookmark tree of the |pdf| file. Now that
\csb{etocsetnexttocdepth} has been added to the package, we have used it
systematically and there was no need for  |bookmarksdepth=3| anymore.

\section{The command \csbhyp{etoc\-set\-toc\-dep\-th.toc}}
\label{etocsettocdepth.toc}

This command \csb{etocsettocdepth.toc} implements some functionality of
|tocvsec2|\footnote{\url{http://ctan.org/pkg/tocvsec2}. I thank D.B. for drawing
  my attention to the incompatibility of this package with \etoc.}, a package
which however was incompatible with \etoc (it can still be used for its
|secnumdepth|-related commands, but its |toc|-related activities will get
canceled by \etoc) and more-or-less designed for a single table of contents.

The action of \csb{etocsettocdepth.toc} is totally different than the one of
\csb{etocsettocdepth}. Rather than modifying the |tocdepth| counter immediately,
it adds a line to the |.toc| file which, when executed inside a table of
contents will enact this change. 

The command \csb{etocsettocdepth.toc}, like
\csb{etocsettocdepth}, accepts both numeric and named
arguments. In the case of a named argument, the actual numeric
value to be used is not yet decided at the time the |.toc|
file is created; it will be the value currently specified for
the named level at the time each table of contents (not having
done |\etocignoretoctocdepth|) is typeset. 

The |tocdepth| counter will never be set to a value finer than its initial value
at the start of the table of contents: so adding commands
\csb{etocsettocdepth.toc} in the document is a way to \emph{restrict} locally
the depth of the table of contents. For example to prevent inclusion in the
tables of contents of the sub-sub-sections of a given chapter.

This
{\fbox{gets executed in ALL tables of contents.}}

\subsection{The commands \csbhyp{etocobeytoctocdepth} and \csbhyp{etocignoretoctocdepth}}
\label{etocobeytoctocdepth}
\label{etocignoretoctocdepth}


So \csb{etocignoretoctocdepth} is provided to cancel the
\csa{etocsettocdepth.toc} mechanism when
needed; and \csb{etocobeytoctocdepth} will
re-activate it. The package does initially \csb{etocobeytoctocdepth}.


\section{The commands \csbhyp{etoc\-depth\-tag.toc} and \csbhyp{etocsettagdepth}}
\label{etocdepthtag.toc}
\label{etocsettagdepth}

As mentioned above, when the argument to  \csb{etocsettocdepth.toc} isn't
numeric but a named level the actual numeric level used is decided at the time
the TOC gets typeset, thus with the \emph{shuffling abilities of \etoc}, one may
obtain a very flexible control in the following way: one first declares with
\csb{etocsetlevel} some
dummy named level, say |partIII|, assigning it the invisible numeric level |6|.
Then before the actual third |\part| command in the source one inserts
\csb{etocsettocdepth.toc}|{partIII}|. At the location where the effect should
cease one inserts in the source \csb{etocsettocdepth.toc}|{all}|. It is now
possible to specify, each time one wants to typeset a TOC, what will be the
finest level for the entries originating in the third part: one just has to do
\csa{etocsetlevel}|{partIII}{1}| for example. This will limit to sections
(if |tocdepth| was at least at that level at the time \toc is encountered).

This method has some limitations:
\begin{enumerate*}[label={(\roman*)}]
  \item the second argument to \csb{etocsetlevel} must be numeric,
  \item it can not be set to |-3| (which would be necessary if one wanted to
    exclude an entire Book from a TOC in a |memoir| document with multiple such
    Books \dots admittedly a possibly rare case!),
  \item it is a bit of a hack as |partIII| is not a real division unit, but just
    a \emph{tag}.
\end{enumerate*} 

Release |1.07h| has a command \csb{etocdepthtag.toc} which
makes it easier to achieve this variable local control of the |tocdepth| at the
time of typesetting TOCs.

It is used as \csb{etocdepthtag.toc}\marg{tag\_name}, where the \meta{tag\_name}
is anything, and this will put the tag in the |.toc| file. When typesetting a
TOC, one issues a series of commands
\csb{etocsettagdepth}\marg{tag\_name}\marg{level} where the \meta{level} may be
either numeric (from |-3| to |5|) or the name of a division unit known to \etoc,
or |none| or |all|. The effect of the tag inside the |.toc| file will then be to
set the |tocdepth| counter to the desired value, in real time (as mentioned
already, this can not get finer than the initial value of |tocdepth| at the
start of the TOC).

The added flexibility is thus that \csb{etocsetlevel} has not been used in a
kind of hacky way, that one may use named level depths, and the
keywords |none| and |all|.

As usual, once the tag depths have been set, they remain in effect until getting
redefined or seeing their scope expire via the closing of a group or of a
surrounding 
environment. For an example, see \autoref{ssec:tocwithdepthtags}.


\subsection{The commands \csbhyp{etocobeydepthtags} and \csbhyp{etocignoredepthtags}}
\label{etocobeydepthtags}
\label{etocignoredepthtags}


After \csb{etocignoredepthtags}, the |.toc| depth tags are ignored (but
\csb{etocdepthtag.toc} still works). The package does initially
\csb{etocobeydepthtags} which makes \etoc react to the found tags in the
|.toc| file. 





\section{Adding commands to the \texorpdfstring{\texttt{.toc}}{.toc} file}
\label{sec:addingtotoc}

We described above \csb{etocsettocdepth.toc} and \csb{etocdepthtag.toc} which
both insert commands inside the |.toc| file. An even more general mechanism of
adding ``action tags'' to the |.toc| file could be envisioned, but this would
just be a wrapper for direct use of |\addtocontents{toc}{\something}|.

One should be cautious when adding in this way
things
to the |.toc| file. For example, inserting
\csa{addtocontents}|{toc}{\string\clearpage}|
just
before a \csa{part} to fix the problem when some part entry (in
the table of contents) is isolated at the bottom of one page,
will cause problems with multiple TOCs: this \csa{clearpage}
will be executed by \etoc each time a \toc or \localtoc
command is encountered! The more prudent thing is to do
rather: {\csa{addtocontents}|{toc}{\string\myclearpage}|,}
to have a |\let\myclearpage\relax| at the top level of the
document and  to use where needed something like:
\begin{verbatim}
\let\myclearpage\clearpage
\tableofcontents
\let\myclearpage\relax
\end{verbatim}
The |memoir| class has the command \csa{settocdepth} which
writes a \csa{changetoc\-depth} command inside the |.toc| file.
This will impact the typesetting by \etoc of \emph{all} tables
of contents, with (possibly) unexpected results: imagine the
document has \csa{settocdepth}|{chapter}| at some point to
avoid having the sections from subsequent chapters be listed
in the main table of contents. Then a local table of contents
in one of these chapters will print a title but will be
without any entry. 

As the |memoir| class by itself allows multiple\toc
  these issues already arise there,
  independently of \etoc, see page 170 of the |memoir|
  manual.

For this specific issue, the commands \csb{etocsettocdepth.toc},
\csb{etocignoretoctocdepth} and \csb{etocobeytoctocdepth} are the way to go; or
their variants \csb{etocdepthtag.toc} and \csb{etocsettagdepth}.

As an aside, any |\setcounter{tocdepth}{n}| command added directly to the |.toc|
file sees its effect (since release |1.07g|) canceled at the end of each table
of contents, which automatically does a |\setcounter{tocdepth}{previous_value}|
with the value active on entering the table of contents.

\subsection{The hyperref option \emph{hidelinks}}\label{ssec:hidelinks}

The colored links (and also the rectangle links) are a bit
annoying when used in tables of contents, especially when
the document uses \etoc and has plenty of them! One may wish
for having colored links, \emph{except} for those within
table of contents!
Indeed, why would things in TOCs need to be either framed in
rectangles or colored, when the user \emph{already expects
  them to be links}?

I use the following trick:  either in the preamble using
|\AtBeginDocument|, or right after |\begin{document}|, I
  have the command
  \centeredline{|\addtocontents{toc}{\protect\hypersetup{hidelinks}}|}

  \begin{framed}
    All TOCs typeset by \etoc have their contents done
    within a group (as if enclosed in an environment). So
    the command \csa{hypersetup}|{hidelinks}| will be
    executed by \emph{each} TOC, but its effect will be
    limited to that TOC. 
  \end{framed}

  I found out experimentally that the option |hidelinks| could
  indeed be set many times with |\hypersetup| (this is not the
  case of all |hyperref| options).



\section{Two Examples}

\subsection{A Beautiful Thesis example}

Here is another relatively  simple example of use of the package
functionalities. 
Let us set up some line styles. We choose a style for sections and
sub-sections which would be suitable for, respectively, sections and
sub-sections in an average length memoir. The line style specifications have
some redundancy for clarity, and do not care about what to do at possible page
breaks. Also, they do not worry about potential multi-column use.

\begin{verbatim}
\begingroup % we start a group to keep the style changes local
\newlength{\tocleftmargin}    \setlength{\tocleftmargin}{5cm}
\newlength{\tocrightmargin}   \setlength{\tocrightmargin}{1cm}

\etocsetstyle{section}              % will pretend to be a Chapter
{\addvspace{1ex}\parfillskip0pt
 \leftskip\tocleftmargin            % (already done in title)
 \rightskip\the\tocrightmargin plus 1fil
 \parindent0pt\color{cyan}}         % (already done)
{\bfseries\LARGE\upshape\addvspace{1ex}\leavevmode}
{\llap{Chapter\hspace{.5em}{\etocnumber}\hspace{.75cm}}\etocname
 \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}

\etocsetstyle{subsection}           % will pretend to be a Section
{}
{\mdseries\large\addvspace{.5ex}\leavevmode}
{\llap{\etocnumber\hspace{.75cm}}\textit{\etocname}%
 \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}

\def\tmptitle{My Beautiful Thesis}
\etocsettocstyle{\color{cyan}\parindent0pt \leftskip\tocleftmargin
  \leavevmode\leaders\hrule height 1pt\hfill\ 
  \huge\textit{\tmptitle}\par}{\bigskip}

\tableofcontents \ref{toc:overview}
\endgroup
\end{verbatim}


\begingroup
\newlength{\tocleftmargin}
\setlength{\tocleftmargin}{5cm}
\newlength{\tocrightmargin}
\setlength{\tocrightmargin}{1cm}

\etocsetstyle{section}
{\addvspace{1ex}\parfillskip0pt
 \leftskip\tocleftmargin
 \rightskip\the\tocrightmargin plus 1fil
 \parindent0pt\color{cyan}}
{\bfseries\LARGE\upshape\addvspace{1ex}\leavevmode}
{\llap{Chapter\hspace{.5em}{\etocnumber}\hspace{.75cm}}\etocname
 \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}

\etocsetstyle{subsection}
{}
{\mdseries\large\addvspace{.5ex}\leavevmode}
{\llap{\etocnumber\hspace{.75cm}}\textit{\etocname}%
 \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}

\def\tmptitle{My Beautiful Thesis}

\etocsettocstyle{\color{cyan}\parindent0pt\leftskip\tocleftmargin
  \leavevmode\leaders\hrule height 1pt\hfill\ 
  \huge\textit{\tmptitle}\par}{\bigskip}

\tableofcontents \ref{toc:overview}
% And again, for the fun of it:
% \def\tmptitle{My Very Beautiful Thesis}
% \tableofcontents \ref{toc:c}
\endgroup


\subsection{A TOC with a background color}\label{ssec:again}

Let us now try out some more sophisticated line styles. The
display will use the \csa{etocframedstyle} package command, which
requires that the produced table of contents fits on a single
page.
We wrap it up in a \hyperref[toc:floating]{figure environment} showing up
\vpageref{toc:floating}. 


\begin{figure}[htbp!]\centering
\colorlet{subsecnum}{black}
\colorlet{secbackground}{green!30}
\colorlet{tocbackground}{red!20!green!20}

\renewcommand{\etocbkgcolorcmd}{\color{tocbackground}}
\renewcommand{\etocleftrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocrightrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocbottomrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etoctoprulecolorcmd}{\color{tocbackground}}

\renewcommand{\etocleftrule}{\vrule width 3cm}
\renewcommand{\etocrightrule}{\vrule width 1cm}
\renewcommand{\etocbottomrule}{\hrule height 12pt}
\renewcommand{\etoctoprule}{\hrule height 12pt}

\renewcommand{\etocinnertopsep}{0pt}
\renewcommand{\etocinnerbottomsep}{0pt}
\renewcommand{\etocinnerleftsep}{0pt}
\renewcommand{\etocinnerrightsep}{0pt}

\newcommand\shiftedwhiterule[2]{%
    \hbox to \linewidth{\color{white}%
    \hskip#1\leaders\vrule height1pt\hfil}\nointerlineskip
\vskip#2}

\etocsetstyle{subsubsection}{\etocskipfirstprefix}
{\shiftedwhiterule{\leftskip}{6pt}}
{\sffamily\footnotesize
\leftskip2.3cm\hangindent1cm\rightskip.5cm\noindent
\hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
\rlap{\hbox to .5cm{\hss\etocpage\hskip.1cm}}\par
\nointerlineskip\vskip3pt}
{}

\etocsetstyle{subsection}{\etocskipfirstprefix}
{\shiftedwhiterule{1.5cm}{6pt}}
{\sffamily\small
\leftskip1.5cm\hangindent.8cm\rightskip.5cm\noindent
\hbox to .75cm{\color{subsecnum}\etocnumber\hss}%
\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
\rlap{\hbox to .5cm{\hss\etocpage\hskip.1cm}}\par
\nointerlineskip\vskip3pt}
{}

\newcommand{\coloredstuff}[2]{%
            \leftskip0pt\rightskip0pt\parskip0pt
            \fboxsep0pt % \colorbox uses \fboxsep also when no frame!
       \noindent\colorbox{secbackground}
               {\parbox{\linewidth}{%
                    \vskip5pt
                    {\noindent\color{#1}#2\par}\nointerlineskip
                    \vskip3pt}}%
       \par\nointerlineskip}

% v1.07l on the occasion of traduction into German documentation:
     % APRIL 26, 2014 Improvement in the section style for better placement of
     % page number when the section name is more than one line long. Use of
     % \makebox rather than \hbox, to be more LaTeX like.
\etocsetstyle{section}
{\coloredstuff{blue}
     {\hfil \bfseries\large Contents of Part One\hfil}}
{\vskip3pt\sffamily\small}
{\coloredstuff{blue}
    {\leftskip1.5cm\rightskip.5cm\parfillskip-\rightskip
     \makebox[0pt][r]{\makebox[.5cm][l]{\etocnumber}}%
     \etocname\hfill{\makebox[.5cm][r]{\etocpage\hspace{.1cm}}}}%
 \vskip6pt}
{}


% attention car \ref{toc:floating} fera référence au compteur de
% toutes les toc, pas visibletoc. 

\etocframedstyle[1]{}
\tableofcontents \label{toc:floating} \ref{toc:overview}
\vspace{-\baselineskip}
\centeredline{|\tableofcontents \ref{toc:overview}| 
(\emph{cf.} \autoref{ssec:again} and \hyperref[toc:clone]{this other toc})}
\end{figure}

The actual design is not pre-built in \etoc; it uses its `framed' style with a
background color. The frame borders have been set to have the same color as the
one serving as background for the entire thing. This design (with other colors)
is in use also for \hyperref[toc:clone]{this other toc}, and the
reader is referred to its \hyperref[ssec:tocclone]{subsection} for the
coding used.

% 11 octobre 2013 ceci était une section avant:
% (17 octobre, je m'aperçois qu'à cause des différents chgts, des
% sous-sections devenant des sections etc... \thisspecialstats ici ne
% faisait pas du tout des statistiques; vaut mieux supprimer et faire
% simplement \localtableofcontents pour maintenir le même layout.)

% les \clearpage sont embêtants; surtout si je prétends qu'on peut
% recompiler facilement sous d'autres conditions...

% on va plutôt faire un \vspace suffisant, cela sera un moindre mal

%\vspace{1cm}

\clearpage
\etocdepthtag.toc {surprising}
\part{Surprising uses of \etoc}
\label{part:surprising}

\thispartstats %% (pas de sous-section)

\etocstandardlines
\etocsettocstyle {}{}
\localtableofcontents

\section{The TOC of TOCs}

\begingroup % \endgroup just after the \tableofcontents command
\etocinline
\etocsetlevel{part}{1}
\etocsetlevel{visibletoc}{0}
\etocsetstyle{visibletoc}
    {\etocskipfirstprefix}
    {, }
    {{\color{niceone}\etocname}}
    {}
\etocsettocstyle{}{}
\etocsetnexttocdepth{visibletoc}


Here is the numbered and linked list of all tables of contents which are
displayed within this document:\footnote{The TOCs put in
  floats may change the order: the numbers are listed
  in the order the TOCs are typeset in the document; but the numbering
  itself is from the order of the TOCs in the \emph{source} of
  this document... }
\tableofcontents\endgroup. And to obtain
it here we just wrote:\par\smallskip 
{\leftskip1cm\rightskip2cm
  \ttfamily\small\baselineskip11pt \noindent Here is the
  numbered and linked list of all tables of contents which are
  displayed within this
  document:~\string\tableofcontents.\par}

  The preparatory work was the following. First, we defined a
  counter |visibletoc| whose vocation is to get incremented at
  each displayed toc. \etoc has its own private counter but it
  counts all TOCs, even those not displayed because the |tocdepth|
  value was |-2| or |-3|.

  We could have added manually |\refstepcounter{visibletoc}|
  and |\label| commands at all suitable locations in the
  document source, and we would then have used here |\ref|
  commands, but this imposes heavy manual editing of the source.

  There is a much better way: there is a hook
  \csb{etocaftertitlehook} and we told it to increment the
  |visibletoc| counter and to write a line to the |.toc| file,
  in a manner analogous to what sectioning commands such as
  |chapter|, |section|, or |subsection| do. As \etoc
  increments its own private counter even before typesetting
  the title of a table of contents, this provides (most of the
  time) a better link destination than any counter manipulated
  from inside \csa{etocaftertitlehook} (for which the link
  would target the area just after the title). So, rather than
  including |\refstepcounter{visibletoc}| inside
  \csa{etocaftertitlehook}, we just put there
  |\stepcounter{visibletoc}| followed by the command
  \csb{etoctoccontentsline}|{visibletoc}{\thevisibletoc}|. This \etoc
  command \csb{etoctoccontentsline}\marg{level\_name}\marg{name} has the same
  effect as:
  \centeredline{|    ||\addcontentsline{toc}|\marg{level\_name}\marg{name}}
  but its usefulness is to circumvent\footnote{using \csa{addtocontents} rather
    than \csa{addcontentsline}} the patching for automatic creation
  of bookmarks done to \csa{addcontentsline} by the |hyperref| package, 
  as pdf bookmarks don't make 
  much sense here (and would elicit a complaint
  of |hyperref| that the bookmark level is `unknown').\footnote{%
  The package provides a starred variant
  \staritb{etoctoccontentsline}, which does allow the creation
  of bookmarks and has a third mandatory argument which is the
  Level to be used by these bookmarks; depending on the context
  the starred as well as the non-starred variants may be
  profitably preceded by \csa{phantomsection}.}

  Finally, the preamble of the document did
  |\etocsetlevel{visibletoc}{6}|. The level |6| (or anything
  with a higher number) is ignored, even if |tocdepth| has
  value |10| for example; this is independently of whether \etoc
  uses the document class default line styles or its own line
  styles, or the ones defined by the user with the
  \csa{etocsetstyle} command. So there is no need to worry that
  something could go wrong. 

  Then, only here we have set |\etocsetlevel{visibletoc}{0}|. And to display
  only this kind of entries we assign temporarily to |part| and |chapter| level
  |1| (or anything higher than zero) and set |tocdepth| to the value |0|. We
  also did \csa{etocsetstyle\{visibletoc\}\{\string\etocskipfirstprefix\}\{,
    \}\{\string\etocname\}\{\}} which defines an inline display with the comma
  as separator. Finally, as \etoc issues |\par| automatically by default just
  before typesetting a table of contents, we used the command \csb{etocinline}
  (also known as \cs{etocnopar}) which turns off this behavior.

Here are the implementation details:

\begingroup
\begin{verbatim}
   < in the preamble >
\newcounter{visibletoc}
\renewcommand{\etocaftertitlehook}
   {\stepcounter{visibletoc}\etoctoccontentsline{visibletoc}{\thevisibletoc}}
\etocsetlevel{visibletoc}{6}
\begin{document}
   < document body >
\subsection{Surprising uses of etoc}
\begingroup
    \etocinline
    \etocsetlevel{part}{1}
    % \etocsetlevel{chapter}{1} % (no chapters in scrartcl class)
    \etocsetlevel{visibletoc}{0}
    \etocsetstyle{visibletoc}
        {\etocskipfirstprefix}{, }{{\color{niceone}\etocname}}{}
    \etocsettocstyle{}{}     % don't set any title, rules or frame or multicol!
    \etocsetnexttocdepth{visibletoc} % display only the `visibletoc' entries from .toc

Here is the numbered and linked list of all tables of contents which are
displayed within this document: \tableofcontents.
\endgroup
\end{verbatim}

\endgroup

After |\etocsetstyle{visibletoc}{..}{..}{..}{..}|, all future TOCs (not in
compatibility mode) will use the
defined style for level |0| (which is normally the level for
chapters). To keep these changes strictly local the simplest
manner is to put everything inside a group.

The \autoref{subsec:interverting} gives another use of the
shuffling of levels. 


\section{Arbitrary ``Lists Of...'', \csbhyp{etoctoccontentsline}}
\label{etoctoccontentsline}

This idea of interverting the levels is very powerful and allows
to let \etoc display lists of arbitrary things contained in the
document. All of that still
using nothing else than the |.toc| file! 
Example: imagine a document with dozens of
exercises, perhaps defined as |\newtheorem{exercise}{}[section]|. Let
us explain how to instruct \etoc to display an hyperlinked list
of all these exercises. For this we put in the preamble:
\begin{verbatim}
 \newtheorem{exerci}{}[section] 
    % the exercice number will be recoverable via \etocname: v--here--v
 \newcommand*{\exercisetotoc}{\etoctoccontentsline{exercise}{\theexerci}}
 \newenvironment{exercise}{\begin{exerci}\exercisetotoc}{\end{exerci}}
 \etocsetlevel{exercise}{6}
\end{verbatim}
In this way, \csa{etocname} will give the exercise number (but \csa{etocnumber}
will be empty). Had we used instead
\begin{verbatim}
 \newcommand*{\exercisetotoc}
    {\etoctoccontentsline{exercise}{\protect\numberline{\theexerci}}}
\end{verbatim}
the exercise number would then have been available via \csa{etocnumber}, and
\csa{etocname} would have been empty. It doesn't matter which one of the two
methods is used. The \etoc command \csa{etoctoccontentsline}|{..}{..}| is
provided as a substitute to \csa{addcon\-tentsline}|{toc}{..}{..}|: this is to
avoid the patching which is done by |hyperref| to \csa{addcontentsline} in its
process of creation of bookmarks. If one wants to authorize |hyperref| to create
bookmarks at a specific level \meta{n}, one can use (here with \meta{n}$=$|2|)
the starred variant \starit{etoctoccontentsline} which has an additional
argument:
\begin{verbatim}
\newcommand{\exercisetotoc}{\etoctoccontentsline*{exercise}{\theexerci}{2}}
\end{verbatim}

The counter |exerci| is already
incremented by the |exerci| theorem environment, and
provides the correct destination for the link added by package
|hyperref|. The command \csa{exercisetotoc} adds for each exercise a line
to the |.toc| file, corresponding to a fictitious document
unit with name `|exercise|'. A
four-column list, including the sections, can then be
typeset with the following code:
\begin{verbatim}
  \etocsetnexttocdepth{2}     % sections are at level 1 and will show up
\begingroup
  \etocsetlevel{exercise}{2}   % but:
  \etocsetlevel{chapter}{3}    %     no chapters
  \etocsetlevel{subsection}{3} %     no subsections
  \etocsetlevel{part}{3}       %     no parts
  \etocsetstyle{exercise}{}{}  % \etocname = exercise number
    {\noindent\etocname\strut\leaders\etoctoclineleaders\hfill\etocpage\par}
    {\pagebreak[2]\vskip\baselineskip}
  \etocsetstyle{section}{}{}
    {\noindent\strut{\bfseries\large\etocnumber\hskip.5em\etocname}\par
     \nopagebreak[3]}{}
  \etocruledstyle[4]{\Large\bfseries List of the exercises}
  \setlength{\columnseprule}{.4pt}
  \tableofcontents
\endgroup
\end{verbatim}


\section{A TOC with a fancy layout}

Here is  a table of contents where
the sections from a given chapter are to be represented by a number
range (like 18--22 for a given chapter, 42--49 for another one ...
of course to be inserted automatically in the TOC). 

This is not an image inclusion, the TOC is produced from its original
|tex| source inserted in this document after replacement of 
|part|, |chapter| or |section| with |dummypart|, |dummychapter| and
|dummysection| (and there is also a dummy page count).  We
copied the line styles used in the original and
displayed the table of contents following:
\begin{verbatim}
    \etocsetlevel{dummypart}  {-1} \etocsetlevel{part}   {2}
    \etocsetlevel{dummychapter}{0} \etocsetlevel{chapter}{2}
    \etocsetlevel{dummysection}{1} \etocsetlevel{section}{2}
                    \etocsetnexttocdepth{dummysection}
\end{verbatim}
Each chapter displays the numbers of only the first and the last sections it
  contains. See the
source file |etoc.dtx| for the details of how this is done. 

Another technique for doing this kind of things is explained in 
  \autoref{ssec:statistics}.  

\begingroup

    \etocsetlevel{dummypart}{-1}
    \etocsetlevel{dummychapter}{0}
    \etocsetlevel{dummysection}{1}
    \etocsetlevel{part}{2}
    \etocsetlevel{chapter}{2}
    \etocsetlevel{section}{2}

    \newif\ifextraidone
    \newif\ifextraiidone

    \etocsetstyle{dummypart}
    {}
    {}
    {\begin{center}\Large\bfseries PART \etocnumber
    \ifextraiidone\\\etocname.\fi\end{center}
    \ifextraidone\else
    \noindent\hskip.7\linewidth
        \hbox to .2\linewidth
% février (ou janvier?) 2013
% je modifie ici en ajoutant un \hss, pour compenser la plus petite
% taille de txrm. Ok.
        {\hss\small\textsc{\bfseries Sections.\hss Page.}}\par\fi
    \extraidonetrue
    }
    {}

    \newcommand\mytocleaders{\hbox to .125\linewidth{...\hss}}
    \etocsetstyle{dummychapter}
    {}
    {\par\noindent\etocifnumbered
        {\makebox[.15\linewidth][r]{\bfseries\etocnumber.}}
        {\hspace*{.15\linewidth}}}
    {\hbox to .65\linewidth
        {\hspace{1em}\etocname\leaders\mytocleaders\hss}%
     \hskip-.1\linewidth
     \hbox to .2\linewidth{\hspace{1.5em}...\hss
                    \etocifnumbered
                        {\etocpage}
                        {\ifextraiidone\else\etocpage\fi}}%
     \hskip-.2\linewidth
    }
    {}

    \newbox\forsectionnumbers
    \makeatletter
% 21 février 2013: je rajoute \color@begingroup et \color@endgroup
    \etocsetstyle{dummysection}
    {\setbox\forsectionnumbers=\hbox to .1\linewidth
        \bgroup\color@begingroup\hss\etocskipfirstprefix}
    {\@gobble}
    {\etocnumber---}
    {\etocnumber\color@endgroup\egroup
    % for reasons I do not quite understand, in some pdf viewers the dots
    % do not completely disappear if here \fboxsep0pt is used.
    % (problèmes liés à l'anti-aliasing, sur Mac OS X, Skim, Preview...)
    % (j'ai maintenu ici la méthode de mon post sur stackexchange, mais
    %  sans doute je pourrais réfléchir à une autre façon évitant d'avoir à
    %  « effacer ») 
        \fboxsep=.5pt\colorbox{white}{\box\forsectionnumbers}\par
        \ifextraiidone\else
            \begin{center}\bfseries Concord.\end{center}
            \noindent\makebox[.15\linewidth][r]{\textsc{\bfseries Lesson.}}\par
        \fi\extraiidonetrue
    }
    \makeatother

    \renewcommand{\etocinnertopsep}{0pt}

    \etocruledstyle[1]{%
        \parbox{\linewidth}{%
            \centering
            \textsc{\bfseries\LARGE\MakeUppercase{Table of Contents}}\\
            \rule{.2\linewidth}{2pt}}%
    }
        
    \etocsetnexttocdepth{dummysection}

    \tableofcontents
   
\makeatletter
    \def\adddummysection {\stepcounter{dummysection}%
      \addtocontents {toc}{\protect\contentsline 
          {dummysection}{\protect\numberline{\thedummysection}}%
                   {\the\dummypage }%
     %\ifEtoc@hyperref ou \ifdefined\hyperref si e-TeX
     {\@currentHref }%
     %\fi
     }}
 
    \def\adddummychapter #1{\stepcounter{dummychapter}%
      \advance\dummypage2
      \addtocontents {toc}{\protect\contentsline 
          {dummychapter}{\protect\numberline{\thedummychapter}#1}%
                   {\the\dummypage }%
     %\ifEtoc@hyperref ou \ifdefined\hyperref si e-TeX
     {\@currentHref }%
     %\fi
     }}


    \def\adddummychapno #1{\advance\dummypage2
      \addtocontents {toc}{\protect\contentsline 
          {dummychapter}{#1}{\the\dummypage }%
     %\ifEtoc@hyperref ou \ifdefined\hyperref si e-TeX
     {\@currentHref }%
     %\fi
     }}

    \def\adddummypart #1{\stepcounter{dummypart}%
       \advance\dummypage4
       \addtocontents {toc}{\protect\contentsline 
          {dummypart}{\protect\numberline{\Roman{dummypart}}#1}%
                     {\the\dummypage }%
     %\ifEtoc@hyperref ou \ifdefined\hyperref si e-TeX
     {\@currentHref }%
     %\fi
     }}
\makeatother
    
    \newcount\dummypage \dummypage-1

    \adddummypart {}
    
    \adddummychapno {Introductory}

    \newcount\tempcount

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<8
    \repeat

    \adddummychapter {Concord of Subject and Verb}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<17
    \repeat

    \adddummychapter {Concord of Substantive and Adjective}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<22
    \repeat

    \adddummychapno {Concord of Relative and its Antecedent}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<25
    \repeat

    \adddummypart {Government}

    \adddummychapter {The Accusative Case}

    \adddummychapno {General uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<30
    \repeat

    \adddummychapno {Particular uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<37
    \repeat

    \adddummychapter {Verbs governing two Accusatives}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<41
    \repeat

    \adddummychapter {The Causal}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<49
    \repeat

    \adddummychapter {The Instrumental Case}

    \adddummychapno {General uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<54
    \repeat

    \adddummychapno {Particular uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<59
    \repeat

    \adddummychapter {The Dative Case}

    \adddummychapno {General uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<65
    \repeat

    \adddummychapno {Particular uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<71
    \repeat

    \adddummychapter {The Ablative Case}

    \adddummychapno {General uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<75
    \repeat

    \adddummychapno {Particular uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<86
    \repeat

    \adddummychapter {The Locative Case}

    \adddummychapno {General uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<92
    \repeat

    \adddummychapno {Particular uses}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<100
    \repeat
\endgroup

\section{Another compatibility mode}

As explained in \autoref{ssub:compat}, the commands
\csa{etocstandardlines} and \csa{etocstandarddisplaystyle} tell \etoc to,
essentially, act as an observer. The document class layout for the table of
contents is then perfectly obeyed. There is no way to customize this standard
layout (change fonts, margins, vertical spacings, etc...) from within the
package. For this, use some package dedicated to this task; because \etoc either
is (temporarily perhaps) in compatibility mode with no customization on its part
possible, or the user has specified the layout in \csa{etocsetstyle} commands
(and \csa{etocsettocstyle}) and is (supposedly...) in complete control.

Well, there is actually an alternative. It is possible to use the
\csa{etocsetstyle} commands to recreate an artificial compatibility mode, in
order to achieve effects like the following, all things being otherwise equal to
the document class defaults:
\begin{enumerate}[noitemsep]
\item get the |hyperref| link to encapsulate only the names, but not the numbers
  of each entry of the table of contents,
\item use the document class style for chapters and sections, but modify it only
  for subsections,
\item do either of the above only for some portions of the table of contents.
\end{enumerate}

Here is how to proceed. One puts in the preamble:
\begin{verbatim}
\makeatletter
\newcommand{\MyStandardTOC}{%
  \begingroup
  \let\savedpartline\l@part
  \let\savedchapterline\l@chapter  %% remove if article/scrartcl class
  \let\savedsectionline\l@section
  \let\savedsubsectionline\l@subsection 
  % and so on if \subsubsection, etc... is used
  % 
  % for the book or article classes:
  \etocsetstyle{part}{}{}
    {\savedpartline{\etocnumber\hspace{1em}\etocname}{\etocpage}}{}%
  % for the scrbook or scrartcl classes:
  \etocsetstyle{part}{}{}
    {\savedpartline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
  % identical in book/article/scrbook/scrartcl classes:
  \etocsetstyle{chapter}{}{}   %%% only for book and scrbook
    {\savedchapterline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
  \etocsetstyle{section}{}{} 
    {\savedsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
  \etocsetstyle{subsection}{}{}
    {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
  % etc... if further sectioning units are used
  % (see the text for what to do with the memoir class)
  \etocstandarddisplaystyle % this is for the title, page-marks, etc...
  \tableofcontents     
  \endgroup}
\makeatother
\end{verbatim}
Of course if the document has only one table of contents then there is no need
to put the commands inside a macro, or even inside a group.\footnote{and if
moreover one just wants to keep the same layout as in the default, one may
question why using \etoc... there is \emph{one} good reason: numbers and names
are separately \texttt{hyperref} links, whereas normally there is only one link
holding both the number and the name corresponding to one toc entry.} With these
commands 
\etoc will construct a TOC completely identical to what would have been done by
one of the document class: |article|, |book|, |scrartcl|, |scrbook|. \footnote{For the
|memoir| class, one needs a bit more: each of the command \csa{booknumberline},
\csa{partnumberline} and \csa{chapternumberline} will have to be saved with a
\csa{let}, and, one then specifies:
\centeredline{%
\csa{etocsetstyle\{chapter\}\{\}\{\}\{\string\savedchapterline\{%
\string\savedchapternumberline}}
\hbox to \linewidth{\hfil\hfil \ttfamily 
        \{\csa{etocnumber}\}\csa{etocname}\}\{\csa{etocpage}\}\}\{\}\hfil} 
(and analogously for |part|, respectively |book|).}
The number and the name of each entry are each separately an |hyperref| link, as
is always the case with \etoc, when not in compatibility mode. Replacing
\csa{etocnumber} with \csa{etocthenumber} will give a TOC where the numbers are
not links anymore, but the names still are. Or one may decide to use \csa{etocthename}
and keep an hyperlinked number with
\csa{etocnumber}. 

Here is a subtler example where one only marginally modifies the
sections (adding color to the number and removing the |hyperref| link) and keeps
the subsections as in the default, \emph{except} for those of one specific
section, for which the layout is completely modified:
\MyQuasiStandardTOC{\ref{toc:overview}}
\bigskip
This example only has sections and subsections, and the code used in \csa{MyStandardTOC} was:
\begin{verbatim}
\etocsetstyle{section}{}
  {\ifnum\etocthenumber=3
      \etocsetstyle{subsection}
        {\par\nopagebreak\begingroup
         \leftskip1.5em \rightskip\@tocrmarg \parfillskip\@flushglue 
         \parindent 0pt \normalfont\normalsize\rmfamily\itshape
         % \columnsep1em
         % \begin{minipage}{\dimexpr\linewidth-\leftskip-\rightskip\relax}%
         % \begin{multicols}{2}%
         \etocskipfirstprefix}
        {\allowbreak\,--\,}
        {\etocname\ \textup{(\etocnumber)}}
        {.\par\endgroup}%
        % {.\par\end{multicols}\end{minipage}\par\endgroup}%
    \else
      \etocsetstyle{subsection}
       {}{}
       {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}
       {}%
    \fi} 
  {\savedsectionline{\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}
  {}%
\end{verbatim}

Notice the page head-mark added by this standard TOC. Sections and subsections
are printed exactly as in the default (except for the subsections of one
specific user-chosen section and except for the color of the section numbers),
with no need to specify explicitely any length, font or other formatting
instructions. But we had to examine the |scrartcl| sources to determine what to
use for \csa{leftskip} and \csa{rightskip} for our customized section
entries.


\section{The TOC as a tree}\label{tocastree}

Using |tikz|\footnote{\url{http://ctan.org/pkg/pgf}} and the package
|forest|\footnote{\url{http://ctan.org/pkg/forest}} we shall display the table
of contents of this part as a tree. The technique is to
use the \etoc modified command \csa{tableofcontents} not for typesetting, but to
prepare a macro, or rather here a \emph{token list} variable, with all the
instructions to be executed later. \textsc{Leslie Lamport}'s book has no mention
whatsoever of token lists, and \LaTeX{} gives the impression to not really
expect the general user to ever hear about them (or delimited macros); this
whole section and the next are thus for 
advanced users.

Putting the \csa{etocnumber} and \csa{etocname}
commands in \csa{treetok} would be of no use: to which number or name would they
then refer to, in a delayed execution? 

We need to store, not the macro names, but the macro contents. And also we wish
to maintain the correct |hyperref| hyperlinks.\footnote{This manual up to the
version of May 14, 2013 used package |tikz-qtree| but there were problems with
hyperlinks. No such problem arises either when using |forest| or the native
|tikz| syntax for trees (which will be illustrated in the next section).} The
commands \csa{etocname}, etc\dots, are robust, it is easier to work with 
\csa{etocthelinkednumber}, \csa{etocthelinkedname}, and \csa{etocthelinkedpage}
which contain the same information in an easier accessible form.

For this |forest| tree we have designed very special \etoc styles for sections
and subsections. They use a token list register called |\treetok| and a
macro |\appendtotok| whose r\^ole is to append to a given token list variable
the contents of a macro given as second argument. All this will happen in
reaction to a |\tableofcontents| command, but \emph{nothing} has yet been
printed in the process.\footnote{There is always a \csa{par}, which here is not
a problem, but can be suppressed if need be via the command \csb{etocinline} or
its synonym \csb{etocnopar}.} This is the later job of a |forest| environment
which will be given the contents of |\treetok|.


% 7 mars: j'utilise \etocthelinkedname défini à partir de 1.07f
% mais bien sûr je sais que ça ne marche pas (sauf dans l'arbre pour le lien de
% la section du bas) dans un QTree. Mais ça marche parfaitement dans un arbre
% TikZ natif.

% 9 septembre 2013: je remplace QTree par Forest, et il n'y a pas de problème
% avec les hyperliens, ça marche out of the box (une fois que j'ai appris un peu
% de sa syntaxe et de celle de TikZ).

\newcommand*\PrepareSectionNode{%
  \tmptok {\centering\bfseries}%
  \appendtotok\tmptok\etocthelinkedname
  \edef\foresttreenode{ [{\noexpand\parbox{2cm}{\the\tmptok}}}% 
}

% 7 mars: j'utilise maintenant \etocthelinkedname
\newcommand*{\PrepareSubsectionNode}{%
  \tmptok {\raggedright}%  j'ai essayé aussi avec \sloppy
  \appendtotok\tmptok\etocthelinkedname
  \edef\foresttreenode{ [{\noexpand\parbox{6cm}{\the\tmptok}}}%
}

\etocsetstyle{section}
  {\etocskipfirstprefix}
  {\appendtotok\treetok{ ]}}
  {\PrepareSectionNode \appendtotok\treetok\foresttreenode}
  {\appendtotok\treetok{ ]}}

\etocsetstyle{subsection}
  {\etocskipfirstprefix}
  {\appendtotok\treetok{ ]}}
  {\PrepareSubsectionNode \appendtotok\treetok\foresttreenode}
  {\appendtotok\treetok{ ]}}

\etocsettocstyle
    {\treetok{[{\hyperref[part:overview]{Overview}}}}
    {\global\appendtotok\treetok{ ]}}


% 11 octobre
% forest ne veut pas @\the\treetok avec un \treetok vide, donc
% il faut lui donner une valeur par défaut.
\treetok{[{run latex again}]}

% 12 octobre
% pour que varioref fonctionne bien, je dois mettre la \tableofcontents
% au plus près de l'environnement forest

\begin{figure}[th!]\centering
 \etocsetnexttocdepth{subsection}
     \tableofcontents \label{toc:forest}\ref{toc:overview}
     \hypersetup{hidelinks}%
     \bracketset{action character=@}
     \begin{forest} 
                  for tree={anchor=center,child anchor=west,
                            grow'=east,draw,thick,
                            edge={draw,thick,dashed,color=teal}},
                  where={level()==1}{circle,thick,fill=blue!5,
                                    before computing xy={l=3cm}}{},
                  where={level()==2}{fill=red!5,
                                    before computing xy={l=6cm}}{},
                  % je trouve ce truc pour une position absolue. OK!
                  rectangle, thick, fill=cyan!5, inner sep=6pt,
     @\the\treetok 
     \end{forest}
     \centeredline{A table of contents displayed as a |forest| tree.}
\end{figure}


The resulting tree has been put in a \hyperref[toc:forest]{float}, which
appears \vpageref[above]{toc:forest}. Here is the 
code used for its production:
\begin{verbatim}
\newtoks\treetok
\newtoks\tmptok

\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
  #1\expandafter\expandafter\expandafter
    {\expandafter\the\expandafter #1#2}}

\newcommand*\PrepareSectionNode{%
  \tmptok {\centering\bfseries}%
  \appendtotok\tmptok\etocthelinkedname
  \edef\foresttreenode{ [{\noexpand\parbox{2cm}{\the\tmptok}}}% 
}

\newcommand*{\PrepareSubsectionNode}{%
  \tmptok {\raggedright}%
  \appendtotok\tmptok\etocthelinkedname
  \edef\foresttreenode{ [{\noexpand\parbox{6cm}{\the\tmptok}}}%
}

\etocsetstyle{section}
  {\etocskipfirstprefix}
  {\appendtotok\treetok{ ]}}
  {\PrepareSectionNode \appendtotok\treetok\foresttreenode}
  {\appendtotok\treetok{ ]}}

\etocsetstyle{subsection}
  {\etocskipfirstprefix}
  {\appendtotok\treetok{ ]}}
  {\PrepareSubsectionNode \appendtotok\treetok\foresttreenode}
  {\appendtotok\treetok{ ]}}

\etocsettocstyle
    {\treetok{[{\hyperref[part:overview]{Overview}}}}
    {\global\appendtotok\treetok{ ]}}

% forest does not like @\the\treetok if \treetok is empty. On first latex
% run, this will be the case because the TOC style defined above will not
% have been executed, as the label {toc:overview} does not refer to a valid 
% TOC yet. So we must give a safe default value to \treetok
\treetok{[{run latex again}]}

\begin{figure}[th!]\centering
     \etocsetnexttocdepth{subsection}
     \tableofcontents \label{toc:forest}\ref{toc:overview}
     \hypersetup{hidelinks}%
     \bracketset{action character=@}
     \begin{forest} 
                  for tree={anchor=center,child anchor=west,
                            grow'=east,draw,thick,
                            edge={draw,thick,dashed,color=teal}},
                  where={level()==1}{circle,thick,fill=blue!5,
                                    before computing xy={l=3cm}}{},
                  where={level()==2}{fill=red!5,
                                    before computing xy={l=6cm}}{},
                  rectangle, thick, fill=cyan!5, inner sep=6pt,
     @\the\treetok 
     \end{forest}
\end{figure}
\end{verbatim}

Why |\hypersetup{hidelinks}|? as explained in
\autoref{ssec:hidelinks}, I prefer the links in TOCs not to be
colorized, nor framed, so this document inserts a command
%\csa{hypersetup}\texttt{\{hidelinks\}} % ok pour hyphénation
%\csa{hypersetup}|{hidelinks}| % pas ok
|\hypersetup{hidelinks}| % ok maintenant 12 octobre 2013
 in the |.toc| file. But at the time the
|\treetok| contents are unpacked the |\hyperlink| commands
originating in
|\etocthelinkedname|, etc\dots{} will be executed in the normal
environment for links (which, in this document, is to colorize
them). Rather than having \etoc's code try to guess what the current ``style''
for links is (a concept not really provided by |hyperref| it
seems) and store it in |\etocthelinkedname|, etc\dots, I opted for
the simpler solution to leave it up to the user to recreate
whatever conditions are desired. So here  it is necessary to re-issue
|\hypersetup{hidelinks}| in the |figure| environment.

There are some other examples in this documentation where
|\tableofcontents| is used to prepare material for later
typesetting:
\begin{itemize}
\item printing the statistics at the start of each Part (see
  \autoref{ssec:statistics}) is done using save boxes (so the problem of the
  appearance of the links does not arise then).
\item the typesetting of the TOC as a table in the pre-|1.08| way (see
  \autoref{ssec:tocastableold}); there we also have to issue
  |\hypersetup{hidelinks}| after having collected the names, numbers and
  page numbers in a token list register.
\item and the two additional tree examples in the next section.
\end{itemize}


\section{The TOC as a molecule}\label{sec:molecule}

It is also possible to construct a TOC tree obeying the TikZ
syntax for trees: but this is a more complicated task for the
\etoc line styles for reasons related to the way braces are
handled by \TeX{} (they need, when filling up the token list to be
always balanced at each step, else complicated tricks must be
employed.)

The simplest strategy is to allocate a token list (or use a macro) for each
level used: we may need a \csa{parttok}, a \csa{chaptertok}, a
\csa{sectiontok} and a \csa{subsectiontok}, to help in the task of filling
up the total \csa{treetok}. As we are interested here in the table of
contents of this (or another) document part, only a \csa{sectiontok} and a
\csa{subsectiontok} will be needed.


\begin{verbatim}
% \newtoks\treetok % already done earlier
\newtoks\sectiontok \newtoks\subsectiontok \newcommand*{\treenode}{}

\newcommand*{\appendchildtree}[2]{% token list t1 becomes: t1 child {t2}
   \edef\tmp{\the#1 child {\the#2}}%
   #1\expandafter{\tmp}%
}
\newcommand*{\preparetreenode}{%
  \tmptok\expandafter{\etocthelinkednumber}% expanded one time (mandatory)
  \edef\treenode{node {\the\tmptok}}%
}

\etocsetstyle{section}
  {\etocskipfirstprefix}
  {\appendchildtree\treetok\sectiontok}
  {\preparetreenode \sectiontok\expandafter{\treenode}}
  {\appendchildtree\treetok\sectiontok}

\etocsetstyle{subsection}
  {\etocskipfirstprefix}
  {\appendchildtree\sectiontok\subsectiontok}
  {\preparetreenode \subsectiontok\expandafter{\treenode}}
  {\appendchildtree\sectiontok\subsectiontok}

\etocsettocstyle
  {\treetok{\node {\hyperref[part:overview]{Overview}}}}
  {\global\appendtotok\treetok{ ;}}

% moved to the inside of the figure environment for correct \pageref{toc:molecule}
% \etocsetnexttocdepth{subsection}
% \tableofcontents \label{toc:molecule} \ref{toc:overview}
\end{verbatim}

% \newtoks\sectiontok
% \newtoks\subsectiontok
\newcommand*\treenode {}

\newcommand*{\appendchildtree}[2]{% token list t1 becomes: t1 child {t2}
   \edef\tmp{\the#1 child {\the#2}}%
   #1\expandafter{\tmp}%
}

\newcommand*{\preparetreenode}{%
  \tmptok\expandafter{\etocthelinkednumber}%
  \edef\treenode{node {\the\tmptok}}%
}

\etocsetstyle{section}
  {\etocskipfirstprefix}
  {\appendchildtree\treetok\sectiontok}
  {\preparetreenode
   \sectiontok\expandafter{\treenode}}
  {\appendchildtree\treetok\sectiontok}

\etocsetstyle{subsection}
  {\etocskipfirstprefix}
  {\appendchildtree\sectiontok\subsectiontok}
  {\preparetreenode
   \subsectiontok\expandafter{\treenode}}
  {\appendchildtree\sectiontok\subsectiontok}

\etocsettocstyle
  {\treetok{\node {\hyperref[part:overview]{Overview}}}}
  {\global\appendtotok\treetok{ ;}}

\begin{figure}[th!]\centering
\etocsetnexttocdepth{subsection}
   \tableofcontents \label{toc:molecule}\ref{toc:overview}
   \hypersetup{hidelinks}%
   \begin{tikzpicture}
              [grow cyclic,
               level 1/.style={level distance=4cm,sibling angle=72},
               level 2/.style={level distance=2cm,sibling angle=60},
               every node/.style={ball color=red,circle,text=SkyBlue},
               edge from parent path={[dashed,very thick,color=cyan]
                           (\tikzparentnode) --(\tikzchildnode)}] 
     \the\treetok
   \end{tikzpicture}
   \centeredline{A table of contents as a ``molecule.''}
\end{figure}

% Pour que \pageref fonctionne correctement, je dois mettre
% le \tableofcontents dans la figure. 

The |\tableofcontents| command appears just above the
|tikzpicture| environment in a figure float (for the label of the
table of contents to certainly
refer to the same page as the one where the picture will actually be printed).
We thus get the table of contents as a ``\hyperref[toc:molecule]{molecule}'',
which  
appears \vpageref[above]{toc:molecule}. Here is the code actually
producing it:
\begin{verbatim}
\begin{figure}[th!]\centering
   \etocsetnexttocdepth{subsection}
   \tableofcontents \label{toc:molecule} \ref{toc:overview}
   \hypersetup{hidelinks}%
   \begin{tikzpicture}
              [grow cyclic,
               level 1/.style={level distance=4cm,sibling angle=72},
               level 2/.style={level distance=2cm,sibling angle=60},
               every node/.style={ball color=red,circle,text=SkyBlue},
               edge from parent path={[dashed,very thick,color=cyan]
                           (\tikzparentnode) --(\tikzchildnode)}] 
     \the\treetok
   \end{tikzpicture}
\end{figure}
\end{verbatim}

This \hyperref[toc:molecule]{TikZ TOC} is fully hyperlinked, like the
previous 
\hyperref[toc:forest]{Forest TOC}.

\etocsettocstyle
  {\treetok{\node {\autoref{part:globalcmds}}}}
  {\global\appendtotok\treetok{ ;}}

\etocsetnexttocdepth {subsection}
\tableofcontents \ref{toc:globalcmds}

\noindent  
\parbox{4cm}{\hypersetup{hidelinks}%
    \begin{tikzpicture}
              [grow cyclic,
               level 1/.style={level distance=2.5cm,sibling angle=60},
               level 2/.style={level distance=1cm,sibling angle=45},
               every node/.style={ball color=red!50,circle,text=black},
               edge from parent path={[very thick,color=cyan]
                       (\tikzparentnode) --(\tikzchildnode)}] 
     \the\treetok
   \end{tikzpicture}}%
\begin{minipage}{\dimexpr\linewidth-4cm\relax}
  On the side, the (fully hyperlinked) table of contents of
  \autoref{part:globalcmds}.
  \def\MacroFont{\ttfamily\small\hyphenchar\font-1 \baselineskip10pt\relax}%
\begin{verbatim}
\etocsettocstyle
  {\treetok{\node {\autoref{part:globalcmds}}}}
  {\global\appendtotok\treetok{ ;}}
\etocsetnexttocdepth {subsection}
\tableofcontents \ref{toc:globalcmds}
\noindent  
\parbox{4cm}{\hypersetup{hidelinks}%
   \begin{tikzpicture}
      [grow cyclic,
       level 1/.style={level distance=2.5cm,sibling angle=60},
       level 2/.style={level distance=1cm,sibling angle=45},
       every node/.style={ball color=red!50,circle,text=black},
       edge from parent path={[very thick,color=cyan]
               (\tikzparentnode) --(\tikzchildnode)}] 
     \the\treetok
   \end{tikzpicture}}%
...
\end{verbatim}
\end{minipage}

\section{The TOC as a TikZ mind map}
\label{sec:mindmap}

This is in the same spirit as the ``molecule'' example. The use of the \eTeX{}
primitive \csa{unexpanded} will simplify the code.\footnote{The ``molecule''
example was added to this documentation on |2013/03/03|. The ``mindmap''
example was motivated on |2015/03/11| by
\url{http://tex.stackexchange.com/a/232584/4686}. Further help was then obtained via
\url{http://tex.stackexchange.com/q/232816/4686} and this led to the  
\hyperref[toc:mindmaptitlepage]{title page} which is a further example.}


\begingroup
%\newtoks\treetok
%\newtoks\parttok

\newcommand*\partnode {}  % just to check we don't overwrite something
%\newcommand*\childnode {}

\newcommand*\tmprotate {} % just to check we don't overwrite something
\newcommand*\tmpoption {} % just to check we don't overwrite something
\newcommand*\tmpstuff  {} % just to check we don't overwrite something

% \newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
%   #1\expandafter\expandafter\expandafter{\expandafter\the\expandafter #1#2}}

\renewcommand*{\appendchildtree}[3]{% 
% this is to construct "t1 child [branch color= #3]{t2}" from #1=t1 and #2=t2
% t1 and t2 are two toks variable (not macros)
% #3 = for example teal!60
   \edef\tmpstuff {\the#1 child [branch color = #3]{\the#2}}%
   #1\expandafter {\tmpstuff }%
}

% \newcounter{partco}

% 1,2,3,4,5,... -> 1,2,3,1,2,3,1,2,3
% \def\pseudomodthree #1{\numexpr #1 + 3 - 3*((#1+1)/3)\relax}

\etocsetstyle{part}
  {\etocskipfirstprefix}
% This updates the global tree with the data  from the previous
% part and all its children sections. Moved here because for some parts the
% sections are not displayed due to depth tags.
  {\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {teal!60}%   first
   \or \appendchildtree\treetok\parttok {yellow!80}% second
   \else\appendchildtree\treetok\parttok {green!50}% third and next ...
   \fi
   }
  {\stepcounter{partco}%
% customize manually  some TikZ set-up (should be done inside the TikZ thing I guess)
   \def\tmpoption {}%
   \def\tmprotate {}% first
   \ifnum\value{partco}=5 \def\tmprotate {[counterclockwise from =-40]}\fi
   \ifnum\value{partco}=8 \def\tmprotate {[counterclockwise from =-50]}\fi
% define the part node
   \edef\partnode{node \tmpoption 
                  {\unexpanded\expandafter{\etocthelinkednumber}. 
                   \unexpanded\expandafter{\etocthelinkedname}}\tmprotate }%
% this is a starting point which will be filled it by the section children
   \parttok\expandafter{\partnode}}
  {\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {teal!60}%   first
   \or \appendchildtree\treetok\parttok {yellow!80}% second
   \else\appendchildtree\treetok\parttok {green!50}% third and next ...
   \fi
   }

\etocsetstyle{section}
  {}
  {}
  {% define the section node
   \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber} 
                        \unexpanded\expandafter{\etocthelinkedname}}}}%
   % append it to the current \parttok
   \appendtotok\parttok\childnode
    }
  {}

\etocsettocstyle
  {\setcounter{partco}{0}%
   \treetok{\node [root concept]{\textbf{The \etoc documentation}}}}
  {\global\appendtotok\treetok{ ;}}
% The \global above is mandatory because etoc always typesets TOC inside a group

\etocsetnexttocdepth{section}
% use of depth tags to cut out some sections.
\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {section}
\etocsettagdepth {arbitrarily}{part}
\etocsettagdepth {surprising} {section}
\etocsettagdepth {linestyles} {part}
\etocsettagdepth {globalcmds} {section}
\etocsettagdepth {custom}     {section}
\etocsettagdepth {tips}       {section}
\etocsettagdepth {code}       {section}

\tikzset{
    branch color/.style={
        concept color=#1!white,
        every child/.append style={concept color=#1!white!30!white, font=\normalsize},
    }
}%

\begin{figure}[th!]
\tableofcontents\label{toc:mindmap}%
\centeredline{\resizebox{.85\paperwidth}{!}%
{\begin{tikzpicture}[mindmap,
                    grow cyclic, 
                    text width=2cm, 
                    align=flush center, 
                    nodes={concept}, 
                    concept color=orange!60,
                    root concept/.append style={text width=4cm, font=\Large},
                    level 1/.append style={level distance=5cm,sibling angle=45, text width=3cm},
                    level 2/.append style={level distance=8cm,sibling angle=25, text width=3cm},
                    level 1 concept/.append style={font=\normalsize},
                    ]
\the\treetok
\end{tikzpicture}}}
\end{figure}
\endgroup

It is difficult to get everything to fit on one page. However \csa{resizebox}
comes to the rescue. And it preserves hyperlinks. Nevertheless for this
example I excluded some sections from the display, using the technique of the
\etoc \hyperref[etocdepthtag.toc]{depth tags}. The fully hyperlinked TOC
appears \vpageref{toc:mindmap}.

\begin{verbatim}
\begingroup
\newtoks\treetok
\newtoks\parttok

\newcommand*\partnode {}  % just to check we don't overwrite something
\newcommand*\childnode {}

\newcommand*\tmprotate {} % just to check we don't overwrite something
\newcommand*\tmpoption {} % just to check we don't overwrite something
\newcommand*\tmpstuff  {} % just to check we don't overwrite something

\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
   #1\expandafter\expandafter\expandafter{\expandafter\the\expandafter #1#2}}

\renewcommand*{\appendchildtree}[3]{% 
% this is to construct "t1 child [branch color= #3]{t2}" from #1=t1 and #2=t2
% t1 and t2 are two toks variable (not macros)
% #3 = for example teal!60
   \edef\tmpstuff {\the#1 child [branch color = #3]{\the#2}}%
   #1\expandafter {\tmpstuff }%
}

\newcounter{partco}

% 1,2,3,4,5,... -> 1,2,3,1,2,3,1,2,3
\def\pseudomodthree #1{\numexpr #1 + 3 - 3*((#1+1)/3)\relax}

\etocsetstyle{part}
  {\etocskipfirstprefix}
% This updates the global tree with the data  from the previous
% part and all its children sections. Moved here because for some parts the
% sections are not displayed due to depth tags.
  {\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {teal!60}%   first
   \or \appendchildtree\treetok\parttok {yellow!80}% second
   \else\appendchildtree\treetok\parttok {green!50}% third and next ...
   \fi
   }
  {\stepcounter{partco}%
% customize manually  some TikZ set-up (should be done inside the TikZ thing I guess)
   \def\tmpoption {}%
   \def\tmprotate {}% first
   \ifnum\value{partco}=5 \def\tmprotate {[counterclockwise from =-40]}\fi
   \ifnum\value{partco}=8 \def\tmprotate {[counterclockwise from =-50]}\fi
% define the part node
   \edef\partnode{node \tmpoption 
                  {\unexpanded\expandafter{\etocthelinkednumber}. 
                   \unexpanded\expandafter{\etocthelinkedname}}\tmprotate }%
% this is a starting point which will be filled it by the section children
   \parttok\expandafter{\partnode}}
  {\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {teal!60}%   first
   \or \appendchildtree\treetok\parttok {yellow!80}% second
   \else\appendchildtree\treetok\parttok {green!50}% third and next ...
   \fi
   }

\etocsetstyle{section}
  {}
  {}
  {% define the section node
   \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber} 
                        \unexpanded\expandafter{\etocthelinkedname}}}}%
   % append it to the current \parttok
   \appendtotok\parttok\childnode
    }
  {}

\etocsettocstyle
  {\setcounter{partco}{0}%
   \treetok{\node [root concept]{\textbf{The \etoc documentation}}}}
  {\global\appendtotok\treetok{ ;}}
% The \global above is mandatory because etoc always typesets TOC inside a group

\etocsetnexttocdepth{section}
% use of depth tags to cut out some sections.
\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {section}
\etocsettagdepth {arbitrarily}{part}
\etocsettagdepth {surprising} {section}
\etocsettagdepth {linestyles} {part}
\etocsettagdepth {globalcmds} {section}
\etocsettagdepth {custom}     {section}
\etocsettagdepth {tips}       {section}
\etocsettagdepth {code}       {section}

\tikzset{
    branch color/.style={
        concept color=#1!white,
        every child/.append style={concept color=#1!white!30!white, font=\normalsize},
    }
}%

\begin{figure}[th!]
\tableofcontents\label{toc:mindmap}%
\centeredline{\resizebox{.85\paperwidth}{!}%
{\begin{tikzpicture}[mindmap,
                    grow cyclic, 
                    text width=2cm, 
                    align=flush center, 
                    nodes={concept}, 
                    concept color=orange!60,
                    root concept/.append style={text width=4cm, font=\Large},
                    level 1/.append style={level distance=5cm,sibling angle=45, text width=3cm},
                    level 2/.append style={level distance=8cm,sibling angle=25, text width=3cm},
                    level 1 concept/.append style={font=\normalsize},
                    ]
\the\treetok
\end{tikzpicture}}}
\end{figure}
\endgroup
\end{verbatim}

An interesting alternative is to use \etoc rather to convert the entire TOC
into a TikZ tree (perhaps excluding some parts) and print it out to a file
from which it can be recovered and manipulated directly by the author of the
document. Things written to the |.log| file get broken into lines. Here is a
technique to get non-broken output. Once the \csa{treetok} has been computed
by \etoc (as in the \hyperref[toc:molecule]{molecule} example, or the current
example), this code snippet will write it out to file with extension
|.toctree|:
\begin{verbatim}
  \newwrite\TOCasTree
  \immediate\openout\TOCasTree=\jobname.toctree
  \immediate\write\TOCasTree{\the\treetok}%
\end{verbatim}
The author can then copy it from there and customize it manually to get a
suitable tikz picture.


\section{The TOC as a table}
\label{sec:tocastable}

With release |1.08| it is easier to typeset a TOC as a table. It is
possible to open a tabular in the title part of the TOC (first argument
to \csb{etocsettocstyle}) and then close it after the contents (second
argument to \csb{etocsettocstyle}), and specify in the line styles how
to use the tabulation |&| and tabular end of row |\\|. There are some
conditions and a few caveats:

\begin{enumerate}
\item it is mandatory to issue \csb{etocglobaldefs} for \etoc's
  definitions to have global scope,
\item it is impossible to start one of the \meta{start}, \meta{prefix},
  \meta{contents} or \meta{finish} specification with a sole |\hline|,
  \emph{i.e.} one not preceded by a |\\| (it is however possible to put
  |\\| at the end of \meta{prefix} and the |\hline| at the start of
  \meta{contents}).
\item as is explained next, it is recommended to use the  |\\| at
  the start of the \meta{prefix} or \meta{contents}
  specifications to close the \emph{previous} row, not at the end
  to close the \emph{current} row; when the TOC is a partial one (a
  \csa{localtableofcontents}) this advice becomes (in almost all
  situations) mandatory.
\end{enumerate}

Here is an example of a TOC as a |longtable|, as is possible relatively
simply now with |1.08|. The code follows.

\begingroup
\etocglobaldefs % necessary for \etocthename etc... to survive &

% observe the locations of the \\
\etocsetstyle{part}
  {}
  {\\\hline}
  {\strut\etocnumber &\bfseries\etocname &\etocpage }
  {}

\etocsetstyle{section}
  {}
  {\etociffirst{\etocifnumbered{\\\hline}{\\\hline\hline}}{\\}}
  {\etocnumber&\etocname &\etocpage }
  {}

\etocsetstyle{subsection}
  {}
  {\\}
  {&\makebox[1cm][c]{\etocnumber}%
    \parbox[t]{\dimexpr6cm-\tabcolsep\relax}{\sloppy\itshape\etocname\strut}%
   &\itshape\etocpage }
  {}

\etocsettocstyle
    {\hypersetup{hidelinks}%
     \begin{longtable}{|>{\bfseries}c|p{7cm}|r|}
     \hline
     \multicolumn{3}{|c|}{\Large\bfseries\strut\MakeUppercase{\contentsname}}%
     }
    {\\\hline\end{longtable}}

\etocsetnexttocdepth {subsection}

\tableofcontents
\endgroup

\begin{verbatim}
\begingroup
\etocglobaldefs % necessary for \etocname etc... to survive &

% observe the locations of the \\
\etocsetstyle{part}
  {}
  {\\\hline}
  {\strut\etocnumber &\bfseries\etocname&\etocpage }
  {}

\etocsetstyle{section}
  {}
  {\etociffirst{\etocifnumbered{\\\hline}{\\\hline\hline}}{\\}}
  {\etocnumber&\etocname &\etocpage }
  {}

\etocsetstyle{subsection}
  {}
  {\\}
  {&\makebox[1cm][c]{\etocnumber}%
    \parbox[t]{\dimexpr6cm-\tabcolsep\relax}{\sloppy\itshape\etocname\strut}%
   &\itshape\etocpage }
  {}

\etocsettocstyle
    {\hypersetup{hidelinks}%
     \begin{longtable}{|>{\bfseries}c|p{7cm}|r|}
     \hline
     \multicolumn{3}{|c|}{\Large\bfseries\strut\strut TABLE OF CONTENTS}%
     }
    {\\\hline\end{longtable}}

\etocsetnexttocdepth {subsection}

\tableofcontents
\endgroup
\end{verbatim}

Examining the code above the reader will wonder why the |\\| are
always given first in \meta{prefix+contents} and not, as is more
intuitive, rather last. In many cases one may indeed construct
TOC-as-tables with the |\\| located at the end of the style
specifications (but almost never for a \csa{localtableofcontents}).
The problem in the previous example was with the positioning of the
|\hline|'s.

Due to technical aspects of how \TeX{} constructs alignments any
definition or assignment done after an |\\| starts a new row, and
thus makes |\hline| an illegal token (this shows as a |misplaced
\noalign| error.) Not only does \etoc have to do such definitions
to construct \csb{etocname} etc..., it is furthermore the case that
some packages put things in the |.toc| file and as a result there
is never any guarantee that between two \csa{contentsline} there
will not be such a token like |\relax| which in the contexts of
alignments forces \TeX{} to start a cell and thus makes it
impossible then to insert an |\hline|.

The safest way is to start with an |\\| each line style
specification. We had a little problem with the fact that we wanted
parts not only to have a rule above them (easy, they do |\\\hline|)
but also below them: after each part there is a section, thus the
section which are first of their kind used the \csb{etociffirst}
conditional branching. The attentive reader will notice one last
subtlety: the title was supposed to be followed not by one, but by
two |\hline|'s.

To solve this we could have used a one-time macro redefining itself, but
we noticed that the title was followed by the unnumbered Abstract, thus
the \csb{etocifnumbered} switch came to the rescue.

Last technical note: because we put the |\\| inside the branches, there
was no need to employ the expandable variants \csb{etocxiffirst} and
\csb{etocxifnumbered}.

For the hardliner's old way of obtaining the exact same result, see
\autoref{ssec:tocastableold}.

Here is also a much simpler example. It is a local table of
contents.

\begin{center}
\etocsetstyle{section}
             {}
             {\etociffirst{\\\hline\hline}{\\\hline}}
             {\etocname& 
              \etocnumber& 
              \etocpage }
             {}

\etocsettocstyle
   {\hypersetup{hidelinks}\begin{tabular}{|p{4cm}|c|c|}\hline
    \multicolumn{1}{|c|}{\bfseries Section}&
    \bfseries number&
    \bfseries page}
   {\\\hline\end{tabular}}

\etocglobaldefs % MANDATORY !!
\etocsetnexttocdepth{1}

\tableofcontents\ref{toc:overview}
\end{center}

\begin{verbatim}
\begin{center}
\etocsetstyle{section}
             {}
             {\etociffirst{\\\hline\hline}{\\\hline}}
             {\etocname & \etocnumber & \etocpage }
             {}

\etocsettocstyle
   {\hypersetup{hidelinks}\begin{tabular}{|p{4cm}|c|c|}\hline
    \multicolumn{1}{|c|}{\bfseries Section}&
    \bfseries number&
    \bfseries page}
   {\\\hline\end{tabular}}

\etocglobaldefs % MANDATORY !!
\etocsetnexttocdepth{1}

\tableofcontents\ref{toc:overview}
\end{center}
\end{verbatim}

\subsection{The commands \csbhyp{etocglobaldefs} and \csbhyp{etoclocaldefs}}
\label{etocglobaldefs}
\label{etoclocaldefs}

In \LaTeX{} the meaning of a command defined via |\newcommand\foo{...}| inside
an environment (or group) vanishes from \TeX's memory on exit from this
environment (or group). At times however it is needed to make definitions with
global scope, for this \TeX{} has the primitive prefix |\global|.

By default \etoc's definitions of \csb{etocname} etc... are local. This causes
problems in certain contexts such as seen here with TOC as tables, but also
with |enumitem| \emph{inline} variants of its standard environments, because
the command |\item| then closes a group.

After \csb{etocglobaldefs}, \etoc will make its definitions of \csb{etocname}
etc... have global scope. For normal use this is not necessary. It does not hurt
either to activate it systematically. 

To return to the default, use \csb{etoclocaldefs}. Note that both
\csb{etocglobaldefs} and \csb{etoclocaldefs} actions are local to the
environment or group where they are used.


\clearpage
\etocdepthtag.toc {linestyles}

\part{Commands for the toc line styles}
\label{part:linestyles}

\thispartstats

\etocsetstyle{section}
{\begin{enumerate}[leftmargin=.75cm, label=\etocifnumbered
      {{\fboxrule1pt\fcolorbox{green}{white}{\etocnumber}}}{}]}
% Dec 7, 2012. I hit upon a problem whose origin I found was
% with xcolor, as xcolor modifies \fbox
% (try \section{\fbox{A}} with and without xcolor). The fix
% was to \protect the \fbox used in the |enumitem| label.
% Strangely enough, with |hyperref| active, the problem did
% not show up. Anyhow I now use \fcolorbox rather than \fbox
% and there is no problem anymore. Also I don't have now to
% use \normalcolor which already needed protection.
{\normalsize\bfseries\rmfamily\item}
{\etocname{} (page \etocpage)}
{\end{enumerate}}

\etocsetstyle{subsection}
{\begin{enumerate}[leftmargin=0cm, label=\etocnumber]}
{\normalfont \item}
{\etocname{} (p.~\etocpage)}
{\end{enumerate}}

\etocsetstyle{subsubsection}
{\par\nobreak\begingroup\normalfont\footnotesize\itshape\etocskipfirstprefix}
{\allowbreak\,--\,}
{\etocname}
{.\hfil\par\endgroup\pagebreak[3]}

% 27 janvier 2013 22:30
% je définis les macros (non protégées) 
% \etocthename, \etocthenumber, \etocthepage

\etocruledstyle[1]{\etocfontminusone\color{green}%
     \fboxrule1pt\fboxsep1ex
     \framebox[\linewidth]
              {\normalcolor\hss Contents of \autoref{part:linestyles}\hss}}

\localtableofcontents \label{toc:a}

\section{The \csbhyp{etocsetstyle} command}
\label{etocsetstyle}

\subsection{The \csbhyp{etocname} and \csbhyp{etocpage} commands}
\label{etocname}
\label{etocpage}

Let us explain how \etoc was used to produce the table of
contents displayed at the beginning of this second part.
This
is a local table of contents, and we used the command \localtoc.


We shall distinguish between the \emph{line styles} and the
\emph{toc display style}. The line styles were (essentially)
obtained in the following manner:%
\footnote{the present document has
  {\ttfamily\string\renewcommand\string{%
      \string\familydefault\string}\string{\string\sfdefault\string}}
  in its preamble, hence \csa{normalfont} switches to the
  |sans| typeface; so in the section line-style, I wrote
  \csa{rmfamily} instead.}

\begingroup\small
\begin{verbatim}
\etocsetstyle{section}
{\begin{enumerate}}
{\normalsize\bfseries\rmfamily\item}
{\etocname{} (page \etocpage)}
{\end{enumerate}}

\etocsetstyle{subsection}
{\begin{enumerate}}
{\normalfont\item}
{\etocname{} (p.~\etocpage)}
{\end{enumerate}}

\etocsetstyle{subsubsection}
{\par\nobreak\begingroup\normalfont
        \footnotesize\itshape\etocskipfirstprefix}
{\allowbreak\,--\,}
{\etocname}
{.\hfil\par\endgroup\pagebreak[3]}
\end{verbatim}
\endgroup

These provisory style definitions rely on the automatic
numbering generated by the |enumerate| environments but it is
much better to use the further command \csb{etocnumber} inside
the item label, which gives the real thing. The improved
definitions will thus be explained later.

With this style, one would have 
to be imaginative to design something then for paragraph and
subparagraph entries! perhaps as superscripts? Well, usually
one does not need paragraphs and subparagraphs numbered and
listed in the TOC, so our putative user here chose a design
where no provision is made for them and added the definitive:
\begin{verbatim}
\etocsetstyle{paragraph}{}{}{}{}
\etocsetstyle{subparagraph}{}{}{}{}
\end{verbatim}
This is also the situation with the default package line styles!

Each \csb{etocsetstyle} command has five mandatory arguments:\\
\hbox to \linewidth
{\hfil\csb{etocsetstyle}\color{blue}\marg{levelname}%
  \marg{start}\marg{prefix}\marg{contents}\marg{finish}\hfil}
The initially recognized \meta{levelname}'s are the sectioning
levels of the standard document classes: from \emph{part} (or
\emph{book} which is used by the |memoir| class) down to
\emph{subparagraph}.

The \meta{start} code is executed when a toc entry of that level is
encountered and the previous one was at a higher level. The
\meta{finish} code is executed when one again encounters a higher
level toc entry. In the mean-time all entries for that level are
typeset by executing first the \meta{prefix} code and then the
\meta{contents} code. 

The (robust) commands \csb{etocname}, \csb{etocnumber} and \csb{etocpage} are
provided for use inside the \meta{prefix} and \meta{contents} parts of the
\csa{etocsetstyle} specification. They represent of course, the name, number,
and page number of the corresponding toc entry. If package |hyperref| is
active in the document and has added hyperlinks to the TOC data, then these
links are kept in the commands \csa{etocname}, \csa{etocnumber} and
\csa{etocpage} (this last one will have a link only if |hyperref| was passed
option \emph{linktoc=all}.)

\subsection{The \csbhyp{etocskipfirstprefix} and \csbhyp{etociffirst} commands}
\label{etocskipfirstprefix}
\label{etociffirst}
\label{etocxiffirst}

The chosen |subsubsection| style made use of the command
\csb{etocskipfirstprefix}, which instructs \etoc to \emph{not} use
for the first item the specified \meta{prefix} code.\footnote{With
versions earlier than |1.08| it had to be the very last token in
the \meta{start} code. It may now appear anywhere therein.}

The command \csb{etociffirst}\marg{YES CODE}\marg{NO CODE} (new
with |1.08|) is a more flexible way to customize the \meta{prefix}
(and \meta{contents}) specifications. It executes the \meta{YES
CODE} branch if this is the first unit at that level (inside a
lower level) and the \meta{NO CODE} if not. This is a robust
command which survives to expansion (for example in an |enumitem| label).

The variant \csb{etocxiffirst} does the same, but is expandable.


\subsection{The \csbhyp{etocnumber} command}
\label{etocnumber}

So far, our specifications would use the numbering generated
by the |enumerate| environments, but of course we generally want
the actual numbers as found in the |.toc| file. This is
available via the \csb{etocnumber} command. To get the labels
in the |enumerate| list to use it we can proceed with the
syntax {\ttfamily label=\char32} from the package |enumitem|:
\begin{verbatim}
\etocsetstyle{section}
{\begin{enumerate}[label=\etocnumber]}
{\normalsize\bfseries\rmfamily\item}
{\etocname{} (page \etocpage)}
{\end{enumerate}}
\end{verbatim}
Rather than just \csa{etocnumber} we then used something like
|\fbox{\etocnumber}|. Note that \csa{etocnumber} is a robust
command which explains why it can be used inside the label specification
without needing an added |\protect|.


\subsection{The \csbhyp{etocifnumbered} switch}
\label{etocifnumbered}
\label{etocxifnumbered}

The \csa{fbox} would give an unaesthetic result in the case of
an unnumbered section (which ended up in the table of
contents via an \csa{addcontentsline} command).\footnote{as
  seen we use \csa{fcolorbox} rather than \csa{fbox}. Due
  to some redefinition made by package |xcolor|, had we used
  \csa{fbox} (and not used |hyperref|) we would have needed
  \csa{protect}\csa{fbox}.}

The \csb{etocifnumbered}\marg{A}\marg{B} command executes
\meta{A} if the number exists, and \meta{B} if not. So we use
it in the code which was finally chosen for the |section| level:
\begin{verbatim}
\etocsetstyle{section}
{\begin{enumerate}[leftmargin=.75cm, label=\etocifnumbered
      {{\fboxrule1pt\fcolorbox{green}{white}{\etocnumber}}}{}]}
{\normalsize\bfseries\rmfamily\item}
{\etocname{} (page \etocpage)}
{\end{enumerate}}

\etocsetstyle{subsection}
{\begin{enumerate}[leftmargin=0cm, label=\etocnumber]}
{\normalfont \item}
{\etocname{} (p.~\etocpage)}
{\end{enumerate}}
\end{verbatim}

If we had changed only the |section| level, and not the
|subsection| level, an error on compilation would have occurred
because the package style for subsections expects to start `in
vertical mode'. An additional \csa{par} token in the
\meta{contents} part of the |section| level would have fixed
this: |{...(page \etocpage)\par}|.

The command \csb{etocifnumbered} is robust;  \csb{etocxifnumbered}
(new with |1.08|) has the same effect but is expandable.


\subsection{The \csbhyp{etocthename}, \csbhyp{etocthenumber}, and
\csbhyp{etocthepage} commands}
\label{etocthename}
\label{etocthenumber}
\label{etocthepage}

It is sometimes desirable to have access to the name, number and page
number without the hyperref link data: something similar to the starred
variant of the \csa{ref} command, when package |hyperref| is used. For
example one may wish to use the unit or page number in some kind of
numeric context, or change its formatting. This is provided by
\csb{etocthename}, \csb{etocthenumber}, and \csb{etocthepage}.


These commands are not protected, so in moving argument
contexts (for example in a label specification) they should be
preceded by |\protect|.

\subsection{The \csbhyp{etoclink} command}
\label{etoclink}

The command \csb{etoclink}\marg{linkname} can be used in the line style
specifications in a manner analogous to the argument-less
commands \csa{etocname}, \csa{etocnumber} and \csa{etocpage}. It
creates a link (if such a link was added by |hyperref| to the
|.toc| file entry) whose destination is the corresponding document
unit and whose name is the given argument. 
Hence |\etoclink{\etocthename}| is like the original
|\etocname|.
Notice that if |hyperref| was not instructed to put a link in the page number
(via 
its option \emph{linktoc=all}) then \etoc's \csa{etocpage} contains no link
either, but |\etoclink{\etocthepage}| does. 


The command \csa{etoclink} is robust.

\subsection{The \csbhyp{etocthelinkedname}, \csbhyp{etocthelinkednumber},
\csbhyp{etocthelinkedpage} and \csbhyp{etocthelink} commands}
\label{etocthelinkedname}
\label{etocthelinkednumber}
\label{etocthelinkedpage}
\label{etocthelink}


This is for advanced uses by advanced users. 
The \csa{etocthename} macro has
been mentioned before; using it in instructions such as
|\global\let\lastone\etocthename| in an \etoc line style will
define the macro |\lastone| to expand to the last name seen at the
corresponding level. But no facilities was previously available to
do the same with the link data.

The package provides since |1.07f 2013/03/07| \csa{etocthelinkedname} to do
the similar thing, with the link data included. It was used in this
documentation when doing the \hyperref[tocastree]{examples with trees}.

Also provided with the similar goal: \csa{etocthelinkednumber},
\csa{etocthelinkedpage} (which contains a link only if |hyperref|
added one to the page number) and \csa{etocthelink}\marg{linkname}
which allows to make a link with an arbitrary name.

All these commands are fragile. In fact starting with |1.08a|, \csa{etocname}
is exactly the robust variant of \csa{etocthelinkedname}.

Obsolete example of \begingroup
        \etocsetstyle {section}
          {\begin{itemize*}[itemjoin={{; }}, itemjoin*={{, and }}]}
          {\global\let\TmpEtocNumber\etocthelinkednumber
           \global\let\TmpEtocName\etocthelinkedname 
           \global\let\TmpEtocPage\etocthelinkedpage }
          {\item [{\bfseries\TmpEtocNumber.}]\TmpEtocName\ 
                 (\emph{p. \TmpEtocPage})}
          {\end{itemize*}.}%
    \etocsetnexttocdepth {section}%
    \etocsettocstyle {a table of contents done as an inline 
                          \texttt{enumitem} environment: }{}%
    \etocinline\tableofcontents \ref{toc:globalcmds}
\endgroup

\begin{verbatim}
Obsolete example of \begingroup
        \etocsetstyle {section}
          {\begin{itemize*}[itemjoin={{; }}, itemjoin*={{, and }}]}
          {\global\let\TmpEtocNumber\etocthelinkednumber
           \global\let\TmpEtocName\etocthelinkedname 
           \global\let\TmpEtocPage\etocthelinkedpage }
% (the above needed as \item closes a group in enumitem inline environments)
          {\item [{\bfseries\TmpEtocNumber.}]\TmpEtocName\ 
                 (\emph{p. \TmpEtocPage})}
          {\end{itemize*}.}%
    \etocsetnexttocdepth {section}%
    \etocsettocstyle {a table of contents done as an inline 
                          \texttt{enumitem} environment: }{}%
    \etocinline\tableofcontents \ref{toc:globalcmds}
\endgroup
\end{verbatim}

\etoc |1.08a| offers a simpler way to the same result. And there is no need
anymore here for \csa{etocthelinkedname}, \csa{etocname} works.
\begin{verbatim}
Example of 
\begingroup\etocglobaldefs % <-- NEW mit etoc 1.08.
        \etocsetstyle {section}
          {\begin{itemize*}[itemjoin={{; }}, itemjoin*={{, und }}]}
          {}
          {\item [{\bfseries\etocnumber.}] \etocname\ (\emph{p. \etocpage })}
          {\end{itemize*}.}%
    \etocsetnexttocdepth {section}%
    \etocsettocstyle {a table of contents done as an inline
                       \texttt{enumitem} environment: }{}%
    \etocinline\tableofcontents \ref{toc:globalcmds}
\endgroup
\end{verbatim}
Example of 
\begingroup\etocglobaldefs % <-- NEW mit etoc 1.08.
        \etocsetstyle {section}
          {\begin{itemize*}[itemjoin={{; }}, itemjoin*={{, und }}]}
          {}
          {\item [{\bfseries\etocnumber.}]
                 \etocname\ (\emph{p. \etocpage })}
          {\end{itemize*}.}%
    \etocsetnexttocdepth {section}%
    \etocsettocstyle {a table of contents done as an inline
                       \texttt{enumitem} environment: }{}%
    \etocinline\tableofcontents \ref{toc:globalcmds}
\endgroup

\section{The \csbhyp{etocsetlevel} command}
\label{etocsetlevel}

As already explained in \autoref{part:surprising}, one
can inform \etoc of a level to associate to a given sectioning
command with \csa{etocsetlevel}. For example:
\begin{verbatim}
\etocsetlevel{cell}{0}
\etocsetlevel{molecule}{1}
\etocsetlevel{atom}{2}
\etocsetlevel{nucleus}{3}
\end{verbatim}
In compatibility mode, it will be assumed that the macros |\l@cell|,
|\l@molecule|, ..., have been defined somewhere either by the user or a class:
doing only |\etocsetlevel| is not enough for the corresponding level to work
out-of-the-box in compatibility mode.

However, if no table of contents is typeset in compatibility mode, then all that
matters  is that the various line styles have been set. If, for example
|section| is at level |1|, then there is no need to do some
\csa{etocsetstyle}|{molecule}{..}{..}{..}{..}| after
\csa{etocsetlevel}|{molecule}{1}| if
\csa{etocsetstyle}|{section}{..}{..}{..}{..}| has already been done (and it has
been done by the package itself in its definition of its own line styles).
 
The accepted levels run from |-2| to |6| inclusive.  Anything else is
mapped to |6|, which is a dummy level, never displayed. The package
does:
\begin{verbatim}
\etocsetlevel{book}{-2}
\etocsetlevel{part}{-1}
\etocsetlevel{chapter}{0}
\etocsetlevel{section}{1}
\etocsetlevel{subsection}{2}
\etocsetlevel{subsubsection}{3}
\etocsetlevel{paragraph}{4}
\etocsetlevel{subparagraph}{5}
\end{verbatim}
\etoc own custom styles are activated by \csa{etocdefaultlines}. They
are illustrated by the main table of contents of this
document. 

These level assignments can be modified at anytime: see
\autoref{part:surprising} for various applications of this
technique. As one 
further example, let's mention here that the \hyperref[toc:main]{main table of
contents} of this document was typeset following these instructions:
\begin{verbatim}
\etocsettocdepth {subsubsection} % set the initial tocdepth
\etocdefaultlines % use the package default line styles. At this early stage in
                  % the document they had not yet been modified by \etocsetstyle
                  % commands, so \etoctoclines could have been used, too.
\etocmarkboth\contentsname
\etocmulticolstyle[1]                   % one-column display
    {\pdfbookmark[1]{Table of contents}{MAINTOC}% create a bookmark in the pdf
     \noindent\bfseries\Large
     \leaders\hrule height1pt\hfill
     \MakeUppercase{Table of Contents}}
\begingroup                             % use a group to limit the scope of the
  \etocsetlevel{subsection}{3}          %   subsection level change.
  \etocsetlevel{subsubsection}{4}       % anything > tocdepth=3.
  \tableofcontents \label{toc:main}
\endgroup
\end{verbatim}
In this way, the subsections used the style originally designed for
subsubsections, the subsubsections were not printed. Without this modification,
the appearance would have been very different: the package line styles were
targeted to be employed in documents with many many sub-sub-sections, in a
two-column layout, giving thus a more compact output that what is achieved by
the default \LaTeX{} table of contents. But here, we have few sub-sub-sections
and it is more interesting to drop them and print in a visually different manner
sections and subsections. 


\section{Scope of commands added to 
         the \texorpdfstring{\texttt{.toc}}{.toc} file}

\begingroup % pour \small et \MacroFont en particulier.
\small

\subsection{Testing the scope}

Let us switch to the color red, and also add this command to the |.toc| file:

\color{red!50}
\addtocontents{toc}{\string\color{red!50}}

\def\MacroFont{\ttfamily \footnotesize\hyphenchar\font45 }
\begin{verbatim}
   \color{red!50}                             % changing text color
   \addtocontents{toc}{\string\color{red!50}} % and also in the .toc file
\end{verbatim}


\subsection{This is a (pale) red subsection for illustrative purposes}

Actually, this title here was printed black, due to the way the |scrartcl| class
works (it would have been red in the |article| class), but we are more
interested in how it looks in the tables of contents: it does appear red in the
\hyperref[toc:main]{main table of contents} at the beginning of
this document, and also in the \hyperref[toc:a]{table of
contents for this part}. Both entries obey as expected the
|\color{red!50}| command inserted in the |.toc| file.

But let us now close this subsection and start a section.


\section{Am I also red?}

The question is about how it appears in the tables of contents: the answer is
that, yes it is red in the \hyperref[toc:main]{main TOC}, and no
it is not red in the \hyperref[toc:a]{local TOC for this part}.
The reason is that the \meta{finish} code for the subsection level closed a
group, as it used |\end{enumerate}|.

This illustrates the discussion from \autoref{ssec:limitations}. 

The default package line styles do not contain group opening and closing
instructions: the influence of a command added to the |.toc| file will propagate
until cancelled by another explicit such command inserted in the |.toc|
file.

\begin{verbatim}
    \normalcolor
    \addtocontents{toc}{\string\normalcolor}
\end{verbatim}
\endgroup

\normalcolor
\addtocontents{toc}{\string\normalcolor}

Back to black. Note that this scope problem arises in real life in a
multi-lingual document, as the |babel| package writes to the |.toc| file the
language changes occurring in the document. 


\clearpage
\etocdepthtag.toc {globalcmds}

\part{Commands for the toc display style}
\label{part:globalcmds}

\thispartstats

\etocsettocstyle{}{}
\etocstandardlines
\localtableofcontents \label{toc:globalcmds}


\section{Specifying the toc display style}


The \emph{toc display} style says whether the TOC appears with
multiple columns or just one, whether the title is typeset as
in the |article| or |book| class, or should be centered above
the entries, with rules on its sides, or if the entire TOC
should be put in a frame. For example, to opt for a ruled
heading and single column layout, one issues commands of the
following type:
\begin{verbatim}
\etocruledstyle[1]{Title} \tableofcontents    (or \localtableofcontents)
shortcuts:         \etocruled[1]{Title}  (or  \etoclocalruled[1]{Title})
\end{verbatim}

\subsection{The command \csbhyp{etocsettocstyle}}
\label{etocsettocstyle}

This is a command with two mandatory arguments:\\
\centerline{\csb{etocsettocstyle}\marg{before\_toc}%
\marg{after\_toc}}
The \marg{before\_toc} part is responsible for typesetting the
heading, for example it can be something like
\starit{section}|{\contentsname}|. 

Generally speaking this heading
should leave \TeX{} in ``vertical mode'' when the actual
typesetting of the contents will start: the line styles (either
from the standard classes or the package default line styles)
all expect to get started in `vertical mode'.

The first argument to \csb{etocsettocstyle} can also contain
instructions to mark the page headings.  Or
it could check (book class) to see if two-column mode is on,
and switch to one-column style, and the \meta{after\_toc} part
would then reenact the two-column mode.

The commands to be described next \csb{etocmulticolstyle},
\csb{etocruledstyle}, and \csb{etocframedstyle} all call
\csa{etocsettocstyle} as a lower-level routine, to start a 
\texttt{multi\-cols} environment in \marg{before\_toc} and close it in
\marg{after\_toc}. 

\subsection{The commands \csbhyp{etocmulticolstyle}, \csbhyp{etocmulticol}, and \csbhyp{etoclocalmulticol}}
\label{etocmulticolstyle}
\label{etocmulticol}
\label{etoclocalmulticol}

This is a command with one optional and one mandatory argument:\\
\centerline{\csb{etocmulticolstyle}%
  \oarg{number\_of\_columns}\marg{heading}} The
\meta{number\_of\_columns} can go from 1 to 10 (it defaults to 2; if its
value is 1, naturally no |multicols| environment is then created). The
\meta{heading} will typically be some `vertical' material like:
  \meta{heading} = |\section*|\marg{title}
but one may also have horizontal material like |\fbox{Hello World}| (\etoc
adds automatically a |\par| at the end of this ``heading'' argument to
\csb{etocmulticolstyle}). Here is for example
how the main table of contents of this document was
configured:
\begin{verbatim}
\etocmulticolstyle{\noindent\bfseries\Large
                   \leaders\hrule height1pt\hfill
                   \MakeUppercase{Table of Contents}}
\end{verbatim}
After \csa{etocmulticolstyle} all future \csa{tableofcontents} will use the
specified style, if it does not get changed in-between. A shortcut for
just one table of contents and 
no impact on the styles of later TOCs is:\\
\centerline{\csa{etocmulticol}\oarg{number\_of\_columns}\marg{heading}}
And there is also
\csa{etoclocalmulticol}\oarg{number\_of\_columns}\marg{heading}.

\subsubsection{The command \csbhyp{etoctocstyle}}
\label{etoctocstyle}

\centeredline{\csb{etoctocstyle}\oarg{kind}%
\marg{number\_of\_columns}\marg{title}}
\centeredline{=
\csb{etocmulticolstyle}|[|{\itshape number\_of\_columns}|]|%
|{\kind*{|\itshape title\upshape|}}|}
where |kind| is one of |chapter|, |section|, . . . and defaults
to |chapter| or |section| depending on the document class.

\paragraph{\texorpdfstring{\csbhyp{etoc\-toc\-style\-with\-marks}}{etoctocstylewithmarks}}%
\leavevmode\unskip{\color{blue}\oarg{kind}\marg{number\_of\_columns}\marg{title}\marg{mark}}
\label{etoctocstylewithmarks}
\label{etoctocstylewithmarksnouc}

\centeredline
{=\csb{etocmulticolstyle}|[|{\itshape number\_of\_columns}|]|%
|{\kind*{|\itshape title \ttfamily\upshape\string\markboth%
|{\MakeUppercase{|{\rmfamily\itshape mark}|}}}}|} 
where |kind| is one of |chapter|, |section|, ... The
actual display of the marks depends on the settings of the
page style. There is variant \csb{etoctocstylewithmarksnouc}
which does not uppercase.


\paragraph{Do we really want paragraph entries in the TOC?}

\paragraph{really?}

\subsection{The commands  \csbhyp{etocruledstyle}, \csbhyp{etocruled} and \csbhyp{etoclocal\-ruled}}
\label{etocruledstyle}
\label{etocruled}
\label{etoclocalruled}

The general format of \csa{etocruledstyle} is:\\
\centerline{\csb{etocruledstyle}%
\oarg{number of columns}\marg{title of the toc}}
\noindent 
The title is horizontal material (the |LR| mode of 
\emph{\LaTeX{}, a document preparation system}): if it
does not fit on one line it should be put in a \csa{parbox}  of
a given width.
The green frame for the heading of the table of contents at
the \hyperref[toc:a]{start of the second part of this
  document} was obtained with:
\begin{verbatim}
\etocruledstyle[1]{\etocfontminusone\color{green}%
     \fboxrule1pt\fboxsep1ex
     \framebox[\linewidth]
              {\normalcolor\hss Contents of this part\hss}}
\end{verbatim}


As a shortcut to set the style with \csb{etocruledstyle} and
then issue a
\csa{tableofcontents}, all inside a group
so that  future table of contents will not be
affected, there is:\\
\centerline{\csb{etocruled}\oarg{number\_of\_columns}\marg{title}}
And the local form will be \csb{etoclocalruled}.

\subsection{The commands \csbhyp{etocframedstyle},  \csbhyp{etocframed}, and \csbhyp{etoclocal\-framed}}
\label{etocframedstyle}
\label{etocframed}
\label{etoclocalframed}

Same mechanism:\\
\centerline{\csb{etocframedstyle}%
  \oarg{number\_of\_columns}\marg{title}}
and the accompanying shortcut:\\
\centerline{\csb{etocframed}\oarg{number\_of\_columns}\marg{title}} The
shortcut is used if one does not want to modify the style of the next
TOCs (the other way is to put the whole thing inside braces or a
|\begingroup...\endgroup|; there is also \csa{etoclocalframed} for a
local table of contents).

The entire table of contents is framed. The title itself is not framed:
if one wants a frame one should set it up inside the \meta{title}
argument to \csa{etocframedstyle} or \csa{etocframed}. The colors for
the background and for the components (top, left, right, bottom) of the
border are specified via suitable |\renewcommand|'s (see
\autoref{ssec:customdisplay}).

A |minipage| is used, hence the produced table of contents isn't
compatible with a page break. For allowing page breaks, use of
the commands of
\href{http://ctan.org/pkg/mdframed}{mdframed}\footnote{\url{http://ctan.org/pkg/mdframed}}
or 
\href{http://ctan.org/pkg/tcolorbox}{tcolorbox}\footnote{\url{http://ctan.org/pkg/tcolorbox}}
in the arguments of \csb{etocsettocstyle}  
is recommended.

Examples in this document are on pages \pageref{toc:d},
\pageref{toc:floating}, \pageref{toc:b}, and \pageref{toc:clone}.


\subsection{Headings, titles, \csbhyp{etocoldpar}, \csbhyp{etocinnertopsep}}
\label{etocinnertopsep}
\label{etocoldpar}

For \csb{etocmulticolstyle} the mandatory \meta{heading} argument can be
either 
vertical mode material like |\section*{\emph{Table of Contents}}| or
horizontal mode material like in the simple |\etocmulticolstyle{Hello World}|.

No explicit |\par| or empty line can be inserted in the mandatory
argument of \csb{etocmulticolstyle}, but \etoc provides \csb{etocoldpar}
as a substitute: it does |\let\etocoldpar\par| before the |multicols|
environment and inserts this |\etocoldpar|\footnote{this command
  \csa{etocoldpar} (= working \csa{par} in the argument to
  \csa{etocmulticolstyle}) is not related to the switch \csb{etocinline}
  whose purpose is to tell \etoc not to do a \csa{par} before the table
  of contents.} at the end of the heading, then does a vertical skip of
value \csa{etocinnertopsep}. The command \csb{etocoldpar} can also be
used explicitely if needed in the mandatory argument to
\csa{etocmulticolstyle} (it is not allowed to insert an empty line
in this argument).

On the other hand the commands \csb{etocruledstyle} and
\csb{etocframedstyle} expect an argument ``in LR mode'' (to use the
terminology from \emph{LaTeX, a document preparation system}). This
means that multiline titles are only possible if enclosing
them inside something like a \csa{parbox}.



An important dimension used by all three of \csb{etocmulticolstyle},
\csb{etocruledstyle} and \csb{etocframedstyle} is
\csb{etocinnertopsep}. It gives the amount of separation
between the heading and the start of the contents. Its default
value is |2ex| and it is changed with
|\renewcommand*{\etocinnertopsep}|\marg{new\_value}, not with
|\setlength|. 



\subsection{The compatibility mode \csbhyp{etocstandarddisplaystyle}}
\label{etocstandarddisplaystyle}

\etoc will then emulate what the document class would have
done regarding the global display style of the table of
contents, in its absence. All customizing from inside the
class should be obeyed, too.

\subsection{The command \csbhyp{etoc\-inline}}
\label{etocinline}
\label{etocnopar}
\label{etocdisplay}

With \csb{etocinline}, or its synonym |\etocnopar|, the
|\tableofcontents| command and its variants do \emph{not} first issue a
|\par| to close the previous paragraph. Hence, the table of contents can
be printed in an inline style; or, if used only for preparing some token
list or macro, it will leave nothing in the token stream on execution.

Issue \csb{etocdisplay} to return to the default situation that
|\tableofcontents| and variants issue a |\par| to switch to vertical
mode before typesetting the TOC title and contents.

\section{Starred variants of the \csbhyp{tableofcontents}  etc... commands}
\label{tableofcontents*}
\label{localtableofcontents*}
\label{etocbeforetitlehook}
\label{etocaftertitlehook}
\label{etocaftercontentshook}
\label{etocmemoirtoctotocfmt}

The \toc, \localtoc, \csa{etocmulticol}, and all their cousins and
variants have starred variants (the star must be before the other
arguments). For all but the |memoir| class, they are like the original.
For the |memoir| class, the original prints an entry in the |.toc| file,
as is the usage for the original \toc command in that class, whereas the
starred variants do not, as is the habit in that class.

As soon as one starts using local table of contents one
discovers that the default |memoir| thing which is to create a
|chapter| entry for each TOC is not convenient. The command
\csb{etocmemoirtoctotocfmt}\marg{kind}\marg{name} will change
the format (\meta{kind} is |chapter|, |section|, |subsection|... and
\meta{name} can be for example \csa{contentsname}.) The initial set-up
is with |chapter| and |\contentsname|. 

The format of the actual heading of the TOC should also be set
appropriately (for example with \csa{etoctocstyle}), to use the
identical division unit as in the first argument to
\csa{etocmemoirtoctotocfmt}. 

A weird situation arises when one has two successive
\csa{localtableofcontents} (obviously this is not a truly real
life situation), just after a \csa{part} for example. The first
one creates (if the default has not been modified as indicated
above) a Chapter heading which is
written to the |.toc|. Then the second one thinks to be local
to this chapter . . . and as a result it displays nothing. The
fix is to define the second one to be a clone of the first
one.

Independently of the situation with the |memoir| class there is
generally speaking a hook macro called
\csb{etocaftertitlehook} which is inhibited by using the
starred variants of the displaying commands. Except for the
|memoir| class, this hook is initially defined to do nothing.

There is \csb{etocaftercontentshook}, similarly defined to do
nothing. And \csb{etocbeforetitlehook} is also initially defined to do
nothing. They can be used for some special effects.

\section{Table of contents for this part}


\subsection{Testing the compatibility mode}

As a third example we now print the local table of contents
for this part. First we will test the compatibility mode.\footnote{the
present document uses the |scrartcl| class, and we check here that
the \etoc compatibility mode does respect the customizing done via the
class commands.}   The original was invisibly defined with a label at the
beginning of this \autoref{part:globalcmds}.
\begin{verbatim}
\KOMAoptions{toc=left}
\etocstandarddisplaystyle % necessary for the display to obey toc=left
\etocstandardlines
\tableofcontents \ref{toc:globalcmds}
\end{verbatim}
\KOMAoptions{toc=left}
\etocstandarddisplaystyle
\etocstandardlines
\tableofcontents \ref{toc:globalcmds}

\subsection{A framed display}

We now opt for a ``framed'' style, using the package default
line styles and some colors added (it has been put in a float which appears
\vpageref{toc:b}).\footnote{inside the |figure| environment and before the
  framed toc, which uses |multicols|, we added \csa{normalcolor} as work-around
  to an interaction bug (related to the \csa{color\{red\}} command we added to
  the |.toc| file) between |multicols|, |color| and the |figure|
  environment. This bug has nothing to do with \etoc.}

\begin{verbatim}
\etocdefaultlines
\begingroup 
\renewcommand{\etoccolumnsep}{2em}
\renewcommand{\etocinnerleftsep}{1.5em}
\renewcommand{\etocinnerrightsep}{1.5em}
% specify a background color for the toc contents
\renewcommand{\etocbkgcolorcmd}{\color{yellow!10}}
% set up the top and bottom rules 
\renewcommand{\etoctoprule}{\hrule height 1pt}
\renewcommand{\etoctoprulecolorcmd}{\color{red!25}}
\renewcommand{\etocbottomrule}{\hrule height 1pt}
\renewcommand{\etocbottomrulecolorcmd}{\color{red!25}}
% set up the left and right rules
\renewcommand{\etocleftrule}{\vrule width 5pt}
\renewcommand{\etocrightrule}{\vrule width 5pt}
\renewcommand{\etocleftrulecolorcmd}{\color{red!25}}
\renewcommand{\etocrightrulecolorcmd}{\color{red!25}}
% use \fcolorbox to set up a colored frame for the title
\fboxrule1pt
\renewcommand{\etocbelowtocskip}{0pt\relax}
\etocframedstyle {\normalsize\rmfamily\itshape
  \fcolorbox{red}{white}{\parbox{.8\linewidth}{\centering
      This is a table of contents \`a la \etoc, but just for
      the sections and subsections in this part. As it is put
      in a frame, it has to be small enough to fit on 
      one page. It has the label |toc:b|.}}}
\begin{figure}[ht!]
  \centering
\normalcolor % work-around to a bug involving color and multicols (and figure)
\tableofcontents \label{toc:b} \ref{toc:globalcmds}
\end{figure}
\endgroup
\end{verbatim}


\etocdefaultlines
\begingroup 
\renewcommand{\etoccolumnsep}{2em}
\renewcommand{\etocinnerleftsep}{1.5em}
\renewcommand{\etocinnerrightsep}{1.5em}
% specify a background color for the toc contents
\renewcommand{\etocbkgcolorcmd}{\color{yellow!10}}
% set up the top and bottom rules 
\renewcommand{\etoctoprule}{\hrule height 1pt}
\renewcommand{\etoctoprulecolorcmd}{\color{red!25}}
\renewcommand{\etocbottomrule}{\hrule height 1pt}
\renewcommand{\etocbottomrulecolorcmd}{\color{red!25}}
% set up the left and right rules
\renewcommand{\etocleftrule}{\vrule width 5pt}
\renewcommand{\etocrightrule}{\vrule width 5pt}
\renewcommand{\etocleftrulecolorcmd}{\color{red!25}}
\renewcommand{\etocrightrulecolorcmd}{\color{red!25}}
% use \fcolorbox to set up a colored frame for the title
\fboxrule1pt
\renewcommand{\etocbelowtocskip}{-.5\baselineskip\relax}
\etocframedstyle {\normalsize\rmfamily\itshape
  \fcolorbox{red}{white}{\parbox{.8\linewidth}{\centering
      This is a table of contents \`a la \etoc, but just for
      the sections and subsections in this part. As it is put
      in a frame, it has to be small enough to fit on 
      one page. It has the label |toc:b|.}}}
\begin{figure}[ht!]
  \centering
\normalcolor % work-around to a bug involving color and multicols (and figure)
\tableofcontents \label{toc:b} \ref{toc:globalcmds}
\end{figure}
\endgroup

% Il y a un color leak du framed mais uniquement lorsqu'il est mis dans le
% float. 2013/10/13, qui révèle un bug (?? NON) du style framed je vais regarder
% mais bon. Le leak apparaît avec ruled aussi, et même avec juste multicolstyle
% MAIS PAS EN UNE SEULE COLONNE (même framed ou ruled). il semble qu'il y aie
% donc un problème d'interaction avec multicol là. à voir. Pas le temps
% maintenant.

% 2013/10/14
% il s'agit en fait d'un bug de color+multicols+figure qui n'a rien à voir avec
% etoc: 
% http://tex.stackexchange.com/questions/138783/color-leak-from-multicols-within-a-figure
% J'ai trouvé le work-around qui consiste simplement à ajouter un \normalcolor
% _avant_ le multicols à l'intérieur de figure

\subsection{A (crazy) inline display}

Let us finally make some crazy inline display of the table of
contents of this entire document. We will typeset the subsections as
footnotes... This kind of style is suitable for a hyperlinked
document, probably not for print! (although I like it, but my personal taste in
many matters does not seem to be widely shared).

%%%% Note: 27 april 2014 

%%%% except for a miraculous situation depending from the quantity of previous
%%%% material this TOC will have links extending accross pagebreaks, which
%%%% dvipdfmx does not know how to handle completely. Apart from that the output
%%%% is ok, thus no need to try seriously to avoid them. 

\begingroup
\newsavebox{\forsubsections}
\etocsetstyle{part}{\upshape. \etocskipfirstprefix}{. \upshape}{\bfseries\etocname:~~}{}
\etocsetstyle{section}{\itshape\etocskipfirstprefix}{, }{\mdseries\etocname}{}
\etocsetstyle{subsection}
   {\begin{lrbox}{\forsubsections}\upshape\etocskipfirstprefix}
   {; }
   {\etocname}
   {\end{lrbox}\footnote{\unhbox\forsubsections.}}
\etocsetstyle{subsubsection}{ (\itshape\etocskipfirstprefix}
  {, }{\etocname}{\/\upshape)}
\etocsettocstyle{Here is the inline table of contents. }{.\par}
\tableofcontents \label{toc:crazyinline}
\endgroup

The code used:
\begin{verbatim}
\begingroup
\newsavebox{\forsubsections}
\etocsetstyle{part}{\upshape. \etocskipfirstprefix}{. \upshape}
                      {\bfseries\etocname:~~}{}
\etocsetstyle{section}{\itshape\etocskipfirstprefix}{, }
                      {\mdseries\etocname}{}
\etocsetstyle{subsection}
   {\begin{lrbox}{\forsubsections}\upshape\etocskipfirstprefix}
   {; }{\etocname}{\end{lrbox}\footnote{\unhbox\forsubsections.}}
\etocsetstyle{subsubsection}
  { (\itshape\etocskipfirstprefix}{, }{\etocname}{\/\upshape)}
\etocsettocstyle{Here is the inline table of contents. }{.\par}
\tableofcontents
\endgroup
\end{verbatim}


\clearpage
\etocdepthtag.toc {custom}

\part{Using and customizing \etoc}
\label{part:custom}

\thispartstats

\etocdefaultlines
\renewcommand{\etoctoprule}{\hrule height2pt depth0pt}
\renewcommand{\etoctoprulecolorcmd}{\color{red}}

\etocruledstyle{\normalfont\normalsize\rmfamily\fboxrule1pt\color{red}%
  \fbox{\parbox{.8\linewidth}{\centering\normalcolor This is a table of
      contents for the sections and
      subsections in this part. It carries the label |toc:c|}}} 

\localtableofcontents \label{toc:c}


\section{Summary of the main style commands}

\subsection{Setting up local styles}

\hbox{\color{green}\fboxrule1pt\fboxsep1em
\setbox0\hbox{\csa{etocthename}, \csa{etocthenumber}, \csa{etocthepage}, \csa{etoclink}\marg{linkname}}%
\framebox[\linewidth][c]
{\vbox{\hsize\wd0\normalcolor\noindent
\csa{etocsetstyle}\marg{levelname}%
  \marg{start}\marg{prefix}\marg{contents}\marg{finish}\\
\csa{etocname}, \csa{etocnumber}, \csa{etocpage},
\csa{etocifnumbered}\marg{A}\marg{B}\\
\csa{etocthename}, \csa{etocthenumber}, \csa{etocthepage}, \csa{etoclink}\marg{linkname}
}}}

\subsection{Setting up toc display styles}

\medskip
\hbox{\color{green}\fboxrule1pt\fboxsep1em
\setbox0\hbox{\csa{etoctocstylewithmarksnouc}\oarg{kind}%
\marg{number\_of\_columns}\marg{title}\marg{mark}}%
\framebox[\linewidth][c]
{\vbox{\hsize\wd0
\normalcolor\noindent
\csa{etocmulticolstyle}\oarg{number\_of\_columns}\marg{heading}\\
\csa{etoctocstyle}\oarg{kind}\marg{number\_of\_columns}\marg{title}\\
\csa{etoctocstylewithmarks}\oarg{kind}\marg{number\_of\_columns}%
\marg{title}\marg{mark}\\
\csa{etoctocstylewithmarksnouc}\oarg{kind}\marg{number\_of\_columns}%
\marg{title}\marg{mark}\\
\csa{etocruledstyle}\oarg{number\_of\_columns}\marg{title}\\
\csa{etocframedstyle}\oarg{number\_of\_columns}\marg{title}\\
\csa{etocsettocstyle}\marg{before\_toc}\marg{after\_toc}}}}

\subsection{Displaying tables of contents}


\medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em
  \setbox0\hbox{\csa{etocname}, \csa{etocnumber},
    \csa{etocpage}, \csa{etocifnumbered}\marg{A}\marg{B}}%
  \framebox[\linewidth][c]
  {\vbox{\hsize\wd0\normalcolor\noindent
      \toc\\
      \localtoc\\
      \csa{etocmulticol}\oarg{number\_of\_columns}\marg{heading}\\
      \csa{etoclocalmulticol}\oarg{number\_of\_columns}\marg{heading}\\
      \csa{etocruled}\oarg{number\_of\_columns}\marg{title}\\
      \csa{etoclocalruled}\oarg{number\_of\_columns}\marg{title}\\
      \csa{etocframed}\oarg{number\_of\_columns}\marg{title}\\
      \csa{etoclocalframed}\oarg{number\_of\_columns}\marg{title}\\
      \hbox{}{\itshape\ttfamily\ \ \ \  and their starred variants}
   }}}

\subsection{Labels and references}

The commands (starred or not) to actually display the table of contents
can be followed with optional labels or references:\par

\medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em
  \setbox0\hbox{\csa{etocname}, \csa{etocnumber},
    \csa{etocpage}, \csa{etocifnumbered}\marg{A}\marg{B}}%
  \framebox[\linewidth][c]
  {\vbox{\hsize\wd0\normalcolor\noindent
      \toc \csa{label}|\{toc:here\}|\\ 
      \toc \csa{ref}|\{toc:far\}| \\
      \toc \csa{label}|\{toc:here\}| \csa{ref}|\{toc:far\}| \\
      \localtoc \csa{label}|\{toc:here\}|\\
      \hbox{}{\itshape\ttfamily\ \ \ \ similarly with\ }%
      \csa{etocmulticol}{\itshape\ttfamily\ etc . . . }
   }}}


\medskip The commands for local tables of
contents do \emph{not} react to a \csa{ref} following them. 

When re-displaying another toc, only its contents are transferred:
both the line styles and the toc display style are the ones
currently defined, not the ones from the cloned toc.


\section{The package default line styles: \csbhyp{etocdefaultlines}}
\label{etocdefaultlines}

These line styles were written at an early stage in the
development of the package; although the next section explains how
to customize the font choicess or vertical spaces, etc\dots, used
by these line styles, most other changes would require copying
them from the sources and modify them directly. Admittedly they
have been written at a rather scary low-\TeX{} level, and will not
serve as a very friendly starting point. 

Activating their use is done via \csa{etocdefaultlines}, or
\csa{etoctoclines} if the line styles have not been modified with
\csa{etocsetstyle}. Sections and sub-sections are printed in
essentially the same manner, except that the leading for
sub-sections is a bit smaller (with document classes lacking a
\csa{chapter} command, the sections are printed in bold typeface;
this is the case in the present document). Sub-sub-sections are
printed inline, in one paragraph, with no numbers or page numbers.
This style was designed and tested with documents having lots of
sub-sub-sections, and should be used on a two-column layout: it
provides (only in that situation with many sub-sub-sections) a
more compact presentation than what is achieved by the \LaTeX{}
default.\footnote{and there will never be a Part or Chapter entry
  alone at the bottom of a column or page (except if it has no
  sub-unit).} On the other hand, used with a one-column layout,
and with few sub-sub-sections, the style is a bit more spread out
vertically than the \LaTeX{} default, sub-sections are not
visually much different from sections (especially for document
classes with a \csa{chapter} command), so the result is less
hierarchical in appearance than in the \LaTeX{} default.

In this document, for the \hyperref[toc:main]{main table of contents}, we did 
|\etocsetlevel{subsection}{3}| hence the sub-sections were printed with the
sub-sub-section inline style. 

Let us, to the contrary, typeset now this main table of contents as if the
document had been done with a class having the \csa{chapter} command: we will
print sections as chapters, and subsections as sections. We use
\csa{etocsetlevel} for that, and also we need to change the font style of
``sections'' (which in truth are our subsections) to use not the bold but the
medium series; we modify the \csa{etocfontone} command for that. Also we use dot
leaders which are less spread out than in the package default.


\begin{verbatim}
\etocruledstyle[2]{\normalfont\normalsize\rmfamily\itshape
  \fbox{\parbox{.6\linewidth}{
      \leftskip 0pt plus .5fil
      \rightskip 0pt plus -.5fil
      \parfillskip 0pt plus 1fil This is the global table of
      contents on two columns, using \etoc default line styles, but with
      sections as chapters, and subsections as sections.
      }}}
\etocdefaultlines
\etocsetnexttocdepth{1}
\begingroup
\etocsetlevel{section}{0}
\etocsetlevel{subsection}{1}
\renewcommand*{\etocfontone}{\normalfont \normalsize}
\renewcommand*{\etoctoclineleaders}
        {\hbox{\normalfont\normalsize\hbox to 1ex {\hss.\hss}}}
\sloppy
\tableofcontents
\endgroup
\end{verbatim}

\etocruledstyle[2]{\normalfont\normalsize\rmfamily\itshape
  \fbox{\parbox{.6\linewidth}{
      \leftskip 0pt plus .5fil
      \rightskip 0pt plus -.5fil
      \parfillskip 0pt plus 1fil This is the global table of
      contents on two columns, using \etoc default line styles, but with
      sections as chapters, and subsections as sections.
      }}}

\etocdefaultlines
\etocsetnexttocdepth{1}

\begingroup
\etocsetlevel{section}{0}
\etocsetlevel{subsection}{1}
\renewcommand*{\etocfontone}{\normalfont \normalsize}
\renewcommand*{\etoctoclineleaders}
        {\hbox{\normalfont\normalsize\hbox to 1ex {\hss.\hss}}}
\sloppy
\tableofcontents
\endgroup

\section{Customizing \etoc}

\subsection{Customizing  the \etoc pre-defined line styles}

We will simply list the relevant commands as defined in the
package. Customizing them goes through suitable
\csa{renewcommand}s:
\begin{verbatim}
\newcommand*\etocfontminustwo{\normalfont \LARGE \bfseries}
\newcommand*\etocfontminusone{\normalfont \large \bfseries}
\newcommand*\etocfontzero{\normalfont \large \bfseries}
\newcommand*\etocfontone{\normalfont \normalsize \bfseries}
\newcommand*\etocfonttwo{\normalfont \normalsize}
\newcommand*\etocfontthree{\normalfont \footnotesize}

\newcommand*\etocsepminustwo{4ex plus .5ex minus .5ex}
\newcommand*\etocsepminusone{4ex plus .5ex minus .5ex}
\newcommand*\etocsepzero{2.5ex plus .4ex minus .4ex}
\newcommand*\etocsepone{1.5ex plus .3ex minus .3ex}
\newcommand*\etocseptwo{.5ex plus .1ex minus .1ex}
\newcommand*\etocsepthree{.25ex plus .05ex minus .05ex}

\newcommand*\etocminustwoleftmargin{1.5em plus 0.5fil}
\newcommand*\etocminustworightmargin{1.5em plus -0.5fil}
\newcommand*\etocminusoneleftmargin{1em}
\newcommand*\etocminusonerightmargin{1em}

\newcommand*\etocbaselinespreadminustwo{1}
\newcommand*\etocbaselinespreadminusone{1}
\newcommand*\etocbaselinespreadzero{1}
\newcommand*\etocbaselinespreadone{1}
\newcommand*\etocbaselinespreadtwo{1}
\newcommand*\etocbaselinespreadthree{.9}
\newcommand*\etoctoclineleaders
    {\hbox{\normalfont\normalsize\hbox to 2ex {\hss.\hss}}}
\newcommand*\etocabbrevpagename{p.~}  % initial of "page"
\newcommand*\etocpartname{Part}  % prior to v1.08b, was \partname
% but this didn't make sense e.g. with babel+frenchb whose \frenchpartname
% takes into account the value of the part counter.
\newcommand*\etocbookname{Book} % to be modified according to language
\end{verbatim}

No customizing of the standard line styles is possible from
within \etoc. As already explained, when
\csa{etocstandardlines} has been issued, the package just makes
itself very discrete and acts only at the global level, and
the TOC entries are (hopefully) formatted as would have
happened in the absence of \etoc.\footnote{with the
  KOMA-script classes, we noticed that
  \csa{etocstandarddisplaystyle} was apparently needed for the
  KOMA options |toc=left| to be active at the level of the line entries.}  


The \csa{etocstandardlines} compatibility mode will work also with
sectioning commands made known to \etoc via \csa{etocsetlevel},
under the condition of course that these sectioning commands
are accompanied with all the relevant definitions for
typesetting toc entries in the \LaTeX{} default manner
(existence of the macros \csa{l@something} . . .).

Using the command \csa{etocsetstyle}, be it in the preamble or
in the body of the document, has the secondary effect of
switching off the compatibility mode.

\subsection{Customizing the toc display styles}
\label{ssec:customdisplay}

Again we list the relevant macros, what they do should be
legible from their names. Note that \csa{renewcommand}'s and
not \csa{setlength}'s have to be used for what appear to be
lengths, and that color commands are not just color
specifications, they must include \csa{color}, and are canceled
by re-defining them to do \csa{relax}.
\begin{verbatim}
\newcommand*\etocabovetocskip{3.5ex plus 1ex minus .2ex} 
\newcommand*\etocbelowtocskip{3.5ex plus 1ex minus .2ex}

\newcommand*\etoccolumnsep{2em}
\newcommand*\etocmulticolsep{0ex}
\newcommand*\etocmulticolpretolerance{-1}
\newcommand*\etocmulticoltolerance{200}
\newcommand*\etocdefaultnbcol{2}
\newcommand*\etocinnertopsep{2ex}
\newcommand*\etoctoprule{\hrule}
\newcommand*\etoctoprulecolorcmd{\relax}

% for the framed style only:
\newcommand*\etocinnerleftsep{2em}
\newcommand*\etocinnerrightsep{2em}
\newcommand*\etocinnerbottomsep{3.5ex}

\newcommand*\etocleftrule{\vrule}
\newcommand*\etocrightrule{\vrule}
\newcommand*\etocbottomrule{\hrule}
\newcommand*\etocleftrulecolorcmd{\relax}
\newcommand*\etocrightrulecolorcmd{\relax}
\newcommand*\etocbottomrulecolorcmd{\relax}

\newcommand*\etocbkgcolorcmd{\relax}

% hooks
\newcommand\etocframedmphook{\relax}
\end{verbatim}

The \csa{etocframedmphook} is positioned immediately
after the beginning of a minipage environment where the
contents of the framed TOC are typeset. 

The \csa{...colorcmd} commands are initially set to expand to
\csa{relax} (hence do not require package |color| or |xcolor|
to be loaded). If one has modified a command such as
\csa{etocbkgcolorcmd} to expand to a color command and wants
to reset it to do nothing, one \emph{must} use
|\renewcommand{\etocbkgcolorcmd}{\relax}| and not
\csa{let}\csa{etocbkgcolorcmd}\csa{relax}.

Regarding the dimensions of the top rule they can be specified
in |ex|'s or |em|'s as in this example:
\centeredline{|\renewcommand{\etoctoprule}{\hrule height 1ex}|} 
The package code is done in such a manner
that it is the font size in instance at the end of typesetting
the title argument to \csa{etocruledtoc} or
\csa{etocframedtoc} which will be used for the meaning of the
`1ex'. Of course also the other rule commands can have their
dimensions in font relative units, but their values are
decided on the basis of the font in effect just before the
table of contents.

The top and bottom rules do not have to be rules and can be
horizontal \emph{leaders} (of a specified height) in the general
\TeX{} sense. However the left and right rules are not
used as (horizontal) leaders but as objects of a given specified
width. Note that \emph{only} the Plain \TeX{} syntax for rules is
accepted here. 

\section{One more example of colored TOC layout}
\label{ssec:tocclone}

The command \csa{etocframedstyle} puts the title on the top
rule in a centered position. This is not very convenient for
this example so we included the title as part of the
\meta{start} code at section level, to get it \emph{inside}
the frame.

\begin{verbatim}
\begingroup
\definecolor{subsecnum}{RGB}{13,151,225}
\definecolor{secbackground}{RGB}{0,177,235}
\definecolor{tocbackground}{RGB}{212,237,252}

\renewcommand{\etocbkgcolorcmd}{\color{tocbackground}}
\renewcommand{\etocleftrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocrightrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocbottomrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etoctoprulecolorcmd}{\color{tocbackground}}

\renewcommand{\etocleftrule}{\vrule width 1cm}
\renewcommand{\etocrightrule}{\vrule width .5cm}
\renewcommand{\etocbottomrule}{\hrule height 12pt}
\renewcommand{\etoctoprule}{\hrule height 12pt}

\renewcommand{\etocinnertopsep}{0pt}
\renewcommand{\etocinnerbottomsep}{0pt}
\renewcommand{\etocinnerleftsep}{0pt}
\renewcommand{\etocinnerrightsep}{0pt}

\newcommand\shiftedwhiterule[2]{%
    \hbox to \linewidth{\color{white}%
    \hskip#1\leaders\vrule height1pt\hfil}\nointerlineskip\vskip#2}

\etocsetstyle{subsubsection}{\etocskipfirstprefix}
  {\shiftedwhiterule{\leftskip}{6pt}}
  {\sffamily\footnotesize
     \leftskip2.5cm\hangindent1cm\rightskip1cm\noindent
     \hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
     \color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
     \rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par
     \nointerlineskip\vskip3pt}
  {}

\etocsetstyle{subsection}{\etocskipfirstprefix}
  {\shiftedwhiterule{1.5cm}{6pt}}
  {\sffamily\small
     \leftskip1.5cm\hangindent1cm\rightskip1cm\noindent
     \hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
     \color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
     \rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par
     \nointerlineskip\vskip6pt}
  {}

\newcommand{\coloredstuff}[2]{%
            \leftskip0pt\rightskip0pt\parskip0pt
            \fboxsep0pt % \colorbox uses \fboxsep also when no frame!
       \noindent\colorbox{secbackground}
               {\parbox{\linewidth}{%
                    \vskip5pt
                    {\noindent\color{#1}#2\par}\nointerlineskip
                    \vskip3pt}}%
       \par\nointerlineskip}

\etocsetstyle{section}
{\coloredstuff{white}
     {\hfil \hyperref[toc:b]{\bfseries\large I am a twin of  
     that other TOC (click me!)}\hfil}}
{\vskip3pt\sffamily\small}
{\coloredstuff{white}
    {\leftskip1.5cm\rightskip.5cm\parfillskip-\rightskip
     \makebox[0pt][r]{\makebox[.5cm][r]{\etocnumber\hspace{.2cm}}}%
     \etocname\hfill\makebox[.5cm][r]{\etocpage\hspace{.2cm}}}%
 \vskip6pt }
{}

\etocframedstyle[1]{}
\tableofcontents \label{toc:clone} \ref{toc:globalcmds}
\endgroup
\end{verbatim}

\begingroup
\definecolor{subsecnum}{RGB}{13,151,225}
\definecolor{secbackground}{RGB}{0,177,235}
\definecolor{tocbackground}{RGB}{212,237,252}

\renewcommand{\etocbkgcolorcmd}{\color{tocbackground}}
\renewcommand{\etocleftrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocrightrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocbottomrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etoctoprulecolorcmd}{\color{tocbackground}}

\renewcommand{\etocleftrule}{\vrule width 1cm}
\renewcommand{\etocrightrule}{\vrule width .5cm}
\renewcommand{\etocbottomrule}{\hrule height 12pt}
\renewcommand{\etoctoprule}{\hrule height 12pt}

\renewcommand{\etocinnertopsep}{0pt}
\renewcommand{\etocinnerbottomsep}{0pt}
\renewcommand{\etocinnerleftsep}{0pt}
\renewcommand{\etocinnerrightsep}{0pt}

\newcommand\shiftedwhiterule[2]{%
    \hbox to \linewidth{\color{white}%
    \hskip#1\leaders\vrule height1pt\hfil}\nointerlineskip
\vskip#2}

\etocsetstyle{subsubsection}{\etocskipfirstprefix}
{\shiftedwhiterule{\leftskip}{6pt}}
{\sffamily\footnotesize
\leftskip2.5cm\hangindent1cm\rightskip1cm\noindent
\hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
\rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par
\nointerlineskip\vskip3pt}
{}

\etocsetstyle{subsection}{\etocskipfirstprefix}
{\shiftedwhiterule{1.5cm}{6pt}}
{\sffamily\small
\leftskip1.5cm\hangindent1cm\rightskip1cm\noindent
\hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
\rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par
\nointerlineskip\vskip6pt}
{}

\newcommand{\coloredstuff}[2]{%
            \leftskip0pt\rightskip0pt\parskip0pt
            \fboxsep0pt % \colorbox uses \fboxsep also when no frame!
       \noindent\colorbox{secbackground}
               {\parbox{\linewidth}{%
                    \vskip5pt
                    {\noindent\color{#1}#2\par}\nointerlineskip
                    \vskip3pt}}%
       \par\nointerlineskip}

% v1.07l on the occasion of traduction into German documentation 
     % APRIL 26, 2014 Improvement in the section style for better placement of
     % page number when the section name is more than one line long. Use of
     % \makebox rather than \hbox, to be more LaTeX like.
\etocsetstyle{section}
{\coloredstuff{white}
     {\hfil \hyperref[toc:b]{\bfseries\large I am a twin of  
     that other TOC (click me!)}\hfil}}
{\vskip3pt\sffamily\small}
{\coloredstuff{white}
    {\leftskip1.5cm\rightskip.5cm\parfillskip-\rightskip
     \makebox[0pt][r]{\makebox[.5cm][r]{\etocnumber\hspace{.2cm}}}%
     \etocname\hfill\makebox[.5cm][r]{\etocpage\hspace{.2cm}}}%
 \vskip6pt }
{}

\etocframedstyle[1]{}

\begin{figure}[ht!]\centering
    \tableofcontents \label{toc:clone} \ref{toc:globalcmds}
\end{figure}
\endgroup

The TOC has been put in a \hyperref[toc:clone]{float} which appears
\vpageref{toc:clone}. The coding is a bit involved\footnote{and reveals the
  author's preference for the \TeX{} syntax...} as it does not use any
additional package. Also, it was written at some early stage and I have not
revised it since.

A better solution would be to use some package to set
up a background color possibly extending accross pages, as the
framed style (which we used to get this background
color) can only deal with material short enough to fit on one
page.

Regarding colors, generally speaking all color commands inside
\etoc are initially defined to do nothing, and the choice to
use or not colors is left to the user.

\clearpage
\etocdepthtag.toc {tips}

\part{Tips}
\label{part:tipsandtricks}

\thispartstats

%%%% \invisiblelocaltableofcontents \label{toc:tipsandtricks}

\etocsettocstyle{}{}
\etocstandardlines
\localtableofcontents

\section{... and tricks}

\subsection{Hacking  framed parboxes}


\begin{verbatim}
\etocdefaultlines
\renewcommand\etoctoprule{\hrule height 2pt depth 2pt}
\etocruled{\color{green}\fboxrule2pt\fboxsep1ex
               \fbox{\raisebox{-\fontdimen22\textfont2}
                    {\color{blue}\parbox{.5\linewidth}
                       {\normalfont This text is perfectly centered
                        vertically with respect to the
                        surrounding horizontal rules.}}}}
\ref{toc:globalcmds}
\end{verbatim}

\etocdefaultlines

\renewcommand\etoctoprule{\hrule height 2pt depth 2pt}

\etocruled{\color{green}\fboxrule2pt\fboxsep1ex
              \fbox{\raisebox{-\fontdimen22\textfont2}
                    {\color{blue}\parbox{.5\linewidth}
                       {\normalfont This text is perfectly centered
                        vertically with respect to the
                        surrounding horizontal rules.}}}}
              \ref{toc:globalcmds}


\subsection{Interverting the levels}
\label{subsec:interverting}

Let us display and count all subsections occurring in this
document (see \autoref{part:surprising} for other uses of
this technique):  
\begin{verbatim}
\etocsetnexttocdepth{2}
\begingroup
\etocsetlevel{part}{3}
\etocsetlevel{section}{3}
\etocsetstyle{subsection}
    {\small\begin{enumerate}[itemsep=0pt,label=,leftmargin=0pt]}
    {\normalfont\bfseries\item}
    {\roman{enumi}. \mdseries\etocname{} (\etocnumber, p.~\etocpage)}
    {\end{enumerate}}
\renewcommand{\etoccolumnsep}{2.75em}
\renewcommand{\columnseprule}{1pt}
\etocmulticol[3]{\subsection{All subsections of this document}}
\endgroup
\end{verbatim}

\etocsetnexttocdepth{2}

\begingroup
\etocdefaultlines
\etocstandarddisplaystyle
\etocsetlevel{book}{3}
\etocsetlevel{part}{3}
\etocsetlevel{chapter}{3}
\etocsetlevel{section}{3}
\etocsetstyle{subsection}{\small
\begin{enumerate}[itemsep=0pt,label=,leftmargin=0pt]}
{\normalfont\bfseries\item}
{\roman{enumi}. \mdseries\etocname{} (\etocnumber, p.~\etocpage)}
{\end{enumerate}}

\renewcommand{\etoccolumnsep}{2.75em}
\renewcommand{\columnseprule}{1pt}

%%\etocmarkbothnouc{List of all subsections}
%% le mark (\markright) est fait par \subsection

\etocmulticol[3]{\subsection{All subsections of this document}\label{toc:allsubsections}}


\endgroup

\subsection{Displaying statistics}\label{ssec:statistics}

Each part of this document starts with a paragraph telling how many
sections and subsections it has. Well, each one of this paragraph is a
table of contents! We designed a macro \csa{thispartstats} to do that.
It uses ``storage'' boxes to keep the information about the first and
last section or subsection. Using boxes is the simplest manner to
encapsulate the |hyperref| link for later use (whether there is one or
none). However, one cannot modify then the font or the color (using the
\TeX{} primitive \csa{setbox} rather than the \LaTeX{} \csa{sbox} would
allow to change the color of the un-boxed saved box). If such a need
arises, one must switch from using boxes to using macros, and store the
|hyperref| data for later use as was done in the code presented in
\autoref{sec:molecule}. We present also this second method.

But first, the code of \csa{thispartstats}:\par
\begin{verbatim}
\newsavebox\firstnamei  \newsavebox\firstnumberi
\newsavebox\lastnamei   \newsavebox\lastnumberi
\newsavebox\firstnameii \newsavebox\firstnumberii
\newsavebox\lastnameii  \newsavebox\lastnumberii
\newcounter{mycounti}   \newcounter{mycountii}
\newcommand*{\thispartstatsauxi}{} \newcommand*{\thispartstatsauxii}{}
\newcommand*{\oldtocdepth}{}
\newcommand*{\thispartstats}{%
  \setcounter{mycounti}{0}%
  \setcounter{mycountii}{0}%
  \def\thispartstatsauxi{%
         \sbox{\firstnamei}{\etocname}%
         \sbox{\firstnumberi}{\etocnumber}%
         \def\thispartstatsauxi{}}%
  \def\thispartstatsauxii{%
         \sbox{\firstnameii}{\etocname}%
         \sbox{\firstnumberii}{\etocnumber}%
         \def\thispartstatsauxii{}}%
  \begingroup
  \etocsetstyle{subsection} {} {}
    {\thispartstatsauxii
     \stepcounter{mycountii}%
     \sbox{\lastnameii}{\etocname}%
     \sbox{\lastnumberii}{\etocnumber}} {}%
  \etocsetstyle{section} {} {}
    {\thispartstatsauxi
     \stepcounter{mycounti}%
     \sbox{\lastnamei}{\etocname}%
     \sbox{\lastnumberi}{\etocnumber}}
    {Here are some statistics for this part: it contains \arabic{mycounti}
    section\ifnum\value{mycounti}>1 s\fi{} and \arabic{mycountii}
    subsection\ifnum\value{mycountii}>1 s\fi. The name of the first section is
    \unhbox\firstnamei{} and the corresponding number is \unhbox\firstnumberi. 
    The name of the last section is \unhbox\lastnamei{} and its number is
    \unhbox\lastnumberi. The name of the first subsection is \unhbox\firstnameii{}
    and the corresponding number is \unhbox\firstnumberii. The name of the last
    subsection is \unhbox\lastnameii{} and its number is \unhbox\lastnumberii.}%
  \etocinline % cancels the automatic \par automatically before the TOC
  \etocsettocstyle {}{}
  \etocsetnexttocdepth{2}%
  \localtableofcontents  % to be used at the top level of a Part.
  \endgroup
}
\end{verbatim}

And now, the variant with macros rather than boxes (this variant as it
stands here is for using within a section).
\begin{verbatim}
\makeatletter
\newcommand*\firstsubname   {}  \newcommand*\lastsubname    {}
\newcommand*\firstsubnumber {}  \newcommand*\lastsubnumber  {}
\newcommand*\thisspecialstatsaux{}
\newcommand*{\thisspecialstats}{%
  \setcounter{mycounti}{0}%
  \def\thisspecialstatsaux{%
         \let\firstsubname\etocthelinkedname
         \let\firstsubnumber\etocthelinkednumber
         \def\thisspecialstatsaux{}}
  \begingroup
  \etocsetstyle{subsection} {} {}
    {\thisspecialstatsaux
     \stepcounter{mycounti}%
     \let\lastsubname\etocthelinkedname
     \let\lastsubnumber\etocthelinkednumber }
    {Here are some statistics for this section. It contains \arabic{mycounti}
      subsections. The name of its first is \emph{\firstsubname{}} and the 
      corresponding number is {\firstsubnumber}. The name of the last 
      subsection is \emph{\lastsubname{}} and its number is {\lastsubnumber}.}% 
   \etocsettocstyle {}{}
   \etocinline
   \etocsetnexttocdepth {1}%
   \localtableofcontents % to be used within a section
  \endgroup
}
\makeatother
\end{verbatim}

\subsection{Using depth tags}
\label{ssec:tocwithdepthtags}

We want a TOC which will have a heading for each |\part| (except
the last part with the code source, which we decide not to
include), and will additionally open up \autoref{part:globalcmds}
up to paragraphs. To achieve this we added to this source various
\csb{etocdepthtag.toc} commands, and it remains now to set the
levels for each tag using \csb{etocsettagdepth} (this was used
earlier in this document, in \autoref{sec:secondexample}, within a
group hence it did not affect the other tables of contents).

However, the package line styles do not display paragraphs, and the
standard line styles of the document class give too much vertical
spacing (in this context) when displaying a Part heading in the TOC. So
we cook up our own, quickly designed line styles, in the style of
\autoref{sec:firstexample} (but with a way to put page numbers on the
right which is more like the method used by \LaTeX2e's
|\@dottedtocline|; and multi-line headings now leave empty the area
underneath the numbers contrarily to the code from
\autoref{sec:firstexample}). And after a few minutes for choosing
lengths (now that this has been done once, it can be recycled easily) we
get:

\etocsetnexttocdepth {all}
\begingroup
\parindent 0pt
\leftskip 0cm
\rightskip 0.75cm
\parfillskip -\rightskip
\newcommand*{\EndParWithPagenoInMargin}
    {\nobreak\hfill
     \nobreak\makebox[0.75cm][r]{\mdseries\normalsize\etocpage}%
     \par}
\renewcommand*\etoctoclineleaders
    {\hbox{\normalfont\normalsize\hbox to .75ex {\hss.\hss}}}
\newcommand*{\EndParWithPagenoInMarginAndLeaders}
    {\nobreak\leaders\etoctoclineleaders\hfill
     \nobreak\makebox[0.75cm][r]{\mdseries\normalsize\etocpage}%
     \par }
\etocsetstyle {part}
              {}
              {\leavevmode\leftskip 1cm\relax}
              {\bfseries\large\llap{\makebox[1cm][r]{\etocnumber\ \ }}%
               \etocname\EndParWithPagenoInMargin\smallskip}
              {}
\etocsetstyle {section}
              {}
              {\leavevmode\leftskip 1.75cm\relax}
              {\bfseries\normalsize\llap{\makebox[.75cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {subsection}
              {}
              {\leavevmode\leftskip 2.75cm\relax }
              {\mdseries\normalsize\llap{\makebox[1cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {subsubsection}
              {}
              {\leavevmode\leftskip 4cm\relax }
              {\mdseries\normalsize\llap{\makebox[1.25cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {paragraph}
              {}
              {\leavevmode\leftskip 5.5cm\relax }
              {\mdseries\normalsize\llap{\makebox[1.5cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {part}
\etocsettagdepth {arbitrarily}{part}
\etocsettagdepth {surprising} {part}
\etocsettagdepth {linestyles} {part}
\etocsettagdepth {globalcmds} {paragraph}
\etocsettagdepth {custom}     {part}
\etocsettagdepth {tips}       {part}
\etocsettagdepth {code}       {none}
\renewcommand\etoctoprule {\hrule height 3pt\relax }
\renewcommand\etoctoprulecolorcmd {\color{blue}}
\renewcommand\etocaftercontentshook 
   {\medskip\begingroup \color{blue}\hrule height 3pt \endgroup }
\etocruledstyle [1]{\Large\bfseries 
                    \fbox{\makebox[8cm]{A TOC using depth tags}}}
\sloppy
\tableofcontents

\begin{verbatim}
\etocsetnexttocdepth {all}
\begingroup 
\parindent 0pt \leftskip 0cm \rightskip .75cm \parfillskip -\rightskip
\newcommand*{\EndParWithPagenoInMargin}
    {\nobreak\hfill
     \nobreak\makebox[0.75cm][r]{\mdseries\normalsize\etocpage}%
     \par}
\renewcommand*\etoctoclineleaders
    {\hbox{\normalfont\normalsize\hbox to .75ex {\hss.\hss}}}
\newcommand*{\EndParWithPagenoInMarginAndLeaders}
    {\nobreak\leaders\etoctoclineleaders\hfill
     \nobreak\makebox[0.75cm][r]{\mdseries\normalsize\etocpage}%
     \par }
\etocsetstyle {part}
              {}
              {\leavevmode\leftskip 1cm\relax}
              {\bfseries\large\llap{\makebox[1cm][r]{\etocnumber\ \ }}%
               \etocname\EndParWithPagenoInMargin\smallskip}
              {}
\etocsetstyle {section}
              {}
              {\leavevmode\leftskip 1.75cm\relax}
              {\bfseries\normalsize\llap{\makebox[.75cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {subsection}
              {}
              {\leavevmode\leftskip 2.75cm\relax }
              {\mdseries\normalsize\llap{\makebox[1cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {subsubsection}
              {}
              {\leavevmode\leftskip 4cm\relax }
              {\mdseries\normalsize\llap{\makebox[1.25cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {paragraph}
              {}
              {\leavevmode\leftskip 5.5cm\relax }
              {\mdseries\normalsize\llap{\makebox[1.5cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {part}
\etocsettagdepth {arbitrarily}{part}
\etocsettagdepth {surprising} {part}
\etocsettagdepth {linestyles} {part}
\etocsettagdepth {globalcmds} {paragraph}
\etocsettagdepth {custom}     {part}
\etocsettagdepth {tips}       {part}
\etocsettagdepth {code}       {none}
\renewcommand\etoctoprule {\hrule height 3pt\relax }
\renewcommand\etoctoprulecolorcmd {\color{blue}}
\renewcommand\etocaftercontentshook 
   {\medskip\begingroup \color{blue}\hrule height 3pt \endgroup }
\etocruledstyle [1]{\Large\bfseries 
                    \fbox{\makebox[8cm]{A TOC using depth tags}}}
\sloppy
\tableofcontents
\endgroup
\end{verbatim}
\endgroup

\subsection{Typesetting the TOC as a table (the old way)}
\label{ssec:tocastableold}

Due to, among other things, the fact that alignment cells create and close
groups, and that by default definitions of \csb{etocname}, \csb{etocnumber},
\csb{etocpage} made by \etoc are local, it was not easy to typeset a TOC as
table with \etoc, prior to release |1.08|. 

Not only \csb{etocname} etc... caused a problem, but also the basic
redefinition of \csa{contentsline} was made by \etoc only after the
first argument to \csb{etocsettocstyle} had been executed, hence if this
argument were to open a tabular, the \etoc redefinition of
\csa{contentsline} would be done in the first cell of the first row and
get lost thereafter.

Thus one had to resort to the technique explained in \autoref{tocastree}
of using the execution of \csa{tableofcontents} as a way to store data
which was then displayed later.

For the record, here is how the TOC from \autoref{sec:tocastable} was
coded in the old days. We don't have here the problems with the
positioning of |\hline|'s we face with the newer method; on the other
hand we must manipulate token registers which are not familiar to most
\LaTeX{} users (macros could be used, but would be more cumbersome,
except perhaps if using the \eTeX{} \csa{unexpanded}).

The method here is the most powerful because it filters out of the
|.toc| file only the data we want (the other things are not ignored,
they are executed but hopefully do not create havoc; typically they are
language changing instructions, or updates to certain counters, etc...),
and we are less susceptible to fall potential victims of various
external macros inserted in the |.toc| file by other packages.

Note: rather than |\toks| registers it would be easier here to use \eTeX{}
\csa{unexpanded} primitive. See for example \autoref{sec:mindmap}.

\begin{verbatim}
\newtoks\toctabletok
\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
  #1\expandafter\expandafter\expandafter {\expandafter\the\expandafter #1#2}}

\newcommand*\PreparePart{%
  \toks0 \expandafter{\etocthelinkednumber}%
  \toks2 \expandafter{\etocthelinkedname}%
  \toks4 \expandafter{\etocthelinkedpage}%
  \edef\toctablepiece {\noexpand\hline
                      \noexpand\strut\the\toks0 &\noexpand\bfseries\the\toks2 
                                 &\the\toks4 \noexpand\\\noexpand\hline}% 
}
\newcommand*\PrepareSection{%
  \toks0 \expandafter{\etocthelinkednumber}%
  \toks2 \expandafter{\etocthelinkedname}%
  \toks4 \expandafter{\etocthelinkedpage}%
  \edef\toctablepiece {\the\toks0 &\the\toks2 &\the\toks4 \noexpand\\}% 
}
% new version for 1.07k, 2014/03/06
\newcommand*{\PrepareSubsection}{%
  \toks0 \expandafter{\etocthelinkednumber}%
  \toks2 \expandafter{\expandafter\itshape\etocthelinkedname\strut}%
  \toks4 \expandafter{\expandafter\itshape\etocthelinkedpage}%
  \edef\toctablepiece{&\noexpand\makebox[1cm][c]{\the\toks0}%
                      \noexpand\parbox[t]{\dimexpr6cm-\tabcolsep\relax}
                                         {\noexpand\sloppy\the\toks2}%
                      &\the\toks4 \noexpand\\}%
}

\begingroup
\etocsetstyle{part}{}{}{\PreparePart \appendtotok\toctabletok\toctablepiece}{}

\etocsetstyle{section}{}{}{\PrepareSection \appendtotok\toctabletok\toctablepiece}{}

\etocsetstyle{subsection}{}{}{\PrepareSubsection\appendtotok\toctabletok\toctablepiece}{}

\etocsettocstyle
    {\toctabletok{\hypersetup{hidelinks}%
                 \begin{longtable}{|>{\bfseries}c|p{7cm}|r|}\hline
                 \multicolumn{3}{|c|}{\Large\bfseries\strut TABLE OF CONTENTS}%
                 \\\hline\hline}}
    {\global\toctabletok\expandafter{\the\toctabletok\hline\end{longtable}}}
\etocsettocdepth {subsection}
\tableofcontents
\the\toctabletok
\endgroup
\end{verbatim}

\subsection{Compatibility with other packages}
\label{etocaftertochook}

The contents of the |.toc| file (if it already exists) are read into memory by
\etoc once, at the time of |\begin{document}|.\footnote{New with |1.07m|.
    Earlier versions read the |.toc| file at the time of
    \csa{usepackage\{etoc\}}. Thanks to Denis Bitouzé who signaled a Babel
    related problem, which turned out to be caused by this.}

\begin{framed}
  One should load \etoc \emph{after} \texttt{babel}. This is in order for
  |babel|'s shorthands to be active at the time when \etoc loads the |.toc|
  file.
\end{framed}

The |.toc| file remains available
  to other packages for read operations until the location of the first table
  of contents at which time a write stream is opened by \etoc and from that
  point the file is erased until its contents are again written to the disk by
  \LaTeX{} at the end of the compilation.

\etoc loads the package |multicol|. 

\etoc requires the |.toc| file to use the |\contentsline| macro (possibly
patched by other packages). It is thus incompatible with the |beamer| class.
However, if |beamer| is used in an article mode, i.e., with the article class
in conjunction with the |beamerarticle| package, then \etoc should work.

\etoc is |hyperref| aware and hopefully |hyperref| compatible: the macros
\csa{etocname}, \csa{etocnumber}, and \csa{etocpage} contain the |hyperref|
links, if present (note that the \emph{linktoc=all} option of |hyperref| tells
it to put a link also in the page number corresponding to a given toc entry).
For example, the tables of contents of the present document are all fully
linked. It doesn't matter whether \etoc or |hyperref| is loaded first.

Release |1.07k| adds compatibility with package
|tocloft|:\footnote{\url{http://ctan.org/pkg/tocloft}} steps are
taken to prevent the redefinition of |\tableofcontents| done by
|tocloft| at |\begin{document}|.
%
As long as \etoc is left in compatibility mode the customization done by
|tocloft| will be obeyed, for both the line styles and the TOC title.
One may still benefit from the \emph{depth tags} management by \etoc,
from its |\localtableofcontents|, from its |\label+\ref| mechanism. One
may use |\etocsetstyle| to define via \etoc the layout for one TOC and
then use rather |tocloft| for another one, if |\tableofcontents| follows
\csb{etocstandardlines} and \csb{etocstandarddisplaystyle}. In this
compatibility mode |\etocsetlevel{division unit}{6}| will render
invisible the chosen division level, but exchanging levels is otherwise
not possible.

\begin{framed}
  One should load \etoc \emph{after} \texttt{tocloft}. A warning is
  issued if otherwise.
\end{framed}

Release |1.07l| has also improved the compatibility with the |memoir| class: its
|appendix| level has been made known to \etoc. It is at the same level as
|chapter|, thus the chapter line style should possibly do a test for some user
defined boolean whose activation may be added to the |.toc| file at the suitable
location via |\addtocontents{toc}{..}|, if one needs to distinguish the two
kinds of divisions.

\etoc can not really cohabit with packages modifying the \csa{tableofcontents}
  command: some sort of truce can be achieved if \etoc is loaded last, hence is
  the winner. 

  \begin{framed}
    Do not modify the |\tableofcontents| command like this:
    \centeredline{|\let\oldtableofcontents\tableofcontents|}
    \centeredline{|\renewcommand\tableofcontents{\oldtableofcontents\mystuff}|}
    as this will make the |\label/\ref| mechanism impossible. Rather you may do
    \centeredline{|\renewcommand\etocaftertochook{\mystuff}|} and there is
    also \csb{etocaftercontentshook} which is executed a bit
    earlier\footnotemark{}
    just before
    the 
    closing part of the toc display style (and thus still within a group.)
  \end{framed}
\footnotetext{contrarily to \csa{etocaftertochook},
      \csa{etocaftercontentshook} is not executed if the |tocdepth| did not
      allow the printing of the TOC.}

  \etoc used to be incompatible with package
  |tocvsec2|\footnote{\url{http://ctan.org/pkg/tocvsec2}}; it now cohabits, sort
  of, as it deactivates |tocvsec2|'s modification of |\tableofcontents| (done in
  the style above) and also cancels its other |toc|-related macros, but
  reimplements partially their functionality with \csb{etocsettocdepth.toc}. By
  the way, at least two latex runs are necessary for new uses of this command in
  a document to have an effect in tables of contents.

When a \localtoc is inserted by the user in the document, a
line containing an \etoc inner command and an identification
number is added to the |.toc| file. The correct local table of
contents will be displayed only on the next |latex| run.

It is possible to customize (using package |tocloft| for
example) throughout the document the macros \csa{l@section},
\csa{l@subsection} ... and the effect will be seen in the next
table of contents typeset by \etoc in compatibility mode.

It is possible to use simultaneously \etoc and
{\color{niceone}|tableof|}\footnote{\url{http://ctan.org/pkg/tableof}}. Release
|1.08| of \etoc requires at least version |1.4a| of |tableof|. If
\csb{etocglobaldefs} is put in the preamble, this must be after the loading of
package |tableof|. {\color{niceone}|tableof|} command \csa{nexttocwithtags}
should work as expected. 

{\color{niceone}|tableof|} commands \csa{tableof}, \csa{tablenotof}, ... will
typeset the (a priori global) table of contents according to the document
class defaults, obeying the \etoc depth tags; as explained in the |tableof|
documentation they do not typeset a TOC title. They should \emph{not} be used
in case \csb{etocglobaldefs} was issued before, except if its scope has been
terminated since then, or \csb{etoclocaldefs} has cancelled its influence.

\subsection{\TeX nical matters}

The \csb{etocname}, \csb{etocnumber}, \csb{etocpage} commands are protected
against premature expansion. They contain suitable |hyperref| links if package
|hyperref| is loaded and active for the TOC. The commands \csb{etoclink} and
\csb{etocifnumbered} are also protected against premature expansion. Also
\csb{etociffirst} and \csb{etoctoccontentsline}.

On the other hand \csb{etocthename}, \csb{etocthenumber}, \csb{etocthepage}
are \emph{not} protected against expansion. And neither are
\csb{etocthelinkedname}, \csb{etocthelinkednumber}, \csb{etocthelinkedpage}.
The latter contain hyperlink data, if present in the |.toc| file.

The commands such as \csb{etocsetstyle}, \csb{etocsetlevel},
\csb{etocsettocstyle}, \csb{etocmulticolstyle},
\csb{etocruledstyle}, \csb{etocframedstyle} obey \LaTeX{}'s
groups. All TOCs are typeset inside groups.

\subsection{Errors and catastrophes}

  After using \csa{etocsetstyle} for one level, the remaining
  uncustomized levels use the \etoc default styles (those
  which are activated by \csa{etocdefaultlines}). One has to
  make sure that all levels needed for the next table of
  contents are mutually compatible: in particular the \etoc
  default line styles expect each to be started in ``vertical mode''.

  When using multiple \toc commands in a document, one should beware from adding
  typesetting instructions directly in the |.toc| file, as they will be executed
  by \etoc for all TOCs: even for a \localtoc it doesn't matter if that
  instruction seems to concern material outside of its scope, it will get
  executed nevertheless. If absolutely necessary (but this should never be)
  these instructions should be done in such a way that they can be activated or
  deactivated easily from the document source, as need be.

  As is usual with toc and labels, after each change, one has
  to run latex a certain number of times to let the produced
  document get its final appearance (at least twice).\par

\clearpage
\etocdepthtag.toc {code}

\part{The code}

\section{Timestamp}

This is the documentation as of \texttt{\etocdocdate}, printed from the
source file with the time stamp \texttt{\etocdtxtimestamp}. The package
version is \texttt{\etocpkgversion}, of \texttt{\etocpkgdate}.

% STOP ENGLISH VERSION
^^Afi

^^Acatcode92 12

^^Aifnum^^AForDeutsch=1

    ^^Acatcode92 0


% START GERMAN (DEUTSCH) VERSION
\bookmark[named=FirstPage,level=1]{Titelseite}% 10 octobre 2013. 

\begingroup

\etocsetstyle{part}
  {\etocskipfirstprefix}
  {\ifcase\pseudomodthree{\value{partco}}%
   \or  \appendpart\treetok\parttok {teal!60}%   first
   \or  \appendpart\treetok\parttok {yellow!80}% second
   \else\appendpart\treetok\parttok {green!50}%  third and next ...
   \fi
   }
  {\stepcounter{partco}%
   \edef\treenode{node
                  {\unexpanded\expandafter{\etocthelinkednumber}. 
                   \unexpanded\expandafter{\etocthelinkedname}}}%
% grosse astuce: la première Partie ne sera pas embêtée par les trois sections
% avant car ce qu'elles auront mis dans \parttok va être effacé.
   \parttok\expandafter{\treenode}}
  {\ifcase\pseudomodthree{\value{partco}}%
   \or  \appendpart\treetok\parttok {teal!60}%   first
   \or  \appendpart\treetok\parttok {yellow!80}% second
   \else\appendpart\treetok\parttok {green!50}%  third and next ...
   \fi
   }

\etocsetstyle{section}
  {}
  {}
  {% define the section node
   \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber} 
                        \unexpanded\expandafter{\etocthelinkedname}}}}%
   \appendtotok\parttok\childnode }
  {}

\etocsetnexttocdepth{section}

\etocsettocstyle
  {\setcounter{partco}{0}%
   \treetok{\node [root concept]{\normalfont{Das \etoc-Paket}\par {\normalsize\textsc
    {Jean-François Burnol}\par \ttfamily jfbu (at) free (dot) fr}\par
  {\normalsize Paketversion:\par \etocDEpkgversion{} (\etocDEpkgdate )\par}}}}
  {\global\appendtotok\treetok{ ;}}

\etocinline\tableofcontents\label{toc:mindmaptitlepage}

\tikzset {branch color/.style={concept color=#1!white,
             every child/.append style={concept color=#1!white!30!white}}%
         }%

\global
\setbox\TitlePageMindmapTOC\hbox {\begingroup
\resizebox{.9\paperwidth}{!}{%
\begin{tikzpicture}[mindmap,
                    text width=2cm,
                    align = flush center,
                    growth function=\tikzmycustomgrowth,
                    nodes={concept},
                    concept color=orange!60,
                    root concept/.append style={font=\huge, text width = 6cm},
                    level 1/.append style={level distance=7cm, sibling angle=360/8},% 8 hard-coded mais je pourrais aussi le calculer
                    level 1 concept/.append style={font=\Large, text width = 3cm},
                    level 2/.append style={level distance=12.5cm, sibling angle=360/35},% 35 hard coded mais je pourrais aussi le calculer
                    % distance par rapport au CENTRE ! (avec le code tel qu'en ce moment)
                   ]
\the\treetok
\end{tikzpicture}}\endgroup }

\endgroup

\indent\null
\begingroup
 \let\thefootnote\empty
\footnote{Original Dokumentationzeitstempel: ``\etocDEdocdate''.\par
    Übersetzt ins Deutsche von Felix Baral-Weber, Jenny Rothkrämer-Vogt, Daniel
    Büttner, Claudia Dahl, Christian Otto und Christine Römer (FSU Jena).
    Hinweise zur Übersetzung an Christine\_Roemer at t-online dot de.}
\endgroup
\setcounter{footnote}{0}

\AddToShipoutPictureFG*{\put(10.5cm,16.85cm)
                        {\makebox(0,0){\box\TitlePageMindmapTOC}}}


\clearpage


\etocdepthtag.toc {preamble}
%----
% MAIN TOC
%
\etocsettocdepth {subsubsection}
\etoctoclines
\etocmarkboth\contentsname
\etocmulticolstyle[1]
     {\pdfbookmark[1]{Inhaltsverzeichnis}{MAINTOC}%
      \noindent\bfseries\Large
      \leaders\hrule height1pt\hfill
      \MakeUppercase{Inhaltsverzeichnis}}
\begingroup
  \etocsetlevel{subsection}{3}
  \etocsetlevel{subsubsection}{6}
\tableofcontents \label{toc:main}
\endgroup

\phantomsection\addcontentsline{toc}{section}{\abstractname}
\begin{abstract}
  Das \etoc"=Paket gibt dem Nutzer lückenlose Möglichkeiten, die Einträge des
  Inhaltsverzeichnis individuell über \emph{Name}, \emph{Nummer}, und
  \emph{Seitenzahl} für jede gliedernde Einheit zu setzen. Dieses wird durch die
  Definition von \emph{Zeilenstilen (line-styles)} für jede Unterteilungsstufe
  des Dokuments realisiert. Das Paket bietet darüber hinaus seinen eigenen
  Zeilenstile. Einfachere werden als Beispiele in dieser Dokumentation
  angeboten. Die einfachste Nutzung wird durch die Verwendung der
  Layout"=Hilfsmittel, von Paketen die sich mit Listen"=Umgebungen beschäftigen,
  gewährt.
  
  In Hinsicht auf das \emph{globale Inhaltsverzeichnis} bietet \etoc\
  vordefinierte Stile, die auf der Mehrspaltenansicht mit optionalen,
  unterstrichenen Titeln oder eingerahmten Inhalten basieren.

  Der \csa{tableofcontents}"=Befehl kann beliebig mehrfach benutzt werden. Er hat
  die Variante \csa{localtableofcontents}, welche die Inhaltsangabe 'local' zur
  aktuellen Dokumenten"=Sektion ausgibt. Eine Erweiterung der
  \csa{label}/\csa{ref}-Syntax erlaubt die Reproduktion (mit anderem Layout)
  einer lokalen Inhaltsangabe, die irgendwo anders im Dokument definiert wurde.

  Mit "`tiefen Tags"' erhält man noch feinere Kontrolle über jede Inhaltsangabe
  und darüber, welche unterteilende Einheit angezeigt werden soll, oder nicht.

  Mit \emph{Kompatibilismus} wird die Formatierung der Dokumentklasse geerbt
  (die womöglich von anderen Paketen verändert wurde); und die Formatierung, die
  von der Dokumentklasse (die womöglich von anderen Paketen verändert wurde)
  geerbt wird.

  Die Zuweisung von Ebenen zu den unterteilenden Einheiten kann zu jeder Zeit
  geändert werden und \etoc kann dadurch in einer ziemlich generellen Weise
  genutzt werden, um selbsterstellte 'Listen von' zu erzeugen. Keine
  Zusatzdateien werden zusätzlich zu der Standard-|.toc|-Datei benutzt.
\end{abstract}

\section{Vorwort}

Andere populäre Pakete, die sich mit Inhaltsangaben befassen, sind
|tocloft|, |titletoc| und |minitoc|. Warum also ein anderes? 
Ich habe \etoc erst für mich selbst entwickelt und  
später von den anderen Paketen erfahren.

Wie es auch in der |tocloft|-Dokumentation erklärt wird, ist das
Standard-\LaTeX -Layout für Inhaltsangaben in den Klassen"=Definitionen
begraben. Im Besonderen sind die meisten Längen hart codiert und der 
einzige Weg für den Benutzer, sie zu ändern, ist, die Klasse in den
Dokumenten"=Ordner zu kopieren und dann die Längen zu ändern.
Die vernünftigere Alternative ist die Benutzung eines auf das Veränderungsziel
gerichteten Pakets, wie |tocloft| oder eine andere flexible Dokumentklasse.

Freilich, obwohl jetzt hoffentlich nichts mehr hart codiert ist, 
muss man noch immer das Paket oder die Klassen"=Definitionen durchgehen.
Das bedeutet, dass man sich viele (vermutlich große) Menge an Makros
merken muss, die nur dieser Aufgabe dienen. Und man wird immer
auf die Anpassung eines zu Anfang gegebenen Layouts eingeschränkt sein.

Der Sinn von \etoc ist ein anderer. Der Nutzer wird sich mit 
\emph{Name}, \emph{Nummer} und der \emph{Seitenzahl} beschäftigen. 
Diese korresponieren mit jeder Dokumenten"=Unterteilung (und können in
einer Zeile der |.toc|-Datei gefunden werden). Sie können, wenn gewünscht,
durch die Befehle \csb{etocname}, \csb{etocnumber} und \csb{etocpage} 
abgerufen werden. 

\etoc scheint (mindestens teilweise) mit den Dokument"=Klassen |article|, 
|book|, |report|, |scrartcl|, |scrbook|, |scrreprt| und |memoir| 
kompatibel zu  sein. Seit der Version |1.07k| ist es möglich \etoc 
gleichzeitig mit |tocloft| zu benutzen.

\section{Lizenz}

\begingroup\ttfamily\small\hyphenchar\font -1
           \parindent0pt 
           \obeyspaces\obeylines
\etocLicense\endgroup


\clearpage
\etocsettocdepth {subsection}

\etocdepthtag.toc{overview}

\part{Überblick}\label{part:overview}

\thispartstats

\invisiblelocaltableofcontents \label{toc:overview}

\section{Muss ich Computerfreak sein, um \etoc benutzen zu können?}

Nicht wirklich. Der einfachste Weg ist die Benutzung von 
|enumerate|-Umgebungen mit den Anpassungsmöglichkeiten von 
Paketen wie |enumitem|, \footnote{\url{http://ctan.org/pkg/enumitem}} 
um von \etoc aus der |.toc|-Datei die abgerufenen Daten anzuzeigen.
Die Daten bestehen aus \emph{Name} (\csb{etocname}), \emph{Gliederungsnummer}
(\csb{etocnumber}) und \emph{Seitenzahl} (\csb{etocpage}).

Dieses wird \hyperref[toc:a]{zu Beginn} von \autoref{part:linestyles}
gezeigt. Anspruchsvollere Beispiele würden anspruchsvollere
|enumitem|-Optionen benutzen. Man könnte nun sagen, dass der Nutzer
sich einige Anpassungen merken muss. Und das ist auch so, aber die 
Syntax und Optionsbezeichnungen, die es zu behalten gilt, sind
in keinster Weise ähnlich.

Die Methode wird \hyperref[sec:firstexample]{später} 
(\autoref{sec:firstexample}) erklärt. Dafür ist ein wenig Wissen über
|\leftskip|, |\rightskip| usw. notwendig. Und eine Ausarbeitung , deren 
Code kann man hier (\autoref{ssec:tocwithdepthtags}) finden, die Nachahmung des 
Standardaussehens einer Inhaltsangabe. 

Wie Sie beim Lesen dieser Anleitung noch sehen werden, ist \etoc
ziemlich vielfältig (ganz besonders, weil es erlaubt, die Hierarchie jeder 
unterteilenden Einheit des Dokuments zu re-definieren) und man kann damit 
überraschende Effekte erreichen: \autoref{part:surprising} handelt davon. Mehr 
davon gibt es noch in \autoref{part:tipsandtricks}.

\begin{framed}
\setcounter{mycounti}{0}%
  \etocinline
\etocsetlevel{part}{1}
\etocsetlevel{chapter}{1}
\etocsetlevel{visibletoc}{0}
\etocsetstyle{visibletoc}
    {}
    {\stepcounter{mycounti}}
    {}
    {}
\etocsettocstyle{}{}
\etocsetnexttocdepth{0}
\tableofcontents
Ein ganz besonders wichtiger Aspekt von \etoc ist, dass es darauf ausgelegt ist,
viele Inhaltsangaben in dem selben Dokument zu erzeugen, \emph{Mit nur einer
  |.toc|-Datei.} Die gegenwärtige Dokumentation enthält \arabic{mycounti}
sichtbare Inhaltsangaben (und ein paar unsichtbare). Sie benutzt dabei nur eine
|.toc|-Datei!\footnotemark{} Darum sollte man zweimal nachdenken, bevor man
manuell extra Befehle zu der |.toc|-Datei hinzufügt (siehe
\autoref{sec:addingtotoc}).
\end{framed}

\footnotetext{Das Selbstzählen wurde durch eine Inhaltsangabe erreicht, die 
in einen gerahmten Paragraphen eingesetzt wurde! \dots Die Technik für diese Art
von Effekt wird später erklärt.}


\subsection{Beschränkungen in der Benutzung von Listen"=Umgebungen für
Inhalsangaben}
\label{ssec:limitations}

Es gibt ein paar Einschränkungen für das Nutzen von Listen"=Umgebungen
beim Setzen der TOCs. Eine davon liegt dem 
Geltungsbereichsbeschränkungen der Umgebungen inne. Die |.toc|-Datei
könnte neben den Informationen zum Stil einige andere Befehle
beinhalten, die Probleme hervorrufen können
(\LaTeX -Umgebungen schaffen Gruppen.).

Darum machen die eingebauten "`Zeilenstile"' (line styles), wie sie von \etoc
vorgeschlagen werden (die durch die \hyperref[toc:main]{Hauptinhaltsangabe} in
diesem Dokument gezeigt werden) keinen Gebrauch von Umgebungen. Tatsächlich
nutzt in dieser Gebrauchsanweisung nur die \hyperref[toc:a]{Inhaltsangabe} zu
Beginn von \autoref{part:linestyles} und in \autoref{toc:allsubsections}
e\texttt{numerate}-Umgebungen, um Zeilenstile anzugeben.

\section{Zeilenstile und Stile der Inhaltsangabe (toc display style)}

Eine Unterscheidung muss zwischen den \emph{Zeilenstilen},
\emph{z.\,B.} der Art und Weise wie Namen, Kapitelnummern und 
Seitenzahlen auf jedem Level angezeigt werden und dem
\emph{Inhaltsangabenstil} (mangels einer besseren Bezeichnung)
gemacht werden. Dieser sagt, wie die Titel gesetzt werden sollen,
ob oder nicht ein Eintrag in die |.toc|-Datei gemacht werden soll,
ob oder nicht der Inhalt mit mehreren Spalten gesetzt werden soll,
usw..., der letztere wird von \csa{etocsettocstyle} (oder einem
höherrangigen Befehl) geregelt. Das erste wird von 
\csa{etocsetstyle} initialisiert.

\subsection{\csbhyp{etocsetstyle} für den Zeilenstil}

Das ist der Befehl, der \etoc sagt, was es mit \csa{etocname}, \csa{etocnumber},
und \csa{etocpage} machen soll. Er hat fünf Pflichtargumente: Das erste ist der
Name der unterteilenden Einheit: Im Vorhinein bekannte Namen sind |book|,
|part|, |chapter|, |section|, |subsection|, |subsubsection|, |paragraph|,
|subparagraph| und viele weitere können anhand dem \csb{etocsetlevel}"=Befehl
einem (numerischen) Level zugewiesen werden.\footnote{Mit der
  \texttt{memoir}-Dokumentklasse kennt \etoc \texttt{Appendix} als
  Kapitelüberschrift.}


%% Änderungen zur Übersetzung ins Deutsche:
%% jf b has added here forgotten emphasized text for 2)&3) and 
%% removed various \newline. 
Die vier anderen Argumente von \csb{etocsetstyle}
spezifizieren:
1) \emph{Was zu tun ist, wenn dieses Level zuerst nach einem höheren
  auftritt,}
2) \& 3) (Zwei Argumente, ein 'Präfix' und ein 'Inhalt')
\emph{Was zu tun ist, wenn ein neuer Eintrag dieses Typs gefunden wird,}
und 4) \emph{Das letzte Argument ist der Code, der ausgeführt
  wird, wenn eine unterteilende Einheit von höherer Wichtigkeit wieder von oben
  getroffen wird.}


\subsection{\csbhyp{etocsettocstyle} für den Stil der Inhaltsangabe}

Der \csb{etocsettocstyle}"=Befehl erlaubt es festzulegen,
was vor und nach den Zeileneinträgen eines Inhaltsverzeichnis
passieren soll, und im Speziellen wie die Titel ausgegeben
werden sollen. Er hat zwei Argumente. Das erste wird vor
der Inhaltsangabe ausgeführt (typischerweise wird es Inhalte
ausgeben und definiert passende Markierungen für die
Seitenüberschriften). Der Zweite wird nach der Inhaltsangabe
ausgeführt.

\etoc bietet vier (anpassbare) höhere Inhaltsabgabenstile:
\csb{etocmulticolstyle}, \csb{etoctocstyle},
\csb{etocruledstyle} und \csb{etocframedstyle}.
Alle nutzen das |multicol|-Paket mit standardmäßig zwei
Spalten (Einspaltenmodus kann durch das optionale Argument 
 |[1]| erreicht werden). 

Diese Befehle müssen entweder von \toc oder \localtoc gefolgt sein.

\subsection{Kompatibilismus}\label{ssub:compat}
\label{etoctoclines}
\label{etocstandardlines}

Vor den "`Zeilenstilen"' und den "`Inhaltsangabenstilen"' besteht
die Möglichkeit in den Kompabilitätsmodus zu wechseln, der die
Standardeinstellungen der Dokumentenklasse nimmt.
\footnote{Für den "`Inhaltsangabenstil"' überprüft \etoc, ob
es die Klassen kennt, wenn nicht, fällt es zur |article|-Klasse
zurück. Es wird auch überprüfen, ob \texttt{tocloft} die
Inhaltsangaben"=Datei verändert hat.}
Dieses wir wie folgt aktiviert:\\
\makebox[5.2cm][l]{\csb{etocstandardlines}}
 |% `Zeileneinträge' wie ohne \usepackage{etoc}|\\
\makebox[5.2cm][l]{\csb{etocstandarddisplaystyle}}
 |% `Inhaltsstil'  wie ohne \usepackage{etoc}|

Wenn der Befehl \csa{etocsetstyle} \emph{noch nicht in der Präambel benutzt 
worden ist}, wird das Paket in |\begin{document}| sitzen (in diesem
Kompatibilismus). Folglich sollte \csa{usepackage\{etoc\}} hoffentlich
nichts am Aussehen eines im Vorhinein vorhandenen Dokuments der Klassen 
|article|, |book|, |report|, |scrartcl|, |scrbook|, |scrreprt| und |memoir|
ändern.

Jede Benutzung von \csa{etocsetstyle} in der \emph(Präambel des Textkörpers) des
Dokuments schaltet den Kompabilitäsmodus für Zeilenstile aus, behält ihn aber 
für den Inhaltsabgabenstil.
 
Man kann ihn für Zeilenstile anhand von \csb{etocstandardlines}
wieder aktivieren. \csb{etoctoclines} reaktiviert Zeilenstile wie
Sie mit der Hilfe von \csa{etocsetstyle} definiert wurden, wenn deren
Gültigkeitsbereich nicht auf eine Gruppe oder eine Umgebung beschränkt 
war.
  
Der Befehl \csb{etocdefaultlines} setzt den Zeilenstil darauf zurück,
wie er intern von \etoc in \autoref{etocdefaultlines} beschrieben wurde.
  
Sogar wenn \csb{etocsetstyle} benutzt wurde, bleibt der globale Stil 
zu Beginn, wie er in der Dokumentenklasse definiert wurde (oder von dem
|tocloft| Paket). Man muss den Befehl \csb{etocsettocstyle} oder seine
Varianten setzen, um diesem Kompatibilitätsmodus auf dem 
"`Inhaltsangebenstil"'-Level zu beenden. Er wird reaktiviert,
wenn \csb{etocstandarddisplaystyle} benutzt wird.

\section{Ein erstes Beispiel}
\label{sec:firstexample}

Hier sehen sie ein erstes Beispiel zur Beschreibung der Zeilenform.
Wir fügen die Quelldatei direkt nach dem Start von \autoref{part:overview} ein:

\centeredline{|\invisiblelocaltableofcontents \label{toc:overview}|} 
%
Dieses erstellt ein Label |toc:overview|, das wir von jeder Stelle im Dokument
benutzen können:
%
\centeredline{|\tableofcontents \ref{toc:overview}|} 
%
Und da wir |\invisible...|,\footnote{Das ist eine Abkürzung, um die |tocdepth|
  temporär auf |-3| zu setzen. Dieses sagt \etoc, die Inhaltsangabe und die
  Überschrift nicht auszugeben.} benutzt haben, existiert die lokale
Inhaltsangabe nur durch seine Klone anderswo im Dokument.

Anhand von \csb{etocdefaultlines} oder dem Stil der Standard"=Dokumentklasse,
anhand von \csb{etocstandardlines}, könnten wir auch die Zeilenform benutzen,
die von \etoc definiert wird. Hier waren wir jedoch ein wenig ehrgeiziger und
wollten unser eigenen Stil anlegen. Die Technik ist einfach: Jede Überschrift
ist an sich ein eigener Paragraph, der sich über mehrere Zeilen erstrecken kann;
es ist für seinen |\leftskip| selbst verantwortlich.

\begingroup
\parindent 0pt
\parfillskip 0pt
\leftskip 0cm
\rightskip 1cm
\etocsetstyle {section}
              {}
              {\leavevmode\leftskip 0cm\relax}
              {\bfseries\normalsize\makebox[.5cm][l]{\etocnumber.}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\mdseries\etocpage}}\par}
              {}
\etocsetstyle {subsection}
              {}
              {\leavevmode\leftskip .5cm\relax }
              {\mdseries\normalsize\makebox[1cm][l]{\etocnumber}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\etocpage}}\par}
              {}
\etocsetstyle {subsubsection}
              {}
              {\leavevmode\leftskip 1.5cm\relax }
              {\mdseries\normalsize\makebox[1cm][l]{\etocnumber}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\etocpage}}\par}
              {}
\etocruledstyle[1]{\bfseries \Large Mein erstes \etoc: TOC von
  \autoref{part:overview} (\nameref{part:overview})}
\tableofcontents \ref {toc:overview}
\endgroup

Dieses ist ein einfaches Design, das keine Maßnahmen zum Zeilenumbruch
bereitstellt. Diese sollten zwischen Abschnitten und Unterabschnitten, etc.
unterbunden werden, da wir es nur für die Inhaltsangabe von diesem Abschnitt
nutzen. Durch die Abschnitte als höchste Ebene entstand keine Notwendigkeit,
einen Stil für den ganze Teil zu erstellen. (Wir definierten einen
Unterabschnitt"=Zeilenstil, aber wie sich herausstellt, gibt es keine
Unterabschnitte in diesem Teil). Die zwei Befehle, die benutzt wurden,
spezifizieren den Zeilen"=Stil (\csb{etocsetstyle}) und den globalen
Inhaltsausgabestil (\csb{etocruledstyle}).

Das |\rightskip| wird von allen angewandt und schafft Platz, wo die Seitenzahlen
gedruckt werden. Einzelheiten dieser Technik werden in dem
\autoref{sec:secondexample} und \autoref{ssec:tocwithdepthtags} benutzt. Hier
wird eine Inhaltsangabe mit Abschnitten und Paragraphen verwendet. Beide
erlauben mehrzeilige Überschriften und nutzen einer Technik, die Seitenzahlen
mit dem richtigen Seitenabstand auszugeben. Dieses wurde von der Funktionsweise
von Makros aus \LaTeX2e's |\@dottedtocline| inspiriert.

\begin{verbatim}
\begingroup\parindent 0pt \parfillskip 0pt \leftskip 0cm \rightskip 1cm
\etocsetstyle {section}
              {}
              {\leavevmode\leftskip 0cm\relax}
              {\bfseries\normalsize\makebox[.5cm][l]{\etocnumber.}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\mdseries\etocpage}}\par}
              {}
\etocsetstyle {subsection}
              {}
              {\leavevmode\leftskip .5cm\relax }
              {\mdseries\normalsize\makebox[1cm][l]{\etocnumber}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\etocpage}}\par}
              {}
\etocsetstyle {subsubsection}
              {}
              {\leavevmode\leftskip 1.5cm\relax }
              {\mdseries\normalsize\makebox[1cm][l]{\etocnumber}%
               \etocname\nobreak\hfill\nobreak
               \rlap{\makebox[1cm]{\etocpage}}\par}
              {}
\etocruledstyle[1]{\bfseries \Large My first \etoc: TOC von
  \autoref{part:overview} (\nameref{part:overview})}
\tableofcontents \ref {toc:overview}
\endgroup
\end{verbatim}

\section{Ein zweites Beispiel}
\label{sec:secondexample}

Dieses zweite Beispiel zeigt nur den Inhalt von \autoref{part:linestyles} und
\autoref{part:globalcmds}. Diese Auswahl wird durch die Technik von \emph{depth
  tags} realisiert, die in \autoref{etocsettagdepth} und
\autoref{ssec:tocwithdepthtags} beschrieben wird. Dessen Layout ist in etwa wie
das von der \hyperref[toc:main]{Hauptinhaltsangabe}, obwohl die Zeilenstile ganz
anders programmiert sind.

\begingroup
\newcommand*{\DotsAndPage}
{\nobreak\leaders\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}%
         \hfill\nobreak
         \makebox[\rightskip][r]{\bfseries\normalsize\etocpage}\par}

\etocsetstyle {part}
{\parindent 0pt
 \nobreak
 \etocskipfirstprefix}
{\pagebreak[3]\bigskip}
{\large\rmfamily\bfseries\scshape\centering
  \etocifnumbered{Part \etocnumber{} -- }{}\etocname\par}
{}

\etocsetstyle {section}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
 \nobreak\medskip
 \etocskipfirstprefix}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
 \pagebreak[1]\smallskip}
{\normalsize\rmfamily\bfseries\scshape
 \etocnumber. \etocname\DotsAndPage }
{\parfillskip 0pt plus 1fil\relax }

\etocsetstyle {subsection}
{\leftskip1cm\rightskip .75cm \parfillskip 0pt plus 1fil\relax 
 \nobreak\smallskip}
{}
{\footnotesize\sffamily\mdseries\itshape
 \etocname{} (\etocnumber, p. \etocpage). }
{\par\medskip}

\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {none}
\etocsettagdepth {arbitrarily}{none}
\etocsettagdepth {surprising} {none}
\etocsettagdepth {linestyles} {subsection}
\etocsettagdepth {globalcmds} {subsection}
\etocsettagdepth {custom}     {none}
\etocsettagdepth {tips}       {none}
\etocsettagdepth {code}       {none}

\etocsettocstyle {\centering\LARGE\textsc{\contentsname}\par\nobreak\medskip}{}
\etocsetnexttocdepth {subsection}
\tableofcontents
\endgroup

Der Code:
\begin{verbatim}
\begingroup
\newcommand*{\DotsAndPage}
{\nobreak\leaders\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}%
         \hfill\nobreak
         \makebox[\rightskip][r]{\bfseries\normalsize\etocpage}\par}

\etocsetstyle {part}
{\parindent 0pt
 \nobreak
 \etocskipfirstprefix}
{\pagebreak[3]\bigskip}
{\large\rmfamily\bfseries\scshape\centering
 \etocifnumbered{Part \etocnumber{} -- }{}\etocname\par}
{}

\etocsetstyle {section}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
 \nobreak\medskip
 \etocskipfirstprefix}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
 \pagebreak[1]\smallskip}
{\normalsize\rmfamily\bfseries\scshape
 \etocnumber. \etocname\DotsAndPage }
{\parfillskip 0pt plus 1fil\relax }

\etocsetstyle {subsection}
{\leftskip1cm\rightskip .75cm \parfillskip 0pt plus 1fil\relax 
 \nobreak\smallskip}
{}
{\footnotesize\sffamily\mdseries\itshape
 \etocname{} (\etocnumber, p. \etocpage). }
{\par\medskip}

\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {none}
\etocsettagdepth {arbitrarily}{none}
\etocsettagdepth {surprising} {none}
\etocsettagdepth {linestyles} {subsection}
\etocsettagdepth {globalcmds} {subsection}
\etocsettagdepth {custom}     {none}
\etocsettagdepth {tips}       {none}
\etocsettagdepth {code}       {none}

\etocsettocstyle {\centering\LARGE\textsc{\contentsname}\par\nobreak\medskip}{}
\etocsetnexttocdepth {subsection}
\tableofcontents
\endgroup
\end{verbatim}

\section{Verlinkte Liste der Hauptbefehle}
% 16 octobre

\begingroup\raggedcolumns
\advance\linewidth18pt
\begin{multicols}{3}\parindent0pt\relax
  \csb{etocaftercontentshook}\par
  \csb{etocaftertitlehook}\par
  \csb{etocaftertochook}\par
  \csb{etocbeforetitlehook}\par
  \csb{etocdefaultlines}\par
  \csb{etocdepthtag.toc}\par
  \csb{etocdisplay}\par
  \csb{etocframedstyle}\par
  \csb{etocframed}\par
  \csb{etociffirst}\par
  \csb{etocifnumbered}\par
  \csb{etocignoredepthtags}\par
  \csb{etocignoretoctocdepth}\par
  \csb{etocinline}\par
  \csb{etoclink}\par
  \csb{etoclocalframed}\par
  \csb{etoclocalmulticol}\par
  \csb{etoclocalruled}\par
  \csb{etocmulticolstyle}\par
  \csb{etocmulticol}\par
  \csb{etocname}\par
  \csb{etocnumber}\par
  \csb{etocobeydepthtags}\par
  \csb{etocobeytoctocdepth}\par
  \csb{etocpage}\par
  \csb{etocruledstyle}\par
  \csb{etocruled}\par
  \csb{etocsetlevel}\par
  \csb{etocsetnexttocdepth}\par
  \csb{etocsetstyle}\par
  \csb{etocsettagdepth}\par
  \csb{etocsettocdepth.toc}\par
  \csb{etocsettocdepth}\par
  \csb{etocsettocstyle}\par
  \csb{etocskipfirstprefix}\par
  \csb{etocstandarddisplaystyle}\par
  \csb{etocstandardlines}\par
  \csb{etocthelinkedname}\par
  \csb{etocthelinkednumber}\par
  \csb{etocthelinkedpage}\par
  \csb{etocthelink}\par
  \csb{etocthename}\par
  \csb{etocthenumber}\par
  \csb{etocthepage}\par
  \csb{etoctoccontentsline}\par
  \csb{etoctoclines}\par
%\vspace{5\baselineskip}\hrule height 0pt
\end{multicols}
\endgroup


\clearpage
% 15 octobre, je teste les tags
\etocdepthtag.toc {arbitrarily}

\part{Beliebig viele TOCs und lokale Versionen davon}
% 13 octobre, ceci était une section avant

\thispartstats

\etocsettocstyle{}{}
\etocstandardlines
\localtableofcontents

\section{Beschriften und anderswo wieder benutzen}

\etoc  erlaubt beliebig viele \csa{tableofcontents}"=Befehle in
ihrem Dokument. Die Zeilen- und Inhaltsangabenstile können
natürlich dazwischen geändert werden. Außerdem setzt 
\csa{localtableofcontents} lokale Inhaltsangaben: \emph{z.\,B.} alle 
Abschnitte und Unterabschnitte innerhalb eines bestimmten 
Kapitels oder alle Unterabschnitte und tiefer innerhalb eines gegebenen 
Unterabschnitt usw. 

\etoc erlaubt das Labeln von Inhaltsangaben, beispielsweise mit
\csa{label\{toc:A\}}, und wird es woanders
\csa{tableofcontents}\csa{ref\{toc:A\}}, wenn gewollt, wieder anzeigen. Das
eigentliche Layout (inklusive Titel) wird lokal bestimmt. Die Zeilen- und
Inhaltsangabenstile (inklusive Titel) sind die aktuellen und der Wert von
|tocdepth| leistet Folge. Hier ein Beispiel: Die Inhaltsangabe von
\autoref{part:custom} ist innerhalb eines \hyperref[toc:d]{float}, der auf
dieser Seite erscheint: \vpageref{toc:d}.
\begin{figure}[ht!]
  \centering
  \begingroup
  \etocstandardlines 
  \renewcommand{\etocbkgcolorcmd}{\color{green!5}}
  \renewcommand{\etocbelowtocskip}{0pt\relax}
  \fboxsep1ex 
  \etocframedstyle [1]{\fbox{\makebox[.5\linewidth]{\etocfontminusone
        \hyperref[toc:c]{Ich bin von weit her}}}}
  \tableofcontents \label{toc:d} \ref{toc:c}
  \endgroup
\end{figure}

Wir benutzen dies:
\begin{verbatim}
\begin{figure}[ht!]
  \centering
  \begingroup
  \etocstandardlines 
  \renewcommand{\etocbkgcolorcmd}{\color{green!5}}
  \renewcommand{\etocbelowtocskip}{0pt\relax}
  \fboxsep1ex 
  \etocframedstyle [1]{\fbox{\makebox[.5\linewidth]{\etocfontminusone
        \hyperref[toc:c]{I am from far away}}}}
  \tableofcontents \label{toc:d} \ref{toc:c}
  \endgroup
\end{figure}
\end{verbatim}
Wichtig: Man sollte \toc|\ref{toc:d}| nicht woanders benutzen. Um wieder zu 
Klonen, muss man eine Refernz zum Original"=Label benutzen: \toc|\ref{toc:c}|.

\section{Eine mächtige Funktionsweise von \etoc: Die Wieder\-zuweisung von 
Levels mit von \csbhyp{etocsetlevel}}

Die intrinsischen Level, die durch \etoc manipuliert wurden, sind numerisch: von
|-2| (welches |book| aus der |memoir|-Klasse entspricht) bis hinab zu |5|
(|subparagraph|). Jedoch kann die Zuweisung eines numerischen Level zu einem
gegebenen Namen zu jeder Zeit mit de Befehl
\csb{etocsetlevel}\marg{level\_name}\marg{number} abgeändert werden. Daraus und
aus der Benutzung des \LaTeX -|tocdepth|-Zählers resultieren mächtige
Anwendungszwecke: \meta{level\_name} muss sich nicht mit dem eigentlichen
Unterteilungsbefehls des Dokuments überschneiden. Außerdem kann \etoc genutzt
werden, um beliebige "`Listen von Dingen"' ohne weitere Hilfsdateien, außer der
|.toc|-Datei, zu erstellen. Dieses wird in \autoref{part:surprising} weiter
erklärt.

\begin{framed}
  Es wird oft gesagt, dass Unterteilungslevel von |\part| in den
  Standardklassen, die keinen |\chapter|"=Befehl haben, gleich |0| sind, und in
  denen mit |\chapter|"=Befehl gleich |-1| ist. Das ist auch \emph{richtig}, wenn
  man die \emph{automatische Nummerierung}, gesteuert durch den Wert des
  |secnumdepth|-Zählers, betrachtet. Aber es ist \emph{falsch}, wenn man den
  Effekt des |tocdepth|-Zählers sieht. Setzt man |tocdepth| in der |article|
  -Klasse direkt vor |\tableofcontents| auf |-1|, verhindert das \emph{nicht},
  dass Abschnitte in der Inhaltsangabe aufzutauchen. Man muss es dafür auf |-2|
  stellen, ganz egal ob in der |article|- oder der |book|-Klasse.

  Die kanonischen Level, grundsätzlich bekannt aus \etoc, sind 
  von Relevanz für den \textbf{|tocdepth|}-Zähler in den Standardklassen
  und werden in der folgenden Tabelle rekapituliert:
  
  \centeredline{
    \fbox{\begin{tabular}{rc}
        (|memoir| class) book&-2\\ part&-1\\ chapter&0 \\
        section&1\\ subsection&2 \\
        subsubsection&3 \\ paragraph&4 \\ subparagraph& 5
    \end{tabular}}}

\smallskip Mit \etoc kann der Nutzer innerhalb einem gegebenen Unterabschnitt
einfach lokale Inhaltsangaben ausgeben. Darin werden, wenn gewollt,
Unterabschnitte in dem Stil von Abschnitten, Paragraphen in dem Stil von
Unterabschnitten und Unterparagraphen im Stil von Unter"=Unterabschnitten
gedruckt. Demnach kann man entscheiden alles auf das Level |6| zu setzen (wird
von \etoc nie angezeigt), außer z.\,B. Paragraphen, die auf Level |1| befördert
werden. So erstellt man eine schöne Inhaltsangabe aller Paragraphen eines
Dokuments. (|tocdepth| mindestens |1|)\footnotemark
\end{framed}

\footnotetext{Normalerweise sollte man diese Inhaltsangabe der Paragraphen
nicht im Kompabtibilitätsmodus ausgeben. Der würde darauf bestehen, einen 
gigantischen Abstand nach rechts einzufügen.}

\section{Die \csbhyp{etoc\-set\-toc\-depth}- und  
  \csbhyp{etoc\-set\-next\-toc\-depth}"=Befehle} 
\label{etocsettocdepth}
\label{etocsetnexttocdepth}

Der |tocdepth|-Zähler hat keinen Einfluss darauf, was in die |.toc|-Datei
geschrieben wird; dessen Einfluss ist ausschließlich auf das Setzen der
Inhaltsangabe gerichtet. In der Standardklasse ist nur ein |\tableofcontents|
möglich, wobei mit \etoc beliebig viele erlaubt sind. Dadurch könnte man
|tocdepth| immer und immer wieder auf einen passenden Wert ändern (der
entscheidet, wie tief die Abschnitte angezeigt werden sollen) bis die
Inhaltsangabe gesetzt werden muss.

\etoc bietet \csb {etocsettocdepth}\marg{level} an, wessen verpflichtendes
Argument entweder (von |-3| bis |5|) oder einen Unterteilungstyp wie
|subsection| oder |subsubsection| oder alle anderen, die davor in \etoc mit
\csb{etocsetlevel} (die Schlüsselworte |all| und |none| erkannt werden,
allerdings nicht in Zusammenhang mit der Dokumentenunterteilung) deklariert
wurden. Das tut das passende |\setcounter{tocdepth}{numeric_level}|.

Wie in dem nächsten Unterabschnitt erklärt wird, wird |tocdepth| von |hyperref|
benutzt. Man muss die folgenden Schritte befolgen, um den Einfluss von
|hyperref|`s Änderungen auf die Lesezeichen zu verhindern. \etoc hat \csb
{etocsetnexttocdepth}\marg{level}. Dessen Einfluss endet direkt nach der
nächsten Inhaltsangabe. Daraus folgt, dass
\texttt{\textbackslash\foreignlanguage{english}{invisibletableofcontents}}
essenziell für |\etocsetnexttocdepth{none}\tableofcontents| ist.

Der einfachste Weg ist also, eine einfache Instanz des
\csb{etocsettocdepth}"=Befehl nach |\begin{document}| und vor dem ersten
  |\tableofcontents| mit dem tiefsten Level als Argument zu setzen. -- Dieses
  dann lokal zu benutzen, wo es gebraucht wird, anhand von
  \csb{etocsetnexttocdepth} vor |\tableofcontents| oder |\localtableofcontents|.

\subsection{Die hyperref"=Option \emph{bookmarksdepth}}
\label{ssec:bookmarksdepth}

Wenn man den Zähler |tocdepth| verändert, um \toc oder \localtoc
mehrfach zu benutzen, sollte man gewahr sein, dass das Paket
|hyperref| standardmäßig den Wert des \emph{aktuellen} Wertes
der |tocdepth|-Zählers berücksichtigt, um zu entscheiden, ob die |pdf|-Datei 
Lesezeichen, korrespondierend mit den Unterteilungsbefehlen, die in der
Quelldatei vorgefunden wurde, anzeigt. Dadurch muss man typischer Weise
den |tocdepth|-Zähler auf seinen vorigen Wert zurücksetzen, nachdem man
ihn temporär für eine  gegebene Inhaltsangabe modifiziert hat.

Alternativ gibt es die \emph{bookmarksdepth=n}-Option des |hyperref|-Pakets.
Dabei ist \emph{n} die gewünschte maximale Lesezeichen"=Tiefe. Diese kann
numerisch sein oder der Name eines Levels, das |hyperref| bekannt ist.

Wir sind in dieser Dokumentation schon an |bookmarksdepth=3| vorbeigekommen. Es
war eine Option von |hyperref|. Auch wenn |tocdepth| nach dem Ausgeben einer
Inhaltsangabe aus Nachlässigkeit auf |1| stehen gelassen wurde, so wurden der
Lesezeichenbaum der |pdf|-Datei nicht verändert. Da \csb{etocsetnexttocdepth}
jetzt zu dem Paket hinzugefügt wurde, ist keine Verwendung mehr für
|bookmarksdepth=3|.

\section{Der Befehl \csbhyp{etoc\-set\-toc\-dep\-th.toc}}
\label{etocsettocdepth.toc}

Dieser Befehl \csb{etocsettocdepth.toc} implementiert einige Funktionalitäten
von Paket |tocvsec2|\footnote{\url{http://ctan.org/pkg/tocvsec2}. Ich danke D.B.
  meine Aufmerksamkeit auf die Inkompatibilität dieses Pakets mit \etoc
  gerichtet zu haben.}. Dieses Paket war inkompatibel mit \etoc. Es kann nun
noch für seine mit |secnumdepth| in Verbindung stehenden Befehle genutzt werden,
alle mit |toc| in Verbindung stehenden Aktivitäten werden jedoch durch \etoc
abgebrochen.

Das Handeln von \csb{etocsettocdepth.toc} ist grundlegend verschieden zu
\csb{etocsettocdepth}. Anstatt den |tocdepth|-Zähler direkt zu verändern,
fügt es der |.toc|-Datei eine Linie an, die, wenn ausgeführt, in einer
Inhaltsangabe diese Veränderung ausführen wird.

Der Befehl \csb{etocsettocdepth.toc} akzeptiert, wie
\csb{etocsettocdepth}, Namen und numerische Argumente.
In dem Fall eines Namen als Argument ist der tatsächliche numerische
Wert noch nicht festgelegt, wenn |.toc|-Datei erstellt wird. Es wird
der Wert sein, der aktuell für das benannte Level der Inhaltsangabe 
(ohne |\etocignoretoctocdepth| gemacht zu haben) bei
jeder Erstellung einer Inhaltsangabe spezifiziert wird.

Der |tocdepth|-Zähler wird niemals auf einen Wert gesetzt, der feiner
als der ist, mit dem er zu Beginn der Inhaltsangabe initialisiert wurde.
Also ist das Hinzufügen von \csb{etocsettocdepth.toc} im Dokument ein Weg 
die Tiefe einer lokalen Inhaltsangabe einzugrenzen. Zum Beispiel,
um die Einfügung von Unter-unter"=Abschnitten  oder eines gegebenen
Kapitels zu unterbinden.


Dieses
{\fbox{wird in allen Inhaltsangaben ausgeführt.}}

\subsection{Die Befehle \csbhyp{etocobeytoctocdepth} und \csbhyp{etocignoretoctocdepth}}
\label{etocobeytoctocdepth}
\label{etocignoretoctocdepth}


Also wird \csb{etocignoretoctocdepth} gesetzt, um den
\csa{etocsettocdepth.toc}-Mecha\-nismus abzubrechen, wenn 
benötigt; und \csb{etocobeytoctocdepth} wird es
reaktivieren. Das Paket führt \csb{etocobeytoctocdepth} zu Beginn aus.


\section{Die Befehle \csbhyp{etoc\-depth\-tag.toc} und \csbhyp{etocsettagdepth}}
\label{etocdepthtag.toc}
\label{etocsettagdepth}

Wie oben erwähnt, wenn das Argument für \csb{etocsettocdepth.toc} kein
numerisches sondern ein Namen"=Level ist, wird durch die tatsächliche Nummer bei
der Erstellung der Inhaltsangabe entschieden. Dadurch und anhand der
\emph{Schiebe"=Mechanismen von \etoc} kann man einen sehr flexiblen Aufbau
erreichen: Man erklärt mit \csb{etocsetlevel} zuerst ein paar Platzhaltelevel,
z.\,B. |partIII|, und weist ihm das unsichtbare Level |6| zu. Dann, vor dem
dritten |\part| Befehl, fügt man \csb{etocsettocdepth.toc}|{partIII}| ein. An
dem Ort, an dem der Effekt enden soll, setzt man
\csb{etocsettocdepth.toc}|{all}| ein. Es ist nun möglich, jedes Mal, wenn man
eine Inhaltsangabe setzen will, das feinste Level der Einträge aus dem dritten
Teil zu spezifizieren. Man muss z.\,B. nur \csa{etocsetlevel}|{partIII}{1}|
schreiben. Es wird die Abschnitte limitieren (sofern |tocdepth| mindestens auf
diesem Level war, wenn die Inhaltsangabe ausgegeben wurde).

Die Methode hat ein paar Beschränkungen:
\begin{enumerate*}[label={(\roman*)}]
  \item Das zweite Argument von \csb{etocsetlevel} muss numerisch sein;
  \item es kann nicht auf |-3| gesetzt werden (was nötig wäre, wenn man ganze
  Bücher aus der Inhaltsangabe streichen wöllte in den Klasse |memoir|);
  \item es ist ein bisschen getrickst, seit |partIII| kein richtiger unterteilender
  Abschnitt ist sondern nur ein \emph{tag}.
\end{enumerate*} 

Version |1.07h| enthält den Befehl \csb{etocdepthtag.toc}, der
es einfacher macht, diese variable lokale Kontrolle des |tocdepth| zu erreichen,
wenn die Inhaltsangabe erstellt wird.


Es wird als \csb{etocdepthtag.toc}\marg{tag\_name} genutzt, wo der
\meta{tag\_name} irgendetwas ist, das wird den Tag in die |.toc|-Datei setzen.
Wenn die Inhaltsangabe erstellt wird, initiiert das eine Reihe von Befehlen
\csb{etocsettagdepth}\marg{tag\_name}\marg{level}, wo das \meta{level} entweder
numerisch (von |-3| bis |5|) oder ein Name einer unterteilenden Einheit, die
\etoc bekannt ist, oder |none| oder |all|. Der Effekt von den Tags innerhalb der
|.toc|-Datei ist es, den |tocdepth|-Zählers auf den gewünschten Wert zu setzen
(das kann wie schon erwähnt, nicht feiner sein als der initiale Wert des
|tocdepth|-Zählers).

Die hinzugefügte Flexibilität wirkt sich insofern aus, dass \csb{etocsetlevel}
nicht mehr mit dieser getricksten Methode, bei der man Level"=Tiefen und |none|
und |all| benutzt hat.

Wie immer, wenn die Tag"=Tiefen gesetzt wurden, bleiben sie wirkend, bis sie
wieder definiert werden oder ihr Wirkungsgebiet beendet wird, indem die
umschließende Gruppe geschlossen wird. Für ein Beispiel, siehe hier:
\autoref{ssec:tocwithdepthtags}.


\subsection{Die Befehle \csbhyp{etocobeydepthtags} und \csbhyp{etocignoredepthtags}}
\label{etocobeydepthtags}
\label{etocignoredepthtags}


Nach \csb{etocignoredepthtags} werden die |.toc|-Tiefentags ignoriert
(nach \csb{etocdepthtag.toc}  funktionieren sie jedoch noch). Das Paket
führt zu Beginn \csb{etocobeydepthtags} aus. Dieses befielt \etoc auf die
gefundenen Tags in der |.toc|-Datei zu reagieren.

\section{Befehle zur \texorpdfstring{\texttt{.toc}}{.toc}-Datei hinzufügen}
\label{sec:addingtotoc}

Wir beschrieben oben die Befehle \csb{etocsettocdepth.toc} und
\csb{etocdepthtag.toc}, welche beide Befehle in die |.toc|-Datei einfügen. Ein
noch allgemeinerer Weg, um "`action tags"' in die |.toc|-Datei einzufügen, wäre
vorstellbar, allerdings würde auch nur indirekt
|\addtocontents{toc}{\something}| benutzt werden.

Man sollte vorsichtig sein, wenn man auf diesem Weg Dinge zur |.toc|-Datei
hinzufügt. Zum Beispiel das Einfügen von
\csa{addtocontents}|{toc}{\string\clearpage}| direkt vor einem \csa{part} behebt
den Fehler, dass Teileinträge in Inhaltsangaben vom Rest getrennt am Ende der
Seite auftauchen, kann aber auch Probleme mit mehreren Inhaltsangaben haben:
\csa{clearpage} wird jedes Mal ausgeführt, wenn \etoc über ein \toc oder
\localtoc stolpert. Die schlauere Methode wäre es:
{\csa{addtocontents}|{toc}{\string\myclearpage}|,} den |\let\myclearpage\relax|,
man hätte den Befehl |\let\myclearpage\relax| zu Beginn des Dokuments und wenn
benötigt, benutzt man etwas wie:
\begin{verbatim}
\let\myclearpage\clearpage
\tableofcontents
\let\myclearpage\relax
\end{verbatim}
Die |memoir|-Klasse besitzt den Befehl \csa{settocdepth}, der einen
\csa{changetoc\-depth}"=Befehl in die |.toc|-Datei setzt. Dieses
beeinflusst die Schriftsetzung von \etoc bei \emph{allen} Inhaltsangaben mit
möglichen unvorhersehbaren Ergebnissen: Stellen Sie sich vor, irgendwo im Dokument
stünde \csa{settocdepth}|{chapter}|, um die Abschnitte von Unterabschnitten
nicht in der Hauptinhaltsangabe aufzulisten. In diesem Fall würde eine
lokale Inhaltsangabe in einem dieser Kapitel einen Titel ohne jeden Eintrag ausgeben. 

Da die |memoir|-Klasse von Haus aus schon mehrfache \toc erlaubt, tritt dieser
Fehler schon viel früher, und unabhängig von \etoc, auf. Siehe Seite 170 der
|memoir|-Anleitung.

Für diesen Spezialfall gibt es folgende Befehle: \csb{etocsettocdepth.toc},
\csb{etocignoretoctocdepth}, \csb{etocobeytoctocdepth} oder deren
Varianten \csb{etocdepthtag.toc} und \csb{etocsettagdepth}.

Nebenbei, jeder |\setcounter{tocdepth}{n}|"=Befehl fügt direkt in die
|.toc|-Datei hinzu. Es scheint so, dass seine Wirkung ist (seit der Version
|1.07g|), beendet den Abschluss jedes Inhaltsverzeichnis zu beenden, automatisch
wird ein |\setcounter{tocdepth}{previous_value}| genommen, mit dem Wert, aktiv
ein Inhaltsverzeichnis zu nehmen.

\subsection{Die hyperref"=Option \emph{hidelinks}}\label{ssec:hidelinks}

Die farbigen Links (und auch die Kastenlinks) sind einwenig ärgerlich, wenn in
Inhaltsverzeichnissen verwendet, insbesonders, wenn das Dokument \etoc verwendet
und viele von ihnen beinhaltet! Man kann sich wünschen, farbige Links
\emph{ausschließlich} für Inhaltsverzeichnisse! In der Tat, warum sollten in
TOCs diese Dinge gerahmt oder farbig sein müssen, wenn der Benutzer
\emph{bereits erwartet, dass dort Links sind}?

Ich nehme den folgenden Trick: Entweder in der Präambel zu nehmen
|\AtBeginDocument| oder danach |\begin{document}|, ich habe den Befehl   \centeredline{|\addtocontents{toc}{\protect\hypersetup{hidelinks}}|}

  \begin{framed}
    Alle TOCs, die von \etoc gesetzt sind, haben ihre Inhalte in eine
    Gruppierung getan, (wie in einer Umgebung eingeschlossen). So wird der
    Befehl \csa{hypersetup}|{hidelinks}| ausgeführt von \emph{jedem} TOC, aber
    sein Effekt wird limitiert zu dem TOC.
  \end{framed}

Experimentell habe ich herausgefunden, dass die Option |hidelinks| oftmals mit
|\hypersetup| eingestellt werden kann (Dies ist nicht bei allen
|hyperref|-Optionen der Fall).



\section{Zwei Beispiele}

\subsection{Eine wunderschöne Beispielthese}

Hier ist noch ein relativ einfaches Beispiel für die Verwendung der
Paket"=Funktionsweisen. Lassen Sie uns einige Linienstile einrichten. Wir wählen
einen Stil für Abschnitte und Unterabschnitte, welche für die Abschnitte und
Unterabschnitte in einem durchschnittlichen Memoirenumfang geeignet wären. Die
Linienstilspezifikationen haben eine gewisse Redundanz für die Klarheit, und sie
interessieren sich nicht dafür, was bei möglichen Seitenumbrüchen zu tun ist.
Auch sind sie nicht besorgt über die potentielle mehrspaltige Nutzung.

\begin{verbatim}
\begingroup % wir starten, um eine Gruppe zu behalten 
\newlength{\tocleftmargin}    \setlength{\tocleftmargin}{5cm}
\newlength{\tocrightmargin}   \setlength{\tocrightmargin}{1cm}

\etocsetstyle{section}              % wird vorgegeben, ein Kapitel zu sein
{\addvspace{1ex}\parfillskip0pt
 \leftskip\tocleftmargin            % (bereits im Titel getan)
 \rightskip\the\tocrightmargin plus 1fil
 \parindent0pt\color{cyan}}         % (bereits getan)
{\bfseries\LARGE\upshape\addvspace{1ex}\leavevmode}
{\llap{Chapter\hspace{.5em}{\etocnumber}\hspace{.75cm}}\etocname
 \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}

\etocsetstyle{subsection}           % wird vorgegeben, ein Abschnitt zu sein
{}
{\mdseries\large\addvspace{.5ex}\leavevmode}
{\llap{\etocnumber\hspace{.75cm}}\textit{\etocname}%
 \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}

\def\tmptitle{My Beautiful Thesis}
\etocsettocstyle{\color{cyan}\parindent0pt \leftskip\tocleftmargin
  \leavevmode\leaders\hrule height 1pt\hfill\ 
  \huge\textit{\tmptitle}\par}{\bigskip}

\tableofcontents \ref{toc:overview}
\endgroup
\end{verbatim}

\begingroup
\newlength{\tocleftmargin}
\setlength{\tocleftmargin}{5cm}
\newlength{\tocrightmargin}
\setlength{\tocrightmargin}{1cm}

\etocsetstyle{section}
{\addvspace{1ex}\parfillskip0pt
 \leftskip\tocleftmargin
 \rightskip\the\tocrightmargin plus 1fil
 \parindent0pt\color{cyan}}
{\bfseries\LARGE\upshape\addvspace{1ex}\leavevmode}
{\llap{Kapitel\hspace{.5em}{\etocnumber}\hspace{.75cm}}\etocname
 \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}

\etocsetstyle{subsection}
{}
{\mdseries\large\addvspace{.5ex}\leavevmode}
{\llap{\etocnumber\hspace{.75cm}}\textit{\etocname}%
 \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}

\def\tmptitle{Meine wunderschöne These}

\etocsettocstyle{\color{cyan}\parindent0pt\leftskip\tocleftmargin
  \leavevmode\leaders\hrule height 1pt\hfill\ 
  \huge\textit{\tmptitle}\par}{\bigskip}

\tableofcontents \ref{toc:overview}
% And again, for the fun of it:
% \def\tmptitle{My Very Beautiful Thesis}
% \tableofcontents \ref{toc:c}
\endgroup


\subsection{Ein TOC  mit einer Hintergrundfarbe}\label{ssec:again}

Lassen Sie uns nun einige anspruchsvollere Linienstile versuchen. Das Display
wird den Paket"=Befehl \csa{etocframedstyle} verwenden, damit das erzeugte
Inhaltsverzeichnis auf eine einzige Seite passt. Wir wickeln es in eine
\hyperref[toc:floating]{Figur"=Umgebung}, damit es auf der aktuellen Seite
angezeigt wird. \vpageref{toc:floating}.


\begin{figure}[htbp!]\centering
\colorlet{subsecnum}{black}
\colorlet{secbackground}{green!30}
\colorlet{tocbackground}{red!20!green!20}

\renewcommand{\etocbkgcolorcmd}{\color{tocbackground}}
\renewcommand{\etocleftrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocrightrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocbottomrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etoctoprulecolorcmd}{\color{tocbackground}}

\renewcommand{\etocleftrule}{\vrule width 3cm}
\renewcommand{\etocrightrule}{\vrule width 1cm}
\renewcommand{\etocbottomrule}{\hrule height 12pt}
\renewcommand{\etoctoprule}{\hrule height 12pt}

\renewcommand{\etocinnertopsep}{0pt}
\renewcommand{\etocinnerbottomsep}{0pt}
\renewcommand{\etocinnerleftsep}{0pt}
\renewcommand{\etocinnerrightsep}{0pt}

\newcommand\shiftedwhiterule[2]{%
    \hbox to \linewidth{\color{white}%
    \hskip#1\leaders\vrule height1pt\hfil}\nointerlineskip
\vskip#2}

\etocsetstyle{subsubsection}{\etocskipfirstprefix}
{\shiftedwhiterule{\leftskip}{6pt}}
{\sffamily\footnotesize
\leftskip2.3cm\hangindent1cm\rightskip.5cm\noindent
\hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
\rlap{\hbox to .5cm{\hss\etocpage\hskip.1cm}}\par
\nointerlineskip\vskip3pt}
{}

\etocsetstyle{subsection}{\etocskipfirstprefix}
{\shiftedwhiterule{1.5cm}{6pt}}
{\sffamily\small
\leftskip1.5cm\hangindent.8cm\rightskip.5cm\noindent
\hbox to .75cm{\color{subsecnum}\etocnumber\hss}%
\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
\rlap{\hbox to .5cm{\hss\etocpage\hskip.1cm}}\par
\nointerlineskip\vskip3pt}
{}

\newcommand{\coloredstuff}[2]{%
            \leftskip0pt\rightskip0pt\parskip0pt
            \fboxsep0pt % \colorbox uses \fboxsep also when no frame!
       \noindent\colorbox{secbackground}
               {\parbox{\linewidth}{%
                    \vskip5pt
                    {\noindent\color{#1}#2\par}\nointerlineskip
                    \vskip3pt}}%
       \par\nointerlineskip}

% v1.07l on the occasion of traduction into German documentation:
     % APRIL 26, 2014 Improvement in the section style for better placement of
     % page number when the section name is more than one line long. Use of
     % \makebox rather than \hbox, to be more LaTeX like.
\etocsetstyle{section}
{\coloredstuff{blue}
     {\hfil \bfseries\large Inhalt von Teil Eins\hfil}}
{\vskip3pt\sffamily\small}
{\coloredstuff{blue}
    {\leftskip1.5cm\rightskip.5cm\parfillskip-\rightskip
     \makebox[0pt][r]{\makebox[.5cm][l]{\etocnumber}}%
     \etocname\hfill{\makebox[.5cm][r]{\etocpage\hspace{.1cm}}}}%
 \vskip6pt }
{}


% attention car \ref{toc:floating} fera référence au compteur de
% toutes les toc, pas visibletoc. 

\etocframedstyle[1]{}
\tableofcontents \label{toc:floating} \ref{toc:overview}
\vspace{-\baselineskip}
\centeredline{|\tableofcontents \ref{toc:overview}| 
(\emph{cf.} \autoref{ssec:again} and \hyperref[toc:clone]{this other toc})}
\end{figure}

Das aktuelle Design ist nicht in \etoc vorgefertigt; sondern nutzt seine
`eingerahmten' Stile mit einer Hintergrundfarbe. Die Rahmengrenzen wurden so
gesetzt, dass die gleiche Farbe, wie die Hintergrundfarbe, für die gesamte Sache
dienen soll. Dieses Design (mit anderen Farben) wird auch für
\hyperref[toc:clone]{dieses andere Inhaltsverzeichnis} benutzt, und der Leser
bezieht sich auf seine \hyperref[ssec:tocclone]{Unterabschnitte}, welche für die
Kodierung vorgesehen sind.


\clearpage
\etocdepthtag.toc {surprising}
\part{Überraschende Anwendungen von \etoc}
\label{part:surprising}

\thispartstats %% (pas de sous-section)

% in dtx of release 1.07h there was here a \thisspecialstats, but it
% originated from the period when this \part was only a \section. So its
% effect was not the intended one, basically it had the same effect as this:
\etocstandardlines
\etocsettocstyle {}{}
\localtableofcontents

\section{Das TOC für TOCs}

\begingroup % \endgroup just after the \tableofcontents command
\etocinline
\etocsetlevel{part}{1}
\etocsetlevel{visibletoc}{0}
\etocsetstyle{visibletoc}
    {\etocskipfirstprefix}
    {, }
    {{\color{niceone}\etocname}}
    {}
\etocsettocstyle{}{}
\etocsetnexttocdepth{visibletoc}

Hier ist die nummerierte und verknüpfte Liste aller Tabellen von Inhalten, die
in diesem Dokument dargestellt sind \footnote{Die Inhaltsverzeichnisse können
  "`Schwimmer"' setzen, um die Reihenfolge zu ändern: die Zahlen werden in der
  Reihenfolge der Inhaltsverzeichnisse in dem Dokument aufgeführt; aber die
  Nummerierung selbst ist von der Reihenfolge der Inhaltsverzeichnisse in der
  \emph{Quelle} dieses Dokumentes \ldots}
\tableofcontents\endgroup. Und hier erhalten wir, was
wir gerade geschrieben haben:\par\smallskip 
{\leftskip1cm\rightskip2cm
  \ttfamily\small\baselineskip11pt \noindent Hier ist die
  nummerierte und verknüpfte Liste aller Tabellen von Inhalten, die in
  diesem Dokument dargestellt sind:~\string\tableofcontents.\par}

Die vorausgehenden Arbeiten waren wie folgt. Zuerst definierten wir einen Zähler
|visibletoc|, dessen Berufung es ist, bei jedem angezeigten Inhaltsverzeichnis
erhöht zu werden. \etoc hat einen eigenen Zähler, aber es zählen alle
Inhaltsverzeichnisse, auch wenn diese nicht angezeigt werden, da die |tocdepth|
Werte |-2| oder |-3| waren.

Wir könnten manuell |\refstepcounter{visibletoc}| und |\label| an allen
geeigneten Stellen im Dokument hinzufügen, und wir würden dann |\ref|- Befehle
verwenden, aber dies stellt eine hohe manuelle Bearbeitung der Quelle dar.

Es gibt eine viel bessere Möglichkeit: Es gibt einen Aufhänger
\csb{etocaftertitlehook} und wir sagten, es erhöht sich der |visibletoc|-Zähler
und wir schreiben eine Anlage zu der |.toc|-Datei, in analoger Weise zu dem
Gliederungsbefehl, zum Beispiel |Kapitel|, |Abschnitt| oder |Unterabschnitt|.
Wie \etoc seinen eigenen Zähler erhöht, noch bevor der Titel des
Inhaltsverzeichnisses gesetzt wird, bietet diese (die meiste Zeit) einen
besseren Link"=Zielpunkt als jeder Zähler von \csa{etocaftertitlehook} (der Link
wird nach dem Titel platziert). Anstatt mit |\refstepcounter{visibletoc}|,
innerhalb von \csa{etocaftertitlehook}, formulieren wir
|\stepcounter{visibletoc}|, dann folgt der Befehl
\csb{etoctoccontentsline}|{visibletoc}{\thevisibletoc}|. Dieser \etoc"=Befehl
\csb{etoctoccontentsline}\marg{level\_name}\marg{name} hat die gleiche Wirkung
wie: \centeredline{| ||\addcontentsline{toc}|\marg{level\_name}\marg{name}} aber
sein Nutzen ist es \footnote{Mit \csa{addtocontents} anstatt
  \csa{addcontentsline}.}, die Reparatur der automatischen Erstellung von
Lesezeichen zu verhindern mit \csa{addcontentsline} bei dem |hyperref|-Paket,
wie die pdf"=Lesezeichen machen sie nicht viel Sinn hier (und würde eine
Beschwerde bezüglich von |hyperref| eruieren, denn das Lesezeichen"=Niveau ist
`unbekannt').\footnote{ Das Paket bietet eine Stern"=Variante
  \staritb{etoctoccontentsline}, die zulässt, dass die Erstellung von
  Lesezeichen und das Haben eines dritten obligatorischen Arguments, welches das
  Lesezeichen"=Niveau darstellt, funktioniert; abhängig vom Kontext kann die
  Hauptrolle und die Nicht"=Stern"=Variante profitabel durch \csa{phantomsection}
  sein.}
 
Schließlich war in der Präambel des Dokuments |\etocsetlevel{visibletoc}{6}|.
Das Niveau |6| (oder etwas mit einer höheren Zahl) wird ignoriert, auch wenn
|tocdepth| zum Beispiel den Wert |10| hat; das ist unabhängig davon, ob \etoc
die Dokumentenklasse als Standardlinien oder als eigene Linienstile nutzt oder
die, die vom Benutzer mit \csa{etocsetstyle} Befehl definiert wurden. Es gibt
also keinen Grund zur Sorge, dass etwas schief gehen könnte.

Dann haben wir hier nur |\etocsetlevel{visibletoc}{0}| gesetzt. Und nur diese
Art von Einträgen weisen wir vorübergehend eine |Teil|- und |Kapitel|-Ebene |1|
zu (oder etwas höher als null) und setzen |tocdepth| auf den Wert |0|. Wir haben
auch \csa{etocsetstyle\{visibletoc\}\{\string\etocskipfirstprefix\}\{,
  \}\{\string\etocname\}\{\}}, welche eine innere Anzeige mit dem Komma als
Trennzeichen definiert. Wie \etoc Aspekte |\par| automatisch als Standard das
Inhaltsverzeichnis setzt, verwendeten wir den Befehl \csb{etocinline} (auch als
\cs{etocnopar} bekannt), welches die Reaktion ausmacht .

Hier sind die Details der Implementierung:

\begingroup
\begin{verbatim}
 < in der Prämbel >
\newcounter{visibletoc}
\renewcommand{\etocaftertitlehook}
   {\stepcounter{visibletoc}\etoctoccontentsline{visibletoc}{\thevisibletoc}}
\etocsetlevel{visibletoc}{6}
\begin{document}
   < document body >
\subsection{Surprising uses of etoc}
\begingroup
    \etocinline
    \etocsetlevel{part}{1}
    % \etocsetlevel{chapter}{1} % (keine Kapitel in scrartcl Klasse)
    \etocsetlevel{visibletoc}{0}
    \etocsetstyle{visibletoc}
        {\etocskipfirstprefix}{, }{{\color{niceone}\etocname}}{}
    \etocsettocstyle{}{}     % keine Titel, Regeln oder Rahmen festgelegt!
    \etocsetnexttocdepth{visibletoc} % zeigt nur die `visibletoc' Einträge an aus .toc

Hier ist die nummerierte und verknüpfte Liste aller Tabellen von Inhalten,
die in diesem Dokument angezeigt werden: \tableofcontents.
\endgroup
\end{verbatim}

\endgroup

Nach |\etocsetstyle{visibletoc}{..}{..}{..}{..}|, wird für alle zukünftigen 
Inhaltsverzeichnisse (nicht im
Kompatibilitätsmodus) der definierte Stil für das Niveau 
|0| verwendet (was normalerweise der Pegel für ein Kapitel
ist). Um diese Änderung auf die einfachste Art und Weise zu halten, muss man
alles in eine Gruppe setzen.

Der \autoref{subsec:interverting} gibt eine andere Verwendung
von Verschachtelungsstufen an. 

\section{Willkürliche "`Listen von \ldots "', \csbhyp{etoctoccontentsline}}
\label{etoctoccontentsline}

Die Idee der Internabwehr ist leistungsfähig und ermöglicht
\etoc"=Anzeigelisten, um beliebige Dinge in dem Dokument enthalten zu lassen.
Und all das mit noch nichts anderem als der
|.toc| Datei! 
Beispiel: Stellen Sie sich ein Dokument mit Dutzenden von Übungen vor,
vielleicht als |\newtheorem{exercise}{}[section]|.
Lassen Sie uns erklären, wie man \etoc anweist, eine verlinkte Liste all dieser
Übungen anzuzeigen. Dafür haben wir in der Präambel geschrieben:
\begin{verbatim}
 \newtheorem{exerci}{}[section] 
    % the exercice number will be recoverable via \etocname: v--here--v
 \newcommand*{\exercisetotoc}{\etoctoccontentsline{exercise}{\theexerci}}
 \newenvironment{exercise}{\begin{exerci}\exercisetotoc}{\end{exerci}}
 \etocsetlevel{exercise}{6}
\end{verbatim}
Auf diese Weise wird \csa{etocname} die Übungsnummer vergeben (aber
\csa{etocnumber} wird leer sein). Hätten wir stattdessen
\begin{verbatim}
 \newcommand*{\exercisetotoc}
    {\etoctoccontentsline{exercise}{\protect\numberline{\theexerci}}}
\end{verbatim}
%
verwendet, wäre die Übungsnummer via \csa{etocnumber} verfügbar und
\csa{etocname} wäre leer gewesen. Es spielt keine Rolle, welches der beiden
Verfahren verwendet wird. Der \etoc Befehl \csa{etoctoccontentsline}|{..}{..}|
wird als Ersatz für \csa{addcon\-tentsline}|{toc}{..}{..}| verwendet: Das ist
die, die durch das Reparieren von |hyperref| zu \csa{addcontentsline} verwendet
wird, um in ihrem Prozess die Erstellung von Lesezeichen zu vermeiden. Wenn man
|hyperref| ermächtigt, Lesezeichen auf einer bestimmten Ebene \meta{n} zu
erschaffen, kann einer (hier mit \meta{n}$=$|2|) die Stern"=Variante
\starit{etoctoccontentsline} benutzen, welche ein zusätzliches Argument hat:
%
\begin{verbatim}
\newcommand{\exercisetotoc}{\etoctoccontentsline*{exercise}{\theexerci}{2}}
\end{verbatim}

Der Zähler |exerci| wird bereits durch das |exerci|-Theoremumfeld erhöht und
sorgt für den richtigen Ort für den Link zusätzlich zum Paket
|hyperref|. Der Befehl \csa{exercisetotoc} fügt für jede Übung eine Zeile in die
|.toc|-Datei, entsprechend einer fiktiven Dokumenteinheit
mit dem Namen `|Übung|' ein. Eine
Vier"=Säulen"=Liste, einschließlich der Abschnitte, kann dann erreichen mit 
\begin{verbatim}
 \etocsetnexttocdepth{2}     % Abschnitte sind auf Stufe 1 und werden anzeigen
\begingroup
  \etocsetlevel{exercise}{2}   % aber:
  \etocsetlevel{chapter}{3}    %     keine Kapitel
  \etocsetlevel{subsection}{3} %     keine Unterabschnitte
  \etocsetlevel{part}{3}       %     keine Parts
  \etocsetstyle{exercise}{}{}  % \etocname = exercise number
    {\noindent\etocname\strut\leaders\etoctoclineleaders\hfill\etocpage\par}
    {\pagebreak[2]\vskip\baselineskip}
  \etocsetstyle{section}{}{}
    {\noindent\strut{\bfseries\large\etocnumber\hskip.5em\etocname}\par
     \nopagebreak[3]}{}
  \etocruledstyle[4]{\Large\bfseries List of the exercises}
  \setlength{\columnseprule}{.4pt}
  \tableofcontents
\endgroup
 \end{verbatim}


\section{Ein TOC mit einem extravagantem Layout}

Hier ist ein Inhaltsverzeichnis, wo die Abschnitte aus einem bestimmten Kapitel
durch einen Zahlenbereich dargestellt werden sollen
(wie 18--22 bei einem bestimmten Kapitel, 42--49 für ein anderes \ldots\
natürlich in das Inhaltsverzeichnis automatisch eingefügt wurden). 

Dies ist kein Abbildungseinschluss, das Inhaltsverzeichnis wird von seiner
ursprünglichen 
|tex|-Quelle in dieses Dokument nach dem Austausch des
|Teils|, |Kapitels| oder |Abschnitts| mit |Dummy-Teil|, |Dummy-Kapitel| und
|Dummy-Abschnitt| (und da ist auch eine Dummy-Seitenzahl) produziert.  Wir
kopierten die Linienstile, wie im Original verwendet, und
das Inhaltsverzeichnis zeigt folgende Situation an:
\begin{verbatim}
    \etocsetlevel{dummypart}  {-1} \etocsetlevel{part}   {2}
    \etocsetlevel{dummychapter}{0} \etocsetlevel{chapter}{2}
    \etocsetlevel{dummysection}{1} \etocsetlevel{section}{2}
                    \etocsetnexttocdepth{dummysection}
\end{verbatim}

Jedes Kapitel zeigt die Zahl nur von dem ersten und dem letzten Abschnitt an.
Siehe in der Quelldatei |etoc.dtx| für die Details nach, wie das gemacht wird.

Eine andere Technik für diese Art der Dinge erläutert 
  \autoref{ssec:statistics}.  

\begingroup

    \etocsetlevel{dummypart}{-1}
    \etocsetlevel{dummychapter}{0}
    \etocsetlevel{dummysection}{1}
    \etocsetlevel{part}{2}
    \etocsetlevel{chapter}{2}
    \etocsetlevel{section}{2}

    \newif\ifextraidone
    \newif\ifextraiidone

    \etocsetstyle{dummypart}
    {}
    {}
    {\begin{center}\Large\bfseries TEIL \etocnumber
    \ifextraiidone\\\etocname.\fi\end{center}
    \ifextraidone\else
    \noindent\hskip.7\linewidth
        \hbox to .2\linewidth
% février (ou janvier?) 2013
% je modifie ici en ajoutant un \hss, pour compenser la plus petite
% taille de txrm. Ok.
       {\hss\small\textsc{\bfseries Kapitel.\hss Seite.}}\par\fi
    \extraidonetrue
    }
    {}

    \newcommand\mytocleaders{\hbox to .125\linewidth{...\hss}}
    \etocsetstyle{dummychapter}
    {}
    {\par\noindent\etocifnumbered
        {\makebox[.15\linewidth][r]{\bfseries\etocnumber.}}
        {\hspace*{.15\linewidth}}}
    {\hbox to .65\linewidth
        {\hspace{1em}\etocname\leaders\mytocleaders\hss}%
     \hskip-.1\linewidth
     \hbox to .2\linewidth{\hspace{1.5em}...\hss
                    \etocifnumbered
                        {\etocpage}
                        {\ifextraiidone\else\etocpage\fi}}%
     \hskip-.2\linewidth
    }
    {}

    \newbox\forsectionnumbers
    \makeatletter
% 21 février 2013: je rajoute \color@begingroup et \color@endgroup
    \etocsetstyle{dummysection}
    {\setbox\forsectionnumbers=\hbox to .1\linewidth
        \bgroup\color@begingroup\hss\etocskipfirstprefix}
    {\@gobble}
    {\etocnumber---}
    {\etocnumber\color@endgroup\egroup
    % for reasons I do not quite understand, in some pdf viewers the dots
    % do not completely disappear if here \fboxsep0pt is used.
    % (problèmes liés à l'anti-aliasing, sur Mac OS X, Skim, Preview...)
    % (j'ai maintenu ici la méthode de mon post sur stackexchange, mais
    %  sans doute je pourrais réfléchir à une autre façon évitant d'avoir à
    %  « effacer ») 
        \fboxsep=.5pt\colorbox{white}{\box\forsectionnumbers}\par
        \ifextraiidone\else
            \begin{center}\bfseries Kongruenz.\end{center}
            \noindent\makebox[.15\linewidth][r]{\textsc{\bfseries Übung.}}\par
        \fi\extraiidonetrue
    }
    \makeatother

    \renewcommand{\etocinnertopsep}{0pt}

    \etocruledstyle[1]{%
        \parbox{\linewidth}{%
            \centering
            \textsc{\bfseries\LARGE\MakeUppercase{Inhaltsverzeichnis}}\\
            \rule{.2\linewidth}{2pt}}%
    }
        
    \etocsetnexttocdepth{dummysection}

    \tableofcontents
   
\makeatletter
    \def\adddummysection {\stepcounter{dummysection}%
      \addtocontents {toc}{\protect\contentsline 
          {dummysection}{\protect\numberline{\thedummysection}}%
                   {\the\dummypage }%
     %\ifEtoc@hyperref ou \ifdefined\hyperref si e-TeX
     {\@currentHref }%
     %\fi
     }}
 
    \def\adddummychapter #1{\stepcounter{dummychapter}%
      \advance\dummypage2
      \addtocontents {toc}{\protect\contentsline 
          {dummychapter}{\protect\numberline{\thedummychapter}#1}%
                   {\the\dummypage }%
     %\ifEtoc@hyperref ou \ifdefined\hyperref si e-TeX
     {\@currentHref }%
     %\fi
     }}

    \def\adddummychapno #1{\advance\dummypage2
      \addtocontents {toc}{\protect\contentsline 
          {dummychapter}{#1}{\the\dummypage }%
     %\ifEtoc@hyperref ou \ifdefined\hyperref si e-TeX
     {\@currentHref }%
     %\fi
     }}

    \def\adddummypart #1{\stepcounter{dummypart}%
       \advance\dummypage4
       \addtocontents {toc}{\protect\contentsline 
          {dummypart}{\protect\numberline{\Roman{dummypart}}#1}%
                     {\the\dummypage }%
     %\ifEtoc@hyperref ou \ifdefined\hyperref si e-TeX
     {\@currentHref }%
     %\fi
     }}
\makeatother
    
    \newcount\dummypage \dummypage-1

    \adddummypart {}
    
    \adddummychapno {Einleitung}

    \newcount\tempcount

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<8
    \repeat

    \adddummychapter {Kongruenz von Subjekt und Verb}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<17
    \repeat

    \adddummychapter {Kongruenz von Substantiven und Adjektiven}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<22
    \repeat

    \adddummychapno {Kongruenz von Relativen und Antezendenten}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<25
    \repeat

    \adddummypart {Government}

    \adddummychapter {Der Akkusativ}

    \adddummychapno {Allgemeine Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<30
    \repeat

    \adddummychapno {Besondere Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<37
    \repeat

    \adddummychapter {Verbrektion über zwei Akkusative}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<41
    \repeat

    \adddummychapter {Der Kausativ}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<49
    \repeat

    \adddummychapter {Der Instrumental}

    \adddummychapno {Allgemeine Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<54
    \repeat

    \adddummychapno {Besondere Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<59
    \repeat

    \adddummychapter {Der Dativ}

    \adddummychapno {Allgemeine Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<65
    \repeat

    \adddummychapno {Besondere Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<71
    \repeat

    \adddummychapter {Der Ablativ}

    \adddummychapno {Allgemeine Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<75
    \repeat

    \adddummychapno {Besondere Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<86
    \repeat

    \adddummychapter {Der Lokativ}

    \adddummychapno {Allgemeine Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<92
    \repeat

    \adddummychapno {Besondere Anwendungen}

    \loop\advance\tempcount by 1
    \adddummysection
    \ifnum\tempcount<100
    \repeat
\endgroup

\section{Ein weiterer Kompatibilitätsmodus}

Wie in \autoref{ssub:compat} erläutert, sagen die Befehle
\csa{etocstandardlines} und \csa{etocstandarddisplaystyle} \etoc im
Wesentlichen, wie man als Beobachter fungiert. Das Dokumentenklasse"=Layout für
das Inhaltsverzeichnis wird dann gehorchen. Es gibt keine Möglichkeit, dieses
Standard"=Layout aus dem Paket anzupassen (ändern von Schriftarten, Rändern,
vertikalen Abständen, etc.) . Definieren Sie dazu ein Paket von dieser Funktion;
weil entweder \etoc (vorübergehend vielleicht) im Kompatibilitätsmodus ohne
Anpassung auf seinen Teil möglich ist oder der Benutzer hat das Layout in
\csa{etocsetstyle}"=Befehlen angegeben (und \csa{etocsettocstyle}) ist (angeblich
\ldots ) in der kompletten Steuerung.

Nun, es ist eigentlich eine Alternative. Es ist möglich, die Verwendung der
\csa{etocsetstyle}"=Befehle zu nutzen, um einen künstlichen Kompatibilitätsmodus
neu zu erstellen, um Effekte zu erreichen, wie die folgenden, alle Dinge
gleichen andererseits dem Dokumentenklassen"=Standard:
\begin{enumerate}[noitemsep]
\item Enthält der |hyperref|-Link nur die Namen, aber nicht die Anzahl der
  jeweils zu kapselnden Einträge der Inhaltstabellen;
\item verwenden Sie den Dokumentenklassen"=Stil für Kapitel und Abschnitte, aber
  ändern Sie es nur für Teilbereiche;
\end{enumerate}

Hier ist beschrieben, wie Sie vorgehen müssen. Man nimmt in die Präambel:
\begin{verbatim}
\makeatletter
\newcommand{\MyStandardTOC}{%
  \begingroup
  \let\savedpartline\l@part
  \let\savedchapterline\l@chapter  %% remove if article/scrartcl class
  \let\savedsectionline\l@section
  \let\savedsubsectionline\l@subsection 
  % and so on if \subsubsection, etc... is used
  % 
  % for the book or article classes:
  \etocsetstyle{part}{}{}
    {\savedpartline{\etocnumber\hspace{1em}\etocname}{\etocpage}}{}%
  % for the scrbook or scrartcl classes:
  \etocsetstyle{part}{}{}
    {\savedpartline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
  % identical in book/article/scrbook/scrartcl classes:
  \etocsetstyle{chapter}{}{}   %%% only for book and scrbook
    {\savedchapterline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
  \etocsetstyle{section}{}{} 
    {\savedsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
  \etocsetstyle{subsection}{}{}
    {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
  % etc... if further sectioning units are used
  % (see the text for what to do with the memoir class)
  \etocstandarddisplaystyle % this is for the title, page-marks, etc...
  \tableofcontents     
  \endgroup}
\makeatother
\end{verbatim}
Natürlich ist es so, wenn das Dokument nur ein Inhaltsverzeichnis hat, dann gibt
es keine Notwendigkeit, die Befehle in ein Makro zu setzen oder sogar in eine
Gruppe. \footnote{Und wenn darüber hinaus, um das gleiche Layout wie im Standard
zu halten, kann man sich die Frage stellen, warum man \etoc benutzt \ldots\ Es
gibt \emph{einen} guten Grund: Zahlen und Namen sind separate
\texttt{hyperref}-Links, nach der Regel gibt es nur eine Verbindung, die sowohl
die Nummer und den Namen auf einem toc"=Eintrag entsprechen.} Mit dem Befehl
\etoc ist ein Inhaltsverzeichnis völlig identisch zu einem von der
Dokumentenklasse: |article|, |book|, |scrartcl|, |scrbook|. \footnote{Für die
|memoir|-Klasse braucht man ein bisschen mehr: Jeder der Befehle
\csa{booknumberline}, 
\csa{partnumberline} und \csa{chapternumberline} müssen in ein
\csa{let} gebettet werden und sie ergeben dann ein:
\centeredline{%
\csa{etocsetstyle\{chapter\}\{\}\{\}\{\string\savedchapterline\{%
\string\savedchapternumberline}}
\hbox to \linewidth{\hfil\hfil \ttfamily 
        \{\csa{etocnumber}\}\csa{etocname}\}\{\csa{etocpage}\}\}\{\}\hfil} 
(und analog für |part| und |book|).}
Die Anzahl und die Namen der einzelnen Einträge sind jeweils separat in einem
|hyperref|-Link, wie es immer der Fall bei \etoc ist, wenn man nicht im
Kompatibilitätsmodus ist. Ersetzt man \csa{etocnumber} mit \csa{etocthenumber},
dann ergibt es ein Inhaltsverzeichnis, wo die Zahlen nicht mehr verlinkt sind,
aber die Namen noch. Oder man kann sich entscheiden, \csa{etocthename} zu
verwenden und eine Hyperlink"=Nummer mit \csa{etocnumber} zu erhalten.

Hier ist ein subtiles Beispiel, wo nur geringfügig die "`sections"' modifiziert
wurden (hinzufügen von Farbe für die Nummer und das Entfernen des
|hyperref|-Links) und die Unterabschnitte, wie in der Standardeinstellung,
\emph{mit Ausnahme} von einer bestimmte "`section"' im Layout komplett geändert
wurde: \MyQuasiStandardTOC{\ref{toc:overview}} \bigskip Dieses Beispiel hat nur
Abschnitte und Unterabschnitte und der in \csa{MyStandardTOC} verwendete Code
war:
% corrected section number in verbatim code: 4 not 3 (2015/03/18)
\begin{verbatim}
\etocsetstyle{section}{}
  {\ifnum\etocthenumber=4
      \etocsetstyle{subsection}
        {\par\nopagebreak\begingroup
         \leftskip1.5em \rightskip\@tocrmarg \parfillskip\@flushglue 
         \parindent 0pt \normalfont\normalsize\rmfamily\itshape
         % \columnsep1em
         % \begin{minipage}{\dimexpr\linewidth-\leftskip-\rightskip\relax}%
         % \begin{multicols}{2}%
         \etocskipfirstprefix}
        {\allowbreak\,--\,}
        {\etocname\ \textup{(\etocnumber)}}
        {.\par\endgroup}%
        % {.\par\end{multicols}\end{minipage}\par\endgroup}%
    \else
      \etocsetstyle{subsection}
       {}{}
       {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}
       {}%
    \fi} 
  {\savedsectionline{\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}
  {}%
\end{verbatim}

Beachten Sie die Seite mit den Kopf"=Zeichen, welche man dem Inhaltsverzeichnis
hinzufügen kann. Abschnitte und Unterabschnitte sind genauso wie im Standard
(mit Ausnahme der Unterabschnitte, welche von einem bestimmten
Benutzer"=Abschnitt aus gewählt wird und bis auf die Farbe der
Abschnittsnummern), ohne das explizit die Länge, die Schriftart oder andere
Formatierungsanweisungen gegeben werden. Aber wir mussten die |scrartcl|-Quellen
untersuchen, um festzustellen, was zu nehmen ist für \csa{leftskip} und
\csa{rightskip} für unsere Nutzer-sections"=Einträge.

\section{Das TOC als ein Baum}\label{tocastree}

Mit |tikz|\footnote{\url{http://ctan.org/pkg/pgf}} und dem Paket
|forest|\footnote{\url{http://ctan.org/pkg/forest}} wird das Inhaltsverzeichnis
als Baum angezeigt. Die Technik ist, den von \etoc geänderten Befehl
\csa{tableofcontents} nicht für den Satz zu verwenden, sondern ein Makro, oder
besser hier eine \emph{symbolische Liste}-Variable vorzubereiten, mit allen
Anweisungen, die später ausgeführt werden. \textsc{Leslie Lamport}'s Buch
erwähnt überhaupt nicht die symbolische Liste und \LaTeX{} vermittelt den
Eindruck, nicht wirklich darauf zu warten, dass die Mehrheit der Nutzer immer
über sie (oder begrenzte Makros) etwas hört; die ganze Sache und der folgende
Abschnitt sind daher für fortgeschrittene Anwender.

Setzt man die \csa{etocnumber}- und \csa{etocname}"=Befehle in \csa{treetok},
dann würde das nichts nützen: Auf welche Zahl oder Namen würde sich das dann
beziehen, in einer verzögerten Ausführung?

Wir brauchen die Speicherung der Makro"=Namen, aber nicht die Makro"=Inhalte. Und
wir wollen auch die korrekten |hyperref|-Hyper"=Links erhalten.\footnote{Dieses
Handbuch bis zu der Version vom 14. Mai 2013 verwendete das Paket |tikz-qtree|,
aber es gab Probleme mit den Hyper"=Links. Kein solches Problem entsteht mit
|forest| oder mit der nativen Syntax |tikz| für Bäume (die im nächsten Abschnitt
dargestellt sind).} 

\textbf{UEBERSETZUNG NOETIG}
\begin{otherlanguage}{english}
  The commands \csa{etocname}, etc\dots, are robust, it is easier to work with
  \csa{etocthelinkednumber}, \csa{etocthelinkedname}, and
  \csa{etocthelinkedpage} which contain the same information in an easier
  accessible form.
\end{otherlanguage}
% ALT:
% Die Hyper-Link-Informationen von \etoc setzen innen
% \csa{etocname}, etc. \ldots, aber es ist nur ein Zeiger, nicht lagerungsfähig
% für die spätere Verwendung; aber das Paket bietet \csa{etocthelinkednumber},
% \csa{etocthelinkedname} und \csa{etocthelinkedpage}, deren Inhalte enthalten den
% Hyper-Link in einer Form, die gespeichert und später wiederverwendet werden
% können.

Aus diesem |forest|"=Baum haben wir ganz besondere \etoc"=Stile für Abschnitte und
Unterabschnitte konzipiert. Sie verwenden ein symbolisches Listenregister mit
dem Namen |\treetok| und ein Makro |\appendtotok|, deren Aufgabe es ist, zu
einer bestimmten symbolischen Listenvariablen den Inhalt eines Makros als
zweites Argument anzuhängen. All dies wird in Reaktion auf einen Befehl
|\tableofcontents| passieren, aber noch ist \emph{nichts} in deren
Prozess.\footnote{Es gibt immer ein \csa{par}, welches kein Problem ist, es kann
aber unterdrückt werden, wenn der Bedarf über den Befehl \csb{etocinline} oder
dessen Synonym \csb{etocnopar} besteht.} Das ist der spätere Job einer
|forest|-Umgebung, die den Inhalt von |\treetok| wiedergeben soll.
\newtoks\treetok
\newtoks\tmptok

% \newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
%   #1\expandafter\expandafter\expandafter
%     {\expandafter\the\expandafter #1#2}}


% 7 mars: j'utilise \etocthelinkedname défini à partir de 1.07f
% mais bien sûr je sais que ça ne marche pas (sauf dans l'arbre pour le lien de
% la section du bas) dans un QTree. Mais ça marche parfaitement dans un arbre
% TikZ natif.

% 9 septembre 2013: je remplace QTree par Forest, et il n'y a pas de problème
% avec les hyperliens, ça marche out of the box (une fois que j'ai appris un peu
% de sa syntaxe et de celle de TikZ).

\newcommand*\PrepareSectionNode{%
  \tmptok {\centering\bfseries}%
  \appendtotok\tmptok\etocthelinkedname
  \edef\foresttreenode{ [{\noexpand\parbox{2cm}{\the\tmptok}}}% 
}

% 7 mars: j'utilise maintenant \etocthelinkedname
\newcommand*{\PrepareSubsectionNode}{%
  \tmptok {\raggedright}%  j'ai essayé aussi avec \sloppy
  \appendtotok\tmptok\etocthelinkedname
  \edef\foresttreenode{ [{\noexpand\parbox{6cm}{\the\tmptok}}}%
}

\etocsetstyle{section}
  {\etocskipfirstprefix}
  {\appendtotok\treetok{ ]}}
  {\PrepareSectionNode \appendtotok\treetok\foresttreenode}
  {\appendtotok\treetok{ ]}}

\etocsetstyle{subsection}
  {\etocskipfirstprefix}
  {\appendtotok\treetok{ ]}}
  {\PrepareSubsectionNode \appendtotok\treetok\foresttreenode}
  {\appendtotok\treetok{ ]}}

\etocsettocstyle
    {\treetok{[{\hyperref[part:overview]{Überblick}}}}
    {\global\appendtotok\treetok{ ]}}


% 11 octobre
% forest ne veut pas @\the\treetok avec un \treetok vide, donc
% il faut lui donner une valeur par défaut.
\treetok{[{run latex again}]}

% 12 octobre
% pour que varioref fonctionne bien, je dois mettre la \tableofcontents
% au plus près de l'environnement forest

\begin{figure}[th!]\centering
 \etocsetnexttocdepth{subsection}
     \tableofcontents \label{toc:forest}\ref{toc:overview}
     \hypersetup{hidelinks}%
     \bracketset{action character=@}
     \begin{forest} 
                  for tree={anchor=center,child anchor=west,
                            grow'=east,draw,thick,
                            edge={draw,thick,dashed,color=teal}},
                  where={level()==1}{circle,thick,fill=blue!5,
                                    before computing xy={l=3cm}}{},
                  where={level()==2}{fill=red!5,
                                    before computing xy={l=6cm}}{},
                  % je trouve ce truc pour une position absolue. OK!
                  rectangle, thick, fill=cyan!5, inner sep=6pt,
     @\the\treetok 
     \end{forest}
     \centeredline{Ein Inhalsverzeichnis in Form eines |forest|"=Baums.}
\end{figure}

Der resultierende Baum wird in einem \hyperref[toc:forest]{Puffer} angelegt, welcher
\vpageref[oben]{toc:forest} erscheint. Hier ist der zur Herstellung notwendige Code:
\begin{verbatim}
\newtoks\treetok
\newtoks\tmptok

\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
  #1\expandafter\expandafter\expandafter
    {\expandafter\the\expandafter #1#2}}

\newcommand*\PrepareSectionNode{%
  \tmptok {\centering\bfseries}%
  \appendtotok\tmptok\etocthelinkedname
  \edef\foresttreenode{ [{\noexpand\parbox{2cm}{\the\tmptok}}}% 
}

\newcommand*{\PrepareSubsectionNode}{%
  \tmptok {\raggedright}%
  \appendtotok\tmptok\etocthelinkedname
  \edef\foresttreenode{ [{\noexpand\parbox{6cm}{\the\tmptok}}}%
}

\etocsetstyle{section}
  {\etocskipfirstprefix}
  {\appendtotok\treetok{ ]}}
  {\PrepareSectionNode \appendtotok\treetok\foresttreenode}
  {\appendtotok\treetok{ ]}}

\etocsetstyle{subsection}
  {\etocskipfirstprefix}
  {\appendtotok\treetok{ ]}}
  {\PrepareSubsectionNode \appendtotok\treetok\foresttreenode}
  {\appendtotok\treetok{ ]}}

\etocsettocstyle
    {\treetok{[{\hyperref[part:overview]{Überblick}}}}
    {\global\appendtotok\treetok{ ]}}

% forest does not like @\the\treetok if \treetok is empty. On first latex
% run, this will be the case because the TOC style defined above will not
% have been executed, as the label {toc:overview} does not refer to a valid 
% TOC yet. So we must give a safe default value to \treetok
\treetok{[{run latex again}]}

\begin{figure}[th!]\centering
     \etocsetnexttocdepth{subsection}
     \tableofcontents \label{toc:forest}\ref{toc:overview}
     \hypersetup{hidelinks}%
     \bracketset{action character=@}
     \begin{forest} 
                  for tree={anchor=center,child anchor=west,
                            grow'=east,draw,thick,
                            edge={draw,thick,dashed,color=teal}},
                  where={level()==1}{circle,thick,fill=blue!5,
                                    before computing xy={l=3cm}}{},
                  where={level()==2}{fill=red!5,
                                    before computing xy={l=6cm}}{},
                  rectangle, thick, fill=cyan!5, inner sep=6pt,
     @\the\treetok 
     \end{forest}
\end{figure}
\end{verbatim}

Warum |\hypersetup{hidelinks}|? Wie in \autoref{ssec:hidelinks} erläutert ist,
werden die Links in Inhaltsverzeichnissen nicht eingefärbt, noch gerahmt, so
dass dieses Dokument den Befehl
|\hypersetup{hidelinks}|
hinzufügt. Aber immer werden die |\treetok|-Inhalte in die
|\hyperlink|-Ursprungsbefehle in |\etocthelinkedname| ausgepackt, etc. \ldots{}
Sie werden in der normalen Umgebung für Links (die in diesem Dokument zu
kolorieren sind) ausgeführt. Der \etoc -Code versucht zu erraten, was der
aktuelle "`Stil"' für Links ist (ein Begriff, der nicht wirklich von |hyperref|
vorausgesetzt zu sein scheint) und speichert es in |\etocthelinkedname|, etc.
\ldots, Ich entschied mich für die einfachere Lösung, es dem Benutzer zu
überlassen, ob er es neu erstellt, was auch immer für Bedingungen erwünscht
sind. So, hier ist es notwendig, das |\hypersetup{hidelinks}| in dem
|figure|-Umgebung neu zu erstellen.

Es gibt einige andere Beispiele in dieser Dokumentation, wobei
|\tableofcontents| verwendet wird, um Material zu haben für den späteren
Schriftsatz:
\begin{itemize}
\item Für das Drucken der Statistiken zu Beginn der einzelnen Abschnitte (siehe
  \autoref{ssec:statistics}) wurden unbeschädigte Boxen benutzt (das Problem der
  Darstellung der Links funktioniert nicht).
\item Zum Setzen des Inhaltsverzeichnisses als eine Tabelle mit der Methode von
  \autoref{ssec:tocastableold};
  auch dort werden wir |\hypersetup{hidelinks}| setzen, nachdem wir die Namen,
  Nummern und Seitennummern in einem symbolischen Listenregister gesetzt haben.
\item Und zwei weitere Baum"=Beispiele sind im nächsten Abschnitt.
\end{itemize}


\section{Das TOC als ein Molekül}\label{sec:molecule}

Es ist auch möglich, einen Inhaltsverzeichnisbaum nach der TikZ-Syntax für Bäume
zu konstruieren: Aber das ist eine kompliziertere Aufgabe für die \etoc
Linienstile, welche die Klammern in einer Art und Weise von \TeX{} behandeln.
(Sie brauchen für das Auffüllen der symbolischen Liste im Zusammenhang mit jedem
Schritt immer eine Balance, sonst müssen immer kompliziertere Tricks angewandt
werden.).

Die einfachste Strategie ist es, eine symbolische Liste zuzuweisen (oder Sie
verwenden ein Makro) für jede Ebene: Wir brauchen ein \csa{parttok}, ein
\csa{chaptertok}, ein \csa{sectiontok} und ein \csa{subsectiontok}, um in der
Aufgabe die \csa{treetok} zu befüllen. Wir interessieren uns hier für die
Tabelle der Inhalte von diesem (oder einem anderen) Dokumententeil, nur ein
\csa{sectiontok} und ein \csa{subsectiontok} wird dafür gebraucht.

\begin{verbatim}
% \newtoks\treetok % already done earlier
\newtoks\sectiontok \newtoks\subsectiontok \newcommand*{\treenode}{}

\newcommand*{\appendchildtree}[2]{% token list t1 becomes: t1 child {t2}
   \edef\tmp{\the#1 child {\the#2}}%
   #1\expandafter{\tmp}%
}
\newcommand*{\preparetreenode}{%
  \tmptok\expandafter{\etocthelinkednumber}% expanded one time (mandatory)
  \edef\treenode{node {\the\tmptok}}%
}

\etocsetstyle{section}
  {\etocskipfirstprefix}
  {\appendchildtree\treetok\sectiontok}
  {\preparetreenode \sectiontok\expandafter{\treenode}}
  {\appendchildtree\treetok\sectiontok}

\etocsetstyle{subsection}
  {\etocskipfirstprefix}
  {\appendchildtree\sectiontok\subsectiontok}
  {\preparetreenode \subsectiontok\expandafter{\treenode}}
  {\appendchildtree\sectiontok\subsectiontok}

\etocsettocstyle
  {\treetok{\node {\hyperref[part:overview]{Overview}}}}
  {\global\appendtotok\treetok{ ;}}

% moved to the inside of the figure environment for correct \pageref{toc:molecule}
% \etocsetnexttocdepth{subsection}
% \tableofcontents \label{toc:molecule} \ref{toc:overview}
\end{verbatim}

\newtoks\sectiontok
\newtoks\subsectiontok
\newcommand*\treenode {}

\newcommand*{\appendchildtree}[2]{% token list t1 becomes: t1 child {t2}
   \edef\tmp{\the#1 child {\the#2}}%
   #1\expandafter{\tmp}%
}

\newcommand*{\preparetreenode}{%
  \tmptok\expandafter{\etocthelinkednumber}%
  \edef\treenode{node {\the\tmptok}}%
}

\etocsetstyle{section}
  {\etocskipfirstprefix}
  {\appendchildtree\treetok\sectiontok}
  {\preparetreenode
   \sectiontok\expandafter{\treenode}}
  {\appendchildtree\treetok\sectiontok}

\etocsetstyle{subsection}
  {\etocskipfirstprefix}
  {\appendchildtree\sectiontok\subsectiontok}
  {\preparetreenode
   \subsectiontok\expandafter{\treenode}}
  {\appendchildtree\sectiontok\subsectiontok}

\etocsettocstyle
  {\treetok{\node {\hyperref[part:overview]{Überblick}}}}
  {\global\appendtotok\treetok{ ;}}

\begin{figure}[th!]\centering
\etocsetnexttocdepth{subsection}
   \tableofcontents \label{toc:molecule}\ref{toc:overview}
   \hypersetup{hidelinks}%
   \begin{tikzpicture}
              [grow cyclic,
               level 1/.style={level distance=4cm,sibling angle=72},
               level 2/.style={level distance=2cm,sibling angle=60},
               every node/.style={ball color=red,circle,text=SkyBlue},
               edge from parent path={[dashed,very thick,color=cyan]
                           (\tikzparentnode) --(\tikzchildnode)}] 
     \the\treetok
   \end{tikzpicture}
   \centeredline{Ein Inhaltsverzeichnis als ein "`Molekül"'.}
\end{figure}

% Pour que \pageref fonctionne correctement, je dois mettre
% le \tableofcontents dans la figure. 

Der |\tableofcontents|"=Befehl erscheint direkt über der Umgebung in dem
|tikzpicture|-Umfeld und ist eine Gleitfigur (über Inhaltslabel sicherlich auf
die gleiche Seite zu beziehen, wie die in dem das Bild tatsächlich gedruckt
werden soll). Wir erhalten somit das Inhaltsverzeichnis als
"`\hyperref[toc:molecule]{Molekül}"', welches oben erscheint
\vpageref[above]{toc:molecule}. Hier ist der aktuelle, tatsächlich produzierte
Code:
\begin{verbatim}
\begin{figure}[th!]\centering
   \etocsetnexttocdepth{subsection}
   \tableofcontents \label{toc:molecule} \ref{toc:overview}
   \hypersetup{hidelinks}%
   \begin{tikzpicture}
              [grow cyclic,
               level 1/.style={level distance=4cm,sibling angle=72},
               level 2/.style={level distance=2cm,sibling angle=60},
               every node/.style={ball color=red,circle,text=SkyBlue},
               edge from parent path={[dashed,very thick,color=cyan]
                           (\tikzparentnode) --(\tikzchildnode)}] 
     \the\treetok
   \end{tikzpicture}
\end{figure}
\end{verbatim}

Dieses \hyperref[toc:molecule]{TikZ-TOC} ist komplett verlinkt, wie das
vorherige \hyperref[toc:forest]{Forest-TOC} auch.

\etocsettocstyle
  {\treetok{\node {\autoref{part:globalcmds}}}}
  {\global\appendtotok\treetok{ ;}}

\etocsetnexttocdepth {subsection}
\tableofcontents \ref{toc:globalcmds}

\noindent  
\parbox{4cm}{\hypersetup{hidelinks}%
    \begin{tikzpicture}
              [grow cyclic,
               level 1/.style={level distance=2.5cm,sibling angle=60},
               level 2/.style={level distance=1cm,sibling angle=45},
               every node/.style={ball color=red!50,circle,text=black},
               edge from parent path={[very thick,color=cyan]
                       (\tikzparentnode) --(\tikzchildnode)}] 
     \the\treetok
   \end{tikzpicture}}%
\begin{minipage}{\dimexpr\linewidth-4cm\relax}
  Seitlich ist das (völlig mit Hyper"=Links versehene) Inhaltsverzeichnis von
  \autoref{part:globalcmds}.
  \def\MacroFont{\ttfamily\small\hyphenchar\font-1 \baselineskip10pt\relax}%
\begin{verbatim}
\etocsettocstyle
  {\treetok{\node {\autoref{part:globalcmds}}}}
  {\global\appendtotok\treetok{ ;}}
\etocsetnexttocdepth {subsection}
\tableofcontents \ref{toc:globalcmds}
\noindent  
\parbox{4cm}{\hypersetup{hidelinks}%
   \begin{tikzpicture}
      [grow cyclic,
       level 1/.style={level distance=2.5cm,sibling angle=60},
       level 2/.style={level distance=1cm,sibling angle=45},
       every node/.style={ball color=red!50,circle,text=black},
       edge from parent path={[very thick,color=cyan]
               (\tikzparentnode) --(\tikzchildnode)}] 
     \the\treetok
   \end{tikzpicture}}%
...
\end{verbatim}
\end{minipage}

\section{Das TOC als ein TikZ Mind"=Map}
\label{sec:mindmap}

\textbf{UEBERSETZUNG NOETIG}

\begin{otherlanguage}{english}
This is in the same spirit as the ``molecule'' example. The use of the \eTeX{}
primitive \csa{unexpanded} will simplify the code.\footnote{The ``molecule''
example was added to this documentation on |2013/03/03|. The ``mindmap''
example was motivated on |2015/03/11| by
\url{http://tex.stackexchange.com/a/232584/4686}. Further help was then obtained via
\url{http://tex.stackexchange.com/q/232816/4686} and this led to the  
\hyperref[toc:mindmaptitlepage]{title page} which is a further example.}

\begingroup
%\newtoks\treetok
%\newtoks\parttok

\newcommand*\partnode {}  % just to check we don't overwrite something
%\newcommand*\childnode {}

\newcommand*\tmprotate {} % just to check we don't overwrite something
\newcommand*\tmpoption {} % just to check we don't overwrite something
\newcommand*\tmpstuff  {} % just to check we don't overwrite something

% \newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
%   #1\expandafter\expandafter\expandafter{\expandafter\the\expandafter #1#2}}

\renewcommand*{\appendchildtree}[3]{% 
% this is to construct "t1 child [branch color= #3]{t2}" from #1=t1 and #2=t2
% t1 and t2 are two toks variable (not macros)
% #3 = for example teal!60
   \edef\tmpstuff {\the#1 child [branch color = #3]{\the#2}}%
   #1\expandafter {\tmpstuff }%
}

% \newcounter{partco}

% 1,2,3,4,5,... -> 1,2,3,1,2,3,1,2,3
% \def\pseudomodthree #1{\numexpr #1 + 3 - 3*((#1+1)/3)\relax}

\etocsetstyle{part}
  {\etocskipfirstprefix}
% This updates the global tree with the data  from the previous
% part and all its children sections. Moved here because for some parts the
% sections are not displayed due to depth tags.
  {\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {teal!60}%   first
   \or \appendchildtree\treetok\parttok {yellow!80}% second
   \else\appendchildtree\treetok\parttok {green!50}% third and next ...
   \fi
   }
  {\stepcounter{partco}%
% customize manually  some TikZ set-up (should be done inside the TikZ thing I guess)
   \def\tmpoption {}%
   \def\tmprotate {}% first
   \ifnum\value{partco}=5 \def\tmprotate {[counterclockwise from =-40]}\fi
   \ifnum\value{partco}=8 \def\tmprotate {[counterclockwise from =-50]}\fi
% define the part node
   \edef\partnode{node \tmpoption 
                  {\unexpanded\expandafter{\etocthelinkednumber}. 
                   \unexpanded\expandafter{\etocthelinkedname}}\tmprotate }%
% this is a starting point which will be filled it by the section children
   \parttok\expandafter{\partnode}}
  {\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {teal!60}%   first
   \or \appendchildtree\treetok\parttok {yellow!80}% second
   \else\appendchildtree\treetok\parttok {green!50}% third and next ...
   \fi
   }

\etocsetstyle{section}
  {}
  {}
  {% define the section node
   \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber} 
                        \unexpanded\expandafter{\etocthelinkedname}}}}%
   % append it to the current \parttok
   \appendtotok\parttok\childnode
    }
  {}

\etocsettocstyle
  {\setcounter{partco}{0}%
   \treetok{\node [root concept]{\textbf{The \etoc documentation}}}}
  {\global\appendtotok\treetok{ ;}}
% The \global above is mandatory because etoc always typesets TOC inside a group

\etocsetnexttocdepth{section}
% use of depth tags to cut out some sections.
\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {section}
\etocsettagdepth {arbitrarily}{part}
\etocsettagdepth {surprising} {section}
\etocsettagdepth {linestyles} {part}
\etocsettagdepth {globalcmds} {section}
\etocsettagdepth {custom}     {section}
\etocsettagdepth {tips}       {section}
\etocsettagdepth {code}       {section}

\tikzset{
    branch color/.style={
        concept color=#1!white,
        every child/.append style={concept color=#1!white!30!white, font=\normalsize},
    }
}%

\begin{figure}[th!]
\tableofcontents\label{toc:mindmap}%
\centeredline{\resizebox{.85\paperwidth}{!}%
{\begin{tikzpicture}[mindmap,
                    grow cyclic, 
                    text width=2cm, 
                    align=flush center, 
                    nodes={concept}, 
                    concept color=orange!60,
                    root concept/.append style={text width=4cm, font=\Large},
                    level 1/.append style={level distance=5cm,sibling angle=45, text width=3cm},
                    level 2/.append style={level distance=8cm,sibling angle=25, text width=3cm},
                    level 1 concept/.append style={font=\normalsize},
                    ]
\the\treetok
\end{tikzpicture}}}
\end{figure}
\endgroup

It is difficult to get everything to fit on one page. However \csa{resizebox}
comes to the rescue. And it preserves hyperlinks. Nevertheless for this
example I excluded some sections from the display, using the technique of the
\etoc \hyperref[etocdepthtag.toc]{depth tags}. The fully hyperlinked TOC
appears \vpageref{toc:mindmap}.

\begin{verbatim}
\begingroup
\newtoks\treetok
\newtoks\parttok

\newcommand*\partnode {}  % just to check we don't overwrite something
\newcommand*\childnode {}

\newcommand*\tmprotate {} % just to check we don't overwrite something
\newcommand*\tmpoption {} % just to check we don't overwrite something
\newcommand*\tmpstuff  {} % just to check we don't overwrite something

\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
   #1\expandafter\expandafter\expandafter{\expandafter\the\expandafter #1#2}}

\renewcommand*{\appendchildtree}[3]{% 
% this is to construct "t1 child [branch color= #3]{t2}" from #1=t1 and #2=t2
% t1 and t2 are two toks variable (not macros)
% #3 = for example teal!60
   \edef\tmpstuff {\the#1 child [branch color = #3]{\the#2}}%
   #1\expandafter {\tmpstuff }%
}

\newcounter{partco}

% 1,2,3,4,5,... -> 1,2,3,1,2,3,1,2,3
\def\pseudomodthree #1{\numexpr #1 + 3 - 3*((#1+1)/3)\relax}

\etocsetstyle{part}
  {\etocskipfirstprefix}
% This updates the global tree with the data  from the previous
% part and all its children sections. Moved here because for some parts the
% sections are not displayed due to depth tags.
  {\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {teal!60}%   first
   \or \appendchildtree\treetok\parttok {yellow!80}% second
   \else\appendchildtree\treetok\parttok {green!50}% third and next ...
   \fi
   }
  {\stepcounter{partco}%
% customize manually  some TikZ set-up (should be done inside the TikZ thing I guess)
   \def\tmpoption {}%
   \def\tmprotate {}% first
   \ifnum\value{partco}=5 \def\tmprotate {[counterclockwise from =-40]}\fi
   \ifnum\value{partco}=8 \def\tmprotate {[counterclockwise from =-50]}\fi
% define the part node
   \edef\partnode{node \tmpoption 
                  {\unexpanded\expandafter{\etocthelinkednumber}. 
                   \unexpanded\expandafter{\etocthelinkedname}}\tmprotate }%
% this is a starting point which will be filled it by the section children
   \parttok\expandafter{\partnode}}
  {\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {teal!60}%   first
   \or \appendchildtree\treetok\parttok {yellow!80}% second
   \else\appendchildtree\treetok\parttok {green!50}% third and next ...
   \fi
   }

\etocsetstyle{section}
  {}
  {}
  {% define the section node
   \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber} 
                        \unexpanded\expandafter{\etocthelinkedname}}}}%
   % append it to the current \parttok
   \appendtotok\parttok\childnode
    }
  {}

\etocsettocstyle
  {\setcounter{partco}{0}%
   \treetok{\node [root concept]{\textbf{The \etoc documentation}}}}
  {\global\appendtotok\treetok{ ;}}
% The \global above is mandatory because etoc always typesets TOC inside a group

\etocsetnexttocdepth{section}
% use of depth tags to cut out some sections.
\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {section}
\etocsettagdepth {arbitrarily}{part}
\etocsettagdepth {surprising} {section}
\etocsettagdepth {linestyles} {part}
\etocsettagdepth {globalcmds} {section}
\etocsettagdepth {custom}     {section}
\etocsettagdepth {tips}       {section}
\etocsettagdepth {code}       {section}

\tikzset{
    branch color/.style={
        concept color=#1!white,
        every child/.append style={concept color=#1!white!30!white, font=\normalsize},
    }
}%

\begin{figure}[th!]
\tableofcontents\label{toc:mindmap}%
\centeredline{\resizebox{.85\paperwidth}{!}%
{\begin{tikzpicture}[mindmap,
                    grow cyclic, 
                    text width=2cm, 
                    align=flush center, 
                    nodes={concept}, 
                    concept color=orange!60,
                    root concept/.append style={text width=4cm, font=\Large},
                    level 1/.append style={level distance=5cm,sibling angle=45, text width=3cm},
                    level 2/.append style={level distance=8cm,sibling angle=25, text width=3cm},
                    level 1 concept/.append style={font=\normalsize},
                    ]
\the\treetok
\end{tikzpicture}}}
\end{figure}
\endgroup
\end{verbatim}

An interesting alternative is to use \etoc rather to convert the entire TOC
into a TikZ tree (perhaps excluding some parts) and print it out to a file
from which it can be recovered and manipulated directly by the author of the
document. Things written to the |.log| file get broken into lines. Here is a
technique to get non-broken output. Once the \csa{treetok} has been computed
by \etoc (as in the \hyperref[toc:molecule]{molecule} example, or the current
example), this code snippet will write it out to file with extension
|.toctree|:
\begin{verbatim}
  \newwrite\TOCasTree
  \immediate\openout\TOCasTree=\jobname.toctree
  \immediate\write\TOCasTree{\the\treetok}%
\end{verbatim}
The author can then copy it from there and customize it manually to get a
suitable tikz picture.

\end{otherlanguage}


\section{Das TOC als eine Tabelle}
\label{sec:tocastable}

\textbf{UEBERSETZUNG NOETIG}
\begin{otherlanguage}{english}
With release |1.08| it is easier to typeset a TOC as a table. It is
possible to open a tabular in the title part of the TOC (first argument
to \csb{etocsettocstyle}) and then close it after the contents (second
argument to \csb{etocsettocstyle}), and specify in the line styles how
to use the tabulation |&| and tabular end of row |\\|. There are some
conditions and a few caveats:

\begin{enumerate}
\item it is mandatory to issue \csb{etocglobaldefs} for \etoc's
  definitions to have global scope,
\item it is impossible to start one of the \meta{start}, \meta{prefix},
  \meta{contents} or \meta{finish} specification with a sole |\hline|,
  \emph{i.e.} one not preceded by a |\\| (it is however possible to put
  |\\| at the end of \meta{prefix} and the |\hline| at the start of
  \meta{contents}).
\item as is explained next, it is recommended to use the  |\\| at
  the start of the \meta{prefix} or \meta{contents}
  specifications to close the \emph{previous} row, not at the end
  to close the \emph{current} row; when the TOC is a partial one (a
  \csa{localtableofcontents}) this advice becomes (in almost all
  situations) mandatory.
\end{enumerate}

Here is an example of a TOC as a |longtable|, as is possible relatively
simply now with |1.08|. The code follows.
\end{otherlanguage}

\begingroup
\etocglobaldefs
\etocsetstyle{part}
  {}
  {\\\hline}
  {\strut\etocnumber &\bfseries\etocname 
                              &\etocpage }
  {}
\etocsetstyle{section}
  {}
  {\etociffirst{\etocifnumbered{\\\hline}{\\\hline\hline}}{\\}}
  {\etocnumber&\etocname &\etocpage }
  {}
\etocsetstyle{subsection}
  {}
  {\\}
  {&\makebox[1cm][c]{\etocnumber}%
    \parbox[t]{\dimexpr6cm-\tabcolsep\relax}
              {\sloppy\itshape\etocname\strut}%
   &\itshape\etocpage }
  {}
\etocsettocstyle
    {\hypersetup{hidelinks}%
     \begin{longtable}{|>{\bfseries}c|p{7cm}|r|}
     \hline
     \multicolumn{3}{|c|}{\Large\bfseries\strut\MakeUppercase{\contentsname}}%
     }
    {\\\hline\end{longtable}}
\etocsetnexttocdepth {subsection}
\tableofcontents
\endgroup

\begin{verbatim}
UEBERSETZUNG NOETIG
\begingroup
\etocglobaldefs % necessary for \etocname etc... to survive &

% observe the locations of the \\
\etocsetstyle{part}
  {}
  {\\\hline}
  {\strut\etocnumber &\bfseries\etocname 
                              &\etocpage }
  {}

\etocsetstyle{section}
  {}
  {\etociffirst{\etocifnumbered{\\\hline}{\\\hline\hline}}{\\}}
  {\etocnumber&\etocname &\etocpage }
  {}

\etocsetstyle{subsection}
  {}
  {\\}
  {&\makebox[1cm][c]{\etocnumber}%
    \parbox[t]{\dimexpr6cm-\tabcolsep\relax}
              {\sloppy\itshape\etocname\strut}%
   &\itshape\etocpage }
  {}

\etocsettocstyle
    {\hypersetup{hidelinks}%
     \begin{longtable}{|>{\bfseries}c|p{7cm}|r|}
     \hline
     \multicolumn{3}{|c|}{\Large\bfseries TABLE OF CONTENTS}%
     }
    {\\\hline\end{longtable}}

\etocsetnexttocdepth {subsection}

\tableofcontents
\endgroup
\end{verbatim}

\textbf{UEBERSETZUNG NOETIG}

\begin{otherlanguage}{english}
Examining the code above the reader will wonder why the |\\| are
always given first in \meta{prefix+contents} and not, as is more
intuitive, rather last. In many cases one may indeed construct
TOC-as-tables with the |\\| located at the end of the style
specifications (but almost never for a \csa{localtableofcontents}).
The problem in the previous example was with the positioning of the
|\hline|'s.

Due to technical aspects of how \TeX{} constructs alignments any
definition or assignment done after an |\\| starts a new row, and
thus makes |\hline| an illegal token (this shows as a |misplaced
\noalign| error.) Not only does \etoc have to do such definitions
to construct \csb{etocname} etc..., it is furthermore the case that
some packages put things in the |.toc| file and as a result there
is never any guarantee that between two \csa{contentsline} there
will not be such a token like |\relax| which in the contexts of
alignments forces \TeX{} to start a cell and thus makes it
impossible then to insert an |\hline|.

The safest way is to start with an |\\| each line style
specification. We had a little problem with the fact that we wanted
parts not only to have a rule above them (easy, they do |\\\hline|)
but also below them: after each part there is a section, thus the
section which are first of their kind used the \csb{etociffirst}
conditional branching. The attentive reader will notice one last
subtlety: the title was supposed to be followed not by one, but by
two |\hline|'s.

To solve this we could have used a one-time macro redefining itself, but
we noticed that the title was followed by the unnumbered Abstract, thus
the \csb{etocifnumbered} switch came to the rescue.

Last technical note: because we put the |\\| inside the branches, there
was no need to employ the expandable variants \csb{etocxiffirst} and
\csb{etocxifnumbered}.

For the hardliner's old way of obtaining the exact same result, see
\autoref{ssec:tocastableold}.

Here is also a much simpler example. It is a local table of
contents.
\end{otherlanguage}

\begin{center}
\etocsetstyle{section}
             {}
             {\etociffirst{\\\hline\hline}{\\\hline}}
             {\etocname& \etocnumber&\etocpage }
             {}

\etocsettocstyle
   {\hypersetup{hidelinks}\begin{tabular}{|p{4cm}|c|c|}\hline
    \multicolumn{1}{|c|}{\bfseries Abschnitt}&
    \bfseries Nummer&
    \bfseries Seite}
   {\\\hline\end{tabular}}

\etocglobaldefs % VERPFLICHTEND !!
\etocsetnexttocdepth{1}

\tableofcontents\ref{toc:overview}
\end{center}

\begin{verbatim}
\begin{center}
\etocsetstyle{section}
             {}
             {\etociffirst{\\\hline\hline}{\\\hline}}
             {\etocname & \etocnumber & \etocpage }
             {}

\etocsettocstyle
   {\hypersetup{hidelinks}\begin{tabular}{|p{4cm}|c|c|}\hline
    \multicolumn{1}{|c|}{\bfseries Abschnitt}&
    \bfseries Nummer&
    \bfseries Seite}
   {\\\hline\end{tabular}}

\etocglobaldefs % VERPFLICHTEND !!
\etocsetnexttocdepth{1}

\tableofcontents\ref{toc:overview}
\end{center}
\end{verbatim}

\subsection{Die Befehle \csbhyp{etocglobaldefs} und \csbhyp{etoclocaldefs}}
\label{etocglobaldefs}
\label{etoclocaldefs}

\textbf{UEBERSETZUNG NOETIG}

\begin{otherlanguage}{english}
In \LaTeX{} the meaning of a command defined via |\newcommand\foo{...}| inside
an environment (or group) vanishes from \TeX's memory on exit from this
environment (or group). At times however it is needed to make definitions with
global scope, for this \TeX{} has the primitive prefix |\global|.

By default \etoc's definitions of \csb{etocname} etc... are local. This causes
problems in certain contexts such as seen here with TOC as tables, but also
with |enumitem| \emph{inline} variants of its standard environments, because
the command |\item| then closes a group.

After \csb{etocglobaldefs}, \etoc will make its definitions of \csb{etocname}
etc... have global scope. For normal use this is not necessary. It does not hurt
either to activate it systematically. 

To return to the default, use \csb{etoclocaldefs}. Note that both
\csb{etocglobaldefs} and \csb{etoclocaldefs} actions are local to the
environment or group where they are used.
\end{otherlanguage}


\clearpage
\etocdepthtag.toc {linestyles}

\part{Befehle für die TOC"=Linienstile}
\label{part:linestyles}

\thispartstats

\etocsetstyle{section}
{\begin{enumerate}[leftmargin=.75cm, label=\etocifnumbered
      {{\fboxrule1pt\fcolorbox{green}{white}{\etocnumber}}}{}]}
% Dec 7, 2012. I hit upon a problem whose origin I found was
% with xcolor, as xcolor modifies \fbox
% (try \section{\fbox{A}} with and without xcolor). The fix
% was to \protect the \fbox used in the |enumitem| label.
% Strangely enough, with |hyperref| active, the problem did
% not show up. Anyhow I now use \fcolorbox rather than \fbox
% and there is no problem anymore. Also I don't have now to
% use \normalcolor which already needed protection.
{\normalsize\bfseries\rmfamily\item}
{\etocname{} (Seite \etocpage)}
{\end{enumerate}}

\etocsetstyle{subsection}
{\begin{enumerate}[leftmargin=0cm, label=\etocnumber]}
{\normalfont \item}
{\etocname{} (S.~\etocpage)}
{\end{enumerate}}

\etocsetstyle{subsubsection}
{\par\nobreak\begingroup\normalfont\footnotesize\itshape\etocskipfirstprefix}
{\allowbreak\,--\,}
{\etocname}
{.\hfil\par\endgroup\pagebreak[3]}

% 27 janvier 22:30
% je définis les macros (non protégées) 
% \etocthename, \etocthenumber, \etocthepage

\etocruledstyle[1]{\etocfontminusone\color{green}%
     \fboxrule1pt\fboxsep1ex
     \framebox[\linewidth]
              {\normalcolor\hss Inhalt von \autoref{part:linestyles}\hss}}

\localtableofcontents \label{toc:a}

\section{Der \csbhyp{etocsetstyle}"=Befehl}
\label{etocsetstyle}

\subsection{Die \csbhyp{etocname}- und \csbhyp{etocpage}"=Befehle}
\label{etocname}
\label{etocpage}

Hier soll erläutert werden, wie \etoc\ dazu verwendet wurde, das
Inhaltsverzeichnis am Beginn des zweiten Teils zu erstellen. Es handelt sich
dabei um ein lokales Inhaltsverzeichnis, weshalb der Befehl \localtoc\ verwendet
wurde.

Wir müssen hierbei unterscheiden zwischen den Linienstilen (\emph{line styles})
und dem Ausgabestil (\emph{toc display style}). Die \emph{line styles} erhält
man grundsätzlich auf die folgende Art und Weise:


\footnote{Das vorliegende Dokument hat
  {\ttfamily\string\renewcommand\string{%
     \string\familydefault\string}\string{\string\sfdefault\string}}
  in seiner Präambel, deshalb schaltet der Befehl \csa{normalfont} zur
  |sans| Schriftart; aus diesem Grund habe ich im Abschnitt line-style 
  \csa{rmfamily} geschrieben.}

\begingroup\small
\begin{verbatim}
\etocsetstyle{section}
{\begin{enumerate}}
{\normalsize\bfseries\rmfamily\item}
{\etocname{} (page \etocpage)}
{\end{enumerate}}

\etocsetstyle{subsection}
{\begin{enumerate}}
{\normalfont\item}
{\etocname{} (p.~\etocpage)}
{\end{enumerate}}

\etocsetstyle{subsubsection}
{\par\nobreak\begingroup\normalfont
        \footnotesize\itshape\etocskipfirstprefix}
{\allowbreak\,--\,}
{\etocname}
{.\hfil\par\endgroup\pagebreak[3]}
\end{verbatim}
\endgroup

Diese provisorischen Stil"=Definitionen beruhen auf der automatischen
Nummerierung, die von der |enumerate|-Umgebung generiert wird, es ist aber
wesentlich besser den Befehl \csb{etocnumber} innerhalb des Item-labels zu
verwenden, denn das gibt das richtige Ergebnis. Die verbesserten Definitionen
werden dahingehend später erklärt.

Mit diesem Stil müsste man so
einfallsreich sein, etwas zu designen, was nicht mit Abschnitten oder
Unterabschnitten zu tun hat, vielleicht so etwas wie Superscripte. Nun,
normalerweise braucht man Abschnitte und Unterabschnitte nicht nummeriert und
aufgelistet in der TOC, also hat unser vermeintlicher Benutzer ein Design
gewählt, welches dafür nichts bereitstellt und fügte noch hinzu:
\begin{verbatim}
\etocsetstyle{paragraph}{}{}{}{}
\etocsetstyle{subparagraph}{}{}{}{}
\end{verbatim}
Das ist der gleiche Sachverhalt wie mit den Standardlinienstilen!

Jeder \csb{etocsetstyle}"=Befehl hat fünf notwendige Argumente:\\ \hbox to
\linewidth {\hfil\csb{etocsetstyle}\color{blue}\marg{levelname}%
\marg{start}\marg{prefix}\marg{contents}\marg{finish}\hfil} Die
\meta{levelname}'s sind die Abschnittseinteilungen der
Standard"=Dokument"=Klassen: Von \emph{part} (oder \emph{book}, welches von der
|memoir|-Klasse benutzt wird) herunter bis zu \emph{subparagraph}.

Der \meta{start}-Code wird ausgeführt, wenn ein toc"=Eintrag dieses Levels
gefunden wurde und der vorherige ein höheres Level hatte. Der \meta{finish}-Code
wird ausgeführt, sobald man wieder einen Eintrag mit einem höheren toc"=Level
findet. In der Zwischenzeit werden alle Einträge für dieses Level gesetzt, indem
zuerst der \meta{prefix}-Code und dann der \meta{contents}-Code ausgeführt wird.

Die (robusten) Befehle \csb{etocname}, \csb{etocnumber} und \csb{etocpage} sind
für die Benutzung innerhalb der \meta{prefix} und \meta{contents}-Teile aus der
\csa{etocsetstyle}-Spezifikation. Diese enthalten den Namen, die Nummerierung
und die Seitennummer des entsprechenden toc"=Eintrags. Ist das Paket |hyperref|
im Dokument eingebunden, und es existieren Verlinkungen zu den TOC-Daten, dann
werden diese Links in den Befehlen \csa{etocname}, \csa{etocnumber} und
\csa{etocpage} gehalten (Der letzte hat nur einen Link, wenn |hyperref| die
Option \emph{linktoc=all} übergeben wurde).



\subsection{Die \csbhyp{etocskipfirstprefix} und \csbhyp{etociffirst} Befehle}
\label{etocskipfirstprefix}
\label{etociffirst}
\label{etocxiffirst}

% ALTES
% Der gewählte |subsubsection|-Stil benutzt außerdem den Befehl
% \csb{etocskipfirstprefix}, welcher -- falls verwendet -- der letzte im
% \emph{start}-Code sein \emph{muss}. Er sorgt dafür, dass der "`prefix"'-Code
% nicht für das erste Objekt ausgeführt wird.

\textbf{UEBERSETZUNG NOETIG}

\begin{otherlanguage}{english}
The chosen |subsubsection| style made use of the command
\csb{etocskipfirstprefix}, which instructs \etoc to \emph{not} use
for the first item the specified \meta{prefix} code.\footnote{With
versions earlier than |1.08| it had to be the very last token in
the \meta{start} code. It may now appear anywhere therein.}

The command \csb{etociffirst}\marg{YES CODE}\marg{NO CODE} (new
with |1.08|) is a more flexible way to customize the \meta{prefix}
(and \meta{contents}) specifications. It executes the \meta{YES
CODE} branch if this is the first unit at that level (inside a
lower level) and the \meta{NO CODE} if not. This is a robust
command which survives to expansion (for example in an |enumitem| label).

The variant \csb{etocxiffirst} does the same, but is expandable.
\end{otherlanguage}


\subsection{Der \csbhyp{etocnumber}"=Befehl}
\label{etocnumber}

Bis hierhin würde unsere Spezifikation die Nummerierung verwenden, die von der 
|enumerate|-Umgebung generiert wird, jedoch möchten wir natürlich die in 
der |.toc|-Datei deklarierten Nummern benutzen. Das kann man mit Hilfe des 
\csb{etocnumber}"=Befehls erreichen. Um die Bezeichnungen in die 
|enumerate|-Auflistung zu bekommen, fährt man mit der Syntax 
{\ttfamily label=\char32} des |enumitem|-Pakets fort:
\begin{verbatim}
\etocsetstyle{section}
{\begin{enumerate}[label=\etocnumber]}
{\normalsize\bfseries\rmfamily\item}
{\etocname{} (page \etocpage)}
{\end{enumerate}}
\end{verbatim}
Lieber als nur \csa{etocnumber} haben wir dann so etwas wie |\fbox{\etocnumber}|
benutzt. Dabei ist festzuhalten, dass \csa{etocnumber} ein robuster Befehl ist,
was erklärt, warum er in der Label"=Spezifikation benutzt werden kann, ohne
|\protect| hinzuzufügen.

\subsection{Der \csbhyp{etocifnumbered}-Schalter}
\label{etocifnumbered}
\label{etocxifnumbered}

Die \csa{fbox} würde ein unästhetisches Ergebnis bringen im Fall eines nicht
nummerierten Abschnitts (welches beispielsweise im Inhaltsverzeichnis gelandet
ist mittels eines \csa{addcontentsline} Befehls).\footnote{Wie man sieht, wird
\csa{fcolorbox} verwendet wird statt \csa{fbox}. Aufgrund einer Neudefinition --
durchgeführt vom |xcolor|-Paket-- haben wir \csa{fbox} verwendet (und nicht
|hyperref|), sonst hätten wir \csa{protect}\csa{fbox} benötigt.}

Der \csb{etocifnumbered}\marg{A}\marg{B}"=Befehl führt \meta{A} aus, wenn die
Nummer existiert, und \meta{B} falls nicht. Also benutzen wir es in dem Code,
welcher letztendlich für das |section|-Level gewählt wurde:
\begin{verbatim}
\etocsetstyle{section}
{\begin{enumerate}[leftmargin=.75cm, label=\etocifnumbered
      {{\fboxrule1pt\fcolorbox{green}{white}{\etocnumber}}}{}]}
{\normalsize\bfseries\rmfamily\item}
{\etocname{} (page \etocpage)}
{\end{enumerate}}

\etocsetstyle{subsection}
{\begin{enumerate}[leftmargin=0cm, label=\etocnumber]}
{\normalfont \item}
{\etocname{} (p.~\etocpage)}
{\end{enumerate}}
\end{verbatim}

Wenn wir nur das |section|-Level geändert hätten und nicht das
|subsection|-Level, dann wäre ein Kompilierfehler aufgetreten, denn der
Paket"=Stil für die "`subsections"' erwartet dann `im Vertikal"=Modus' zu starten.
Ein zusätzliches \csa{par}-Token im \meta{contents}-Teil des |section|-Levels
hätte das behoben: |{...(page \etocpage)\par}|.

\textbf{UEBERSETZUNG NOETIG}

\begin{otherlanguage}{english}
The command \csb{etocifnumbered} is robust;  \csb{etocxifnumbered}
(new with |1.08|) has the same effect but is expandable.
\end{otherlanguage}

\subsection{Die Befehle \csbhyp{etocthename}, \csbhyp{etocthenumber} sowie
\csbhyp{etocthepage}}
\label{etocthename}
\label{etocthenumber}
\label{etocthepage}

Es ist manchmal wünschenswert, Zugriff auf Name, Nummer und Seitenzahl zu haben,
ohne die hyperref"=Daten: Ähnlich wie die *-Variante des \csa{ref}"=Befehls, wenn
das |hyperref|-Paket verwendet wird. Beispielsweise könnte man den Wunsch haben,
eine Einheit oder Seitenzahl in einer Art numerischem Kontext verwenden zu
wollen oder seine Formatierung zu ändern. Diese Funktionalität wird von
\csb{etocthename}, \csb{etocthenumber} und \csb{etocthepage} bereitgestellt.

Diese Befehle sind aber nicht geschützt, also sollten sie in veränderlichen
Kontexten (zum Beispiel Label"=Beschreibungen mit vorangestelltem |\protect|)
verwendet werden.


\subsection{Der \csbhyp{etoclink}"=Befehl}
\label{etoclink}

Der Befehl \csb{etoclink}\marg{linkname} kann in Linienstil"=Beschreibungen
benutzt werden, in ähnlicher Art und Weise wie die argumentlosen Befehle
\csa{etocname}, \csa{etocnumber} und \csa{etocpage}. Er erzeugt einen Link
(falls solch ein von |hyperref| zur |.toc|-Datei hinzugefügt wurde), dessen Ziel
der entsprechende Dokumentteil ist und dessen Name das angegebene Argument ist.
Daher ist |\etoclink{\eotcthename}| das ursprüngliche |\etocname|. Es ist darauf
zu achten, dass wenn |hyperref| nicht damit beauftragt wurde, die Seitenzahl mit
einem Link zu versehen (mittels seiner Option \emph{linktoc=all}), dann hat
\etoc's \csa{etocpage} auch keinen Link, |\etoclink{\etocthepage}| allerdings
schon.

Der Befehl \csa{etoclink} ist robust. 

\subsection{Die Befehle \csbhyp{etocthelinkedname}, \csbhyp{etocthelinkednumber},
\csbhyp{etocthelinkedpage} und \csbhyp{etocthelink}}
\label{etocthelinkedname}
\label{etocthelinkednumber}
\label{etocthelinkedpage}
\label{etocthelink}

Das Folgende ist für fortgeschrittene Anwendungen von fortgeschrittenen
Benutzern. Das \csa{etocthename}-Makro wurde bereits schon einmal erwähnt;
verwendet man es in Anweisungen wie |\global\let\lastone\etocthename| in einem
\etoc line"=Stil, definiert das Macro |\lastone| so, dass es sich ausbreitet bis
zum letzten Namen auf dem korrespondieren Level. Jedoch bestand bisher keine
Möglichkeit, dass Gleiche auch für die Link"=Daten zu tun.

Das in diesem Paket enthaltene \csa{etocthelinkedname} stellt dies nun zur
Verfügung, inklusive der Link"=Daten. Es wurde in dieser Dokumentation benutzt
bei Erstellung der \hyperref[tocastree]{Beispiele mit Bäumen}.

Ebenfalls bereit gestellt mit ähnlichen Funktionen: \csa{etocthelinkednumber},
\csa{etocthelinkedpage} (welches nur einen Link enthält, wenn |hyperref| einen
zu dieser Seitenzahl hinzugefügt hat) und \csa{etocthelink}\marg{linkname},
welches es erlaubt einen Link mit einem beliebigen Name zu erstellen.

All diese Befehle sind \emph{nicht} robust.
\textbf{UEBERSETZUNG NOETIG}
\begin{otherlanguage}{english}
   In fact starting with |1.08a|, \csa{etocname}
is exactly the robust variant of \csa{etocthelinkedname}.
\end{otherlanguage}

Veralteter Beispiel\begingroup\
        \etocsetstyle {section}
          {\begin{itemize*}[itemjoin={{; }}, itemjoin*={{, und }}]}
          {\global\let\TmpEtocNumber\etocthelinkednumber
           \global\let\TmpEtocName\etocthelinkedname 
           \global\let\TmpEtocPage\etocthelinkedpage }
          {\item [{\bfseries\TmpEtocNumber.}]\TmpEtocName\ 
                 (\emph{S. \TmpEtocPage})}
          {\end{itemize*}.}%
    \etocsetnexttocdepth {section}%
    \etocsettocstyle {(ein Inhaltsverzeichnis als eine Inline-%
                       \texttt{enumitem}-Umgebung): }{}%
    \etocinline\tableofcontents \ref{toc:globalcmds}
\endgroup

\begin{verbatim}
Veralteter Beispiel\begingroup
        \etocsetstyle {section}
          {\begin{itemize*}[itemjoin={{; }}, itemjoin*={{, und }}]}
          {\global\let\TmpEtocNumber\etocthelinkednumber
           \global\let\TmpEtocName\etocthelinkedname 
           \global\let\TmpEtocPage\etocthelinkedpage }
% Obiges ist erforderlich, da \item, hier in itemize*, eine Gruppe schließt.
          {\item [{\bfseries\TmpEtocNumber.}]\TmpEtocName\ 
                 (\emph{S. \TmpEtocPage})}
          {\end{itemize*}.}%
    \etocsetnexttocdepth {section}%
    \etocsettocstyle {(ein Inhaltsverzeichnis als eine Inline-%
                       \texttt{enumitem}-Umgebung): }{}%
    \etocinline\tableofcontents \ref{toc:globalcmds}
\endgroup
\end{verbatim}

Mit \etoc |1.08| gibt es ein einfacher Weg zum gleichen Resultat:
\begin{verbatim}
Beispiel\begingroup\etocglobaldefs % <-- NEU mit etoc 1.08.
        \etocsetstyle {section}
          {\begin{itemize*}[itemjoin={{; }}, itemjoin*={{, und }}]}
          {}
          {\item [{\bfseries\etocnumber.}]
                 \etocname\ (\emph{S. \etocpage })}
          {\end{itemize*}.}%
    \etocsetnexttocdepth {section}%
    \etocsettocstyle {(ein Inhaltsverzeichnis als eine Inline-%
                       \texttt{enumitem}-Umgebung): }{}%
    \etocinline\tableofcontents \ref{toc:globalcmds}
\endgroup
\end{verbatim}
Beispiel\begingroup\etocglobaldefs % <-- NEU mit etoc 1.08.
        \etocsetstyle {section}
          {\begin{itemize*}[itemjoin={{; }}, itemjoin*={{, und }}]}
          {}
          {\item [{\bfseries\etocnumber.}]
                 \etocname\ (\emph{S. \etocpage })}
          {\end{itemize*}.}%
    \etocsetnexttocdepth {section}%
    \etocsettocstyle {(ein Inhaltsverzeichnis als eine Inline-%
                       \texttt{enumitem}-Umgebung): }{}%
    \etocinline\tableofcontents \ref{toc:globalcmds}
\endgroup

\section{Der \csbhyp{etocsetlevel}"=Befehl}
\label{etocsetlevel}

Wie bereits in \autoref{part:surprising} erklärt, kann man \etoc mitteilen,
welches Level er mit einem bestimmten Abschnitts"=Befehl assoziieren soll,
nämlich mit \csa{etocsetlevel}. Zum Beispiel:

\begin{verbatim}
\etocsetlevel{cell}{0}
\etocsetlevel{molecule}{1}
\etocsetlevel{atom}{2}
\etocsetlevel{nucleus}{3}
\end{verbatim}
Im Kompatibilitäts"=Modus wird davon ausgegangen, dass die Makros |\l@cell|,
\texttt{\textbackslash l@mo\-le\-cule}, \ldots\ entweder durch
den Benutzer oder von einer anderen Klasse definiert wurden: Nur |\etocsetlevel|
ist nicht genug, um auf dem korrespondierenden Pegel "`out-of-the-box"' zu
arbeiten.

Jedoch, ist im Kompatibilitätsmodus kein Inhaltsverzeichnis gesetzt, dann ist
nur wichtig, dass die verschiedenen Linienstile gesetzt sind. 
Wenn beispielsweise |section| auf Level |1| ist, dann muss man nicht mehr 
\csa{etocsetstyle}|{molecule}{..}{..}{..}{..}| nach 
\csa{etocsetstyle}|{molecule}{1}|  aufrufen, da 
\csa{etocsetstyle}|{section}{..}{..}{..}{..}| bereits 
wirksam ist (und es wurde im Paket selbst in der Definition seines
Linienstils gesetzt). 
 
Die akzeptierten Level laufen von |-2| bis einschließlich |6|. Alles andere wird
auf |6| abgebildet, welches ein Dummy"=Level ist und nie dargestellt wird. Das
Paket tut Folgendes:
\begin{verbatim}
\etocsetlevel{book}{-2}
\etocsetlevel{part}{-1}
\etocsetlevel{chapter}{0}
\etocsetlevel{section}{1}
\etocsetlevel{subsection}{2}
\etocsetlevel{subsubsection}{3}
\etocsetlevel{paragraph}{4}
\etocsetlevel{subparagraph}{5}
\end{verbatim}
Die benutzerdefinierten Stile von \etoc werden von \csa{etocdefaultlines}
aktiviert. Sie werden vom Haupt"=Inhaltsverzeichnis dieses Dokuments dargestellt.
Die Level"=Zuweisungen können jederzeit modifiziert werden: In
\autoref{part:surprising} sieht man verschiedene Anwendungen dieser Technik. 

Als ein weiteres Beispiel soll hier angeführt werden, wie das 
\hyperref[toc:main]{Haupt"=Inhaltsverzeichnis} dieses Dokuments gesetzt
wurde, nämlich mit den folgenden Instruktionen: 
\begin{verbatim}
\etocsettocdepth {subsubsection} % set the initial tocdepth
\etocdefaultlines % use the package default line styles. At this early stage in
                  % the document they had not yet been modified by \etocsetstyle
                  % commands, so \etoctoclines could have been used, too.
\etocmarkboth\contentsname
\etocmulticolstyle[1]                   % one-column display
    {\pdfbookmark[1]{Table of contents}{MAINTOC}% create a bookmark in the pdf
     \noindent\bfseries\Large
     \leaders\hrule height1pt\hfill
     \MakeUppercase{Table of Contents}}
\begingroup                             % use a group to limit the scope of the
  \etocsetlevel{subsection}{3}          %   subsection level change.
  \etocsetlevel{subsubsection}{4}       % anything > tocdepth=3.
  \tableofcontents \label{toc:main}
\endgroup
\end{verbatim}
Auf diese Art und Weise benutzen die "`subsections"' die Stile, die ursprünglich
für "`subsubsections"' vorgesehen waren, während diese gar nicht gedruckt
werden. Ohne diese Modifikation wäre das Erscheinungsbild ein anderes gewesen:
die Paketlinienstile sind dafür gedacht gewesen, in Dokumenten mit vielen vielen
"`subsubsections"' verarbeitet zu werden, in einem Zwei"=Spalten"=Layout, um
diesen ein kompakteres Ergebnis zu liefern als die
Standard-\LaTeX-Inhaltsverzeichnisse. Hier haben wir jedoch noch ein paar
"`subsubsections"', daher ist es interessanter, diese zu ignorieren und dafür
"`sections"` und "`subsections"' visuell unterschiedlich zu drucken.

\section{Umfang der zur \texorpdfstring{\texttt{.toc}}{.toc}-Datei gehörigen Befehle}

\begingroup % pour \small et \MacroFont en particulier.
\small

\subsection{Testen des Bereichs}

Lasst uns zur Farbe Rot wechseln und außerdem diesen Befehl zur
|.toc|-Datei hinzufügen: 

\color{red!50}
\addtocontents{toc}{\string\color{red!50}}

\def\MacroFont{\ttfamily \footnotesize\hyphenchar\font45 }
\begin{verbatim}
   \color{red!50}                             % Ändern der Textfarbe
   \addtocontents{toc}{\string\color{red!50}} % das Gleiche in der .toc-Datei
\end{verbatim}


\subsection{Dies ist eine (blass)rote Subsection zu Demonstrationszwecken}

Gut, der Titel hier wurde schwarz dargestellt, was daran liegt, wie die
|scrartcl|-Klasse funktioniert (in der |article|-Klasse wäre er rot gewesen),
aber wir sind ohnehin mehr daran interessiert, wie er im Inhaltsverzeichnis
aussieht: Und tatsächlich ist er rot im
\hyperref[toc:main]{Haupt"=Inhaltsverzeichnis} dieses Dokuments, genau so wie im
\hyperref[toc:a]{Inhaltsverzeichnis für diesen Abschnitt}. Beide Befehle
gehorchen wie erwartet dem |\color{red!50}|"=Befehl, der in die |.toc|-Datei
geschrieben wurde.

Aber lasst uns jetzt diese "`subsection"' beenden und eine "`section"' starten.

\section{Bin ich auch rot?}

Die Frage ist, ob es im Inhaltsverzeichnis erscheint: Die Antwort ist ja, es ist
rot im \hyperref[toc:main]{Haupt"=Inhaltsverzeichnis} und nein es ist nicht rot
im \hyperref[toc:a]{Inhaltsverzeichnis für diesen Abschnitt}. Grund dafür ist,
dass der \meta{finish}-Code für dieses "`subsection"'-Level eine Gruppe
geschlossen hat, da es |\end{enumerate}| verwendet hat.

Das zeigt noch einmal die Diskussion aus \autoref{ssec:limitations}.

Die standardmäßigen Paket-line"=Stile beinhalten keine Gruppen-Öffnung- und
Schliess"=Befehle: Die Gültigkeit eines Befehls in der |.toc|-Datei wird also
solange bestehen, bis er explizit durch einen weiteren Befehl wieder rückgängig
gemacht wird.

\begin{verbatim}
    \normalcolor
    \addtocontents{toc}{\string\normalcolor}
\end{verbatim}
\endgroup

\normalcolor
\addtocontents{toc}{\string\normalcolor}

Zurück zu Schwarz. Man beachte das diese Bereichsprobleme auch in mehrsprachigen
Dokumenten auftauchen, da das |babel|-Paket auftretende Sprachänderungen
ebenfalls in die |.toc|-Datei schreibt.


\clearpage
\etocdepthtag.toc {globalcmds}

\part{Befehle für den toc"=Display"=Stil}
\label{part:globalcmds}

\thispartstats

\etocsettocstyle{}{}
\etocstandardlines
\localtableofcontents \label{toc:globalcmds}


\section{Festlegung des toc"=Display"=Stils}


Der \emph{toc display}-Stil gibt an, ob das Inhaltsverzeichnis mit mehreren
Spalten erscheint oder nur mit einer, ob der Titel gesetzt ist wie in der
|article|- oder |book|-Klasse, oder ob er über den Einträgen zentriert sein
soll, mit Regeln an der Seite, oder ob das gesamte Inhaltsverzeichnis in einen
Rahmen gepackt werden soll. Entscheidet man sich bspw. für eine einheitliche
Überschrift und ein Ein"=Spalten"=Layout, so verwendet man dafür folgende Befehle:
\begin{verbatim}
\etocruledstyle[1]{Title} \tableofcontents    (or \localtableofcontents)
shortcuts:         \etocruled[1]{Title}  (or  \etoclocalruled[1]{Title})
\end{verbatim}

\subsection{Der Befehl \csbhyp{etocsettocstyle}}
\label{etocsettocstyle}

Dies ist ein Befehl mit zwei notwendigen Argumenten:
%
\centeredline{\csb{etocsettocstyle}\marg{before\_toc}\marg{after\_toc}}
%
Der \marg{before\_toc}-Teil ist verantwortlich für den Schriftsatz der
Überschriften, so kann er beispielsweise etwas sein wie
\starit{section}|{\contentsname}|.

Generell gesprochen, sollte diese Überschrift \TeX{} im "`Vertikal"=Modus"'
lassen, wenn der eigentliche Schriftsatz des Inhalts beginnt: die Linienstile
(entweder von den Standardklassen oder den Paketlinenstilen) erwarten alle im
`Vertikal"=Modus' zu starten.

Das erste Argument von \csb{etocsettocstyle} kann auch Instruktionen beinhalten,
um die Seitenüberschriften zu markieren. Oder es kann prüfen (|book|-Klasse), ob
der Zwei"=Spalten"=Modus eingeschaltet ist, um dann zum Ein"=Spalten"=Modus zu
wechseln. Der \meta{after\_toc}-Teil würde dann wieder den Ein"=Spalten"=Modus
aktivieren.

Die im Folgenden beschriebenen Befehle \csb{etocmulticolstyle},
\csb{etocruledstyle} und \csb{etocframedstyle} rufen alle \csa{etocsettocstyle}
als Subroutine auf, um eine \texttt{Mehr\-spalten}-Umgebung mit Hilfe von
\marg{before\_toc} zu starten, welche mit \marg{after\_toc} wieder geschlossen
wird.

\subsection{Die Befehle \csbhyp{etocmulticolstyle}, \csbhyp{etocmulticol} und 
\csbhyp{etoclocalmulticol}}
\label{etocmulticolstyle}
\label{etocmulticol}
\label{etoclocalmulticol}

Dies ist ein Befehl mit einem optionalen und einem notwendigen Argument:
%
\centeredline{\csb{etocmulticolstyle}\oarg{number\_of\_columns}\marg{heading}}
% 
Die
\oarg{number\_of\_coloumns} können von 1 bis 10 gehen (default: 2; ist der Wert
1, so wird natürlich keine |multicols|-Umgebung angelegt). Das \meta{heading}
wird typischerweise `vertikaler' Art sein, also wie: \meta{heading} =
|\section*|\marg{title}, aber man kann auch horizontale Dinge realisieren wie
|\fbox{Hallo Welt}| (\etoc fügt automatisch ein |\par| ans Ende des
"`heading"'-Arguments von \csb{etocmulticolstyle}). Hier ist einmal exemplarisch
dargestellt, wie das Haupt"=Inhaltsverzeichnis dieses Dokuments konfiguriert
wurde:
\begin{verbatim}
\etocmulticolstyle{\noindent\bfseries\Large
                   \leaders\hrule height1pt\hfill
                   \MakeUppercase{Table of Contents}}
\end{verbatim}
Nach \csa{etocmulticolstyle} haben alle zukünftigen \csa{tableofcontents} den
spezifizierten Stil, falls es zwischendurch nicht mehr geändert wird. Eine
kürzere Variante für nur ein Inhaltsverzeichnis ohne Einfluss auf spätere ist:
\centeredline{\csa{etocmulticol}\oarg{number\_of\_columns}\marg{heading}} oder
\centeredline{\csa{etoclocalmulticol}\oarg{number\_of\_columns}\marg{heading}.}

\subsubsection{Der Befehl \csbhyp{etoctocstyle}}
\label{etoctocstyle}

\centeredline{\csb{etoctocstyle}\oarg{kind}%
\marg{number\_of\_columns}\marg{title}}
\centeredline{=\csb{etocmulticolstyle}|[|{\itshape number\_of\_columns}|]|%
|{\kind*{|\itshape title\upshape|}}|}
Wobei |Typ| gewählt wird aus |chapter|, |section| usw. Standardwert ist
|chapter| oder |section|, abhängig von der Dokumentklasse.

\paragraph{\texorpdfstring{\csbhyp{etoc\-toc\-style\-with\-marks}}{etoctocstylewithmarks}}%
\leavevmode\unskip{\color{blue}\oarg{kind}\marg{number\_of\_columns}\marg{title}\marg{mark}}
\label{etoctocstylewithmarks}
\label{etoctocstylewithmarksnouc}

\centeredline
{=\csb{etocmulticolstyle}|[|{\itshape number\_of\_columns}|]|%
|{\kind*{|\itshape title \ttfamily\upshape\string\markboth%
|{\MakeUppercase{|{\rmfamily\itshape mark}|}}}}|} 
Wobei |Typ| gewählt wird aus |chapter|, |section| usw. Die wirkliche Anzeige der
Markierungen ("`marks"') hängt vom Seitenstil ab. Es gibt die Variante 
\csb{etoctocstylewithmarksnouc}, welche Großschreibung unterdrückt.

\paragraph{Möchten wir wirklich pargraph"=Einträge im Inhaltsverzeichnis?}

\paragraph{Wirklich?}

\subsection{Die Befehle \csbhyp{etocruledstyle}, \csbhyp{etocruled} und
 \csbhyp{etoclocal\-ruled}}
\label{etocruledstyle}
\label{etocruled}
\label{etoclocalruled}

Das generelle Format von \csa{etocruledstyle} ist:
\centeredline{\csb{etocruledstyle}%
              \oarg{number of columns}\marg{title of the toc}}
\noindent
Der Titel ist horizontales Material (der |LR|-Modus von \emph{\LaTeX{}, ein 
Dokument"=Vorbereitung"=System,}): wenn es nicht in eine Zeile passt, dann sollte
es in eine \csa{parbox} mit einer gegebenen Weite geschrieben werden. Der grüne
Rahmen für die Überschrift des Inhaltsverzeichnisses zu \hyperref[toc:a]{Beginn
des zweiten Teils dieses Dokuments} wurde erzeugt durch:
\begin{verbatim}
\etocruledstyle[1]{\etocfontminusone\color{green}%
     \fboxrule1pt\fboxsep1ex
     \framebox[\linewidth]
              {\normalcolor\hss Contents of this part\hss}}
\end{verbatim}

Eine kürzerer Weg den Stil zu setzen mit \csb{etocruledstyle} und dann einen 
\csa{tableofcontents} zu erstellen, alles zusammen in einer Gruppe damit
zukünftige Inhaltsverzeichnisse nicht betroffen sind, ist: 
\centeredline{\csb{etocruled}\oarg{number\_of\_columns}\marg{title}}

\subsection{Die Befehle \csbhyp{etocframedstyle},  \csbhyp{etocframed}
und \csbhyp{etoclocal\-framed}}
\label{etocframedstyle}
\label{etocframed}
\label{etoclocalframed}

Die gleiche Arbeitsweise: 
%
\centeredline{\csb{etocframedstyle}\oarg{number\_of\_columns}\marg{title}} 
und die passende Abkürzung:
%
\centeredline{\csb{etocframed}\oarg{number\_of\_columns}\marg{title}} 
Diese wird
verwendet, wenn man nicht den Stil zukünftiger Inhaltsverzeichnisse modifizieren
will (eine ändere Möglichkeit wäre es, das Ganze in Klammern zu packen oder
innerhalb eines |\begingroup...\endgroup|; es gibt auch noch einen
\csa{etoclocalframed} für ein lokales Inhaltsverzeichnis).

Das gesamte Inhaltsverzeichnis ist eingerahmt. Der Titel selbst aber nicht:
Möchte man das erreichen, dann muss man das im \meta{title}-Argument mit
\csa{etocframedstyle} oder \csa{etocframed} festhalten. Die Farben für den
Hintergrund und der anderen Komponenten (oben, links, rechts, unten) des Rahmens
sind festgelegt mittels geeigneter |\renewcommand|'s (siehe
\autoref{ssec:customdisplay}).

Eine |minipage| wird benutzt, von daher ist das produzierte Inhalsverzeichnis
nicht kompatibel mit Seitenumbrüchen. Um diese zu erlauben, wird empfohlen, die
Befehle
\href{http://ctan.org/pkg/mdframed}{mdframed}\footnote{\url{http://ctan.org/pkg/mdframed}}
oder
\href{http://ctan.org/pkg/tcolorbox}{tcolorbox}\footnote{\url{http://ctan.org/pkg/tcolorbox}}
in den Argumenten von \csb{etocsettocstyle} zu verwenden.

Beispiele in diesem Dokument findet man auf den Seiten \pageref{toc:d}, 
\pageref{toc:floating}, \pageref{toc:b} und \pageref{toc:clone}.

\subsection{Überschriften, Titel, \csbhyp{etocoldpar}, \csbhyp{etocinnertopsep}}
\label{etocinnertopsep}
\label{etocoldpar}

Das für \csb{etocmulticolstyle} notwendige \meta{heading}-Argument kann entweder
Vertikal"=Modus"=Material sein wie |\section*{\emph{Inhaltsverzeichnis}}| oder die
horizontale Variante wie das einfache |\etocmulticolstyle{Hallo Welt}|.

Es kann kein explizites |\par| oder eine Leerzeile in das notwendige Argument
von \csb{etocmulticolstyle} eingefügt werden, aber \etoc stellt \csb{etocoldpar}
als Ersatz bereit: Es fügt |\let\etocoldpar\par| vor der |multicols|-Umgebung
ein und eben dieses |\etocoldpar|\footnote{Dieser Befehl \csa{etocoldpar} (=
funktionierendes \csa{par} im Argument von \csa{etocmulticolstyle}) ist nicht
verwandt mit dem Schalter \csb{etocinline}, dessen Zweck es ist \etoc
mitzuteilen, kein \csa{par} vor dem Inhaltsverzeichnis auszuführen.} am Ende der
Überschrift ein, und macht dann noch einen vertikalen Sprung der Größe
\csa{etocinnertopsep}.

Auf der anderen Seite erwarten die Befehle \csb{etocruledstyle} und
\csb{etocframedstyle} ein Argument im "`LR-Modus"' (um die Terminologie von
\emph{\LaTeX, a document preparation system} zu nutzen). Das bedeutet, dass
mehrzeilige Titel nur möglich sind, wenn man sie in etwas wie eine \csa{parbox}
einschließt.

Eine wichtige Größe verwendet von sowohl \csb{etocmulticolstyle},
\csb{etocruledstyle} als auch \csb{etocframedstyle} ist \csb{etocinnertopsep}.
Es gibt an, wieviel Platz zwischen den Überschriften und dem Start des Inhalts
liegen soll. Der Default"=Wert ist |2ex| und man kann es mittels
|\renewcommand*{\etocinnertopsep}|\marg{neuer\_Wert} ändern, nicht mit
|\setlength|.

\subsection{Der Kompatibilitätsmodus \csbhyp{etocstandarddisplaystyle}}
\label{etocstandarddisplaystyle}

\etoc wird dann das emulieren, für was eigentlich die Dokument"=Klasse
verantwortlich ist, in Bezug auf den globalen Display"=Stil des
Inhaltsverzeichnisses. Allen Änderung von innerhalb der Klasse sollten
berücksichtigt werden.

\subsection{Der Befehl \csbhyp{etoc\-inline}}
\label{etocinline}
\label{etocnopar}
\label{etocdisplay}

Mit \csb{etocinline} oder seinem Synonym |\etocnopar|, von dem
|\tableofcontents|"=Befehl und seinen Varianten werden \emph{nicht} zuerst ein
|\par| erstellt, um den vorherigen |paragraph| zu schließen. Von daher kann man
das Inhaltsverzeichnis in einem Inline"=Stil darstellen; oder, wenn nur gebraucht
um eine Token"=Liste bzw. ein Makro vorzubereiten, wird es bei der Ausführung
nichts im Token"=Stream hinterlassen.

% JFBU:
Mit \csb{etocdisplay} werden (nochmal) von dem |\tableofcontents|"=Befehl und
seinen Varianten zuerst ein |\par| erstellt.

\section{Gesternde Varianten des \csbhyp{tableofcontents}  etc. Befehls}
\label{tableofcontents*}
\label{localtableofcontents*}
\label{etocbeforetitlehook}
\label{etocaftertitlehook}
\label{etocaftercontentshook}
\label{etocmemoirtoctotocfmt}

Die Befehle \toc, \localtoc, \csa{etocmulticol} und all ihre Cousins und
Varianten haben Stern"=Varianten (der Stern muss vor den anderen Argumenten
kommen). Für alle Klassen außer |memoir| verhalten diese sich wie die Originale.
Für |memoir| jedoch, schreibt das Original einen Eintrag in die |.toc|-Datei,
genau so wie die Verwendung des echten \toc Befehls in dieser Klasse, während
aber die Stern"=Variante genau das nicht tut, wie es in |memoir| die Regel ist.

Sobald man damit beginnt, lokale Inhaltsverzeichnisse zu benutzen merkt man,
dass der |memoir|-Standard, welcher dazu gedacht ist, einen |chapter|-Eintrag
für jedes Inhaltsverzeichnis zu erzeugen, nicht praktisch ist. Der Befehl
\csb{etocmemoirtoctotocfmt}\marg{Typ}\allowbreak\marg{name} ändert das Format
(\meta{Typ} ist wieder |chapter|, |section|, |subsection| etc. und \meta{name}
kann bspw. \csa{contentsname} sein.) Die Standardwerte für diese Größen sind
|chapter| und |\contentsname|.

Das Format der tatsächlichen Überschrift des Inhaltsverzeichnisses sollte
ebenfalls ordnungsgemäß gesetzt werden (z.\,B. mit \csa{etoctocstyle}), um
einfach die selbe Einheitsgröße zu nutzen wie im ersten Argument von
\csa{etocmemoirtoctotocfmt}.

Eine ungewöhnliche Situation tritt auf, wenn man zwei aufeinanderfolgende
\csa{localtableofcontents} hat (offensichtlich ist das eine nicht sehr
wahrscheinliche Situation), direkt nach einem \csa{part} zum Beispiel. Der erste
würde dann eine Kapitelüberschrift erzeugen (wenn der Standard nicht geändert
wurde, wie oben angedeutet), welche in die |.toc|-Datei geschrieben werden
würde. Das zweite Inhaltsverzeichnis denkt dann, es ist ein lokales zu diesem
Kapitel gehörig und würde aus diesem Grund nichts darstellen. Die Lösung für
dieses Problem ist es, das zweite als Klon des ersten zu definieren.

Unabhängig von der Situation hat man bei der |memoir|-Klasse immer ein
Hook"=Makro namens \csb{etocaftertitlehook}, welches man unterdrückt, indem man
die Stern"=Varianten der Darstellungsbefehle nutzt. Außer für die |memoir|-Klasse
ist dieser Hook dazu gedacht, überhaupt nichts zu tun. 

Außerdem gibt es noch \csb{etocaftercontentshook}, ähnlich definiert, um
nichts zu tun. Es gibt auch \csb{etocbeforetitlehook}: es ist definiert
um nichts zu tun. Beide können für einige spezielle Effekte genutzt
werden.


\section{Das In\-halts\-ver\-zeic\-hnis von die\-sem Teil}

\subsection{Über\-prü\-fen des Kom\-pa\-tibilitäts\-modus}

Als drittes Beispiel wollen wir nun das Inhaltsverzeichnis dieses Teils setzen.
Dazu wollen wir zuerst den Kompatibilitätsmodus testen.\footnote{Dieses
Dokument wurde als |scrartcl| gesetzt. Wir wollen nun testen, ob 
der Kompatibilitätsmodus des \etoc"=Pakets die Anpassungen innerhalb der
Klassenbefehle umsetzt.} Das ursprüngliche Inhaltsverzeichnis ist
unsichtbar und wurde am Anfang von \autoref{part:globalcmds} definiert,
wobei es mit einem Label versehen wurde. 
\begin{verbatim}
\KOMAoptions{toc=left}
\etocstandarddisplaystyle % wird benötigt, damit toc=left gilt
\etocstandardlines
\tableofcontents \ref{toc:globalcmds}
\end{verbatim}
\KOMAoptions{toc=left}
\etocstandarddisplaystyle
\etocstandardlines
\tableofcontents \ref{toc:globalcmds}

\subsection{Ein In\-halts\-ver\-zeich\-nis mit Rahmen}

Als nächstes wollen wir ein gerahmtes Inhaltsverzeichnis erzeugen, wobei wir den
vom Paket vorgegebenen Linienstil nutzen und ein paar Farben hinzufügen wollen.
(Es wurde in eine Float"=Umgebung eingefügt, die man \vpageref{toc:b}
findet.)\footnote{Innerhalb der |figure|-Umgebung und vor dem gerahmten
Inhaltsverzeichnis, welches die Option |multicols| nutzt, haben wir den Befehl
\csa{normalcolor} eingefügt, um einen Bug zu umgehen, der durch die Interaktion
zwischen |multicols|, |color| und der |figure|-Umgebung entsteht. (Wir brauchen
den Befehl \csa{color\{red\}} in der |.toc|-Datei.) Der Fehler wird nicht durch
das \etoc"=Paket verursacht.} 

\begin{verbatim}
\etocdefaultlines
\begingroup 
\renewcommand{\etoccolumnsep}{2em}
\renewcommand{\etocinnerleftsep}{1.5em}
\renewcommand{\etocinnerrightsep}{1.5em}
% Befehle für die Hintergrundfarbe des Inhaltsverzeichnisses
\renewcommand{\etocbkgcolorcmd}{\color{yellow!10}}
% Befehle für die Rechtecke vor und nach dem Inhalt des Verzeichnisses 
\renewcommand{\etoctoprule}{\hrule height 1pt}
\renewcommand{\etoctoprulecolorcmd}{\color{red!25}}
\renewcommand{\etocbottomrule}{\hrule height 1pt}
\renewcommand{\etocbottomrulecolorcmd}{\color{red!25}}
% Befehle für die Rechtecke links und rechts des Inhaltsverzeichnisses
\renewcommand{\etocleftrule}{\vrule width 5pt}
\renewcommand{\etocrightrule}{\vrule width 5pt}
\renewcommand{\etocleftrulecolorcmd}{\color{red!25}}
\renewcommand{\etocrightrulecolorcmd}{\color{red!25}}
% mit \fcolorbox legen wir einen farbigen Rahmen für den Titel an
\fboxrule1pt
\renewcommand{\etocbelowtocskip}{0pt\relax}
\etocframedstyle {\normalsize\rmfamily\itshape
  \fcolorbox{red}{white}{\parbox{.8\linewidth}{\centering
      Dies ist das nach \etoc gestaltete Inhaltsverzeichnis, welches 
      jedoch nur die Abschnitte und Unterabschnitte dieses Teils 
      enthält. Da es gerahmt ist, darf es nicht größer sein als eine Seite. 
      Es hat das Label |toc:b|.}}}
\begin{figure}[ht!]
  \centering
\normalcolor % Workaround für einen Bug von color und multicols (und figure)
\tableofcontents \label{toc:b} \ref{toc:globalcmds}
\end{figure}
\endgroup
\end{verbatim}


\etocdefaultlines
\begingroup 
\renewcommand{\etoccolumnsep}{2em}
\renewcommand{\etocinnerleftsep}{1.5em}
\renewcommand{\etocinnerrightsep}{1.5em}
% specify a background color for the toc contents
\renewcommand{\etocbkgcolorcmd}{\color{yellow!10}}
% set up the top and bottom rules 
\renewcommand{\etoctoprule}{\hrule height 1pt}
\renewcommand{\etoctoprulecolorcmd}{\color{red!25}}
\renewcommand{\etocbottomrule}{\hrule height 1pt}
\renewcommand{\etocbottomrulecolorcmd}{\color{red!25}}
% set up the left and right rules
\renewcommand{\etocleftrule}{\vrule width 5pt}
\renewcommand{\etocrightrule}{\vrule width 5pt}
\renewcommand{\etocleftrulecolorcmd}{\color{red!25}}
\renewcommand{\etocrightrulecolorcmd}{\color{red!25}}
% use \fcolorbox to set up a colored frame for the title
\fboxrule1pt
\renewcommand{\etocbelowtocskip}{-.5\baselineskip\relax}
\etocframedstyle {\normalsize\rmfamily\itshape
  \fcolorbox{red}{white}{\parbox{.8\linewidth}{\centering
      Dies ist das nach \etoc gestaltete Inhaltsverzeichnis, welches 
      jedoch nur die Abschnitte und Unterabschnitte dieses Teils 
      enthält. Da es gerahmt ist, darf es nicht größer sein als eine Seite. 
      Es hat das Label |toc:b|.}}}
\begin{figure}[ht!]
  \centering
\normalcolor % work-around to a bug involving color and multicols (and figure)
\tableofcontents \label{toc:b} \ref{toc:globalcmds}
\end{figure}
\endgroup

% Il y a un color leak du framed mais uniquement lorsqu'il est mis dans le
% float. 2013/10/13, qui révèle un bug (?? NON) du style framed je vais regarder
% mais bon. Le leak apparaît avec ruled aussi, et même avec juste multicolstyle
% MAIS PAS EN UNE SEULE COLONNE (même framed ou ruled). il semble qu'il y aie
% donc un problème d'interaction avec multicol là. à voir. Pas le temps
% maintenant.

% 2013/10/14
% il s'agit en fait d'un bug de color+multicols+figure qui n'a rien à voir avec
% etoc: 
% http://tex.stackexchange.com/questions/138783/color-leak-from-multicols-within-a-figure
% J'ai trouvé le work-around qui consiste simplement à ajouter un \normalcolor
% _avant_ le multicols à l'intérieur de figure

\subsection{Eine (verrückte) In\-line"=Dar\-stellung}

Nun wollen wir eine etwas verrückte Inline"=Darstellung erzeugen, womit das
Inhaltsverzeichnis des gesamten Dokuments gesetzt werden soll. Hier werden die
Unterabschnitte als Fußnoten dargestellt. Diese Art der Darstellung bietet sich
eher für verlinkte Dokumente an, weniger für gedruckte! (Mir hingegen gefällt
diese Art der Darstellung, obwohl mein Geschmack scheinbar oft nicht geteilt
wird.)

%%%% Note: 27 april 2014 

%%%% except for a miraculous situation depending from the quantity of previous
%%%% material this TOC will have links extending accross pagebreaks, which
%%%% dvipdfmx does not know how to handle completely. Apart from that the output
%%%% is ok, thus no need to try seriously to avoid them. 

\begingroup
\newsavebox{\forsubsections}
\etocsetstyle{part}{\upshape. \etocskipfirstprefix}{. \upshape}{\bfseries\etocname:~~}{}
\etocsetstyle{section}{\itshape\etocskipfirstprefix}{, }{\mdseries\etocname}{}
\etocsetstyle{subsection}
   {\begin{lrbox}{\forsubsections}\upshape\etocskipfirstprefix}
   {; }
   {\etocname}
   {\end{lrbox}\footnote{\unhbox\forsubsections.}}
\etocsetstyle{subsubsection}{ (\itshape\etocskipfirstprefix}
  {, }{\etocname}{\/\upshape)}
\etocsettocstyle{Hier ist das inline dargestellte Inhaltsverzeichnis. }{.\par}
\tableofcontents \label{toc:crazyinline}
\endgroup

Zur Erzeugung dieses Inhaltsverzeichnisses wurde folgender Code genutzt:
\begin{verbatim}
\begingroup
\newsavebox{\forsubsections}
\etocsetstyle{part}{\upshape. \etocskipfirstprefix}{. \upshape}
                      {\bfseries\etocname:~~}{}
\etocsetstyle{section}{\itshape\etocskipfirstprefix}{, }
                      {\mdseries\etocname}{}
\etocsetstyle{subsection}
   {\begin{lrbox}{\forsubsections}\upshape\etocskipfirstprefix}
   {; }{\etocname}{\end{lrbox}\footnote{\unhbox\forsubsections.}}
\etocsetstyle{subsubsection}
  { (\itshape\etocskipfirstprefix}{, }{\etocname}{\/\upshape)}
\etocsettocstyle{Hier ist das inline dargestellte Inhaltsverzeichnis. }{.\par}
\tableofcontents
\endgroup
\end{verbatim}


\clearpage
\etocdepthtag.toc {custom}

\part{\etoc nutzen und an\-passen}
\label{part:custom}
\thispartstats

\etocdefaultlines
\renewcommand{\etoctoprule}{\hrule height2pt depth0pt}
\renewcommand{\etoctoprulecolorcmd}{\color{red}}

\etocruledstyle{\normalfont\normalsize\rmfamily\fboxrule1pt\color{red}%
  \fbox{\parbox{.8\linewidth}{\centering\normalcolor Dies ist das
      Inhaltsverzeichnis mit den Abschnitten und Unterabschnitten von
      diesem Teil. Es hat das Label |toc:c|.}}}  

\localtableofcontents \label{toc:c}

\section{Über\-blick über die Grund\-befehle zur Stil\-bearbeitung}

\subsection{Ein lokales Inhalts\-ver\-zeich\-nis an\-passen}
\hbox{\color{green}\fboxrule1pt\fboxsep1em
\setbox0\hbox{\csa{etocthename}, \csa{etocthenumber}, \csa{etocthepage}, \csa{etoclink}\marg{Name des Links}}%
\framebox[\linewidth][c]
{\vbox{\hsize\wd0\normalcolor\noindent
\csa{etocsetstyle}\marg{Name der Ebene}%
  \marg{Start}\marg{Präfix}\marg{Inhalt}\marg{Abschluss}\\
\csa{etocname}, \csa{etocnumber}, \csa{etocpage},
\csa{etocifnumbered}\marg{A}\marg{B}\\
\csa{etocthename}, \csa{etocthenumber}, \csa{etocthepage}, \csa{etoclink}\marg{Name des Links}
}}}

\subsection{Das Aus\-sehen eines Inhalts\-ver\-zeichnisses an\-passen}
\medskip
\hbox{\color{green}\fboxrule1pt\fboxsep 1em
\setbox0\hbox{\csa{etoctocstylewithmarksnouc}\oarg{Ebene}%
\marg{Anzahl der Spalten}\marg{Titel}\marg{Symbol}}%
\framebox[\linewidth][c]
{\vbox{\hsize\wd0
\normalcolor\noindent
\csa{etocmulticolstyle}\oarg{Anzahl der Spalten}\marg{Überschrift}\\
\csa{etoctocstyle}\oarg{Ebene}\marg{Anzahl der Spalten}\marg{Titel}\\
\csa{etoctocstylewithmarks}\oarg{Ebene}\marg{Anzahl der Spalten}%
\marg{Titel}\marg{Symbol}\\
\csa{etoctocstylewithmarksnouc}\oarg{Ebene}\marg{Anzahl der Spalten}%
\marg{Titel}\marg{Symbol}\\
\csa{etocruledstyle}\oarg{Anzahl der Spalten}\marg{Titel}\\
\csa{etocframedstyle}\oarg{Anzahl der Spalten}\marg{Titel}\\
\csa{etocsettocstyle}\marg{vor dem Inhaltsverzeichnis}\marg{nach dem Inhaltsverzeichnis}}}}

\subsection{In\-halts\-ver\-zeich\-nisse dar\-stellen}
\medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em
  \setbox0\hbox{\csa{etocname}, \csa{etocnumber},
    \csa{etocpage}, \csa{etocifnumbered}\marg{A}\marg{B}}%
  \framebox[\linewidth][c]
  {\vbox{\hsize\wd0\normalcolor\noindent
      \toc\\
      \localtoc\\
      \csa{etocmulticol}\oarg{Anzahl der Spalten}\marg{Überschrift}\\
      \csa{etoclocalmulticol}\oarg{Anzahl der Spalten}\marg{Überschrift}\\
      \csa{etocruled}\oarg{Anzahl der Spalten}\marg{Titel}\\
      \csa{etoclocalruled}\oarg{Anzahl der Spalten}\marg{Titel}\\
      \csa{etocframed}\oarg{Anzahl der Spalten}\marg{Titel}\\
      \csa{etoclocalframed}\oarg{Anzahl der Spalten}\marg{Titel}\\
      \hbox{}{\itshape\ttfamily\ \ \ \  und die mit Sternchen versehenen Varianten}
   }}}

\subsection{Label und Referenzen}

Optional dürfen die Befehle für Label oder Referenzen auf die Befehle, die die
Darstellung des Inhaltsverzeichnisses realisieren, folgen. Hierbei ist
unwichtig, ob letztere mit Sternchen versehen sind oder nicht.\par

\medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em
  \setbox0\hbox{\csa{etocname}, \csa{etocnumber},
    \csa{etocpage}, \csa{etocifnumbered}\marg{A}\marg{B}}%
  \framebox[\linewidth][c]
  {\vbox{\hsize\wd0\normalcolor\noindent
      \toc \csa{label}|\{toc:here\}|\\ 
      \toc \csa{ref}|\{toc:far\}| \\
      \toc \csa{label}|\{toc:here\}| \csa{ref}|\{toc:far\}| \\
      \localtoc \csa{label}|\{toc:here\}|\\
      \hbox{}{\itshape\ttfamily\ \ \ \  \ }%
      \csa{etocmulticol}{\itshape\ttfamily, etc. funktionieren ähnlich}
   }}}


\medskip Ein \csa{ref}"=Befehl, der auf einen Befehl zur Erzeugung eines lokalen
Inhaltsverzeichnisses folgt, hat \emph{keinen} Einfluss auf diesen. Wird ein
anderes Inhaltsverzeichnis erneut dargestellt, so wird nur dessen Inhalt
angepasst. Sowohl das Aussehen des Inhaltsverzeichnisses als auch die
Darstellung seiner Linien orientieren sich an dem, das gerade definiert wurde
und nicht an dem, von dem der Inhalt übernommen wurde.

\section{Der Linien\-standard des Pakets: \csbhyp{etoc\-defaultlines}}
\label{etocdefaultlines}

Die Linienstile stammen bereits aus einer frühen Entwicklungsphase des Pakets,
weswegen sie sich noch sehr an \TeX{} orientieren und dadurch gruselig aussehen.
Daher bieten sie keinen guten Einstiegspunkt. Oft muss man, will man an dem Stil
etwas ändern, diesen aus dem Quellcode kopieren und direkt bearbeiten. Trotzdem
soll in diesem Abschnitt erläutert werden, wie die Schriftarten, die vertikalen
Abstände, etc. des gewählten Linienstils verändert werden können.

Wurden die vorgegebenen Linienstile nicht durch \csa{etocsetstyle} verändert, so
kann man sie mit den Befehlen \csa{etocdefaultlines} bzw. \csa{etoctoclines}
einschalten. Außer, dass der Einzug eines Unterabschnitts etwas kleiner ist als
der eines Abschnitts, gleichen sich beide Gliederungsebenen. (Wie dieses
Dokument zeigt, werden Abschnitte in Dokumentklassen, denen der Befehl
\csa{chapter} fehlt, stets mit einer fettgedruckten Type gesetzt.)
Unter"=Unterabschnitte werden inline, im selben Paragraphen und ohne Nummer oder
Seitenzahl dargestellt. Dieser Stil wurde für Dokumente, die viele
Unter"=Unterabschnitte enthalten, entwickelt und anschließend mit solchen
getestet. Für derartige Dokumente sollte ein zweispaltiges Layout verwendet
werden, da diese Darstellung kompakter ist als jene, die standardmäßig durch
\LaTeX{} erzeugt wird.\footnote{Außerdem werden dadurch einzelne Teil- bzw.
  Kapiteleinträge am Ende einer Seite oder einer Spalte vermieden, solange diese
  weiter untergliedert sind.} Verwendet man hingegen ein einspaltiges Layout und
enthält der Teil nur wenige Unter"=Unterabschnitte, so wird das
Inhaltsverzeichnis im Vergleich zur mit \LaTeX{} gesetzten Variante etwas in die
Breite gezogen. Weiterhin wirkt diese Darstellung weniger hierarisch als der
\LaTeX{}-Standard, da sich die Darstellung von Abschnitten und Unterabschnitten
kaum unterscheidet. (Dies gilt besonders, wenn die Dokumentklasse den Befehl
\csa{chapter} erlaubt.)

Da wir für das \hyperref[toc:main]{zentrale Inhaltsverzeichnis}
|\etocsetlevel{subsection}{3}| gesetzt haben, werden die Unterabschnitte und die
Unter"=Unterabschnitte inline dargestellt.

Im Gegensatz dazu wollen wir nun das zentrale Inhaltsverzeichnis so darstellen,
als ob wir eine Dokumentklasse genutzt hätten, die den Befehl \csa{chapter}
erlaubt. Daher werden die Abschnitte im Folgenden als Kapitel und die
Unterabschnitte als Abschnitte gedruckt, was wir u. a. mit Hilfe des Befehls
\csa{etocsetlevel} erreichen. Zusätzlich nutzen wir für Abschnitte, welche in
Wirklichkeit unsere Unterabschnitte sind, statt der fetten Serie einer
Schriftart die halbfette Variante. Hierfür modifizieren wir den Befehl
\csa{etocfontone}. Weiterhin nutzen wir einen gepunkteten Einzug, da dieser
weniger Platz einnimmt als der Paketstandard.

\begin{verbatim}
\etocruledstyle[2]{\normalfont\normalsize\rmfamily\itshape
  \fbox{\parbox{.6\linewidth}{
      \leftskip 0pt plus .5fil
      \rightskip 0pt plus -.5fil
      \parfillskip 0pt plus 1fil 
  Dies  ist das zentrale zweispaltige Inhaltsverzeichnis, das den
  Standardlinienstil von \etoc nutzt, wobei die Abschnitte wie Kapitel und die
  Unterabschnitte wie Abschnitte gesetzt wurden. }}} 
\etocdefaultlines
\renewcommand{\etocpartname}{\partname}% UEBERSETZUNG NOETIG
% <1.08b had \partname by default but this does not work well with frenchb
% hence the default is now simply Part. Here we can use \partname or Teil.
\etocsetnexttocdepth{1}
\begingroup
\etocsetlevel{section}{0}
\etocsetlevel{subsection}{1}
\renewcommand*{\etocfontone}{\normalfont \normalsize}
\renewcommand*{\etoctoclineleaders}
        {\hbox{\normalfont\normalsize\hbox to 1ex {\hss.\hss}}}
\sloppy
\tableofcontents
\endgroup
\end{verbatim}

\etocruledstyle[2]{\normalfont\normalsize\rmfamily\itshape
  \fbox{\parbox{.6\linewidth}{
      \leftskip 0pt plus .5fil
      \rightskip 0pt plus -.5fil
      \parfillskip 0pt plus 1fil Dies ist das zentrale zweispaltige
      Inhaltsverzeichnis, das den Standardlinienstil von \etoc nutzt, wobei die
      Abschnitte wie Kapitel und die Unterabschnitte wie Abschnitte gesetzt
      wurden. }}}

\etocdefaultlines
\etocsetnexttocdepth{1}

\begingroup
\etocsetlevel{section}{0}
\etocsetlevel{subsection}{1}
\renewcommand*{\etocfontone}{\normalfont \normalsize}
\renewcommand*{\etoctoclineleaders}
        {\hbox{\normalfont\normalsize\hbox to 1ex {\hss.\hss}}}
\sloppy
\tableofcontents
\endgroup

\section{\etoc individuell an\-passen}

\subsection{Den durch \etoc vor\-de\-finierten Linien\-stil individualisieren}

Im Folgenden sollen einfach die wichtigsten Befehle des Pakets aufgelistet werden. Man kann diese
bequem mittels \csa{renewcommand} anpassen:
\begin{verbatim}
\newcommand*\etocfontminustwo{\normalfont \LARGE \bfseries}
\newcommand*\etocfontminusone{\normalfont \large \bfseries}
\newcommand*\etocfontzero{\normalfont \large \bfseries}
\newcommand*\etocfontone{\normalfont \normalsize \bfseries}
\newcommand*\etocfonttwo{\normalfont \normalsize}
\newcommand*\etocfontthree{\normalfont \footnotesize}

\newcommand*\etocsepminustwo{4ex plus .5ex minus .5ex}
\newcommand*\etocsepminusone{4ex plus .5ex minus .5ex}
\newcommand*\etocsepzero{2.5ex plus .4ex minus .4ex}
\newcommand*\etocsepone{1.5ex plus .3ex minus .3ex}
\newcommand*\etocseptwo{.5ex plus .1ex minus .1ex}
\newcommand*\etocsepthree{.25ex plus .05ex minus .05ex}

\newcommand*\etocminustwoleftmargin{1.5em plus 0.5fil}
\newcommand*\etocminustworightmargin{1.5em plus -0.5fil}
\newcommand*\etocminusoneleftmargin{1em}
\newcommand*\etocminusonerightmargin{1em}

\newcommand*\etocbaselinespreadminustwo{1}
\newcommand*\etocbaselinespreadminusone{1}
\newcommand*\etocbaselinespreadzero{1}
\newcommand*\etocbaselinespreadone{1}
\newcommand*\etocbaselinespreadtwo{1}
\newcommand*\etocbaselinespreadthree{.9}
\newcommand*\etoctoclineleaders
    {\hbox{\normalfont\normalsize\hbox to 2ex {\hss.\hss}}}
\newcommand*\etocabbrevpagename{p.~} % muss der Sprache angepasst werden
                 % deutsche Nutzer: \renewcommand*\etocabbrevpagename{S.~}
\newcommand*\etocpartname{Part}  % prior to v1.08b, was \partname
% but this didn't make sense e.g. with babel+frenchb whose \frenchpartname
% takes into account the value of the part counter. UEBERSETZUNG NOETIG.
\newcommand*\etocbookname{Book} % muss der Sprache angepasst werden
\end{verbatim}

Der Standardlinienstil kann innerhalb der \etoc"=Umgebung nicht individualisiert
werden. Wie bereits erwähnt, wird das Paket nach Aufruf des Befehls
\etocstandardlines kaum verwendet und agiert lediglich auf globaler Ebene,
sodass die Einträge des Inhaltsverzeichnisses (hoffentlich) so dargestellt
werden, als ob das Paket \etoc fehlen würde.\footnote{Innerhalb der
  KOMA-script"=Klassen muss der Befehl \csa{etocstandarddisplaystyle} genutzt
  werden, damit die Option |toc=left| auch für die Linieneinträge gilt.}

Wurde mittels \csa{etocsetlevel} die Tiefe der Gliederung soweit herabgesetzt,
dass \etoc die Befehle für bestimmte Gliederungsebenen kennt, so wirkt der
Kompatibilitätsmodus, also \csa{etocstandardlines}, auch auf diese. Dies gilt
natürlich nur für Gliederungsbefehle, die dem Standard von \LaTeX{} entsprechen
und die alle Definitionen liefern, welche zum Darstellen von Einträgen im
Inhaltsverzeichnis benötigt werden. (Es muss ein Makro der Art \csa{l@irgendwas}
existieren.)

Sobald der Befehl \csa{etocsetstyle} aufgerufen wird, wird zusätzlich der
Kompatibilitätsmodus ausgeschaltet. Es spielt hierbei keine Rolle, ob der Befehl
in der Präambel oder im Hauptteil des Dokuments steht.

\subsection{Die Dar\-stellung eines Inhalts\-ver\-zeich\-nisses an\-spassen}
\label{ssec:customdisplay}

Erneut wollen wir uns darauf beschränken die relevanten Makros aufzulisten, da
deren Funktion aus ihrem Namen ableitbar ist. Soll die Länge eines Befehls
verändert werden, so muss der entsprechende Befehl mittels \csa{renewcommand}
und nicht durch \csa{setlength} verändert werden. Weiterhin erlauben Befehle,
welche die Farbe verändern, nicht nur die Standardfarben. Will man ihr Verhalten
ändern, so muss man in der neuen Definition den Befehl \csa{color} aufrufen. Um
ihre Wirkung zu beenden, muss man sie so neu definieren, dass sie danach nur den
Befehl \csa{relax} enthalten.
\begin{verbatim}
\newcommand*\etocabovetocskip{3.5ex plus 1ex minus .2ex} 
\newcommand*\etocbelowtocskip{3.5ex plus 1ex minus .2ex}

\newcommand*\etoccolumnsep{2em}
\newcommand*\etocmulticolsep{0ex}
\newcommand*\etocmulticolpretolerance{-1}
\newcommand*\etocmulticoltolerance{200}
\newcommand*\etocdefaultnbcol{2}
\newcommand*\etocinnertopsep{2ex}
\newcommand*\etoctoprule{\hrule}
\newcommand*\etoctoprulecolorcmd{\relax}

% nur für gerahmte Inhaltsverzeichnisse:
\newcommand*\etocinnerleftsep{2em}
\newcommand*\etocinnerrightsep{2em}
\newcommand*\etocinnerbottomsep{3.5ex}

\newcommand*\etocleftrule{\vrule}
\newcommand*\etocrightrule{\vrule}
\newcommand*\etocbottomrule{\hrule}
\newcommand*\etocleftrulecolorcmd{\relax}
\newcommand*\etocrightrulecolorcmd{\relax}
\newcommand*\etocbottomrulecolorcmd{\relax}

\newcommand*\etocbkgcolorcmd{\relax}

% Haken
\newcommand\etocframedmphook{\relax}
\end{verbatim}

Der Befehl \csa{etocframedmphook} ist direkt hinter dem Anfang einer Minipage,
innerhalb der der Inhalt eines gerahmten Verzeichnisses gesetzt wird, verankert.

Wurden die Farbbefehle, also \csa{...colorcmd}, nicht verändert, so expandieren
sie lediglich zu \csa{relax}. (Daher muss man für ihre Verwendung nicht die
Pakete |color| oder |xcolor| einbinden.) Hat man jedoch einen solchen Befehl -
wie zum Beispiel \csa{etocbkgcolorcmd} - so verändert, dass er nun tatsächlich
eine Farbe anzeigt, so kann dies nur mittels
|\renewcommand{\etocbkgcolorcmd}{\relax}| aufgehoben werden und nicht durch
\csa{let}\csa{etocbkgcolorcmd}\csa{relax}.

Wie man an dem Beispiel \centeredline{|\renewcommand{\etoctoprule}{\hrule height
    1ex}|} erkennen kann, werden die Größen des oberen Rechtecks in den Maßen
|ex| und |em| angegeben.
   
Sobald der Titel während der Befehlsausführung von \csa{etocruledtoc} oder
\csa{etocframedtoc} gesetzt wurde, nutzt der Paketcode dessen Schriftgröße, um
die Bedeutung von \glq1ex\grq~zu ermitteln. Natürlich dürfen auch die anderen
Befehle zur Erzeugung eines Rechtecks Maße annehmen, deren Wert sich nur durch
eine zugehörige Schriftgröße ergibt. Hierbei dient jedoch die Schrift vor dem
Inhaltsverzeichnis als Referenz.
 
Wie in \TeX{} üblich, werden sowohl das Rechteck vor als auch das nach dem
Inhalt des Verzeichnisses durch einfache Einzüge (einer festgelegten Höhe)
realisiert. Es muss sich hierbei also nicht um echte Rechtecke handeln. Die
Rechtecke links und rechts vom Inhalt werden hingegen nicht durch (horizontale)
Einzüge verwirklicht. Sie stellen vielmehr Objekte einer bestimmten Weite dar.
Daher darf hier \emph{nur} die Syntax von \TeX{}"=Befehlen, mit deren Hilfe man
Rechtecke erzeugt, genutzt werden.

\section{Ein weiteres Bei\-spiel für ein farbiges Inhalts\-verzeichnis}
\label{ssec:tocclone}

Beim Befehl \csa{etocframedstyle} wird der Titel in der Mitte des oberen Rechtecks positioniert. Dies würde im folgenden Beispiel
jedoch sehr unschön aussehen, weswegen wir den Titel innerhalb der \meta{start}-Umgebung eines Abschnittbefehls
platzieren. Hierdurch wird er innerhalb des Rahmens gesetzt.

\begin{verbatim}
\begingroup
\definecolor{subsecnum}{RGB}{13,151,225}
\definecolor{secbackground}{RGB}{0,177,235}
\definecolor{tocbackground}{RGB}{212,237,252}

\renewcommand{\etocbkgcolorcmd}{\color{tocbackground}}
\renewcommand{\etocleftrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocrightrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocbottomrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etoctoprulecolorcmd}{\color{tocbackground}}

\renewcommand{\etocleftrule}{\vrule width 1cm}
\renewcommand{\etocrightrule}{\vrule width .5cm}
\renewcommand{\etocbottomrule}{\hrule height 12pt}
\renewcommand{\etoctoprule}{\hrule height 12pt}

\renewcommand{\etocinnertopsep}{0pt}
\renewcommand{\etocinnerbottomsep}{0pt}
\renewcommand{\etocinnerleftsep}{0pt}
\renewcommand{\etocinnerrightsep}{0pt}

\newcommand\shiftedwhiterule[2]{%
    \hbox to \linewidth{\color{white}%
    \hskip#1\leaders\vrule height1pt\hfil}\nointerlineskip\vskip#2}

\etocsetstyle{subsubsection}{\etocskipfirstprefix}
  {\shiftedwhiterule{\leftskip}{6pt}}
  {\sffamily\footnotesize
     \leftskip2.5cm\hangindent1cm\rightskip1cm\noindent
     \hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
     \color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
     \rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par
     \nointerlineskip\vskip3pt}
  {}

\etocsetstyle{subsection}{\etocskipfirstprefix}
  {\shiftedwhiterule{1.5cm}{6pt}}
  {\sffamily\small
     \leftskip1.5cm\hangindent1cm\rightskip1cm\noindent
     \hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
     \color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
     \rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par
     \nointerlineskip\vskip6pt}
  {}

\newcommand{\coloredstuff}[2]{%
            \leftskip0pt\rightskip0pt\parskip0pt
            \fboxsep0pt % Auch ohne Rahmen nutzt \colorbox den Befehl \fboxsep!
       \noindent\colorbox{secbackground}
               {\parbox{\linewidth}{%
                    \vskip5pt
                    {\noindent\color{#1}#2\par}\nointerlineskip
                    \vskip3pt}}%
       \par\nointerlineskip}

\etocsetstyle{section}
{\coloredstuff{white}
     {\hfil \hyperref[toc:b]{\bfseries\large Ich bin der Zwilling von 
            diesem Verzeichnis (Klick mich an!)}\hfil}}
{\vskip3pt\sffamily\small}
{\coloredstuff{white}
    {\leftskip1.5cm\rightskip.5cm\parfillskip-\rightskip
     \makebox[0pt][r]{\makebox[.5cm][r]{\etocnumber\hspace{.2cm}}}%
     \etocname\hfill\makebox[.5cm][r]{\etocpage\hspace{.2cm}}}%
 \vskip6pt }
{}

\etocframedstyle[1]{}
\tableofcontents \label{toc:clone} \ref{toc:globalcmds}
\endgroup
\end{verbatim}

\begingroup
\definecolor{subsecnum}{RGB}{13,151,225}
\definecolor{secbackground}{RGB}{0,177,235}
\definecolor{tocbackground}{RGB}{212,237,252}

\renewcommand{\etocbkgcolorcmd}{\color{tocbackground}}
\renewcommand{\etocleftrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocrightrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etocbottomrulecolorcmd}{\color{tocbackground}}
\renewcommand{\etoctoprulecolorcmd}{\color{tocbackground}}

\renewcommand{\etocleftrule}{\vrule width 1cm}
\renewcommand{\etocrightrule}{\vrule width .5cm}
\renewcommand{\etocbottomrule}{\hrule height 12pt}
\renewcommand{\etoctoprule}{\hrule height 12pt}

\renewcommand{\etocinnertopsep}{0pt}
\renewcommand{\etocinnerbottomsep}{0pt}
\renewcommand{\etocinnerleftsep}{0pt}
\renewcommand{\etocinnerrightsep}{0pt}

\newcommand\shiftedwhiterule[2]{%
    \hbox to \linewidth{\color{white}%
    \hskip#1\leaders\vrule height1pt\hfil}\nointerlineskip
\vskip#2}

\etocsetstyle{subsubsection}{\etocskipfirstprefix}
{\shiftedwhiterule{\leftskip}{6pt}}
{\sffamily\footnotesize
\leftskip2.5cm\hangindent1cm\rightskip1cm\noindent
\hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
\rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par
\nointerlineskip\vskip3pt}
{}

\etocsetstyle{subsection}{\etocskipfirstprefix}
{\shiftedwhiterule{1.5cm}{6pt}}
{\sffamily\small
\leftskip1.5cm\hangindent1cm\rightskip1cm\noindent
\hbox to 1cm{\color{subsecnum}\etocnumber\hss}%
\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill
\rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par
\nointerlineskip\vskip6pt}
{}

\newcommand{\coloredstuff}[2]{%
            \leftskip0pt\rightskip0pt\parskip0pt
            \fboxsep0pt % \colorbox uses \fboxsep also when no frame!
       \noindent\colorbox{secbackground}
               {\parbox{\linewidth}{%
                    \vskip5pt
                    {\noindent\color{#1}#2\par}\nointerlineskip
                    \vskip3pt}}%
       \par\nointerlineskip}

% v1.07l on the occasion of traduction into German documentation 
     % APRIL 26, 2014 Improvement in the section style for better placement of
     % page number when the section name is more than one line long. Use of
     % \makebox rather than \hbox, to be more LaTeX like.
\etocsetstyle{section}
{\coloredstuff{white}
     {\hfil \hyperref[toc:b]
            {\bfseries\large Ich bin der Zwilling von diesem 
                      Verzeichnis (Klick mich an!)}%
      \hfil}}
{\vskip3pt\sffamily\small}
{\coloredstuff{white}
    {\leftskip1.5cm\rightskip.5cm\parfillskip-\rightskip
     \makebox[0pt][r]{\makebox[.5cm][r]{\etocnumber\hspace{.2cm}}}%
     \etocname\hfill\makebox[.5cm][r]{\etocpage\hspace{.2cm}}}%
 \vskip6pt }
{}

\etocframedstyle[1]{}

\begin{figure}[ht!]\centering
    \tableofcontents \label{toc:clone} \ref{toc:globalcmds}
\end{figure}
\endgroup

Das Inhaltsverzeichnis befindet sich in einer
\hyperref[toc:clone]{float}-Umgebung, die man \vpageref{toc:clone} findet. Da
diese Art von Code keine zusätzlichen Pakete verlangt, ist er etwas
komplexer.\footnote{Zudem zeigt er die Vorliebe des Autors für die
\TeX{}-Syntax.} Außerdem wurde er in einem früheren Stadium entwickelt und
seither nicht überarbeitet.

Da Rahmen (welche hier genutzt wurden, um die Hintergrundfarbe zu setzen) nur
die Hintergrundfarbe innerhalb einer Seite verändern, würde es sich anbieten,
weitere Pakete einzubinden, mit deren Hilfe man die Hintergrundfarbe über
mehrere Seiten hinweg verändern kann.

Alle Befehle, welche die Farbe verändern, sind in \etoc zu Beginn so definiert,
dass sie nichts verändern. Daher kann der Nutzer selbst entscheiden, ob er
Farben nutzen will oder nicht.


\clearpage
\etocdepthtag.toc {tips}

\part{Tipps}
\label{part:tipsandtricks}

\thispartstats

\etocsettocstyle{}{}
\etocstandardlines
\localtableofcontents

\section{\ldots\ und Tricks}

\subsection{Hacken "`framed parboxes"'}


\begin{verbatim}
\etocdefaultlines
\renewcommand\etoctoprule{\hrule height 2pt depth 2pt}
\etocruled{\color{green}\fboxrule2pt\fboxsep1ex
               \fbox{\raisebox{-\fontdimen22\textfont2}
                    {\color{blue}\parbox{.5\linewidth}
                       {\normalfont Dieser Text ist vertikal  perfekt zentriert
               unter Berücksichtigung der \emph{surrounding horizontal rules.}}}}
\ref{toc:globalcmds}
\end{verbatim}

\etocdefaultlines

\renewcommand\etoctoprule{\hrule height 2pt depth 2pt}

\etocruled{\color{green}\fboxrule2pt\fboxsep1ex
              \fbox{\raisebox{-\fontdimen22\textfont2}
                    {\color{blue}\parbox{.5\linewidth}
                       {\normalfont Dieser Text ist vertikal  perfekt zentriert
               unter Berücksichtigung der \emph{surrounding horizontal rules.}}}}}
              \ref{toc:globalcmds}


\subsection{Umstellen der Ebenen}
\label{subsec:interverting}

Lasst uns alle Unterabschnitte zeigen und aufzählen, die in diesem Dokument
vorkommen (Siehe \autoref{part:surprising} für andere Verwendungen dieser Technik.):  
\begin{verbatim}
\etocsetnexttocdepth{2}
\begingroup
\etocsetlevel{part}{3}
\etocsetlevel{section}{3}
\etocsetstyle{subsection}
    {\small\begin{enumerate}[itemsep=0pt,label=,leftmargin=0pt]}
    {\normalfont\bfseries\item}
    {\roman{enumi}. \mdseries\etocname{} (\etocnumber, p.~\etocpage)}
    {\end{enumerate}}
\renewcommand{\etoccolumnsep}{2.75em}
\renewcommand{\columnseprule}{1pt}
\etocmulticol[3]{\subsection{Alle Unterabschnitte in diesem Dokument}}
\endgroup
\end{verbatim}

\etocsetnexttocdepth{2}

\begingroup
\etocdefaultlines
\etocstandarddisplaystyle
\etocsetlevel{book}{3}
\etocsetlevel{part}{3}
\etocsetlevel{chapter}{3}
\etocsetlevel{section}{3}
\etocsetstyle{subsection}{\small
\begin{enumerate}[itemsep=0pt,label=,leftmargin=0pt]}
{\normalfont\bfseries\item}
{\roman{enumi}. \mdseries\etocname{} (\etocnumber, S.~\etocpage)}
{\end{enumerate}}

\renewcommand{\etoccolumnsep}{2.75em}
\renewcommand{\columnseprule}{1pt}

%%\etocmarkbothnouc{List of all subsections}
%% le mark (\markright) est fait par \subsection

\etocmulticol[3]{\subsection{{Alle Unterabschnitte in diesem Dokument}}\label{toc:allsubsections}}


\endgroup

\subsection{Sta\-ti\-sti\-ken anzeigen}\label{ssec:statistics}

Jeder Teil dieses Dokuments beginnt mit einem Paragraphen, der sagt, wieviele
Kapitel und Unterkapitel er hat. Nun, jeder von diesen Paragraphen ist ein
Inhaltsverzeichnis! Wir haben ein Makro \csa{thispartstats} geschaffen, um dies
zu tun. Es nutzt "`Speicher"'"=Boxen, um die Informationen über die ersten und
späteren Kapitel und Unterkapitel zu halten. Boxen zu nehmen, ist die einfachste
Art und Weise |hyperref|-Links für spätere Verwendungen zu kapseln (ob es einer
ist oder keiner). Allerdings kann man dann nichts an der Schriftart oder Farbe
ändern (die \TeX -Primitive \csa{setbox} eher nehmend als von \LaTeX{}
\csa{sbox} würde die Farbe Farbe um das ohne Boxen gespeicherte Feld verändern).
Wenn eine solche Notwendigkeit entsteht, muss man von der Boxenverwendung zum
Makro nehmen wechseln und die |hyperref|-Daten für später speichern, wie im oben
im Code von \autoref{sec:molecule} vorgestellt. Wir präsentieren auch diese
zweite Methode.

Aber als Erstes der Code von \csa{thispartstats}:\par
\begin{verbatim}
\newsavebox\firstnamei  \newsavebox\firstnumberi
\newsavebox\lastnamei   \newsavebox\lastnumberi
\newsavebox\firstnameii \newsavebox\firstnumberii
\newsavebox\lastnameii  \newsavebox\lastnumberii
\newcounter{mycounti}   \newcounter{mycountii}
\newcommand*{\thispartstatsauxi}{} \newcommand*{\thispartstatsauxii}{}
\newcommand*{\oldtocdepth}{}
\newcommand*{\thispartstats}{%
  \setcounter{mycounti}{0}%
  \setcounter{mycountii}{0}%
  \def\thispartstatsauxi{%
         \sbox{\firstnamei}{\etocname}%
         \sbox{\firstnumberi}{\etocnumber}%
         \def\thispartstatsauxi{}}%
  \def\thispartstatsauxii{%
         \sbox{\firstnameii}{\etocname}%
         \sbox{\firstnumberii}{\etocnumber}%
         \def\thispartstatsauxii{}}%
  \begingroup
  \etocsetstyle{subsection} {} {}
    {\thispartstatsauxii
     \stepcounter{mycountii}%
     \sbox{\lastnameii}{\etocname}%
     \sbox{\lastnumberii}{\etocnumber}} {}%
  \etocsetstyle{section}
    {}
    {}
    {\thispartstatsauxi
     \stepcounter{mycounti}%
     \sbox{\lastnamei}{\etocname}%
     \sbox{\lastnumberi}{\etocnumber}}
% Hier wird ein Befehl definiert, der fuer jedes Teil ein paar Fakten sammelt
% und ausgibt. 
    {Zu Beginn wollen wir ein paar Fakten zu diesem Teil nennen. Er enthält
     \arabic{mycounti} Abschnitt\ifnum\value{mycounti}>1 e\fi{} und 
      \arabic{mycountii} Unterabschnitt\ifnum\value{mycountii}>1 e\fi. Der Name des ersten 
      Abschnitts lautet
     \glqq\unhbox\firstnamei{}\grqq~und er hat die Gliederungsnummer 
     \glqq\unhbox\firstnumberi\grqq. Der Name des letzten Abschnitts lautet 
     \glqq\unhbox\lastnamei{}\grqq~und er hat die Nummer
     \glqq\unhbox\lastnumberi\grqq. 
     \ifnum\value{mycountii}>0  Der erste 
     Unterabschnitt heißt 
     \glqq\unhbox\firstnameii{}\grqq~und er hat die Nummer 
     \glqq\unhbox\firstnumberii\grqq. Der Name des letzten Unterabschnitts ist 
     \glqq\unhbox\lastnameii{}\grqq~und dessen Nummer ist
     \glqq\unhbox\lastnumberii\grqq.\fi }% 
  \etocinline
  \etocsettocstyle {}{}
  \etocsetnexttocdepth{2}%
  \localtableofcontents  % to be used at the top level of a Part.
  \endgroup
}
\end{verbatim}

Und nun, die Variante mit Makros anstelle von der mit Boxen (diese Variante
steht hier für die Verwendung in einem Kapitel).
\begin{verbatim}
\makeatletter
\newcommand*\firstsubname   {}  \newcommand*\lastsubname    {}
\newcommand*\firstsubnumber {}  \newcommand*\lastsubnumber  {}
\newcommand*\thisspecialstatsaux{}
\newcommand*{\thisspecialstats}{%
  \setcounter{mycounti}{0}%
  \def\thisspecialstatsaux{%
         \let\firstsubname\etocthelinkedname
         \let\firstsubnumber\etocthelinkednumber
         \def\thisspecialstatsaux{}}
  \begingroup
  \etocsetstyle{subsection} 
    {} 
    {}
    {\thisspecialstatsaux
     \stepcounter{mycounti}%
     \let\lastsubname\etocthelinkedname
     \let\lastsubnumber\etocthelinkednumber }
    {Zu Beginn wollen wir ein paar Fakten zu diesem Teil nennen. Er enthält
     \arabic{mycounti} Unterabschnitt\ifnum\value{mycounti}>1 e\fi{}. Der Name des ersten 
      Abschnitts lautet\emph{\firstsubname{}} und er hat die Gliederungsnummer 
      {\firstsubnumber}. Der Name des letzten Unterabschnitts lautet 
      \emph{\lastsubname{}} und er hat die Nummer{\lastsubnumber}.}
   \etocsettocstyle {}{}
   \etocinline
   \etocsetnexttocdepth {1}%
   \localtableofcontents % to be used within a section
  \endgroup
}
\makeatother
\end{verbatim}

\subsection{Tiefe Tags nehmen}
\label{ssec:tocwithdepthtags}

Wir wollen ein TOC, das für jeden |\part| eine Überschrift hat (außer der letzte
Teil mit dem Quellcode, wofür beschließen, ihn nicht einzubeziehen), und wir
wollen \autoref{part:globalcmds} öffnen für die Paragraphen. Um dies zu
erreichen, fügen wir zu dieser Quelle verschiedene
\csb{etocdepthtag.toc}"=Befehle und es bleibt jetzt, zu setzen die Levels für
jeden Tag mit \csb{etocsettagdepth} (dies wurde oben in diesem Dokument
verwendet in \autoref{sec:secondexample}, in einer Gruppe, damit es keine
Auswirkungen auf andere Inhaltsverzeichnisse hat).

Allerdings sind die Linienstile des Pakets nicht in der Lage Paragraphen
anzuzeigen und die Standardlinienstile der Dokumentklasse geben zu viel
vertikalen Abstand (in diesem Zusammenhang) bei der Anzeige einer
Teilüberschrift im TOC aus.Deshalb kochen wir unseren eigenen, schnell
entwickelten Linienstil, in der Art von \autoref{sec:firstexample} (aber auf dem
Weg Seitenzahlen von rechts, was mehr wie eine Methode von \LaTeX2e's
|\@dottedtocline| ist; und mehrzeilige Überschriften lassen nun den Bereich
unter den Zahlen leer, im Gegensatz zu dem Code von \autoref{sec:firstexample}).
Und nach ein paar Minuten für die Wahl der Längen (jetzt ist das erstmal getan,
es kann leicht recycelt) erhalten wir:

\etocsetnexttocdepth {all}
\begingroup
\parindent 0pt
\leftskip 0cm
\rightskip 0.75cm
\parfillskip -\rightskip
\newcommand*{\EndParWithPagenoInMargin}
    {\nobreak\hfill
     \nobreak\makebox[0.75cm][r]{\mdseries\normalsize\etocpage}%
     \par}
\renewcommand*\etoctoclineleaders
    {\hbox{\normalfont\normalsize\hbox to .75ex {\hss.\hss}}}
\newcommand*{\EndParWithPagenoInMarginAndLeaders}
    {\nobreak\leaders\etoctoclineleaders\hfill
     \nobreak\makebox[0.75cm][r]{\mdseries\normalsize\etocpage}%
     \par }
\etocsetstyle {part}
              {}
              {\leavevmode\leftskip 1cm\relax}
              {\bfseries\large\llap{\makebox[1cm][r]{\etocnumber\ \ }}%
               \etocname\EndParWithPagenoInMargin\smallskip}
              {}
\etocsetstyle {section}
              {}
              {\leavevmode\leftskip 1.75cm\relax}
              {\bfseries\normalsize\llap{\makebox[.75cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {subsection}
              {}
              {\leavevmode\leftskip 2.75cm\relax }
              {\mdseries\normalsize\llap{\makebox[1cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {subsubsection}
              {}
              {\leavevmode\leftskip 4cm\relax }
              {\mdseries\normalsize\llap{\makebox[1.25cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {paragraph}
              {}
              {\leavevmode\leftskip 5.5cm\relax }
              {\mdseries\normalsize\llap{\makebox[1.5cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {part}
\etocsettagdepth {arbitrarily}{part}
\etocsettagdepth {surprising} {part}
\etocsettagdepth {linestyles} {part}
\etocsettagdepth {globalcmds} {paragraph}
\etocsettagdepth {custom}     {part}
\etocsettagdepth {tips}       {part}
\etocsettagdepth {code}       {none}
\renewcommand\etoctoprule {\hrule height 3pt\relax }
\renewcommand\etoctoprulecolorcmd {\color{blue}}
\renewcommand\etocaftercontentshook 
   {\medskip\begingroup \color{blue}\hrule height 3pt \endgroup }
\etocruledstyle [1]{\Large\bfseries 
                    \fbox{\makebox[8cm]{Ein TOC -- nehmend tiefe Tags}}}
\sloppy
\tableofcontents

\begin{verbatim}
\etocsetnexttocdepth {all}
\begingroup 
\parindent 0pt \leftskip 0cm \rightskip .75cm \parfillskip -\rightskip
\newcommand*{\EndParWithPagenoInMargin}
    {\nobreak\hfill
     \nobreak\makebox[0.75cm][r]{\mdseries\normalsize\etocpage}%
     \par}
\renewcommand*\etoctoclineleaders
    {\hbox{\normalfont\normalsize\hbox to .75ex {\hss.\hss}}}
\newcommand*{\EndParWithPagenoInMarginAndLeaders}
    {\nobreak\leaders\etoctoclineleaders\hfill
     \nobreak\makebox[0.75cm][r]{\mdseries\normalsize\etocpage}%
     \par }
\etocsetstyle {part}
              {}
              {\leavevmode\leftskip 1cm\relax}
              {\bfseries\large\llap{\makebox[1cm][r]{\etocnumber\ \ }}%
               \etocname\EndParWithPagenoInMargin\smallskip}
              {}
\etocsetstyle {section}
              {}
              {\leavevmode\leftskip 1.75cm\relax}
              {\bfseries\normalsize\llap{\makebox[.75cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {subsection}
              {}
              {\leavevmode\leftskip 2.75cm\relax }
              {\mdseries\normalsize\llap{\makebox[1cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {subsubsection}
              {}
              {\leavevmode\leftskip 4cm\relax }
              {\mdseries\normalsize\llap{\makebox[1.25cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsetstyle {paragraph}
              {}
              {\leavevmode\leftskip 5.5cm\relax }
              {\mdseries\normalsize\llap{\makebox[1.5cm][l]{\etocnumber}}%
               \etocname\EndParWithPagenoInMarginAndLeaders}
              {}
\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {part}
\etocsettagdepth {arbitrarily}{part}
\etocsettagdepth {surprising} {part}
\etocsettagdepth {linestyles} {part}
\etocsettagdepth {globalcmds} {paragraph}
\etocsettagdepth {custom}     {part}
\etocsettagdepth {tips}       {part}
\etocsettagdepth {code}       {none}
\renewcommand\etoctoprule {\hrule height 3pt\relax }
\renewcommand\etoctoprulecolorcmd {\color{blue}}
\renewcommand\etocaftercontentshook 
   {\medskip\begingroup \color{blue}\hrule height 3pt \endgroup }
\etocruledstyle [1]{\Large\bfseries 
                    \fbox{\makebox[8cm]{A TOC using depth tags}}}
\sloppy
\tableofcontents
\endgroup
\end{verbatim}
\endgroup

\subsection{Das TOC als eine Tabelle setzend (die alte Weise)}
\label{ssec:tocastableold}

%%% ALT TEXT:
% Tabellenzellen erstellen Gruppen; Definitionen von |\etocname|, |\etocnumber|,
% |\etocpage| sind lokal gemacht, also wenn die erste Zelle einer Zeile ist, wo
% die |.toc|-Dateizeile gelesen wird und|\etocname| und |\etocnumber| definiert
% wird, werden diese Definitionen nach dem Tabularzeichen |&|
% verloren gehen. Der 
% Quellcode von \etoc beginnt, die "`Anfangs"'- und "`End"'teile der Linienstile
% zu öffnen oder Gruppen zu schließen, durch ein |&| beispielsweise im
% "`Präfix"'-Teil des Linienstils ist nicht zu erwarten.

% Weiterhin, ähnlich sieht die Sache der Neudefinition von |\contentsline|, made
% by \etoc , aus, jedesmal wird ein TOC gesetzt. Es wird nach dem
% ersten Argument 
% getan, wenn \csb{etocsettocstyle} ausgeführt wurde, weil, wenn dieses Argument
% eine Tabelle öffnet, die |etoc|-Neudefintion der |\contentsline| in die erste
% Zelle der ersten Zeile getan werden will und danach verloren geht.

% So, mit dem Öffnen und Schließen mit |\etocsettocstyle| und dem
% Nehmen von |&| | 
% und | innerhalb eines Level-Stils, kann man nicht direkt ein TOC
% in eine Tabelle 
% setzen.

% Der \etoc -Quellcode könnte geändert werden, zu machen Modifizierungen von
% einigen relevanten globalen Definitionen, aber ich habe mich dagegen
% entschieden. Setzen als eine |tabular| (oder später als |longtable|) wird nur
% fortgeschrittene Anwendern gesucht und fortgeschrittene Anwender können die
% Technik einsetzen, die in \autoref{tocastree} erklärt wurden. Hier ist ein
% Beispiel mit einem vollverlinkten Inhaltsverzeichnis. Der Code kommt nach der
% Tabelle.


\textbf{UEBERSETZUNG NOETIG}

\begin{otherlanguage}{english}
Due to, among other things, the fact that alignment cells create and close
groups, and that by default definitions of \csb{etocname}, \csb{etocnumber},
\csb{etocpage} made by \etoc are local, it was not easy to typeset a TOC as
table with \etoc, prior to release |1.08|. 

Not only \csb{etocname} etc... caused a problem, but also the basic
redefinition of \csa{contentsline} was made by \etoc only after the
first argument to \csb{etocsettocstyle} had been executed, hence if this
argument were to open a tabular, the \etoc redefinition of
\csa{contentsline} would be done in the first cell of the first row and
get lost thereafter.

Thus one had to resort to the technique explained in \autoref{tocastree}
of using the execution of \csa{tableofcontents} as a way to store data
which was then displayed later.

For the record, here is how the TOC from \autoref{sec:tocastable} was
coded in the old days. We don't have here the problems with the
positioning of |\hline|'s we face with the newer method; on the other
hand we must manipulate token registers which are not familiar to most
\LaTeX{} users (macros could be used, but would be more cumbersome,
except perhaps if using the \eTeX{} \csa{unexpanded}).

The method here is the most powerful because it filters out of the
|.toc| file only the data we want (the other things are not ignored,
they are executed but hopefully do not create havoc; typically they are
language changing instructions, or updates to certain counters, etc...),
and we are less susceptible to fall potential victims of various
external macros inserted in the |.toc| file by other packages.

Note: rather than |\toks| registers it would be easier here to use \eTeX{}
\csa{unexpanded} primitive. See for example \autoref{sec:mindmap}.
\end{otherlanguage}


\begin{verbatim}
\newtoks\toctabletok
\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
  #1\expandafter\expandafter\expandafter {\expandafter\the\expandafter #1#2}}

\newcommand*\PreparePart{%
  \toks0 \expandafter{\etocthelinkednumber}%
  \toks2 \expandafter{\etocthelinkedname}%
  \toks4 \expandafter{\etocthelinkedpage}%
  \edef\toctablepiece {\noexpand\hline
                      \noexpand\strut\the\toks0 &\noexpand\bfseries\the\toks2 
                                 &\the\toks4 \noexpand\\\noexpand\hline}% 
}
\newcommand*\PrepareSection{%
  \toks0 \expandafter{\etocthelinkednumber}%
  \toks2 \expandafter{\etocthelinkedname}%
  \toks4 \expandafter{\etocthelinkedpage}%
  \edef\toctablepiece {\the\toks0 &\the\toks2 &\the\toks4 \noexpand\\}% 
}
% new version for 1.07k, 2014/03/06
\newcommand*{\PrepareSubsection}{%
  \toks0 \expandafter{\etocthelinkednumber}%
  \toks2 \expandafter{\expandafter\itshape\etocthelinkedname\strut}%
  \toks4 \expandafter{\expandafter\itshape\etocthelinkedpage}%
  \edef\toctablepiece{&\noexpand\makebox[1cm][c]{\the\toks0}%
                      \noexpand\parbox[t]{\dimexpr6cm-\tabcolsep\relax}
                                         {\noexpand\sloppy\the\toks2}%
                      &\the\toks4 \noexpand\\}%
}

\begingroup
\etocsetstyle{part}{}{}{\PreparePart \appendtotok\toctabletok\toctablepiece}{}

\etocsetstyle{section}{}{}{\PrepareSection \appendtotok\toctabletok\toctablepiece}{}

\etocsetstyle{subsection}{}{}{\PrepareSubsection\appendtotok\toctabletok\toctablepiece}{}

\etocsettocstyle
    {\toctabletok{\hypersetup{hidelinks}%
                 \begin{longtable}{|>{\bfseries}c|p{7cm}|r|}\hline
                 \multicolumn{3}{|c|}{\Large\bfseries\strut TABLE OF CONTENTS}%
                 \\\hline\hline}}
    {\global\toctabletok\expandafter{\the\toctabletok\hline\end{longtable}}}
\etocsettocdepth {subsection}
\tableofcontents
\the\toctabletok
\endgroup
\end{verbatim}

\subsection{Kompatibilität mit anderen Paketen}
\label{etocaftertochook}

% JFBU modifiziert Januar 23, 2015
Die Inhalte der |.toc|-Datei (falls bereits vorhanden) werden einmal in den
Speicher von \etoc getan, bei |\begin{document}|. \footnote{Neu mit |1.07m|.
    Früherer Versionen benutzten die |.toc|-Datei bei
    \csa{usepackage\{etoc\}}. Danke an Denis Bitouzé für ein Babel-etoc
    Problem entdecken zu haben.} 

\begin{framed}
  Man sollte \etoc \emph{nach} \texttt{babel} laden.
\end{framed}

  Die |.toc|-Datei bleibt für andere Pakete nutzbar für
  Lesevorgänge bis zum Ort des ersten Inhaltsverzeichnisses, zu diesem
  Zeitpunkt wird ein Schreib-stream durch \etoc geöffnet und von diesem Punkt
  aus wird die Datei gelöscht bis ihr Inhalt wieder auf die Platte von
  \LaTeX{} am Ende der Kompilierung geschrieben wurde.

\etoc lädt das Paket |multicol|. 

\etoc erwartet die Sektionierungseinheiten des Dokuments, um ihre Daten in eine
Datei mit der Endung |.toc| zu schreiben, in Form von Linien, die enthalten den
\csa{contentsline}"=Befehl und dessen Argumente. 
\textbf{UEBERSETZUNG NOETIG}
\begin{otherlanguage}{english}
  \etoc requires the |.toc| file to use the |\contentsline| macro (possibly
  patched by other packages). It is thus incompatible with the |beamer| class.
  However, if |beamer| is used in an article mode, i.e., with the article
  class in conjunction with the |beamerarticle| package, then \etoc should
  work.
\end{otherlanguage}

Es ist |hyperref| bekannt und hoffentlich kompatibel mit ihm: die Macros
\csa{etocname}, \csa{etocnumber} und \csa{etocpage} enthalten die
|hyperref|-Links, wenn vorhanden (Beachten Sie, dass die
\emph{linktoc=all}-Option von |hyperref| mitteilt, dass ein Link zur
Seitenzahl zu setzen ist, für ein einen toc"=Eintrag.). Beispielsweise sind die
Inhaltsverzeichnisse des vorliegenden Dokuments komplett verlinkt.
Es ist kein Thema, ob \etoc vor oder nach |hyperref| geladen wird.

Die Release |1.07k| fügt Kompatibilität mit dem Paket |tocloft| hinzu:
\footnote{\url{http://ctan.org/pkg/tocloft}} Schritte wurden getan, um eine Neudefinition
von |\tableofcontents| zu vermeiden, getan von |tocloft| an  |\begin{document}|.
%

Solange \etoc ungeschickt ist im Kompatibilitätsmodus, wird von |tocloft| die
Anpassung sowohl für den Lin ienstil als auch den TOC-Titel getan. Man kann
immer noch von den \emph{tiefen Tags}-Management mit \etoc profitieren, von
seinem |\localtableofcontents|, von seinem |\label+\ref|-Mechanismus. Man kann
|\etocsetstyle| nehmen, um mit \etoc das Layout des TOC zu definieren und dann
eher |tocloft| für etwas anderes, wenn auf |\tableofcontents| folgen
\csb{etocstandardlines} und \csb{etocstandarddisplaystyle}. In diesem
Kompatibiltätsmodus |\etocsetlevel{division unit}{6}| wird die gewählte
Bereichsebene gerendert, aber der Austausch von Ebenen ist andererseits nicht
möglich.
\begin{framed}
  Man sollte \etoc \emph{nach} \texttt{tocloft} laden. Sonst wird eine Warnung
  ausgegeben.
\end{framed}

Die Release |1.07l| hat ebenfalls die Kompatibilität mit der |memoir|-Klasse
verbessert: Seine |appendix|-Ebene kann mit \etoc gemacht werden. Es ist die
gleiche Ebene wie wie bei |chapter|, also der Kapitelebenstil kann eventuell ein
Test für einige boolesche"=Ausdrücke sein, die aktiviert sein können via einer
Instruktion an die |.toc|-Datei aufgenommen werden, wenn man zwei Arten von
Unterteilungen unterscheidet.

\etoc kann nicht wirklich mit Paketen zusammensein, die
\csa{tableofcontents}"=Befehle ändern: Eine Art Waffenstilstand kann erreicht
werden, wenn \etoc zuletzt geladen wird, daher ist es der Gewinner.
  \begin{framed}
    Ändern Sie nicht den |\tableofcontents|"=Befehl, wie diesen folgenden:
    \centeredline{|\let\oldtableofcontents\tableofcontents|,}
    \centeredline{|\renewcommand\tableofcontents{\oldtableofcontents\mystuff}|,}
    da dies den |\label/\ref|-Mechanismus unmöglich macht. Sie können vielmehr
    \centeredline{|\renewcommand\etocaftertochook{\mystuff}|} ausführen und es
    ergibt auch \csb{etocaftercontentshook}, das führt ein bisschen eher
    \footnotemark{} aus, gerade vor dem Schließen des Teils vom toc"=Anzeigestil
    (und damit innerhalb einer Gruppe).
   \end{framed}
\footnotetext{Im Gegensatz zu \csa{etocaftertochook},
     \csa{etocaftercontentshook} wird nicht ausgeführt, wenn |tocdepth| das
     Drucken des TOC nicht ermöglicht.}

\etoc zu verwenden, kann unvereinbar sein mit dem Paket
|tocvsec2|\footnote{\url{http://ctan.org/pkg/tocvsec2}}; jetzt lebt es ,
sortierend, wie es deaktiviert die Modifikationen des |\tableofcontents| durch
|tocvsec2| (getan im Stile von oben) und es kanzelt auch andere |toc|-bezogene
Macros, aber es reimplantiert partiell ihre Funktionalität mit
\csb{etocsettocdepth.toc}. In der Art und Weise, die letzten beiden \LaTeX-Läufe
sind für das erneute Nehmen des Befehls in einem Dokument notwendig, um einen
Effekt im Inhaltsverzeichnis zu haben.
  
Wenn ein \localtoc durch den Nutzer in das Dokument aufgenommen wird, eine
Zeile, in einen inneren \etoc"=Befehl und eine Identifikationszahl in die
|.toc|-Datei aufgenommen wird. Das korrekte Inhaltsverzeichnis wird nur nach dem
nächsten \LaTeX -Lauf angezeigt werden.

Es ist möglich (unter Verwendung des Pakets|tocloft| beispielsweise), im
gesamten Dokument die Makros \csa{l@section}, \csa{l@subsection} \ldots{} zu
benutzen und der Effekt wird im nächsten Inhaltsverzeichnis durch den
Kompatibilitätsmodus von \etoc sichtbar werden.

\textbf{UEBERSETZUNG NOETIG}

\begin{otherlanguage}{english}
It is possible to use simultaneously \etoc and
{\color{niceone}|tableof|}\footnote{\url{http://ctan.org/pkg/tableof}}. Release
|1.08| of \etoc requires at least version |1.4a| of |tableof|. If
\csb{etocglobaldefs} is put in the preamble, this must be after the loading of
package |tableof|. {\color{niceone}|tableof|} command \csa{nexttocwithtags}
should work as expected. 

{\color{niceone}|tableof|} commands \csa{tableof}, \csa{tablenotof}, ... will
typeset the (a priori global) table of contents according to the document
class defaults, obeying the \etoc depth tags; as explained in the |tableof|
documentation they do not typeset a TOC title. They should \emph{not} be used
in case \csb{etocglobaldefs} was issued before, except if its scope has been
terminated since then, or \csb{etoclocaldefs} has cancelled its influence.
\end{otherlanguage}

\subsection{\TeX -nische Sachen}

Die \csa{etocname}, \csa{etocnumber}, \csa{etocpage} Befehle sind gegen
vorzeitige Expansion geschützt. Sie enthalten geeignete |hyperref|-Links, wenn
das Paket |hyperref| geladen und aktiviert für das TOC ist. Die Befehle
\csa{etoclink} und \csa{etocifnumbered} sind auch gegen vorzeige Expansion
geschützt. Auch \csb{etociffirst} und \csb{etoctoccontentsline}.

Andererseits \csb{etocthename}, \csb{etocthenumber}, \csb{etocthepage}, haben
keine Anbindung an |hyperref|-Links und sind nicht gegen Expansionen geschützt.
Und \csb{etocthelinkedname}, \csb{etocthelinkednumber},
\csb{etocthelinkedpage} sind auch nicht gegen Expansionen geschützt.

Befehle wie \csb{etocsetstyle}, \csb{etocsetlevel}, \csb{etocsettocstyle},
\csb{etocmulticolstyle}, \csb{etocruledstyle}, \csb{etocframedstyle} folgen
Gruppierungen von \LaTeX. Alle TOCs werden in Gruppierungen gesetzt.

\subsection{Fehler und Katastrophen}

Nach der Verwendung von \csa{etocsetstyle}für eine Ebene nehmen die restlichen,
nicht angepassten Ebenen die Standardstile von \etoc (diejenigen, die aktiviert
werden von \csa{etocdefaultlines}). Man muss sicherstellen, dass alle Ebenen,
die für das nächste Inhaltsverzeichnis gebraucht werden, miteinander kompatibel
sind: Insbesonders, dass die Standardlinienstile jeweils im "`vertikalen Modus"'
gestartet werden.

Wenn man mehrere \toc"=Befehle in einem Dokument verwendet, sollte man sich
hüten, mehrere Satzanweisungen in der |.toc|-Datei zu addieren, so sie mit \toc
ausgeführt für alle TOCs ausgeführt werden: Auch für \localtoc spielt es keine
Rolle, ob die Anweisungen Material außerhalb des Anwendungbereichs betreffen,
sie werden sie trotzdem erhalten. Falls unbedingt erforderlich (aber es das
sollte es nie) müssen dies Instruktionen so sein, dass einfach aktiviert oder
deaktiviert werden von der Dokumentquelle, wie es sein muss.

So wie es üblich ist bei TOCs und Labels, muss nach jeder Änderung \LaTeX{} eine
bestimmte Anzahl von Durchführungen haben, um für das Dokument das endgültige
Aussehen zu erhalten (mindestens zweimal durchlaufen).



\clearpage
\etocdepthtag.toc {code}

\part{Der Code}

\section{Zeitstempel}

Dies ist die deutsche Dokumentation von \texttt{\etocDEdocdate}, erzeugt von der
Quelldatei mit dem Stempel \texttt{\etocdtxtimestamp}. Die dokumentierte
Paketversion ist \texttt{\etocDEpkgversion} von \texttt{\etocDEpkgdate}.

% STOP GERMAN (DEUTSCH) VERSION

^^Afi

^^Acatcode92 0

\catcode1 13

\begingroup
\renewcommand\lowast{{\normalsize\raisebox{-.4\height}{*}}}
\small

\ifnum\ForEnglish=1
    \section{Change history}
\fi

\ifnum\ForDeutsch=1
    \section{Änderungen}
\fi

\selectlanguage{english}

\setlength{\columnsep}{\etoccolumnsep}

\makeatletter

% 27 avril 2014 un petit hack pour hyphénation (éventuelle) en allemand
% j'ai déjà ~ qui sera de catcode 0, cependant il faudrait aussi les accolades,
% donc finalement pour aller vite, je rends le + actif. Je modifie aussi le test
% fait par \jfverbaspace (n'ayant pas commenté mon code, j'ai dû réfléchir pour
% me rappeler à peu près ce que c'était censé faire).

\def\jfverbatim{\@beginparpenalty \predisplaypenalty 
  \parindent \z@ 
  \parfillskip \@flushglue 
  \parskip \tw@\p@ plus 1fil\relax
  \let \do \@makeother \dospecials \makestarlowast \catcode`$ \active
  \begingroup\lccode`~`$
  \lowercase{\endgroup\def~[##1]{\foreignlanguage{ngerman}{##1}}}%
  \catcode`^ \active
  \begingroup\lccode`~`^
  \lowercase{\endgroup\def~{\nopagebreak}}% ajouté 2014/04/28, oblige à un peu
                                % plus de mark-up cependant
  \catcode`\~\z@ 
  \footnotesize\normalfont\baselineskip10pt\relax
  \frenchspacing \obeyspaces \jf@xverbatim }

\begingroup 
\catcode `|=0 \catcode `[= 1 \catcode`]=2 
\catcode `\{=12 \catcode `\}=12 \catcode`\\=12 
|long|gdef|jf@xverbatim#1\end{jfverbatim}[#1|end[jfverbatim]]
|endgroup

\def\endjfverbatim{} 

\newdimen\jfverbadim

\everypar{\leftskip\jfverbadim\bgroup
          \def\par{\egroup\jfverbadim\z@\@@par}%
          \def\jfverbaspace#1{\if\@sptoken\string#1\unskip\else\ \fi#1}}

\begingroup\obeyspaces\def\x{\endgroup%
\def {\ifvmode\advance\jfverbadim.5em\relax\else\expandafter\jfverbaspace\fi}}\x

\makeatother

\begin{multicols}{2}
\begin{jfverbatim}
v1.08b [2015/03/18]^

   Bug fixes: 
   - extra space token removed from `\localtableofcontents` (showed
   only for inline TOCs.)
   - \etocpartname (a macro used by the package own default line
   styles) was defined to be \partname, but this is not compatible
   at least with babel+french context. Now simply expands to Part.
   - some problems fixed in the German documentation.


v1.08a [2015/03/13]^

   \etocname, \etocnumber and \etocpage are now the robust
   variants of \etocthelinkedname, \etocthelinkednumber and
   \etocthelinkedpage. This should arguably have been done since
   the addition of the latter to etoc with v1.07f [2013/03/07].
   The earlier \etocname etc... contained the hyperlink
   destination only in an unexpanded form.

   The documentation has a brand new title page and a new section
   The TOC as a TikZ mind map both illustrating further uses of
   etoc to display tables of contents as trees in an automatic 
   manner.


v1.08 [2015/03/10]^

   \etocskipfirstprefix may now appear anywhere in the <start>
   part of a level style. 

   New commands \etociffirst, \etocxiffirst, \etocxifnumbered.

   It is now possible to issue line style specifications directly
   with & and \\ tokens, in order to typeset a TOC as a tabular
   or longtable with the opening for example in the first
   argument of \etocsettocstyle and the closing in its second
   argument.

   It is mandatory for such uses to issue \etocglobaldefs which
   tells etoc to proceed globally for certain definitions. This
   is also useful in the context of the inline environments of
   package enumitem.

   On this occasion, various old parts of the code have been
   improved.


v1.07n [2015/03/05]^

   No more use of \toks@ when etoc constructs \etocthelinkedname
   etc... Thus \toks@ can be put in the line styles in order to
   accumulate information. Only useful if it is certain nothing
   else will change \toks@ either.

   In the documentation: list of main commands now in alphabetic
   order.


v1.07m [2015/01/23]^

   Reading of .toc file is delayed to \begin{document} to account for
   possible Babel active characters used therein. Thanks to Denis
   Bitouzé who reported a Babel related problem.

   Improved global toc display emulation under KOMA-script classes.

   New command \etocbeforetitlehook. New command \etocdisplay.


v1.07l [doc of 2014/04/29]^

   Added to the documentation an example of use of \etocthelinkedname together
   with an enumitem inline itemize* environment; moved main TOC to immediately
   after the title, and license to the first pages.

   Incorporation of the translation into German done on the initiative of
   $[Christine Römer] by $[Felix Baral-Weber, Jenny Rothkrämer-Vogt, Daniel
   Büttner, Claudia Dahl, Christian Otto and Christine Römer (FSU Jena).] My
   grateful thanks to all!


v1.07l [2014/04/22]^

   Fixes a bug with the 1.07k compatibility layer with tocloft which had broken
   the 1.07k (sic) compatibility with memoir (yes, memoir class 1.07k testing
   had been done before adding the tocloft thing to the source code . . . ).
   Also, etoc when detecting tocvsec2 now checks if this is under the memoir
   class, as then nothing special needs to be done to rescue \tableofcontents,
   contrarily to the situation with the native tocvsec2. 


v1.07k [2014/03/06]^

   Compatibility with package tocloft; and improved compatibility with
   class memoir. Novel TOC example in Overview.


v1.07j [2013/12/03]^

   Some issues with the documentation formatting (now two-sided) have been
   addressed, and a novel documentation section ``Typesetting the TOC as a
   table'' has been added. Very minor code change (\Etoc@readtoc).


v1.07i [2013/10/21]^

   Changes to the \etocmulticolstyle and \etocruledstyle codes 
   to lessen the risk of a page break after the title (in the one-column case).


v1.07h [2013/10/16]^

   New commands \etocdepthtag.toc, \etocsettagdepth, \etocobeydepthtags,
   \etocignoredepthtags. 


v1.07g [2013/10/13]^

   New commands \etocsettocdepth, \etocsettocdepth.toc,
   \etocobeytoctocdepth, \etoc~-ignoretoctocdepth which
   emulate part of tocvsec2 functionality ; measures to
   make tocvsec2 partially compatible with etoc.

   New commands \etocsetnexttocdepth, \invisibletableofcontents,
   \invisiblelocaltableofcontents.

   Switched from tikz-qtree to forest for the first `toc as
   tree' example. 

   Command names are linked to their descriptions, and many
   other changes in the documentation.

   Removed printing of temporary message when the local toc
   id is not yet stabilized; indeed \localtableofcontents
   can have many uses, such as filling up some token list
   register and one may wish to not have anything typeset, 
   even in an intermediate run. 

   All of tex etoc.dtx, etex etoc.dtx, xetex etoc.dtx, latex
   etoc.dtx, pdflatex etoc.dtx are now possible, and the
   extracted file etoc.tex allows easy customization of
   compilation options for the documentation (default is via
   dvipdfmx which produces the smallest file).


v1.07f [2013/03/07]^

   New macros \etocthelinkedname, \etocthelinkednumber,
   \etocthelinkedpage, and \etocthelink.


v1.07e [2013/03/01]^

   Improvements in the package own line styles with
   regards to penalties and vertical spaces. 

   Addition to the documentation of an example of
   a tree-like table of contents (uses tikz).

   More such examples added 2013/03/03.


v1.07d [2013/02/24]^

   Minor code improvements and new documentation 
   section ``Another compatibility mode''.


v1.07b [2013/02/02]^

   Removal of the \xspace from the macros \etocname, 
   \etocnumber, \etocpage.

   Additional examples in the documentation.


v1.07 [2013/01/29]^

   New commands:

      \etocthename, \etocthenumber, \etocthe~-page, \etoclink, 

      \etoctoccontentsline, \etoctoccontentsline~lowast

      \etocnopar, \etocaftercontentshook

   Modified command: \etocmulticolstyle

   New documentation section ``Surprising uses of etoc'' which
   explains how to do  ``Lists of arbitrary things'', in
   addition to the tables of contents.


v1.06 [2012/12/07]^

   The standard macros \l@section etc... are modified only
   during the calls to \tableofcontents; they can thus be
   customized as will by the user (with the help of a
   package like tocloft) and this will be taken into account
   by etoc for the TOCs typeset in compatibility mode.


v1.05 [2012/12/01]^

   \localtableofcontents replaces \tableofcontents~lowast (for
   compatibility with the memoir class).

   Compatibility with KOMA-script and memoir document
   classes.


v1.04 [2012/11/24]^

   A (possibly local) table of contents can be labeled:

       \tableofcontents \label{toc:1}

   and reproduced elsewhere in the document (with a possibly
   completely different layout):

       \tableofcontents \ref{toc:1}


v1.02 [2012/11/18]^

   Initial version.

\end{jfverbatim}
\end{multicols}
\endgroup  % group for modified verbatim printing of the changes log

\makeatletter
    \let\check@percent\original@check@percent
\makeatother

\small

\ifnum\ForEnglish=1
\section{Implementation}
\fi

\ifnum\ForDeutsch=1
\section{Ausführung}
\fi

\indent % !!!!!!!!!!!!!!!!! Lundi 09 mars 2015 à 09:32:22
% PUTAIN DE BORDEL DE MERDE AVEC CES \trivlist
% il faut faire un paragraphe après \section sinon pas d'espacement
% vertical en sortie de blocs macrocode. Pas évident à trouver, vu que
% je customisais différentes choses qui pouvaient affecter macrocode.

% 9 mars 2015
% Pour rappel on avait dans le préambule:
% \def\MacroFont{\ttfamily\small\hyphenchar\font45 \baselineskip11pt\relax}
% ce qui donne donc le \macro@font qui sera utilisé.



\StopEventually{\normalsize
  \ifnum\NoSourceCode=1
   \ifnum\ForEnglish=1
     \texttt{\parindent 0pt\rightskip 1cm minus 1cm
     This documentation has been compiled without inclusion of the source
     code. To produce the English documentation with source code included:\endgraf
     \ \ \ \ run etex on etoc.dtx or etoc.ins to produce etoc.tex,\endgraf
     \ \ \ \ then four times latex on etoc.tex, then dvipdfmx on etoc.dvi.\endgraf
     \medskip
     To produce the German documentation with source code included, run etex on
     etoc.dtx or etoc.ins to produce etoc-DE.tex, then edit etoc-DE.tex
     to set \string\NoSourceCode\space to 0, and run latex thrice on etoc-DE.tex
     then dvipdfmx on etoc-DE.dvi\endgraf
     \medskip
     (ignore dvipdfmx warnings, or, in case of problems caused by an old version
     of dvipdfmx, set \string\Withdvipdfmx\space to 0 in etoc.tex or
     etoc-DE.tex, to compile with pdflatex)\endgraf }% 
   \fi
   \ifnum\ForDeutsch=1
     \texttt{\hyphenchar\font-1
     \parindent 0pt\rightskip 0.5cm minus 0.5cm \selectlanguage{ngerman}%
     Diese Dokumentation wurde ohne Einbeziehung des Quellcodes erstellt. Um 
     die englische Dokumentation mit dem Quellcode zu produzieren, ist
     einzubeziehen: \endgraf  
     \ \ \ \ kompilieren etex mit etoc.dtx oder etoc.ins, um etoc.tex zu
     produzieren, \endgraf 
     \ \ \ \ dann viermal latex mit etoc.tex, dann dvipdfmx mit etoc.dvi.\endgraf
     \medskip 
     Um die deutsche Dokumentation mit Einbeziehung des Quellcodes zu erstellen,
     ist zu kompilieren etex mit etoc.dtx oder etoc.ins, um etoc-DE.tex zu 
     erzeugen, dann ist \string\NoSourceCode\space in etoc-DE.tex auf 0 zu 
     setzen, dann ist latex dreimal mit etoc-DE.tex laufen zu lassen, dann 
     dvipdfmx mit etoc-DE.dvi.\endgraf 
     \medskip
     (Ignorieren Sie dvipdfmx-Warnungen oder, im Falle von Problemen mit einer 
     alten Version von dvipdfmx, setzen Sie \string\Withdvipdfmx\space auf 0 in
     etoc.tex oder etoc-DE.tex um dann pdflatex laufen zu lassen.)\endgraf }% 
   \fi
  \fi
\end{document}}


% November 2012
% I don't want to have to type at this location (far from the top of the
% file) explicitly the package version or version date, as it is
% inconvenient to have to remember to do this when updating the package.
% Also, I prefer not to add macros to the |.sty| file giving the package
% date, name, or version. So I extracted this from the real macrocode
% environment (leaving out the \init@crossref.)

\makeatletter
\begingroup
\topsep\MacrocodeTopsep
\trivlist\parskip\z@\item[]
\macro@font
\leftskip\@totalleftmargin  \advance\leftskip\MacroIndent
\rightskip\z@  \parindent\z@  \parfillskip\@flushglue
\global\@newlistfalse \global\@minipagefalse
\ifcodeline@index
  \everypar{\global\advance\c@CodelineNo\@ne
  \llap{\theCodelineNo\ \hskip\@totalleftmargin}}%
\fi
\string\NeedsTeXFormat\string{LaTeX2e\string}\par
\string\ProvidesPackage\string{etoc\string}\par
\noindent\space [\etocpkgdate\space\etocpkgversion\space\etocpkgdescription]\par
\nointerlineskip
\global\@inlabelfalse
\endtrivlist
\endgroup
\makeatother

% The catcode hackery next is to avoid to have <*package> to be listed
% in the commented source code...
% (c) 2012/11/19 jf burnol ;-)

\MakePercentIgnore

%
% \catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11
% \let</none>\relax
% \def<*package>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12}
%
%</none>
%<*package>
%    \begin{macrocode}
\RequirePackage{multicol}
\DeclareOption*{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}}
\ProcessOptions\relax
%    \end{macrocode}
% |1.08| suppresses |\ifEtoc@part| and defines |\ifEtoc@skipprefix|. It
% also defines |\etocglobaldefs|, |\etoclocaldefs| and |\Etoc@global|.
%    \begin{macrocode}
\newtoks\Etoc@toctoks
\def\Etoc@par{\par}
\def\etocinline{\def\Etoc@par{}}
\let\etocnopar\etocinline
\def\etocdisplay{\def\Etoc@par{\par}}% 1.07m 2015/01/23
%    \end{macrocode}
% |\etocglobaldefs| should be used only for special things such as TOC as a
% table; it should be put in a group to limit its scope. If used in the
% preamble, it must come \emph{after} |tableof| if the later is loaded too.
%    \begin{macrocode}
\let\Etoc@global\@empty              % 1.08 2015/03/10
\def\etocglobaldefs{\let\Etoc@global\global\let\tof@global\global}
\def\etoclocaldefs {\let\Etoc@global\@empty\let\tof@global\@empty}
\newif\ifEtoc@jj  % book
\newif\ifEtoc@j   % part  
\newif\ifEtoc@    % chapter
\newif\ifEtoc@i   % section
\newif\ifEtoc@ii  % subsection
\newif\ifEtoc@iii % subsubsection
\newif\ifEtoc@iv  % paragraph
\newif\ifEtoc@v   % subparagraph
\newif\ifEtoc@number
\newif\ifEtoc@hyperref
\newif\ifEtoc@parskip   % 1.07d
\newif\ifEtoc@tocwithid
\newif\ifEtoc@standard
\newif\ifEtoc@skipprefix % 1.08
\newif\ifEtoc@isfirst    % 1.08
\newif\ifEtoc@localtoc
\newif\ifEtoc@skipthisone
\newif\ifEtoc@stoptoc
\newif\ifEtoc@notactive
\newif\ifEtoc@mustclosegroup
\def\etoc@{\etoc@}
%    \end{macrocode}
% |1.07g| uses a second counter; this could be avoided, but ok, let's not be
% that strict. 
%    \begin{macrocode}
\newcounter{etoc@tocid}
\newcounter{etoc@tocdepth}% 1.07g
%    \end{macrocode}
% |2015/03/08| Why do I use |jj| in the flags and |minustwo| here? and
% is there an entity full of forgiveness out there to save my soul even
% if taking into consideration my use of single and doubled |@|'s ?
% Although I desperately need to waste time I miraculously decided not
% to change everything today and thus the somewhat dispendious set-up
% below is maintained.
%    \begin{macrocode}
\@ifclassloaded{memoir}{\def\Etoc@minf{-\thr@@}}{\def\Etoc@minf{-\tw@}}
\def\Etoc@@minustwo@@{-\tw@}
\let\Etoc@@minusone@@\m@ne
\let\Etoc@@zero@@    \z@
\let\Etoc@@one@@     \@ne
\let\Etoc@@two@@     \tw@
\let\Etoc@@three@@   \thr@@
\chardef\Etoc@@four@@ 4
\chardef\Etoc@@five@@ 5
\chardef\Etoc@@six@@  6
\let\Etoc@localtop\Etoc@@minustwo@@
\def\Etoc@@minustwo@{minustwo}
\def\Etoc@@minusone@{minusone}
\def\Etoc@@zero@    {zero}
\def\Etoc@@one@     {one}
\def\Etoc@@two@     {two}
\def\Etoc@@three@   {three}
\def\Etoc@@four@    {four}
\def\Etoc@@five@    {five}
%    \end{macrocode}
% |1.07g|.
%    \begin{macrocode}
\expandafter\def\csname Etoc@-3@@\endcsname {-\thr@@}
\expandafter\let\csname Etoc@-2@@\endcsname \Etoc@@minustwo@@
\expandafter\let\csname Etoc@-1@@\endcsname \Etoc@@minusone@@
\expandafter\let\csname Etoc@0@@\endcsname  \Etoc@@zero@@
\expandafter\let\csname Etoc@1@@\endcsname  \Etoc@@one@@
\expandafter\let\csname Etoc@2@@\endcsname  \Etoc@@two@@
\expandafter\let\csname Etoc@3@@\endcsname  \Etoc@@three@@
\expandafter\let\csname Etoc@4@@\endcsname  \Etoc@@four@@
\expandafter\let\csname Etoc@5@@\endcsname  \Etoc@@five@@
\expandafter\let\csname Etoc@6@@\endcsname  \Etoc@@six@@
\let\Etoc@all@@   \Etoc@@five@@
\let\Etoc@none@@  \Etoc@minf   
%    \end{macrocode}
% Versions earlier than |1.08| did |\Etoc@newlevel| in a quite
% embarrassing way with an |\edef|.
%    \begin{macrocode}
\let\Etoc@levellist\@empty
\def\Etoc@newlevel #1%
{\expandafter\def\expandafter\Etoc@levellist\expandafter
        {\Etoc@levellist\Etoc@levellist@elt #1}%
}
\def\etocsetlevel#1#2{%
 \expandafter\Etoc@newlevel\csname l@#1\endcsname
 \ifcase#2\relax
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@zero@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@zero@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@one@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@one@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@two@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@two@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@three@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@three@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@four@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@four@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@five@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@five@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@six@@
   \else
   \ifnum#2=\m@ne
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minusone@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minusone@
   \else
   \ifnum#2=-\tw@
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minustwo@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minustwo@
   \else
       \PackageWarning{etoc}
         {unexpected value `#2' in \string\etocsetlevel.^^J%
          Should be -2,-1, 0, 1, 2, 3, 4, 5, or 6. Set to 6 (=ignored)}%
       \expandafter\let\csname Etoc@#1@@\endcsname\Etoc@@six@@
\fi\fi\fi}
\etocsetlevel{book}{-2}
\etocsetlevel{part}{-1}
\etocsetlevel{chapter}{0}
\etocsetlevel{section}{1}
\etocsetlevel{subsection}{2}
\etocsetlevel{subsubsection}{3}
\etocsetlevel{paragraph}{4}
\etocsetlevel{subparagraph}{5}
%    \end{macrocode}
% The first two parameters of |\Etoc@et@hop| are exchanged in |1.08|
% compared to earlier versions; this is in relation to changes done in
% |\Etoc@etoccontentsline|.
%    \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{parskip}{\Etoc@parskiptrue}{}%
\@ifpackageloaded{hyperref}{\Etoc@hyperreftrue
                            \def\Etoc@et@hop#1#2#3#4#5{#2{#3}{#4}{#5}#1}%
                            \long\def\Etoc@gobblesixorfive#1#2#3#4#5#6{}}
                           {\def\Etoc@et@hop#1#2#3#4{#2{#3}{#4}#1}%
                            \long\def\Etoc@gobblesixorfive#1#2#3#4#5{}}%
}
%    \end{macrocode}
% |2015/03/08| One has to be careful about the |Etoc@end@<level>| user
% defined macros which may close groups. This has always been the reason
% for the |\global|'s here and elsewhere.
%
% |1.08| uses |\Etoc@level| rather than a |#1| which used to be anyhow always
% the |\Etoc@tmp|. Now |\Etoc@level| is what was called formerly |\Etoc@tmp|
% in |\Etoc@etoccontentsline|.
%    \begin{macrocode}
\def\Etoc@setflags {%
  \ifcase \Etoc@level
      \global\Etoc@vfalse
      \global\Etoc@ivfalse
      \global\Etoc@iiifalse
      \global\Etoc@iifalse
      \global\Etoc@ifalse
      \global\Etoc@true
  \or
      \global\Etoc@vfalse
      \global\Etoc@ivfalse
      \global\Etoc@iiifalse
      \global\Etoc@iifalse
      \global\Etoc@itrue
  \or
      \global\Etoc@vfalse
      \global\Etoc@ivfalse
      \global\Etoc@iiifalse
      \global\Etoc@iitrue
  \or
      \global\Etoc@vfalse
      \global\Etoc@ivfalse
      \global\Etoc@iiitrue
  \or
      \global\Etoc@vfalse
      \global\Etoc@ivtrue
  \or
      \global\Etoc@vtrue
  \else
%    \end{macrocode}
% |2015/03/08| I move up the common assignments.
%    \begin{macrocode}
    \global\Etoc@vfalse
    \global\Etoc@ivfalse
    \global\Etoc@iiifalse
    \global\Etoc@iifalse
    \global\Etoc@ifalse
    \global\Etoc@false
    \ifnum\Etoc@level=\m@ne
      \global\Etoc@jtrue
    \else
      \global\Etoc@jfalse
      \global\Etoc@jjtrue
    \fi
  \fi}
%    \end{macrocode}
% |1.08| This was originally in |\Etoc@etoccontentsline|, intermixed
% with the definitions of |\Etoc@contents| and |\Etoc@prefix|. Separated
% here for clarity of code. One has to be careful that this may close
% groups. The conditionals are all global. The |\Etoc@level| has been
% |\global\let| to a |\chardef| variable. The final |\else| of the
% |\ifcase| assumes none of the |\Etoc@end@..| routines modify it,
% naturally.
%    \begin{macrocode}
\def\Etoc@doends {%  
    \ifcase \Etoc@level
        \ifEtoc@v  \Etoc@end@five\fi
        \ifEtoc@iv \Etoc@end@four\fi
        \ifEtoc@iii\Etoc@end@three\fi
        \ifEtoc@ii \Etoc@end@two\fi
        \ifEtoc@i  \Etoc@end@one\fi
    \or
        \ifEtoc@v  \Etoc@end@five\fi
        \ifEtoc@iv \Etoc@end@four\fi
        \ifEtoc@iii\Etoc@end@three\fi
        \ifEtoc@ii \Etoc@end@two\fi
    \or
        \ifEtoc@v  \Etoc@end@five\fi
        \ifEtoc@iv \Etoc@end@four\fi
        \ifEtoc@iii\Etoc@end@three\fi
    \or
        \ifEtoc@v \Etoc@end@five\fi
        \ifEtoc@iv\Etoc@end@four\fi
    \or 
        \ifEtoc@v \Etoc@end@five\fi 
    \or 
    \else
      \ifEtoc@v  \Etoc@end@five \fi
      \ifEtoc@iv \Etoc@end@four \fi
      \ifEtoc@iii\Etoc@end@three\fi
      \ifEtoc@ii \Etoc@end@two  \fi
      \ifEtoc@i  \Etoc@end@one  \fi
      \ifEtoc@   \Etoc@end@zero \fi
      \ifnum \Etoc@level =-\tw@
        \ifEtoc@j \Etoc@end@minusone\fi
      \fi
    \fi
}
%    \end{macrocode}
% Heart of \etoc hack into execution of |.toc| file. It MUST be the case
% that the file contains |\contentsline {<unit>}...| instructions, with
% the standard meaning of executing |\l@unit| (the hyperref
% modifications are taken into account). It is the various |\l@unit|'s
% which are (locally) |\let| to |\Etoc@lxyz| and it is |\Etoc@lxyz|
% which does the parsing of the arguments in order to extract name,
% number and page number. Once they are obtained, via the execution of
% this indirectly hacked |\contentsline|, the code executes the
% |\Etoc@prefix| and |\Etoc@contents| corresponding to that unit level,
% according to the user |\etocsetstyle| declarations. Before that the
% begin part is executed when \etoc first encounters that level
% coming from a higher one and the end part will be executed when
% hitting a more important level.
%
% |\etocskipfirstprefix| was already part of the very first release of
% \etoc. Up to |1.07n| it was just an elegant |\@thirdofthree| possibly
% executed just before a |\@firstoftwo{\Etoc@swa{#1}}{\Etoc@swb{#1}}|
% line. But this made it impossible for me to execute things afer the
% |begin| parts.
%
% Executing stuff before |begin| is now a potential problem because the user
% can close some group in the |begin| code (this was in fact impossible in
% versions |<1.08| because this would have erased the definitions of
% |\Etoc@contents| and |\Etoc@prefix|). Thus I am not so free now to define
% things before execution of begin, if I allow people to close a group
% therein, except if I make them global.
%
% The mechanism of |\etocskipfirstprefix| made it impossible to add
% anything at the end of the |begin| codes. Thus I changed it in |1.08|
% to simply work with a (global) boolean flag. This gives user the
% freedom to use |\etocskipfirstprefix| anywhere in the |begin| code and
% it made room for a delimited macro I called |\etoconlyonfirst|. But
% then I dropped it in favor of definition of the |\etociffirst|
% conditional.
%
% Macros |\Etoc@swa| and |\Etoc@swb| which did the |\Etoc@et@hop| thing have
% been suppressed, their effect is incorporated to the end of
% |\Etoc@etoccontentsline|.
%    \begin{macrocode}
\def\etocskipfirstprefix {\global\Etoc@skipprefixtrue }
%    \end{macrocode}
% |2015/03/08| Let's record that |\Etoc@level| used to be called
% |\Etoc@tmp| in versions earlier than |1.08| (and |\Etoc@tmp| is used
% in the completely different ulterior |\Etoc@lxyz| context). The code
% sets it for example to be |\Etoc@section@@| which has been let by
% |\etocsetlevel| to |\@ne|, thus is always self-terminating in
% |\ifnum..\fi| contexts.
%    \begin{macrocode}
\def\Etoc@etoccontentsline #1{%
  \global\expandafter\let\expandafter\Etoc@level\csname Etoc@#1@@\endcsname
  \Etoc@skipthisonefalse
  \ifnum\Etoc@level=\Etoc@@six@@
      \Etoc@skipthisonetrue
  \else
    \ifEtoc@localtoc
      \let\Etoc@next\relax
      \ifEtoc@stoptoc 
        \Etoc@skipthisonetrue 
      \fi
      \ifnum\Etoc@level<\Etoc@localtop 
        \def\Etoc@next{\global\Etoc@stoptoctrue}%
        \Etoc@skipthisonetrue
      \fi
      \ifEtoc@notactive
        \def\Etoc@next{\Etoc@setflags}%
        \Etoc@skipthisonetrue
      \fi
      \Etoc@next
    \fi
  \fi
  \let\Etoc@next\Etoc@gobblesixorfive
  \ifnum\c@tocdepth<\Etoc@level 
  \else 
  \ifEtoc@skipthisone
  \else
%    \end{macrocode}
% |1.08| New way to handle the compatibility mode. One has to worry
% only for the local tables of contents (in inactive state, which still
% must be parsed for global level flags) but in this case
% |\Etoc@setflags| was done above already. Earlier method proceeded with
% dummy empty line styles.
%    \begin{macrocode}
  \ifEtoc@standard\let\Etoc@next\@thirdofthree
  \else
%    \end{macrocode}
% |2015/03/08| Ever since the first release of \etoc, the code has
% to be careful that the |\Etoc@end@<level>| user defined macros may
% close groups. This is the reason why some assignments have to be done
% globally. The |\let\Etoc@next\Etoc@gobblesixorfive| above could be
% local, because it is used only in case the stuff below is skipped,
% inclusive of |\Etoc@doends| which may close groups.
%
% Versions |1.08| extracts to a separate macro |\Etoc@doends|. Earlier code
% did |\global\let\Etoc@next\relax| but we can now give a default |\relax|
% value to |\Etoc@next| with no need of a |\global| prefix.
%    \begin{macrocode}
    \Etoc@doends
%    \end{macrocode}
% |1.08| the |\Etoc@next| will (possibly) execute the |begin| code,
% \emph{before} |\Etoc@contents| and |\Etoc@prefix| get defined,
% contrarily to what I did in earlier versions. I still reset the flags
% before execution of the |begin| codes (although the flags are not
% supposed to be used therein anyhow).
%
% Also the \meta{begin} code does |\Etoc@isfirsttrue|.
%    \begin{macrocode}
    \let\Etoc@next\@empty
    \Etoc@global\Etoc@isfirstfalse
%    \end{macrocode}
% |2015/03/08| If my naming scheme had not been so baroque, I could easily do
% things in a more concise way here...
%    \begin{macrocode}
    \ifcase\Etoc@level
        \ifEtoc@\else    \def\Etoc@next{\Etoc@begin@zero}\fi
    \or
        \ifEtoc@i\else   \def\Etoc@next{\Etoc@begin@one}\fi
    \or
        \ifEtoc@ii\else  \def\Etoc@next{\Etoc@begin@two}\fi
    \or
        \ifEtoc@iii\else \def\Etoc@next{\Etoc@begin@three}\fi
    \or 
        \ifEtoc@iv\else  \def\Etoc@next{\Etoc@begin@four}\fi
    \or 
        \ifEtoc@v\else   \def\Etoc@next{\Etoc@begin@five}\fi
    \else
      \ifnum\Etoc@level=\m@ne
        \ifEtoc@j\else   \def\Etoc@next{\Etoc@begin@minusone}\fi
      \else
        \ifEtoc@jj\else  \def\Etoc@next{\Etoc@begin@minustwo}\fi
      \fi
    \fi
    \Etoc@setflags
    \Etoc@next
    \let\Etoc@next\@empty
%    \end{macrocode}
% |1.08|:
% \begin{enumerate}
% \item  separates the definition of |\Etoc@prefix| and
% |\Etoc@contents| from the execution of the |end| parts. And it does
% the definition with some |\csname|'s.
%
% \item implements |\etocskipfirstprefix| with a boolean, this is less slick
% but more flexible than the earlier method.
%
% \item defines the |\etociffirst| conditional.
%
% \item has |\Etoc@level| rather than |\Etoc@tmp| and thus we can dispense
% with the |\ifEtoc@part| switch as we will be able to test the equality
% |\Etoc@level=-1| inside of |\Etoc@lxyz|.
% 
% \item adds the |\Etoc@global| prefix.
% \end{enumerate}
%    \begin{macrocode}
    \Etoc@global\expandafter\def\expandafter\Etoc@prefix\expandafter
        {\csname Etoc@prefix@\csname Etoc@#1@\endcsname\endcsname }%
    \Etoc@global\expandafter\def\expandafter\Etoc@contents\expandafter
        {\csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname }%
    \ifEtoc@skipprefix \Etoc@global\let\Etoc@prefix\@empty\fi
    \global\Etoc@skipprefixfalse
  \fi\fi\fi
%    \end{macrocode}
% |1.08| modifies the ending to not use the |\Etoc@swa| and |\Etoc@swb|
% things. With this version, the |\Etoc@next| here is only to gobble
% everything if it has to (or gobble only the \etoc things, when in
% compatibility mode).
%
% For the record we don't do |\csname l@#1\endcsname| mainly because
% hyperref patches |\contentsline|. 
% 
% The location where |\Etoc@savedcontentsline| is |\let| to
% |\contentsline| has been moved with release |1.08| to before the
% title as set by |\etocsettoctyle|, thus it is now possible to open a
% tabular in this part. And with the |\Etoc@global| prefix the user may
% opt for global definitions of |\etocname| and the like, thus use
% freely |&| and other group closing things. Also, some care has been
% put into doing only expandable things after expansion of the
% \meta{prefix} and \meta{contents} parts of a sectioning unit style.
%    \begin{macrocode}
  \Etoc@next
  \Etoc@et@hop{\Etoc@prefix\Etoc@contents}{\Etoc@savedcontentsline{#1}}%
}
%    \end{macrocode}
% |2013/03/07|:
%
% Up to |1.06| \etoc defined only \csa{etocname}, \csa{etocnumber} and
% \csa{etocpage}. The |hyperref| added data is recycled in the simplest manner,
% prefixing it with \csa{leavevmode}. The included \csa{Hy@tocdestname} is left
% unexpanded. We have to spend some time with delimited macros to
% dis-entangle the |.toc| data, and reconstruct the possible |hyperref|
% data. If
% the page number is not hyperlinked, \csa{etocpage} does \emph{not} add the
% link found possibly in the name.
%
% Then |1.07| added \csa{etocthename}, \csa{etocthenumber}, \csa{etocthepage}
% which are left fragile and do not have the links data, and
% \csa{etoclink}\marg{linkname} which is robust and reconstructs an arbitrarily
% named link. 
%
% A need (for things like building up a token list to be used in a
% |tikzpicture|) arose later to have some form of the link which could be
% saved by a simple command like one can do
% |\global\let\lastname\etocthename|, and avoid having to manipulate
% \csa{Hy@tocdestname}. So |1.07f| adds \csa{etocthelinkedname},
% \csa{etocthelinkednumber}, \csa{etocthelinkedpage}, \csa{etocthelink}: they
% use \csa{hyperlink} with an expanded \csa{Hy@tocdestname}.
%
% |1.08a|: I delayed from |2013/03/07| to release |1.08a| of |2015/03/13| the
% obvious decision to convert \csa{etocname}, etc ... to be the robust
% versions of \csa{etocthelinkedname}, etc ..., for sentimental reason. But
% the earlier variants contained the hyperref destination in unexpanded form.
% 
% |1.07f| also adds \csa{leavevmode} to \csa{etoclink} which
% should have been done earlier, as it was included in \csa{etocname} etc...
%
% attention,  \csa{@namedef}|{A}{B}| and not \csa{@namedef}|{A} {B}| !!
% on the other hand this gives a simple way to insert a space as the first
% token in the paramaters. For \csa{Etoc@again} (which appears later in the
% code), a \csa{@firstofone} construct is however the simplest of all.
%
% |2015/03/09|: |1.08| adds |\Etoc@global| prefix.
%
% |2015/03/13|: |1.08a| drops the original constructions of |\etocname| etc...
% which contained an unexpanded hyperref destination.
%    \begin{macrocode}
\def\Etoc@lxyz #1#2{% 
    \Etoc@global\@namedef {etoclink }{\leavevmode}%        fall-back
    \Etoc@global\let\etocthelink       \@empty  %        fall-back
    \Etoc@global\def\etocthename       {#1}%  (if link, will be removed later)
    \Etoc@global\def\etocthelinkedname {#1}%  will probably get redefined 
    \Etoc@getthepage #2\etoc@ % defines \etocthelinkedpage (and \etoclink)
    \Etoc@getnb #1\relax\relax\etoc@  % gets number *and* name, and \etoclink
    \ifEtoc@number\else               
      \ifnum\Etoc@level=\m@ne
        \Etoc@getit #1\hspace\relax\etoc@   % additional job for parts
      \fi
    \fi
    \Etoc@global\expandafter\let\csname etocname \endcsname\etocthelinkedname
    \Etoc@global\expandafter\let\csname etocnumber \endcsname\etocthelinkednumber
    \Etoc@global\expandafter\let\csname etocpage \endcsname\etocthelinkedpage
    }
%    \end{macrocode}
% |1.08| adds the |\Etoc@global|'s.
%    \begin{macrocode}
\def\Etoc@getthepage #1{%
  \let\Etoc@next\Etoc@getthepage@nohyp
  \ifEtoc@hyperref\ifx #1\hyper@linkstart
    \let\Etoc@next\Etoc@getthepage@hyp
  \fi\fi
  \Etoc@next #1%
}
\def\Etoc@getthepage@nohyp #1\etoc@ {%
    \Etoc@global\def\etocthepage       {#1}%
    \Etoc@global\def\etocthelinkedpage {#1}%
}
%    \end{macrocode}
% |1.07k| corrects a bug here with an extra space before |##1| in 
% |\@namedef{etoclink } ##1|. In 99.99\% of use cases however, the
% macro gets redefined at a later stage, thus the bug did not show.
%
% |1.07n| replaces use of |\toks@| by macro |\Etoc@tmp|. Thus, the user has
% the (not so recommended) possibility to use |\toks@| in the styles, even to
% store information whose scope extends beyond the execution of each
% |\contentsline|.
%
% |1.08| adds the |\Etoc@global|'s.
%    \begin{macrocode}
\def\Etoc@getthepage@hyp #1#2#3#4#5\etoc@ {%
  \Etoc@global\@namedef{etoclink }##1{\leavevmode #1{#2}{#3}{##1}#5}%
  \Etoc@global\def\etocthepage {#4}%
  \edef\Etoc@tmp {{#3}}%
  \Etoc@global\expandafter\def\expandafter\etocthelinkedpage\expandafter
    {\expandafter\hyperlink \Etoc@tmp{#4}}%
}
%
\def\Etoc@getnb #1{%
  \let\Etoc@next\Etoc@getnb@nohyp
  \ifEtoc@hyperref\ifx #1\hyper@linkstart
    \let\Etoc@next\Etoc@getnb@hyp
  \fi\fi
  \Etoc@next #1%
}
%
\def\Etoc@getit #1{%
  \let\Etoc@next\Etoc@getit@nohyp
  \ifEtoc@hyperref\ifx #1\hyper@linkstart
    \let\Etoc@next\Etoc@getit@hyp
  \fi\fi
  \Etoc@next #1%
}
%    \end{macrocode}
% |1.08| adds the |\Etoc@global|'s.
%    \begin{macrocode}
\def\Etoc@getnb@nohyp #1#2#3\etoc@ {%
    \def\Etoc@getname ##1\relax\relax\etoc@ {%
      \Etoc@global\def\etocthename       {##1}%
      \Etoc@global\def\etocthelinkedname {##1}%
     }%
  \ifx #1\numberline
    \Etoc@global\def\etocthenumber       {#2}%
    \Etoc@global\def\etocthelinkednumber {#2}%
    \Etoc@global\Etoc@numbertrue
    \Etoc@getname #3\etoc@
  \else % then \etocthename and \etocthelinkedname already defined
    \Etoc@global\let\etocthenumber       \@empty
    \Etoc@global\let\etocthelinkednumber \@empty
    \Etoc@global\Etoc@numberfalse
  \fi
}
%    \end{macrocode}
% |1.07n| replaces use of |\toks@| by macro |\Etoc@tmp|. |1.08| adds
% the |\Etoc@global|'s.
%    \begin{macrocode}
\def\Etoc@getnb@hyp #1#2#3#4#5#6\etoc@ {%
         \def\Etoc@getname ##1\relax\relax\etoc@ {%
         \Etoc@global\def\etocthename {##1}%
         \edef\Etoc@tmp   {{#3}}%
         \Etoc@global\expandafter\def\expandafter\etocthelinkedname\expandafter
                              {\expandafter\hyperlink \Etoc@tmp{##1}}%
         }%
         \def\Etoc@getnbr ##1##2##3\etoc@ {%
          \ifx ##1\numberline
            \Etoc@global\def\etocthenumber {##2}%
            \edef\Etoc@tmp   {{#3}}%
            \Etoc@global\expandafter\def\expandafter\etocthelinkednumber
                        \expandafter{\expandafter\hyperlink \Etoc@tmp{##2}}%
            \Etoc@global\Etoc@numbertrue
            \Etoc@getname ##3\etoc@
          \else
            \Etoc@global\let\etocthenumber       \@empty
            \Etoc@global\let\etocthelinkednumber \@empty
            \Etoc@global\Etoc@numberfalse
            \Etoc@global\def\etocthename {#4}%
            \edef\Etoc@tmp   {{#3}}%
            \Etoc@global\expandafter\def\expandafter\etocthelinkedname
                        \expandafter {\expandafter\hyperlink \Etoc@tmp{#4}}%
          \fi
         }%
  \Etoc@global\@namedef {etoclink }##1{\leavevmode #1{#2}{#3}{##1}#5}%
  \Etoc@global\edef\etocthelink ##1{\noexpand\hyperlink {#3}{##1}}%
  \Etoc@getnbr #4\relax\relax\etoc@
}
%    \end{macrocode}
% |1.08| adds the |\Etoc@global|'s.
%    \begin{macrocode}
\def\Etoc@getit@nohyp #1\hspace#2#3\etoc@ {%
    \def\Etoc@getname ##1\hspace\relax\etoc@ {%
       \Etoc@global\def\etocthename       {##1}%
       \Etoc@global\def\etocthelinkedname {##1}%
    }%
  \ifx\relax#2\else 
        \Etoc@global\def\etocthenumber       {#1}%
        \Etoc@global\def\etocthelinkednumber {#1}%
        \Etoc@global\Etoc@numbertrue
        \Etoc@getname #3\etoc@
  \fi
}
%    \end{macrocode}
% |1.07n| replaces use of |\toks@| by macro |\Etoc@tmp|. |1.08| adds
% the |\Etoc@global|'s.
%    \begin{macrocode}
\def\Etoc@getit@hyp #1#2#3#4#5#6\etoc@ {%
    \def\Etoc@getname ##1\hspace\relax\etoc@ {%
       \Etoc@global\def\etocthename {##1}%
       \edef\Etoc@tmp   {{#3}}%
       \Etoc@global\expandafter\def\expandafter\etocthelinkedname
                   \expandafter{\expandafter\hyperlink \Etoc@tmp{##1}}%
    }%
    \def\Etoc@getnbr ##1\hspace##2##3\etoc@ {%
       \ifx\relax##2\else
         \Etoc@global\def\etocthenumber {##1}%
         \edef\Etoc@tmp   {{#3}}%
         \Etoc@global\expandafter\def\expandafter\etocthelinkednumber
                     \expandafter{\expandafter\hyperlink \Etoc@tmp{##1}}%
         \Etoc@global\Etoc@numbertrue
         \Etoc@getname ##3\etoc@
       \fi
    }%
  \Etoc@getnbr #4\hspace\relax\etoc@
}
%    \end{macrocode}
% |1.08a| of |2015/03/12| does the long-postponed thing to let |\etocname|
% etc.. be simply the robust variant of |\etocthelinkedname| etc...
%    \begin{macrocode}
\let\etocthename   \@empty
\let\etocthenumber \@empty
\let\etocthepage   \@empty
\let\etocthelinkedname   \@empty
\let\etocthelinkednumber \@empty
\let\etocthelinkedpage   \@empty
\let\etocthelink   \@empty
\DeclareRobustCommand*{\etocname}  {}
\DeclareRobustCommand*{\etocnumber}{}
\DeclareRobustCommand*{\etocpage}  {}
\DeclareRobustCommand*{\etoclink}  {}
\DeclareRobustCommand*{\etocifnumbered}
   {\ifEtoc@number\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
\expandafter\let\expandafter\etocxifnumbered\csname etocifnumbered \endcsname
%    \end{macrocode}
% |1.08| defines |\etociffirst|
%    \begin{macrocode}
\DeclareRobustCommand*{\etociffirst}
   {\ifEtoc@isfirst\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
\expandafter\let\expandafter\etocxiffirst\csname etociffirst \endcsname
%    \end{macrocode}
% |1.07j| modifies |\Etoc@readtoc|.
%    \begin{macrocode}
\def\Etoc@readtoc {%
  \ifeof \Etoc@tf
  \else
     \read \Etoc@tf to \Etoc@buffer
     \Etoc@toctoks=\expandafter\expandafter\expandafter
       {\expandafter\the\expandafter\Etoc@toctoks\Etoc@buffer}%
     \expandafter\Etoc@readtoc
  \fi
}
%    \end{macrocode}
% |1.07m| moves the reading of the toc file At Begin Document. Needed for
% Babel activated characters.
%    \begin{macrocode}
\Etoc@toctoks {}% (superfluous, but for clarity)
\AtBeginDocument{\IfFileExists{\jobname.toc}
    {{\endlinechar=\m@ne
      \makeatletter
      \newread\Etoc@tf
      \openin\Etoc@tf\@filef@und
      \Etoc@readtoc
      \global\Etoc@toctoks=\expandafter{\the\Etoc@toctoks}%
      \closein\Etoc@tf}}
    {\typeout{No file \jobname.toc.}}}
%    \end{macrocode}
% 1.07d: parskip and |\@nobreakfalse| stuff moved to |\Etoc@tableofcontents|
%    \begin{macrocode}
\def\Etoc@openouttoc{%
  \ifEtoc@hyperref 
    \ifx\hyper@last\@undefined
    \IfFileExists{\jobname .toc}
      {\Hy@WarningNoLine 
         {old toc file detected, not used; run LaTeX again (cheers from etoc)}%
       \global\Etoc@toctoks={}%
      }
      {}%
    \fi
  \fi
  \if@filesw 
   \newwrite \tf@toc 
   \immediate \openout \tf@toc \jobname .toc\relax 
  \fi 
  \global\let\Etoc@openouttoc\empty
}
%    \end{macrocode}
% |1.08| has a new way to handle |\Etoc@standardtrue|.
%
% Also the expansion of |\Etoc@levelist| is moved to inside
% |\Etoc@tableofcontents| as set-up by |\etocsettocstyle|. This opens up
% the possibility for the user to open a group in the title (for example
% start a tabular) which would be closed (by the first |&|) sometime
% later. In combination with |\etocglobaldefs| it will be now much
% easier to typeset TOC as tables with \etoc!
%    \begin{macrocode}
\def\Etoc@toctoc{%
   \global\Etoc@vfalse
   \global\Etoc@ivfalse
   \global\Etoc@iiifalse
   \global\Etoc@iifalse
   \global\Etoc@ifalse
   \global\Etoc@false
   \global\Etoc@jfalse
   \global\Etoc@jjfalse
\the\Etoc@toctoks
\ifEtoc@notactive\else 
  \ifEtoc@v   \Etoc@end@five\fi
  \ifEtoc@iv  \Etoc@end@four\fi
  \ifEtoc@iii \Etoc@end@three\fi
  \ifEtoc@ii  \Etoc@end@two\fi
  \ifEtoc@i   \Etoc@end@one\fi
  \ifEtoc@    \Etoc@end@zero\fi
  \ifEtoc@j   \Etoc@end@minusone\fi
  \ifEtoc@jj  \Etoc@end@minustwo\fi
\fi}
%    \end{macrocode}
% Slightly better coded in |1.08b|. Had some bad experiences with TeX
% conditionals back in 2011/2012 when I started LaTeX programming, and the
% code was a remnant of extra cautious attitude.
%    \begin{macrocode}
\def\etoc@@startlocaltoc#1#2{%
    \ifEtoc@localtoc 
      \ifEtoc@notactive
        \ifnum #1=#2\relax
          \ifEtoc@jj  \Etoc@global\let\Etoc@localtop\Etoc@@minusone@@ \fi
          \ifEtoc@j   \Etoc@global\let\Etoc@localtop\Etoc@@zero@@  \fi
          \ifEtoc@    \Etoc@global\let\Etoc@localtop\Etoc@@one@@   \fi
          \ifEtoc@i   \Etoc@global\let\Etoc@localtop\Etoc@@two@@   \fi
          \ifEtoc@ii  \Etoc@global\let\Etoc@localtop\Etoc@@three@@ \fi
          \ifEtoc@iii \Etoc@global\let\Etoc@localtop\Etoc@@four@@  \fi
          \ifEtoc@iv  \Etoc@global\let\Etoc@localtop\Etoc@@five@@  \fi
          \ifEtoc@v   \Etoc@global\let\Etoc@localtop\Etoc@@six@@   \fi
          \global\Etoc@notactivefalse
          \global\Etoc@vfalse
          \global\Etoc@ivfalse
          \global\Etoc@iiifalse
          \global\Etoc@iifalse
          \global\Etoc@ifalse
          \global\Etoc@false
          \global\Etoc@jfalse
          \global\Etoc@jjfalse
        \fi
      \fi
    \fi
}
\let\etoc@startlocaltoc\@gobble
%    \end{macrocode}
% |1.07g| suppresses the printing of |--unknown etoc ref: run latex again--| as
% sometimes one uses |\localtableofcontents| to prepare something else, and one
% does not want any text output even in intermediate runs.
% 
% Also |1.07g| adds |\etocaftertochook| to help with
% |\invisiblelocaltableofcontents| (and then I did |\etocsetnexttocdepth|).
% |1.07h| makes the hook used by |\etocsetnexttocdepth| private.
%
% |2014/03/14|: |1.08b| suppresses a space token from an unprotected end of
% line at the end after the replacement text of |\etoc@startlocaltoc| (bug
% dating back to |1.03 2012/11/23|). I didn't see it due to the originally
% badly formatted source of |\Etoc@next|.
%    \begin{macrocode}
\def\Etoc@localtableofcontents#1{%
    \edef\Etoc@tmp{#1}%
    \ifnum\Etoc@tmp<\@ne
       \PackageWarning{etoc}%
            {Unknown toc id: run LaTeX to get references right}% 
       \let\Etoc@next\@gobble
    \else
       \let\Etoc@next\@firstofone
    \fi
    \Etoc@next 
    {% 1.08b removes a space token from unprotected line ending
       \edef\etoc@startlocaltoc##1{\noexpand\etoc@@startlocaltoc{##1}{#1}}%
       \Etoc@localtoctrue
       \let\Etoc@localtop\Etoc@@minustwo@@
       \global\Etoc@stoptocfalse
       \global\Etoc@notactivetrue
       \Etoc@tableofcontents
    }%
    \endgroup\ifEtoc@mustclosegroup\endgroup\fi
    \Etoc@aftertochook % 1.07h
    \etocaftertochook % 1.07g
}
%    \end{macrocode}
% |2013/03/07|: I discover a \csa{@namedef} trick to construct the
% \csa{Etoc@again} space delimited macro:\\ 
% |    \@namedef {Etoc@again} {...stuff...}|\\
%  Original version was (copied from analogous stuff in |source2e|):\\
% |    {\def\1{\Etoc@again}\expandafter\gdef\1 {...stuff...}}|\\
% and in the end (now that I think about it) I simply use |\@firstofone|.\par
%    \begin{macrocode}
\def\Etoc@getrefno #1#2\etoc@ {#1}
\def\Etoc@getref #1{\@ifundefined{r@#1}{0}{\expandafter\expandafter\expandafter
          \Etoc@getrefno\csname r@#1\endcsname\relax\etoc@}}
\def\Etoc@ref#1{\Etoc@localtableofcontents{\Etoc@getref{#1}}}
\def\Etoc@label#1{\label{#1}\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
\@firstofone{\def\Etoc@again} {\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
%    \end{macrocode}
% Why |\global| for |\Etoc@notactivefalse|? and not for
% |\Etoc@localtocfalse|. Must think about this, a pity I did not
% document it when I was young and intelligent ...
%    \begin{macrocode}
\def\Etoc@t@bleofcontents{%
 \ifx\Etoc@nexttoken\label
    \def\Etoc@next{\expandafter\Etoc@label\@gobble}%
 \else
 \ifx\Etoc@nexttoken\@sptoken
    \let\Etoc@next\Etoc@again
 \else
 \ifEtoc@tocwithid
    \def\Etoc@next{\Etoc@localtableofcontents{\c@etoc@tocid}}%
 \else
    \ifx\Etoc@nexttoken\ref
       \def\Etoc@next{\expandafter\Etoc@ref\@gobble}%
    \else
       \def\Etoc@next{\Etoc@localtocfalse
                      \global\Etoc@notactivefalse
                      \Etoc@tableofcontents
                      \endgroup
                      \ifEtoc@mustclosegroup\endgroup\fi
                      \Etoc@aftertochook % 1.07h
                      \etocaftertochook % 1.07g 
                      }%
    \fi
 \fi\fi\fi\Etoc@next}
%    \end{macrocode}
% |1.07g| for consistency Etoc@ prefix added.
%    \begin{macrocode}
\def\Etoc@table@fcontents{%
    \refstepcounter{etoc@tocid}% 
    \Etoc@tocwithidfalse
    \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
\def\Etoc@localtable@fcontents{%
    \refstepcounter{etoc@tocid}%
    \addtocontents{toc}{\string\etoc@startlocaltoc{\arabic{etoc@tocid}}}%
    \Etoc@tocwithidtrue
    \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
%    \end{macrocode}
% |1.07g| defines |\etoctableofcontents| to be able to undo the evil and
% brutal doings of some packages with |\tableofcontents|.
%
% |1.08| patches |tableof|'s influence. Version |1.4a| or later of |tableof|
% is needed. 
%    \begin{macrocode}
\let\etocaftertitlehook    \@empty
\let\etocaftercontentshook \@empty
\def\etoctableofcontents{%
   \Etoc@openouttoc
   \Etoc@par
   \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents
%    \end{macrocode}
% No need for tableof extra group level, and furthermore
% it is better to get rid of it if. However I can't do it globally because I
% want to leave open for the user the possibility (whose interest is quasi nil
% however) of using directly |\tableof|, |\tablenotof|, ... and not the only
% reasonable thing which is |\nexttocwithtags{}{}|.
%    \begin{macrocode}
      \let\tof@begingroup\@empty
      \let\tof@endgroup  \@empty
      \def\etoc@startlocaltoc##1{\etoc@@startlocaltoc{##1}{\c@etoc@tocid}}%
      \@ifstar
      {\def\Etoc@aftertitlehook{}\Etoc@table@fcontents}
      {\let\Etoc@aftertitlehook\etocaftertitlehook\Etoc@table@fcontents}}
\let\tableofcontents\etoctableofcontents
\newcommand*\localtableofcontents{%
   \Etoc@openouttoc
   \Etoc@par
   \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents
      \let\tof@begingroup\@empty
      \let\tof@endgroup  \@empty
      \@ifstar
      {\def\Etoc@aftertitlehook{}\Etoc@localtable@fcontents}
      {\let\Etoc@aftertitlehook\etocaftertitlehook\Etoc@localtable@fcontents}}
%    \end{macrocode}
% |1.08| moves earlier the definitions of |\Etoc@savedcontentsline| as
% well as |\Etoc@levellist|. It will thus not be operative to do
% |\etocsetlevel| from inside the title now. But perhaps it will be
% easier to deal with tables.
%
% Also I remove a big |\@firstofone|, and use rather
% |\Etoc@gobbletoetoc@| for the gobbling case.
%
% Also, |1.08| modifies the code to do only expandable things after
% |\Etoc@toctoc|, in order to allow opening of an alignment in the first
% argument and closing in the second. Earlier versions had an
% |\Etoc@@next| initially set to relax after the first |\Etoc@toctoc|. I
% was in 2012/2013 quite uneasy with the TeX conditionals hence wanted
% for safety to move the things for the second invocation of
% |\Etoc@toctoc| after the |\fi\fi\fi|. I could define an |\afterfififi|
% macro, but it should be ok as it is done here.
%    \begin{macrocode}
\long\def\Etoc@gobbletoetoc@ #1\etoc@ {}
\newcommand\etocsettocstyle[2]{%
\def\Etoc@tableofcontents
{%
    \ifnum\c@tocdepth>\Etoc@minf
    \else\expandafter
     \Etoc@gobbletoetoc@ % skip all
    \fi
    \etocbeforetitlehook % 1.07m
    \Etoc@storetocdepth % 1.07g
    \let\Etoc@savedcontentsline\contentsline % moved up here 1.08
    \let\contentsline\Etoc@etoccontentsline 
    \ifEtoc@standard
    \else % moved here from \Etoc@toctoc (1.08)
        \def\Etoc@levellist@elt####1{\let####1\Etoc@lxyz}%
        \Etoc@levellist
        \let\booknumberline\numberline
        \let\partnumberline\numberline
        \let\chapternumberline\numberline
    \fi
    #1%
    \ifEtoc@parskip\parskip\z@skip\fi %1.07d
    \Etoc@aftertitlehook
    \Etoc@toctoc
            \ifEtoc@tocwithid\else
              \ifEtoc@localtoc
                \ifEtoc@notactive
                  \Etoc@localtocfalse
                  \global\Etoc@notactivefalse
                  \Etoc@toctoc
                \fi
              \fi
            \fi
    \etocaftercontentshook
    #2\@nobreakfalse % 1.07d: \@nobreakfalse moved here
    \Etoc@resettocdepth  % 1.07g. moved here from before #2 by 1.08
%    \end{macrocode}
% |1.08|: necessary if |tableof 1.4a| has been used in global mode and thus
% was forced to modify globally |\contentsline|. The collateral effect is that
% \etoc is now forced to reset globally |\contentsline|.
%    \begin{macrocode}
    \ifx\Etoc@global\global\ifx\tof@finish\@empty\else
        \global\let\contentsline\Etoc@savedcontentsline
    \fi\fi
    \@gobble\etoc@ 
}% end of \Etoc@tableofcontents definition by \etocsettocstyle
}
%    \end{macrocode}
% |2015/03/09| |1.08| hacks the begin parts to update therein the
% |\ifEtoc@isfirst| flag.
%    \begin{macrocode}
\def\etocsetstyle{\Etoc@standardfalse\etoc@setstyle}
\long\def\etoc@setstyle#1#2#3#4#5{%
     \long\expandafter\def
     \csname Etoc@begin@\csname Etoc@#1@\endcsname\endcsname
                     {#2\Etoc@global\Etoc@isfirsttrue}%
     \long\expandafter\def
     \csname Etoc@prefix@\csname Etoc@#1@\endcsname\endcsname   {#3}%
     \long\expandafter\def
     \csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname {#4}%
     \long\expandafter\def
     \csname Etoc@end@\csname Etoc@#1@\endcsname\endcsname      {#5}%
}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocfontminustwo {\normalfont \LARGE \bfseries}
\def\etocfontminusone {\normalfont \large \bfseries}
\def\etocfontzero     {\normalfont \large \bfseries}
\def\etocfontone      {\normalfont \normalsize \bfseries}
\def\etocfonttwo      {\normalfont \normalsize}
\def\etocfontthree    {\normalfont \footnotesize}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocsepminustwo  {4ex \@plus .5ex \@minus .5ex}
\def\etocsepminusone  {4ex \@plus .5ex \@minus .5ex}
\def\etocsepzero      {2.5ex \@plus .4ex \@minus .4ex}
\def\etocsepone       {1.5ex \@plus .3ex \@minus .3ex}
\def\etocseptwo       {.5ex \@plus .1ex \@minus .1ex}
\def\etocsepthree     {.25ex \@plus .05ex \@minus .05ex}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocbaselinespreadminustwo {1}
\def\etocbaselinespreadminusone {1}
\def\etocbaselinespreadzero     {1}
\def\etocbaselinespreadone      {1}
\def\etocbaselinespreadtwo      {1}
\def\etocbaselinespreadthree    {.9}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocminustwoleftmargin  {1.5em plus 0.5fil}
\def\etocminustworightmargin {1.5em plus -0.5fil}
\def\etocminusoneleftmargin  {1em}
\def\etocminusonerightmargin {1em}
\def\etoctoclineleaders 
        {\hbox{\normalfont\normalsize\hb@xt@2ex {\hss.\hss}}}
\def\etocabbrevpagename {p.~}
%    \end{macrocode}
% Versions earlier than |1.08b| (and since |v1.05 2012/12/01|) defined
% \csa{etocpartname} (for use by \etoc's own line styles) to expand to
% \csa{partname}. But this didn't make sense in the context for example of
% |babel| and |frenchb|, because \csa{frenchpartname} does things depending on
% the current value of the counter |part|. The code in recent |frenchb| (but
% not yet |v2.5a| when |\etocpartname| was introduced) constructs control
% sequences |\ordinali|, etc... If the part counter is zero, this gives
% |\ordinal|. Usually this is not defined, hence no error happens (as it is
% constructed via |\csname|), but under class |memoir| the bug showed up. All
% this to explain that I found out about this long lasting problem only on
% |2015/03/14|. Probably a sign that \etoc's own line styles are rarely
% used...
%    \begin{macrocode}
\def\etocpartname       {Part}% modified 1.08b
\def\etocbookname       {Book}
%    \end{macrocode}
% placeholder for comments
% The macro \csa{etocdefaultlines} was initially called \csa{etoctoclines}. Now
% \csa{etoctoclines} just does \csa{Etoc@standardfalse}.
% Version |1.07e| has rewritten entirely the stuff related to penalties and
% \csa{addvspace}, as this was not satisfactory in the earlier versions, which
% were written at a early stage in the development of the
% package. Actually I am not fully satisfied with these line styles.
%
%    \begin{macrocode}
\def\etocdefaultlines{\Etoc@standardfalse % 
%% `book':
\etoc@setstyle{@minustwo}
  {\addpenalty\@M\etocskipfirstprefix}
  {\addpenalty\@secpenalty}
  {\begingroup 
   \etocfontminustwo
   \addvspace{\etocsepminustwo}%
   \parindent \z@ 
   \leftskip  \etocminustwoleftmargin
   \rightskip \etocminustworightmargin
   \parfillskip \@flushglue
   \vbox{\etocifnumbered{\etocbookname\enspace\etocnumber:\quad}{}\etocname
        \baselineskip\etocbaselinespreadminustwo\baselineskip
        \par}%
   \addpenalty\@M\addvspace{\etocsepminusone}%
   \endgroup}
  {}%
%% `part':
\etoc@setstyle{@minusone}
  {\addpenalty\@M\etocskipfirstprefix}
  {\addpenalty\@secpenalty}
  {\begingroup 
   \etocfontminusone
   \addvspace{\etocsepminusone}%
   \parindent \z@ 
   \leftskip  \etocminusoneleftmargin
   \rightskip \etocminusonerightmargin
   \parfillskip \@flushglue
   \vbox{\etocifnumbered{\etocpartname\enspace\etocnumber.\quad}{}\etocname
         \baselineskip\etocbaselinespreadminusone\baselineskip
         \par}%
   \addpenalty\@M\addvspace{\etocsepzero}%
   \endgroup}
  {}%
%% `chapter':
\etoc@setstyle{@zero}
  {\addpenalty\@M\etocskipfirstprefix}
  {\addpenalty\@itempenalty}
  {\begingroup 
   \etocfontzero
   \addvspace{\etocsepzero}%
   \parindent \z@ \parfillskip \@flushglue 
   \vbox{\etocifnumbered{\etocnumber.\enspace}{}\etocname
         \baselineskip\etocbaselinespreadzero\baselineskip
         \par}%
   \endgroup}
  {\addpenalty{-\@highpenalty}\addvspace{\etocsepminusone}}%
%% `section':
\etoc@setstyle{@one}
  {\addpenalty\@M\etocskipfirstprefix}
  {\addpenalty\@itempenalty}
  {\begingroup
   \etocfontone
   \addvspace{\etocsepone}%
   \parindent \z@ \parfillskip \z@ 
   \setbox\z@\vbox{\parfillskip\@flushglue
                   \etocname\par
                   \setbox\tw@\lastbox
                   \global\setbox\@ne\hbox{\unhbox\tw@\ }}%
   \dimen\z@=\wd\@ne
   \setbox\z@=\etoctoclineleaders
   \advance\dimen\z@\wd\z@
   \etocifnumbered
     {\setbox\tw@\hbox{\etocnumber, \etocabbrevpagename\etocpage}}
     {\setbox\tw@\hbox{\etocabbrevpagename\etocpage}}%
   \advance\dimen\z@\wd\tw@
   \ifdim\dimen\z@ < \linewidth
       \vbox{\etocname~%
             \leaders\box\z@\hfil\box\tw@
             \baselineskip\etocbaselinespreadone\baselineskip
             \par}% 1.08b adds the % here
   \else
       \vbox{\etocname~%
             \leaders\copy\z@\hfil\break 
             \hbox{}\leaders\box\z@\hfil\box\tw@
             \baselineskip\etocbaselinespreadone\baselineskip
             \par}% 
   \fi
   \endgroup}
  {\addpenalty\@secpenalty\addvspace{\etocsepzero}}%
%% `subsection':
\etoc@setstyle{@two}
  {\addpenalty\@medpenalty\etocskipfirstprefix} 
  {\addpenalty\@itempenalty}
  {\begingroup
   \etocfonttwo
   \addvspace{\etocseptwo}%
   \parindent \z@ \parfillskip \z@
   \setbox\z@\vbox{\parfillskip\@flushglue
                   \etocname\par\setbox\tw@\lastbox
                   \global\setbox\@ne\hbox{\unhbox\tw@}}%
   \dimen\z@=\wd\@ne
   \setbox\z@=\etoctoclineleaders
   \advance\dimen\z@\wd\z@
   \etocifnumbered
     {\setbox\tw@\hbox{\etocnumber, \etocabbrevpagename\etocpage}}
     {\setbox\tw@\hbox{\etocabbrevpagename\etocpage}}%
   \advance\dimen\z@\wd\tw@
   \ifdim\dimen\z@ < \linewidth
       \vbox{\etocname~%
             \leaders\box\z@\hfil\box\tw@
             \baselineskip\etocbaselinespreadtwo\baselineskip
             \par}%
   \else
       \vbox{\etocname~%
             \leaders\copy\z@\hfil\break 
             \hbox{}\leaders\box\z@\hfil\box\tw@
             \baselineskip\etocbaselinespreadtwo\baselineskip
             \par}%
   \fi
   \endgroup}
  {\addpenalty\@secpenalty\addvspace{\etocsepone}}%
%% `subsubsection':
\etoc@setstyle{@three}
  {\addpenalty\@M
   \etocfontthree
   \vspace{\etocsepthree}%
   \noindent
   \etocskipfirstprefix}
  {\allowbreak\,--\,}
  {\etocname}
  {.\hfil
    \begingroup
     \baselineskip\etocbaselinespreadthree\baselineskip
     \par
    \endgroup
   \addpenalty{-\@highpenalty}}%
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\etoc@setstyle{@four}{}{}{}{}%
\etoc@setstyle{@five}{}{}{}{}%
} % end of \etocdefaultlines!
%    \end{macrocode}
% The |\etocinnertopsep| default value is too big as well as |\etocbelowtocskip|
% and |\etocabovetocskip|, I guess, but if I am remember correctly I chose them
% to mimick the standard TOC spacings in |article| class.
%    \begin{macrocode}
\def\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} 
\def\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex}
\def\etoccolumnsep{2em}
\def\etocmulticolsep{0ex}
\def\etocmulticolpretolerance{-1}
\def\etocmulticoltolerance{200}
\def\etocdefaultnbcol{2}
\def\etocinnertopsep{2ex}
%    \end{macrocode}
% |1.07i| adds a |\nobreak| before the |\etocinnertopsep| and a test of vertical
% mode to see if truly adding a |\par| is a reasonable idea, in the
% case of single-column mode.
%
% |1.08b| revisits this old code written perhaps at a time I didn't know about
% |\expandafter| !
%    \begin{macrocode}
\newcommand\etocmulticolstyle[2][\etocdefaultnbcol]{%
\etocsettocstyle
   {\let\etocoldpar\par
    \addvspace{\etocabovetocskip}%
    \ifnum #1>\@ne
          \expandafter\@firstoftwo
    \else \expandafter\@secondoftwo
    \fi
    {\multicolpretolerance\etocmulticolpretolerance
    \multicoltolerance\etocmulticoltolerance
    \setlength{\columnsep}{\etoccolumnsep}%
    \setlength{\multicolsep}{\etocmulticolsep}%
    \begin{multicols}{#1}[#2\etocoldpar\addvspace{\etocinnertopsep}]}
    {#2\ifvmode\else\begingroup\interlinepenalty\@M\parskip\z@skip
                    \@@par\endgroup
       \fi
       \nobreak\addvspace{\etocinnertopsep}%
       \pretolerance\etocmulticolpretolerance
       \tolerance\etocmulticoltolerance}%
   }%
   {\ifnum #1>\@ne
          \expandafter\@firstofone
    \else \expandafter\@gobble
    \fi
    {\end{multicols}}%
    \addvspace{\etocbelowtocskip}}%
}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocinnerbottomsep{3.5ex}
\def\etocinnerleftsep{2em}
\def\etocinnerrightsep{2em}
\def\etoctoprule{\hrule}
\def\etocleftrule{\vrule}
\def\etocrightrule{\vrule}
\def\etocbottomrule{\hrule}
\def\etoctoprulecolorcmd{\relax}
\def\etocbottomrulecolorcmd{\relax}
\def\etocleftrulecolorcmd{\relax}
\def\etocrightrulecolorcmd{\relax}
%    \end{macrocode}
% |1.07i| moves the |\nobreak| to before the |\vskip\etocinnertopsep|
% (especially important for the single column case).
%    \begin{macrocode}
\def\etoc@ruledheading #1{%
   \hb@xt@\linewidth{\color@begingroup
          \hss #1\hss\hskip-\linewidth
          \etoctoprulecolorcmd\leaders\etoctoprule\hss
          \phantom{#1}%
          \leaders\etoctoprule\hss\color@endgroup}%
          \nointerlineskip\nobreak\vskip\etocinnertopsep}
\newcommand*\etocruledstyle[2][\etocdefaultnbcol]{%
\etocsettocstyle
   {\addvspace{\etocabovetocskip}%
    \ifnum #1>\@ne\expandafter\@firstoftwo
         \else \expandafter\@secondoftwo
    \fi
       {\multicolpretolerance\etocmulticolpretolerance
        \multicoltolerance\etocmulticoltolerance
        \setlength{\columnsep}{\etoccolumnsep}%
        \setlength{\multicolsep}{\etocmulticolsep}%
        \begin{multicols}{#1}[\etoc@ruledheading{#2}]}
       {\etoc@ruledheading{#2}%
         \pretolerance\etocmulticolpretolerance
         \tolerance\etocmulticoltolerance}} 
   {\ifnum #1>\@ne\expandafter\@firstofone
         \else \expandafter\@gobble
    \fi
    {\end{multicols}}%
    \addvspace{\etocbelowtocskip}}}
%    \end{macrocode}
% |1.07k| defines |\Etoc@relax| and |\etocbkgcolorcmd| as |\long|: the user
% manual says to use |\renewcommand\etocbkgcolorcmd|, and an |\ifx| test is used
% in the framed style. It was thus a bug to have non-long definitions before. Or
% I could have said in the user manual to use |\renewcommand*|, or in
% |\etocframedstyle| I should test for the two, or I should pause to try to
% remember about this code and think about it.
%    \begin{macrocode}
\def\etocframedmphook{\relax}
\long\def\etocbkgcolorcmd{\relax}
\long\def\Etoc@relax{\relax}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\newbox\etoc@framed@titlebox
\newbox\etoc@framed@contentsbox
\newcommand*\etocframedstyle[2][\etocdefaultnbcol]{%
\etocsettocstyle{%
    \addvspace{\etocabovetocskip}%
    \sbox\z@{#2}%
    \dimen\z@\dp\z@
        \ifdim\wd\z@<\linewidth \dp\z@\z@ \else \dimen\z@\z@ \fi
    \setbox\etoc@framed@titlebox=\hb@xt@\linewidth{\color@begingroup
        \hss 
        \ifx\etocbkgcolorcmd\Etoc@relax\else 
            \sbox\tw@{\color{white}%
            \vrule\@width\wd\z@\@height\ht\z@\@depth\dimen\z@}%
            \ifdim\wd\z@<\linewidth \dp\tw@\z@\fi
            \box\tw@
            \hskip-\wd\z@
        \fi
        \copy\z@
        \hss
        \hskip-\linewidth
        \etoctoprulecolorcmd\leaders\etoctoprule\hss%
        \hskip\wd\z@
        \etoctoprulecolorcmd\leaders\etoctoprule\hss\color@endgroup}%
    \setbox\z@\hbox{\etocleftrule\etocrightrule}%
    \dimen\tw@\linewidth\advance\dimen\tw@-\wd\z@
        \advance\dimen\tw@-\etocinnerleftsep
        \advance\dimen\tw@-\etocinnerrightsep
    \setbox\etoc@framed@contentsbox=\vbox\bgroup
        \hsize\dimen\tw@
        \kern\dimen\z@
        \vskip\etocinnertopsep
        \hbox\bgroup
        \begin{minipage}{\hsize}%
        \etocframedmphook
    \ifnum #1>\@ne\expandafter\@firstoftwo
    \else \expandafter\@secondoftwo
    \fi
        {\multicolpretolerance\etocmulticolpretolerance
        \multicoltolerance\etocmulticoltolerance
        \setlength{\columnsep}{\etoccolumnsep}%
        \setlength{\multicolsep}{\etocmulticolsep}%
        \begin{multicols}{#1}}  
        {\pretolerance\etocmulticolpretolerance
         \tolerance\etocmulticoltolerance}}
    {\ifnum #1>\@ne\expandafter\@firstofone
         \else \expandafter\@gobble
     \fi
      {\end{multicols}\unskip }%
    \end{minipage}%
    \egroup
    \vskip\etocinnerbottomsep
    \egroup
    \vbox{\hsize\linewidth
        \ifx\etocbkgcolorcmd\Etoc@relax\else
            \kern\ht\etoc@framed@titlebox
            \kern\dp\etoc@framed@titlebox
            \hb@xt@\linewidth{\color@begingroup
            \etocleftrulecolorcmd\etocleftrule
            \etocbkgcolorcmd
            \leaders\vrule 
                   \@height\ht\etoc@framed@contentsbox 
                   \@depth\dp\etoc@framed@contentsbox 
            \hss
            \etocrightrulecolorcmd\etocrightrule
            \color@endgroup}\nointerlineskip
            \vskip-\dp\etoc@framed@contentsbox
            \vskip-\ht\etoc@framed@contentsbox
            \vskip-\dp\etoc@framed@titlebox
            \vskip-\ht\etoc@framed@titlebox
        \fi
    \box\etoc@framed@titlebox\nointerlineskip
    \hb@xt@\linewidth{\color@begingroup
    {\etocleftrulecolorcmd\etocleftrule}%
    \hss\box\etoc@framed@contentsbox\hss
    \etocrightrulecolorcmd\etocrightrule\color@endgroup}
    \nointerlineskip
    \vskip\ht\etoc@framed@contentsbox
    \vskip\dp\etoc@framed@contentsbox
    \hb@xt@\linewidth{\color@begingroup\etocbottomrulecolorcmd
          \leaders\etocbottomrule\hss\color@endgroup}}
    \addvspace{\etocbelowtocskip}}}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\newcommand\etoc@multicoltoc[2][\etocdefaultnbcol]{%
    \etocmulticolstyle[#1]{#2}%
    \tableofcontents}
\newcommand\etoc@multicoltoci[2][\etocdefaultnbcol]{%
    \etocmulticolstyle[#1]{#2}%
    \tableofcontents*}
\newcommand\etoc@local@multicoltoc[2][\etocdefaultnbcol]{%
    \etocmulticolstyle[#1]{#2}%
    \localtableofcontents}
\newcommand\etoc@local@multicoltoci[2][\etocdefaultnbcol]{%
    \etocmulticolstyle[#1]{#2}%
    \localtableofcontents*}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\newcommand*\etoc@ruledtoc[2][\etocdefaultnbcol]{%
    \etocruledstyle[#1]{#2}%
    \tableofcontents}
\newcommand*\etoc@ruledtoci[2][\etocdefaultnbcol]{%
    \etocruledstyle[#1]{#2}%
    \tableofcontents*}
\newcommand*\etoc@local@ruledtoc[2][\etocdefaultnbcol]{%
    \etocruledstyle[#1]{#2}%
    \localtableofcontents}
\newcommand*\etoc@local@ruledtoci[2][\etocdefaultnbcol]{%
    \etocruledstyle[#1]{#2}%
    \localtableofcontents*}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\newcommand*\etoc@framedtoc[2][\etocdefaultnbcol]{%
    \etocframedstyle[#1]{#2}%
    \tableofcontents}
\newcommand*\etoc@framedtoci[2][\etocdefaultnbcol]{%
    \etocframedstyle[#1]{#2}%
    \tableofcontents*}
\newcommand*\etoc@local@framedtoc[2][\etocdefaultnbcol]{%
    \etocframedstyle[#1]{#2}%
    \localtableofcontents}
\newcommand*\etoc@local@framedtoci[2][\etocdefaultnbcol]{%
    \etocframedstyle[#1]{#2}%
    \localtableofcontents*}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocmulticol{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@multicoltoci}
    {\etoc@multicoltoc}}
\def\etocruled{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@ruledtoci}
    {\etoc@ruledtoc}}
\def\etocframed{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@framedtoci}
    {\etoc@framedtoc}}
\def\etoclocalmulticol{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@local@multicoltoci}
    {\etoc@local@multicoltoc}}
\def\etoclocalruled{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@local@ruledtoci}
    {\etoc@local@ruledtoc}}
\def\etoclocalframed{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@local@framedtoci}
    {\etoc@local@framedtoc}}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocarticlestyle{%
    \etocsettocstyle
    {\section *{\contentsname 
                \@mkboth {\MakeUppercase \contentsname}
                         {\MakeUppercase \contentsname}}}
    {}}
\def\etocarticlestylenomarks{%
    \etocsettocstyle
    {\section *{\contentsname}}
    {}}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocbookstyle{%
    \etocsettocstyle
    {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi 
     \chapter *{\contentsname 
                \@mkboth {\MakeUppercase \contentsname}
                         {\MakeUppercase \contentsname}}}
    {\if@restonecol \twocolumn \fi}}
\def\etocbookstylenomarks{%
    \etocsettocstyle
    {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi 
     \chapter *{\contentsname}}
    {\if@restonecol \twocolumn \fi}}
\let\etocreportstyle\etocbookstyle
\let\etocreportstylenomarks\etocbookstylenomarks
\def\etocmemoirtoctotocfmt #1#2{%
    \def\Etoc@addsuitablecontentsline{\addcontentsline {toc}{#1}{#2}}%
    \renewcommand*\etocaftertitlehook{%
      \ifmem@em@starred@listof
      \else\phantomsection\aftergroup\Etoc@addsuitablecontentsline\fi}}
\def\etocmemoirstyle{%
    \etocsettocstyle
        {\ensureonecol \par \begingroup \@nameuse {@tocmaketitle}
         \Etoc@aftertitlehook\let\Etoc@aftertitlehook\relax
         \parskip \cftparskip \@nameuse {cfttocbeforelisthook}}
        {\@nameuse {cfttocafterlisthook}\endgroup\restorefromonecol}}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocscrartclstyle{%
    \etocsettocstyle
        {\let\if@dynlist\if@tocleft
         \def\@currext{toc}% added 1.07m 2015/01/23
         \iftocfeature {toc}{onecolumn}
             {\iftocfeature {toc}{leveldown}
              {}
              {\if@twocolumn \aftergroup \twocolumn \onecolumn \fi }}
             {}%
%    \end{macrocode}
% |1.07k|: next line to do as within current |scrartcl 2013/12/19 v3.12| 
% KOMA-Script article class.
%    \begin{macrocode}
         \iftocfeature {toc}{numberline}{\def \nonumberline {\numberline {}}}{}%
         \tocbasic@listhead {\listoftocname}%
         \begingroup \expandafter \expandafter \expandafter 
         \endgroup \expandafter 
         \ifx 
             \csname microtypesetup\endcsname \relax 
         \else 
             \iftocfeature {toc}{noprotrusion}{}
                 {\microtypesetup {protrusion=false}%
                  \PackageInfo {tocbasic}%
                  {character protrusion at toc deactivated}}%
         \fi
         \setlength {\parskip }{\z@ }%
         \setlength {\parindent }{\z@ }%
         \setlength {\parfillskip }{\z@ \@plus 1fil}% 
         \csname tocbasic@@before@hook\endcsname
         \csname tb@toc@before@hook\endcsname}
        {\csname tb@toc@after@hook\endcsname 
         \csname tocbasic@@after@hook\endcsname}}
\let\etocscrbookstyle\etocscrartclstyle
\let\etocscrreprtstyle\etocscrartclstyle
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\etocstandarddisplaystyle{\etocarticlestyle}
\newcommand*\etocmarkboth[1]{%
    \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
\newcommand*\etocmarkbothnouc[1]{\@mkboth{#1}{#1}}
\newcommand\etoctocstyle[3][section]{\etocmulticolstyle[#2]%
    {\csname #1\endcsname *{#3}}}
\newcommand\etoctocstylewithmarks[4][section]{\etocmulticolstyle[#2]%
    {\csname #1\endcsname *{#3\etocmarkboth{#4}}}}
\newcommand\etoctocstylewithmarksnouc[4][section]{\etocmulticolstyle[#2]%
    {\csname #1\endcsname *{#3\etocmarkbothnouc{#4}}}}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\Etoc@redefetocstyle#1{%
    \renewcommand\etoctocstylewithmarks[4][#1]
    {\etocmulticolstyle[##2]%
          {\csname ##1\endcsname *{##3\etocmarkboth{##4}}}}
    \renewcommand\etoctocstylewithmarksnouc[4][#1]
    {\etocmulticolstyle[##2]%
          {\csname ##1\endcsname *{##3\etocmarkbothnouc{##4}}}}
    \renewcommand\etoctocstyle[3][#1]{%
     \etocmulticolstyle[##2]{\csname ##1\endcsname *{##3}}}}
\@ifclassloaded{scrartcl}
    {\renewcommand*\etocstandarddisplaystyle{\etocscrartclstyle}}{}
\@ifclassloaded{book}
    {\renewcommand*\etocfontone{\normalfont\normalsize}
     \renewcommand*\etocstandarddisplaystyle{\etocbookstyle}
     \Etoc@redefetocstyle{chapter}}{}
\@ifclassloaded{report}
    {\renewcommand*\etocfontone{\normalfont\normalsize}
     \renewcommand*\etocstandarddisplaystyle{\etocreportstyle}
     \Etoc@redefetocstyle{chapter}}{}
\@ifclassloaded{scrbook}
    {\renewcommand*\etocfontone{\normalfont\normalsize}
     \renewcommand*\etocstandarddisplaystyle{\etocscrbookstyle}
     \Etoc@redefetocstyle{chapter}}{}
\@ifclassloaded{scrreprt}
    {\renewcommand*\etocfontone{\normalfont\normalsize}
     \renewcommand*\etocstandarddisplaystyle{\etocscrreprtstyle}
     \Etoc@redefetocstyle{chapter}}{}
%    \end{macrocode}
%|1.07k (2014/03/06)| adds the |appendix| to the list of known levels if class
%|memoir| is detected.
%    \begin{macrocode}
\@ifclassloaded{memoir}
    {\etocsetlevel{appendix}{0}%
     \renewcommand*\etocfontone{\normalfont\normalsize}
     \etocmemoirtoctotocfmt{chapter}{\contentsname}%
     \renewcommand*\etocstandarddisplaystyle{\etocmemoirstyle}
     \Etoc@redefetocstyle{chapter}}{}
%    \end{macrocode}
%|1.07k (2014/03/06)| adds the compatibility with the |tocloft| package; in
% compatibility mode etoc will obey the |tocloft| customisation for the division
% headings as well as for the toc title.
%
%|1.07l (2014/04/02)| fixes the bug from the |tocloft| compatibility layer which
%was |memoir| incompatible: |memoir| has its version of |tocloft| which doesn't
%have the |\if@cftnctoc| boolean.
%    \begin{macrocode}
\def\etoctocloftstyle {%
    \etocsettocstyle 
    {\@cfttocstart\par\begingroup
      \parindent\z@ \parskip\cftparskip \@cftmaketoctitle
      \if@cfttocbibind\@cftdobibtoc\fi }%
    {\endgroup\@cfttocfinish }%
}
\@ifclassloaded{memoir}{}
{\@ifpackageloaded{tocloft}
    {\if@cftnctoc\else
     \renewcommand*\etocstandarddisplaystyle{\etoctocloftstyle}
     \AtBeginDocument{\let\tableofcontents\etoctableofcontents}
     \fi }
    {\AtBeginDocument
      {\@ifpackageloaded{tocloft}
       {\if@cftnctoc\else
         \PackageWarning {etoc}
         {Package `tocloft' was loaded after `etoc'!^^J% 
**** to prevent it from overwriting \protect\tableofcontents, it will be tricked^^J%
**** into believing to have been loaded with option `titles'. For better^^J%
**** compatibility, please load `tocloft' before `etoc'}%
        \AtEndDocument{\PackageWarning{etoc}
                       {Please load `tocloft' /before/ `etoc'!}}\fi
        \@cftnctoctrue }%
       {}%
      }%
     }%
}
%    \end{macrocode}
% placeholder for comments
%    \begin{macrocode}
\def\Etoc@addtocontents #1#2%
    {\ifEtoc@hyperref
       \addtocontents {toc}{\protect\contentsline 
                {#1}{#2}%
                {\thepage }{\@currentHref }}%
     \else
       \addtocontents {toc}{\protect\contentsline 
          {#1}{#2}{\thepage }}%
     \fi}
\def\Etoc@addcontentsline@ #1#2#3%
    {\@namedef{toclevel@#1}{#3}%
     \addcontentsline {toc}{#1}{#2}}
\DeclareRobustCommand*{\etoctoccontentsline}
    {\@ifstar{\Etoc@addcontentsline@}{\Etoc@addtocontents}}
%    \end{macrocode}
% All the following added for version |1.07g [2013/10/13]|. Motivated by
% a demand about  |tovsec2|. But it is impossible to make |tocvsec2|
% compatible, if not re-doing all `toc' macros in |tocvsec2| 
% (|v1.3, 2011/08/07|). I do not retain the stack idea, which does not convince
% me as useful. The empty line in the |.toc| file is put there by
% |tocvsec2| (see its code line 143). 
% 
% I take this opportunity to add to the start of the toc file 
% |\let\etoc@startlocaltoc\@gobble| in case |etoc| is not detected, I should
% possibly have done that long ago (like I did in |tableof|).
%
% In |1.07h| I decide that I should not have used |\Etoc@| but |\etoc@| for
% |\Etoc@settocdepth|. So I now use lowercase and add a temporary line for
% transition in the very improbable situation that someone actually did already
% use the just released |1.07g|.
%
% In |1.07i| the deactivation of |\etoc@settocdepth| done at the start
% of the |.toc| file (for the case this file is used after having
% removed |etoc| from the document, or imported in another document) is
% done via letting it to |\@gobble| rather than |\count@| (which would
% not be ok, as what follows would be undefined too). The reason for the
% |\count@| also used originally in |\etocignoretoctocdepth| is that
% when I first worked on |1.07g| I possibly had more than one token
% after |\etoc@settocdepth|, but I changed that later.
%
%    \begin{macrocode}
\def\Etoc@storetocdepth {\global\c@etoc@tocdepth\c@tocdepth }
\def\Etoc@resettocdepth {\global\c@tocdepth\c@etoc@tocdepth }
\def\etocobeytoctocdepth {\def\etoc@settocdepth 
        {\afterassignment\Etoc@@nottoodeep \global\c@tocdepth}}
\def\Etoc@@nottoodeep {\ifnum\c@tocdepth>\c@etoc@tocdepth
                          \global\c@tocdepth\c@etoc@tocdepth\fi }
\def\etocignoretoctocdepth {\let\etoc@settocdepth\@gobble } 
\def\etocsettocdepth   {\futurelet\Etoc@nexttoken\Etoc@set@tocdepth }
\def\Etoc@set@tocdepth {\ifx\Etoc@nexttoken\bgroup
                            \expandafter\Etoc@set@tocdepth@
                       \else\expandafter\Etoc@set@toctocdepth
                       \fi }
\def\Etoc@set@tocdepth@ #1{\@ifundefined {Etoc@#1@@}
      {\PackageWarning{etoc}
          {Unknown sectioning unit #1, \protect\etocsettocdepth\space ignored}}
      {\global\c@tocdepth\csname Etoc@#1@@\endcsname}%
}
\def\Etoc@set@toctocdepth  #1#{\Etoc@set@toctocdepth@ }
\def\Etoc@set@toctocdepth@ #1{%
  \@ifundefined{Etoc@#1@@}%
   {\PackageWarning{etoc}
        {Unknown sectioning depth #1, \protect\etocsettocdepth.toc ignored}}%
   {\addtocontents {toc}      
   {\protect\etoc@settocdepth\expandafter\protect\csname Etoc@#1@@\endcsname}}% 
}
%    \end{macrocode}
% |1.07h| adds the depth tags, and an even more general mechanism could be added
% at some point: we could insert `action' tags and have the user map them to
% arbitrary commands. For the time being we just provide 
% |\etocdepthtag.toc {name}| and |\etocsettagdepth {tag_name}{level}| where
% level is numeric or 
% alphabetical. The numeric
% level |-3| is now again not accepted by |\etocsetlevel|, it can be used with
% |\etocsettagdepth| (which accepts equivalently |none|).
%    \begin{macrocode}
\def\etocdepthtag   #1#{\Etoc@depthtag } % \etocdepthtag.toc {name}
\def\Etoc@depthtag  #1{\addtocontents {toc}{\protect\etoc@depthtag {#1}}}
\def\etocignoredepthtags {\let\etoc@depthtag \@gobble }
\def\etocobeydepthtags   {\let\etoc@depthtag \Etoc@depthtag@ }
\def\Etoc@depthtag@ #1{\@ifundefined{Etoc@depthof@#1}%
       {}% ignore in silence if tag has no associated depth
       {\afterassignment\Etoc@@nottoodeep
                 \global\c@tocdepth\csname Etoc@depthof@#1\endcsname}%
}
\def\etocsettagdepth #1#2{\@ifundefined{Etoc@#2@@}%
       {\PackageWarning{etoc}
         {Unknown sectioning depth #2, \protect\etocsettagdepth\space ignored}}%
       {\@namedef{Etoc@depthof@#1}{\@nameuse{Etoc@#2@@}}}%
}
%    \end{macrocode}
% We must cancel all |tocvsec2| toc-related actions. But a check must be done
% for the memoir class, as its |tocvsec2| emulation does not have the
% incompatible things etoc needs to revert. This extra check added with etoc
% |1.07l|.
%    \begin{macrocode}
\def\Etoc@tocvsec@err #1{\PackageError {etoc}
        {the command \protect#1\space is incompatible with etoc} 
        {use \protect\etocsettocdepth.toc as replacement (check the manual)}%
}%
\AtBeginDocument {%
   \@ifclassloaded{memoir}
    {\PackageWarning{etoc}{You may consider using \protect\etocsettocdepth.toc
      as a drop-in^^J
      replacement to the memoir own \protect\settocdepth\space
      if you wish to exploit etoc to its^^J 
      fullest. Similarly consider using
     \protect\etocsettocdepth\space and 
     \protect\etocsetnexttocdepth^^J rather 
     than memoir's \protect\maxtocdepth.}}
    {\@ifpackageloaded {tocvsec2}
     {\def\maxtocdepth  #1{\Etoc@tocvsec@err \maxtocdepth   }%
      \def\settocdepth  #1{\Etoc@tocvsec@err \settocdepth   }%
      \def\resettocdepth  {\@ifstar {\Etoc@tocvsec@err \resettocdepth }%
                                    {\Etoc@tocvsec@err \resettocdepth }%
                          }%
      \def\save@tocdepth #1#2#3{}%    % if etoc is added to file previously
      \let\reset@tocdepth\relax       % using tocvsec2
      \let\remax@tocdepth\relax   
      \let\tableofcontents\etoctableofcontents
      \PackageWarning {etoc}
      {package tocvsec2 detected and its modification of^^J
       \protect\tableofcontents\space reverted. Use
       \protect\etocsettocdepth.toc as a replacement^^J 
       for the tocvsec2 toc-related commands}}{}%
   }%
}%
%    \end{macrocode}
% |1.07g|
%    \begin{macrocode}
\def\invisibletableofcontents {\etocsetnexttocdepth {-3}\tableofcontents }%
\def\invisiblelocaltableofcontents 
                         {\etocsetnexttocdepth {-3}\localtableofcontents }%
\def\etocsetnexttocdepth #1{%
    \@ifundefined{Etoc@#1@@}
     {\PackageWarning{etoc}
       {Unknown sectioning unit #1, \protect\etocsetnextocdepth\space ignored}}
     {\edef\Etoc@aftertochook {\global\c@tocdepth\the\c@tocdepth\space
                              \let\noexpand\Etoc@aftertochook\noexpand\@empty }%
       \global\c@tocdepth\csname Etoc@#1@@\endcsname}%
}%
%    \end{macrocode}
% |1.07h|. In order for the |.toc| file to be usable without error even
% without etoc. In |1.07i| use of |\@gobble| for |\etoc@settocdepth|.
%    \begin{macrocode}
\addtocontents {toc}{\protect\@ifundefined{etoctocstyle}%
           {\let\protect\etoc@startlocaltoc\protect\@gobble 
            \let\protect\etoc@settocdepth\protect\@gobble
            \let\protect\etoc@depthtag\protect\@gobble }{}}%
%    \end{macrocode}
% Initializations.
%    \begin{macrocode}
\def\etocstandardlines {\Etoc@standardtrue}
\def\etoctoclines      {\Etoc@standardfalse}
\etocdefaultlines
\etocstandardlines 
\etocstandarddisplaystyle
\etocobeytoctocdepth 
\etocobeydepthtags
\let\Etoc@aftertochook\@empty % private for \etocsetnexttocdepth
\let\etocaftertochook \@empty % public for end user.
\let\etocbeforetitlehook \@empty % new with 1.07m
\endinput
%    \end{macrocode}
% \MakePercentComment
\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         \~}

\CheckSum{3028}

\csname check@checksum\endcsname
\Finale
%%
%% End of file `etoc.dtx'.