summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/reledmac/reledmac.dtx
blob: c5bb0685d80165a2f259c72a198ad0f7d7882454 (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
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
% \iffalse meta-comment
%
% reledmac.dtx
% Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net
% Maintainer:Maïeul Rouquette maieul at maieul dot net
% Copyright 2003 -- 2005 Peter R. Wilson / 2011-.. Maïeul Rouquette
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any
% later version.
% The latest version of the license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2003/06/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% This work consists of the files listed in the README file.
%
%
%<*driver>
\documentclass[twoside]{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{xr-hyper}
\usepackage{url}
  \usepackage[draft=false,
              plainpages=false,
              pdfpagelabels,
              bookmarksnumbered,
%            hyperindex=true
              hyperindex=false
             ]{hyperref}
\addtolength\marginparwidth{30pt}
\usepackage[mono=false]{libertine}
\usepackage[series={A,B},noend,noeledsec,nofamiliar]{reledmac}
\usepackage{reledpar}
\usepackage[english]{babel}
\usepackage{xspace}
\usepackage{doctools}
\usepackage{graphicx,metalogo}
\usepackage{csquotes}
% Index and Changelog in one column
\makeatletter
  \renewenvironment{theglossary}{%
      \@restonecoltrue\if@twocolumn\@restonecolfalse\fi
      \columnseprule \z@  \columnsep 35\p@
      \glossary@prologue%
      \GlossaryParms \let\item\@idxitem \ignorespaces}
    {\if@restonecol\onecolumn\else\clearpage\fi}
  \def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
    \columnseprule \z@  \columnsep 35\p@
    \index@prologue%
    \IndexParms \let\item\@idxitem \ignorespaces}
  \def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
  \@mparswitchfalse
\makeatother
\EnableCrossrefs
\RecordChanges
\CodelineIndex
%%\OnlyDescription
\renewcommand{\MakeUppercase}[1]{#1}
\pagestyle{headings}
\setcounter{StandardModuleDepth}{1}
\usepackage{longtable}
\externaldocument[reledpar-]{reledpar}
\begin{document}
  \raggedbottom
  \DocInput{reledmac.dtx}
\end{document}
%</driver>
%
% \fi
%
% \newcommand{\reff}[1]{\ref{#1} p.~\pageref{#1}}
%
% \makeatletter
% \newcommand*{\DescribeIt}{\leavevmode\@bsphack\begingroup\MakePrivateLetters
%  \Describe@It}
% \newcommand*{\Describe@It}[1]{\endgroup
%   \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
%   \SpecialItIndex{#1}\@esphack\ignorespaces}
% \newcommand*{\SpecialItIndex}[1]{\@bsphack
%   \index{#1\actualchar{\protect\ttfamily#1}\encapchar usage}\@esphack}
%
% \DoNotIndex{\@,\@@par,\@beginparpenalty,\@empty}
% \DoNotIndex{\@flushglue,\@input}
% \DoNotIndex{\@makefnmark,\@makeother,\@maketitle}
% \DoNotIndex{\@namedef,\@ne,\@spaces,\@tempa}
% \DoNotIndex{\@tempb,\@tempswafalse,\@tempswatrue}
% \DoNotIndex{\@thanks,\@thefnmark,\@topnum}
% \DoNotIndex{\@@,\@elt,\@forloop,\@fortmp,\@gtempa,\@totalleftmargin}
% \DoNotIndex{\",\/,\@ifundefined,\@nil,\@verbatim,\@vobeyspaces}
% \DoNotIndex{\|,\~,\ ,\active,\advance,\aftergroup,\begingroup,\bgroup}
% \DoNotIndex{\mathcal,\csname,\def,\documentstyle,\dospecials,\edef}
% \DoNotIndex{\egroup}
% \DoNotIndex{\else,\endcsname,\endgroup,\endinput,\endtrivlist}
% \DoNotIndex{\expandafter,\fi,\fnsymbol,\futurelet,\gdef,\global}
% \DoNotIndex{\hbox,\hss,\if,\if@inlabel,\if@tempswa,\if@twocolumn}
% \DoNotIndex{\ifcase}
% \DoNotIndex{\ifcat,\iffalse,\ifx,\ignorespaces,\index,\input,\item}
% \DoNotIndex{\jobname,\kern,\leavevmode,\leftskip,\let,\llap,\lower}
% \DoNotIndex{\m@ne,\next,\newpage,\nobreak,\noexpand,\nonfrenchspacing}
% \DoNotIndex{\obeylines,\or,\protect,\raggedleft,\rightskip,\rm,\sc}
% \DoNotIndex{\setbox,\setcounter,\small,\space,\string,\strut}
% \DoNotIndex{\strutbox}
% \DoNotIndex{\thefootnote,\thispagestyle,\topmargin,\trivlist,\tt}
% \DoNotIndex{\twocolumn,\typeout,\vss,\vtop,\xdef,\z@}
% \DoNotIndex{\,,\@bsphack,\@esphack,\@noligs,\@vobeyspaces,\@xverbatim}
% \DoNotIndex{\`,\catcode,\end,\escapechar,\frenchspacing,\glossary}
% \DoNotIndex{\hangindent,\hfil,\hfill,\hskip,\hspace,\ht,\it,\langle}
% \DoNotIndex{\leaders,\long,\makelabel,\marginpar,\markboth,\mathcode}
% \DoNotIndex{\mathsurround,\mbox,\newcount,\newdimen,\newskip}
% \DoNotIndex{\nopagebreak}
% \DoNotIndex{\parfillskip,\parindent,\parskip,\penalty,\raise,\rangle}
% \DoNotIndex{\section,\setlength,\TeX,\topsep,\underline,\unskip,\verb}
% \DoNotIndex{\vskip,\vspace,\widetilde,\\,\%,\@date,\@defpar}
% \DoNotIndex{\[,\{,\},\]}
% \DoNotIndex{\count@,\ifnum,\loop,\today,\uppercase,\uccode}
% \DoNotIndex{\baselineskip,\begin,\tw@}
% \DoNotIndex{\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k,\l,\m,\n,\o,\p,\q}
% \DoNotIndex{\r,\s,\t,\u,\v,\w,\x,\y,\z,\A,\B,\C,\D,\E,\F,\G,\H}
% \DoNotIndex{\I,\J,\K,\L,\M,\N,\O,\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z}
% \DoNotIndex{\1,\2,\3,\4,\5,\6,\7,\8,\9,\0}
% \DoNotIndex{\!,\#,\$,\&,\',\(,\),\+,\.,\:,\;,\<,\=,\>,\?,\_}
% \DoNotIndex{\discretionary,\immediate,\makeatletter,\makeatother}
% \DoNotIndex{\meaning,\newenvironment,\par,\relax,\renewenvironment}
% \DoNotIndex{\repeat,\scriptsize,\selectfont,\the,\undefined}
% \DoNotIndex{\arabic,\do,\makeindex,\null,\number,\show,\write,\@ehc}
% \DoNotIndex{\@author,\@ehc,\@ifstar,\@sanitize,\@title,\everypar}
% \DoNotIndex{\if@minipage,\if@restonecol,\ifeof,\ifmmode}
% \DoNotIndex{\lccode,\newtoks,\onecolumn,\openin,\p@,\SelfDocumenting}
% \DoNotIndex{\settowidth,\@resetonecoltrue,\@resetonecolfalse,\bf}
% \DoNotIndex{\clearpage,\closein,\lowercase,\@inlabelfalse}
% \DoNotIndex{\selectfont,\mathcode,\newmathalphabet,\rmdefault}
% \DoNotIndex{\bfdefault}
% \DoNotIndex{\newcommand,\renewcommand,\providecommand}
% \DoNotIndex{\ ,\to,\hsize,\multiply,\textit}
%
% \newcommand{\dtxfilename}{\texttt{reledmac.dtx}}
% \GetFileInfo{reledmac.sty}
% ^^A To put the changes in the right order : see http://tex.stackexchange.com/a/74113/7712
%\makeatletter
%  \let\org@changes@\changes@
%    \def\my@changes v#1.#2.#3\@nil{%
%      \org@changes@{v#1.\six@digits{#2}.#3=v#1.#2.#3}%
%    }%
%    \newcommand*{\six@digits}[1]{%
%      \ifnum#1<100000 0\fi
%      \ifnum#1<10000 0\fi
%      \ifnum#1<1000 0\fi
%      \ifnum#1<100 0\fi
%      \two@digits{#1}%
%    }%
%    \renewcommand*{\changes@}[1]{%
%            \my@changes#1.\@nil
%    }%
%\makeatother
% \newcommand{\edmac}{\protect\package{edmac}\xspace}
% \newcommand{\tabmac}{\protect\package{tabmac}\xspace}
% \newcommand{\edstanza}{\protect\package{edstanza}\xspace}

% \newcommand{\ledmac}{\protect\package{ledmac}\xspace}
% \newcommand{\Ledmac}{\protect\package{Ledmac}\xspace}
% \newcommand{\ledpar}{\protect\package{ledpar}\xspace}
% \newcommand{\Ledpar}{\protect\package{Ledpar}\xspace}


% \newcommand{\eledmac}{\protect\package{eledmac}\xspace}
% \newcommand{\Eledmac}{\protect\package{Eledmac}\xspace}
% \newcommand{\eledpar}{\protect\package{eledpar}\xspace}
% \newcommand{\Eledpar}{\protect\package{Eledpar}\xspace}

% \newcommand{\reledmac}{\protect\package{reledmac}\xspace}
% \newcommand{\Reledmac}{\protect\package{Reledmac}\xspace}
% \newcommand{\reledpar}{\protect\package{reledpar}\xspace}
% \newcommand{\Reledpar}{\protect\package{Reledpar}\xspace}

% \let\macpackage\reledmac
% \let\parpackage\reledpar
% \let\Macpackage\reledmac
% \let\Parpackage\reledpar
% \newcommand{\texbook}{\textit{TeXbook}\xspace}
% \newcommand{\thetexbook}{\textit{The TeXbook}\xspace}
%
% \newcommand{\egstart}{%
%    \par
%    \begingroup
%    \centering
%    \begin{minipage}{0.45\textwidth}}
% \newcommand{\egmid}{%
%    \end{minipage}\hfill\begin{minipage}{0.45\textwidth}}
% \newcommand{\egend}{%
%    \end{minipage}\par\endgroup}
% \changes{v0.1.0}{2003/03/25}{First public release}
% \changes{v0.2.0}{2003/08/16}{Added tabmac code, and extended indexing}
% \changes{v0.2.1}{2003/09/13}{Bug fixes and match with mempatch v1.8}
% \changes{v0.2.2}{2003/11/09}{Improved paragraph footnotes}
% \changes{v0.2.2}{2003/11/09}{New Dekker example}
% \changes{v0.3.0}{2004/02/14}{Includes edstanza and more}
% \changes{v0.3.1}{2004/02/18}{Not released. Added remarks about the parallel package}
% \changes{v0.4.0}{2004/02/29}{Added minipage, etc., support}
% \changes{v0.4.1}{2004/03/28}{Not released. Minor editorial improvements and code tweaks}
% \changes{v0.5.0}{2004/04/04}{Added sidenotes, familiar footnotes in numbered text}
% \changes{v0.5.1}{2004/04/10}{Fixed right line numbers killed in v0.5}
% \changes{v0.6.0}{2004/11/16}{Fixed long paragraphs looping}
% \changes{v0.6.0}{2004/11/16}{Prepared for eledpar package}
% \changes{v0.6.0}{2004/12/10}{Fixed minor typos}
% \changes{v0.7.0}{2005/02/18}{Tidying up for eledpar and ledarab packages}
% \changes{v0.7.0}{2005/02/18}{Replaced all \protect\cs{interAfootnotelinepenalty}, etc.,
%                         by just \protect\cs{interfootnotelinepenalty}}
% \changes{v0.7.0}{2005/03/02}{eledmac having been available for 2 years,
%                         deleted the commented out original edmac texts}
% \changes{v0.7.0}{2011/06/17}{Ma\"ieul Rouquette new maintainer}
% \changes{v0.8.0}{2011/17/06}{Bug on endnotes fixed: in a // text, all endnotes will print and be placed at the ends of columns (!)}
% \changes{v0.8.1}{2011/07/14}{Bug on \protect\cs{edtext} ; \protect\cs{critex} ; \protect\cs{lemma} fixed: we can now us non-switching commands}
% \changes{v0.9.0}{2011/08/03}{No more ledpatch. All patches are now in the main file.}
% \changes{v0.9.1}{2011/08/08}{Fix some bugs linked to integrating ledpatch on the main file.}
% \changes{v0.10.0}{2011/08/22}{Corrections to \protect\cs{section} and other titles in numbered sections}
% \changes{v0.11.0}{2011/09/16}{Makes it possible to add a symbol on each verse's hanging, as in French typography. Redefines the command \protect\cs{hangingsymbol} to define the character.}
% \changes{v0.12.0}{2011/10/01}{Possibility to number the pstart with the commands \protect\cs{numberpstarttrue}.}
% \changes{v0.12.0}{2011/10/01}{For compatibility with eledpar, possibility to use \protect\cs{autopar} on the right side.}
% \changes{v0.12.1}{2011/10/02}{The numbering of \protect\cs{pstarts} restarts on each \protect\cs{beginnumbering}.}
% \changes{v0.12.1}{2011/10/02}{Don't number \protect\cs{pstarts} of stanza.}
% \changes{v0.13.0}{2011/11/08}{New stanzaindentsrepetition counter:  to repeat stanza indents every \emph{n} verses.}
% \changes{v0.13.1}{2011/11/18}{\protect\cs{thepstartL} and \protect\cs{thepstartR}  use now \protect\cs{bfseries} and not \protect\cs{bf}, which is deprecated and makes conflicts with memoir class.}
% \changes{v0.14.0}{2012/04/04}{Tweaked \protect\cs{edlabel} to get correct line number if the command is first element of a paragraph.}
% \changes{v1.0.0}{2012/09/15}{Some compatibility break with eledmac. Change of name: eledmac.}
% \changes{v1.1.0}{2012/09/25}{New package option: parapparatus.}
% \changes{v1.4.0}{2012/11/16}{Compatibility with LuaTeX of RTL notes.}
% \changes{v1.4.2}{2012/12/12}{Debug with some special classes.}
% \changes{v1.4.3}{2012/12/18}{Spurious space after familiar footnotes.}
% \changes{v1.4.4}{2013/02/18}{Label inside familiar footnotes.}
% \changes{v1.4.5}{2013/03/02}{Bug with komasscript + eledpar + chapter.}
% \changes{v1.4.6}{2013/04/15}{Bug with memoir class introduced by 1.4.5.}
% \changes{v1.4.8}{2013/07/02}{Corrects a bug with parallel texts introduced by 1.1.}
% \changes{v1.6.1}{2013/10/27}{Corrects a false hanging verse when a verse is exactly the length of a line.}
% \changes{v1.4.0}{2012/11/16}{Compatibility with LuaTeX of RTL notes.}
% \changes{v1.8.0}{2013/12/13}{Compatibility with parledgroup option of eledpar package.}
% \changes{v1.8.2}{2014/01/31}{Debug compatibility problem with hebrew option of babel package.}
% \changes{v1.8.3}{2014/02/03}{Fixes spurious spaces added by v1.7.0.}
% \changes{v1.10.0}{2014/02/27}{Add \protect\cs{pstartref} and \protect\cs{xpstartref} to refer to a pstart number (extension of \protect\cs{edlabel}).}
% \changes{v1.10.1}{2014/02/28}{Compatibility with \textsf{cleveref}.}
% \changes{v1.10.2}{2014/03/17}{Compatibility of stanza with v1.8a of babel-greek.}
% \changes{v1.10.3}{2014/04/07}{Debug of cross-referencing.}
% \changes{v1.10.4}{2014/04/09}{Debug of critical notes in edtabular environnment.}
% \changes{v1.10.5}{2014/04/14}{Debug of \protect\cs{xxref}.}
% \changes{v1.10.5}{2014/04/14}{Debug of \protect\cs{pausenumbering}.}
% \changes{v1.10.6}{2014/05/01}{Debug of interaction between \protect\cs{autopar} and\protect\cs{pausenumbering}.}
% \changes{v1.11.1}{2014/05/29}{Correct a bug when a critical note starts with plus or minus.}
% \changes{v1.12.0}{2014/08/05}{Compatibility with \protect\package{musixtex}.}
% \changes{v1.12.0}{2014/08/05}{Debug eledmac sectioning command after using \protect\cs{resumenumbering}.}
% \changes{v1.12.3}{2014/08/15}{Underline lemma in \protect\cs{eledxxx} when using draft mode.}
% \changes{v1.12.3}{2014/08/15}{Correct bug with side and familiar notes in tabular environments.}
% \changes{v1.12.3}{2014/08/15}{Debug left and right notes (bugs added by 1.12.0)}
% \changes{v1.12.3}{2014/08/15}{Debug \protect\cs{eledxxx} with some paper size}
% \changes{v1.12.4}{2014/08/25}{Debug spurious page breaks before \protect\cs{chapter} (bug added in 1.12.0)}
% \changes{v1.13.1}{2014/09/25}{Debug quotation environment inside of a \protect\cs{pstart} preceded by a sectioning command.}
% \changes{v1.13.1}{2014/09/25}{Coming back of page and line breaking penalties's management, deleted by error in v0.17.}
% \changes{v1.13.2}{2014/09/30}{Fix a bug with normal footnotes, added by v1.13.0.}
% \changes{v1.13.3}{2014/10/04}{Fix extra spaces with paragraphed footnotes, added by v1.13.0.}
% \changes{v1.13.4}{2014/10/20}{Fix a bug with index when memoir class is used without hyperref}
% \changes{v1.15.0}{2015/01/12}{Fix a bug with footnotes layout when using some options of the geometry package (bug add by v1.13.0).}
% \changes{v1.16.0}{2015/01/23}{Compatibility of standard footnotes with some biblatex styles.}
% \changes{v1.16.0}{2015/01/23}{New \protect\cs{stanzaindent} command.}
% \changes{v1.18.0}{2015/02/23}{Compatibility with \LuaLaTeX\ RTL languages.}
% \changes{v1.19.0}{2015/03/06}{\protect\cs{Xmaxhnotes} and \protect\cs{maxhnotesX} work now for both  two-columns and three-columns setting.}
% \changes{v1.19.0}{2015/03/06}{Compatibility with \protect\package{eledpar} v.1.13.0.}
% \changes{v1.19.1}{2015/03/12}{Call \protect\cs{correct@footinsX@box} and \protect\cs{correct@Xfootins@box} directly in \protect\cs{print@notesX@forpages} and \protect\cs{print@Xnotes@forpages}, that is in \protect\package{eledpar}.}
% \changes{v1.20.0}{2015/03/22}{Correct \protect\cs{Xinplaceofnumber} hook.}
% \changes{v1.20.0}{2015/03/22}{Add series option.}
% \changes{v1.20.0}{2015/03/22}{Fix issues with RTL text in notes when using \LuaLaTeX.}
% \changes{v1.20.0}{2015/03/22}{The \protect\cs{newif}s are not followed by boolean values set to false, because it is the \TeX\ default setting.}
% \changes{v1.20.0}{2015/03/22}{Explicit error message when calling \protect\cs{Xfootnote} outside of \protect\cs{edtext}.}
% \changes{v1.20.0}{2015/03/22}{Fix a bug with line number typesetting direction when using \protect\cs{eledsection} and similar commands for RTL texts with \LuaLaTeX.}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{AtEveryPstart} and \protect\cs{AtEveryPend} are now compatible with \protect\cs{autopar}}
% \changes{v1.21.0}{2015/04/13}{Fix a bug with space between columns with notes in two columns (bug added in v1.13.0).}
% \changes{v1.21.0}{2015/04/13}{Add nocritical, noend, nofamiliar and noledgroup options.}
% \changes{v1.21.0}{2015/04/13}{Fix a bug with \protect\cs{maxhnotesX} when using \protect\cs{foottwocolX} or \protect\cs{footthreecolX}.}
% \changes{v1.21.0}{2015/04/13}{Add \protect\cs{Xtwolinesbutnotmore} and \protect\cs{Xtwolinesonlyinsamepage}.}
% \changes{v1.21.0}{2015/04/13}{Fix a bug when a \protect\cs{Xfootnote} follows a \protect\cs{Xendnote} in the second argument of \protect\cs{edtext} (bug added in eledmac 1.0.0 !).}
% \changes{v1.21.0}{2015/04/13}{Add noeledsec package option}
% \changes{v1.21.0}{2015/04/13}{parapparatus option works now with familiar footnotes.}
% \changes{v1.21.0}{2015/04/13}{Add \protect\cs{beforenotesX} and \protect\cs{Xbeforenotes} features for notes set in two and three column.}
% \changes{v1.21.0}{2015/04/13}{Debug \protect\cs{beforenotesX} \protect\cs{maxhnotesX} \protect\cs{noteswidthliketwocolumnsX} and \protect\cs{afterruleX} with footnotes set in two and three columns.}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{Xafterrule} and \protect\cs{afterruleX} features no longer create problems of overflowing at the bottom of the page.}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{preXnotes} and \protect\cs{prenotesX} features no longer create problems of overflowing at the bottom of the page.}
% \changes{v1.21.0}{2015/04/13}{Fix spurious space after first page number in \protect\cs{doendnotes}. oldprintnpnumspace option allows to come back to previous setting}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{chapter} inside optional argument of \protect\cs{pstart} works when typesetting parallel pages}
% \changes{v1.22.0}{2015/04/25}{When using hyperref package, internal links in index or with \protect\cs{edlineref} are now targeted to the top and not longer to the bottom of the lines they refer to.}
% \changes{v1.22.0}{2015/04/25}{Provides support for xindy.}
% \changes{v1.22.0}{2015/04/25}{Adds hyperlink for references to notes in indices.}
% \changes{v1.22.0}{2015/04/25}{Fix conflict between noend package option and edtabularx environments}
% \changes{v1.22.1}{2015/04/29}{Fix a bug (added on v1.22.0) with \protect\cs{Xinplaceofnumber} hook.}
% \changes{v1.23.0}{2015/05/18}{Compatibility between nofamiliar/nocriticals option and minipage/ledgroup.}
% \changes{v1.23.0}{2015/05/18}{Fix error of \protect\cs{iftrue} not closed.}
% \changes{v1.23.0}{2015/05/18}{Allow use of \protect\cs{sameword} with inputenc managing of UTF-8.}
% \changes{v1.23.0}{2015/05/18}{Error message when using \protect\cs{beginnumbering}\ldots\ \protect\cs{endnumbering} without \protect\cs{pstart}.}
% \changes{v1.23.0}{2015/05/18}{New tools to ensure the line-list file uses the right version of commands when upgrading the eledmac version.}
% \changes{v1.23.0}{2015/05/18}{Fix a bug with \protect\cs{skipnumbering} called immediately after a \protect\cs{pstart}.}
% \changes{v1.23.0}{2015/05/18}{Fix spurious space with \protect\cs{skipnumbering} (bug added on v1.21.0).}
% \changes{v1.23.1}{2015/05/20}{Fix a bug with \protect\cs{lemma} command in the right side.}
% \changes{v1.23.2}{2015/05/29}{Compatibility with \LaTeX's release 2015.}
% \changes{v1.24.0}{2015/06/02}{We can reinitialize \protect\cs{AtEveryPstart} and \protect\cs{AtEveryPend} providing to it an empty argument.}
% \changes{v1.24.1}{2015/06/21}{\protect\cs{lemma} is disabled when using `nocritical` option.}
% \changes{v1.24.2}{2015/06/26}{Fix incompatibility between `nofamiliar` option and `memoir` package.}
% \changes{v1.24.3}{2015/07/07}{Restore marginal numbers and notes with sectioning command (bug introduced in v1.21.0)}
% \changes{v1.24.4}{2015/07/19}{Fix spurious space with \protect\cs{edindex} when using xindy+hyperref option.}
% \changes{v1.24.5}{2015/07/16}{Fix a bug of indent, when a  added in 1.1.0, when a \protect\cs{beginnumbering} immediately follow a sectioning command.}
% \changes{v2.0.0}{2015/07/19}{Package's name becomes \reledmac.}
% \changes{v2.0.0}{2015/07/19}{In order to have a more consistent name's convention, many names has been changed.}
% \changes{v2.0.0}{2015/07/19}{Many \LaTeX's output macros are now patched and not override.}
% \changes{v2.0.0}{2015/07/19}{Add nonum option for endnotes.}
% \changes{v2.0.0}{2015/07/19}{Add \protect\cs{Xendinplaceofnumber} hook.}
% \changes{v2.0.0}{2015/07/19}{Add \protect\cs{Xendnonumber} hook.}
% \changes{v2.0.0}{2015/07/19}{Fix a bug when printing only one series of endnotes, but wanted to keep endnotes for other series.}
% \changes{v2.0.1}{2015/07/27}{Fix incompatibility between optional argument of \protect\cs{pstart} and \protect\cs{numberpstarttrue}}
% \changes{v2.0.1}{2015/07/27}{Fix a bug in eledmac-compat option}
% \changes{v2.1.0}{2015/08/08}{New tools to number stanzas}
% \changes{v2.1.0}{2015/08/02}{Fix a bug with \protect\cs{chapter} in optional argument of \protect\cs{pstart} in parallel typesetting with \protect\ltxclass{scrbook}.}
% \changes{v2.1.0}{2015/08/02}{Fix a bug with \protect\cs{eledchapter} in parallel typesetting with \protect\ltxclass{scrbook}.}
% \changes{v2.1.0}{2015/08/02}{Fix a bug with \protect\cs{setline} at the beginning of a \protect\cs{pstart}.}
% \changes{v2.1.0}{2015/08/02}{Fix a bug with \protect\cs{advanceline} at the beginning of a \protect\cs{pstart}.}
% \changes{v2.1.0}{2015/08/08}{Fix spacing bug with \protect\cs{Xbhooknote} and \protect\cs{bhooknoteX} when using them to insert text and not to execute code.}
% \changes{v2.1.0}{2015/08/08}{Fix spacing bug with \protect\cs{Xbhooknote} and \protect\cs{bhooknoteX} when using them to insert text and not to execute code.}
% \changes{v2.1.1}{2015/08/13}{Fix a bug with \protect\cs{ledpbsetting}\protect\arg{before}.}
% \changes{v2.1.2}{2015/08/26}{Fix a bug with lineation by pstart and tabular environments (added in 2.1.0).}
% \changes{v2.1.3}{2015/09/05}{Fix a bug with \protect\cs{edindex} when using not-Latin characters without UTF-8 engines}
% \changes{v2.1.3}{2015/09/05}{\protect\cs{Xhangindent} and \protect\cs{hangindentX} work now with all the paragraphs in the note.}
% \changes{v2.1.3}{2015/09/05}{\protect\cs{Xnoindent} and \protect\cs{noindentX} work now again (broken in 2.0.0).}
% \changes{v2.1.3}{2015/09/05}{Change some internal code in order to provide compatibility with \LaTeX\ release of october~2015}
% \changes{v2.1.3}{2015/09/05}{Fix a bug which inserted double space before paragraphed familiar notes.}
% \changes{v2.2.0}{2015/09/29}{Fix a bug with combination of \protect\cs{onehalfspacing} and two columns and three columns notes typeset.}
% \changes{v2.2.0}{2015/09/29}{Fix a bug with some setting command and optimization option.}
% \changes{v2.2.0}{2015/09/29}{New setting tools for endnotes: \protect\cs{Xendnumberonlyfirstinline}, \protect\cs{Xendnumberonlyfirstintwolines}, \protect\cs{Xendsymlinenum}, \protect\cs{Xendbeforenumber}, \protect\cs{Xendafterenumber}, \protect\cs{Xendbeforesymlinenum}, \protect\cs{Xendaftersymlinenum}, \protect\cs{Xendboxsymlinenum}, \protect\cs{Xendhangindent}, \protect\cs{Xendbhooklinenumber}, \protect\cs{Xendahooklinenumber}, \protect\cs{Xendbhookinplaceofnumber}, \protect\cs{Xendahookinplaceofnumber}.}
% \changes{v2.2.0}{2015/09/29}{Fix spurious space with paragraphed critical notes when using \LuaLaTeX.}
% \changes{v2.2.0}{2015/09/29}{Increase line list version number to ensure compatibility with new options of \reledpar package.}
% \changes{v2.2.1}{2015/10/05}{Compatibility with \LaTeX format 2015/10/01.}
% \changes{v2.2.2}{2015/10/09}{Fix a bug in \protect\cs{sethangingsymbol}.}
% \changes{v2.2.2}{2015/10/09}{Fix a bug with old version of \protect\package{etex}.}
% \hyphenation{man-u-script man-u-scripts}
% \changes{v2.3.0}{2015/10/14}{Warning message when using some setting commands inside rightside environment (deprecated behavior)}
% \changes{v2.3.0}{2015/10/14}{Disable empty lines as paragraph in stanza.}
% \changes{v2.3.0}{2015/10/14}{Fix incompatibility of paragraphed footnotes with \protect\package{bidi} v17.9 and following.}
% \changes{v2.3.1}{2015/10/19}{Fix spurious space when using optional argument of \protect\cs{stanza} (introduced in v2.3.0).}
% \changes{v2.4.0}{2015/10/19}{\protect\cs{Xbhooknote} and \protect\cs{bhooknoteX} work with notes in columns.}
% \changes{v2.4.0}{2015/10/19}{Fix a bug with \protect\cs{sameword} in right side.}
% \changes{v2.4.0}{2015/10/19}{Fix spurious space in two columns and three columns notes.}
% \changes{v2.4.0}{2015/10/19}{Fix a bug of \protect\cs{parindentX} and \protect\cs{Xparindent} with two columns and three columns notes.}
% \changes{v2.4.0}{2015/10/19}{Fix spurious space when using optional argument of \protect{stanza} (introduced in v2.3.0).}
% \changes{v2.4.1}{2015/10/26}{Fix a bug with \protect\cs{appref} and \protect\cs{apprefwithpage} (introduced in v2.4.0).}
% \changes{v2.4.1}{2015/10/26}{Fix a bug with tabular environments when using \protect\package{babel} or \protect\package{polyglossia} languages that override \LaTeX\ \protect\cs{roman} command, like Greek.}
% \changes{v2.4.1}{2015/10/26}{Fix a bug with tabular environments when using \protect\package{babel} or \protect\package{polyglossia} languages that override \LaTeX\ \protect\cs{roman} command, like Greek language.}
% \changes{v2.5.0}{2015/11/13}{Compatibility with new hook and tools of \protect\reledpar~2.6.0.}
% \changes{v2.5.0}{2015/11/13}{\protect\cs{lemma} can be used even when the \protect\option{nocritical} is enabled.}
% \changes{v2.5.0}{2015/11/13}{New hooks to customize page and line number appearance in endnotes.}
% \changes{v2.5.0}{2015/11/13}{New hooks: \protect\cs{Xbhookgroup} and \protect\cs{bhookgroupX}.}
% \changes{v2.5.0}{2015/11/13}{\protect\cs{appref} and \protect\cs{apprefwithpage} can take linerangesep optional argument.}
% \changes{v2.5.0}{2015/11/13}{\protect\cs{apprefwithpage} works also when \protect\option{noend} option is enabled.}
% \changes{v2.5.0}{2015/11/13}{\protect\cs{apprefwithpage} and \protect\cs{appref} print double quotation mark when the label was not defined.}
% \changes{v2.5.0}{2015/11/13}{\protect\cs{apprefwithpage} and \protect\cs{appref} work with right side crossref.}
% \changes{v2.5.0}{2015/11/13}{\protect\cs{edlabel} works now in \protect\cs{Xfootnote}.}
% \changes{v2.5.0}{2015/11/13}{Log now states `There were undefined references` when using wrong references in \protect\cs{edlineref} or \protect{edpageref}.}
% \changes{v2.5.0}{2015/11/13}{Fix spurious vertical space in \protect\env{astanza} environment (\reledpar)}
% \changes{v2.6.0}{2015/11/20}{Adds compatibility with \protect\option{innnote} and \protect\option{notenumber} options of \protect\package{indextools} package.}
% \changes{v2.6.0}{2015/11/20}{Fix a bug with footnote counter in \protect\env{ledgroup} (added in v2.5.0).}
% \changes{v2.6.0}{2015/11/20}{Fix bug, introduced in v2.5.0, with footnote numbering in parallel typesetting when using \protect\package{perpage} package.}
% \changes{v2.7.0}{2015/11/29}{Warning for duplicate and undefined labels are parsable by latexmk}
% \changes{v2.7.0}{2015/11/29}{Warning for duplicate labels does not send any more a false line and page number}
% \changes{v2.7.0}{2015/11/29}{Fix a bug with \protect\cs{SErefwithpage}.}
% \changes{v2.7.0}{2015/11/29}{Fix (again) bugs with footnote numbering in parallel typesetting while using \protect\env{ledgroup} environments (bug added in v2.5.0).}
% \changes{v2.7.0}{2015/11/29}{When using \protect\package{hyperref} package, add links for \protect\cs{SEref} and related, \protect\cs{appref} and related.}
% \changes{v2.7.0}{2015/11/29}{When using \protect\package{hyperref} package, add links from critical footnotes and critical endnotes to the line of text they refers}
% \changes{v2.7.0}{2015/11/29}{When using \protect\package{hyperref} package, add link in familiar footnotes between the footnote marks in the text and the footnote marks in the footnote}
% \changes{v2.7.0}{2015/11/29}{Fix bugs in compatibility with \protect\option{innote} and \protect\option{notenumber} options of \protect\package{indextools} package, when indexing outside of a \protect\env{ledgroup}.}
% \changes{v2.7.0}{2015/11/29}{New commands to make glossaries connected to page and linenumber with the \protect\package{glossaries} package}
% \changes{v2.7.0}{2015/11/29}{Add dash as default page range separator for \protect\cs{SEonlypage}}
% \changes{v2.7.0}{2015/11/29}{Delete parenthesis after \protect\cs{SErefonlypage}.}
% \changes{v2.7.0}{2015/11/29}{New setting commands: \protect\cs{setSErefonlypageprefixsingle} and \protect\cs{setSErefonlypageprefixmore}}
% \changes{v2.7.0}{2015/11/29}{Debug \protect\cs{SErefonlypage} when referring to only one page.}
% \changes{v2.7.1}{2015/12/06}{Debug \protect\cs{Xbhookgroup} hooks executed on columnar footnotes (moved to a larger group, to take effect).}
% \changes{v2.7.2}{2015/12/13}{Fix problem of hyphenation when using \protect\package{hyperref} package (added in v2.7.0).}
% \changes{v2.8.0}{2016/01/15}{\protect\macpackage cross-referencing can take advantage of \protect\package{xr} package.}
% \changes{v2.8.0}{2016/01/15}{No indentation for paragraphed notes in ledgroup. Can be changed with \protect\cs{Xparindent} and \protect\cs{parindentX}.}
% \changes{v2.8.0}{2016/01/15}{More \protect\cs{edgls\ldots} commands.}
% \changes{v2.8.1}{2016/02/22}{Warnings for undefined labels are really parsable by latexmk}
% \changes{v2.8.2}{2016/02/27}{Fix a bug with \protect\cs{AtEveryPstart} added in version 2.0.0.}
% \changes{v2.8.2}{2016/02/27}{Fix a bug with vertical space after the between-sectioning command as optional argument of a \protect\cs{pstart} and \protect\cs{pstart} content}
% \changes{v2.8.2}{2016/02/27}{Fix a bug concerning indent in a paragraph immediately following a sectioning command (bug NOT fixed on reledpar)}
% \changes{v2.9.0}{2016/03/23}{Allow continuing line numbering between normal text and parallel text, using \protect\cs{pausenumbering} and \protect\cs{resumenumbering} and the \protect\option{continuousnumberingwithcolumns} option.}
% \changes{v2.9.0}{2016/03/23}{Fix a bug when using \protect\cs{lineneation}\protect\arg{page} and \protect\cs{pausenumbering}\protect\ldots\protect\cs{resumenumbering}.}
% \changes{v2.9.0}{2016/03/23}{Write correct metadata in numbered files when using \protect\cs{pausenumbering}\protect\ldots\protect\cs{resumenumbering}.}
% \changes{v2.9.0}{2016/03/23}{Fix a bug with three- and two-column footnote setting (added in v.2.4.0).}
% \changes{v2.9.0}{2016/03/23}{Fix spurious space inside three-column familiar footnote.}
% \changes{v2.9.1}{2016/04/09}{Fix a bug when notes start with ``plus'' or ``minus''.}
% \changes{v2.9.2}{2016/04/30}{Fix a bug with \protect\package{hyperref} package when a lemma starts with ``plus'' or ``minus'' (bug introduced in v.~2.7.0).}
% \changes{v2.9.3}{2016/05/02}{Fix a bug with line number position and reset added by v.~2.9.0}
% \changes{v2.10.0}{2016/05/08}{Add \protect\cs{AtEveryStanza} and \protect\cs{AtEveryStopStanza}.}
% \changes{v2.10.0}{2016/05/08}{More specific error messages.}
% \changes{v2.10.0}{2016/05/08}{Fix a bug in \protect\cs{ledlsnotefontsetup} and \protect\cs{ledrsnotefontsetup} which could not handle \protect\cs{color} command properly.}
% \changes{v2.10.1}{2016/05/18}{Add `nopenalties` option.}
% \changes{v2.10.1}{2016/05/18}{Fix a bug introduced in v.~1.4: not paragraphed critical footnotes could prevent marginal line number from being displayed}
% \changes{v2.11.0}{2016/06/02}{Prevent \protect\cs{Xtxtbeforenotes} hook from causing notes to go beyond the bottom margin}
% \changes{v2.11.0}{2016/06/02}{Make \protect\cs{parafootsepX} work}
% \changes{v2.11.0}{2016/06/02}{Fix a bug in \protect\cs{Xparafootsep} in parallel typesetting}
% \changes{v2.11.0}{2016/06/02}{Add new tools to produce an apparatus of manuscripts}
% \changes{v2.12.0}{2016/06/16}{Fix a bug with familiar footnote number in optional argument of \protect\cs{pstart} or \protect\cs{pend} in parallel typesetting}
% \changes{v2.12.0}{2016/06/16}{Add \protect\cs{hidenumberingonleftpage} and \protect\cs{hidenumberingonrightpage}}
% \changes{v2.12.0}{2016/06/16}{\protect\cs{preXnotes} becomes \protect\cs{Xprenotes} (naming convention)}
% \changes{v2.12.0}{2016/06/16}{Add \protect\option{auxdir} option.}
% \changes{v2.12.0}{2016/06/16}{Add \protect\cs{toendnotes} and related.}
% \changes{v2.12.0}{2016/06/16}{Fix a bug when using \protect\cs{chapter} in optional argument of \protect\cs{pstart} in parallel typesetting in combination with the \protect\option{noeledsec} option.}
% \changes{v2.12.0}{2016/06/16}{Fix spurious vertical space in \protect\cs{chapter} when used as optional argument of \protect\cs{pstart} in parallel tyepsetting.}
% \changes{v2.12.0}{2016/06/16}{Fix a bug with \protect\cs{ledinnernote} and \protect\cs{ledouternote} in parallel typesetting}
% \changes{v2.12.0}{2016/06/16}{More accurate message to control the position of \protect\cs{Xfootnote} and \protect\cs{applabel} in the \protect\LaTeX\ code}
% \changes{v2.12.0}{2016/06/16}{Fix a bug in critical and familiar footnotes when using uppercase letters with accent mark}
% \changes{v2.12.0}{2016/06/16}{Make endnote compatible with \protect\cs{sameword} mechanism}
% \changes{v2.13.0}{2016/06/18}{Version 2.13.0 never existed.}
% \changes{v2.13.1}{2016/06/18}{In critical footnotes, the right side flag is printed only if requested explicitly with \protect\cs{Xlineflag} (bug added in v.~2.5.0).}
% \changes{v2.13.2}{2016/06/24}{Fix a bug added in v.~11.2 which could make parallel typesetting not work.}
% \changes{v2.13.3}{2016/06/28}{Makes \protect\cs{Xendafterpagenumbe} affecting \protect\cs{SErefwithpage}}
% \changes{v2.14.0}{2016/07/01}{Hyperref with the line number inside critical footnotes is correct when using \protect\cs{xxref}}
% \changes{v2.14.0}{2016/07/01}{Some internal changes for new features of \protect\reledpar.}
% \changes{v2.14.1}{2016/07/04}{Fix a bug when using \protect\cs{footnoteX} in the first argument of \protect\cs{edtext}.}
% \changes{v2.14.1a}{2016/07/14}{Fix problematic typos in the handbook.}
% \changes{v2.15.0}{2016/07/22}{Add `byline` arrangement.}
% \changes{v2.15.0}{2016/07/22}{Fix \protect\cs{Xtxtbeforenotes} in ledgroup.}
% \changes{v2.15.1}{2016/09/07}{Fix \protect\cs{edindex} in tabular environments.}
% \changes{v2.15.2}{2016/09/12}{Fix a bug with \protect\package{fancyhdr} package 3.8 and later.}
% \changes{v2.15.3}{2016/09/26}{Fix a bug with \protect\cs{section} in optional argument of \protect\cs{pstart} and empty line before \protect\cs{pend} (bug added in v2.8.2).}
% \changes{v2.15.3}{2016/09/26}{Simplification of the sectioning command code.}
% \changes{v2.16.0}{2016/10/02}{Display a warning message if using a version of \protect\LaTeX\ that is too old.}
% \changes{v2.16.0}{2016/10/02}{Deleted dead code.}
% \changes{v2.16.0}{2016/10/02}{New options for \protect\cs{fnpos} and \protect\cs{mpfnpos} to set a customized order for familiar and critical footnotes.}
% \changes{v2.16.0}{2016/10/02}{Compatibility with new features of \protect\reledpar}
% \changes{v2.16.0}{2016/10/02}{Fix a bug with \protect\cs{Xtxtbeforenotes} for notes in three or two columns}
% \changes{v2.16.0}{2016/10/02}{Fix a bug with \protect\cs{Xgroupbylines} for notes in two columns}
% \changes{v2.16.0}{2016/10/02}{Fix a bug with `notenumber' option of \protect\package{indextools} package when indexing texts in familiar footnotes.}
% \changes{v2.16.0}{2016/10/02}{When indexing texts in familiar footnotes with \protect\cs{edtext}, refer to the line number where the footnote is called.}
% \changes{v2.16.0}{2016/10/02}{When indexing texts in sidenotes with \protect\cs{edtext}, refer to the line number where the sidenote is called.}
% \changes{v2.16.0}{2016/10/02}{Fix potential bug when using \protect\cs{edindex} in critical footnotes.}
% \changes{v2.16.0}{2016/10/02}{Add \protect\cs{Xendpagenumberonlyfirst}, \protect\cs{Xendpagenumberonlyfirstifsingle}, \protect\cs{Xendpagenumberonlyfirstintwo}, \protect\cs{Xendinplaceofpagenumber} and \protect\cs{Xendsympagenum} hooks.}
% \changes{v2.16.0}{2016/10/02}{When \protect\cs{edindex} is called outside of a \protect\cs{beginnumbering}\protect\ldots\protect\cs{endnumbering} structure, it is automatically switched to \protect\cs{index}, with a warning message.}
% \changes{v2.16.1}{2016/10/04}{Fix a bug with redefinition of the style of the footnote number (bug added in v2.12.0)}
% \changes{v2.16.2}{2016/10/07}{Error message if \protect\package{footmisc} is loaded after \protect\package{reledmac}.}
% \changes{v2.16.2}{2016/10/07}{Fix a bug introduced by v2.16.1 when using  non-expandable control sequence, like \protect\cs{normalfont}, in the footnote number style.}
% \changes{v2.16.3}{2016/10/12}{Fix a bug with \protect\cs{SEref} (bug added in v2.7.0).}
% \changes{v2.16.4}{2016/10/16}{Fix a bug with vertical space before sectioning command in optional argument of \protect\cs{pstart} (bug added in v2.15.3).}
% \changes{v2.16.5}{2016/10/20}{Fix potential spurious spaces in endnotes.}
% \changes{v2.16.6}{2016/11/14}{Take into account \protect\cs{linenumberstyle} when using \protect\cs{edlineref}.}
% \changes{v2.16.6}{2016/11/14}{Fix a bug with the line number style in \protect\cs{doennotes} when referring to right side line in parallel typesetting.}
% \changes{v2.16.7}{2016/12/12}{Fix a bug with \protect\cs{numberpstarttrue} when using multiple \protect\cs{beginnumbering}\ldots\ \protect\cs{endnumbering}.}
% \changes{v2.16.7}{2016/12/12}{Fix a bug with \protect\cs{msdata} when using multiple \protect\cs{beginnumbering}\ldots\ \protect\cs{endnumbering}.}
% \changes{v2.16.8}{2016/12/16}{Fix a bug with \protect\cs{edindex} in footnotes in parallel typesetting.}
% \changes{v2.17.0}{2016/12/23}{Add \protect\cs{edglsadd} command.}
% \changes{v2.17.0}{2016/12/23}{Add \protect\cs{setmsdataposition} setting.}
% \changes{v2.17.1}{2017/01/22}{Fix spurious space in paragraphed footnotes when using \protect\LuaLaTeX without using Right-To-Left text.}
% \changes{v2.17.2}{2017/01/25}{Change log message when numbered files still don't exist, in order to improve compatibility with \protect\emph{latexmk}.}
% \changes{v2.17.3}{2017/01/31}{Fix a bug with \protect\cs{doendnotesbysection} and \protect\cs{doendnotes}.}
% \changes{v2.17.4}{2017/02/10}{Fix a bug with \protect\cs{setSErefonlypageprefixsingle} and \protect\cs{setSErefonlypageprefixmore}.}
% \changes{v2.17.5}{2017/02/12}{Fix a bug with \protect\cs{pstartref} when refering to the left side in parallel typesetting.}
% \changes{v2.18.0}{2017/02/22}{Fix a bug when using both \protect\cs{Xnumberonlyfirstintwolines} or \protect\cs{Xnumberonlyfirstinline} and \protect\cs{Xparafootsep} and \protect\cs{Xsymlinenum}.}
% \changes{v2.18.0}{2017/02/22}{Fix a bug when using a \protect\cs{edtext} in two lines or more in right-to-left typesetting with \protect\XeLaTeX.}
% \changes{v2.18.1}{2017/03/20}{Fix a bug when using \protect\cs{msdata} with \protect\LuaLaTeX or with the \protect\package{hyperref} package.}
% \changes{v2.19.0}{2017/04/14}{Add better compatibility with the \protect\package{csquotes} package when using familiar footnotes.}
% \changes{v2.19.0}{2017/04/14}{Add \protect\cs{footnoteXmark} and \protect\cs{footnoteXtext} commands.}
% \title{\Macpackage \\
% \changes{v2.19.0}{2017/04/14}{Fix a bug with paragraph indent after sectioning command.}
% \changes{v2.20.0}{2017/05/04}{Fix a bug when using familiar footnotes in \protect\cs{eledsection} and related.}
% \changes{v2.20.0}{2017/05/04}{Reset font specification at the beginning of familiar footnotes.}
% \changes{v2.20.0}{2017/05/04}{Add starred version of \protect\cs{AtEveryPstart}, \protect\cs{AtEveryPend}, \protect\cs{AtEveryStanza} and \protect\cs{AtEveryStopStanza}.}
% \changes{v2.20.0}{2017/05/04}{Add \protect\cs{AtStartEveryStanza},  \protect\cs{BeforeEveryStopStanza},  \protect\cs{AtEndEveryPend},  \protect\cs{AtStartEveryPstart}.}
% \changes{v2.20.0}{2017/05/04}{Add second optional argument to \protect\cs{pstart}, \protect\cs{pend} and \protect\cs{stanza}.}
% \changes{v2.20.0}{2017/05/04}{Add third and fourth optional argument to \protect\cs{newverse}.}
% \changes{v2.21.0}{2017/06/04}{Fix a bug when using formatting command in the argument of \protect\cs{edindex} inside \protect\cs{edtext}.}
% \changes{v2.21.0}{2017/06/04}{Now, as explained in the handbook, a \protect\cs{edindex} inside \protect\cs{edtext} only creates an index reference to the main text, and not to the critical footnote.}
% \changes{v2.21.0}{2017/06/04}{Add the possibility of nested \protect\cs{sameword} commands.}
% \changes{v2.22.0}{2017/06/08}{Fix a bug added in v2.16.0  when using \protect\cs{Xtxtbeforenotes} with paragraphed or normal footnotes.}
% \changes{v2.22.0}{2017/06/08}{Fix a bug with three and two columns critical footnotes, broken in v.~2.17.6.}
% \changes{v2.22.0}{2017/06/08}{Add \protect\cs{txtbeforenotesX} hook.}
% \changes{v2.22.0}{2017/06/08}{Add \protect\cs{txtbeforenotesonlyonceX} and \protect\cs{Xtxtbeforenotesonlyonce} hooks.}
% \changes{v2.22.1}{2017/07/07}{Compatibility with new version of \protect\reledpar.}
% \changes{v2.22.1}{2017/07/07}{Fix a bug with some commands inside \protect\cs{sameword}.}
% \changes{v2.22.2}{2017/07/17}{Do not print footnotes at the first run.}
% \changes{v2.23.0}{2017/07/31}{Add \protect\option{swcaseinsensitive} option}
% \changes{v2.23.0}{2017/07/31}{Optimisation of the code added on v2.22.2 to not print footnotes at the first run.}
% \changes{v2.24.0}{2017/08/17}{When a \protect\cs{setlinenum} is used, it is stronger than the \protect\cs{lineation}\protect\arg{page} setting.}
% \changes{v2.24.0}{2017/08/17}{Fix a bug with \protect\cs{edlabel} at the beginning of a \protect\cs{pstart}.}
% \changes{v2.24.0}{2017/08/17}{Add \protect\cs{swnoexpands} macro to avoid problems with not fully expandable macro inside \protect\cs{sameword}.}
% \changes{v2.24.0}{2017/08/17}{Fix spurious space with \protect\cs{labelpstarttrue}}
% \changes{v2.24.1}{2017/08/31}{Compatibility with \protect\parpackage 2.20.2}
% \changes{v2.24.2}{2017/10/21}{Fix bug between tabular environments and endnotes}
% \changes{v2.25.0}{2017/11/05}{Add \protect\cs{Xendtxtbeforenotes} hook}
% \changes{v2.26.0}{2017/11/11}{Fix bug in \protect\cs{xpstartref}}
% \changes{v2.26.0}{2017/11/11}{Add a mechanism for annotation of stanza line numbering}
% \changes{v2.26.1}{2017/11/26}{Fix bug with \protect\cs{linenumannotation}}
% \changes{v2.26.2}{2017/12/22}{Fix bug with \protect\cs{Xgroupbyline} and optional argument of critical footnotes.}
% \changes{v2.26.2}{2017/12/22}{Fix bug with \protect\cs{Xgroupbyline} for the series after the first one.}
% \changes{v2.26.2}{2017/12/22}{Fix bug with \protect\cs{Xgroupbyline} and \protect\cs{Xparafootsep}.}
% \changes{v2.26.2}{2017/11/22}{Fix bug with \protect\cs{linenumannotation} in parallel typesetting}
% \changes{v2.26.3}{2018/01/06}{Fix bug added by v2.26.0 with notes in parallel typesetting}
% \changes{v2.26.4}{2018/01/18}{Fix bug when using \protect\cs{numberpstarttrue} and alterning between manual \protect\cs{pstart} and automatic \protect\cs{pstart} produced by \protect\cs{autopar}}
% \changes{v2.26.5}{2018/01/18}{Fix bug with using \protect\cs{eledsection} and related when alternate normal typesetting and parallel typesetting}
% \changes{v2.26.5}{2018/01/28}{Check that users have a enough recent version of \protect\package{xparse}}
% \changes{v2.26.5}{2018/01/18}{Fix bug when using \protect\cs{eledsection} with the \protect\option{continuousnumberingwithcolumns} of \protect\parpackage}
% \changes{v2.26.5}{2018/01/28}{Fix bug with \protect\option{continuousnumberingwithcolumns}}
% \changes{v2.26.6}{2018/02/28}{Fix bug with \protect\cs{lineation} by page and nexted \protect\cs{edtext} between two pages (added in v.~2.24.0)}
% \changes{v2.26.7}{2018/04/07}{Fix page number in footnote and endnotes when using \protect\option{sameparallelpagenumber} option of \protect\parpackage and typesetting critical text in single mode after critical text in double page mode}
% \changes{v2.26.8}{2018/04/30}{Fix bug in some specific cases, introduced by v.2.27.7}
% \changes{v2.26.9}{2018/05/02}{Fix bug with critical footnotes line number when alternating between \protect\cs{numberlinefalse} and \protect\cs{numberlinetrue}.}
% \changes{v2.26.9}{2018/05/02}{Fix bug with page number in footnote after \protect\cs{mainmatter} (bug introduced in v2.26.7)}
% \changes{v2.26.9}{2018/05/02}{Workaround with a bug of \protect\LaTeX 2018/04/01 patch level 3 to generate the .sty file from a .ins file}
% \changes{v2.26.10}{2018/05/05}{Really fix bug with page number in footnote after \protect\cs{mainmatter} (bug introduced in v2.26.7)}
% \changes{v2.26.10}{2018/05/05}{Add error message when insertion a \protect\cs{pstart} or \protect\cs{pend} inside \protect\cs{edtext} arguments}
% \changes{v2.26.11}{2018/05/21}{Allow to use \protect\cs{edtext} inside \protect\cs{sameword}}
% \changes{v2.26.12}{2018/07/19}{Precise minimal version of xparse package required.}
% \changes{v2.27.0}{2018/09/13}{Add \protect\cs{doinsidethislinehook}.}
% \changes{v2.27.1}{2018/10/12}{Fix spurious space in \protect\cs{hidenumbering}.}
% \changes{v2.28.0}{2018/11/30}{Familiar footnotes can take an optional argument to manually define the footnote mark.}
% \changes{v2.28.1}{2018/12/22}{Fix bug with the alignment of the columns of two and three columns critical footnotes.}
% \changes{v2.29.0}{2019/01/08}{Fix bug with \protect\cs{linenumannotation} and `nofamiliar` option.}
% \changes{v2.29.0}{2019/01/08}{Really reset line number annotation at each line}
% \changes{v2.29.0}{2019/01/08}{Add \protect\option{noresetlinenumannotation}}
% \changes{v2.29.0}{2019/01/08}{Fix little bug with \protect\cs{msdata}}
% \changes{v2.30.0}{2019/01/22}{Add \protect\cs{Xnoidenticallinenumannotation} and \protect\cs{Xendnoidenticallinenumannotation} hooks}
% \changes{v2.30.0}{2019/01/22}{Add separator between line number annotations in margin. Add \protect\cs{setlinenumannotationsep}}
% \changes{v2.31.0}{2019/02/22}{Add \protect\option{noprefix} and \protect\option{prefixmore} to \protect\cs{appref} and \protect\cs{SEref}.}
% \changes{v2.31.1}{2019/03/03}{Fix bug with \protect\cs{Xgroupbyline}, which could produce spurious blank lines.}
% \changes{v2.31.1}{2019/03/03}{Fix bug with multiple footnote layer and \protect\cs{Xgroupbyline}.}
% \changes{v2.31.1}{2019/03/03}{Fix incompatibility between \protect\cs{Xgroupbyline} and \protect\package{hyperref} package.}
% \changes{v2.31.1}{2019/03/03}{Fix incompatibility between \protect\cs{Xgroupbyline} and optional argument of critical footnotes.}
% \changes{v2.31.1}{2019/03/03}{Fix bug in vertical spacing with \protect\cs{Xgroupbyline}.}
% \changes{v2.31.1}{2019/03/03}{Fix bug with indentation with \protect\cs{Xgroupbyline}.}
% \changes{v2.31.1}{2019/03/03}{Fix bug with \protect\cs{Xhangindent} and \protect\cs{hangindentX} for right-to-left texts.}
% \changes{v2.31.2}{2019/04/03}{Fix bug with familiar footnote containing non-default font (introduced with v.~2.20.0).}
% \changes{v2.31.3}{2019/06/19}{Fix bug with paragraphed footnote in RTL context.}
% \changes{v2.32.0}{2019/07/15}{Add \protect\cs{Xlinenumannotationonlyfirst}, \protect\cs{Xlinenumannotationonlyfirstintwo}, \protect\cs{Xsymlinenumannotation}, \protect\cs{Xendlinenumannotationonlyfirst}, \protect\cs{Xendlinenumannotationonlyfirstintwo} and \protect\cs{Xendsymlinenumannotation}.}
% \changes{v2.32.1}{2019/07/21}{Do not print \protect\cs{Xendsep} if we print \protect\cs{Xendsymlinenum}.}
% \changes{v2.32.1}{2019/07/21}{When using \protect\cs{parindentX} or \protect\cs{Xparindent} and stanza, use the normal indentation in the footnote, not the verse indentation.}
% \changes{v2.32.2}{2019/11/28}{Fix spurious vertical space in familiar footnotes with \protect\LuaLaTeX.}
% \changes{v2.32.3}{2019/12/09}{Fix bug with critical footnotes when typesetting Arabic text with \protect\package{polyglossia}.}
% \changes{v2.32.4}{2020/02/04}{Fix bug \protect\cs{footnoteXmark} and \protect\cs{footnoteXtext}.}
% \changes{v2.32.4}{2020/01/04}{\protect\cs{footnoteXmark} and \protect\cs{footnoteXtext} can now have an optional argument, setting the footnote number.}
% \changes{v2.32.4}{2020/02/04}{Fix bug when using \protect\cs{Xgroupbyline} and twocol arrangement.}
% \changes{v2.32.4}{2020/02/04}{Fix bug with three and two columns footnotes when using \protect\package{bidi}.}
% \changes{v2.32.5}{2020/03/08}{Fix bug with \protect\cs{edindex} inside \protect\cs{eledsection} and related.}
% \changes{v2.32.5}{2020/03/08}{Fix bug with page number in index with \protect\cs{edindex} when indexing a critical notes.}
% \changes{v2.32.5}{2020/03/08}{Fix bug with macro inside \protect\cs{sameword} with no-\protect\XeTeX\ engines.}
% \changes{v2.32.6}{2020/04/19}{Fix bug with glossary entries inside the first argument of \protect\cs{edtext}.}
% \changes{v2.32.6}{2020/04/19}{Add hyperref link when inserting glossary entries.}
% \changes{v2.32.7}{2020/05/03}{Fix bug with \protect\cs{parafootsepX}.}
% \changes{v2.32.7}{2020/05/03}{Fix bug with \protect\cs{lineation}\arg{pstart} and \protect\cs{edtext} in the very first line of a \protect\cs{pstart}.}
% \changes{v2.32.7}{2020/05/03}{Fix spurious spaces at the very first line of \protect\env{edtabular} environnments.}
% \changes{v2.32.8}{2020/05/24}{Add subline number in manuscript apparatus.}
% \changes{v2.33.0}{2020/05/31}{Add startstanzaindentsrepetition feature.}
% \changes{v2.33.0}{2020/05/31}{Add antilabe feature.}
% \changes{v2.33.0}{2020/05/31}{Add \protect\cs{Xinnotemark} and \protect\cs{innotemarkX} hooks.}
% \changes{v2.33.1}{2020/06/06}{Fix a spacing bug when the argument of \protect\cs{antilabe} contains more than one word.}
% \changes{v2.34.0}{2020/06/24}{Add \protect\cs{Xpstartonlyfirst} and \protect\cs{Xstanzaonlyfirst}.}
% \changes{v2.34.0}{2020/06/24}{Add \protect\cs{Xpstartseparator}.}
%      Typeset scholarly editions with \LaTeX\thanks{This file (\dtxfilename)
% has version number \fileversion, last revised \filedate.}}
%
% \author{%
% Ma\"ieul Rouquette\thanks{\texttt{maieul at maieul dot net}} \\
% {\small based on the original \protect\package{ledmac} by} \\
% Peter Wilson \\
% Herries Press \\
% {\small which was based on the original \edmac, \tabmac{} and \edstanza{} by} \\
% John Lavagnino, Dominik Wujastyk, Herbert Breger and Wayne Sullivan.
% }
%
% \date{}
%
%
% \maketitle
%
%
% \begin{abstract}
%
%  The \macpackage provides many tools in order to typeset scholarly editions.
% It is based on the \eledmac package, which was based on the \ledmac package, which was based on the \edmac \TeX\ package.
%
% It can be used in combination with \parpackage in order to typeset two texts in parallel,
% like an original text and its translation in a modern language.
%
%
% \Macpackage provides many tools and options. Normally, they are all documented in this file.
% Also provided is a help folder, ``\href{examples/.}{examples}''. The folder contains additional examples (although not for every possible case).
% Examples starting with ``1-'' are for basic uses, those starting with ``2-'' are for advanced uses.
%
% To report bugs or request a new feature, please go to ledmac GitHub page and click on ``New Issue'': \url{https://github.com/maieul/ledmac/issues/}.
% You must create an account on github.com to access my page (maieul/ledmac).
% GitHub accounts are free for open-source users. You can post messages in English or in French (preferred).
%
% You can subscribe to the \macpackage mail list at:\\ \url{http://geekographie.maieul.net/146}
% \end{abstract}
%
% \renewcommand{\numberline}[1]{#1~}
% \tableofcontents
%
%
% \section{Introduction}
%
% \subsection{Aim of the package}
%
% The \macpackage\ package, together with \LaTeX, provides several
% important facilities for formatting critical editions of texts in
% a traditional manner. Major features include:
% \begin{itemize}
% \item automatic stepped line numbering, by page, section or paragraph;
% \item sub-lineation within the main series of line numbers;
% \item variant readings automatically keyed to line numbers;
% \item caters to both prose and verse;
% \item multiple series of footnotes and endnotes;
% \item block or columnar formatting of the footnotes;
% \item simple tabular material may be line numbered;
% \item indexing keyed to page and line numbers.
% \end{itemize}
%
% \Macpackage allows the scholar engaged in preparing a critical
% edition to focus attention wholly on the task of creating the
% critical text and evaluating the variant readings, text-critical
% notes and testimonia. \LaTeX{} and \Macpackage\ will take care of
% the formatting and visual correlation of all the disparate types
% of information.
%
% Apart from \macpackage there are other \LaTeX\ packages for typesetting critical editions.
% However, the aim of \macpackage is to provide an ``all in one'' and flexible tool in the field of critical editions.
%
% Any suggestions for new features are welcome.
%
% This manual contains a general description of how to use \macpackage, followed by
% the complete source code and its extensive documentation (in sections~\ref{overview} and following, enumerated with Roman numerals).
% It ends with a list of actions to do when migrating from one version to other, a change history and an index to the
% source code.
%
% You do not need to read the source code for this package in order to use it; we
% provide this code primarily for reference, and many of our
% comments on it repeat material that is also found in earlier sections. But no documentation,
% however thorough, can cover every question that comes up and many can be
% answered quickly by consulting the code. On a first reading,
% we suggest that you read only the general documentation in
% sections~\ref{howto}, unless you are particularly interested in the innards of \macpackage.
%
% \subsection{History}
%
% \subsubsection{\edmac}
%
% The original version of \edmac{} was \texttt{TEXTED.TEX}, written
% by John Lavagnino\index{Lavagnino, John}
% in late 1987 and early 1988 for formatting
% critical editions of English plays.
%
% John passed these macros on to Dominik Wujastyk\index{Wujastyk, Dominik}
% who, in
% September--October 1988, added the footnote paragraphing mechanism,
% margin swapping and other changes to suit his own purposes, making the
% style more like that traditionally used for classical texts in Latin and
% Greek (e.g., the Oxford Classical Texts series). He also wrote some
% extra documentation and sent the files out to several people. This
% version of the macros was the first to be called \edmac.
%
% The present version was developed in the summer of 1990, with the
% intent of adding necessary features, streamlining and documenting
% the code, and further generalizing it to make it easily adaptable
% to the needs of editors in different disciplines.  John did most
% of the general reworking and documentation, with the financial
% assistance of the Division of the Humanities and Social Sciences,
% California Institute of Technology.  Dominik adapted the code to
% the conventions of Frank Mittelbach's\index{Mittelbach, Frank}
% \verb"doc" option, and added some documentation, multiple-column
% footnotes, cross-references, and crop marks.\footnote{This version of
% the macros was used to format the Sanskrit text in volume I of {\em
% Metarules of P\=a\d ninian Grammar\/} by Dominik Wujastyk (Groningen:
% Forsten, 1993).} A description by John and Dominik of this version of
% \edmac{} was published as `An overview of \edmac: a \PlainTeX\
% format for critical editions', \emph{TUGboat} \textit{11} (1990),
% pp.\,623--643.
%
% From 1991 through 1994, the macros continued to evolve, and were tested at a
% number of sites.  We are very grateful to all the members of the (now defunct)
% \verb"edmac@mailbase.ac.uk" discussion group who helped us with
% smoothing out the bugs and infelicities in the macros.
% Ron Whitney\index{Whitney, Ron} and our anonymous reviewer at
% the TUG were both of great help in ironing out last-minute
% wrinkles, while Ron made some important suggestions which may help
% to make future versions of \edmac{} even more efficient.
% Wayne
% Sullivan,\index{Sullivan, Wayne} in particular, provided several
% important fixes and contributions, including adapting the
% Mittelbach\slash
% Sch\"opf\index{Sch\"opf, Rainer}\index{Mittelbach, Frank} `New
% Font Selection Scheme' for use with \PlainTeX\ and \edmac.
% Another project Wayne has worked
% on is a \verb"DVI" post-processor which works with an \edmac{}
% that has been slightly modified to output \protect\cs{special}s.  This
% combination enables you to recover to some extent the text of
% each line as {\sc ascii} code, facilitating the creation of
% concordances, an {\em index verborum}, etc.
%
% As of 1994, we were pleased to be able to say that \edmac{} was
% being used for the real-life book production of several interesting
% editions, such as the Latin texts of Euclid's {\sl
% Elements},\footnote{Gerhard Brey\index{Brey, Gerhard} used \edmac{} in
% the production of Hubert L.~L.\ Busard\index{Busard, Hubert L.~L.} and
% Menso Folkerts,\index{Folkerts, Menso} {\em Robert of Chester's
% (?)\index{Chester, Robert of} Redaction of Euclid's\index{Euclid} {\em
% Elements}, the so-called Adelard II\index{Adelard II} Version}, 2 vols.,
% (Basel, Boston, Berlin: Birkh\"auser, 1992).} an edition of the letters
% of Nicolaus Copernicus,\footnote{Being prepared at the German Copernicus
% Research Institute, Munich.}\index{Copernicus, Nicolaus} Simon
% Bredon's\index{Bredon, Simon} {\em Arithmetica},\footnote{Being prepared
% by Menso Folkerts {\em et al.}, at the Institut f\"ur Geschichte der
% Naturwissenschaften in Munich.} a Latin translation by Plato of
% Tivoli\index{Plato of Tivoli} of an Arabic astrolabe
% text,\footnote{Richard Lorch,\index{Lorch, Richard} Gerhard
% Brey\index{Brey, Gerhard} {\em et al.}, at the same Institute.} a Latin
% translation of part II of the Arabic {\em Algebra\/} by Ab\=u K\=amil
% Shuj\=a' b.~Aslam,\index{Abu Kamil Shuja' b.~Aslam}\footnote{Richard
% Lorch, `Ab\=u K\=amil on the Pentagon and Decagon' in {\em Vestigia
% Mathematica}, ed.\ M. Folkerts and J. P. Hogendijk (Amsterdam, Atlanta:
% Rodopi, 1993).} the Latin {\em Rithmachia\/} of Werinher von
% Tegernsee,\footnote{Menso Folkerts, `Die {\em Rithmachia\/} des Werinher
% von Tegernsee', ibid.} a middle-Dutch romance epic on the
% Crusades,\footnote{Geert H. M. Claassens,\index{Claassens, Geert H. M.}
% {\em De Middelnederlandse Kruisvaartromans}, (Amsterdam: Schiphower en
% Brinkman, 1993).} a seventeenth-century Hungarian politico-philosophical
% tract,\footnote{Emil Hargittay, {\em Cs\'aky Istv\'an: Politica
% philosophiai Okoskod\'as-szerint val\'o rendes \'eletnek p\'eld\'aja
% (1664--1674)\/} (Budapest: Argumentum Kiad\'o, 1992).} an anonymous
% Latin compilation from Hungary entitled {\em Sermones Compilati in
% Studio Gererali Quinqeecclesiensi in Regno Ungarie},\footnote{Being
% produced, as was the previous book, by Gyula Mayer\index{Mayer, Gyula}
% in Budapest.} the collected letters and papers of
% Leibniz,\index{Leibniz}\footnote{Leibniz, {\em S\"amtliche Schriften und
% Briefe}, series {\sc I, III, VII,} being edited by Dr.\ H.\
% Breger\index{Breger, Herbert}, Dr.~N. G\"adeke\index{G\"adeke, Nora} and
% others at the Leibniz-Archiv, Nieders\"achsische Landesbibliothek, Hannover.
% (see \url{http://www.nlb-hannover.de/Leibniz})}
% Theodosius's\index{Theodosius} {\em Spherics}, the German {\em
% Algorismus} of Sacrobosco,\index{Sacrobosco} the Sanskrit text of the
% {\em K\={a}\'{s}ik\={a}\-v\d{r}tti\/} of V\={a}mana\index{Vamana} and
% Jay\={a}ditya\index{Jayaditya},\footnote{Being prepared at Poona and
% Lausanne Universities.} and the English texts of Thomas
% Middleton's\index{Middleton, Thomas} collected works.
%
% \subsubsection{\ledmac}
%
%
%
%    Version 1.0 of \tabmac{} was released by
% Herbert Breger\index{Breger, Herbert} in October
% 1996. This added the capability for typesetting tabular material.
%
%    Version 0.01 of \edstanza{} was released by
% Wayne Sullivan~\index{Sullivan, Wayne}
% in June 1992, to help a colleague with typesetting Irish verse.
%
%    In March 2003 Peter Wilson started an attempt to port \edmac{}
% from TeX to LaTeX. The starting point was \edmac{} version 3.16
% as documented on 19 July 1994 (available from CTAN). In August 2003
% the \tabmac{} functions were added; the starting point for these
% being version 1.0 of Ocober 1996. The \edstanza{} (v0.01) functions were
% added in February 2004. Sidenotes and regular footnotes in numbered
% text were added in April 2004. This port was called \ledmac (\LaTeX\ \edmac).
%
% Since July~2011, ledmac is maintained by Ma\"ieul Rouquette. It is increasingly
% powerful and flexible, but it also has become increasingly divergent from the original TeX macro.
%
% \subsubsection{\eledmac}
% Important changes were put in version 1.0, to make \ledmac more easily extensible (see \reff{displayoptions}).
% These changes can trigger small problems with the old customization. That is why a new name was selected: \eledmac (extended \ledmac).
%
% To migrate from \ledmac to \eledmac, please read \reff{migration}.
%
% \subsubsection{\reledmac}
%
% \eledmac has facilitated the creation of customized critical editions.
% However, the changes made to allow such customization were made in a non-systematic way.
% Many deprecated commands were kept and many technical `debts' were accumulated,
% hindering the future evolution of the package.
%
% For these reasons, Maïeul Rouquette decided on a spring cleaning of the code.
% As some commands name were changed, the resulting compatibility was broken (a little).
%
% A new name was selected: \reledmac (extended renewed \eledmac).
% To migrate from \eledmac to \reledmac, please read \reff{migratereledmac}.
%
% \subsection{Bibliography}
% A collaborative list of works edited with (r)(e)(ledmac is available at
% \url{https://www.zotero.org/groups/209265/critical_editions_typeset_with_edmac_ledmac_eledmac_and_reledmac/}.
% Please add your own edition made with (r)(e)ledmac.
%
% If you write a book or an article about (r)(e)ledmac, please add it on the collaborative bibliography on \url{https://www.zotero.org/groups/1024519/}.
% \subsection{Acknowledgements}
% Maïeul Rouquette may thank his predecessor, and all the \macpackage\ communauty. Especially, he may thanks all the people who checks English spell and grammar for the handbook.
% \section{How the package works --- the problem of the number of \LaTeX\ runs}\label{howto}
% The \macpackage package is a three-pass package like \LaTeX\ itself.
% Although your textual apparatus and line
% numbers will be printed on the first run, it takes two more
% compilations by \LaTeX\ to be sure that everything is correctly
% placed, and one more if you typeset right-to-left text with \XeLaTeX.
% If you make any subsequent changes altering the number
% of lines or notes, the input file may similarly
% require three passes to get everything to the right place.
% \Macpackage will tell you that you need to make more runs when it detects changes,
% but it does not expend the labor to check this thoroughly. If you have
% problems with a line or two misnumbered at the top of a page, try
% running \LaTeX\ once or twice more.
%
% \textbf{However, the best way to be sure that one has made the right number of runs
% is to use some of \LaTeX's run scripts like \emph{latexmk}}.
%
% \section{Compatibility warning}
%
% If you use other classes than \cs{article} or \cs{book}, or modify the layout with \package{geometry}, some settings should be made to have correct height for the blocks of notes.
%
%Please read \reff{Xmaxhnotes}.
%
% If you use the \LuaTeX\ engine, you need \LuaTeX\ 1.1.0 or later.
% A file may mix \emph{numbered} and \emph{unnumbered} text.
%
% Numbered text is printed with marginal line numbers and can include
% footnotes and endnotes that are referenced to those line numbers:
% this is how you will want to print the text that you are editing.
%
% Unnumbered text is not printed with line numbers, and you can't
% use \macpackage's note commands with it: this is appropriate for
% introductions and other material added by the editor around the
% edited text.
%
%
% \section{Options}
% The package can be loaded with a number of global options which are listed here. There are two types of options:
% 1) options which provide specific features, and, 2) options which optimize the package's performance.
% It is advisable for you to read the relevant parts of the handbook, before reading about the first type of option
% (specific features), but you can look at the second type (package optimization) in your first reading of the manual.
%
% \subsection{Specific features}
% \begin{description}
% \item[draft] underlines lemmas in the main text.
% \item[auxdir] \macpackage generates auxiliary files.
% It could be useful to store them in a specific directory.
% You can set it using \option{auxdir}=\meta{folder} option.
% Note the two following point:
%    \begin{enumerate}
%       \item \TeX\ is not able to create folder. You should create it yourself.
%       \item The option does not change the default \LaTeX auxiliary files (.aux, .toc, \ldots).
%    \end{enumerate}
% \item[antilabe] enable \cs{antilabe} feature (see \reff{antilabe});
% \item[eledmac-compat] help to migrate from \eledmac to \reledmac (see \reff{eledmac-compat});
% \item[nopenalties] must be called in some cases when using paragraphed endnotes (see \reff{nopenalties)};
% \item[nopbinverse] prevents page break within verse environment;
% \item[noquotation] by default, the quotation environment is redefined within numbered text. You can disable this redefinition with \verb|noquotation| (see \reff{noquotation});
% \item[noresetlinenumannotation] does not reset the annotations to line number at each line (see \reff{annotation});
% \item[parapparatus] by default, the apparatus cannot contain paragraph breaks; this option enables paragraphing inside the apparatus;
% \item[swcaseinsensitive] make \cs{sameword} command case insensitive;
% \item[widthliketwocolumns] set the width of the text printed in a single column to be the same as the width of the text printed in two parallel columns with \parpackage. This is useful when alternating between normal and parallel typesetting;
% \item[xindy] and \verb|xindy+hyperref| select \verb+xindy+ as the index processor (\reff{xindy}).
% \end{description}
%
% \subsection{Optimizing package performance}\label{option:performance}
% \begin{description}
% \item[nocritical] disables tools for critical footnotes (\protect\cs{Afootnote}, \protect\cs{Bfootnote} etc.). If you do not need critical footnotes, this option lets \macpackage\ run faster.
% It will also preserve room for other packages.
% \item[noeledsec] disables tools for \protect\cs{eledsection} and related commands (\reff{eledsection}).
% \item[noend] disables tools for endnotes (\protect\cs{Aendnote}, \protect\cs{Bendnote} etc.). If you do not need endnotes, this option lets \macpackage\ run faster.
% It will also preserve room for other packages.
% \item[nofamiliar] disables tools for familiar footnotes (\protect\cs{footnoteA}, \protect\cs{footnoteB} etc.). If you do not need familiar footnotes, this option lets \macpackage\ run faster.
% It will also preserve room for other packages.
% \item[noledgroup] \macpackage allows use of a series of critical notes and a new series of normal notes inside minipage and ledgroup environments (see \reff{ledgroup}). However, such features use up computer memory, at the expense of other processing needs. So if you do not need this feature, use \verb+noledgroup+ option. This should make \macpackage faster.
% \item[series] \Macpackage\  defines five levels of notes: A, B, C, D, E.
% Using all these levels consumes memory space and processing speed.
% This is why, if your work does not require the entire A--E series, you can narrow down the available number of series.
% For example, if you only need A and B series, call the package with \verb+series={A,B}+ option.
% \end{description}
%
% \section{Text lines and paragraphs numbering}
%
% \subsection{Text lines numbering}
% \DescribeMacro{\beginnumbering}
% \DescribeMacro{\endnumbering}
% Each section of numbered text must be preceded by \protect\cs{beginnumbering}
% and followed by \protect\cs{endnumbering}, as in the following example. \\
% \egstart
% \begin{verbatim}
% \beginnumbering
% Text
% \endnumbering
% \end{verbatim}
% \egend
%
% The \protect\cs{beginnumbering} macro resets the line number to zero,
% reads an auxiliary file called \meta{jobname}.\file{nn} (where
% \meta{jobname} is the name of the main input file for this job,
% and \file{nn} is 1 for the first numbered section, 2 for
% the second section, and so on), and then creates a new version of
% this auxiliary file to collect information during this run. The
% first instance of \protect\cs{beginnumbering} also opens a file called
% \meta{jobname}\file{.<series>end} to receive the text of the endnotes.
% \protect\cs{endnumbering} closes the \meta{jobname}.\file{nn} file.
%
% If the line numbering of a text is to be continuous from start to end,
% then the whole text will be typed between one pair of
% \protect\cs{beginnumbering} and \protect\cs{endnumbering} commands. But your text
% will most often contain chapter or other divisions marking sections
% that should be independently numbered, and these will be appropriate
% places to begin new numbered sections.
%
% \Macpackage has to read and store in memory
% a certain amount of information about the entire section when it
% encounters a \protect\cs{beginnumbering} command, so it speeds up the
% processing and reduces memory use when a text is divided into a larger
% number of sections (at the expense of multiplying the number of
% external files that are generated).
%
% \subsection{Paragraphs}
% \subsubsection{Basics}
% \DescribeMacro{\pstart}
% \DescribeMacro{\pend}
% Within a numbered section, each paragraph of numbered text must
% be marked using the \protect\cs{pstart} and \protect\cs{pend} commands like this: \\
% \egstart
% \begin{verbatim}
% \pstart
% Paragraph of text.
% \pend
% \end{verbatim}
% \egend
%
% Text that appears within a numbered section but is not marked with
% \protect\cs{pstart} and \protect\cs{pend} will not be numbered.
%
% The following example shows the proper section and paragraph
% markup and the kind of output that would typically be generated:
% \egstart
% \begin{verbatim}
% \beginnumbering
% \pstart
% This is a sample paragraph, with
% lines numbered automatically.
% \pend
%
% \pstart
% This paragraph too has its
% lines automatically numbered.
% \pend
%
% The lines of this paragraph are
% not numbered.
%
% \pstart
% And here the numbering begins
% again.
% \pend
% \endnumbering
% \end{verbatim}
% \egend
%
% \subsubsection{Automatically producing  \protect\cs{pstart} \ldots{} \protect\cs{pend}}
% \DescribeMacro{\autopar}\label{autopar}
% You can use \protect\cs{autopar} to avoid the nuisance of this paragraph markup
% and still have every paragraph automatically numbered.  The
% \protect\cs{autopar} command needs to be called inside a \cs{beginnumbering}\ldots\cs{endnumbering} structure, as follows:
% \egstart
% \begin{verbatim}
%   \beginnumbering
%   \autopar
%
%   A paragraph of numbered text.
%
%   Another paragraph of numbered
%   text.
%
%   \endnumbering
% \end{verbatim}
% \egend
%
% \protect\cs{autopar} fails, however, on paragraphs that start with a
% \verb"{" or with any other command that starts a new group before it
% generates any text. Such paragraphs need to be started explicitly,
% before the new group is opened,
% using \protect\cs{indent}, \protect\cs{noindent}, or \protect\cs{leavevmode}, or using
% \protect\cs{pstart} itself.\footnote{For a detailed study of the
% reasons for this restriction, see Barbara Beeton, `Initiation
% rites', \textit{TUGboat} \textbf{12} (1991),
% pp.\,257--258.\protect\index{Beeton, Barbara Ann Neuhaus Friend}}
%
% \subsubsection{Content before specific \protect\cs{pstart} and after specific \protect\cs{pend}}\label{pstart:optionalarg}
% \changes{v1.12.0}{2014/08/05}{Optional arguments for \protect\cs{pstart} and \protect\cs{pend}.}
% Both \protect\cs{pstart} and \protect\cs{pend} can take an optional argument in brackets.
% Its content will be printed before the beginning of \protect\cs{pstart} / after the end of  \protect\cs{pend} instead of the argument of \protect\cs{AtEveryPstart} / \protect\cs{AtEveryPend}.
%
% Note that a \cs{noindent} will be automatically added before this argument, and, consequently, a \cs{parskip} will be inserted.
% You can use a second optional argument in brackets to avoid that \cs{noindent}.
% \begin{verbatim}
% \pstart[foo] % A \noindent will be inserted before foo.
% \pstart[][foo]% No \noindent before foo.
% \end{verbatim}
%
% The second optional argument of \cs{pstart} / \cs{pend} replaces the argument of \cs{AtEveryPstart*} / \cs{AtEveryPend*}.
%
% If you need to start a \protect\cs{pstart} with brackets, or to add brackets after a \protect\cs{pend}, just add a \protect\cs{relax} between \protect\cs{pstart}\,\ldots\,\protect\cs{pend} and the brackets.
%
% This feature is also useful when typesetting verses (see \reff{verse}) or \parpackage\ (see \reff{eledpar}).
%
% A \protect\cs{noindent} is automatically added before this argument.
%
% \subsubsection{Content before every \protect\cs{pstart} and after every \protect\cs{pend}}
% \changes{v1.15.0}{2015/01/12}{New commands \protect\cs{AtEveryPstart} and \protect\cs{AtEveryPend}.}
% \label{AtEveryPstart} \DescribeMacro{\AtEveryPstart}\DescribeMacro{\AtEveryPend}
% You can use both \protect\cs{AtEveryPstart} and \protect\cs{AtEveryPend}.
% Their arguments will be printed before every \protect\cs{pstart} begins / after  every \protect\cs{pend} ends.
%
% Note that a \cs{noindent} will be inserted before the argument, and, consequently, a \cs{parskip}. You can use the starred version of \protect\cs{AtEveryPstart} and \protect\cs{AtEveryPend} to avoid the \cs{noindent}.
%
% \DescribeMacro{\AtStartEveryPstart}\DescribeMacro{\AtEndEveryPend}
%  The argument of \cs{AtStartEveryPstart} / \cs{AtEndEveryPend} will be inserted at the beginning  / the end of every \cs{pstart} / \cs{pend} in the same paragraph. For example, if you want  each \cs{pstart} to start with a star, you can use:
% \begin{verbatim}
% \AtStartEveryPstart{*}
% \end{verbatim}
% Instead of manually doing
% \begin{verbatim}
% \pstart * Real pstart content.\pend
% \end{verbatim}
% \subsubsection{Numbering paragraphs (\protect\cs{pstart})}
% \changes{v0.12.0}{2011/10/01}{Possibility to number \protect\cs{pstart}.}
% It is possible to insert a number at every \protect\cs{pstart} command; you must use the \DescribeMacro{\numberpstarttrue}\protect\cs{numberpstarttrue} command to have it. You can stop the numbering with \DescribeMacro{\numberpstartfalse}\protect\cs{numberpstartfalse}.
% You can redefine the command \DescribeMacro{\thepstart}\protect\cs{thepstart} to change style.
% You can change the value of the pstart number by using \emph{after} \protect\cs{beginnumbering}:
% \begin{verbatim}
% \setcounter{pstart}{value}
% \end{verbatim}
% On each \protect\cs{beginnumbering} the numbering restarts.
% \changes{v0.15.0}{2012/06/11}{Possibility to print \protect\cs{pstart} number at the sides of the text.}
%
% \DescribeMacro{\sidepstartnumtrue}
% With the \protect\cs{sidepstartnumtrue} command, the number of \protect\cs{pstart} will be printed at the sides of the text.
% In this case, the line number will be not printed.
%
% \changes{v1.1.0}{2012/09/25}{Add \protect\cs{labelpstarttrue}.}
% \DescribeMacro{\labelpstarttrue}
% With the \protect\cs{labelpstarttrue} command, a \protect\cs{label} added just after a \protect\cs{pstart} will refer to the number of this pstart.
%
% \subsubsection{Languages written in Right to Left}
% If you use languages written right to left with \LuaLaTeX\ or \XeLaTeX,
% you must switch text direction \emph{before} the \protect\cs{pstart} command.
%
% \subsubsection{Memory limits}
% \textbf{This paragraph is kept for history, but the problems described below should not appear with the most recent version of \LaTeX.}
%
% \label{pause}
% \DescribeMacro{\pausenumbering}
% \DescribeMacro{\resumenumbering}
% \Macpackage stores a lot of information about line numbers and
% footnotes in memory as it goes through a numbered section.  But
% at the end of such a section, it empties its memory out, so to
% speak.  If your text has a very long numbered section it is
% possible that your \LaTeX\ may reach its memory limit.  There are
% two solutions to this.
%
% The first solution is to get a larger \LaTeX\ with increased memory.
%
% The second solution is to
% split your long section into several smaller ones.  The trouble
% with this is that your line numbering will start again at zero
% with each new section.  To avoid this problem, we provide
% \protect\cs{pausenumbering} and \protect\cs{resumenumbering} which are just
% like \protect\cs{endnumbering} \ldots\ \protect\cs{beginnumbering}, except that
% they arrange for your line numbering to continue across the break.
% Use \protect\cs{pausenumbering} only between numbered paragraphs:
% \egstart
% \begin{verbatim}
% \beginnumbering
% \pstart
% Paragraph of text.
% \pend
% \pausenumbering
%
% \resumenumbering
% \pstart
% Another paragraph.
% \pend
% \endnumbering
% \end{verbatim}
% \egend
%
% We have defined these commands as two macros, in case you find it necessary
% to insert text between numbered sections without disturbing the
% line numbering.  But if you are really just using these macros to
% save memory, you might as well type,
% \egstart
% \begin{verbatim}
% \newcommand{\memorybreak}{\pausenumbering\resumenumbering}
% \end{verbatim}
% and type \protect\cs{memorybreak} between the relevant \protect\cs{pend} and
% \protect\cs{pstart}.
% \egend
%
% \subsection{Lineation commands}
%
% \subsubsection{Disabling lineation}
% \DescribeMacro{\numberlinefalse} \DescribeMacro{\numberlinetrue}
% Line numbering can be disabled with  \protect\cs{numberlinefalse}. It can be enabled again with \protect\cs{numberlinetrue}.
%
% \textbf{This feature must be used with caution.}
% \begin{itemize}
%   \item It should not be use if you have critical footnotes after \cs{numberlinefalse}.
%   \item It could be used in the following cases:
%      \begin{itemize}
%         \item You want only familiar footnotes, not critical footnotes;
%         \item You want only parallel typesetting (using \parpackage) but no critical footnotes.
%         \item You disable, for a portion of text, line numbering
%      \end{itemize}
%   \item It must not be used if:
%     \begin{itemize}
%         \item You do not want to have the line number in the margins, but do want to use critical footnotes. In this case, set \cs{firstlinenum} to a big value, such as 100,000 (\reff{firstlinenum}).
%         \item You want to freeze the line numbering for some line, but still keep critical footnotes. In this case, use \cs{startlock} (\reff{startlock}).
%     \end{itemize}
% \end{itemize}
% A successor to \reledmac\ may disable this feature.
% \subsubsection{Setting lineation start and step}
% \DescribeMacro{\firstlinenum}\label{firstlinenum}
% \DescribeMacro{\linenumincrement}
%  By default, \macpackage numbers every 5th line. There are two counters that control this behaviour:
% \verb?firstlinenum? and \verb?linenumincrement?. They can be changed using \protect\cs{firstlinenum}\marg{num} and
% \protect\cs{linenumincrement}\marg{num}. \protect\cs{firstlinenum} specifies the first
% line that will have a printed number, and \protect\cs{linenumincrement} is
% the difference between successive numbered lines. For example, to start printing numbers at the first line
% and to have every other line numbered: \\
% \verb?\firstlinenum{1} \linenumincrement{2}?
%
% \DescribeMacro{\firstsublinenum}
% \DescribeMacro{\sublinenumincrement}
% There are similar commands, \protect\cs{firstsublinenum}\marg{num} and
% \protect\cs{sublinenumincrement}\marg{num} for controlling sub-line numbering.
%
% \DescribeMacro{\linenumberlist}\label{linenumberlist}
% You can define \protect\cs{linenumberlist} to specify a non-uniform distribution
% of printed line numbers. For example: \\
% \verb?\gdef\linenumberlist{1,2,3,5,7,11,13,17,19,23,29}? \\
% to have numbers printed on prime-numbered lines only. There must be
% no spaces within the definition which consists of comma-separated integer
% numbers. The numbers can be in any order but it is easier to read if you
% put them in numerical order. Either omitting the definition of
% \protect\cs{linenumberlist} or following the empty definition \\
% \verb?\gdef\linenumberlist{}? \\
% the standard numbering sequence is applied. The standard sequence
% is that specified by the combination of the \verb+firstlinenum+,
% \verb+linenumincrement+, \verb+firstsublinenum+ and
% \verb+linenumincrement+ counter values.
%
% \subsubsection{Setting lineation reset}
% \DescribeMacro{\lineation}
% \changes{v1.0.0}{2012/09/15}{Debug in lineation command}
% Lines can be numbered either by page, by pstart or by section; you specify
% this using the \protect\cs{lineation}\marg{arg}
% macro, where \meta{arg} is either
% \texttt{page}, \texttt{pstart} or \texttt{section}.

% You may only use this command at places
% where numbering is not in effect; you can't change the lineation system
% within a section. You can change it between sections: they don't all
% have to use the same lineation system.
% The package's standard setting is \verb"\lineation{section}". If the lineation is by pstart, the pstart number will be printed before the line number in the notes.
%
% \subsubsection{Setting line number margin}
% \DescribeMacro{\linenummargin}
% The command \protect\cs{linenummargin}\marg{location} specifies the margin
% where the line (or pstart) numbers will be printed. The permissable values
% for \meta{location} are \texttt{left}, \texttt{right}, \texttt{inner}, or \texttt{outer}:
% for example, \verb"\linenummargin{inner}".
% The package's default setting is \\
% \verb"\linenummargin{left}" \\
% to typeset the numbers in the left hand margin.
% You can change this whenever you're not in the middle of
% making a paragraph.
%
% More precisely, the value of
% \protect\cs{linenummargin} used is the value in effect at the \protect\cs{pend}
% of a numbered paragraph. Apart from an initial setting for
% \protect\cs{linenummargin}, only change \protect\cs{linenummargin} after a \protect\cs{pend},
% whereupon it will apply to all following numbered paragraphs, until
% changed again (changing it between a \protect\cs{pstart} and \protect\cs{pend}
% pair will apply the change to all of the current paragraph).
%
% \subsubsection{Other settings}
%
% \DescribeMacro{\leftlinenum}
% \DescribeMacro{\rightlinenum}
% \DescribeMacro{\linenumsep}
% When a marginal line number is to be printed, there are many ways to display it.
% You can redefine \protect\cs{leftlinenum} and \protect\cs{rightlinenum} to
% change the way marginal line numbers are printed in the
% left and right margins respectively; the initial
% versions print the number in font \protect\cs{numlabfont} (described
% below) at a distance \protect\cs{linenumsep} (initially set to one pica)
% from the text.
%
% \subsection{Changing the line numbers}
%
% Normally, line numbering starts at 1 for the first line of
% a section and increments by one for each line thereafter. There
% are various common modifications of this system and the
% commands described here allow you to put such modifications
% into effect.
%
% \subsubsection{Sublineation}
% \DescribeMacro{\startsub}
% \DescribeMacro{\endsub}
% You insert the \protect\cs{startsub} and \protect\cs{endsub} commands in your text
% to turn sub-lineation on and off. For example, stage directions in plays are often numbered with sub-line
% numbers: as line $10.1$, $10.2$, $10.3$, rather than as $11$, $12$, and $13$.
% Titles and headings are sometimes numbered with sub-line numbers as well.
%
% When sub-lineation is in effect, the line number counter is
% frozen and the sub-line counter advances instead. If one of these
% commands appears in the middle of a line, it doesn't take effect
% until the next line; in other words, a line is counted as a line
% or sub-line depending on what it started out as, even if it
% changes in the middle.
%
% \DescribeMacro{\Xsublinesep}
% \DescribeMacro{\Xsublinesepside}
% You can change the separator between the line number and the subline number either by using \cs{Xsublinesep} without any optional argument (\reff{Xsublinesep}) or by using \cs{Xsublinesepside}. In the second case, it will change the separator only for line numbers in the margins, not in the footnotes.
% \subsubsection{Locking lineation}\label{startlock}
% \DescribeMacro{\startlock}
% \DescribeMacro{\endlock}
% The \protect\cs{startlock} command, used in running text, locks the
% line number at its current value, until you insert \protect\cs{endlock}.
% It can tell for itself whether you are in a patch of line or
% sub-line numbering. One use for line-number locking is in printing
% poetry: there the line numbers should be those of verse lines
% rather than of printed lines, even when a verse line requires several
% printed lines. But in this case you may use the \cs{stanza} mechanism, see \reff{verse}.
%
% \DescribeMacro{\lockdisp}
% When line-number locking is used,
% several printed lines may have the same line number, and you have to
% specify whether you want the number attached to the first printed
% line or the last, or whether you just want the number printed by
% them all, assuming that the settings of the previous parameters
% requires the display of a line number for this line.
% You specify your preference using \protect\cs{lockdisp}\marg{arg}; its
% argument is a word, either \verb+first+, \verb+last+, or \verb+all+.
% The package initially sets this as \protect\cs{lockdisp}\verb+{first}+.
%
% \subsubsection{Setting and changing line number}
% \DescribeMacro{\setline}
% \DescribeMacro{\advanceline}
% In some cases you may want to modify the line numbers that are
% automatically calculated: if you are printing only fragments
% of a work but want to print line numbers appropriate to a complete
% version, for example. The \protect\cs{setline}\marg{num} and
% \protect\cs{advanceline}\marg{num} commands
% may be used to change the current line's number (or the sub-line
% number, if sub-lineation is currently on). They change both the
% marginal line numbers and the line numbers passed to the notes.
% \protect\cs{setline} takes one argument, the value to which you want
% the line number set; it must be $0$ or greater. \protect\cs{advanceline}
% takes one argument, an amount that should be added to the current
% line number; it may be positive or negative.
%
% \DescribeMacro{\setlinenum}
% The \protect\cs{setline} and \protect\cs{advanceline} macros should only be used
% within a \protect\cs{pstart}\ldots\protect\cs{pend} group. The \protect\cs{setlinenum}\marg{num}
% command can be used outside such a group, for example, between
% a \protect\cs{pend} and a \protect\cs{pstart}. It sets the line number
% to \meta{num}.
% It has no effect if used within a \protect\cs{pstart}\ldots\protect\cs{pend} group.
%
% \subsubsection{Line number style}
% \DescribeMacro{\linenumberstyle}
% \DescribeMacro{\sublinenumberstyle}
%  Line numbers are normally printed as arabic numbers. You can
% use \protect\cs{linenumberstyle}\marg{style} to change the numbering style.
% \meta{style} must be one of:
% \begin{description}
% \item[\texttt{Alph}] Uppercase letters (A \ldots\ Z).
% \item[\texttt{alph}] Lowercase letters (a \ldots\ z).
% \item[\texttt{arabic}] Arabic numerals (1, 2, \ldots)
% \item[\texttt{Roman}] Uppercase Roman numerals (I, II, \ldots)
% \item[\texttt{roman}] Lowercase Roman numerals (i, ii, \ldots)
% \end{description}
% Note that with the \texttt{Alph} or \texttt{alph} styles, `numbers'
% must be between 1 and 26 inclusive.
%
% Similarly \protect\cs{sublinenumberstyle}\marg{style} can be used to change
% the numbering style of sub-line numbers, which is normally arabic numerals.
%
% \subsubsection{Skipping and hidding number}
% \DescribeMacro{\skipnumbering}
% When inserted into a numbered line the macro \protect\cs{skipnumbering} causes
% the numbering of that particular line to be skipped; that is, the line
% number is unchanged and no line number will be printed.
% Note that if you use it in \protect\cs{stanza}, you must call it at the beginning of the verse.
%
% \DescribeMacro{\hidenumbering}
% \changes{v1.21.0}{2015/04/13}{Add \protect\cs{hidenumbering}}
% When inserted into a numbered line, the macro \protect\cs{hidenumbering} causes
% the number for that particular line to be hidden; namely, no line number will print.
% Note that if you use it in \protect\cs{stanza}, you must call it at the beginning of the verse.
%
% \DescribeMacro{\hidenumberingonleftpage}
% \cs{hidenumberingonleftpage} is like \protect{hidenumbering}, but is applied only on left page. \cs{hidenumberingonrightpage} is applied on right page.
% They can be useful  if the position of the line number is depending of the position of the page, but the position of marginal note is fixed.
% \subsection{Adding annotations to line numbers}\label{annotation}
% You may want to have two or more numbers associated with a line of text.
% Consider, for example, the following cases:
% \begin{itemize}
%  \item You want to split a line of verse into two parts depending upon some stylistic / rhythmic / linguistic convention.
%  \item You want to add the line number used by a previous edition of the work.
%  \item You want to typeset biblical text, and use division in verse.
% \end{itemize}
% In such instances, you must add the second number manually, as \macpackage\  can't determine a general pattern for such numbering, which depends too heavily upon the edited text.\footnote{However, you may create your own commands dealing with such patterns which will in turn call \macpackage\ commands.}
%
% \DescribeMacro{\linenumannotation}
% To resolve this issue, \macpackage\ allows you to annotate line numbers using the following command:
% \begin{verbatim}
% \linenumannotation{<annotation>}
% \end{verbatim}
%
% The annotation can contain any textual value (whether number, text, or other) such as the line number from the older edition.
% Here are some characteristics of line number annotation:
% \begin{itemize}
%  \item An annotation is associated with a line of text. It is reset with each new line of text, unless you use the \option{noresetlinenumannotation} option of \macpackage.
%  \item It is printed alongside the line number in the margin.
%  \item It is printed following the line number in critical footnotes and endnotes.
%  \item And of particular interest: the annotation is printed in the critical note \emph{only} when the \cs{edtext} is issued after the \cs{linenumannotation}.
%  \item If two or more annotations are called before an \cs{edtext}, the last one is used in associated notes.
%  \item If an annotation is called within an \cs{edtext}, it is printed as an annotation for the end of the lemma.
% \end{itemize}
% Here is an example, supposing we are on line 1:
% \begin{verbatim}
% \edtext{first lemma}
% \linenumannotation{A}
% \edtext{second lemma}{...}
% \edtext{third%
%   \linenumannotation{B}
%  lemma}{...}
% \edtext{fourth lemma}&
% \end{verbatim}
% In the critical notes, the line number will be followed
% \begin{itemize}
%   \item by nothing in the first lemma, as  there is no annotation for this line;
%   \item by \enquote{A} for the second lemma;
%   \item by \enquote{A-B} for the third lemma, as it starts while annotation A is still in effect and it finishes after annotation B has already taken effect;
%   \item by \enquote{B} for the fourth lemma.
% \end{itemize}
% \subsubsection{Modifying annotation associated with a specific note}\label{lineannot}
%
% The \cs{linenum} (\reff{linenum}) macro changes the line number passed to a note.
% \DescribeMacro{\lineannot}The \cs{lineannot} macro does the same for the annotations.
% It takes one argument, containing the beginning and ending annotations separated by a pipe (\verb+|+).
% As with \cs{linenum}, if one wishes to change some specific part of the annotation, one can use
% \begin{verbatim}
% \lineannot{|b}% to change the ending annotation
% \lineannot{a|}% to change the beginning annotation
% \lineannot{a|b}% to change both
% \lineannot{\empty|}% to delete the beginning annotation
% \end{verbatim}
% \subsubsection{Changing the position of the annotation}\label{annotationposition}
% By default, annotations are placed after line numbers in both margin and footnote.
%
% \DescribeMacro{\Xlinenumannotationposition}
% \DescribeMacro{\Xendlinenumannotationposition}
% To change this behaviour, one can use one of the following commands:
% \begin{itemize}
%  \item \cs{Xlinenumannotationposition}\oarg{s}\marg{v} changes the position in critical footnotes with \meta{s} for the series of footnotes to which it applies, where \meta{s} may be a comma-separated list of series. When \meta{s} is empty, the change applies also to annotations at the sides of the page, alongside the line number.
%  \item \cs{Xlinenumannotationpositionside}\marg{v} changes the position at the sides of the page, alongside the line numbers.
%
% Note that \cs{Xlinenumannotationposition} without any optional argument will override this setting.
%  \item \cs{Xendlinenumannotationposition}\oarg{s}\marg{v} changes the position in critical endnotes,
% \meta{s} for the series of endnotes to which it applies, where \meta{s} may once again be a comma-separated list of series.
% \end{itemize}
% In each of these three commands, \meta{v} can be \option{after} or \option{before} to indicate position with regards to the line number.
% \subsubsection{Changing the macro in which annotations are wrapped}\label{wraplinenumannotation}
% By default, annotations are wrapped in the \cs{textsuperscript} macro.
% You can modify this using one of the following:
% \begin{itemize}
%   \item \cs{Xwraplinenumannotation}\oarg{s}\marg{cmd} for critical footnotes; \meta{s} indicates the series of notes to which it applies and may be a comma-separated list of series.
% When \meta{s} is empty, the change applies to the annotations in the margins also---around the line number---as well as to the annotations referenced using the \cs{annotationref} command of the crossref mechanism (\reff{crossref}).
%   \item \cs{Xwraplinenumannotationside}\marg{cmd} for annotations in the margins only.
%
% Note that \cs{Xwraplinenumannotation} without any optional argument will override this setting.
%   \item \cs{Xwraplinenumannotationref}\marg{cmd} for annotations referenced using the \cs{annotationref} command of the crossref mechanism (\reff{crossref}).
%
% Note that \cs{Xwraplinenumannotation} without any optional argument will override this setting.
%   \item \cs{Xendwraplinenumannotation}\oarg{s}\marg{cmd} for critical endnotes, where \meta{s} indicates the series of notes to which it applies, which may be a comma-separated list.
% \end{itemize}
% \meta{cmd} is a command which can take one argument; the backslash is required though.
%
% For example, if you do not wish to have annotations in the margins, but do want to have them in bold in the critical footnotes and endnotes, you say:\footnote{The \cs{@gobble} command takes one argument, and returns nothing.}
% \begin{verbatim}
% \makeatletter
% \Xwraplinenumannotation{\textbf}
% \Xendwraplinenumannotation{\textbf}
% \Xwraplinenumannotationside{\@gobble}
% \makeatother
% \end{verbatim}
% \subsubsection{Not printing the second identical annotations}
% If you print only line number annotation, you may get in critical notes something like \verb+6-6+,
% because the starting and ending annotations are the same.
% \DescribeMacro{\Xnoidenticallinenumannotation}
% \DescribeMacro{\Xendnoidenticallinenumannotation}
% You can avoid that using \\
% \cs{Xnoidenticallinenumannotation}\oarg{s}, for critical footnotes \\
% or
% \cs{Xendnoidenticallinenumannotation}\oarg{s}
% \subsubsection{Separator between annotations}
% \DescribeMacro{\setlinenumannotationsep}
% If there an more than one annotation in the same line, there are separated by a comma.
% If you want to change the separator, you can use \\
% \cs{setlinenumannotationsep}\marg{sep}
% \subsubsection{Annotations in the apparatus}
% Some other options for annotations in the apparatus are described in \reff{annotation-inapparatus}
% \subsection{Executing code at each line}\label{linehook}
% \Macpackage provides an advanced feature for users.
% \DescribeMacro{\dolinehook}\DescribeMacro{\doinsidelinehook}
% The argument passed to \protect\cs{dolinehook}\marg{arg} will be executed
% before slicing a new line in the paragraph.
% The argument passed to \protect\cs{doinsidelinehook}\marg{arg} will be executed before printing a new line, when the line number has already been fixed.
% In many cases, the latter is more useful than the former.
% The file \href{examples/2-line_numbers_in_header.tex}{examples/2-line\_numbers\_in\_header.tex} provides
% an example for printing the first and last line numbers of a page in the header.
%
% \subsection{Executing code at a specific line}
% Sometime, you want to execute a code at a precise point in the flow of your text.
% For example, if the current header of the page corresponds to the position inside the text, you may want to use \cs{markboth} (or similar) command.
% The main problem is that you need to execute \cs{markboth} when \macpackage\ typesets the text, and not when it reads it, because that could create damage with vertical spacing.
%
% \DescribeMacro{\doinsidethislinehook}
% The \cs{doinsidethislinehook}\marg{code} macro allows \meta{code} to be executed when the text is typeset. The \meta{code} will be executed in the line equivalent to the position of \cs{doinsidethislinehook} in the flow of the text.
%
% For example, with the following code:
% \begin{verbatim}
% \beginnumbering
% \pstart
% ...
% 1.\doinsidelinehook{\markboth{1}{1}} a
% \pend
% \end{verbatim}
% \verb+\markboth{1}{1}+ will be executed at the line the \verb+1.+ will be typeset.
% The \meta{code} of \cs{doinsidethislinehook}  will be executed only at the second run of \LaTeX.
%
% See the file
% \href{examples/2-subdivision-number-in-header.tex}{examples/2-subdivision-number-in-header.tex} for an example.
% Especially, the use of this command with \LaTeX\ counters is quite complex, but the example show you how to deal with this problem.
%
% \section{Apparatus commands}
%
% \subsection{Terminology}
% We call ``critical notes'' notes which refer to both a lemma, that is a part of text, and a line number.
% Critical notes are subdivided in critical footnotes and critical endnotes.
%
% We call ``familiar notes'' notes which refer to a footnote mark in the main text.
%
% \Macpackage manages many series of notes of each category.
% A series of notes is identified by an uppercase letter.
% When the series letter is at the \emph{beginning} of a command name, it refers to a critical footnote.
% When the series letter is at the \emph{end} of a command name, it refers to a familiar footnote.
%
% So :
% \begin{itemize}
%  \item \protect\cs{Afootnote} is a critical footnote of the series A.
%  \item \protect\cs{Bendnote} is a critical endnote of the series B.
%  \item \protect\cs{footnoteC} is a familiar footnote of the series C.
% \end{itemize}
% \subsection{Critical notes}
% \subsubsection{The lemma}
% \DescribeMacro{\edtext}
% Within numbered paragraphs, all footnotes and endnotes are generated
% by the \protect\cs{edtext} macro:
% \begin{verse}
% \protect\cs{edtext}\marg{lemma}\marg{commands}
% \end{verse}
%
%
% The \meta{lemma} argument is the lemma in the main text: \protect\cs{edtext}
% both prints this as part of the text, and makes it available to the
% \meta{commands} you specify to generate notes.
%
% For example:
% \egstart
% \begin{verbatim}
% I am happy:
% I saw my friend \edtext{Smith}{
% \Afootnote{Jones C, D.}}
% on Tuesday.
% \end{verbatim}
% \egmid
% \beginnumbering
% \firstlinenum{1}
% \linenumincrement{1}
% \pstart
% I am happy: I saw my friend \edtext{Smith}{
% \Afootnote{Jones C, D.}}
% on Tuesday.
% \pend
% \endnumbering
% \egend
%
% The lemma \verb?Smith? is printed as part of this sentence in
% the text, and is also made available to the footnote
% that specifies a variant, \verb?Jones C, D?. The footnote macro
% is supplied with the line number at which the lemma appears
% in the main text.
%
% The \meta{lemma} may contain further \protect\cs{edtext} commands.
%  Nesting makes
% it possible to print an explanatory note on a long passage together with
% notes on variants for individual words within the passage. For
% example:
% \egstart
% \begin{verbatim}
% I am happy : \edtext{I saw my friend
%   \edtext{Smith}{\Afootnote{Jones
%   C, D.}} on Tuesday.}{
%   \Bfootnote{The date was
%   July 16, 1954.}
% }
% \end{verbatim}
% \egmid
% \beginnumbering
% \firstlinenum{1}
% \linenumincrement{1}
% \pstart
% I am happy : \edtext{I saw my friend
%   \edtext{Smith}{\Afootnote{Jones
%   C, D.}} on Tuesday.}{
%   \Bfootnote{The date was
%   July 16, 1954.}
% }
% \pend
% \endnumbering
% \egend
%
% However, \protect\cs{edtext} cannot handle overlapping but unnested
% notes---for example, one note covering lines 10--15, and another
% covering 12--18; an \protect\cs{edtext} that starts in the \meta{lemma}
% argument of another \protect\cs{edtext} must end there, too. (The
% \protect\cs{lemma} and \protect\cs{linenum} commands may be used to
% generate overlapping notes if necessary.)
%
% \subsubsection{Footnotes}
%
% The second argument of the \protect\cs{edtext} macro, \meta{commands},
% may contain a series of subsidiary commands that generate
% various kinds of notes.
%
% \DescribeMacro{\Afootnote}
% \DescribeMacro{\Bfootnote}
% \DescribeMacro{\Cfootnote}
% \DescribeMacro{\Dfootnote}
% \DescribeMacro{\Efootnote}
% Five separate series of footnotes are maintained; each macro
% takes one argument like \protect\cs{Afootnote}\marg{text}.
% When all of the five
% are used, the \texttt{A} notes appear in a layer just below the main
% text, followed by the rest in turn, down to the \texttt{E} notes at
% the bottom.
% These are the main macros that you will use to construct
% the critical apparatus of your text.
%
% If you need more series of critical notes, please look at \reff{newseries}.
%
%\changes{v1.0.0}{2012/09/15}{Options nonum and nosep in \protect\cs{Xfootnote}.}
%\changes{v1.20.0}{2015/03/22}{Options fulllines in \protect\cs{Xfootnote}.}\label{Xfootnoteopt}
% An optional argument can be added before the text of the footnote. Its value is a comma-separated list of options.
% \label{fulllines}The available options are:
% \begin{itemize}
% \item \verb|fulllines| to disable \protect\cs{Xtwolines} and \protect\cs{Xmorethantwolines} features for this note (cf. \reff{Xtwolines}).
% \item \verb|nonum| disables line numbering for this note. A horizontal blank space is added instead. You can use \cs{Xinplaceofnumber} to set it (\reff{Xinplaceofnumber}).
% \item \verb|nosep| to disable the lemma separator for this note. A horizontal blank space is added instead. You can use \cs{Xinplaceoflemmaseparator} to set it (\reff{Xinplaceoflemmaseparator}).
% \item \verb|linerangesep=|\meta{c} to change to \meta{c} the separator between start line and end line for this particular note.
% \end{itemize}
%
% Example: \protect\cs{Afootnote}\verb|[nonum]|\marg{text}.
%
% \subsubsection{Endnotes}
% \paragraph{Inserting endnotes}
% \DescribeMacro{\Aendnote}
% \DescribeMacro{\Bendnote}
% \DescribeMacro{\Cendnote}
% \DescribeMacro{\Dendnote}
% \DescribeMacro{\Eendnote}
% The package also maintains five separate series of endnotes.
%
% If you do not need the endnotes facility, you should use \verb+noend+ option when loading \macpackage.
%
% The mechanism is similar to the one for footnotes: each macro takes one or more optional arguments and one single argument, like:\\
% \protect\cs{Aendnote}\oarg{option}\marg{text}.
%
% \label{Xendnoteopt}\meta{option} can contain a comma-separated list of values. Allowed values are:
% \begin{itemize}
% \item \verb|fulllines| to disable \protect\cs{Xendtwolines} and \protect\cs{Xendmorethantwolines} features for this particular note (cf. \reff{Xtwolines}).
% \item \verb+nonum+ to disable line number for this particular note.
% \item \verb|nosep| to disable the lemma separator for this particular note. A horizontal blank space is added instead. You can use \cs{Xendinplaceoflemmaseparator} to set it (\reff{Xendinplaceoflemmaseparator}).
% \item \verb|linerangesep=|\meta{c} to change to \meta{c} the separator between start line and end line for this particular note.
% \end{itemize}
%
%
% \paragraph{Printing endnotes}
% \DescribeMacro{\doendnotes}\label{doendnotes} Normally, endnotes are not printed: you must use the
% \protect\cs{doendnotes}\marg{s}, where \meta{s} is the letter of the series to be printed. Put this command where you want the corresponding set of endnotes printed.
% In this case, all the endnotes of the \meta{s} series are printed, for all numbered sections.
% \changes{v1.22.0}{2015/04/25}{Add \protect\cs{doendnotesbysection} command.}
% \changes{v1.22.0}{2015/04/25}{Standardize endnotes handbook.}
%
% \DescribeMacro{\doendnotesbysection} However, you may want to print the endnotes of one given series covering the first numbered section, then the endnotes of another given series covering the first numbered section, then the endnotes of the first given series covering the second numbered section, then the endnotes of the second given series covering the second numbered section, and so forth.
% In this case, use \protect\cs{doendnotesbysection}\marg{s}.
% For each value of \meta{s}, the first call of the command will print the notes for the first series, the second call will print the notes for the second series etc.
% For example, do:
% \begin{verbatim}
% \section{Endnotes}
% \subsection{First text}
% \doendnotesbysection{A}
% \doendnotesbysection{B}
% \subsection{Second text}
% \doendnotesbysection{A}
% \doendnotesbysection{B}
% \end{verbatim}
%
% Note that by default inside endnotes no separator is used between the lemma and the content.
% However you can use the \protect\cs{Xendlemmaseparator} macro to define one (\reff{Xendlemmaseparator}).
%
% As endnotes may be printed at any point in the document they always
% start with the page number where they are called.
%
% \paragraph{Code between endnotes}
% \DescribeMacro{\toendnotes}
% \DescribeMacro{\Xtoendnotes}
% Sometimes, it is useful to insert content between endnotes of the same series: for example to separate endnotes of different sections of the same text.
% In this case, you could use \emph{inside
% numbered text} the command:\\
% \cs{toendnotes}\oarg{series}\marg{content}
% where \meta{series} is a comma-separated list of the series of endnotes where \meta{content} must be inserted.
% If \meta{series} is empty, then \meta{content} is inserted to all the series.
%
% For example:
% \begin{verbatim}
% \toendnotes{\section{Section's title}}
% \end{verbatim}
%
% Alternatively, you can use \cs{Xtoendnotes}\marg{content}, where \enquote{X} must be replaced by a series letter.
%
% Remember that the endnotes are temporarily stored in an auxiliary file. That means in general you want to write the \meta{content} in the auxiliary file \emph{without expanding it}, that is without interpreting \TeX\ content.
%
% However, in some cases, you may want to write a
% once-expanded\footnote{The expansion mechanism of \TeX\ is a quite complex problem, but fundamental. We have no place to explain it fully here. Read introduction to \TeX\ to understand well.}
% version of the \meta{content}, that is the version where the commands are expanded on the first level.
% This can be, for example, to get a counter value.
% Use the starred version in this case.
% For example:
% \begin{verbatim}
% \Atoendnotes*{\string\section{Letter 1 (chap. \thechapter)}}
% \end{verbatim}
%
% \subsubsection{Paragraph in critical apparatus}
% By default, no paragraph can be made in the notes of the critical apparatus.
% You can allow it by adding the options \verb+parapparatus+ when loading the package :
% \begin{verbatim}
% \usepackage[parapparatus]{eledmac}
% \end{verbatim}
%
% Note that you \emph{cannot} use paragraphs (e.g. blank lines or \cs{par}) inside of notes, when they are set to \texttt{paragraph} arrangement!
%
% \subsubsection{Change lemma and line number}
% \DescribeMacro{\lemma}
% \changes{v1.0.0}{2012/09/15}{\protect\cs{lemma} can contain commands.}
% If you want to change the lemma that gets passed to the notes, you
% can do this by using \protect\cs{lemma}\marg{alternative} within the
% second argument to \protect\cs{edtext} and before the note commands.
% The most common use of this command is to abbreviate the lemma that's
% printed in the notes. For example:
% \egstart
% \begin{verbatim}
% I am happy :
% \edtext{I saw my friend
%   \edtext{Smith}{\Afootnote{Jones
%   C, D.}} on Tuesday.}
%   {\lemma{I \dots\ Tuesday.}
%   \Bfootnote{The date was
%   July 16, 1954.}
% }
% \end{verbatim}
% \egmid
% \beginnumbering
% \pstart
% I am happy :
% \edtext{I saw my friend
%   \edtext{Smith}{\Afootnote{Jones
%   C, D.}} on Tuesday.}
%   {\lemma{I \dots\ Tuesday.}
%   \Bfootnote{The date was
%   July 16, 1954.}
% }
% \pend
% \endnumbering
% \egend
%
% \DescribeMacro{\linenum}
% \label{linenum}
% You can use \protect\cs{linenum}\marg{arg} to change the line numbers passed to
% the notes. \meta{arg} actually consist of seven parameters: the page,
% line, and sub-line number for the start of the lemma; the same
% three numbers for the end of the lemma; and the font specifier
% for the lemma. As the argument to \protect\cs{linenum}, you specify
% those seven parameters in that order, separated by vertical bars
% (the \verb"|" character). I.e.\\
% \verb+\linenum{+\meta{start page}\verb+|+\meta{s. line}\verb+|+\meta{s. sub-l.}\verb+|+\meta{end p.}\verb+|+\meta{e. l.}\verb+|+\meta{e. sub-l.}\verb+|+\meta{font}\verb+|+\verb+}+\\
% However, you can retain the value
% computed by \macpackage for any number by simply omitting it; and
% you can omit a sequence of vertical bars at the end of the
% argument.  For example, \verb"\linenum{|||23}" changes only the ending page number of the current lemma.
%
% This command does not change the marginal line numbers in any way;
% it just changes the numbers passed to the notes. Its use comes in
% situations that \protect\cs{edtext} has trouble dealing with for
% whatever reason. If you need notes for overlapping passages that
% aren't nested, for instance, you can use \protect\cs{lemma} and
% \protect\cs{linenum} to generate such notes despite the limitations of
% \protect\cs{edtext}.  If the \meta{lemma} argument to \protect\cs{edtext} is
% extremely long, you may run out of memory; here again you can
% specify a note with an abbreviated lemma using \protect\cs{lemma} and
% \protect\cs{linenum}. The numbers used in \protect\cs{linenum} need not be
% entered manually; you can use the `\texttt{x-}' symbolic cross-referencing
% commands below (\reff{crossref}) to compute them
% automatically.
%
% Similarly, being able to manually change the lemma's font specifier
% in the notes might be important if you were using multiple scripts or
% languages. The form of the font specifier is three
% separate codes separated by \verb"/" characters, giving the family,
% series, and shape codes as defined within NFSS.
%
% \subsubsection{Changing the names of  commands for critical apparatus}
%
% The commands for generating the apparatus have been given
% rather bland names, because editors in different fields have
% widely divergent notions of what sort of notes are required, where
% they should be printed, and what they should be called. But this
% does not mean you have to type \protect\cs{Afootnote} when you would rather
% type something you find more meaningful, like \protect\cs{variant}.
%
% We recommend that you create a series of such aliases and use them
% instead of the names chosen here; all you have to do is put commands
% of this form at the start of your file:\footnote{We use \protect\cs{newcommand} and \protect\cs{newcommandx} instead of classical \protect\cs{let} command because the edtabular environments have to modify the notes definition, and we need to use the newest definition of notes. Read the handbook of \protect\package{xargs} to know more about \protect\cs{newcommandx}.}
% \begin{verbatim}
% \newcommandx{\variant}[2][1,usedefault]{\Afootnote[#1]{#2}}
% \newcommandx{\explanatory}[2][1,usedefault]{\Bfootnote[#1]{#2}}
% \newcommand{\trivial}[1]{\Aendnote{#1}}
% \newcommandx{\testimonia}[2][1,usedefault]{\Cfootnote[#1]{#2}}
% \end{verbatim}
%
%
% \subsection{Disambiguation of identical words in the apparatus}\label{sameword}
% \changes{v1.15.0}{2015/01/12}{New tools to prevent ambiguous references in lemma}
% \changes{v1.23.0}{2015/05/18}{Fix a bug with \protect\cs{sameword} when the same lemma is used for multiple notes or for nested \protect\cs{edtext}s.}
% \changes{v1.23.0}{2015/05/18}{Optional argument of \protect\cs{sameword} can be a comma-separated list of \protect\cs{edtext} depth.}
% \changes{v1.23.0}{2015/05/18}{Fix a bug with \protect\cs{sameword} when the lemma overlaps multiple line.}
% Sometimes, the same word occurs twice (or more) in the same line.
% \Macpackage provides  tools to disambiguate references in the critical notes.
% The lemma will be followed by a reference number if a given word occurs more that once in the same line.
%
% \subsubsection{Basic use}
% \DescribeMacro{\sameword} To use this tool, you have to mark every occurrence of the potentially ambiguous term with the \protect\cs{sameword} command:
%   \begin{verbatim}
%   Lupus \sameword{aut} canis \edtext{\sameword{aut}}{\Afootnote{et}} felix
%   \end{verbatim}
% In this example, \verb+aut+ will be followed, in the critical note, by the exponent \verb+2+ if it is printed in the same line as the first \verb+aut+, but it will not if it is printed in a different line. The number is printed only after the second run.
%
% \subsubsection{Case setting}
% By default, \cs{sameword} is sensitive to the case. E.g. \enquote{foo} is considered as a different word to \enquote{Foo}.
%
% You can use the \option{swcaseinsensitive} when loading the package to make \cs{sameword} insensitive to the case, i.e.
% to consider \enquote{foo} as identical \enquote{Foo}.
%
% \subsubsection{Notes about input encoding with UTF-8 processor}
%
% If you use UTF-8 processor, like \XeLaTeX\ or \LuaLaTeX, there should not be any glitches.
% However, pay attention to how characters are encoded. Similar-looking characters may be represented differently in unicode numbering.
%
% For instance, in French, ``é'' has two possible Unicode codepoints:
% \begin{itemize}
%  \item LATIN SMALL LETTER E (U+0065) + COMBINING ACUTE ACCENT (U+0301)
%  \item LATIN SMALL LETTER E WITH ACUTE (U+00E9)
% \end{itemize}
%
% Which unicode number you use depends, many times, on your keyboard configuration (the computer-input system).
%
%  Inside \macpackage, the \protect\cs{sameword} command considers these two unicodes (code positions) as different characters. If you use only one unicode number consistently, the distinction will probably make no difference to how your text looks, but \protect\cs{sameword} will process the text inaccurately, based on the unicode numbers. To prevent this, do the following:
% \begin{itemize}
%   \item If you use \XeLaTeX, add this line in your preamble:\verb+ \XeTeXinputnormalization 1+.
%   \item If you use \LuaLaTeX, use the \protect\package{uninormalize} package of Michal Hoftich\footnote{\url{https://github.com/michal-h21/uninormalize}.} with the \verb+buffer+ option set to true.
% \end{itemize}
%
% With these tools, \XeTeX\ / \LuaTeX\ will dynamicaly normalize unicode input when reading the file.
% Consequently, you will have no problems with the \protect\cs{sameword} command.
% \subsubsection{Notes about right-to-left texts}
% Due to some internal limits of \XeTeX, \cs{sameword} does not work with right-to-left text with this engine.
%
% If you need to use \cs{sameword} with right-to-left text, you must use \LuaTeX.
% \subsubsection{Use with \protect\cs{lemma} command}
% If you use the \protect\cs{lemma} command, \macpackage\ cannot know to which occurence of \cs{sameword} in the first argument of \cs{edtext} a word marked with \cs{sameword} in \cs{lemma} should refer.
%
% For example, in the following example:
% \begin{verbatim}
%    some thing
%       \edtext{\sameword{sw}
%               and other \sameword{sw}
%               and again \sameword{sw}
%               it is all}%
%       {\lemma{\sameword{sw} \ldots all}\Afootnote{critical note}}.%
% \end{verbatim}
% \Macpackage\ cannot know if the ``sw'' in \protect\cs{lemma} refers to the word after ``thing'', after ``other'', or after ``again''.
%
% Consequently, you must tell \macpackage to which instance of \protect\cs{sameword} you are referring in the first argument of \protect\cs{edtext}:
% \begin{itemize}
%   \item In the content of \protect\cs{lemma}, use \protect\cs{sameword} with no optional argument.
%   \item In the first argument of \protect\cs{edtext}, use \protect\cs{sameword} with the optional argument \oarg{X}. \meta{X} is the depth of the \protect\cs{edtext} where the \protect\cs{lemma} is used.
% So if the \protect\cs{lemma} is called in a \protect\cs{edtext} inside another \protect\cs{edtext}, \meta{X} is equal to \verb+2+.
% If the \protect\cs{lemma} is called in a \protect\cs{edtext} ``of first level'', \meta{X} is equal to \verb|1|. If the lemma is called in both 1 and 2 \protect\cs{edtext} depth, \meta{X} is \verb+1,2+. If that word is referenced in the lemma of every \protect\cs{edtext} depth, \meta{X} can also be set to \verb+inlemma+.
% \end{itemize}
% Note that only words that are actually referenced in a \protect\cs{lemma} need the optional argument. Therefore, the first \protect\cs{sameword} in the example above should have ``1'' as its optional argument, to be referenced correctly in the lemma.
%
% Note also that the \meta{X} does not refer to the level where the \protect\cs{sameword} occurs, but to the level of the \protect\cs{lemma} that refers to that \protect\cs{sameword}. For example:
% \begin{verbatim}
%    \edtext{some \edtext{\sameword[1]{word}}{\Afootnote{om. M}}
%            and other \sameword{word}
%            and again a \sameword{word}
%            it is all}%
%    }{\lemma{some \sameword{word} \ldots all}\Afootnote{critical note}}.%
% \end{verbatim}
% Here the \protect\cs{sameword} occurs in an \protect\cs{edtext} of level 2,
% but since it is referenced by \protect\cs{lemma} on level 1, it has ``1'' in the optional argument.
%
% In the following example figure, each framed box represents an \protect\cs{edtext} level.
% Each number is an occurrence of \protect\cs{sameword}. After a framed box,
% the text in superscript represents the content of \protect\cs{lemma} for that \protect\cs{edtext} level.
% The text in subscript at the right of a number represents the content of the optional argument of \protect\cs{sameword}.
%
%\fbox{%
%  \fbox{%
%   $1_{\mathrm{inlemma}}$
%   \fbox{$2$}
%   $3_2$%
%       }\textsuperscript{$1$\ldots$3$}%
%     4
%     $5_1$
%   }\textsuperscript{1\ldots5}
%
% The \protect\cs{sameword} number~3 is called in a \protect\cs{lemma} related to an \protect\cs{edtext} of level~2.
% It must be marked by ``2''.
%
% The \protect\cs{sameword} number~5 is called in a \protect\cs{lemma} related to \protect\cs{edtext} of level~1. It must be marked by ``1''.
%
% The \protect\cs{sameword} number~1 is called in two \protect\cs{lemma}s: one related to a \protect\cs{edtext} of level~1, the other related to \protect\cs{edtext} of level~2.
% It must be marked by ``1,2''.
% However, as \protect\cs{lemma} is called only in level~1 and~2, ``1,2'' could replaced by ``inlemma''.
%
% The \protect\cs{sameword} number~2 is in the first argument of a \protect\cs{edtext} of level~3, but it has no \protect\cs{lemma}-command, so there is no need to mark it.
%
% Here, the corresponding code:
% \egstart
% \begin{verbatim}
%\edtext{%
%  \edtext{%
%    \sameword[inlemma]{A} (1)
%      \edtext{%
%        \sameword{A} (2)
%      }%
%      {%
%      \Afootnote{level~3}%
%      }%
%    \sameword[2]{A} (3)
%  }%
%  {%
%    \lemma{%
%       \sameword{A}%
%       \ldots%
%       \sameword{A}%
%       }%
%    \Afootnote{level~2}%
%  }%
%  \sameword{A} (4)
%  \sameword[1]{A} (5)
%}%
%{%
%  \lemma{\sameword{A}\ldots\sameword{A}}%
%  \Afootnote{level~1}%
%}
% \end{verbatim}
% \egmid
% \beginnumbering
% \firstlinenum{1}
% \linenumincrement{1}
% \pstart
%\edtext{%
%  \edtext{%
%    \sameword[inlemma]{A} (1)
%      \edtext{%
%        \sameword{A} (2)
%      }%
%      {%
%      \Afootnote{level~3}%
%      }%
%    \sameword[2]{A} (3)
%  }%
%  {%
%    \lemma{\sameword{A}\ldots\sameword{A}}%
%    \Afootnote{level~2}%
%  }%
%  \sameword{A} (4)
%  \sameword[1]{A} (5)
%}%
%{%
%  \lemma{\sameword{A}\ldots\sameword{A}}%
%  \Afootnote{level~1}%
%}
% \pend
% \endnumbering
% \egend
%
% \subsubsection{Sameword for a group of words}
% Sometimes a group of words and not only a single word, occurs multiple times.
% In this case, you have two possibilities.
%
% First, you can consider only the individual words, and not groups of word.
% For example:
% \begin{verbatim}
%\sameword{per} \sameword{causam}
%tamen scire
%\edtext{\sameword{causam}}{\Bfootnote{fnote}}
%est
%\edtext{\sameword{per} \sameword{causam}}{\Bfootnote{causam rei B}}
%cognoscere
%\edtext{\sameword{causam}}{\Bfootnote{fnote}}
% \end{verbatim}
% \begin{ledgroup}
% \beginnumbering
% \pstart
%\sameword{per} \sameword{causam}
%tamen scire
%\edtext{\sameword{causam}}{\Bfootnote{fnote}}
%est
%\edtext{\sameword{per} \sameword{causam}}{\Bfootnote{causam rei B}}
%cognoscere
%\edtext{\sameword{causam}}{\Bfootnote{fnote}}
% \pend
% \endnumbering
% \end{ledgroup}
% In this case it is clear which \enquote{per causam} is meant.
%
% However, in the case that \enquote{per causam} is the lemma of the second note, there should be only one number for that whole lemma.
% In this case we can mark all \enquote{per causam} groups.
% But as \enquote{causam} is also called as lemma in note~1 and ~3, we need to use nested \cs{sameword} commands.
% Consequently, we need to use \cs{lemma} for the \cs{edtext} linked to \enquote{per causam}, as we don't want to number each individual word.
%
% \begin{verbatim}
%\sameword{per \sameword{causam}} tamen scire
%\edtext{\sameword{causam}}{\Bfootnote{fnote}} est
%\edtext{\sameword[1]{per \sameword{causam}}}{\lemma{\sameword{per causam}}\Bfootnote{causam rei B}} cognoscere
%\edtext{\sameword{causam}}{\Bfootnote{fnote}}
% \end{verbatim}
% \begin{ledgroup}
%\beginnumbering
%\pstart
%\sameword{per \sameword{causam}} tamen scire
%\edtext{\sameword{causam}}{\Bfootnote{fnote}} est
%\edtext{\sameword[1]{per \sameword{causam}}}%
% {\lemma{\sameword{per causam}}\Bfootnote{causam rei B}}
% cognoscere
%\edtext{\sameword{causam}}{\Bfootnote{fnote}}
%\pend
%\endnumbering
% \end{ledgroup}
% \subsubsection{Customizing}
% \DescribeMacro{\showwordrank}You can redefine the \protect\cs{showwordrank} macro to change the way the number is printed. The default value is
% \begin{verbatim}
%\newcommand{\showwordrank}[2]{%
%  #1\textsuperscript{#2}%
%}
% \end{verbatim}
% \subsubsection{Problems with some macros}
% \DescribeMacro{\swnoexpands}Macros inside \protect\cs{sameword} that are not fully expandable, mainly macros which manipulate font features, write on full or have optional argument, may cause problems during compilation. Custom commands inside \protect\cs{sameword} may therefore result in errors saying that \enquote{Use of \\sameword doesn't match its definition.} To solve this, include a redefinition of your custom commands in the \protect\cs{swnoexpands} macro.
% In order to not include any content of a macro during comparison, identify the command with \protect\cs{@gobble} For example:
% \begin{verbatim}
%\makeatletter
%\appto{\swnoexpands}{%
%  \let\somemacro\@gobble%
%}
%\makeatother
% \end{verbatim}
% This will drop the content of \protect\cs{somemacro} during comparison.
%
% To include the content of the first and only one argument of a custom command in sameword comparison, use the \protect\cs{@firstofone} command. For example, this is how \cs{emph} is handled:
% \begin{verbatim}
%\makeatletter
% \appto{\swnoexpands}{%
%  \let\emph\@firstofone%
%}
%\makeatother
% \end{verbatim}
% To include command which can take optional argument, use \cs{RenewExpandableDocumentCommand} of \cs{xparse}. For example, this is how \cs{edindex} is handled:
% \begin{verbatim}
%\makeatletter
% \appto{\swnoexpands}{%
%  \RenewExpandableDocumentCommand{\edindex}{om}{}%
%}
%\makeatother
% \end{verbatim}
% \subsubsection{Automatic sameword annotation}
% All potentially ambiguous apparatus entries must be annotated manually. That
% annotation process is laborious and includes a risk of errors.
% \emph{Samewords} is a Python script that can automate this step of the
% process. It can be installed via the \emph{Python Package Index}, but see
% \url{https://github.com/stenskjaer/samewords}
% for more info and documentation. The script is still at a beta stage, so
% comments and questions as well as error reports are very welcome at
% \url{https://github.com/stenskjaer/samewords/issues}.
%
% Please note that the maintainer of this script is not identical with the maintainer of \macpackage.
%
% \subsection{Apparatus of manuscripts}
% The critical notes mostly refer to textual variants between manuscripts which contain the text to be edited.
% It may so happen that the manuscripts only contain parts of the text.
% Depending on one's wishes, \macpackage\ can generate lists of relevant manuscripts for any delimited portion of text.
% Such lists are referred to as \enquote{apparatuses of manuscripts}.
%
% To produce an apparatus of manuscripts with \macpackage, you have to insert specific commands that are used to mark the sections for which only part of the manuscripts are relevant.
% These commands will be processed, and \textbf{after the second \TeX{} run}, corresponding apparatuses of manuscripts will be inserted in the first (viz. 'A' series) level of footnotes.
%
% As the insertion of this apparatus can change the page breaks, you may have to run \TeX{} two or more times.
% We strongly recommend to use tools like \emph{latexmk} to do that.
%
% \subsubsection{Marking sections of text}
% \DescribeMacro{\msdata}
% \cs{msdata}\marg{text} must be inserted at the point where a section for which only part of the manuscripts are relevant starts.
% \meta{text} can be any arbitrary text, viz. a list of the manuscripts that are used for the section that starts.
% The command must be attached right at the point where the section starts, with no space, like so:
% \begin{verbatim}
% \msdata{ABC}Lorem ipsum
% \end{verbatim}
% Which means that the section of text starting by \enquote{Lorem ipsum} is witnessed by manuscripts A, B and C.
%
% \DescribeMacro{\stopmsdata}
% \cs{stopmsdata} must be inserted at the point where the section of text previously marked by \cs{msdata} ends.
% The command must be attached right to the end of the section, with no space.
% As \cs{stopmsdata} is a \LaTeX\ argumentless macro, it will gobble the following space.
% To keep that space, you have to either append a backslash followed by a space or \verb+{}+ to \cs{stopmsdata}, like so:
% \begin{verbatim}
% \msdata{ABC}Lorem ipsum dolor
% [...]
% amet\stopmsdata{} \msdata{ABCD}sic transit [...]
% \end{verbatim}
% Which means that the part of text containing \enquote{Lorem ipsum dolor [...] amet} is witnessed by manuscripts A, B and C, while the part of text starting \enquote{sic transit} is witnessed by manuscripts A, B, C and D.
%
% \cs{stopmsdata} is also automatically inserted by \cs{msdata}.
%
% Note that in most cases, any \cs{stopmsdata} is followed by \cs{msdata}. However, as these two command are usually separated by a space, it may happen that a line break be automatically inserted between them.
% This is why it is advised to always insert \cs{stopmsdata}, even if \cs{msdata} inserts it in case it is forgotten.
%
% \subsubsection{Layout of the apparatus of manuscripts}
% On every page, the apparatus of manuscripts marks the corresponding section with starting and ending line numbers.
% However, the following rules will be applied:
% \begin{itemize}
% \item If the section does not start on the current page, the starting line number will be the line number of the first line on the page.
% \item If the section does not stop on the current page, the ending line number will be the line number of the last line on the page.
% \item If the section neither starts nor ends on the current page, no line number will be printed. The same is true in case both \cs{msdata} is called at the very beginning of the page and \cs{endmsdata} is called at the very end of the page.
% \end{itemize}
% \subsubsection{Settings}
% As the apparatus of manuscripts technically consists of first-level critical notes ('A' series), any setting available for critical notes can be applied (\reff{displayoptions}).
% However, the following \emph{additional} commands are available.
%
% \DescribeMacro{\setmsdataseries}
% The series used by default for the apparatus of manuscripts is series A.
% However, you can change it with \cs{setmsdataseries}\marg{series}.
%
% \DescribeMacro{\setmsdatalabel}
% As the apparatus of manuscripts consists of regular critical footnotes, a lemma is associated to them.
% By default, it is \enquote{Ms.}.
% You can change it using \cs{setmsdatalabel}\marg{txt}.
%
% \DescribeMacro{\setmsdataposition}
% If you want the manuscript apparatus to be on the same level of critical footnotes as the other apparatuses, for each line, reledmac will first insert the manuscript apparatus, then the other footnotes.
% You can change it using:\\
% \cs{msdataposition}\arg{regular-msdata}\\
% And restore the default behaviour using
% \cs{msdataposition}\arg{msdata-regular}
% \subsection{Familiar notes} \label{sec:desc:familiar}
%
%
% \subsubsection{Basic use}
% \DescribeMacro{\footnoteA}
% \DescribeMacro{\footnoteB}
% \DescribeMacro{\footnoteC}
% \DescribeMacro{\footnoteD}
% \DescribeMacro{\footnoteE}
%    As well as the standard \LaTeX\ footnotes generated via \protect\cs{footnote},
% the package also provides
% five series of additional footnotes called \protect\cs{footnoteA} through
% \protect\cs{footnoteE}. These have the familiar marker in the text, and
% the marked text at the foot of the page can be formated using
% any of the styles described for the critical footnotes. Note that
% the `regular' footnotes have the series letter at the end of the macro
% name whereas the critical footnotes have the series letter at the start
% of the name.
%
% The footnote can take a first optional argument to manually define the footnote number or footnote symbol.
% For example:
% \begin{verbatim}
% \footnoteA[22]{This footnote will be numbered 22}
% \end{verbatim}
% \subsubsection{Customizing mark}
% \DescribeMacro{\thefootnoteA}
% \DescribeMacro{\bodyfootmarkA}
% \DescribeMacro{\footfootmarkA}
% Each series uses a set of macros for
% styling the marks. The mark numbering scheme of series A is defined by the
% \protect\cs{thefootnoteA} macro; the default is: \\
% \verb?\renewcommand*{\thefootnoteA}{\arabic{footnoteA}}?\\
% The appearance of the mark in the text is controlled by \protect\cs{bodyfootmarkA}
% which is defined as: \\
% \verb?\newcommand*{\bodyfootmarkA}{%? \\
% \verb?  \hbox{\textsuperscript{\normalfont\@nameuse{@thefnmarkA}}}}? \\
% The command \protect\cs{footfootmarkA} controls the appearance of the mark at the
% start of the footnote text. It is defined as: \\
% \verb?\newcommand*{\footfootmarkA}{\textsuperscript{\@nameuse{@thefnmarkA}}}?
%
%    There are similar command triples for the other series.
% \subsubsection{Separator for multiple footnotes}
%   The \protect\package{footmisc} package~\cite{FOOTMISC} by Robin
% Fairbairns\index{Fairbairns, Robin} has an option whereby
% sequential footnote
% marks in the text can be separated by
% commas\textsuperscript{3,4} like so.
% As a convenience \reledmac\ provides this automatically.
%
% \DescribeMacro{\multfootsep}
% \protect\cs{multfootsep} is used as the separator between footnote markers.
% Its default definition is: \\
% \verb?\providecommand*{\multfootsep}{\textsuperscript{\normalfont,}}? \\
% and can be changed if necessary.
%
% \subsection{Printing the footnote mark without printing the footnote text}
% \DescribeMacro{\footnoteXmark}
% \DescribeMacro{\footnoteXtext}
% In certain cases, you can't directly use \cs{footnoteX}; for example, when using\cs{uline} command of the \package{ulem} package. You need to print the footnote mark first, then call the footnote text to be inserted.
%
% For all \meta{X} command, \macpackage provides a \cs{footnote\meta{X}mark} command and a \cs{footnote\meta{X}text} command, equivalent to standard \LaTeX's command \cs{footnotemark} and \cs{footnotetext}.
% For example, to use with \cs{uline}, do:
% \begin{verbatim}
%  This is \uline{a test containing\mbox{\footnoteAmark}}\footnoteAtext{A
% simple footnote.}\uline{ a simple footnote.}
% \end{verbatim}
%
% If you use \parpackage, you can't use these two commands to print the footnote mark on one side and the footnote text on the other side.
%
% You must use \cs{footnote\meta{X}nomk} and \cs{footnote\meta{X}mk}, defined in \parpackage (\reff{reledpar-nomk})
% \subsection{Changing series}
% \subsubsection{Create a new series}\label{newseries}
%
% If you need more than five series of critical footnotes, you can
% create extra series, using \protect\cs{newseries} command. For example, to create F and G series \protect\cs{newseries}\verb+{G,H}+.
%
% \subsubsection{Delete series}
% As the number of series which are defined increases, \macpackage gets slower.
% If you do not need all of the six standard series (A--E),
% you can load the package with the \verb+series+ option.
% For example, if you need only series~A and~B, use:
% \begin{verbatim}
% \usepackage[series={A,B}]{eledmac}
% \end{verbatim}
% \subsubsection{Series order}
% The default series order is the one called with the \verb+series+ option of the package, or, if this option is not used, A, B, C, D, E.
% Series order determines footnotes order.
%
% \DescribeMacro{\seriesatbegin}\DescribeMacro{\seriesatend} However in some specific cases, you need to change the series order at some point inside the document.
% You can use \protect\cs{seriesatbegin}\marg{s} to pull up a given series \meta{s} to the beginning, or \protect\cs{seriesatend}\marg{s} to push it down to the end.
% \subsection{Position of critical and familiar footnotes}
% \DescribeMacro{\fnpos}\DescribeMacro{\mpfnpos}
% There is a historical incoherence in \protect\package{(r)(e)ledmac}. The familiar footnotes are
% before the critical footnotes in a normal page, but after in a minipage or in a ledgroup.
% However, it is possible to change the relative position of both types of footnotes.
% If you want to have familiar footnotes after critical footnotes in a normal page, use:
% \begin{verbatim}
% \fnpos{critical-familiar}
% \end{verbatim}
% Or, if you want a minipage or ledgroup to have critical footnotes after familiar footnotes, use:
% \begin{verbatim}
% \mpfnpos{familiar-critical}
% \end{verbatim}
%
% You can also decide to alternate familiar and critical footnotes with your own order.
% In this case, the second argument of \cs{fnpos} or \cs{mpfnpos} is a comma-separated list of values.
% Each value has the following form:\\
% \meta{series}\meta{type}
%
% \meta{series} is a series letter (A,B,C etc.), while \meta{type} must be either \enquote{critical} or \enquote{familiar}.
%
% For example, suppose you want to first print the familiar footnotes of the \enquote{A} series, then all the series of critical footnotes, and finally all the series of familiar footnotes, except the \enquote{A} series.
% In this case, use the following command:
% \begin{verbatim}
%\fnpos{%
%  {A}{familiar},
%  {A}{critical},%
%  {B}{critical},%
%  {C}{critical},%
%  {D}{critical},%
%  {E}{critical},%
%  {B}{familiar},%
%  {C}{familiar},%
%  {D}{familiar},%
%  {E}{familiar}%
%}
% \end{verbatim}
% Note that you must define the position of all the series of footnotes you use.
% If you don't, you will have infinite runs of \LaTeX.
%
% \section{Apparatus customization}
% \label{displayoptions}
% \changes{v1.0.0}{2012/09/15}{New generic commands to customize footnote display.}
% Some commands can be used to change the display of the footnotes.
% All can have an optional argument \oarg{s}, which is the letter of the series\,---\,or
% a list of letters separated by comma\,---\,depending on which option is applied.
% If the optional argument is omitted or empty, the setting will apply to the entire series.
%

% When a length, noted \meta{l}, is used, it can be stretchable: \verb|a plus b minus c|. The final length |m| is calculated by \LaTeX{} to have: $a-c \leq m \leq a+b$. If you use some relative unit\footnote{Like \verb|em| which is the width of an `m' in a given font.}, it will be relative to font size of the footnote, except for commands concerning the place kept by the notes --- including blank space.
%
% Some commands are boolean, indicating when an option is enabled.
% If you want to disable the option after enabling it, you must use \verb+[false+] as the second optional argument.
% For example:
% \begin{itemize}
% \item \verb+\XX[A][false]+ to disable the `XX' option for the series A.
% \item \verb+\XX[][false]+ to disable it for all series.
%
% \end{itemize}
% There is also name convention:
% \begin{itemize}
%  \item Names prefixed by \verb+X+ are for setting of critical footnotes.
%  \item Names prefixed by \verb+Xend+ are for setting of critical endnotes.
%  \item  Names suffixed by \verb+X+ are for setting of familiar footnotes.
% \end{itemize}
%
% \subsection{Notes arrangement in a  series}\label{arrangement}
%
% \DescribeMacro{\Xarrangement}
% \DescribeMacro{\arrangementX}
% By default, all footnotes are formatted as a series of separate
% paragraphs in one column. Three other formats are also
% available for notes.
%
% Use \protect\cs{Xarrangement}\oarg{s}\marg{a} to change the arrangement of the \meta{s} series of critical footnotes and \protect\cs{arrangementX}\oarg{s}\marg{a} to change the arrangement of  the \meta{s} series of familiar footnotes.
%
% The value of \meta{a} can be one of the following
% \begin{itemize}
% \item \verb+paragraph+ formats
% all of the footnotes of a series as a single paragraph; if you use this arrangement, you are strongly encouraged to read \reff{paragraphednotes:advanced}.
% \item \verb+twocol+ formats them as separate paragraphs,
% but in two columns;
% \item \verb+threecol+, in three columns.
% \item \verb+normal+, restore normal arrangement.
% \end{itemize}
%
%    You should set up the page layout parameters, and in particular the
% \protect\cs{baselineskip} of the footnotes, before you call this
% macro because its action depends on these;
% too much or too little space will be allotted for the notes on
% the page if these macros use the wrong
% values.
%
% \label{nobreaks}Note that you \emph{cannot} use paragraphs (e.g. blank lines or
% \cs{par}) or line breaks (\cs{break} or \cs{linebreak} or \cs{newline} etc.)
% inside of notes, when they are
% set to \texttt{paragraph} arrangement!
%
% The notes arrangement must be called after having defined the document geometry setting.
% If you must change geometry setting inside your document, do not forget to call note arrangement again.
%
% \protect\cs{hsize} has been set for the pages that use
% this series of notes; otherwise \TeX\ will try to put too
% many or too few of these notes on each page. If you need to
% change the \protect\cs{hsize} within the document, call
% the arrangement macro again afterwards to take account of the new
% value.
% \subsection{Control line number printing}
% \subsubsection{Print line number only at first time}
% \DescribeMacro{\Xnumberonlyfirstinline}\label{Xnumberonlyfirstinline}
% \changes{v1.0.1}{2012/09/16}{Correction on \protect\cs{Xnumberonlyfirstinline} with lineation by pstart or by page.}
% By default, the line number is printed inside every note. If you want to print it only the first time for a given line number
% (i.e., once for line 1, once for line 2, etc.), you can use \protect\cs{Xnumberonlyfirstinline}\oarg{s}.
%
%
% \changes{v1.1.0}{2012/09/25}{Add \protect\cs{Xnumberonlyfirstintwolines}}
% \DescribeMacro{\Xnumberonlyfirstintwolines}\label{Xnumberonlyfirstintwolines}
% Suppose you have a lemma on line~2 and a lemma between line~2 and line~3.
% With \protect\cs{Xnumberonlyfirstinline}, the second lemma is considered to be on the same line as the first lemma.
% But if  you use both \protect\cs{Xnumberonlyfirstinline}\oarg{s} and \protect\cs{Xnumberonlyfirstintwolines}\oarg{s}, a distinction is made.
%
%
% \DescribeMacro{\Xsymlinenum}
% For setting a particular symbol in place of the line number, you can use \protect\cs{Xsymlinenum}\oarg{s}\marg{symbol} in combination with \protect\cs{Xnumberonlyfirstinline}\oarg{s}. From the second lemma of the same line, the symbol will be used instead of the line number. Note that any command called in \meta{symbol} must be robust. Use \protect\cs{robustify} to robustify a non-robust command.
%
% \DescribeMacro{\Xendnumberonlyfirstinline}
% \DescribeMacro{\Xendnumberonlyfirstintwolines}
% \DescribeMacro{\Xendsymlinenum}
% For endnotes, \cs{Xendnumberonlyfirstinline}; \cs{Xendnumberonlyfirstintwolines} and \cs{Xendsymlinenum} are the equivalents of
% \\ \cs{Xnumberonlyfirstinline}; \cs{Xnumberonlyfirstintwolines} and \cs{Xsymlinenum}.
%
% \subsubsection{Print line number annotation only the first time}\label{annotation-inapparatus}
% \DescribeMacro{\Xlinenumannotationonlyfirst}
% By default, the line number annotation (\reff{annotation}) is printed in every note. If you want to print it only the first time for a given annotation
% you can use \cs{Xlinenumannotationonlyfirst}\oarg{s}.
%
% Note the two following points:
% \begin{itemize}
% \item If you use the \option{noresetlinenumannotation} option of \macpackage, the \cs{Xlinenumannotationonlyfirst} won't take account of the official line number.
% \item The \cs{Xlinenumannotationonlyfirst} works for consecutive lemmas with the same annotation. That is, if you have for example a lemma with an \verb+A+ annotation, then a lemma with a \verb+B+ annotation, then a lemma with an \verb+A+ annotation, each lemma will have its own annotation in the apparatus.
% \end{itemize}
%
% \DescribeMacro{\Xlinenumannotationonlyfirstintwo}
% Suppose you have a lemma on annotation~1 and a lemma between annotation~1 and annotation~3.
% With \cs{Xlinenumannotationonlyfirst}, the second lemma is considered to have the same annotation as the first lemma.
% But if  you use both \cs{Xlinenumannotationonlyfirst}\oarg{s} and \cs{Xlinenumannotationonlyfirstintwo}\oarg{s}, a distinction is made.
%
%
% \DescribeMacro{\Xsymlinenumannotation}
% To use a particular symbol in place of the line number annotation, you can use \protect\cs{Xsymlinenumannotation}\oarg{s}\marg{symbol} in combination with \protect\cs{Xlinenumannotationonlyfirst}\oarg{s}. From the second lemma with the same line number annotation, the symbol will be used instead of the annotation. Note that any command called in \meta{symbol} must be robust. Use \protect\cs{robustify} to robustify a non-robust command.
%
% \DescribeMacro{\Xendlinenumannotationonlyfirst}
% \DescribeMacro{\Xendlinenumannotationonlyfirstintwo}
% \DescribeMacro{\Xendsymlinenumannotation}
% For endnotes, \cs{Xendlinenumannotationonlyfirst}; \cs{Xendlinenumannotationonlyfirstintwo} and \cs{Xendsymlinenumannotation} are the equivalents of
% \\ \cs{Xlinenumannotationonlyfirst}; \cs{Xlinenumannotationonlyfirstintwo} and \cs{Xsymlinenumannotation}.
%
% \subsubsection{Print page number only at first time}
% For endnotes, \reledmac\ provides a mechanism for printing the page number only the first time it is seen.
% However, when a lemma spans over two pages, the line numbers are normally printed in the following pattern: starting page number - starting line number - ending page number - ending line number.
% It follows that what corresponds to the actual `page number' may not be self-evident. So:
% \DescribeMacro{\Xendpagenumberonlyfirst} \cs{Xendpagenumberonlyfirst}\oarg{s} can be called to ensure that the starting page number of a lemma be not printed if it is the same as the ending page number of the preceding lemma.
% You can use \emph{additionally} one (and only one) of the following commands:
% \begin{itemize}
% \item    \cs{Xendpagenumberonlyfirstifsingle}\oarg{s}:
% the first page number of the lemma will not be printed only if the following conditions are true:
% \begin{enumerate}
%   \item The starting page number of the lemma is the same as the ending page number of the preceding lemma.
%   \item The ending page number of the lemma is the same as the starting page number of the lemma.
% \end{enumerate}
% In this case the ending page number will always be printed if it is different from the starting page number.
% \item  \cs{Xendpagenumberonlyfirstintwo}\oarg{s}: both the starting page number and the ending page number of a lemma are not printed if they are both the same as the starting page number and the ending page number of the preceding lemma respectively.
%
% \end{itemize}

%
% In any case, you can use:
% \begin{itemize}
% \item \DescribeMacro{\Xendsympagenum} \cs{Xendsympagenum}\oarg{series}\marg{c} to print \meta{c} when the page number is not printed.
% \item \DescribeMacro{\Xendinplaceofpagenumber} \cs{Xendinplaceofpagenumber}\oarg{series}\marg{l} to print a \meta{l} length horizontal space in case no symbol is printed instead of the page number.
%
% \end{itemize}
%
% \subsubsection{Arbitrary text before line number}
% \DescribeMacro{\Xtxtbeforenumber}
% \cs{Xtxtbeforenumber}\oarg{s}\marg{txt} allows the insertion of \meta{txt} before the line number only when the line number is printed, so taking into account \cs{Xnumberonlyfirstinline} and the like.
% \paragraph{For endnotes}\label{pagelineendnotes}
% \DescribeMacro{\Xendbeforepagenumber}
% \cs{Xendbeforepagenumber}\oarg{s}\marg{text} defines the text before the page number in endnotes. Default value is \verb+p.+ (``p'' followed by a dot).
%
% \DescribeMacro{\Xendafterpagenumber}
% \cs{Xendafterpagenumber}\oarg{s}\marg{text} defines the text after the page number in endnotes. Default value is \verb+) + (open parenthesis followed by a single space).
% \DescribeMacro{\Xendlineprefixsingle}
% \cs{Xendlineprefixsingle}\oarg{s}\marg{text} defines the text before the line number in endnotes when there is only one line. Default value is empty.
% \DescribeMacro{\Xendlineprefixmore}
% \cs{Xendlineprefixmore}\oarg{s}\marg{text} defines the text before the line number in endnotes when there is more than one line. Default value is empty. If you don't define it, it will use the value defined by \cs{Xendlineprefixsingle}.
% \subsubsection{Separator for line range}\label{linerangeseparator}
% \changes{v2.4.0}{2015/10/19}{New hooks:  \protect\cs{Xlinerangeseparator} and \protect\cs{Xendlinerangeseparator}.}
% \changes{v2.4.0}{2015/10/19}{Option linerangesep for critical footnotes and endnotes.}
% \DescribeMacro{\Xlinerangeseparator}
% \DescribeMacro{\Xendlinerangeseparator}
% By default, the separator between the begin line and the end line in a lines' range is an endash in a normal font (\verb+\textnormal{--}+).
% You can change it for critical footnotes with \cs{Xlinerangeseparator}\oarg{s}\marg{text}, and with \cs{Xendlinerangeseparator}\oarg{s}\marg{text} for critical endnotes.
%
% \subsubsection{Abbreviate line range}
% \changes{v1.20.0}{2015/03/22}{Add \protect\cs{Xtwolines} and \protect\cs{Xmorethantwolines} hooks}
% \label{Xtwolines}
% \DescribeMacro{\Xtwolines}\DescribeMacro{\Xmorethantwolines}
% If a lemma is printed on two subsequent lines, \macpackage\ will print the first and the last line numbers.
% Instead of this, it is also possible to print an abbreviation which stands for ``line 1 and subsequent line(s)''.
%
% To achieve this, use \protect\cs{Xtwolines}\oarg{s}\marg{text} and \protect\cs{Xmorethantwolines}\oarg{s}\marg{text}.
% The \meta{text} argument of \protect\cs{Xtwolines} will be printed if the lemma is on two lines, and the \meta{text} argument of \protect\cs{Xmorethantwolines} will be printed if the lemma is on three or more lines.
% For example:
% \begin{verbatim}
% \Xtwolines{sq.}
% \Xmorethantwolines{sqq.}
% \end{verbatim}
% will print ``1sq.'' for a lemma which falls on lines 1--2 and ``1sqq.'' for a lemma which falls on lines 1--4.
%
% If you use \protect\cs{Xtwolines} without setting \protect\cs{Xmorethantwolines}, the \meta{text} argument
% of \protect\cs{Xtwolines} will be used for lemmas which fall on three or more lines.
%
% However, if you want to use a short form (when the lemma overlaps two lines, but not more than two), use \protect\cs{Xtwolinesbutnotmore}\oarg{series}.
%
%
% When you use lineation by page, the final page number, if different from the initial page number,
% will not be printed, because the final page number is included in the \protect\cs{Xendtwolines} symbol.
%
% \DescribeMacro{\Xtwolinesonlyinsamepage}
% However, you can force print the final page number with\\
% \protect\cs{Xtwolinesonlyinsamepage}\oarg{series}.
%
%
% You can disable \protect\cs{Xtwolines} and related for a specific note by using the `[fulllines]` argument in the note macro cf.~\reff{fulllines}.
%
% \label{Xendtwolines}\changes{v1.21.0}{2015/04/13}{Add \protect\cs{Xendtwolines}, \protect\cs{Xendmorethantwolines}, \protect\cs{Xendtwolinesbutnotmore} and \protect\cs{Xendtwolinesonlyinsamepage}.}
% \DescribeMacro{\Xendtwolines}\DescribeMacro{\Xendmorethantwolines}\DescribeMacro{\Xendtwolinesbutnotmore}
% For endnotes, use these macros:
% \protect\cs{Xendtwolines}; \protect\cs{Xendmorethantwolines}; \linebreak \protect\cs{Xendtwolinesbutnotmore};\\
% \protect\cs{Xendtwolinesonlyinsamepage}  instead of \protect\cs{Xtwolines}; \protect\cs{Xmorethantwolines};\\
% \protect\cs{Xtwolinesbutnotmore}; \protect\cs{Xtwolinesonlyinsamepage}.
%
% \subsubsection{Disable line number}
% \DescribeMacro{\Xnonumber}
% You can use \protect\cs{Xnonumber}\oarg{s} if you do not want to have the line number in a footnote.
% \DescribeMacro{\Xendnonumber} \protect\cs{Xendnonumber}\oarg{s} is the same for endnote.
%
% \subsubsection{Printing pstart number}
% \changes{v1.1.0}{2012/09/25}{Add \protect\cs{Xpstart} and \protect\cs{Xonlypstart}}
% \changes{v1.18.0}{2015/02/23}{Add \protect\cs{Xpstarteverytime}}
% \changes{v1.18.0}{2015/02/23}{Debug \protect\cs{Xonlypstart} when using \protect\cs{Xnumberonlyfirstinline} and the current line number differs from the previous.}
% \DescribeMacro{\Xpstart}
% You can use \protect\cs{Xpstart}\oarg{s} if you want to print the pstart number in the footnote, before the line and subline number.
% Note that when you change the lineation system, the option is automatically switched :
% \begin{itemize}
%    \item If you use lineation by pstart, the option is enabled.
%    \item If you use lineation by section or by page, the option is disabled.
% \end{itemize}
%
% \DescribeMacro{\Xpstarteverytime}
% By default, the pstart number is printed only in the part of text where you have called \protect\cs{numberpstarttrue}.
% We don't know why you would like to print the pstart number in the notes and not in the main text.
% However, if you want to do it, you can call  \protect\cs{Xpstarteverytime}\oarg{s}.
% In this case, the pstart number will be printed every time in footnote.
%
% \DescribeMacro{\Xonlypstart}
% In combination with \protect\cs{Xpstart}, you can use \protect\cs{Xonlypstart}\oarg{s} if you want to print only the pstart number in the footnote, and not the line and subline number.
%
% \DescribeMacro{Xpstartonlyfirst} You can use \cs{Xpstartonlyfirst}\oarg{s} to print the pstart number only the first time it appears in the apparatus.
% \DescribeMacro{\Xpstartseparator}
% When using \cs{Xpstart}, you can use \cs{Xpstartseparator}\oarg{s}\marg{text} to print \meta{text} after the pstart number.
% Default value is empty.
% \subsubsection{Printing stanza number}
%
% \DescribeMacro{\Xstanza}\label{Xstanza}
% You can use \cs{Xstanza}\oarg{s} if you want to print the stanza number in the footnote, before the line and subline number.
%
% Of course the stanza number is printed only when you use \cs{numberstanza}
%
% \DescribeMacro{\Xstanzaseparator}
% When using \cs{Xstanza}, you can use \cs{Xstanzaseparator}\oarg{s}\marg{text} to print \meta{text} after the stanza number.
% Default value is empty.
%
% \DescribeMacro{Xstanzaonlyfirst} You can use \cs{Xstanzaonlyfirst}\oarg{s} to print the stanza number only the first time it appears in the apparatus.
% \subsubsection{Separator between line and subline numbers}\label{Xsublinesep}
% \DescribeMacro{\Xsublinesep}
% \cs{Xsublinesep}\oarg{s}\marg{txt} changes the separator between line and subline in footnotes.
%
% \textbf{Employed without optional argument, it also changes the separator in side numbering}.
%
% \DescribeMacro{\Xendsublinesep}
% \cs{Xendsublinesep}\oarg{s}\marg{txt} does the same thing for endnotes.
%
% \textbf{However, it does not change anything for the separator in side numbering. Use \cs{Xsublinesep} without optional argument or \cs{Xsublinesepside}\marg{txt} to do it.}
%
% The default value is \verb+\textnormal{.}+.
% \subsubsection{Separator between page and line numbers}
% \changes{v2.16.0}{2016/01/10}{Add \protect\cs{Xpagelinesep} hook.}
% \DescribeMacro{\Xpagelinesep}
% \cs{Xpagelinesep}\oarg{s}\marg{txt} changes the separator between the page and line number in footnotes.
%
% By default, the value defined for \cs{Xsublinesep} is used.
%
% \subsubsection{Space around number}
% \DescribeMacro{\Xbeforenumber}
% With \protect\cs{Xbeforenumber}\oarg{s}\marg{l}, you can add some space before the line number in a footnote. If the line number is not printed, the space is not either. The default value is 0~pt.
%
% \DescribeMacro{\Xafternumber}
% With \protect\cs{Xafternumber}\oarg{s}\marg{l} you can add some space after the line number in a footnote. If the line number is not printed, neither is the space. The default value is 0.5~em.
%
% \DescribeMacro{\Xendbeforenumber}\DescribeMacro{\Xendaftrenumber}
% \cs{Xendbeforenumber} and \cs{Xendafterenumber} are the equivalents of \cs{Xbeforenumber} and \cs{Xafterenumber} for endnotes.
%
%\changes{v1.4.3}{2012/12/18}{Add \protect\cs{Xnonbreakableafternumber}.}
%\DescribeMacro{\Xnonbreakableafternumber}
% By default, the space defined by \protect\cs{Xafternumber} is breakable.
% With \protect\cs{Xnonbreakableafternumber}\oarg{s} it becomes nonbreakable.
%
% \subsubsection{Space around line symbol}
% \DescribeMacro{\Xbeforesymlinenum}
% With \protect\cs{Xbeforesymlinenum}\oarg{s}\marg{l} you can add some space before the line symbol in a footnote. The default value is value set by \protect\cs{Xbeforenumber}.
%
% \DescribeMacro{\Xaftersymlinenum}
% With \protect\cs{Xaftersymlinenum}\oarg{s}\marg{l} you can add some space after the line symbol in a footnote. The default value is value set by \protect\cs{Xafternumber}.
%
% \DescribeMacro{\Xendbeforesymlinenum}
% \DescribeMacro{\Xendaftersymlinenum}
% \cs{Xendbeforesymlinenum} and \cs{Xendaftersymlinenum} are the equivalents of \cs{Xbeforesymlinenum} and \cs{Xaftersymlinenum} for the endnotes.
%
% \subsubsection{Space in place of number}
% \DescribeMacro{\Xinplaceofnumber}\label{Xinplaceofnumber}
% If no number or symbolic line number is printed, you can add a space, with \cs{Xinplaceofnumber}\oarg{s}\marg{l}. The default value is 1~em.
%
% \DescribeMacro{\Xendinplaceofnumber} \cs{Xendinplaceofnumber}\oarg{s}\marg{l} is the same, for critical endnotes.
% \subsubsection{Boxing line number and line symbol}
% \DescribeMacro{\Xboxlinenum}
% It could be useful to put the line number inside a fixed box: the content of the note will be printed after this box.
% You can use \protect\cs{Xboxlinenum}\oarg{s}\marg{l} to do that.
% To subsequently disable this feature, use \protect\cs{Xboxlinenum} with length equal to 0~pt.
% One use of this feature is to print line number in a column, and the note in an other column:
% \begin{verbatim}
%\Xhangindent{1em}
%\Xafternumber{0em}
%\Xboxlinenum{1em}
% \end{verbatim}
%
% \DescribeMacro{\Xboxsymlinenum}
% \protect\cs{Xboxsymlinenum}\oarg{s}\marg{l} is the same as \protect\cs{Xboxlinenum} but for the line number symbol.
%
% \DescribeMacro{\Xendboxsymlinenum}
% \protect\cs{Xendboxsymlinenum}\oarg{s}\marg{l} is the same as \protect\cs{Xboxsymlinenum} but for endnotes.
%
% \changes{v1.23.0}{2015/05/18}{Add \protect\cs{Xboxlinenumalign} and \protect\cs{Xendboxlinenumalign}.}
% \DescribeMacro{\Xboxlinenumalign}
% If you put line number in box, it will be aligned left inside the box.
% However, you can change it using  \protect\cs{Xboxlinenumalign}\oarg{s}\marg{text} where \meta{text} can be the following:
% \begin{description}
%  \item[L] to align left (default value);
%  \item[R] to align right;
%  \item[C] to center.
% \end{description}
%
% \changes{v1.23.0}{2015/05/18}{Add \protect\cs{Xboxstartlinenum}, \protect\cs{Xendboxstartlinenum}, \protect\cs{Xboxendlinenum}, \protect\cs{Xendboxendlinenum}.}
% When using \protect\cs{Xboxlinenum}, \macpackage put all the line number description in the same box. That is, the same box will contain: the start line number, the dash, and either the end line number or the range symbol (like \verb+ff.+).
% However, it is possible to box them in two different boxes.
% \begin{itemize}
%  \item \protect\cs{Xboxstartlinenum}\oarg{s}\marg{l} will box the start line number in a box of length \meta{l}. The content will be put at the right of the box.
%  \item \protect\cs{Xboxendlinenum}\oarg{s}\marg{l} will box the dash plus the end line number  or the range symbol in a box  of length \meta{l}. The content will be put at the left of the box.
% \end{itemize}
%
% With these two commands, it is possible to horizontaly align the dash of line number when using critical notes, to obtain something like:
% \begin{verbatim}
%   1
%  12-23
%  24ff.
% \end{verbatim}
% \DescribeMacro{\Xendboxlinenum}
% \DescribeMacro{\Xendboxlinenumalign}
% \DescribeMacro{\Xendboxstartlinenumalign}
% \DescribeMacro{\Xendboxendlinenumalign}
% \changes{v1.20.0}{2015/03/22}{Add \protect\cs{Xendboxlinenum}}
% \protect\cs{Xendboxlinenum}\oarg{s}\marg{l}, \protect\cs{Xendboxlinenumalign}\oarg{s}\marg{text},  \protect\cs{Xendboxstartlinenum}\oarg{s}\marg{l},  \protect\cs{Xendboxendlinenum}\oarg{s}\marg{l} are the same as, respectively, \protect\cs{Xboxlinenum} and \protect\cs{Xboxlinenumalign}, \protect\cs{Xboxstartlinenum}, \protect\cs{Xboxendlinenum} except in endnotes.
%
%
% \subsection{Arbitrary code around line number}
% \DescribeMacro{\Xendbhooklinenumber}
% \cs{Xendbhooklinenumber}\oarg{s}\marg{code} is used to execute code before line numbers in endnotes. The code is executed before the \cs{Xendbeforelinenumber} space  and before the \cs{Xendnotenumfont} font setting.
%
% \DescribeMacro{\Xendahooklinenumber}
% \cs{Xendahooklinenumber}\oarg{s}\marg{code} is used to execute code after line number in endnotes.
% The code is executed after the \cs{Xendafternumber} space.
%
%
%
% \DescribeMacro{\Xendbhookinplaceofnumber}
% \cs{Xendbhookinplaceofnumber}\oarg{s}\marg{code} is used to execute code before space or symbol which replace line number in endnotes. The code is executed before the \cs{Xendbeforesymlinenum} space  and before the \cs{Xendnotenumfont} font setting.
%
% \DescribeMacro{\Xendahookinplaceofnumber}
% \cs{Xendahookinplaceofnumber}\oarg{s}\marg{code} is used to execute code after space or symbol which replace line number in endnotes.
% The code is executed after the \cs{Xendaftersymlinenum} space.
%\subsection{Separator between the lemma and the note}
% \subsubsection{For footnotes}
% \DescribeMacro{\Xlemmaseparator}
% By default, in a footnote, the separator between the  lemma and the note is a right bracket (\protect\cs{rbracket})\footnote{For \protect\package{polyglossia}, when the lemma is RTL, the bracket automatically switches to a left bracket.}. You can use \protect\cs{Xlemmaseparator}\oarg{s}\marg{Xlemmaseparator} to change it. The optional argument can be used to specify the series in which it is used. Note that there is a non-breakable space between the lemma and the separator, but a \textbf{breakable} space between the separator and the following text.
%
% \DescribeMacro{\Xbeforelemmaseparator}
% Using \protect\cs{Xbeforelemmaseparator}\oarg{s}\marg{l} you can add some space between lemma and separator. If your lemma separator is empty, this space won't be printed. The default value is 0~em.
%
% \DescribeMacro{\Xafterlemmaseparator}
%  Using \protect\cs{Xafterlemmaseparator}\oarg{s}\marg{l} you can add some space between separator and note. If your lemma separator is empty, this space will not be printed. The default value is 0.5~em.
%
% \DescribeMacro{\Xnolemmaseparator}
% You can suppress the lemma separator, using \protect\cs{Xnolemmaseparator}\oarg{s}, which is simply a alias of \protect\cs{Xlemmaseparator}\oarg{s}\verb|{}|.
%
% \DescribeMacro{\Xinplaceoflemmaseparator}\label{Xinplaceoflemmaseparator}
% With \protect\cs{Xinplaceoflemmaseparator}\oarg{s}\marg{l} you can add a space if no lemma separator is printed. The default value is 1~em.
%
%
% \subsubsection{For endnotes}\label{Xendlemmaseparator}
% \changes{v1.22.0}{2015/04/25}{Add option for lemma separator inside endnotes}
% \DescribeMacro{\Xendlemmaseparator}
% By default, there is no separator inside endnotes between the lemma and the content of the note. You can use \protect\cs{Xendlemmaseparator}\oarg{s}\marg{Xendlemmaseparator} to change this. The optional argument can be used to specify the series in which it is used.
% A common value of \meta{Xendlemmaseparator} is \cs{rbracket}.
%
% Note that there is a non-breakable space between the lemma and the separator, but a \textbf{breakable} space between the separator and the following text.
%
% \DescribeMacro{\Xendbeforelemmaseparator}
% Using \protect\cs{Xendbeforelemmaseparator}\oarg{s}\marg{l} you can add some space between the lemma and the separator. If your lemma separator is empty, this space won't be printed. The default value is 0~em.
%
% \DescribeMacro{\Xendafterlemmaseparator}
%  Using \protect\cs{Xendafterlemmaseparator}\oarg{s}\marg{l} you can add some space between the separator and the content of the note. If your lemma separator is empty, this space won't be printed. The default value is 0.5~em.
%
%
% \DescribeMacro{\Xendinplaceoflemmaseparator}\label{Xendinplaceoflemmaseparator}
% With \protect\cs{Xendinplaceoflemmaseparator}\oarg{s}\marg{l} you can add some space if you choose to remove the lemma separator. The default value is 0.5~em.
%
%
% \subsection{Font style}
% \subsubsection{For line number}
% \DescribeMacro{\Xnotenumfont}
% \protect\cs{Xnotenumfont}\oarg{s}\marg{command} is used to change the font style for line numbers in critical footnotes ;
% \meta{command} must be one (or more) switching command, like \protect\cs{bfseries}.
%
% \DescribeMacro{\Xendnotenumfont}
% \protect\cs{Xendnotenumfont}\oarg{s}\marg{command} is used to change the font style for line numbers in critical footnotes.
% \meta{command} must be one (or more) switching command, like \protect\cs{bfseries}.
%
% \DescribeMacro{\notenumfontX}
% \protect\cs{notenumfontX}\oarg{s}\marg{command} is used to change the font style for note numbers in familiar footnotes.
% \meta{command} must be one (or more) switching command, like \protect\cs{bfseries}.
%

% \subsubsection{For the lemma}
% \changes{v1.11.0}{2014/05/09}{Add hooks to disable the font selection for lemma in footnote.}
% \DescribeMacro{\Xlemmadisablefontselection}
% By default, font of the lemma in footnote is the same as font of the lemma in the main text. For example, if the lemma is in italic in the main text, it is also in italic in note. The \protect\cs{Xlemmadisablefontselection}\oarg{s} command allows to disable it for a specific series.
%
% \DescribeMacro{\Xendlemmadisablefontselection}
% By default, font of the lemma in endnote is the same as font of the lemma in the main text. For example, if the lemma is in italic in the main text, it is also in italic in note. The command allows  \protect\cs{Xendlemmadisablefontselection}\oarg{s} to disable it for a specific series.
%

% \changes{v2.7.0}{2015/11/29}{New hooks: \protect\cs{Xlemmafont} and \protect\cs{Xendlemmafont}}
% \DescribeMacro{\Xlemmafont}\DescribeMacro{\Xendlemmafont}
% Use \cs{Xlemmafont}\oarg{s}\marg{cmd} to apply a \TeX\ font command to the lemma.
%For example, to have boldface lemma:
% \begin{verbatim}
%\Xlemmafont{\bfseries}
% \end{verbatim}
% \cs{Xendlemmafont}\oarg{s}\marg{cmd} is the same for endnotes.
%
%
% \subsubsection{For all notes}
% \DescribeMacro{\Xnotefontsize}
% \protect\cs{Xnotefontsize}\oarg{s}\marg{command} is used to define the font size of critical footnotes of the series. The default value is \protect\cs{footnotesize}.
% The \meta{command} must not be a size in pt, but a standard \LaTeX\ size, like \protect\cs{small}.
%
% \DescribeMacro{\notefontsizeX}
% \protect\cs{notefontsizeX}\oarg{s}\marg{command} is used to define the font size of familiar footnotes of the series. The default value is \protect\cs{footnotesize}.
% The \meta{command} must not be a size in pt, but a standard \LaTeX\ size, like \protect\cs{small}.
%
% \DescribeMacro{\Xendnotefontsize}
% \protect\cs{Xendnotefontsize}\oarg{s}\marg{l} is used to define the font size of end critical footnotes of the series. The default value is \protect\cs{footnotesize}.
% The \meta{command} must not be a size in pt, but a standard \LaTeX\ size, like \protect\cs{small}.
%
% \subsection{Wrapping notes}
% \subsubsection{Wrapping lemmas}
% \changes{v2.10.0}{2016/05/08}{New hooks: \protect\cs{Xwraplemma} and \protect\cs{Xendwraplemma}}
% \DescribeMacro{\Xwraplemma}\label{Xwraplemma}
% \cs{Xwraplemma}\oarg{s}\marg{cmd} is used to wrap, in the footnote, the lemma in a \LaTeX\ command.
% For example, with the \package{bidi} package, to ensure having a lemma written right to left, use \cs{Xwraplemma}\arg{\cs{RL}}.
%
% \DescribeMacro{\Xwrapendlemma}
% \cs{Xendwraplemma}\oarg{s}\marg{cmd} is the same for endnotes.
%
% \subsubsection{Wrapping contents}
% \changes{v2.10.0}{2016/05/08}{New hooks: \protect\cs{Xwrapcontent}, \protect\cs{Xendwrapcontent} and \protect\cs{wrapcontentX}.}
% \DescribeMacro{\Xwrapcontent}
% \cs{Xwrapcontent}\oarg{s}\marg{cmd} is used to wrap the footnote contents --- excluding the lemma --- in a \LaTeX\ command.
%
% For example, if the language of your note is not the same as the language of the lemma, use \cs{Xwrapcontent}\arg{\cs{foreignlanguage}\marg{language}} (with \package{babel}) or \cs{Xwrapcontent}\arg{\cs{text\meta{language}}} (for babel).
%
% \DescribeMacro{\Xendwrapcontent}
% \cs{Xendwrapcontent}\oarg{s}\marg{cmd} is the same for endnotes.
%
% \DescribeMacro{\wrapcontentX}
% \cs{wrapcontentX}\oarg{s}\marg{cmd} is the same for familiar footnotes.
% \subsection{Indent of notes content}
% \changes{v1.21.0}{2015/04/13}{Add \protect\cs{Xparindent} and \protect\cs{hangindentX}}
% \DescribeMacro{\Xparindent}
% By default, \macpackage does not add indentation before the paragraphs inside critical footnotes.
% Use \protect\cs{Xparindent}\oarg{s} to enable indentation.
%
% \DescribeMacro{\parindentX}
% By default, \macpackage does not add indentation before the paragraphs inside familiar footnotes.
% Use \protect\cs{parindentX}\oarg{s} to enable indentation.
%
% \DescribeMacro{\Xhangindent}
% For critical notes NOT paragraphed you can define an indent with \protect\cs{Xhangindent}\oarg{s}\marg{l}, which will be applied in the second line of notes. It can help to make distinction between a new note and a break in a note. The default value is 0~pt.
%
% \DescribeMacro{\hangindentX}
% For  familiar notes NOT paragraphed you can define an indentation with \protect\cs{hangindentX}\oarg{s}\marg{l}, which will be applied in the second line of notes. It can help to make a distinction between a new note and a break in a note.

% \DescribeMacro{\Xendhangindent}
% For  critical endnotes NOT paragraphed you can define an indentation with \protect\cs{Xendhangindent}\oarg{s}\marg{l}, which will be applied in the second line of notes. It can help to make a distinction between a new note and a break in a note.
%
%
% \subsection{Arbitrary code at the beginning of notes}
% \changes{v1.1.0}{2012/09/25}{New hook to add arbitrary code at the beginning of the notes}
% The three next commands add arbitrary code at the beginning of notes.
% As the name's space is local to the notes, you can use it to redefine some style inside the notes.
% For example, if you don't want the pstart number to be in bold, use :
% \begin{verbatim}
% \Xbhooknote{\renewcommand{\thepstart}{\arabic{pstart}.}}
% \end{verbatim}
%
% \DescribeMacro{\Xbhooknote}
% \protect\cs{Xbhooknote}\oarg{s}\marg{code} is to be used at the beginning of each critical footnote.
%
%
% \DescribeMacro{\bhooknoteX}
% \protect\cs{bhooknoteX}\oarg{s}\marg{code} is to be used at the beginning of each familiar footnote.
%
%
% \DescribeMacro{\Xendbhooknote}
% \protect\cs{Xendbhooknote}\oarg{s}\marg{code} is to be used at the beginning of each endnote.
%
% \subsection{Arbitrary code before inserting note}
% \DescribeMacro{\Xbeforeinserting}
% \DescribeMacro{beforeinsertingX}
% \cs{Xbeforeinserting}\oarg{s}\marg{code}
% and \cs{beforeinsertingX}\oarg{s}\marg{code}
% are very technical commands.
%
% They allow one to add any arbitrary code just before the footnotes are added in the list of footnotes.
% The main use is to insert text direction code.
% For example, if you edit right-to-left text with \package{bidi}, but want your critical footnote be left-to-right, use \cs{Xbeforeinserting}{\cs{LTR}}.
% You should also use \cs{Xwraplemma} to ensure your lemmas are right-to-left in a left-to-right paragraph (\reff{Xwraplemma})).
%
% Note that the changes are local to the footnote.
%
%
% \subsection{Options for footnotes in columns}
%
% \subsubsection{Alignment}
% \DescribeMacro{\Xcolalign}
% \DescribeMacro{\colalignX}
% \changes{v1.21.0}{2015/04/13}{Add \protect\cs{Xcolalign} and \protect\cs{colalignX} hooks}
% By default, text in footnotes of two or three columns are flush left and without hyphenation.
% However, you can change this with \protect\cs{Xcolalign}\oarg{s}\marg{code} for critical footnotes,
% and \protect\cs{colalignX}\oarg{s}\marg{code} for familiar footnotes.
%
% \verb+<code>+ must be one of the following command:
% \begin{description}
%  \item[\protect\cs{justifying}] to have text justified, as usual with \LaTeX. You can also let \verb+<code>+ empty.
%  \item[\protect\cs{raggedright}] to have text left aligned, but \emph{without hyphenation}. That is the default \macpackage\ setting.
%  \item[\protect\cs{RaggedRight}] to have text left aligned \emph{with hyphenation} (requires \package{ragged2e}).
%  \item[\protect\cs{raggedleft}] to have text right aligned, but \emph{without hyphenation}.
%  \item[\protect\cs{RaggedLeft}] to have text right aligned \emph{with hyphenation} (requires \package{ragged2e}).
%  \item[\protect\cs{centering}] to have text centered, but \emph{without hyphenation}.
%  \item[\protect\cs{Centering}] to have text centered \emph{with hyphenation} (requires \package{ragged2e}).
% \end{description}
%
% \subsubsection{Size of the columns}\label{hsizecols}
% For the following four macros, be careful that the columns are made from right to left.
%
% \DescribeMacro{\Xhsizetwocol}
% \protect\cs{Xhsizetwocol}\oarg{s}\marg{l} is used to change width of a column when critical notes are displaying in two columns. Default value is \verb+.45 \hsize+.
%
% \DescribeMacro{\Xhsizethreecol}
% \protect\cs{Xhsizethreecol}\oarg{s}\marg{l} is used to change width of a column when critical notes are displaying in three columns. Default value is \verb+.3 \hsize+.
%
% \DescribeMacro{\hsizetwocolX}
% \protect\cs{hsizetwocolX}\oarg{s}\marg{l} is used to change width of a column when familiar notes are displaying in two columns. Default value is \verb+.45 \hsize+.
%
% \DescribeMacro{\hsizethreecolX}
% \protect\cs{hsizethreecolX}\oarg{s}\marg{l} is used to change width of a column when familiar notes are displaying in three columns. Default value is \verb+.3 \hsize+.
%
% \subsection{Options for paragraphed footnotes and notes grouped by line}\label{optionparagraphed}
% \subsubsection{Mark separation of notes}
% \DescribeMacro{\Xafternote} \DescribeMacro{\afternoteX}
% You can add some horizontal space after a note by using \protect\cs{Xafternote}\oarg{s}\marg{l}  (for critical footnotes) or \protect\cs{afternoteX}\oarg{s}\marg{l} (for familiar footnotes). The default value is \verb|1em plus.4em minus.4em|.
%
% \DescribeMacro{\Xparafootsep}\DescribeMacro{\parafootsepX}
% For paragraphed footnotes (see below), you can choose the separator between each note by using \protect\cs{Xparafootsep}\oarg{s}\marg{text} for critical notes and \protect\cs{parafootsepX} for familiar notes.
% A common separator is the double pipe ($\parallel$), which you can set by using \protect\cs{Xparafootsep}\verb+{$\parallel$}+.
%
% Note that if the symbol defined by \protect\cs{Xsymlinenum} must be used at the beginning of a note, the \protect\cs{Xparafootsep} / \protect\cs{parafootsepX} is not used before this note.
%
% \subsubsection{Ragged text}
% \changes{v1.12.0}{2014/08/05}{New options for ragged-paragraph notes}
% \DescribeMacro{\Xragged}
% Text in paragraphed critical notes is justified, but you can use \protect\cs{Xragged}\oarg{s}\arg{L} if you want it to be ragged left (i.e., right justified),
% or \protect\cs{Xragged}\oarg{s}\arg{R} if you want it to be ragged right (i.e., left justified).
%
% \DescribeMacro{\raggedX}
% Text in paragraphed footnotes is justified, but you can use \protect\cs{raggedX}\oarg{s}\arg{L} if you want it to be ragged left, or \protect\cs{raggedX}\oarg{s}\arg{R} if you want it to be ragged right.
%
% \subsection{Options for block of notes}
%
% \subsubsection{Grouping notes by line}
% \DescribeMacro{\Xgroupbyline}
% If you do not use \cs{Xarrangement}\arg{paragraph}, you may want to group all the critical footnotes related to the same line in the same paragraph.
% In this case, use \cs{Xgroupbyline}\oarg{series}.
%
% In many cases, you might like to use it in combination with \cs{Xnumberonlyfirstinline} (\reff{Xnumberonlyfirstinline}).
%
% Note that the \cs{Xafternote} and \cs{Xparafootsep} settings are used to determine space and content between footnotes (\reff{optionparagraphed}).
% \DescribeMacro{\Xgroupbylineseparetwolines}
% Suppose you have two notes on line~1 which overlap lines~1 and~2.
% This last note will be printed, if you use \cs{Xgroupbyline} in the same group as the previous one.
% In the case you want that note to be distinct, you must use both \cs{Xgroupbyline} and \cs{Xgroupbylineseparetwolines}\oarg{s}.
%
% In many cases, you might like to use it in combination with \cs{Xnumberonlyfirstintwolines} (\reff{Xnumberonlyfirstintwolines})
%
% \subsubsection{Text before notes}
% \changes{v1.1.0}{2012/09/12}{New options for block of notes.}
% \DescribeMacro{\Xtxtbeforenotes}
% You can add text before critical footnotes with \protect\cs{Xtxtbeforenotes}\oarg{s}\marg{text}.
% \DescribeMacro{\txtbeforenotesX}
%
% You can add text before familiar footnotes with \protect\cs{txtbeforenotesX}\oarg{s}\marg{text}.
%
% \DescribeMacro{\Xendtxtbeforenotes}
% You can add text before endnotes with \protect\cs{Xendtxtbeforenotes}\oarg{s}\marg{text}. The text will be typeset only if there are endnotes.
%
% \DescribeMacro{\Xtxtbeforenotesonlyonce}
% \DescribeMacro{\txtbeforenotesonlyonceX} By default, such texts are inserted at the beginning of the groups of notes on each page.
% You can add \cs{Xtxtbeforenotesonlyonce} (for critical footnotes) and \cs{txtbeforenotesonlyonceX} (for familiar footnotes) to insert them only the first time notes are typeset.
% \subsubsection{Code before notes}
%\DescribeMacro{\Xbhookgroup}
%\DescribeMacro{\bhookgroupX}
% While \cs{Xtxtbeforenotes} is for typesetting text before notes, \cs{Xbhookgroup}\oarg{s}\marg{code} and \cs{bhookgroupX}\oarg{s}\marg{code} (for critical and familiar respectively) are for executing code before a group of notes, between the rules and the printing of the notes.
%
%
% \subsubsection{Spacing}
% \DescribeMacro{\Xbeforenotes}
% You can change the vertical space before the rule of the critical notes with \protect\cs{Xbeforenotes}\oarg{s}\marg{l}.
% The default value is \verb|1.2em plus .6em minus .6em|.
%
% \textbf{Be careful, the standard \LaTeX\ footnote rule used by \macpackage decreases by 3pt. This 3pt decrease is not changed by this command.}
%
% \DescribeMacro{\beforenotesX}
% You can change the vertical space printed before the rule of the familiar notes with \protect\cs{beforenotesX}\oarg{s}\marg{l}.
% The default value is \verb|1.2em plus .6em minus .6em|.
%
% \textbf{Be careful, the standard \LaTeX\ footnote rule, which is used by \macpackage, decreases 3pt. These 3pt are not changed by this command.}
%
% \DescribeMacro{\Xprenotes}
% You can set the space before the first series of critical notes printed on each page
% and set a different amount of space for each subsequent series on the page.
% You can do it with \protect\cs{Xprenotes}\marg{l}. The default value is \verb+0pt+.
% You can disable this feature by setting the length to 0pt.
%
% \DescribeMacro{\prenotesX}
% You can set the space before the first printed (in a page) series of familiar notes to be different from the space before other series.
% The default value is \verb+0pt+.
% You can do this with \protect\cs{prenotesX}\marg{l}. You can disable this feature by setting the length to 0pt.
%
% \subsubsection{Rule}
% \changes{v1.12.0}{2014/08/05}{New hooks: \protect\cs{Xafterrule} and \protect\cs{afterruleX}}
% \DescribeMacro{\Xafterrule}
% You can change the vertical space printed after the rule of the critical notes with \protect\cs{Xafterrule}\oarg{s}\marg{l}.
% The default value is \verb|0pt|.
%
% \textbf{Be careful, the standard \LaTeX\ footnote rule, which is used by \macpackage, adds 2.6pt. These 2.6pt are not changed by this command.}
%
%
% \DescribeMacro{\afterruleX}
% You can change the vertical space printed after the rule of the familiar notes with \protect\cs{afterruleX}\oarg{s}\marg{l}.
% % The default value is \verb|0pt|.
%
% \textbf{Be careful, the standard \LaTeX\ footnote rule, which is used by \macpackage, adds 2.6pt. These 2.6pt are not changed by this command.}
%
%
% \subsubsection{Maximum height}\label{Xmaxhnotes}
% \DescribeMacro{\Xmaxhnotes}
% By default, one series of critical notes can take up to 80\% of \cs{vsize}, before being broken to the next page.
% If you want to change the size use \protect\cs{Xmaxhnotes}\oarg{s}\marg{l}.
% Be careful : the length can't be flexible, and is relative to the the current font.
% For example, if you want the note to take, at most, 33\% of the text height, do \verb|\Xmaxhnotes{.33\textheight}|.
%
% \DescribeMacro{\maxhnotesX}
% \protect\cs{maxhnotesX}\oarg{s}\marg{l} is the same as previous, but for familiar footnotes.
%
% Note that in many cases, you should call these commands in the begin of the document, because the \cs{vsize} in the preamble is not the same as \cs{vsize} after the preamble.
% That why we recommend to you to add in your preamble
% \begin{verbatim}
% \AtBeginDocument{
%   \maxhnotesX{0.8\textheight}
%   \Xmaxhnotes{0.8\textheight}
% }
% \end{verbatim}
%
% Be careful with the two previous commands.
% Actually, for technical purposes, one paragraphed note is considered as one block.
% Consequently, it cannot be broken between two pages, even if you used these commands.
% The debug is in the todolist.
% \subsubsection{Width}
% \changes{v2.7.0}{2015/11/29}{New hooks: \protect\cs{Xhsize} and \protect\cs{hsizeX}}
% \changes{v2.7.2}{2015/12/13}{\protect\cs{Xhsize} and \protect\cs{hsizeX} become \protect\cs{Xwidth} and \protect\cs{widthX}}
% \DescribeMacro{\Xwidth}
% \DescribeMacro{\widthX}
% \cs{Xwidth}\oarg{s}\marg{l} sets the total width of critical footnotes.
% \cs{widthX}\oarg{s}\marg{l} does the same for familiar footnotes.
%
% \meta{l} can be a length expression, parsable with \cs{dimexpr}.
% For example:
% \begin{verbatim}
%\Xwidth{\columnwidth+\marginparsep+\ledrsnotewidth}
%\widthX{\columnwidth+\marginparsep+\ledrsnotewidth}
% \end{verbatim}
%
% Note that changes the with of the block of notes.
% If you want to change the width of each column when typesetting notes in columns, use \cs{Xhsizetwocol}, \cs{Xhsizethreecol}, \cs{hsizetwocolX}, \cs{hsizethreecolX}, see \reff{hsizecols}.
%
% \subsection{Footnotes and the \parpackage columns}
% \changes{v1.13.0}{2014/09/16}{Add \protect\cs{Xnoteswidthliketwocolumns} and \protect\cs{noteswidthliketwocolumnsX}}
% \DescribeMacro{\Xnoteswidthliketwocolumns}\DescribeMacro{\noteswidthliketwocolumnsX}
% If you use \parpackage\ \protect\cs{columns} macro, you can call :
% \begin{itemize}
%   \item \protect\cs{Xnoteswidthliketwocolumns}\oarg{s} to create critical notes with a two-column size width.
%   \item \protect\cs{noteswidthliketwocolumnsX}\oarg{s} to create familiar notes with a two-column size width.
% \end{itemize}
% \subsection{Line number annotation}
% The way line number annotations are typeset can be changed using hooks as described in \reff{annotationposition} and
% \reff{wraplinenumannotation}.
%
% \subsection{Endnotes in one paragraph}
% \changes{v1.12.0}{2015/04/25}{Add \protect\cs{Xendparagraph} and related settings.}
% \DescribeMacro{\Xendparagraph}
% By default, any new endnote starts a new paragraph.
% Use \protect\cs{Xendparagraph}\oarg{s} to have all end notes of one given series set in one paragraph.
%
% \DescribeMacro{\Xendafternote}
% You can add some space after a endnote series by using \protect\cs{Xendafternote}\oarg{s}\marg{l}. The default value is \verb|1em plus.4em minus.4em|.
%
% \DescribeMacro{\Xendsep}
%  You can choose the separator between each note by \protect\cs{Xendsep}\oarg{s}\marg{text}. A common separator is the double pipe ($\parallel$), which you can set by using \protect\cs{Xendsep}\verb+{$\parallel$}+.
%
% \section{Fonts}\label{fonts}
% One of the most important features of the appearance of the notes,
% and indeed of your whole document, will be the fonts used. We will
% first describe the commands that give you control over the
% use of fonts in the different structural elements of the document,
% especially within the notes, and then in
% subsequent sections specify how these commands are used.
%
%
%
% \DescribeMacro{\numlabfont}
% Line numbers for the main text
% are usually printed in a smaller font in the margin.
% The \protect\cs{numlabfont} macro is provided as a standard name for
% that font: it is initially defined as \\
% \verb"\newcommand{\numlabfont}{\normalfont\scriptsize}" \\
% You might wish to use a different font if, for example,
% you preferred to have these line numbers printed using
% old-style numerals.
%
%
%
%
% \DescribeMacro{\select@lemmafont}
% We will briefly discuss \protect\cs{select@lemmafont}
% here because it is important to know about
% it now, although it is not one of the macros you would expect to
% change in the course of a simple job. Hence it is `protected'
% by having the @-sign in its name.
%
% When you use the \protect\cs{edtext} macro to mark a word in your text
% as a lemma, that word will normally be printed again in your
% apparatus.  If the word in the text happens to be in a font such
% as italic or bold you would probably expect it to appear in the
% apparatus in the same font.  This becomes an absolute necessity
% if the font is actually a different script, such as Arabic or
% Cyrillic.  \protect\cs{select@lemmafont} does the work of
% decoding \macpackage's data about the fonts used to print the lemma in
% the main text and calling up those fonts for printing the lemma in
% the note.
%
% \protect\cs{select@lemmafont} is a macro that takes one long
% argument---the cluster of line numbers passed to the note
% commands. This cluster ends with a code indicating what
% fonts were in use at the start of the lemma.
% \protect\cs{select@lemmafont} selects the appropriate font for the
% note using that font specifier.
%
% \Macpackage uses \protect\cs{select@lemmafont} in a standard footnote
% format macro called \protect\cs{normalfootfmt}.  The footnote formats
% for each of the layers \texttt{A} to \texttt{E} are \protect\cs{let} equal
% to \protect\cs{normalfootfmt}.  So all the layers of the footnotes are
% formatted in the same way.
%
%
% \section{Verse}\label{verse}
%
% \subsection{Basic}
%
% \DescribeMacro{\stanza}
% \DescribeMacro{\&}
% Use \verb?\stanza? at the start of a stanza. Each line in a stanza
% is ended by an ampersand (\verb+&+), and the stanza itself is ended
% by putting \verb?\&? at the end of the last line.
%
% If you need to add brackets directly after \verb?\stanza?, \verb+&+ or \verb?\&?, add \cs{norelax}. Otherwise, the brackets will be interpreted as delimitation of an optional argument (cf.~\reff{contentverse})
%
%
% \subsection{Define stanza indents}
% \DescribeMacro{\stanzaindentbase}
% Lines within a stanza may be indented. The indents are integer multiples
% of the length \verb?\stanzaindentbase?, whose default value is 20pt.
%
% \DescribeMacro{\setstanzaindents}
% In order to use the stanza macros, \textbf{one must set the indentation values}.
% First the value of \verb+\stanzaindentbase+ should be set,
% unless the default value 20pt is desired.
% Every stanza line indentation is a multiple of this.
%
% To specify these
% multiples one invokes, for example \\
% \verb+\setstanzaindents{3,1,2,1,2}+. \\
%
% The numerical entries must be whole numbers, 0 or greater, separated by
% commas without embedded spaces. The first entry
% gives the hanging indentation to be used if the stanza line requires more
% than one print line.
%
%  If it is known that each stanza line will fit in one print line,
% then this first entry should be 0; \TeX\ does less
% work in this case, but no harm ensues if the hanging indentation is not
% 0 but is never used.
%
% If you want the hanging verse to be flush right,
% you can use \protect\cs{sethanginsymbol}: see p.~\reff{hfillhanging}.
%
% Enumeration is by stanza lines, not by print lines.
% In the above example the lines are indented one unit, two units, one unit,
% two units, with 3 units of hanging indentation in case a stanza line is too
% long to fit on one print line.
%
% \subsection{Repeating stanza indents}
%\changes{v0.13.0}{2011/11/08}{New stanzaindentsrepetition counter to repeat stanza indents every \emph{n} verses.}
% \label{stanzaindentsrepetition}Since version 0.13, if the indentation is repeated every \emph{n} verses of the stanza, you can define only the \emph{n} first indentations, and indicate that they are repeated, defining the value of  the \verb+stanzaindentsrepetition+ counter  at \emph{n}. For example:
%\begin{verbatim}
%\setstanzaindents{5,1,0}
%\setcounter{stanzaindentsrepetition}{2}
% \end{verbatim}
%
% is like
%\begin{verbatim}
%\setstanzaindents{5,1,0,1,0,1,0,1,0,1,0}
% \end{verbatim}
%
% \textbf{Be careful: the feature is changed in eledmac 1.5.1. See \reff{change151}.}
%
%If you don't use the  \verb+stanzaindentsrepetition+ counter, make sure you have at least one more numerical
% entry in \verb+\setstanzavalues+ than the number of lines in the stanza.
%
% If you want to disable this feature again, just put the counter to 0:
% \begin{verbatim}
% \setcounter{stanzaindentsrepetition}{0}
% \end{verbatim}
% The macro makes no restriction on the number of lines in a stanza.
%
% Sometime, it is useful to repeat the indents only after some lines of verse.
% You can set the counter \verb+startstanzaindentsrepetition+ to do that.
% Its default value is \verb+1+, that means the repetition starts with line of verse number~1.
%
% For example, you may want to have no indent for the first line, and all other lines been indented by 1.
% So do
% \begin{verbatim}
% \setstanzaindents{1,0,1}
% \setcounter{stanzaindentsrepetition}{1}
% \setcounter{startstanzaindentsrepetition}{2}
% \end{verbatim}
% \subsection{Notes about the scope of the indent settings}
% Stanza indentation values (and penalty values) obey \TeX's grouping
% conventions, so if one stanza among several has a different structure,
% its indentations (penalties) may be set within a group; the prior values
% will be restored when the group ends.
%
% \subsection{Manual stanza indent}
% \DescribeMacro{\stanzaindent}
% \DescribeMacro{\stanzaindent*}
% You can set the indent of some specific verse by calling \protect\cs{stanzaindent}\marg{value} at the beginning of the verse, before any other character. In this case, the indent defined by \protect\cs{setstanzaindents} for this verse is skipped, and \marg{value} is used instead.
%
% If you use the mechanism of indent repetition, the next verse will be printed as it should be even if the current verse would have its normal indent value.
% In other words, using \protect\cs{stanzaindent} in a verse does not shift the indent repetition.
%
% However, if you want to shift the indent repetition, so the next verse has the indent normally used for the current verse, use \protect\cs{stanzaindent*} instead of \protect\cs{stanzaindent}.
% \subsection{Stanza breaking}
% \DescribeMacro{\setstanzapenalties}
% When the stanzas run over several pages, it is often
% desirable that page breaks should arise between certain lines in the
% stanza, so a facility for including penalties after stanza lines is
% provided. If you are satisfied with the page breaks, you need not set the
% penalty values.
%
% The command \\
% \verb+\setstanzapenalties{1,5000,10100,5000,0}+ \\
%  results in a penalty of
% 5000  being placed after the first and third lines of the stanza, and a
% penalty of ${-100}$ after the second.
%
% The first entry ``1'' is a control
% value. If it is zero, then no penalties are passed on to \TeX,
% which is the default. Values between 0 and 10000 are penalty
% values; values between 10001 and 20000 have 10000 subtracted and the result
% is given as a negative penalty. The mechanism used for indentations and
% penalties requires unsigned values less than 32768. No penalty is placed
% after the last line, so the final \verb+,0+ in the example above could
% be omitted.  A penalty of 10000 will prevent a page break; such a
% penalty is included automatically where there is stanza hanging indentation.
% A penalty of ${-10000}$ (corresponding to the entry value 20000 in this
% context) forces a page break. Values in between act as suggestions as to the
% desirability of a page break at a given line. There is a subtle interaction
% between penalties and \emph{glue}, so it may take some adjustment of skips
% and penalties to achieve the best results.
% \subsection{Hanging symbol}
% It is possible to insert a symbol in each line of hanging verse, as in French typography; for example, the opening bracket `['. To insert it in \macpackage, use macro \DescribeMacro{\sethangingsymbol}\protect\cs{sethangingsymbol}\marg{h} with this code.
% In the example of French typography, do
% \begin{verbatim}
% \sethangingsymbol{[\,}
% \end{verbatim}
% \label{hfillhanging} You can also use it to force hanging verse to be flush right:
% \begin{verbatim}
% \sethangingsymbol{\protect\hfill}
% \end{verbatim}
% \subsection{Long verse and page break}
% If you want to prevent page breaks inside long verses, use the option \verb+nopbinverse+ when loading package, or use \protect\cs{lednopbinversetrue}.
% Read \reff{lednopbinversetrue} for further details.
% \subsection{Content before/after verses}\label{contentverse}
% It is possible to add content, like a subtitle or a spacing, before or after verse:
% \begin{itemize}
%   \item The \protect\cs{stanza} command can take an optional argument (in brackets). Its content will be printed before the stanza. A \cs{noindent} is inserted before the content of first optional argument.
% If you don't want this \cs{noindent}, you can use the  second optional argument (also in brackets):
% \begin{verbatim}
% \stanza[foo] % \noindent is inserted before foo.
% \stanza[][foo] % There is no \noindent inserted before foo.
% \end{verbatim}
%
% \item \DescribeMacro{\AtEveryStanza} Use \cs{AtEveryStanza}\marg{arg} to automatically add content before stanzas (not in the same paragraph).
%
% Note that a \cs{noindent} will be inserted before the argument, and, consequently, a \cs{parskip}. You can use the starred version of \protect\cs{AtEveryStanza} to avoid this \cs{noindent}.
%  \item \DescribeMacro{\AtStartEveryStanza} Use \cs{AtStartEveryStanza}  to automatically add content at the beginning of stanzas (in the same paragraph).
%   \item \verb+&+ can be replaced by \protect\cs{newverse} with two optional arguments (in brackets). The first will be printed after the current verse, the second before the next verse.
%
% A \cs{noindent} is automatically inserted before the contents of these optional arguments.
%
% Use a third and fourth optional argument to not add these \cs{noindent}s (to add content respectively after the current verse / before the next verse).
% \item  Use \cs{AtEveryPend}\marg{arg} to automatically add content after verses (including the final one) and \cs{AtEveryPstart}\marg{arg} to automatically add content before verses (including the first one).
%   \item \verb+\&+ can take an optional argument (in brackets). Its content will be printed after the stanza.
%
% \item \DescribeMacro{\AtEveryStopStanza} Use \cs{AtEveryStopStanza} to automatically add content after the end of stanzas (not in the same paragraph).
%
% Note that a \cs{noindent} will be inserted before the argument, and, consequently, a \cs{parskip}. You can use the starred version of \protect\cs{AtEveryStopStanza}  to avoid this \cs{noindent}.
%
%  \item \DescribeMacro{\BeforeEveryStopStanza} Use \cs{BeforeEveryStopStanza} to automatically add content at the end of stanzas (in the same paragraph).
% \end{itemize}
%
%
% \subsection{Numbering stanza}\label{numbering-stanza}
% \DescribeMacro{\numberstanzatrue}
% \DescribeMacro{\numberstanzafalse}
% If you want to automatically number stanzas, use \cs{numberstanzatrue}.
% In this case, the line number will restart at each \cs{stanza}.
%
%
% If you want to disable this feature again, use \cs{numberstanzafalse}.
%
% You can use this feature in combination with \cs{Xstanza} (\reff{Xstanza}).
%
% \DescribeMacro{thestanza}
% You can redefine \cs{thestanza} to change the aspect of stanza number.
% Default value is:
% \begin{verbatim}
% \renewcommand{\thestanza}{%
%   \textbf{\arabic{stanza}}%
% }
%
% \end{verbatim}
%
% You can change the value of the \verb+stanza+ counter with the usual commands of \LaTeX.
%
% \DescribeMacro{\stanzanumwrapper}
% You can redefine \cs{stanzanumwrapper} in order to modify the way the stanza number is inserted in the flow of text.
% Default value is:
% \begin{verbatim}
% \newcommand{\stanzanumwrapper}[1]{%
%    \flagstanza{#1}%
%}
% \end{verbatim}
% \DescribeMacro{\antilabe}
% \subsection{Antilabe}\label{antilabe}
% In dramatic text, it may happen that a line of verse is split between two speakers.
% Thats is called \enquote{antilabe}.
% In this case, the typesetting of the second half  must start at the horizontal position where the typesetting of the first half stops.
%
% \Reledmac\  provides tool for such problematic, but you must enable them with the \option{antilabe} option when loading package, as this option is quite ressource consuming.
%
% The \cs{antilabe}\marg{name} must be called at the beginning of the second half of the line of verse.
%
% Its \meta{name} argument is the name of the speaker.
% Because of the way \TeX\ expand argument, you can use one the following syntax:
% \begin{itemize}
%   \item \verb+\antilabe{name}+, if you typeset the character name;
%   \item \verb+\antilabe\command+,  if the character name is defined in a command, like with the \package{thalie} package;
%   \item \verb+\antilabe{}+, if you do not type the character name.
% \end{itemize}
% See the file  \href{examples/2-antilabe.tex}{examples/2-antilabe.tex} for an example of use.
%
% \DescribeMacro{\beforeantilabe}
% \DescribeMacro{\afterantilabe}
% You can execute any arbitrary code before or after \cs{antilabe} macro just with a redefinition of \cs{beforeantilabe} or \cs{afterantilabe}.
% For example, to add more space, just do:
% \begin{verbatim}
% \renewcommand{\afterantilabe}{\hspace{1em}}
% \end{verbatim}
% \subsection{Various tools}
% \DescribeMacro{\ampersand}
% If you need to print an \& symbol in a stanza, use the \verb?\ampersand?
% macro, not \verb?\&? as this will end the stanza.
%
% \DescribeMacro{\flagstanza}
% Putting \protect\cs{flagstanza}\oarg{len}\marg{text} at the start of a  line
% in a stanza (or elsewhere) will typeset \meta{text} at a
% distance \meta{len} before
% the line. The default \meta{len} is \verb?\stanzaindentbase?.
%
% \subsection{Notes on empty lines}
% Since v2.3.0 of \reledmac, empty lines when typesetting verses no longer produce new paragraphs, and consequently, do not insert vertical spaces.
% Use optional argument of \cs{stanza} or \cs{newverse} to insert vertical space (\reff{contentverse}).
% \section{Grouping}
%    In a \verb?minipage? environment \LaTeX\ changes \verb?\footnote? numbering from
% arabic to alphabetic and puts the footnotes at the end of the minipage.
%
% \DescribeEnv{minipage}
% You can put numbered text with critical footnotes in a minipage and
% the footnotes are set at the end of the minipage.
%
% You can also put familiar footnotes (see section~\ref{sec:desc:familiar})
% in a minipage but unlike with \verb?\footnote? the numbering scheme is
% unaltered.
%
% \DescribeEnv{ledgroup}\label{ledgroup}
% Minipages, of course, are not broken across pages. Footnotes in a \verb?ledgroup?
% environment are typeset at the end of the environment, as with minipages,
% but the environment includes normal page breaks. The environment makes no
% change to the textwidth so it appears as normal text; it just might be that
% footnotes appear in the middle of a page, with text above and below.
%
% \DescribeEnv{ledgroupsized}
% The \verb?ledgroupsized? environment is similar to \verb?ledroup? except that
% you must specify a width for the environment, as with a minipage. \\
% \verb?\begin{ledgroupsized}?\oarg{pos}\marg{width}.
%
%    The required \meta{width} argument is the text width for the environment. The
% optional \meta{pos} argument is for positioning numbered text within
% the normal textwidth. It may be one of the characters:
% \begin{itemize}
% \item[l] (left) numbered text is flush left with respect to the normal
%        textwidth. This is the default.
% \item[c] (center) numbered text is in the center of the textwidth.
% \item[r] (right) numbered text is flush right with respect to the
%        normal textwidth.
% \end{itemize}
% Note that normal text, footnotes, and so forth are all flush left.
%
% \verb?\begin{ledgroupsized}{\textwidth}? is effectively the same as
% \verb?\begin{ledgroup}?
%
%
%
%
%
% \section{Cross referencing}
% \changes{v1.12.0}{2014/08/05}{Add hyperlink to crossref (needs \protect\package{hyperref} package).}
% \label{crossref}\relax
% The package provides a simple cross-referencing facility that allows
% you to mark places in the text with labels, and generate page and
% line number references to those places elsewhere
% using those labels.
%
% \subsection{Basic use}
%
% \DescribeMacro{\edlabel}
% First you place a label in the text using the command
% \protect\cs{edlabel}\marg{lab}. \meta{lab} can be almost anything you like, including
% letters, numbers, punctuation, or a combination---anything but spaces;
% you might type \protect\cs{edlabel}\verb+{toves-3}+, for example.\footnote{More precisely,
% you should stick to characters in the \TeX\ categories of ``letter''
% and ``other''.}
%
% \DescribeMacro{\edpageref}
% \DescribeMacro{\edlineref}
% \DescribeMacro{\sublineref}
% \DescribeMacro{\pstartref}
% \DescribeMacro{\annotationref}
% Elsewhere in the text, either before or after the \protect\cs{edlabel},
% you can refer to its location with \protect\cs{edpageref}\marg{lab},
% \protect\cs{edlineref}\marg{lab}, \cs{edsublineref}\marg{lab}, \cs{pstartref}\marg{lab} or \cs{annotationref}\marg{lab},
% that
% will produce, respectively, the page, line, sub-line,  pstart, the annotation,  on which
% the \protect\cs{edlabel}\marg{lab} command occurred.
%
% Note that the \cs{edlineref} command insert the side flag after the line number.
%
%
% An \protect\cs{edlabel} command may appear in the main text, or in the
% first argument of \protect\cs{edtext}, but not in the apparatus itself.  But
% \protect\cs{edpageref}, \protect\cs{edlineref}, \protect\cs{sublineref}, \protect\cs{pstartref} commands can also be used in
% the apparatus to refer to \protect\cs{edlabel}s in the text.
%
% The \protect\cs{edlabel} command works by writing macros to \LaTeX
% \file{.aux} file. You will need to process
% your document through \LaTeX\ twice in order for the references to
% be resolved.
%
% You will be warned if you use \verb"\edlabel{foo}" and \verb"foo"
% has been used as a label before. The \verb"ref" commands will
% return references to the last place in the file marked with this
% label. You will also be warned if a reference is made to an
% undefined label. (This will also happen the first time you
% process a document after adding a new \protect\cs{edlabel} command: the
% auxiliary file will not have been updated yet.)
%
% \subsection{Cross-referencing to a critical note}
% If you want to refer to a word which is a lemma word, the \cs{edlabel} command should be in the first argument of \cs{edtext} command.
%
% If you want to refer to the content of a \cs{Xfootnote}, the line and subline number printed will be the start line.
%
% If you want to refer to starting and ending lines, you should use \cs{appref} and related tools (\reff{appref}).
% \subsection{Cross-referencing which return a number in any case}
% \DescribeMacro{\xpageref}
% \DescribeMacro{\xlineref}
% \DescribeMacro{\xsublineref}
% \DescribeMacro{\xpstartref}
% \DescribeMacro{\xannotationref}
%
% However, there are situations in which you will want \macpackage\ to
% return a number without displaying any
% warning messages about undefined labels or the like: if you want to
% use the reference in a context where \LaTeX{} is looking for a
% number, such a warning will lead to a complaint that the number
% is missing.
% This is the case for references used within the
% argument to \protect\cs{linenum}, for example (see \reff{linenum}).
%
%For this situation,
% \macpackage\ supplies variants of the reference commands, with the \verb"x"
% prefix: \cs{xpageref}, \cs{xlineref}, \cs{xsublineref}, \cs{xpstartref} and \cs{xannotationref}.
% They have the following limitations:
% \begin{itemize}
%     \item They will not tell you if the label is undefined.
%     \item They must
% be preceded in the file by at least one of the four other
% cross-reference commands---e.g., a \verb"\edlabel{foo}" command,
% even if you never refer to that label---since those commands can all
% do the necessary processing of the \file{.aux} file, and the \protect\cs{x...}
% ones cannot.
%     \item When \protect\package{hyperref} is loaded, the hyperref link will not be added. (Indeed,
%  it is not a limitation, but a feature.)
%     \item With \parpackage, the \cs{xlineref} does not insert the right side flag, in order to obtain a line number. Use \cs{xflagref} to obtain the side flag, depending of your flag.
% \end{itemize}
%
% \subsubsection{Cross-referencing in order to define line number of a critical note}
% \DescribeMacro{\xxref}
%
% The \protect\cs{xxref}\marg{lab1}\marg{lab2} command generates a reference to a sequence of
% lines, for use in the second argument of \protect\cs{edtext}.
% It takes two arguments, both of which are
% labels: e.g., \verb"\xxref{mouse}{elephant}".
%
% It automatically calls \protect\cs{linenum}
% (\reff{linenum}) and \cs{lineannot} (\reff{lineannot})  and sets the beginning page,
% line,   subline numbers and line annotations to those of the place where
% \verb"\edlabel{mouse}" was placed, and the ending ones to those where
% \verb"\edlabel{elephant}" occurs.
%
% For example, one might use the following:
% \begin{verbatim}
%\beginnumbering
%
%\pstart
%\edlabel{Queritur}Queritur utrum metaphysica sit scientia una.
%\pend
%
%\pstart
%\edtext{Et videtur quod non\edlabel{non}.}{\xxref{Queritur}{non}\lemma{queritur \dots{} non}\Afootnote{om. \emph{A}}}
%\pend
%
%\endnumbering
% \end{verbatim}
% \subsection{Not automatic cross-referencing}
% \DescribeMacro{\edmakelabel}
% Sometimes the \protect\cs{edlabel} command cannot be used to specify exactly
% the page and line desired---for example, if you want to refer to a
% page and line number in another volume of your edition.  In such
% cases, you can use the \protect\cs{edmakelabel}\marg{lab}\marg{numbers}
% macro so that you can `roll your own' label.
%
% For example, if you type `\verb"\edmakelabel{elephant}{10|25|0}"'
% you will create a new label, and a later call to \verb"\edpageref{elephant}" would print
% `10' and \verb"\lineref{elephant}" would print `25'. The sub-line
% number here is zero.  It is usually best to collect your
% \protect\cs{edmakelabel} statements near the top of your document, so that
% you can see them at a glance.
% \subsection{Normal \LaTeX\ cross-referencing}
% \DescribeMacro{\label}
% \DescribeMacro{\ref}
% \DescribeMacro{\pageref}
% \changes{v0.2.1}{2003/08/25}{Added text about normal labeling}
%    The normal \protect\cs{label}, \protect\cs{ref} and \protect\cs{pageref} macros may be used
% within numbered text, and operate in the familiar fashion.
% \subsection{References to start and end lines}
% \subsubsection{Reference to main text lines}
% \changes{v2.5.0}{2015/11/13}{New tools to easily make cross-reference to a passage defined by a start and an end line}
% Many times, you may want to make a cross-reference to a passage that is defined by a start line and an end line.
% \Macpackage\ provides specific tools for this scenario.

% \DescribeMacro{\edlabelS}
% Use \cs{edlabelS}\marg{label} to mark the start line of the passage.
%
% \DescribeMacro{\edlabelE}
% Use \cs{edlabelE}\marg{label} to mark the end the end line of the passage.
% These two commands just create two labels which are named \meta{label}\verb+:start+ and \meta{label}\verb+:end+.
%
% \DescribeMacro{\edlabelSE}
% Use \cs{edlabelSE}\marg{label} to mark just one location in the text. Contrary to a classical \cs{edlabel}, the \meta{label} could be use with \cs{SEref} and \cs{SErefwithpage}.
%
%
% The main utility is to use them with three other commands.
% \DescribeMacro{\SEref}
% \cs{SEref}\marg{label} will make a cross-reference printed as a reference in critical footnotes.
%
% \DescribeMacro{\SErefwithpage}
% \cs{SErefwithpage} will make a cross-reference printed as a reference in critical endnotes.
%
% \DescribeMacro{\SErefonlypage}
% \cs{SErefonlypage} will make a cross-reference printed only with page number.
%
% \subsubsection{References to lines that are commented on in the apparatus}\label{appref}
% \changes{v1.21.0}{2015/03/09}{Add \protect\cs{applabel} and related}
% You may want to make a cross-reference to a passage that is referred to by \protect\cs{edtext}.
% \Macpackage\ provides specific tools for this scenario.
%
% \DescribeMacro{\applabel}
% If you use \protect\cs{applabel}\marg{label} inside the second argument of a \protect\cs{edtext},
% \Macpackage\ will add a \protect\cs{edlabel} at the beginning and end of the marked passage.
% The label at the beginning of the passage will have the title \meta{label}\verb+:start+, while the label at the end will have the title \meta{label}\verb+:end+.
%
% If you use \protect\cs{linenum} (\reff{linenum}) to
% refer to these labels, \macpackage\ will use your line settings to refer
% to the passage.
%
% \DescribeMacro{\appref}\DescribeMacro{\apprefwithpage}
% You can also use \protect\cs{appref}\marg{label} and
% \protect\cs{apprefwithpage}\marg{label} to refer to these lines.
% The first one will print the lines as they are printed in the critical footnotes,
% while the second will print the lines as they are printed in endnotes.
%
% \subsubsection{Settings}
% \paragraph{Specific to these tools}
% \DescribeMacro{\setapprefprefixsingle}\DescribeMacro{\setapprefprefixmore}
% If you use \protect\cs{apprefprefixsingle}\marg{prefix}, \meta{prefix} will be printed
% before the line numbers of a \protect\cs{appref}-reference.
% If you use \protect\cs{apprefprefixmore}\marg{prefix}, \meta{prefix} will be printed
% before the line numbers, if you refer to more than one line.
%
% For example, you may use:
% \begin{verbatim}
%  \setapprefprefixsingle{line~}
%  \setapprefprefixmore{lines~}
% \end{verbatim}
%
% Note that if you do not use \protect\cs{setapprefprefixmore}, the argument of \protect\cs{setapprefprefixsingle} will be used in any case.
%
%
% \DescribeMacro{\setSErefprefixsingle}\DescribeMacro{\setSErefprefixmore}
% \cs{setSErefprefixsingle} and \cs{setSErefprefixmore} are similar for \cs{SEref} command.
%
% \DescribeMacro{\setSErefonlypageprefixsingle}
% \DescribeMacro{\setSErefonlypageprefixmore}
% Use \cs{setSErefonlypageprefixsingle}\marg{prefix} to set the page prefix for \cs{SErefonlypage} when there is only one page.
% Use \cs{setSErefonlypageprefixmore}\marg{prefix} to set it when there is more than one page.
% For example:
% \begin{verbatim}
% \setSErefonlypageprefixsingle{p.~}
% \setSErefonlypageprefixmore{pp.~}
% \end{verbatim}
% Note that if you do not use  \cs{setSErefonlypageprefixmore}, the value of \cs{setSErefonlypageprefixsingle} is used instead.
%
%
% \textbf{Also note that \cs{setSErefonlypageprefixsingle} is only a shortcut for \cs{XendbeforepagenumberSErefonlypage} (see \reff{crossrefsetting:linked}).
% So if you use \cs{Xendbeforepagenumber} without any optional argument, it will override this setting.}
% \paragraph{Linked to setting of critical footnotes and endnotes}\label{crossrefsetting:linked}
% Some commands which set the appearance of line numbers in critical footnotes also set the appearance of line numbers in \cs{appref} and \cs{SEref} if called \emph{without the optional series argument}.
%
% These commands are the following:
% \begin{itemize}
%   \item \cs{Xlineflag} (for \parpackage), enabled by default.
%   \item \cs{Xlinerangeseparator}
%   \item \cs{Xmorethantwolines}
%   \item \cs{Xsublinesep}
%   \item \cs{Xtwolines}
%   \item \cs{Xtwolinesbutnotmore}
%   \item \cs{Xtwolinesonlyinsamepage}
%   \item \cs{Xlinenumannotationposition}
%   \item \cs{Xwraplinenumannotation}
%   \item \cs{Xnoidenticallinenumannotation}
% \end{itemize}
%
% If you want to make settings specific  to \cs{appref} or \cs{SEref}, just call them with an optional argument containing a comma-separated list of command names (for example \verb+appref,SEref+) or with a suffix equal to the command name (for example \verb+appref+).
%
%
% The same principle is available for \cs{apprefwithpage}, \cs{SErefwithpage} and \cs{SErefonlypage} with the following commands:
% \begin{itemize}
%   \item\cs{Xendafterpagenumber} (not for \cs{SErefonlypage})
%   \item\cs{Xendbeforepagenumber}
%   \item\cs{Xendlineflag} (for \parpackage), enabled by default.
%   \item\cs{Xendlineprefixmore}
%   \item\cs{Xendlineprefixsingle}
%   \item\cs{Xendlinerangeseparator}
%   \item\cs{Xendmorethantwolines}
%   \item\cs{Xendsublinesep}
%   \item\cs{Xendtwolines}
%   \item\cs{Xendtwolinesbutnotmore}
%   \item\cs{Xendtwolinesonlyinsamepage}
%   \item\cs{Xendlinenumannotationposition}
%   \item\cs{Xendwraplinenumannotation}
%   \item\cs{Xemdnoidenticallinenumannotation}
% \end{itemize}
% \paragraph{For one specific command}
%
% When calling \cs{appref} and \cs{SEref}, you can use as a first optional argument, in brackets (\verb+[]+), any optional argument which can be used for critical footnotes (\reff{Xfootnoteopt}).
%
% When calling \cs{apprefwithpage}, \cs{SErefwithpage} or \cs{SErefonlypage} you can use as a first optional argument, in brackets (\verb+[]+), any optional argument which can be used for critical endnotes (\reff{Xendnoteopt}).
%
% \subsubsection{Combining multiple references}
%
% When combining multiple cross references into a list, it is possible to prevent prefixes reappearing by adding an optional argument to \cs{appref} and \cs{SEref}. The available options are:
% \begin{itemize}
% \item \option{noprefix} to remove any prefix set by \cs{setapprefprefixsingle} or the equivalent for a single reference;
% \item \option{prefixmore} to force the plural version of a prefix.
% \end{itemize}
%
% For example, a reference to `lines 65--66, 72, and 75' might use \verb|\SEref[prefixmore]{ref1}, \SEref[noprefix]{ref2}, and \SEref[noprefix]{ref3}| to achieve this result.
%
% \subsection{Compatibility with \protect\package{xr} package}
% The \cs{externaldocument} command of the \cs{xr} package allows making cross-references from an external document, with the standard \LaTeX\ commands \cs{label} and \cs{ref} (and related).
%
% To use it with the \macpackage\ cross-reference commands (i.e. \cs{edlabel} and related), you must do the following:
% \begin{enumerate}
% \item Load the \package{xr} package.
% \item Load the \package{reledmac} package.
% \item Use the \cs{externaldocument} document command.
% \end{enumerate}
% \section{Sidenotes}
%
% \subsection{Basics}
% The \protect\cs{marginpar} command does not work in numbered text. Instead,
% the package provides for non-floating sidenotes in either margin.
%
% \DescribeMacro{\ledinnernote}
% \DescribeMacro{\ledouternote}
% \protect\cs{ledinnernote}\marg{text} will put \meta{text} into the inner margin level
% with where the command was issued. Similarly, \protect\cs{ledouternote}\marg{text}
% puts \meta{text} in the outer margin.
%
% \changes{v1.12.0}{2014/08/05}{Add \protect\cs{ledinnernote} and \protect\cs{ledouternote} commands.}
% \changes{v1.12.3}{2014/08/15}{Debug \protect\cs{ledinnernote} and \protect\cs{ledouternote} commands in the top of pages.}
% \DescribeMacro{\ledleftnote}
% \DescribeMacro{\ledrightnote}
% \changes{v1.0.0}{2012/09/15}{Possibility to have commands in sidenotes.}
% \DescribeMacro{\ledsidenote}
% \DescribeMacro{\sidenotemargin}
% \protect\cs{ledsidenote}\marg{text} will put \meta{text} into the margin specified
% by the current setting of \protect\cs{sidenotemargin}\marg{location}. The
% permissible value for \meta{location} is one out of the list
% \texttt{left}, \texttt{right}, \texttt{inner}, or \texttt{outer}, for
% example \verb?\sidenotemargin{outer}?. The package's default setting
% is \\
% \verb?\sidenotemargin{right}? \\
% to typeset \protect\cs{ledsidenote}s in the right hand margin.
% This is the opposite of the default margin for line numbers. The style for a \protect\cs{ledsidenote}
% follows that for a \protect\cs{ledleftnote} or a \protect\cs{ledrightnote} depending
% on the margin it is put in.
%
%    If two note commands for the same side are called in the same line, they will
% be appended and separated by a comma.
%
% \textbf{The notes will appear only after the second \LaTeX\ run. If the note positions change in your \texttt{.tex} file,
% you need two runs to get the correction position in the output file.
% You are strongly encouraged to use tools like \emph{latexmk}, to be sure to get the correct number of runs.}
% \subsection{Setting}
%
% \subsubsection{Width}
% \DescribeMacro{\ledlsnotewidth}
% \DescribeMacro{\ledrsnotewidth}
% The left sidenote text is put into a box of width \protect\cs{ledlsnotewidth}
% and the right text into a box of width \protect\cs{ledrsnotewidth}. These
% are initially set to the value of \protect\cs{marginparwidth}.
%
% \subsubsection{Vertical position}
% \DescribeMacro{\rightnoteupfalse}
% \DescribeMacro{\leftnoteupfalse}
% By default, sidenotes are placed to align with the last line of the note to which it refers.
% If you want they to be placed to align with the first line of the note to which it refers, use \protect\cs{leftnoteupfalse} (for left note) and/or \protect\cs{rightnoteupfalse} (for right note).
%
% \subsubsection{Distance to the main text }
% \DescribeMacro{\ledlsnotesep}
% \DescribeMacro{\ledrsnotesep}
% The texts are put a distance \protect\cs{ledlsnotesep} (or \protect\cs{ledrsnotesep})
% into the left (or right) margin. These lengths are initially set to
% the value of \protect\cs{linenumsep}.
%
% \subsubsection{Font}
% \DescribeMacro{\ledlsnotefontsetup}
% \DescribeMacro{\ledrsnotefontsetup}
% These macros  specify how the sidenote texts are to be typeset. The
% initial definitions are:
% \begin{verbatim}
% \newcommand*{\ledlsnotefontsetup}{\raggedleft\footnotesize}% left
% \newcommand*{\ledrsnotefontsetup}{\raggedright\footnotesize}% right
% \end{verbatim}
% These can of course be changed to suit.
%
% \subsubsection{Separator between notes}
% \DescribeMacro{\setsidenotesep}
% If you have two or more sidenotes for the same line, they are separated by a comma.
% But if you want to change this separator, you can use \protect\cs{setsidenotesep}\marg{sep}.
%
% \section{Indexing}
%
% \subsection{Basics}
% \DescribeMacro{\edindex}
% \LaTeX\ provides the |\index|\marg{item} command for specifying that \meta{item}
% and the current page number should be added to the raw index (\file{idx}) file.
% The |\edindex|\marg{item} macro can be used in numbered text to specify
% that \meta{item} and the current page \& linenumber should be added to
% the raw index file.
%
% Note that the file \verb+.idx+ will contain the right reference only after the third run, because of the internal indexing mechanism of \protect\macpackage.
% That means you must first run (Xe/Lua)\LaTeX three times, then run \verb+makeindex+, and then finally run (Xe/Lua)\LaTeX\ again, in order to get an index with the right page numbers.
%
% Also note that using \cs{edtext} in familiar footnotes refers to the line where the footnotes are called
% \subsection{Use with \package{imakeidx} or \package{indextools}}
% If  the \protect\package{imakeidx} or \protect\package{indextools} package is used then the macro takes an optional
% argument, which is the name of a raw index file. For example
% |\edindex[line]{item}| will use |line.idx| as the raw file instead of
% |\jobname.idx|.
%
% The minimal version of \protect\package{imakeidx} package to be used is the version 1.3a uploaded on CTAN on 2013/07/11.
%
% Be careful with the order of package loading and index declaration. You must use this order:
% \begin{enumerate}
%     \item Load \package{imakeidx} or \package{indextools} .
%     \item Load \macpackage.
%   \item Declare the index with the macro \cs{makeindex} of \package{imakeidx} and \package{indextools}.
% \end{enumerate}
%
% \subsection{Referring to critical notes}
% If you want to refer to a word inside an
% \protect\cs{edtext}\marg{lemma}\marg{app} command, \protect\cs{edindex} should be defined inside
% the first argument, e.g.,
% \begin{verbatim}
%   The \edtext{creature\edindex{elephant} was quite
%    unafraid}{\Afootnote{Of the mouse, that is.}}
% \end{verbatim}
%
% If you add \protect\cs{edindex} inside some \protect\cs{Xfootnote} command,
% it will refer to that note, and a suffix \emph{n} will be appended to the reference.
%
% \DescribeMacro{\Xinnotemark}
% \DescribeMacro{\innotemarkX}
% You can redefine the way the reference is made using :
% \begin{itemize}
%  \item \cs{Xinnotemark}\oarg{series}\marg{definition} for critical notes;
%  \item \cs{innotemarkX}\oarg{series}\marg{definition} for familiar notes;
% \end{itemize}
% In the \meta{definition} argument, you can use the following codes:
% \begin{itemize}
% \item \verb+#1+, which stands for footnote series;
% \item \verb+##1+, which stands for reference (ie. page+line)
% \end{itemize}
% For example:
% \begin{verbatim}
% \Xinnotemark{##1\textsuperscript{#1}}
% \end{verbatim}
% \subsection{Separator between page and line numbers}
% \DescribeMacro{\pagelinesep}\label{pagelinesep}
% The page \& linenumber combination is written as |page\pagelinesep line|,
% where the default definition is |\newcommand{\pagelinesep}{-}| so that
% an item on page 3, line 5 will be noted as being at |3-5|. You can
% renew |\pagelinesep| to get a different separator.
%
% |-| is the default
% separator used by the \textsc{MakeIndex} program.
%
% You can reconfigure it, this example defines a colon as separator:
% \begin{verbatim}
% \renewcommand{\pagelinesep}{:}
% \end{verbatim}
%
% However, you also have to configure your \verb+.ist+ index style file. For example, if you use \verb+:+ as separator\footnote{For further detail, you can read \url{http://tex.stackexchange.com/a/32783/7712}.}.
% \begin{verbatim}
% page_compositor ":"
% \end{verbatim}
%
% Read the \textsc{MakeIndex} program's handbook about the \verb+.ist+ file.
% \subsection{Using xindy}\label{xindy}
% Should you decide to use \verb+xindy+ instead of \verb+makeindex+
% to transform your \verb+.idx+ files into \verb+.ind+ files,
% you must use some specific configuration file (\verb+.xdy+) so that
% \verb+xindy+ can understand \protect\package{eledmac} reference syntax of which the scheme is:\\
% \verb+pagenumber-linenumber+
%
% An example of such a file is provided in the ``\href{examples/.}{examples}'' folder.
% Read the xindy handbook to learn how to use it.\footnote{Or, for people
% who read French, read \url{http://geekographie.maieul.net/174}.}
%
% This file also provides, with an explanation, the settings that are needed to put
% \macpackage\ lines numbers in parenthesis, in order
% to make a better distinction between line numbers and page ranges.
%
% In any case, you must load \macpackage\  with the \verb+xindy+ option,
% in order to generate a \verb|.xdy| file which is specific to your document.
% This file is needed by the \verb+.xdy+ example file which is in the ``\href{examples/.}{examples}'' folder.
% Its default name is \verb+reledmac-markup-attr.xdy+,
% but you can change it by using your own as an argument of the \verb|xindy+hyperref| option.
%
% If you choose to use both \verb+xindy+ and the \verb+hyperref+ package,
% you must do three more things:
% \begin{enumerate}
%   \item Use \verb|xindy+hyperref| option when loading the \macpackage\  package.
% When you run (Xe/Lua)\LaTeX with this option, a \verb+.xdy+ configuration file will be generated with all the settings needed to allow internal hyperlinking in each index entry which is created by \protect\cs{edindex}.
%   \item Use \verb+hyperindex=false+ option when loading hyperref.
%   \item Uncomment\,---\,by removing the semicolons at the beginning of the relevant lines\,---\,some lines in the <code>.xdy</code> file provided in the ``\href{examples/.}{examples}'' folder in order to restore internal links in the index to be used by the standard \verb+index+ command.\footnote{These are the recommended lines to provide the best possible compatibility between hyperref and xindy, even without using \macpackage.}.
% \end{enumerate}
% \subsection{Advanced setting}
% \DescribeMacro{\edindexlab}
% The \protect\cs{edindex} process uses a \protect\cs{label} and \protect\cs{ref} mechanism to get
% the correct line number. It automatically generates labels
% of the form \protect\cs{label}\verb|{\edindexlab N}|, where N is a number, and
% the default definition of \protect\cs{edindexlab} is: \\
% |\newcommand*{\edindexlab}{$&}| \\
% in the hopes that this will not be used by any other labels
% (\protect\cs{edindex}'s labels are like \protect\cs{label}\verb|{$&27}|).
% You can change \protect\cs{edindexlab} to something else if you need to.
%
% \section{Glossary}
% \Macpackage\ provides mechanism to make glossaries with the \package{glossaries} package, refering not to the page, but to the page and line.
% \subsection{Preamble setting}
% The standard compositor between page and line number in \macpackage\  is a dash, while \package{glossaries} uses, by default, a dot.
% Consequently, you must:
% \begin{itemize}
% \item Or set .
% \package{glossaries}:\\ \verb+\glsSetCompositor{-}+
% \item Or set \reledmac:\\  \verb+\renewcommand{\pagelinesep}{.}+\\
% In this case, the above will have consequences for your use of \cs{edindex} and you should set your \verb+.ist+ file (\reff{pagelinesep}).
%
% \end{itemize}
% \subsection{Commands}
% The \cs{gls}, \cs{Gls}, and related commands of \package{glossaries} packages have a prefixed version with \verb+ed+, which refers to the page line.
% The argument are the same as for the standard commands.
% So for example:\\
% \cs{edgls}\oarg{options}\marg{label}\oarg{insert}
% \section{Tabular material}
%
% \LaTeX's normal |tabular| and |array| environments cannot be used where
% line numbering is being done; more precisely, they can be used but with
% odd results, so don't use them. However, \macpackage\  provides some simple
% tabulation environments that can be line numbered. The environments
% can also be used in normal unnumbered text.
%
% \DescribeEnv{edarrayl}
% \DescribeEnv{edarrayc}
% \DescribeEnv{edarrayr}
% \DescribeEnv{edtabularl}
% \DescribeEnv{edtabularc}
% \DescribeEnv{edtabularr}
%    There are six environments; the |edarray*| environments are for math
% and |edtabular*| for text entries. The final |l|, |c|, or |r|
% in the environment names indicate that the entries will be flushleft (|l|),
% centered (|c|) or flushright (|r|). There is no means of specifying
% different formats for each column, nor for specifying a fixed width for
% a column. The environments are centered with respect to the surrounding text.
%
% \egstart
% \begin{verbatim}
% \begin{edtabularc}
% 1 & 2 & 3 \\
% a & bb & ccc \\
% AAA & BB & C
% \end{edtabularc}
% \end{verbatim}
% \egmid
% \centering
% \begin{tabular}{ccc}
% 1 & 2 & 3 \\
% a & bb & ccc \\
% AAA & BB & C
% \end{tabular}\par
% \egend
%
%   Entries in the environments are the same as for the normal
% |array| and |tabular| environments but there must be no ending
% \verb?\\? at the end of the last row.
% \emph{There must be the same number of column designators (the \&)
% in each row.} There is no equivalent
% to any line drawing commands (such as \protect\cs{hline}).
% However, unlike the normal environments,  the |ed...| environments
% can cross page breaks.
%
%    Macros like \protect\cs{edtext} can be used as part of an entry.
%
% For example:
% \begin{verbatim}
% \beginnumbering
% \pstart
% \begin{edtabularl}
% \textbf{\Large I} & wish I was a little bug\edindex{bug} &
% \textbf{\Large I} & eat my peas with honey\edindex{honey} \\
%  & With whiskers \edtext{round}{\Afootnote{around}} my tummy &
%  & I've done it all my life. \\
%  & I'd climb into a honey\edindex{honey} pot &
%  & It makes the peas taste funny \\
%  & And get my tummy gummy.\edindex{gummy} &
%  & But it keeps them on the knife.
% \end{edtabularr}
% \pend
% \endnumbering
% \end{verbatim}
%  produces the following parallel pair of verses.
%
% \begin{center}
% \setlength{\tabcolsep}{2pt}
% \begin{tabular}{p{4em}rlrl}
% {\footnotesize 1} & \textbf{\Large I} & wish I was a little bug &
% \textbf{\Large I} & eat my peas with honey \\
% {\footnotesize 2} & & With whiskers round my tummy &
%  & I've done it all my life. \\
% {\footnotesize 3} & & I'd climb into a honey pot &
%  & It makes the peas taste funny \\
% {\footnotesize 4} & & And get my tummy gummy. &
%  & But it keeps them on the knife.
% \end{tabular}
% \end{center}
%
%
%
%
%
% \DescribeMacro{\edtabcolsep}
% The distance between the columns is controlled by the length |\edtabcolsep|.
%
% \DescribeMacro{\spreadmath}
% \DescribeMacro{\spreadtext}
% |\spreadmath|\marg{math} typesets \marg{math} but the \marg{math} has
% no effect on the calculation of column widths.
% |\spreadtext|\marg{text} is the analagous command for use in |edtabular|
% environments.
%
% \egstart
% \begin{verbatim}
% \begin{edarrayl}
% 1 & 2  &  3  &  4 \\
%   & \spreadmath{F+G+C} & & \\
% a & bb & ccc & dddd
% \end{edarrayl}
% \end{verbatim}
% \egmid
% \begin{displaymath}
% \begin{array}{llll}
% 1 & 2  &  3  &  4 \\
%   & \multicolumn{3}{l}{F+G+C} \\
% a & bb & ccc & dddd
% \end{array}
% \end{displaymath}
% \egend
%
% \DescribeMacro{\edrowfill}
% The macro |\edrowfill|\marg{start}\marg{end}\marg{fill}
% fills columns number \meta{start} to \meta{end} inclusive with
% \meta{fill}. The \meta{fill} argument can be any horizontal `fill'.
% For example, |\hrulefill| or |\upbracefill|.
%
% Note that every row must have the same number of columns, even if
% some would not appear to be necessary.
%
% The |\edrowfill| macro can be used in both tabular and array environments.
% The typeset appearance of the following code is shown below.
% \begin{verbatim}
% \begin{edtabularr}
% 1                                & 2    & 3  & 4  & 5 \\
% Q                                &      & fd & h  & qwertziohg \\
% v                                & wptz & x  & y  & vb \\
% g                                & nnn  & \edrowfill{3}{5}{\upbracefill} & & \\
% \edrowfill{1}{3}{\downbracefill} &      &    & pq & dgh \\
% k                                &      & l  & co & ghweropjklmnbvcxys \\
% 1                                & 2 & 3 & \edrowfill{4}{5}{\hrulefill} &
% \end{tabularr}
% \end{verbatim}
%
% \begin{center}
% \begin{tabular}{rrrrr}
% 1                            & 2    & 3  & 4  & 5 \\
% Q                            &      & fd & h  & qwertziohg \\
% v                            & wptz & x  & y  & vb \\
% g                            & nnn  & \multicolumn{3}{c}{\upbracefill} \\
% \multicolumn{3}{c}{\downbracefill}       & pq & dgh \\
% k                            &      & l  & co & ghweropjklmnbvcxys \\
% 1                            & 2    & 3  & \multicolumn{2}{c}{\hrulefill}
% \end{tabular}
% \end{center}
%
%    You can also define your own `fill'. For example:
% \begin{verbatim}
% \newcommand*{\upbracketfill}{%
%   \vrule height 4pt depth 0pt\hrulefill\vrule height 4pt depth 0pt}
% \end{verbatim}
% is a fill like |\upbracefill| except it has the appearance of a
% (horizontal) bracket instead of a brace. It can be used like
% this:
%
% \newcommand*{\upbracketfill}{%
%   \vrule height 4pt depth 0pt\hrulefill\vrule height 4pt depth 0pt}
%
% \begin{verbatim}
% \begin{edarrayc}
% 1 & 2                                & 3 & 4 \\
% a & \edrowfill{2}{3}{\upbracketfill} &   & d \\
% A & B                                & C & D
% \end{edarrayc}
% \end{verbatim}
%
% \begin{displaymath}
% \begin{array}{cccc}
% 1 & 2                                  & 3 & 4 \\
% a & \multicolumn{2}{c}{\upbracketfill}     & d \\
% A & B                                  & C & D
% \end{array}
% \end{displaymath}
%
%
%
% \DescribeMacro{\edatleft}
% \DescribeMacro{\edatright}
% \protect\cs{edatleft}\oarg{math}\marg{symbol}\marg{halfheight} typesets the math
% \meta{symbol} as \protect\cs{left}\marg{symbol}
% with the optional \meta{math} centered before it. The \meta{symbol} is
% twice \meta{halfheight} tall. The \protect\cs{edatright} macro is similar
% and it typesets \protect\cs{right}\marg{symbol} with \meta{math} centered after it.
%
% \begin{verbatim}
% \begin{edarrayc}
%    & 1 & 2 & 3 &  \\
%    & 4 & 5 & 6 &  \\
% \edatleft[left =]{\{}{1.5\baselineskip}
%    & 7 & 8 & 9 &
% \edatright[= right]{)}{1.5\baselineskip}
% \end{edarrayc}
% \end{verbatim}
%
% \begin{displaymath}
% left = \left\{
% \begin{array}{ccc}
%  1 & 2 & 3 \\
%  4 & 5 & 6 \\
%  7 & 8 & 9
% \end{array}
% \right) = right
% \end{displaymath}
%
%
%
% \DescribeMacro{\edbeforetab}
% \DescribeMacro{\edaftertab}
% \protect\cs{edbeforetab}\marg{text}\marg{entry}, where \meta{entry} is an entry in the
% leftmost column, typesets \meta{text} left justified before the \meta{entry}.
% Similarly \protect\cs{edaftertab}\marg{entry}\marg{text}, where \meta{entry} is an entry
% in the rightmost column, typesets \meta{text} right justified after the
% \meta{entry}.
%
% For example:
% \begin{verbatim}
% \begin{edarrayl}
%                    A  & 1 & 2 & 3 \\
% \edbeforetab{Before}{B} & 1 & 3 & 6 \\
%                    C  & 1 & 4 & \edaftertab{8}{After} \\
%                    D  & 1 & 5 & 0
% \end{edarrayl}
% \end{verbatim}
%
%
% \begin{displaymath}
% \begin{array}{p{0.4\textwidth}llp{0.4\textwidth}}
% \mbox{} \hfill $A$ & 1 & 2 & $3$ \\
% Before  \hfill $B$ & 1 & 3 & $6$ \\
% \mbox{} \hfill $C$ & 1 & 4 & $8$ \hfill After \\
% \mbox{} \hfill $D$ & 1 & 5 & $0$
% \end{array}
% \end{displaymath}
%
% \DescribeMacro{\edvertline}
% \DescribeMacro{\edvertdots}
% The macro \protect\cs{edvertline}\marg{height} draws a vertical line \meta{height} high
% (contrast this with \protect\cs{edatright} where the size argument is half the desired
% height).
% \begin{verbatim}
% \begin{edarrayr}
%  a & b & C & d   & \\
%  v & w & x & y   & \\
%  m & n & o & p   & \\
%  k &   & L & cvb & \edvertline{4pc}
% \end{edarrayr}
% \end{verbatim}
%
% \DeleteShortVerb{\|}
% \begin{displaymath}
% \left.
% \begin{array}{rrrr}
%  a & b & C & d   \\
%  v & w & x & y   \\
%  m & n & o & p   \\
%  k &   & L & cvb
% \end{array}
% \right|
% \end{displaymath}
% \MakeShortVerb{\|}
%
% The \protect\cs{edvertdots} macro is similar to \protect\cs{edvertline} except that it
% produces a vertical dotted instead of a solid line.
%
%
% \section{Sectioning commands}
% \changes{v1.1.0}{2012/09/25}{Sectioning commands.}
% \changes{v1.12.0}{2014/08/05}{New sectioning commands.}
% \subsection{Sectioning commands without line numbers or critical notes}
% The standard sectioning commands (\protect\cs{chapter}, \protect\cs{section} etc.) can be used inside numbered text.
% In this case, you must call them as an optional argument of \protect\cs{pstart} (\reff{pstart:optionalarg}):
% \begin{verbatim}
% \pstart[\section{section}]
% Pstart content.
% \pend
% \end{verbatim}
% The line which contains them will not be numbered, and you cannot add critical notes inside.
% \subsection{Sectioning commands with line numbering and critical notes}
% \label{eledsection}
% You have to use the following commands:
% \begin{itemize}
% \item \protect\cs{eledchapter}\oarg{text}\marg{critical text},
% \item \protect\cs{eledchapter*},
% \item \protect\cs{eledsection}\oarg{text}\marg{critical text},
% \item \protect\cs{eledsection*},
% \item \protect\cs{eledsubsection}\oarg{text}\marg{critical text},
% \item \protect\cs{eledsubsection*},
% \item \protect\cs{eledsubsubsection}\oarg{text}\marg{critical text},
% \item \protect\cs{eledsubsubsection*}.
% \end{itemize}
% These are equivalent to the \LaTeX\ commands.
% Each individual command must be called alone in a \protect\cs{pstart}\,\ldots\,\protect\cs{pend}:
% \begin{verbatim}
%\pstart
%\eledsection*{xxxx\ledsidenote{section}}
%\pend
%\pstart
%\eledsubsection*{xxxx\ledsidenote{sub}}
%\pend
%\pstart
%normal text
%\pend
% \end{verbatim}
% After the first run, you will see only the text. This is normal.
% After the second run, you will see the formatting.
% Finally, with the third run, you will see the table of contents.
%
% For technical reasons, the page break before \protect\cs{elechapter} cannot be added automatically.
% You have to insert it manually via \protect\cs{beforeeledchapter}, which must be called outside of a numbered section.
%
% \subsection{Optimization}\label{optimize}
% If you are not going to have any \protect\cs{eledxxx} commands, then load \macpackage\  with \protect\option{noeledsec} option.
% That will suppress the generation of unneeded \file{.eledsec} files, save memory, and make \macpackage\ run faster.
%
% \section{Quotation environments}
% The \verb+quotation+ and \verb+quote+ environments can be used so that the same definition/note appears both inside and outside a numbered section.
% The typographical consequences will resemble the outside numbered sections, based on the styles of the \emph{book} class.
% However, if you use a package that redefines these environments, these redefinitions won't be available inside the numbered section.
% You must open any quotation environments inside a \protect\cs{pstart}\,\ldots\,\protect\cs{pend} block, not outside.
% A quotation environment MUST NOT be opened immediately after a \protect\cs{pstart}
% and MUST NOT be closed immediately before a \protect\cs{pend}.
%
% \label{noquotation} In some cases, you do not want these environments to be redefined in numbered sections.
% You can load the package with the option \verb+noquotation+ to prevent this redefinition.
%
% \section{Page breaks}
%
% \subsection{Control page breaking}
% \changes{v1.7.0}{2013/11/08}{New features for managing page breaks.}
% \Macpackage\ and \parpackage break pages automatically. However, you may sometimes want to either force page breaks, or prevent them.
% \DescribeMacro{\ledpb} \DescribeMacro{\lednopb} The packages provide two macros:
% \begin{itemize}
%    \item \protect\cs{ledpb} adds a page break.
%    \item \protect\cs{lednopb} prevents a page break, by adding one line to the current page if needed.
% \end{itemize}
% \textbf{These commands have effect only at the second run}.
%
% These two commands take effect at the beginning of line in which they are called.
% For example, if you call \protect\cs{ledpb} at l.~444, then l.~443 will be at p.~$n$, and l.~444 at p.~$n+1$.
% \DescribeMacro{\ledpbsetting} However, you can change the behavior and decide they will have effect after  the end of the line, adding
% \verb+\ledpbsetting{after}+ at the beginning of your file (better: in your preamble). With the previous example, l.~444 will be
% on p.~$n$ and l.~445 will be on p.~$n+1$.
%
% If you are using \parpackage to typeset parallel pages, you must use \protect\cs{lednopb} on
% both sides in the two corresponding lines. This is especially important when you are using
% stanzas; otherwise, the pages will be out of sync.
%
% \subsection{Prevent page break in a long verses}
% \label{lednopbinversetrue}\DescribeMacro{\lednopbinversetrue} You can also decide to prevent page breaks between two lines of a long verse. To do this, use \verb+nopbinverse+ when loading package, or add \protect\cs{lednopbinversetrue} in the beginning of your file (better: in your preamble).
%
% This feature works only with verse of 2 lines and no more. It works on the third run, or on the fourth run if using \reledpar.
% By default, when a long verse runs between two pages, a page break will be placed at the beginning of the verse. However, if you have added \cs{ledpbsetting}\arg{after}, the page break will be placed at the end of the long verse and the page containing the long verse will have one extra line.
%
% \section{Miscellaneous}
%
% \DescribeMacro{\extensionchars}
% When the package assembles the name of the auxiliary file for a
% section, it prefixes \protect\cs{extensionchars} to the section number.
% This is initially defined to be empty, but you can add some characters to
% help distinguish these files if you like; what you use is likely
% to be system-dependent. If, for example, you said
% \verb"\renewcommand{\extensionchars}{!}", then you would get temporary
% files called \file{jobname.!1}, \file{jobname.!2}, etc.
%
% \DescribeMacro{\ifledfinal}
%    The package can take options. The option `final', which is the default
% is for final typesetting; this sets \verb?\ifledfinal? to TRUE. The other
% option, `draft', may be useful during earlier stages and sets
% \verb?\ifledfinal? to FALSE.
%
% \DescribeMacro{\showlemma}
%    The lemma within the text is printed via \verb?\showlemma{lemma}?.
% Normally, or with the `final' option, the definition of \verb?\showlemma?
% is: \\
% \verb?\newcommand*{\showlemma}[1]{#1}? \\
% so it just produces its argument.
% With the `draft' option it is defined as \\
% \verb?\newcommand*{\showlemma}[1]{\textit{#1}}? \\
% so that its argument is typeset in an italic font, which may make it
% easier to check that all lemmas have been treated.
%
%    If you would prefer some other style, you could put something like this
% in the preamble:
% \begin{verbatim}
% \ifledfinal\else
%    \renewcommand{\showlemma}[1]{\textbf{#1}}% or simply ...[1]{#1}
% \fi
% \end{verbatim}
%
%
% \subsection{Known and suspected limitations}
% \subsubsection{Non-standard geometry}
% If you use classes other than \ltxclass{article} or \ltxclass{book}, or if you use the geometry package, you should use \protect{maxhnotesX} and\slash{}or \cs{Xmaxhnotes} as explained in \reff{Xmaxhnotes} in order to prevent footnotes from overlapping the bottom margin.
%
% \subsubsection{\package{floatrow} package compatibility}
% The \package{floatrow} package must be loaded before the \macpackage.
% \subsubsection{`No room for a new'}\label{noroom}
% Sometimes, especially when using \macpackage\ with other packages, you could obtain warning messages such 'no room for a new count' or 'no room for a new write'.
%
% In order to prevent such problems, the first thing is to use the options to optimize \macpackage.
% For example, if you need only two series of notes, use the \verb+series={A,B}+ option.
% Read \reff{optimize} in order to know which are the available options.
%
% However, if with these options you still have such messages, here are some tricks.
% \begin{description}
%  \item['no room for a new count'] is often caused by \protect\package{biblatex} being used at the same time.
%  Load \macpackage\ (and \parpackage) \emph{before} \protect\package{biblatex}.
%  \item['no room for a new write'] can be caused by multiple indexes.
% In this case, use \protect\package{indextools} of \protect\package{imakeidx} with the \verb+splitindex+ option, in order to obtain only one \verb+.idx+ file.
% If that does not solve your problem, you can use \protect\package{morewrites} package.
% That should solve the problem, but \LaTeX\ will be slower.
%
% \end{description}
%
% If after reading and applying these advices you have still problem, contact us with a minimal working example.
%
% \subsubsection{Marginal notes}
% In general, \macpackage's system for adding marginal line numbers
% breaks anything that makes direct use of the \LaTeX\ insert system,
% which includes marginpars, footnotes and floats.
%
% However, you can use both \protect\cs{footnote} and the familiar footnote
% series notes in numbered text. A \protect\cs{marginpar} in numbered text
% will throw away its contents and send a warning message to the terminal
% and log file, but will do no harm.
%
% \subsubsection{Paragraph shape}
% \protect\cs{parshape} cannot be used within numbered text, except in a
% very restricted way.
%
% \DescribeMacro{\ballast}
% \LaTeX\ is a three-pass system, but even after a document has
% been processed three times, there are some tricky situations in
% which the page breaks decided by \TeX\ never settle down.  At
% each successive run, \macpackage\ may oscillate between two
% different sets of page decisions.  To stop this happening, should
% it arise, Wayne Sullivan\index{Sullivan, Wayne} suggested the
% inclusion of the quantity \protect\cs{ballast}.  The amount of \protect\cs{ballast}
% will be subtracted from the penalties which apply to the page
% breaks calculated on the \emph{previous} run through \TeX, thus
% reinforcing these breaks.  So if you find your page breaks
% oscillating, insert \\
% \verb"\setcounter{ballast}{100}" \\
% or some such figure, and with any
% luck the page breaks will settle down.  Luckily, this problem
% does not crop up at all often.
% \subsubsection{Paragraphed footnotes}\label{paragraphednotes:advanced}
% The restriction on explicit line-breaking in paragraphed footnotes,
% mentioned on \reff{nobreaks}, and
% described in more detail on \reff{nobreaks-detail}, really is a
% nuisance if that is something you need to do.  There are some possible
% solutions, described by Michael Downes\index{Downes, Michael},
% but this area remains unsatisfactory.
%
% \label{nopenalties}If you use more than one series of paragraphed notes, it may happen, in some particular cases, that only the footnote rule, with no accompanying footnotes, be printed.
% In this case use \reledmac\ package option \option{nopenalties}
% which should solve the problem, but also may produce widow or orphan lines.
% For the time being, we have no solution of this problem.
%
%
%
% \DescribeMacro{\footfudgefiddle}
% For paragraphed footnotes \TeX{} has to estimate the amount of space
% required. If it underestimates this then the notes may get too long and
% run off the bottom of the text block. \protect\cs{footfudgefiddle} can be increased
% from its default 64 (say, to 68) to increase the estimate. You have to use
% \protect\cs{renewcommand} for this, like: \\
% \verb?\renewcommand{\footfudgefiddle}{68}?\\
% Note that you must call it \emph{before} \cs{Xarrangement}\arg{paragraph} or \cs{arrangementX}\arg{paragraph}.
%
% Any settings to `geometry' must be made before \cs{Xarrangement} / \cs{arrangementX}.
%
% Finally, in many cases you should use \cs{Xmaxhnotes} and / or \cs{maxhnotesX} (\reff{Xmaxhnotes}), in order to define the maximum height relative to \cs{textheight} and not to \cs{vsize}, because the \cs{vsize} value is not the same inside and outside of the preamble.
%
% \subsubsection{Use with other packages}
%
% Because of \macpackage's complexity, it may not play well with other
% packages. In particular \macpackage\ is sensitive to commands in the
% arguments to the \protect\cs{edtext} and \protect\cs{*footnote} macros (this is
% discussed in more detail in section~\ref{text}, and in particular
% the discussion about \protect\cs{no@expands} and \protect\cs{morenoexpands}). You
% will have to see what works or doesn't work in your particular case.
%
% \DescribeMacro{\morenoexpands}
% You can define the macro \protect\cs{morenoexpands} to modify macros that you
% call within \protect\cs{edtext}. Because of the way \macpackage{} numbers the lines
% the arguments to \protect\cs{edtext} can be processed more than once and in some
% cases a macro should only be processed once. One example is the \protect\cs{colorbox}
% macro from the \protect\package{color} package, which you might use like this:
% \begin{verbatim}
% ... \edtext{\colorbox{mycolor}{lemma}}{\Afootnote{...\colorbox...}}
% \end{verbatim}
% If you actually try
% this\footnote{Reported by Dirk-Jan Dekker\index{Dekker, Dirk-Jan}
% in the CTT thread `Incompatibility
% of ``color'' package' on 2003/08/28.}
% you will find \LaTeX\ whinging
% `\texttt{Missing \{ inserted}', and then things start to fall apart.
% The trick in this case is to specify either:
% \begin{verbatim}
% \newcommand{\morenoexpands}{\let\colorbox=0}
% \end{verbatim}
% or
% \begin{verbatim}
% \makeatletter
% \newcommand{\morenoexpands}{\let\colorbox\@secondoftwo}
% \makeatother
% \end{verbatim}
% (\protect\cs{@secondoftwo} is an internal \LaTeX\ macro that takes two arguments and
% throws away the first one.)
% The first incantation lets color show in both the main text and footnotes
% whereas the second one shows color in the main text but kills it
% in the lemma and footnotes. On the other hand if you use
% \protect\cs{textcolor} instead, like
% \begin{verbatim}
% ... \edtext{\textcolor{mycolor}{lemma}}{\Afootnote{...\textcolor...}}
% \end{verbatim}
% there is no need to fiddle with \protect\cs{morenoexpands} as the color will
% naturally be displayed in both the text and footnotes. To kill the color
% in the lemma and footnotes, though, you can do:
% \begin{verbatim}
% \makeatletter
% \newcommand{\morenoexpands}{\let\textcolor\@secondoftwo}
% \makeatother
% \end{verbatim}
% It took Peter Wilson a little while to discover all this. If you run into this sort
% of problem you may have to spend some time experimenting before hitting
% on a solution.
%
%%
%
% If you want to use the option \emph{bottom} of the \protect\package{footmisc} package,
% you must load this package \emph{before} the \macpackage\ package.
%

% \subsection{Parallel typesetting}\label{eledpar}
%
%
% Peter Wilson has developed the \ledpar package
% as an extension to \ledmac specifically for parallel typesetting
% of critical texts. This also cooperates with the \protect\package{babel} / \protect\package{polyglossia}
% packages for typesetting in multiple languages.
% \Parpackage is the successor of the primitive \ledpar package.
%
%
% Peter Wilson also developed
% the \protect\package{ledarab} package for
% handling parallel Arabic text in critical editions.
% However, this package is not maintened by Maïeul Rouquette.
% You should use the capabilities of a modern TeX processor, like Xe(La)TeX
%
%
%
%
% \StopEventually{}
%
% \clearpage
% \renewcommand{\thesection}{\Roman{section}}
% \renewcommand\theHsection{\Roman{section}}
% \setcounter{section}{0}
%
% \section{Implementation overview}\label{overview}
%
%
% We present the \macpackage\ code in roughly the order in which it is used
% during a run of \TeX. The order is \emph{exactly} that in which
% it is read when you load the \macpackage{} package, because the same file
% is used to generate this manual and to generate the \LaTeX\ package file.
%
% Most of what follows consists of macro definitions, but there
% are some commands that are executed immediately---especially
% at the start of the code. The documentation generally describes the
% code from the point of view of what happens when the macros are
% executed, though. As each macro is introduced, its name is printed
% in the margin.
%
% After package options, we begin with the commands you use to start and
% stop line numbering in a section of text (Section~\ref{preliminaries}).
% Next comes the machinery for writing and reading the auxiliary file for
% each section that helps us count lines, and for creating list macros
% encoding the information from that file (Section~\ref{lineation}); this
% auxiliary file will be read at the start of each section, to create
% those list macros, and a new version of the file will be started to
% collect information from the body of the section.
%
% Next are commands for marking sections of
% the text for footnotes (Section~\ref{text}), followed by the macros
% that take each paragraph apart, attach the line numbers and insertions,
% and send the result to the vertical list (Section~\ref{paragraph}). The
% footnote commands (Section~\ref{footnotes}) and output routine
% (Section~\ref{output}) finish the main part of the processing;
% cross-referencing (Section~\ref{xref}) and endnotes
% (Section~\ref{endnotes}) complete the story.
%
% In what follows, macros with an @ in their name are more internal
% to the workings of \macpackage\ than those made up just of
% ordinary letters, just as in \PlainTeX\ (see \thetexbook,
% p.\,344).  You are meant to be able to make free with
% ordinary macros, but the `@' ones should be treated with more
% respect, and changed only if you are pretty sure of what you are
% doing.
%
%
% \section{Preliminaries}
% \label{preliminaries}\relax
% \subsection{Links with original \edmac}
%    Generally, these are the modifications to the original.
% \edmac{} code:
% \begin{itemize}
% \item Replace as many \protect\cs{def}'s by \protect\cs{newcommand}'s as possible
% to avoid overwriting \LaTeX\ macros.
%
% \item Replace user-level \TeX\ counts by \LaTeX\ counters.
%
% \item Use the \LaTeX\ font handling mechanisms.
%
% \item Use \LaTeX\ messaging and file facilities.
%
% \end{itemize}
%
%
% \subsection{Package declaration}
% Announce the name and version of the package, which is
% targetted for LaTeX2e.
%
%    \begin{macrocode}
%<*code>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{reledmac}[2020/06/24 v2.34.0 typesetting critical editions]%
%    \end{macrocode}
%
% \subsection{Package options}
% \changes{v0.4.0}{2004/02/29}{Added final/draft options}
% \changes{v1.13.0}{2014/09/16}{Added widthliketwocolumns option}
% \begin{macro}{\ifparledgroup}
% \begin{macro}{\ifsameparallelpagenumber}
% \begin{macro}{\ifprevpgnotnumbered}
% \begin{macro}{\ifledfinal}
% \begin{macro}{\ifnocritical@}
% \begin{macro}{\if@noeled@sec}
% \begin{macro}{\ifnoend@}
% \begin{macro}{\ifnofamiliar@}
% \begin{macro}{\ifnoledgroup@}
% \begin{macro}{\ifparapparatus@}
% \begin{macro}{\ifnoquotation@}
% \begin{macro}{\iflednopbinverse}
% \begin{macro}{\ifwidthliketwocolumns}
% \begin{macro}{\ifxindy@}
% \begin{macro}{\ifxindyhyperref@}
% \begin{macro}{\ifeledmaccompat@}
% \begin{macro}{\ifnoresetlinenumannotation@}
% \begin{macro}{\ifantilabe@}
% Use this to remember which option is used, set and execute the options
% with final as the default.
% We use \protect\package{xkeyval} in order to manage options with argument.
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
%\subsubsection{Options of \parpackage}
% Here, we define some booleans specific to \parpackage\  options, but which have consequences on \macpackage\ internal commands.
%    \begin{macrocode}
\newif\ifparledgroup
\newif\ifsameparallelpagenumber%
\newif\ifprevpgnotnumbered%%
%    \end{macrocode}
%\subsubsection{Options of \macpackage}
%    \begin{macrocode}
\DeclareOptionX{series}[A,B,C,D,E]{\xdef\default@series{#1}}
\ExecuteOptionsX{series}%

\newif\if@noeled@sec%
\DeclareOptionX{noeledsec}{\@noeled@sectrue}

\newif\ifnocritical@%
\DeclareOptionX{nocritical}{\nocritical@true}%

\newif\ifnofamiliar@%
\DeclareOptionX{nofamiliar}{\nofamiliar@true}%

\newif\ifnoledgroup@%
\DeclareOptionX{noledgroup}{\noledgroup@true}%

\newif\ifnoend@%
\DeclareOptionX{noend}{%
 \let\l@dend@open\@gobble%
 \let\l@dend@close\relax%
  \global\let\l@dend@stuff=\relax%
  \noend@true%
}%

\newif\ifnoquotation@
\DeclareOptionX{noquotation}{\noquotation@true}

\newif\ifledfinal
\DeclareOptionX{final}{\ledfinaltrue}
\DeclareOptionX{draft}{\ledfinalfalse}
\ExecuteOptionsX{final}

\newif\ifparapparatus@
\DeclareOptionX{parapparatus}{\parapparatus@true}

\newif\iflednopbinverse
\DeclareOptionX{nopbinverse}{\lednopbinversetrue}

\newif\ifwidthliketwocolumns%
\DeclareOptionX{widthliketwocolumns}{\widthliketwocolumnstrue}%

\newif\ifcontinuousnumberingwithcolumns
\DeclareOptionX{continuousnumberingwithcolumns}{\continuousnumberingwithcolumnstrue}%

\newif\ifxindy@
\DeclareOptionX{xindy}[eledmac-markup-attr.xdy]{%
  \AtBeginDocument{\immediate\openout\eledmac@xindy@out=#1}%
  \newwrite\eledmac@xindy@out%
  \xindy@true%
  \gdef\eledmacmarkuplocrefdepth{:depth 1}%
  \AtEndDocument{\immediate\closeout\eledmac@xindy@out}%
}%

\newif\ifxindyhyperref@
\DeclareOptionX{xindy+hyperref}{%
  \xindyhyperref@true%
}%

\newif\ifeledmaccompat@%
\DeclareOptionX{eledmac-compat}{%
  \eledmaccompat@true%
}%
\DeclareOptionX{nopenalties}{%
  \AtBeginDocument{\let\add@penalties\relax}%
}
\def\l@auxdir{}%
\DeclareOptionX{auxdir}{%
  \xdef\l@auxdir{#1/}%
}%

\newif\ifsw@caseinsensitive%
\DeclareOptionX{swcaseinsensitive}{%
  \sw@caseinsensitivetrue%
}%
\newif\ifnoresetlinenumannotation@
\DeclareOptionX{noresetlinenumannotation}{%
  \noresetlinenumannotation@true%
}%
\newif\ifantilabe@%
\DeclareOptionX{antilabe}{%
  \antilabe@true%
}%
%    \end{macrocode}
% We use the starred form of \protect\cs{ProcessOptionsX} which executes options in
% the order listed in the source file: class options, then listed package
% options, so a package option can override a class option with the same name.
% This was suggested by Dan Luecking\index{Luecking, Dan} in the \texttt{ctt}
% thread \textit{Class/package option processing}, on 27 February 2004.
%    \begin{macrocode}
\ProcessOptionsX*\relax

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Loading packages}
% Loading package \protect\package{xargs} to declare commands with optional arguments.
% Loading package \package{xparse} to declare fully expandable commands with optional argument. Ideally, we should use only \package{xparse} and not \package{xargs}. For historical reasons, we use both.
% \protect\package{Etoolbox} is also used to make code clearer - for example, in dynamic command names (which can replace \protect\cs{csname} etc.).
% Use \protect\package{suffix} to declare commands with a starred version, \protect\package{xstring} to work with strings, \protect\package{ifluatex} and \protect\package{ifxetex} to test if \LuaTeX\ or \XeTeX\  is running, and \protect\package{ragged2e} to manage ragged justification for paragraphed notes.
%  \begin{macrocode}
\RequirePackage{xargs}
\RequirePackage{xparse}[2017/03/07]%
\RequirePackage{etoolbox}
\@ifl@t@r\fmtversion{2015/10/01}
 {\ifboolexpr{not test{\@ifl@t@r\fmtversion{2016/03/31}} or (test{\ifdefstring{\fmtversion}{2016/03/31}} and test {\ifnumless{\patch@level}{3}})}%
   {\PackageWarning{reledmac}{You are using a LaTeX version older than 2016/03/31 patch 3.%
   \MessageBreak You are strongly encouraged to use a newer version.}}%
   {}%
 }%
 {\RequirePackage{etex}%
 \csname reserveinserts\endcsname{32}%
 }%
\RequirePackage{suffix}
\RequirePackage{xstring}
\RequirePackage{ifluatex}
\RequirePackage{ragged2e}
\RequirePackage{ifxetex}%
%    \end{macrocode}
%
% \subsection{Compatibility with \LuaTeX}
% Here, we enable some primitives for \LuaTeX.
%    \begin{macrocode}
\ifx\directlua\undefined\else%
  \directlua{tex.enableprimitives("",{"textdir","pardir","bodydir"})}
\fi
\ifluatex%
  \ifnum\luatexversion<110%
    \PackageWarning{reledmac}{You need to use LuaTeX 1.1.0 or higher}{\@ehc}%
  \fi%
\fi%
%    \end{macrocode}
% \subsection{Boolean flags}
% \begin{macro}{\ifl@dmemoir}
% Define a flag for if the \protect\package{memoir} class has been used.
% \changes{v0.2.0}{2003/07/25}{Added \protect\cs{ifl@dmemoir} for memoir class having been used}
%    \begin{macrocode}
\newif\ifl@dmemoir
\@ifclassloaded{memoir}{\l@dmemoirtrue}{\l@dmemoirfalse}

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\if@ledgroup}
% Flag set to true inside a \env{ledgroup} environment.
%    \begin{macrocode}
\newif\if@ledgroup%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ifl@imakeidx}
% Define a flag for if the \protect\package{imakeidx} package has been used.
%    \begin{macrocode}
\newif\ifl@imakeidx
\@ifpackageloaded{imakeidx}{\l@imakeidxtrue}{}%False is the default value
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\ifl@indextools}
% Define a flag for if the \protect\package{indextools} package has been used.
%    \begin{macrocode}
\newif\ifl@indextools%
\@ifpackageloaded{indextools}{%
  \l@indextoolstrue%
  \l@imakeidxtrue%
  \let\imki@wrindexentry\indtl@wrindexentry%
  }{}%
%    \end{macrocode}
%False is the default value. We consider \protect\package{indextools} as a variant of \protect\package{imakeidx}. That is why we set \protect\cs{ifl@imakeidx} to true. We also let \protect\cs{imki@wrindexentry} to \protect\cs{indtl@wrindexentry}.
% \end{macro}
% \begin{macro}{\ifl@footmisc}
% Define a flag if the \protect\package{footmisc} package has been loaded.
%    \begin{macrocode}
\newif\ifl@footmisc
\@ifpackageloaded{footmisc}{\l@footmisctrue}{}%False is the default value
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\if@RTL}
% The \protect\cs{if@RTL} is defined by the bidi package, which is sometimes loaded by \emph{polyglossia}.
% But we define it as well if the \protect\package{bidi} package is not loaded.
%    \begin{macrocode}
\ifdef{\if@RTL}{}{\newif\if@RTL}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\if@firstlineofpage}
% \cs{if@firstlineofpage} is set to TRUE at the first line of every page.
% \cs{if@firstlineofpageR} is for the right side.
%    \begin{macrocode}
\newif\if@firstlineofpage%
\newif\if@firstlineofpageR%
%    \end{macrocode}
% \end{macro}
% \subsection{Messages}
%
% All the messages are grouped here as macros. This saves \TeX's memory
% when the same message is repeated and also lets them be edited easily.
% \changes{v0.7.0}{2005/02/21}{Made macros of all messages}
% \changes{v1.12.3}{2012/08/15}{Add macros for new messages since v0.7}
%
% \begin{macro}{\reledmac@warning}
% Write a warning message.
%    \begin{macrocode}
\newcommand{\reledmac@warning}[1]{\PackageWarning{reledmac}{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\reledmac@error}
% Write an error message.
% \changes{v0.2.0}{2003/07/25}{Added \protect\cs{eledmac@error} and replaced error messages}
% \changes{v1.12.3}{2014/08/15}{Replaced error messages}
%    \begin{macrocode}
\newcommand{\reledmac@error}[2]{\PackageError{reledmac}{#1}{#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@err@NumberingStarted}
% \begin{macro}{\led@err@NumberingNotStarted}
% \begin{macro}{\led@err@NumberingShouldHaveStarted}
%    \begin{macrocode}
\newcommand*{\led@err@NumberingStarted}{%
  \reledmac@error{Numbering has already been started}{\@ehc}}
\newcommand*{\led@err@NumberingNotStarted}{%
  \reledmac@error{Numbering was not started}{\@ehc}}
\newcommand*{\led@err@NumberingShouldHaveStarted}{%
  \reledmac@error{Numbering should already have been started}{\@ehc}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@err@samewordRTL}
%    \begin{macrocode}
\newcommand*{\led@err@samewordRTL}{%
  \reledmac@error{You can't use \string\sameword \MessageBreak with XeLaTeX \MessageBreak when typesetting RTL text.\MessageBreak Please use LuaTeX instead.}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@err@edtextoutsidepstart}
% \begin{macro}{\led@err@PstartInEdtext}
% \begin{macro}{\led@err@PendInEdtext}
%    \begin{macrocode}
\newcommand*{\led@err@edtextoutsidepstart}{%
  \reledmac@error{\string\edtext\space outside numbered paragraph (\pstart\space ...\space\pend)}{\@ehc}}%

\newcommand{\led@err@PstartInEdtext}[1]{%
  \reledmac@error{\string\pstart\space in \string\edtext\space #1 argument}{\@ehc}%
}%

\newcommand{\led@err@PendInEdtext}[1]{%
  \reledmac@error{\string\pend\space in \string\edtext\space #1 argument}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@mess@NotesChanged}
%    \begin{macrocode}
\newcommand*{\led@mess@NotesChanged}{%
  \typeout{reledmac reminder: }%
  \typeout{ The number of the footnotes in this section
            has changed since the last run.}%
  \typeout{ You will need to run LaTeX two more times
            before the footnote placement}%
  \typeout{ and line numbering in this section are
            correct.}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@mess@SectionContinued}
%    \begin{macrocode}
\newcommand*{\led@mess@SectionContinued}[1]{%
  \message{Section #1 (continuing the previous section)}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@err@LineationInNumbered}
%    \begin{macrocode}
\newcommand*{\led@err@LineationInNumbered}{%
  \reledmac@error{You can't use \string\lineation\space within
                a numbered section}{\@ehc}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\led@warn@BadLineation}
% \begin{macro}{\led@warn@BadLinenummargin}
% \begin{macro}{\led@warn@BadLockdisp}
% \begin{macro}{\led@warn@BadSublockdisp}
%    \begin{macrocode}
\newcommand*{\led@warn@BadLineation}{%
  \reledmac@warning{Bad \string\lineation\space argument}}
\newcommand*{\led@warn@BadLinenummargin}{%
  \reledmac@warning{Bad \string\linenummargin\space argument}}
\newcommand*{\led@warn@BadLockdisp}{%
  \reledmac@warning{Bad \string\lockdisp\space argument}}
\newcommand*{\led@warn@BadSublockdisp}{%
  \reledmac@warning{Bad \string\sublockdisp\space argument}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\led@warn@NoFile}
%    \begin{macrocode}
\newcommand*{\led@warn@NoFile}[1]{%
  \reledmac@warning{File `#1' not found}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@warn@LineFileObsolete}
%    \begin{macrocode}
\newcommand*{\led@warn@Obsolete}[1]{%
  \reledmac@warning{Line-list file #1 was obsolete. We have not read it. Please run LaTeX again.}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@warn@BadAdvancelineSubline}
% \begin{macro}{\led@warn@BadAdvancelineLine}
%    \begin{macrocode}
\newcommand*{\led@warn@BadAdvancelineSubline}{%
  \reledmac@warning{\string\advanceline\space produced a sub-line
                  number less than zero.}}
\newcommand*{\led@warn@BadAdvancelineLine}{%
  \reledmac@warning{\string\advanceline\space produced a line
                  number less than zero.}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\led@warn@BadSetline}
% \begin{macro}{\led@warn@BadSetlinenum}
%    \begin{macrocode}
\newcommand*{\led@warn@BadSetline}{%
  \reledmac@warning{Bad \string\setline\space argument}}
\newcommand*{\led@warn@BadSetlinenum}{%
  \reledmac@warning{Bad \string\setlinenum\space argument}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\led@err@PstartNotNumbered}
% \begin{macro}{\led@err@PstartInPstart}
% \begin{macro}{\led@err@PendNotNumbered}
% \begin{macro}{\led@err@PendNoPstart}
% \begin{macro}{\led@err@AutoparNotNumbered}
% \begin{macro}{\led@err@NumberingWithoutPstart}
%    \begin{macrocode}
\newcommand*{\led@err@PstartNotNumbered}{%
  \reledmac@error{\string\pstart\space must be used within a
                numbered section %
                 (\string\beginnumbering\space ...\space\string\endnumbering)}{\@ehc}}%
\newcommand*{\led@err@PstartInPstart}{%
  \reledmac@error{\string\pstart\space encountered while another
                \string\pstart\space was in effect}{\@ehc}}
\newcommand*{\led@err@PendNotNumbered}{%
  \reledmac@error{\string\pend\space must be used within a
                numbered section}{\@ehc}}
\newcommand*{\led@err@PendNoPstart}{%
  \reledmac@error{\string\pend\space must follow a \string\pstart}{\@ehc}}
\newcommand*{\led@err@AutoparNotNumbered}{%
  \reledmac@error{\string\autopar\space must be used within a
                numbered section}{\@ehc}}
\newcommand*{\led@err@NumberingWithoutPstart}{%
  \reledmac@error{\string\beginnumbering...\string\endnumbering\space without \string\pstart}{\@ehc}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\led@warn@BadAction}
%    \begin{macrocode}
\newcommand*{\led@warn@BadAction}{%
  \reledmac@warning{Bad action code, value \next@action.}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@warn@DuplicateLabel}
% \begin{macro}{\led@warn@AppLabelOutSecondArgEdtext}
% \begin{macro}{\led@warn@RefUndefined}
% \begin{macro}{\led@warn@RefUndefined}
%    \begin{macrocode}
\newcommand*{\led@warn@DuplicateLabel}[1]{%
  \reledmac@warning{Duplicate definition of label `#1'\@gobble}%
  \@latex@warning@no@line{Label `#1' multiply defined}%
}%
\newcommand*{\led@warn@AppLabelOutSecondArgEdtext}[1]{%
  \reledmac@warning{\string\applabel\space outside of the second argument of an \string\edtext\space `#1' on page \thepage.}}%
\newcommand*{\led@warn@RefUndefined}[1]{%
  \G@refundefinedtrue%
  \reledmac@warning{Reference `#1' on page \thepage\space undefined.%
                  Using `000'.}%
  \@latex@warning{Reference `#1' undefined\on@line}%
}%
\newcommand*{\led@warn@pairRefUndefined}[1]{%
  \G@refundefinedtrue%
  \reledmac@warning{Reference `#1:start' and/or `#1:end' on page \thepage\space undefined.
                  Using `??'.}%
  \@latex@warning{Reference `#1:start' and/or `#1:end' undefined\on@line}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\led@warn@NoMarginpars}
%    \begin{macrocode}
\newcommand*{\led@warn@NoMarginpars}{%
  \reledmac@warning{You can't use \string\marginpar\space in numbered text}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@warn@BadHookSeries}
%    \begin{macrocode}
\newcommand{\led@warn@BadHookSeries}[2]{%
  \reledmac@warning{Bad series #1 for #2 hook. Skipped.}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@warn@BadSidenotemargin}
%    \begin{macrocode}
\newcommand*{\led@warn@BadSidenotemargin}{%
  \reledmac@warning{Bad \string\sidenotemmargin\space argument}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@warn@NoIndexFile}
%    \begin{macrocode}
\newcommand*{\led@warn@NoIndexFile}[1]{%
  \reledmac@warning{Undefined index file #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@warn@SeriesStillExist}
%    \begin{macrocode}
\newcommand{\led@warn@SeriesStillExist}[1]{%
  \reledmac@warning{Series #1 is still existing !}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@err@BadAction}
%    \begin{macrocode}
\newcommand*{\led@err@StanzaIndentNotDefined}{%
  \reledmac@error{You have not defined the indentation for the line \number\stanza@count}{\@ehc}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@err@ManySidenotes}
% \begin{macro}{\led@err@ManyLeftnotes}
% \begin{macro}{\led@err@ManyRightnotes}
%    \begin{macrocode}
\newcommand{\led@err@ManySidenotes}{%
  \ifledRcol@%
     \reledmac@warning{\itemcount@\space sidenotes on line \the\line@numR\space p. \the\page@numR}%
  \else%
     \reledmac@warning{\itemcount@\space sidenotes on line \the\line@num\space p. \the\page@num}%
  \fi%
}%
\newcommand{\led@err@ManyLeftnotes}{%
  \ifledRcol@%
    \reledmac@warning{\itemcount@\space leftnotes on line \the\line@numR\space p. \the\page@numR}%
  \else%
    \reledmac@warning{\itemcount@\space leftnotes on line \the\line@num\space p. \the\page@num}%
  \fi%
}%
\newcommand{\led@err@ManyRightnotes}{%
  \ifledRcol@%
    \reledmac@warning{\itemcount@\space rightnotes on line \the\line@numR\space p. \the\page@numR}%
  \else%
    \reledmac@warning{\itemcount@\space rightnotes on line \the\line@num\space p. \the\page@num}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@err@TooManyColumns}
% \begin{macro}{\led@err@UnequalColumns}
% \begin{macro}{\led@err@LowStartColumn}
% \begin{macro}{\led@err@HighEndColumn}
% \begin{macro}{\led@err@ReverseColumns}
%    \begin{macrocode}
\newcommand*{\led@err@TooManyColumns}{%
  \reledmac@error{Too many columns}{\@ehc}}
\newcommand*{\led@err@UnequalColumns}{%
  \reledmac@error{Number of columns is not equal to the number
                in the previous row (or \protect\\ \space forgotten?)}{\@ehc}}
\newcommand*{\led@err@LowStartColumn}{%
  \reledmac@error{Start column is too low}{\@ehc}}
\newcommand*{\led@err@HighEndColumn}{%
  \reledmac@error{End column is too high}{\@ehc}}
\newcommand*{\led@err@ReverseColumns}{%
  \reledmac@error{Start column is greater than end column}{\@ehc}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\led@err@toendnotes@outsidenumbering}
%    \begin{macrocode}
\newcommand{\led@err@toendnotes@outsidenumbering}{%
  \reledmac@error{\string\toendnotes\space and related commands must be called inside a numbered texte (\string\beginnumbering\space ...\space\string\endnumbering)}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@err@EdtextWithoutFootnote}
%    \begin{macrocode}
\newcommand{\led@err@EdtextWithoutFootnote}{%
  \reledmac@error{edtext without Xfootnote. Check syntaxis}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@err@FootnoteNotInSecondArgEdtext}
%    \begin{macrocode}
\newcommand{\led@err@FootnoteNotInSecondArgEdtext}[1]{%
  \reledmac@error{#1footnote outside of the second argument of an edtext. Check syntax}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@PackageAfterEledmac}
%    \begin{macrocode}
\newcommand{\led@error@PackageAfterEledmac}[1]{%
  \reledmac@error{#1 must be loaded before reledmac}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@fail@patch@@makecol}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@@makecol}{%
  \reledmac@error{Fail to patch \string\@makecol\space command}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@fail@patch@@reinserts}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@@reinserts}{%
  \reledmac@error{Fail to patch \string\@reinserts\space command}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@fail@patch@@doclearpage}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@@doclearpage}{%
  \reledmac@error{Fail to patch \string\@doclearpage\space command}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@error@fail@patch@@iiiminipage}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@@iiiminipage}{%
  \reledmac@error{Fail to patch \string\@iiiminipage\space command}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@fail@patch@endminipage}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@endminipage}{%
  \reledmac@error{Failed to patch the \string\endminipage\space command}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@fail@patch@endminipage}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@makeindex}{%
  \reledmac@error{Failed to patch the \string\makeindex\space command}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@warn@edinde@outsidenumbering}
%    \begin{macrocode}
\newcommand{\led@warn@edinde@outsidenumbering}{%
  \reledmac@warning{\string\edindex\space called outside of \string\beginnumbering\space ...\space \string\endnumbering. \MessageBreak Automatically switched to \string\index.}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@warning@hsizeX@deprecated}
%    \begin{macrocode}
\newcommand{\led@warning@hsizeX@deprecated}{%
  \reledmac@warning{\string\hsizeX\space command deprecated, use \string\widthX\space instead.}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@warning@Xhsize@deprecated}
%    \begin{macrocode}
\newcommand{\led@warning@Xhsize@deprecated}{%
  \reledmac@warning{\string\Xhsize\space command deprecated, use \string\Xwidth\space instead.}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@warning@msdatawithoutstop}
%    \begin{macrocode}
\newcommand{\led@warning@msdatawithoutstop}{%
  \reledmac@warning{\string\msdata\space without corresponding \string\stopmsdata}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@warning@preXnotes@deprecated}
%    \begin{macrocode}
\newcommand{\led@warning@preXnotes@deprecated}{%
  \reledmac@warning@preXnotes@deprecated%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Gobbling}
% \changes{v1.14.0}{2014/10/27}{Provide \protect\cs{@gobblefour}}
% \changes{v1.14.0}{2014/10/27}{Move gobbling command}
% \changes{v1.21.0}{2015/04/13}{Provide \protect\cs{@gobblefive}}
% \changes{v0.2.2}{2003/11/05}{Used \protect\cs{providecommand} for \protect\cs{@gobblethree}
%  to avoid clash with the amsfonts package}
% Here, we define some commands which gobble their arguments.
% \begin{macro}{\@gobblethree}
% \begin{macro}{\@gobblefour}
% \begin{macro}{\@gobbleseven}
%    \begin{macrocode}
\providecommand*{\@gobblethree}[3]{}
\providecommand*{\@gobblefour}[4]{}
\providecommand*{\@gobbleseven}[7]{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Wrapping content}
% \begin{macro}{\l@wrap@ifnotemptybox}
% \begin{macro}{\l@wrapcs@ifnotemptybox}
% The \cs{l@wrap@ifnotemptybox} macro wraps its second argument in the command passed as the first argument, but only if the second argument does not produce an empty box.
% That is useful for example when we need to wrap something on a \cs{textsuperscript}.
%
%
% Indeed \verb+a\textsuperscript{}b+ does not produce the same typographical result as
% \verb+ab+.\footnote{Compare the distance between letters in the first case (a\textsuperscript{}b) and in the second one (ab).}
% The l@wrapcs@ifnotemptybox does the same, but take as argument a control sequence name, so without backslash.
%
%    \begin{macrocode}
\newcommand{\l@wrap@ifnotemptybox}[2]{%
  \setbox0=\hbox{#2}%
  \ifdim\wd0=\z@\else%
    #1{#2}%
  \fi%
}%
\newcommand{\l@wrapcs@ifnotemptybox}[2]{%
  \l@wrap@ifnotemptybox{\csname #1\endcsname}{#2}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Miscellaneous commands}
% \begin{macro}{\showlemma}
% \verb?\showlemma?\marg{lemma} typesets the lemma text in the body.
% It depends on the option.
% \changes{v0.4.0}{2004/02/29}{Added \protect\cs{showlemma}}
%    \begin{macrocode}
\ifledfinal
  \newcommand*{\showlemma}[1]{#1}
\else
  \newcommand*{\showlemma}[1]{\underline{#1}}
\fi

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\linenumberlist}
% The code for the \protect\cs{linenumberlist} mechanism was given to Peter Wilson by Wayne
% Sullivan\index{Sullivan, Wayne} on 2004/02/11.
%
% Initialize it as \protect\cs{empty}.
%
% \changes{v0.3.0}{2004/02/14}{Added \protect\cs{linenumberlist} mechanism}
%    \begin{macrocode}
\let\linenumberlist=\empty

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@l@dtempcnta}
% \begin{macro}{\@l@dtempcntb}
% In imitation of \LaTeX, we create a couple of scratch counters.
%
% \LaTeX\ already defines \protect\cs{@tempcnta} and \protect\cs{@tempcntb} but Peter Wilson
% found in the past that it can be dangerous to use these (for example
% one of the AMS packages did something nasty to the \protect\package{ccaption}
% package's use of one of these).
%    \begin{macrocode}
\newcount\@l@dtempcnta \newcount\@l@dtempcntb
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Prepare \parpackage}
% \begin{macro}{\ifl@dpairing}
% \begin{macro}{\ifl@dpaging}
% \begin{macro}{\ifl@dprintingpages}
% \begin{macro}{\ifl@dprintingcolumns}
% \begin{macro}{\ifpst@rtedL}
% \begin{macro}{\l@dnumpstartsL}

% In preparation for the \parpackage  package, these are related to
% the `right' text of parallel texts (when \protect\cs{ifl@dpairing} is TRUE).
% They are explained in the \protect\parpackage
% manual.
% \changes{v0.7.0}{2005/02/24}{Added \protect\cs{l@dnumpstartsL}, \protect\cs{ifl@dpairing}
%              and \protect\cs{ifpst@rted} for/from eledpar}
% \changes{v0.12.0}{2005/10/01}{Added \protect\cs{ifledRcol} and \protect\cs{ifnumberingR} for/from \protect\package{eledpar}}
% \changes{v1.12.0}{2014/08/05}{Add \protect\cs{ifledRcol@} for \protect\package{eledpar}}
% \changes{v1.13.2}{2014/09/31}{Add \protect\cs{ifl@dpaging} for \protect\package{eledpar}}
% \changes{v1.18.0}{2015/02/23}{Add \protect\cs{ifl@dprintingpages} and \protect\cs{@dprintingcolumns} for \protect\package{eledpar}}
%    \begin{macrocode}
\newif\ifl@dpairing
\newif\ifl@dpaging%
\newif\ifl@dprintingpages%
\newif\ifl@dprintingcolumns%
\newif\ifpst@rtedL
\newcount\l@dnumpstartsL
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\ifledRcol}
% \begin{macro}{\ifledRcol@}
% \protect\cs{ifledRcol} is set to true in the \verb+Rightside+ environnement. It must be not confused with \protect\cs{ifledRcol@} which is set to true when a right line is processed, in \protect\cs{Pages} or \protect\cs{Columns}.
%    \begin{macrocode}
\newif\ifledRcol
\newif\ifledRcol@
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\ifnumberingR}
% The \protect\cs{ifnumberingR} flag is
% set to \verb"true" if we're within a right text numbered section.
%    \begin{macrocode}
\newif\ifnumberingR
%    \end{macrocode}
% \begin{macro}{\ifafterendnumberingR}
% The \cs{ifafterendnumberingR} boolean is set to TRUE at \cs{endnumberingR} and to FALSE at next \cs{beginnumberingR} or real \cs{beginnumbering} (not \cs{resumenumbering}). It is mainly used for the \option{continuousnumberingwithcolumns}, to avoid incrementing right column line counters after a \cs{endnumberingR}.
%    \begin{macrocode}
\newif\ifafterendnumberingR%
%    \end{macrocode}
% \end{macro}
% The \cs{ifXnote@} macro is set to true when we are typesetting a critical footnote.
%    \begin{macrocode}
\newif\ifXnote@%
%    \end{macrocode}
% \end{macro}
% \subsection{Booleans provided by other optional packages which are required in any case}
% \begin{macro}{\ifindtl@innote}
% \begin{macro}{\ifindtl@notenumber}
% The \cs{ifindtl@innote} and \cs{ifindtl@notenumber} are required even if \package{indextools} is not used.
%    \begin{macrocode}
\providebool{indtl@innote}%
\providebool{indtl@notenumber}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{ifinstanzaL}
% \begin{macro}{ifinstanzaR}
% These boolean tests are switched by the \protect\cs{stanza} command, using either the left or right side.
%    \begin{macrocode}
 \newif\ifinstanzaL%
 \newif\ifinstanzaR%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{ifinastanzaL}
% \begin{macro}{ifinastanzaR}
% These boolean tests are switched by the \protect\env{astanza} environnement, using either the left or right side.
%    \begin{macrocode}
 \newif\ifinastanzaL%
 \newif\ifinastanzaR%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%\section{Sectioning commands}
%
% \begin{macro}{\section@num}
% You use \protect\cs{beginnumbering} and \protect\cs{endnumbering} to begin
% and end a line-numbered section of the text; the pair of commands may
% be used as many times as you like within one document to start
% and end multiple, separately line-numbered sections. \LaTeX\ will
% maintain and display
% a `section number' as a count named
% \protect\cs{section@num} that counts how many
% \protect\cs{beginnumbering} and \protect\cs{resumenumbering}
% commands have appeared; it need not be
% related to the logical divisions of your text.
%
% \begin{macro}{\extensionchars}
% Each section will read and write an associated `line-list
% file', containing information used to do the numbering; the file
% will be called \meta{jobname}\file{.nn}, where \file{nn} is the
% section number. However, you may direct that
% an extra string be added before the
% \file{nn} in that filename, in order to distinguish these
% temporary files from others: that string is called
% \protect\cs{extensionchars}. Initially it's empty, since different
% operating systems have greatly varying ideas about what
% characters are permitted in file names.  So
% \verb"\renewcommand{\extensionchars}{-}" gives temporary files called
% \file{jobname.-1}, \file{jobname.-2}, etc.
%    \begin{macrocode}
\newcount\section@num
\section@num=0
\let\extensionchars=\empty
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifnumbering}
% \begin{macro}{\numberingtrue}
% \begin{macro}{\numberingfalse}
% The \protect\cs{ifnumbering} flag is
% set to \verb"true" if we are within a numbered section (that is, between
% \protect\cs{beginnumbering} and \protect\cs{endnumbering}). You can use \protect\cs{ifnumbering}
% in your own code to check whether you are in a numbered section, but
% do not change the flag's value.
%    \begin{macrocode}
\newif\ifnumbering
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\beginnumbering}
% \begin{macro}{\initnumbering@reg}
% \protect\cs{beginnumbering} begins a section of numbered text.
% When it is executed we increment the section number,
% initialize our counters, send a message to your terminal, and
% call macros to start the lineation machinery and endnote files.
%
% The initializations here are trickier than they look.
% \protect\cs{line@list@stuff} will use all of the counters
% that are zeroed here when it assembles
% the line-list and other lists of information about the lineation.
% But it will do all of this locally and
% within a group, and when it is done the
% lists will remain but the counters will return to zero. Those same
% counters will then be used as we process the text of this section,
% but the assignments will be made globally. These initializations
% actually apply to both uses, though in all other respects there
% should be no direct interaction between the use of these counters
% and variables in the two processing steps.
% \changes{v0.7.0}{2005/02/24}{Added \protect\cs{initnumbering@reg}}
% \changes{v1.12.0}{2014/08/05}{\protect\cs{beginnumbering} is defined only on \protect\package{eledmac}, not on \protect\package{eledpar}.}
% For parallel processing :
%\begin{itemize}
%  \item zero \protect\cs{l@dnumpstartsL} --- the number of chunks to be processed.
%  \item set \protect\cs{ifpst@rtedL} to FALSE.
% \end{itemize}
%    \begin{macrocode}
\newcommand*{\beginnumbering}{%
  \ifnumbering
    \led@err@NumberingStarted
    \endnumbering
  \fi
  \global\numberingtrue
  \global\afterendnumberingRfalse%
  \global\advance\section@num \@ne
  \initnumbering@reg
  \message{Section \the\section@num }%
  \line@list@stuff{\jobname.\extensionchars\the\section@num}%
  \ifcontinuousnumberingwithcolumns%
    \unless\ifafterendnumberingR%
      \unless\ifl@dpairing%
        \ledRcoltrue%
        \global\advance\section@numR \@ne%
        \message{Section \the\section@numR R (continuoousnumbering)}%
        \line@list@stuffR{\jobname.\extensionchars\the\section@numR R}%
        \ledRcolfalse%
      \fi%
    \fi%
  \fi%
  \l@dend@stuff
  \setcounter{pstart}{1}
  \ifl@dpairing
    \global\l@dnumpstartsL \z@
    \global\pst@rtedLfalse
%    \end{macrocode}
% The tools for section's title commands are called:
% \begin{itemize}
%   \item Define an empty list of pstart number where sectioning commands are called.
%   \item Input auxiliary file with the description of section titles.
%   \item Open the same auxiliary file to write in.
% \end{itemize}
%    \begin{macrocode}
  \else
    \begingroup
    \global\@afterindenttrue%In order to retablish normal feature if the \begingroup was not here
    \initnumbering@quote
    \ifwidthliketwocolumns%
       \setwidthliketwocolumns%
       \csuse{setpositionliketwocolumns@\columns@position}%
    \fi%
  \fi
  \gdef\eled@sections@@{}%
  \if@noeled@sec\else%
    \makeatletter%
    \InputIfFileExists%
      {\l@auxdir\jobname.eledsec\the\section@num}%
      {}%
      {\led@warn@NoFile{\l@auxdir\jobname.eledsec\the\section@num}}%
    \makeatother%
    \immediate\openout\eled@sectioning@out=\l@auxdir\jobname.eledsec\the\section@num\relax%
  \fi%
}
\newcommand*{\initnumbering@reg}{%
  \global\pst@rtedLfalse
  \global\l@dnumpstartsL \z@
  \global\absline@num \z@
  \gdef\normal@page@break{}
  \gdef\l@prev@pb{}
  \gdef\l@prev@nopb{}
  \global\line@num \z@
  \global\subline@num \z@
  \global\@lock \z@
  \global\sub@lock \z@
  \global\sublines@false
  \global\let\next@page@num=\relax
  \global\let\this@section@next@page@num=\relax%
  \global\let\sub@change=\relax
  \global\last@page@num=-10000%
  \ifdefined\line@numR%
    \line@numR=\z@%
    \last@page@numR=\z@%
  \fi%
  \resetprevline@
  \resetprevpage@num
  \global\stopmsdata@inserted@true%
  \global\let\@msdata@list\relax%
  \global\csundef{@msdata@\add@msd@c @data}%
  }

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\endnumbering}
% \protect\cs{endnumbering} must follow the last text for a numbered section.
% It takes care of notifying you when changes have been noted in the
% input that require running the file through again to move everything
% to the right place.
% \changes{v0.7.0}{2005/02/24}{Changed \protect\cs{endnumbering} for eledpar}
% \changes{v1.12.5}{2014/08/31}{Allow to mix parallel columns and normal text when using \protect\cs{pausenumbering}}
% We define it using \cs{def} and not \cs{newcommand} because \LaTeX\ does not allow defining command whose name starts by \enquote{end} except if we are currently creating an environment, which is not the case here.
%    \begin{macrocode}
\def\endnumbering{%
  \ifnumbering
    \global\numberingfalse
    \normal@pars
    \ifnum\l@dnumpstartsL=0%
      \led@err@NumberingWithoutPstart%
    \fi%
%    \end{macrocode}
% For the continuousnumberingwithcolumn options, we need to store a global value for the next \cs{endnumbering}.
% We don't modify this counter globally, because that creates problem for nested \cs{edtext}.
%    \begin{macrocode}
    \global\page@num=\this@section@page@num%
    \global\last@page@num=\this@section@last@page@num%
    \global\let\next@page@num\this@section@next@page@num%
    \ifl@dpairing
      \global\pst@rtedLfalse
    \else
      \ifx\insertlines@list\empty\else
        \global\noteschanged@true
      \fi
      \ifx\line@list\empty\else
        \global\noteschanged@true
      \fi
    \fi
    \ifnoteschanged@
      \led@mess@NotesChanged
    \fi
  \else
    \led@err@NumberingNotStarted
  \fi
  \autoparfalse
  \if@noeled@sec\else%
    \immediate\closeout\eled@sectioning@out%
  \fi%
  \ifl@dpairing\else
    \global\l@dnumpstartsL=\z@%
    \endgroup
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pausenumbering}
% \begin{macro}{\resumenumbering}
% \begin{macro}{\ifresumenumbering@start}
% \begin{macro}{\pausenumbering@page@num}
% The \protect\cs{pausenumbering} macro is just the same as
% \protect\cs{endnumbering}, but with the \protect\cs{ifnumbering} flag set to \verb"true", to
% show that numbering continues across the gap.\footnote{Peter Wilson's thanks
% to Wayne Sullivan,\index{Sullivan, Wayne} who suggested the idea
% behind these macros.}
% The \cs{pausenumbering@page@num} counter stores the \cs{this@section@next@page@num} when the \cs{pause@numbering} is called.
%    \begin{macrocode}
\newcount\pausenumbering@page@num%
\newcommand{\pausenumbering}{%
  \ifx\this@section@next@page@num\relax%
    \global\pausenumbering@page@num=0%
  \else%
    \global\pausenumbering@page@num=\this@section@next@page@num%
  \fi%
  \ifautopar\global\autopar@pausetrue\fi%
  \endnumbering\global\numberingtrue}
%    \end{macrocode}
% The \protect\cs{resumenumbering} macro is a bit more involved, but not much.
% It does most of the same things as \protect\cs{beginnumbering}, but
% without resetting the various counters. Note that no check is made
% by \protect\cs{resumenumbering} to ensure that \protect\cs{pausenumbering} was actually
% invoked.
% The boolean \cs{ifresumenumbering@start} is set to true. That allows us to avoid resetting the line number at the first line of \cs{resumenumbering} if the lineation is by page.
% This boolean is set to false after the first action.
% \changes{v0.7.0}{2005/02/24}{Changed \protect\cs{resumenumbering} for eledpar}
% \changes{v1.12.5}{2014/08/31}{Debug \protect\cs{resumenumbering}}
%    \begin{macrocode}
\newif\ifresumenumbering@start%
\newcommand*{\resumenumbering}{%
  \ifnumbering
     \ifautopar@pause\autopar\fi
     \global\pst@rtedLtrue
     \global\advance\section@num \@ne
     \global\resumenumbering@starttrue%
     \led@mess@SectionContinued{\the\section@num}%
     \set@continuousnumberingforL%
     \line@list@stuff{\jobname.\extensionchars\the\section@num}%
     \ifcontinuousnumberingwithcolumns%
       \unless\ifafterendnumberingR%
          \unless\ifl@dpairing%
            \ledRcoltrue%
            \global\advance\section@numR \@ne%
            \message{Section \the\section@numR R (continuoousnumbering)}%
            \line@list@stuffR{\jobname.\extensionchars\the\section@numR R}%
            \ledRcolfalse%
          \fi%
        \fi%
     \fi%
     \l@dend@stuff
     \ifl@dpairing\else%
        \begingroup%
        \initnumbering@quote%
        \ifwidthliketwocolumns%
          \setwidthliketwocolumns%
          \csuse{setpositionliketwocolumns@\columns@position}%
        \fi%
     \fi%
  \else
    \led@err@NumberingShouldHaveStarted
    \endnumbering
    \beginnumbering
  \fi}


%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\set@continuousnumberingforL}
% \cs{set@continuousnumberingforl} sets pstart counters at a \cs{beginnumbering} or a \cs{resumenumbering} in order to have continuous numbering with single column text.
%    \begin{macrocode}
\newcommand{\set@continuousnumberingforL}{%
 \ifcontinuousnumberingwithcolumns%
   \ifl@dpairing%
     \unless\ifl@dpaging%
       \global\c@pstartL=\c@pstart%
     \fi%
   \fi%
 \fi%
}%
%    \end{macrocode}
% \end{macro}
%
% \section{List macros}
%
%
% We will make heavy use of lists of information, which will be built
% up and taken apart by the following macros; they are
% adapted from \thetexbook, pp.\,378--379, which discusses
% their use in more detail.
%
% These macros consume a large amount of the run-time of this code.
% We intend to replace them in a future version, and in anticipation
% of doing so have defined their interface in such a way that it is
% not sensitive to details of the underlying code.
%
% The historical list tools of \ledmac are keept, because in many cause there are more useful than \protect\package{etoolbox}'s lists.
% They allows to get and delete the first element of a list in one operation. They also expands the items add to the list.
%
% However, \protect\package{etoolbox}'s lists are more useful to loop on them.
% Consequently, depending of what we need, we use one or either.
%
% It could be nice to unify them to the \LaTeX3 list, however such migration would take quite time with some risk of error, for a gain which will be minor.
%
% \begin{macro}{\list@create}
% The \protect\cs{list@create} macro creates a new list.
% This macro does not do anything beyond initializing an empty
% list macro.
%
%    \begin{macrocode}
\newcommand*{\list@create}[1]{%
  \global\let#1=\empty%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\list@clear}
% The \protect\cs{list@clear} macro just initializes a list to the empty list;
% it is no different from
% \protect\cs{list@create} in its effect, but it is in its semantic .
%    \begin{macrocode}
\newcommand*{\list@clear}[1]{%
  \global\let#1=\empty%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xright@appenditem}
% \begin{macro}{\led@toksa}
% \begin{macro}{\led@toksb}
% \protect\cs{xright@appenditem} expands an item and appends it to the right
% end of a list macro. We want the expansion because we will often
% be using this to store the current value of a counter.
% \protect\cs{xright@appenditem} creates global control sequences, like \protect\cs{xdef}, and uses two
% temporary token-list registers, \protect\cs{@toksa} and \protect\cs{@toksb}.
%    \begin{macrocode}
\newtoks\led@toksa \newtoks\led@toksb
\global\led@toksa={\\}
\long\def\xright@appenditem#1\to#2{%
  \global\led@toksb=\expandafter{#2}%
  \xdef#2{\the\led@toksb\the\led@toksa\expandafter{#1}}%
  \global\led@toksb={}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\xleft@appenditem}
% \protect\cs{xleft@appenditem} expands an item and appends it to the left
% end of a list macro; it is otherwise identical to
% \protect\cs{xright@appenditem}.
%    \begin{macrocode}
\long\def\xleft@appenditem#1\to#2{%
  \global\led@toksb=\expandafter{#2}%
  \xdef#2{\the\led@toksa\expandafter{#1}\the\led@toksb}%
  \global\led@toksb={}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\gl@p}
% The \protect\cs{gl@p} macro removes the leftmost
% item from a list and places it in a
% control sequence. You type \verb"\gl@p\l\to\z"
% (where \verb"\l" is the list macro, and
% \verb"\z" receives the left item). \verb"\l" is assumed nonempty:use
% \verb"\ifx\l\empty" to test for an empty \verb"\l". The control
% sequences created by \protect\cs{gl@p} are all global.
%    \begin{macrocode}
\def\gl@p#1\to#2{\expandafter\gl@poff#1\gl@poff#1#2}
\long\def\gl@poff\\#1#2\gl@poff#3#4{\gdef#4{#1}\gdef#3{#2}}

%    \end{macrocode}
% \end{macro}
%
% \section{Line counting}
% \label{lineation}\relax
%
% \subsection{Choosing the system of lineation}
% \changes{v0.15.0}{2012/06/11}{Line numbering can be reset at each pstart.}
% Line number can be reset at each section (default) ; at each page ; at each pstart.
% Here we define
% internal codes for these systems and the macros.
%
%
% \begin{macro}{\ifbypstart@}
% \begin{macro}{\bypstart@true}
% \begin{macro}{\bypstart@false}
% \begin{macro}{\ifbypage@}
% \begin{macro}{\bypage@true}
% \begin{macro}{\bypage@false}
% The \protect\cs{ifbypage@} and \protect\cs{ifbypstart@} flag specifie the current lineation
% system: \begin{itemize}
% \item line-of-page: \verb|bypstart@ = false| and \verb|bypage@ = true|.
% \item line-of-pstart: \verb|bypstart@ = true| and \verb|bypage@ = false|.
% \end{itemize}
% \Macpackage\ will use the line-of-section system unless instructed otherwise.
%    \begin{macrocode}
\newif\ifbypage@
\newif\ifbypstart@
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% The \protect\cs{ifbypage@R} and \protect\cs{ifbypstart@R} flag specifie the current lineation for right side in case of using \parpackage. They are now defined  because they are used in some specific code.
% \Parpackage will use the line-of-section system unless instructed otherwise.
% \begin{macro}{\ifbypage@R}
% \begin{macro}{\ifbypstart@R}
%    \begin{macrocode}
\newif\ifbypage@R
\newif\ifbypstart@R
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\lineation}
% \protect\cs{lineation}\marg{word} is the macro you use to select the
% lineation system.
% Its argument is a string: either \verb+page+, \verb+section+ or \verb+pstart+.
%    \begin{macrocode}
\newcommand*{\lineation}[1]{{
%    \end{macrocode}
% We can't change the lineation system inside numbering section.
%    \begin{macrocode}
  \ifnumbering
    \led@err@LineationInNumbered
  \else
%   \end{macrocode}
% If the argument is \verb+page+.
%   \begin{macrocode}
    \def\@tempa{#1}\def\@tempb{page}%
    \ifx\@tempa\@tempb
        \global\bypage@true
        \global\bypstart@false
        \unless\ifnocritical@%
          \Xpstart[][false]%
        \fi%
%   \end{macrocode}
% If the argument is \verb+pstart+.
%   \begin{macrocode}
    \else
       \def\@tempb{pstart}%
       \ifx\@tempa\@tempb
           \global\bypage@false
           \global\bypstart@true
           \unless\ifnocritical@%
             \Xpstart%
           \fi%
%   \end{macrocode}
% And finally, if the argument is \verb+section+ (default).
%   \begin{macrocode}
       \else
          \def\@tempb{section}
          \ifx\@tempa\@tempb
            \global\bypage@false
            \global\bypstart@false
            \unless\ifnocritical@%
              \Xpstart[][false]%
            \fi%
%    \end{macrocode}
% In other case, it is an error.
%    \begin{macrocode}
          \else
            \led@warn@BadLineation
          \fi
       \fi
    \fi
  \fi}}
%    \end{macrocode}
% \end{macro}
% \subsection{Line number margin}
% \begin{macro}{\linenummargin}
% \begin{macro}{\line@margin}
% \begin{macro}{\l@dgetline@margin}
% \protect\cs{linenummargin}\marg{word} specify which margin
% line numbers are in; it takes one argument, a string, which value can be
% \verb+left+ ;  \verb+right+;  \verb+inner+ or
% \verb+outer+.
%
% The selection is recorded in the count \protect\cs{line@margin}:
% $0$ for left, $1$ for right, $2$ for outer, and $3$ for inner.
% \changes{v0.7.0}{2005/02/23}{Added \protect\cs{l@dgetline@margin}}
%    \begin{macrocode}
\newcount\line@margin%
\newcount\line@margin@columns%Only for parallel typesetting
\line@margin@columns=\m@ne%

\newcommand*{\linenummargin}[1]{{%
  \l@dgetline@margin{#1}%
  \ifnum\@l@dtempcntb>\m@ne
    \ifledRcol
      \global\line@marginR=\@l@dtempcntb
      \led@warn@setting@in@rightside{\linenummargin}%
    \else
      \global\line@margin=\@l@dtempcntb
    \fi
  \fi}}

\newcommand*{\l@dgetline@margin}[1]{%
  \def\@tempa{#1}\def\@tempb{left}%
  \ifx\@tempa\@tempb
    \@l@dtempcntb \z@
  \else
     \def\@tempb{right}%
     \ifx\@tempa\@tempb
       \@l@dtempcntb \@ne
     \else
       \def\@tempb{outer}%
       \ifx\@tempa\@tempb
         \@l@dtempcntb \tw@
       \else
         \def\@tempb{inner}%
         \ifx\@tempa\@tempb
           \@l@dtempcntb \thr@@
         \else
           \led@warn@BadLinenummargin
           \@l@dtempcntb \m@ne
         \fi
       \fi
     \fi
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Line number initialization and increment}
% \begin{macro}{\c@firstlinenum}
% \begin{macro}{\c@linenumincrement}
% The following counters tell \macpackage\ which lines should be
% printed with line numbers. \verb+firstlinenum+ is the number of the
% first line in each section that gets a number;
% \verb+linenumincrement+
% is the difference between successive numbered lines. The initial
% values of these counters produce labels on lines $5$, $10$, $15$, etc.
% \verb+linenumincrement+ must be at least $1$.
%
%    \begin{macrocode}
\newcounter{firstlinenum}
  \setcounter{firstlinenum}{5}
\newcounter{linenumincrement}
  \setcounter{linenumincrement}{5}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@firstsublinenum}
% \begin{macro}{\c@sublinenumincrement}
% The following parameters are just like \verb+firstlinenum+ and
% \verb+linenumincrement+, but for sub-line numbers.
% \verb+sublinenumincrement+ must be at least $1$.
%
%    \begin{macrocode}
\newcounter{firstsublinenum}
  \setcounter{firstsublinenum}{5}
\newcounter{sublinenumincrement}
  \setcounter{sublinenumincrement}{5}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\firstlinenum}
% \begin{macro}{\linenumincrement}
% \begin{macro}{\firstsublinenum}
% \begin{macro}{\sublinenumincrement}
% These macros can be used to set the corresponding counters.
% \changes{v0.7.0}{2005/02/18}{Added \protect\cs{firstlinenum}, \protect\cs{linenumincrement},
%              \protect\cs{firstsublinenum} and \protect\cs{linenumincrement}}
%    \begin{macrocode}

\newcommand*{\firstlinenum}[1]{%
  \ifledRcol%
    \setcounter{firstlinenumR}{#1}%
    \led@warn@setting@in@rightside{\firstlinenum}%
  \else%
    \setcounter{firstlinenum}{#1}%
  \fi%
}
\newcommand*{\linenumincrement}[1]{%
  \ifledRcol%
    \setcounter{linenumincrementR}{#1}%
    \led@warn@setting@in@rightside{\linenumincrement}%
  \else%
    \setcounter{linenumincrement}{#1}%
  \fi%
}
\newcommand*{\firstsublinenum}[1]{%
  \ifledRcol%
    \setcounter{firstsublinenumR}{#1}%
    \led@warn@setting@in@rightside{\firstsublinenum}%
  \else%
    \setcounter{firstsublinenum}{#1}%
  \fi%
}
\newcommand*{\sublinenumincrement}[1]{%
  \ifledRcol%
    \setcounter{sublinenumincrementR}{#1}%
    \led@warn@setting@in@rightside{\sublinenumincrement}%
  \else%
    \setcounter{sublinenumincrement}{#1}%
  \fi%
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Line number locking}
% \begin{macro}{\lockdisp}
% \begin{macro}{\lock@disp}
% \begin{macro}{\l@dgetlock@disp}
% When line locking is being used, the \protect\cs{lockdisp}\marg{word} macro
% specifies whether a line number---if one is due to
% appear---should be printed on the first printed line or on the
% last, or by all of them.
% Its argument is a word, either
% \verb+first+, \verb+last+, or \verb+all+.
% Initially, it is set to \verb+first+.
%
% \protect\cs{lock@disp} encodes the selection: $0$ for first, $1$ for last,
% $2$ for all.
% \changes{v0.7.0}{2005/02/23}{Added \protect\cs{l@dgetlock@disp}}
%    \begin{macrocode}
\newcount\lock@disp
\newcommand{\lockdisp}[1]{{%
  \l@dgetlock@disp{#1}%
  \ifnum\@l@dtempcntb>\m@ne
    \global\lock@disp=\@l@dtempcntb
  \else
    \led@warn@BadLockdisp
  \fi}}
\newcommand*{\l@dgetlock@disp}[1]{
  \def\@tempa{#1}\def\@tempb{first}%
  \ifx\@tempa\@tempb
    \@l@dtempcntb \z@
  \else
     \def\@tempb{last}%
     \ifx\@tempa\@tempb
       \@l@dtempcntb \@ne
     \else
       \def\@tempb{all}%
       \ifx\@tempa\@tempb
         \@l@dtempcntb \tw@
       \else
         \@l@dtempcntb \m@ne
       \fi
     \fi
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sublockdisp}
% \begin{macro}{\sublock@disp}
% The same questions about where to print the line number apply to
% sub-lines, and these are the analogous macros for dealing with
% the problem.
%    \begin{macrocode}
\newcount\sublock@disp
\newcommand{\sublockdisp}[1]{{%
  \l@dgetlock@disp{#1}%
  \ifnum\@l@dtempcntb>\m@ne
    \global\sublock@disp=\@l@dtempcntb
  \else
    \led@warn@BadSublockdisp
  \fi}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Line number style}
% \begin{macro}{\linenumberstyle}
% \begin{macro}{\linenumrep}
% \begin{macro}{\linenumr@p}
% \begin{macro}{\sublinenumberstyle}
% \begin{macro}{\sublinenumrep}
% \begin{macro}{\sublinenumr@p}
% We provide a mechanism for using different representations of the
% line numbers, not just the normal arabic.
%
% NOTE: In v0.7 \protect\cs{linenumrep} and \protect\cs{sublinenumrep} replaced
% the internal \protect\cs{linenumr@p} and \protect\cs{sublinenumr@p}.
%
% \protect\cs{linenumberstyle} and \protect\cs{sublinenumberstyle} are user level
% macros for setting the number representation (\protect\cs{linenumrep}
% and \protect\cs{sublinenumrep}) for line and sub-line numbers.
% \changes{v0.3.0}{2004/02/14}{Added \protect\cs{linenumberstyle} and \protect\cs{sublinenumberstyle}}
% \changes{v0.7.0}{2005/02/18}{Using \protect\cs{linenumrep} instead of \protect\cs{linenumr@p}}
% \changes{v0.7.0}{2005/02/18}{Using \protect\cs{sublinenumrep} instead of \protect\cs{sublinenumr@p}}
%    \begin{macrocode}
\newcommand*{\linenumberstyle}[1]{%
  \def\linenumrep##1{\@nameuse{@#1}{##1}}}
\newcommand*{\sublinenumberstyle}[1]{%
  \def\sublinenumrep##1{\@nameuse{@#1}{##1}}}
%    \end{macrocode}
% Initialise the number styles to arabic.
%    \begin{macrocode}
\linenumberstyle{arabic}
  \let\linenumr@p\linenumrep
\sublinenumberstyle{arabic}
  \let\sublinenumr@p\sublinenumrep

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Line number printing}
% \begin{macro}{\leftlinenum}
% \begin{macro}{\rightlinenum}
% \begin{macro}{\linenumsep}
% \begin{macro}{\numlabfont}
% \begin{macro}{\ledlinenum}
% \protect\cs{leftlinenum} and \protect\cs{rightlinenum} are the macros that are
% called to print marginal line numbers on
% a page, for left- and right-hand margins respectively.
% They are made easy to access and change, since you may
% want to change the styling in some way.
% These standard versions
% illustrate the general sort of thing that will be needed; they are
% based on the \protect\cs{leftheadline} macro in \thetexbook, p.\,416.
%
% Whatever these macros output gets printed in a box that will be
% put into the appropriate margin without any space between it and the
% line of text.
% You will generally want a kern between a line number and
% the text, and \protect\cs{linenumsep} is provided as a standard way of
% storing its size. Line numbers are usually printed in a smaller
% font, and \protect\cs{numlabfont} is provided as a standard name for that
% font. When called, these macros
% will be executed within a group, so font changes and the like will
% remain local.
%
% \protect\cs{ledlinenum} typesets the line (and subline) number.
%
%   The original \protect\cs{numlabfont} specification is equivalent to
% the \LaTeX\ \protect\cs{scriptsize} for a 10pt document.
% \changes{v0.3.0}{2004/02/14}{Added \protect\cs{linenumr@p} and \protect\cs{sublinenum@rep}
%           to \protect\cs{leftlinenum} and \protect\cs{rightlinenum}}
% \changes{v0.7.0}{2005/02/18}{Added \protect\cs{ledlinenum} for use by
%              \protect\cs{leftlinenum} and \protect\cs{rightlinenum}}
%    \begin{macrocode}
\newlength{\linenumsep}
  \setlength{\linenumsep}{1pc}
\newcommand*{\numlabfont}{\normalfont\scriptsize}
\newcommand*{\ledlinenum}{%
  \bgroup%
  \ifluatex%
    \textdir TLT%
  \fi%
  \numlabfont%
  \ifdefstring{\Xlinenumannotationposition@side}{before}{%
    \l@wrap@ifnotemptybox{\Xwraplinenumannotation@side}{%
      \csuse{annot@\the\absline@num @\the\section@num}%
      }%
  }{}%
  \linenumrep{\line@num}%
  \ifsublines@
    \ifnum\subline@num>0\relax
      \unskip%
      \Xsublinesep@side%
      \sublinenumrep{\subline@num}%
    \fi
  \fi%
  \ifdefstring{\Xlinenumannotationposition@side}{after}{%
    \l@wrap@ifnotemptybox{\Xwraplinenumannotation@side}{%
      \csuse{annot@\the\absline@num @\the\section@num}%
      }%
  }{}%
  \egroup%
}%

\newcommand*{\leftlinenum}{%
  \ledlinenum
  \kern\linenumsep}
\newcommand*{\rightlinenum}{%
  \kern\linenumsep
  \ledlinenum}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Line number counters and lists}
%
% Footnote references using line numbers rather than symbols can't be
% generated in one pass, because we do not know the line numbers till we
% ship out the pages. It would be possible if footnotes were never keyed
% to more than one line; but some footnotes gloss passages that may run
% for several lines, and they must be tied to the first line of the
% passage glossed. And even one-line passages require two passes if we
% want line-per-page numbering rather than line-per-section numbering.
%
% So we run \LaTeX\ over the text several times, and each time save
% information about page and line numbers in a `line-list file' to
% be used during the next pass. At the start of each section---whenever
% \protect\cs{beginnumbering} is executed---the line-list file
% for that section
% is read, and the information from it is encoded into a few list
% macros.
%
% We need first to define the different line numbers that are involved
% in these macros, and the associated counters.
%
% \begin{macro}{\line@num}
% The count \protect\cs{line@num} stores the line number that is used in
% marginal line numbering and in notes: counting either by section, page or pstart, depending on your
% choice for this section. This may be qualified by \protect\cs{subline@num}.
%    \begin{macrocode}
\newcount\line@num
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subline@num}
% The count \protect\cs{subline@num} stores
% a sub-line number that qualifies \protect\cs{line@num}. For example,
% line $10$ might have sub-line numbers $1$, $2$ and $3$, which might be
% printed as lines $10.1$, $10.2$, $10.3$.
%    \begin{macrocode}
\newcount\subline@num
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifsublines@}
% \begin{macro}{\sublines@true}
% \begin{macro}{\sublines@false}
% We maintain an associated flag, \protect\cs{ifsublines@},
% to tell us whether we're within
% a sub-line range or not.
%
% You may wonder why we do not just use the value of \protect\cs{subline@num}
% to determine this---treating anything greater than $0$ as an
% indication that sub-lineation is on. We need a separate flag because
% sub-lineation can be used together with line-number locking in odd
% ways: several pieces of a logical line might be interrupted by
% pieces of sub-lineated text, and those sub-line numbers should not
% return to zero until the next change in the major line number. This
% is common in the typesetting of English Renaissance verse
% drama\index{Middleton, Thomas}, in which stage directions are
% given sub-line numbers: a single line of verse may be
% interrupted by several stage directions.
%    \begin{macrocode}
\newif\ifsublines@
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\absline@num}
% The count \protect\cs{absline@num} stores the
% absolute number of lines since the start
% of the section: that is, the number we have actually printed, no matter
% what numbers we attached to them.
% This value is never printed on an output page, though
% \protect\cs{line@num} will often be equal to it. It is used internally to
% keep track of where notes are to appear and where new
% pages start: using this value rather than \protect\cs{line@num} is a lot
% simpler, because it does not depend on the lineation system in use.
%    \begin{macrocode}
\newcount\absline@num
%    \end{macrocode}
% \end{macro}
%
% We will call \protect\cs{absline@num} numbers ``absolute'' numbers, and
% \protect\cs{line@num} and \protect\cs{subline@num} numbers ``visible'' numbers.
%
% \subsection{Line number locking counter}
% \begin{macro}{\@lock}
% \begin{macro}{\sub@lock}
% The counts \protect\cs{@lock} and \protect\cs{sub@lock}
% tell us the state of line-number
% and sub-line-number locking. $0$ means we are not within a locked set of
% lines; $1$ means we are at the first line in the set; $2$, at some
% intermediate line; and $3$, at the last line.
%    \begin{macrocode}
\newcount\@lock
\newcount\sub@lock
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Line number associated to lemma}
% \begin{macro}{\line@list}
% \begin{macro}{\insertlines@list}
% \begin{macro}{\actionlines@list}
% \begin{macro}{\actions@list}
% \begin{macro}{\annot@list}
% Now we can define the list of macros which will be created from the
% line-list file.  We will maintain the following lists:
% \begin{itemize}\addtolength{\itemsep}{-1ex}
% \item \protect\cs{line@list}: the page and line numbers for every
% lemma marked by \protect\cs{edtext}.
% There are seven pieces of information, separated by vertical bars:
% \label{linenumbers}
% \begin{enumerate}\addtolength{\itemsep}{-1ex}
% \item the starting page,
% \item line, and
% \item sub-line numbers, followed by the
% \item ending page,
% \item line, and
% \item sub-line numbers, and then the
% \item font specifier for the lemma.
% \end{enumerate}
%
%
% These line numbers are all visible numbers.
% The font specifier is a set of four codes for font encoding,
% family, series, and shape, separated by \verb"/" characters.
% Thus a lemma that
% started on page $23$, line $35$ and
% went on until page $24$, line $3$
% (with no sub-line numbering), and was typeset in a normal roman font
% would have a line list entry like this: \\
% \verb"23|35|0|24|3|0|OT1/cmr/m/n".
%
% There is one item in this list for every lemma marked by
% \protect\cs{edtext}, even if there are several notes to that lemma, or no
% notes at all. \protect\cs{edtext} reads the data in this list, making it
% available for use in the text of notes.
%
% \item \protect\cs{insertlines@list}: the line numbers of lines that have
% footnotes or other insertions.
% These are the absolute numbers where the corresponding
% lemmas begin. This list contains one entry for every footnote in the
% section; one lemma may contribute no footnotes or many footnotes.
% This list is used by \protect\cs{add@inserts} within \protect\cs{do@line}, to tell
% it where to insert notes.
%
% \item \protect\cs{actionlines@list}: a list of absolute line numbers at
% which we are to perform special
% actions; these actions are specified by the \protect\cs{actions@list} list
% defined below.
%
% \item \protect\cs{actions@list}: action codes corresponding to the line
% numbers in \protect\cs{actionlines@list}. These codes tell \macpackage\ what action
% it is supposed to take at each of these lines. One action, the
% page-start action, is generated behind the scenes by \macpackage{} itself;
% the others, for specifying sub-lineation, line-number locking, and
% line-number alteration, are generated only by explicit commands in
% your input file. The page-start and line-number-alteration actions
% require arguments, to specify the new values for the page or line
% numbers; instead of storing those arguments in another list, we have
% chosen the action-code values so that they can encode both the action
% and the argument in these cases. Action codes greater than $-1000$
% are page-start actions, and the code value is the page number; action
% codes less than $-5000$ specify line numbers, and the code value is
% a transformed version of the line number; action codes between these
% two values specify other actions which require no argument.
%
% Here is the full list of action codes and their meanings:
%
% Any number greater than $-1000$ is a page-start action: the line number
% associated with it is the first line on a page, and the action number is
% the page number. (The cutoff of $-1000$ is chosen because negative
% page-number values are used by some macro packages; we assume that
% page-number values less than $-1000$ are not common.)
% Page-start action codes are added to the list by
% the \protect\cs{page@action} macro, which is (indirectly) triggered by the
% workings of the \protect\cs{page@start} macro; that macro should always be
% called in the output routine, just before the page contents are
% assembled. \Eledmac{} calls it in \protect\cs{pagecontents}.
%
% The action code $-1001$ specifies the start of sub-lineation: meaning
% that, starting with the next line, we should be advancing
% \protect\cs{subline@num} at each start-of-line command, rather than
% \protect\cs{line@num}.
%
% The action code $-1002$ specifies the end of sub-lineation. At the
% next start-of-line, we should clear the sub-line counter and start
% advancing the line number. The action codes for starting and ending
% sub-lineation are added to the list by the \protect\cs{sub@action} macro, as
% called to implement the \protect\cs{startsub} and \protect\cs{endsub} macros.
%
% The action code $-1003$ specifies the start of line number locking.
% After the number for the current line is computed, it will remain
% at that value through the next line that has an action code to end
% locking.
%
% The action code $-1004$ specifies the end of line number locking.
%
% The action code $-1005$ specifies the start of sub-line number locking.
% After the number for the current sub-line is computed, it will remain
% at that value through the next sub-line that has an action code to end
% locking.
%
% The action code $-1006$ specifies the end of sub-line number locking.
%
% The four action codes for line and sub-line number locking are added
% to the list by the \protect\cs{do@lockon} and \protect\cs{do@lockoff} macros, as called
% to implement the \protect\cs{startlock} and \protect\cs{endlock} macros.
%
% An action code of $-5000$ or less sets the current visible line
% number (either the line number or the sub-line number, whichever is
% currently being advanced) to a specific positive value. The value of
% the code is $-(5000+n)$, where $n$ is the value (always $\ge 0$)
% assigned to the current line number. Action codes of this type are
% added to the list by the \protect\cs{set@line@action} macro, as called to
% implement the \protect\cs{advanceline} and \protect\cs{setline} macros: this action only
% occurs when the user has specified some change to the line numbers
% using those macros. Normally \macpackage{} computes the visible line numbers
% from the absolute line numbers with reference to the other
% action codes and the settings they invoke; it does not require an
% entry in the action-code list for every line.
% \item \cs{annot@list} stores line number annotations for the start and the end lines of each  \cs{edtext}, as \cs{line@list} does for line numbers.
% We don't store that in the same list as line numbers as \cs{Xprintlines} already have height arguments, and a \TeX\ macro can take at most nine arguments.
% \end{itemize}
% Here are the commands to create these lists:
%
%    \begin{macrocode}
\list@create{\line@list}
\list@create{\insertlines@list}
\list@create{\actionlines@list}
\list@create{\actions@list}
\list@create{\annot@list}%
%    \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\page@num}
% \begin{macro}{\endpage@num}
% \begin{macro}{\endline@num}
% \begin{macro}{\endsubline@num}
% We will need some counts while we read the line-list,
% for the page number and the ending page, line, and sub-line numbers.
% Some of these will be used again later on, when we are acting on the
% data in our list macros.
%    \begin{macrocode}
\newcount\page@num
\newcount\endpage@num
\newcount\endline@num
\newcount\endsubline@num
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\this@section@page@num}
% The \cs{this@section@page@num} stores the page number on which a numbering section ends.
%    \begin{macrocode}
\newcount\this@section@page@num%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ifnoteschanged@}
% \begin{macro}{\noteschanged@true}
% \begin{macro}{\noteschanged@false}
% If the number of the footnotes in a section is different from what it was
% during the last run, or if this is the very first time you've run
% \LaTeX,
% on this file, the information from the line-list used to place the
% notes will be wrong, and some notes will probably be misplaced.
% When this happens, we prefer
% to give a single error message for the whole section rather than
% messages at every point where we notice the problem, because
% we do not really know where in the section notes were added or removed,
% and the solution in any case is simply to run \LaTeX\ two more times;
% there is no fix needed to the document. The
% \protect\cs{ifnoteschanged@} flag is set if such
% a change in the number of notes is discovered at any point.
%    \begin{macrocode}
\newif\ifnoteschanged@
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \DescribeMacro{\resetprevline@}
% Inside the apparatus, at each note, the line number is stored in a macro called \protect\cs{prevlineX},
% where X is the letter of the current series.
% This macro is called when using \protect\cs{Xnumberonlyfirstinline}.
% This macro must be reset at the same time as the line number.
% The \protect\cs{resetprevline@} does this resetting for every series.
% \begin{macro}{\resetprevline@}
%    \begin{macrocode}
\newcommand*{\resetprevline@}{%
    \def\do##1{\global\csundef{prevline##1}}%
    \dolistloop{\@series}%
}
%    \end{macrocode}
% \end{macro}
%
% \DescribeMacro{\resetprevpage@num}
% Inside the apparatus, at each note, the page number is stored in a macro called \protect\cs{prevpageX@num},
% where X is the letter of the current series.
% This macro is called when using \protect\cs{Xparafootsep} or \protect\cs{parafootsepX}.
% This macro must be reset at the beginning of each numbered section
% The \protect\cs{resetprevpage@} command resets this macro for every series.
% \begin{macro}{\resetprevpage@}
%    \begin{macrocode}
\newcommand*{\resetprevpage@num}{%
    \def\do##1{%
      \ifcsdef{prevpage##1@num}{%
        \global\csname prevpage##1@num\endcsname=\z@%
        \global\csname prevpage##1@numR\endcsname=\z@%
        }%
        {}%
      \ifcsdef{##1prevpage@num}{%
        \global\csname ##1prevpage@num\endcsname=\z@%
        \global\csname ##1prevpage@numR\endcsname=\z@%
        }%
        {}%
      }%
    \dolistloop{\@series}%
}
%    \end{macrocode}
% \end{macro}
% \subsection{Reading the line-list file}
%
%
% \begin{macro}{\read@linelist}
% \protect\cs{read@linelist}\marg{file} is the control sequence
% that  is called by \protect\cs{beginnumbering}
% (via \protect\cs{line@list@stuff}) to open and process a
% line-list file; its argument is the name of the file.
% \label{readlinelist}.
% First, it clear all previous line's list.
%    \begin{macrocode}
\newread\@inputcheck
\newcommand*{\read@linelist}[1]{%
  \ifledRcol%
    \list@clearing@regR%
  \else%
    \list@clearing@reg%
  \fi%
%    \end{macrocode}
%
% When using \parpackage, make sure that the \protect\cs{maxlinesinpar@list} is empty (otherwise things
% will be thrown out of kilter if there is any old stuff still hanging
% in there).
%    \begin{macrocode}
  \list@clear{\maxlinesinpar@list}
%    \end{macrocode}
% Now get the file and interpret it.
% When the file is there we start a new group and make some special
% definitions we will need to process it.
% It is  a sequence of \TeX\
% commands, but they require a few special settings.
% We make [ and
% ] become grouping characters: they are used that way in the
% line-list file, because we need to write them out one at a time
% rather than in balanced pairs, and it is easier to just use
% something other than real braces. @ must become a letter, since
% this is run in the ordinary \LaTeX\ context. We ignore carriage
% returns, since if we are in horizontal mode they can get
% interpreted as spaces to be printed.
%
%
% Our line, page, and line-locking counters were already zeroed
% by \protect\cs{line@list@stuff} if this is being called from within
% \protect\cs{beginnumbering}; sub-lineation will be turned off as well
% in that case. On the other hand,
% if this is being called from \protect\cs{resumenumbering}, those things
% should still have the values they had when \protect\cs{pausenumbering}
% was executed.
%
%   If the file is not there, we print an informative message.
%
% Now, after these preliminaries, we start interpreting the file.
%
%
%    \begin{macrocode}
  \get@linelistfile{#1}%
  \@stopmsd%Security if last \endms{} is forgotten
  \unless\ifledRcol%Get the last line of the last page
    \csnumgdef{@lastabsline@forpage@\the\page@num}{\the\absline@num}%
    \csnumgdef{@lastline@forpage@\the\page@num}{\the\line@num}%
    \csnumgdef{@lastsubline@forpage@\the\page@num}{\the\subline@num}%
  \else%
    \csnumgdef{@lastabsline@forpageR@\the\page@numR}{\the\absline@numR}%
    \csnumgdef{@lastline@forpageR@\the\page@numR}{\the\line@numR}%
    \csnumgdef{@lastsubline@forpageR@\the\page@numR}{\the\subline@numR}%
  \fi%
  \endgroup
%    \end{macrocode}
%
% When the reading is done, we are all through with the
% line-list file. All the information we needed
% from it will now be encoded in our list macros.
%
% Finally, we
% initialize the \protect\cs{next@actionline} and \protect\cs{next@action} macros,
% which specify where and what the next action to be taken is.
%    \begin{macrocode}
  \ifledRcol
    \global\page@numR=\m@ne
    \ifx\actionlines@listR\empty
      \gdef\next@actionlineR{1000000}%
    \else
      \gl@p\actionlines@listR\to\next@actionlineR
      \gl@p\actions@listR\to\next@actionR
    \fi
  \else
    \global\page@num=\m@ne
    \ifx\actionlines@list\empty
      \gdef\next@actionline{1000000}%
    \else
      \gl@p\actionlines@list\to\next@actionline
      \gl@p\actions@list\to\next@action
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\list@clearing@reg}
% Clears the lists for \protect\cs{read@linelist}
% \changes{v0.7.0}{2005/02/22}{Added \protect\cs{list@clearing@reg}}
%    \begin{macrocode}
\newcommand*{\list@clearing@reg}{%
  \list@clear{\line@list}%
  \list@clear{\insertlines@list}%
  \list@clear{\actionlines@list}%
  \list@clear{\actions@list}%
  \list@clear{\linesinpar@listL}%
  \list@clear{\linesonpage@listL}%
  }%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\get@linelistfile}
% \Macpackage{} can take advantage of the \LaTeX\ `safe file input' macros
% to get the line-list file.
% \changes{v0.7.0}{2005/02/22}{Added \protect\cs{get@linelistfile}}
%    \begin{macrocode}
\newcommand*{\get@linelistfile}[1]{%
  \InputIfFileExists{\l@auxdir#1}{%
    \global\noteschanged@false
    \begingroup
      \catcode`\[=1 \catcode`\]=2
      \makeatletter \catcode`\^^M=9}{%
    \led@warn@NoFile{\l@auxdir#1}%
    \global\noteschanged@true
    \begingroup}%
}

%    \end{macrocode}
% \end{macro}
%
% This version of \protect\cs{read@linelist} creates list macros
% containing data for the entire section, so they could get rather
% large. It would be no more difficult to read the line-list file
% incrementally rather than all at once: we could read, at the
% start of each paragraph, only the commands relating to that
% paragraph. But this would require that we
% have two line-lists open at once, one for reading, one for
% writing, and on systems without version numbers we would have to do
% some file renaming outside of \LaTeX\  for that to work. We have
% retained this slower approach to avoid that sort of hacking
% about, but have provided the \protect\cs{pausenumbering} and
% \protect\cs{resumenumbering} macros to help you if you run into
% macro memory limitations (see \reff{pause} above).
%
% \subsection{Commands within the line-list file}
%
% This section defines the commands that can appear within a
% line-list file. They all have very short names because we are
% likely to be writing very large numbers of them out. One macro,
% \protect\cs{@nl}, is especially short, since it will be written to the
% line-list file once for every line of text in a numbered section.
% (Another of these commands, \protect\cs{@lab}, will be introduced in a
% later section, among the cross-referencing commands it is
% associated with.)
%
% When these commands modify the various page and line counters,
% they deliberately do not use \protect\cs{global}. This is because we
% want them to affect only the counter values within the current
% group when nested calls of \protect\cs{@ref} occur. (The code assumes
% throughout that the value of \protect\cs{globaldefs} is zero.)
%
% The macros with \verb"action" in their names contain all the code
% that modifies the action-code list: again, this is so that they
% can be turned off easily for nested calls of \protect\cs{@ref}.
%
% \begin{macro}{\line@list@version}
% The \protect\cs{line@list@version} check if the line-list file does not refers to the older commands of \macpackage.
% In this case, we stop reading the line-list file.
% Consequently, \protect\cs{line@list@version} must be the first line of a line-number file.
%    \begin{macrocode}
\newcommand{\line@list@version}[1]{%
  \IfStrEq{#1}{\this@line@list@version}%
    {}%
    {\ifledRcol%
       \led@warn@Obsolete{\jobname.\extensionchars\the\section@num}%
     \else%
       \led@warn@Obsolete{\jobname.\extensionchars\the\section@num}%
     \fi%
     \endinput%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@nl}
% \begin{macro}{\@nl@reg}
% \changes{v1.12.0}{2014/08/05}{To ensure compatibility with \protect\cs{musixtex}, \protect\cs{@l} becomes \protect\cs{@l}. Consequently, \protect\cs{@l@reg} becomes \protect\cs{@nl@reg}.}
% \protect\cs{@nl} does everything related to the start of a
% new line of numbered text.
%
% In order to get the \protect\cs{setlinenum} to work Peter Wilson had to slip in some new
% code at the start of the macro, to get the timing of the actions
% correct. The problem was that his original naive implementation
% of \protect\cs{setlinenum} had a unfortunate tendency to change the
% number of the last line of the \emph{preceding} paragraph.
% The new code is sort of based on the page number handling and
% \protect\cs{setline}.
% It seems
% that a lot of fiddling with the line number internals is required.
%
% In November 2004 in order to accurately determine page numbers Peter Wilson added
% these to the macro. It is now: \\
% \protect\cs{@nl}\marg{page counter number}\marg{printed page number} \\
% We do not (yet) use the printed number (i.e., the \protect\cs{thepage}) but
% it may come in handy later. The macro \cs{@page} checks if a new
% page has started.
%
% Exactly what \protect\cs{@nl} does depends
% on whether right text is being processed. That's why many code is defined in \protect\cs{@nl@reg} or \protect\cs{nl@regR}.
%
%
% \changes{v0.3.0}{2004/02/14}{Added a bunch of code to \protect\cs{@nl} for handling
%                          \protect\cs{setlinenum}}
% \changes{v0.6.0}{2004/11/16}{Extended \protect\cs{@nl} to include the page number}
% \changes{v0.7.0}{2005/02/22}{Added \protect\cs{@nl@reg}}
%    \begin{macrocode}

\newcommand*{\@nl}[2]{%
  \@page{#1}%
  \ifledRcol%
    \@nl@regR%
  \else%
    \@nl@reg%
  \fi%
}
\newcommand*{\@nl@reg}{%
  \ifx\l@dchset@num\relax \else
    \advance\absline@num \@ne
    \csgdef{l@dchset@num@\the\absline@num}{}%To remember this line have been marked by a \setlinenum
    \set@line@action
    \let\l@dchset@num=\relax
    \advance\absline@num \m@ne
    \advance\line@num \m@ne
  \fi
%    \end{macrocode}
%
% First increment the absolute line-number, and perform
% deferred actions relating to page starts and sub-lines.
%    \begin{macrocode}
  \reset@current@annot%
  \advance\absline@num \@ne
         \ifx\next@page@num\relax \else
             \page@action
             \let\next@page@num=\relax
         \fi
         \ifx\sub@change\relax \else
            \ifnum\sub@change>\z@
               \sublines@true
            \else
               \sublines@false
            \fi
            \sub@action
            \let\sub@change=\relax
         \fi
%    \end{macrocode}
%
% Fix the lock counters, if necessary. A value of $1$ is advanced to
% $2$; $3$ advances to $0$; other values are unchanged.
%    \begin{macrocode}
         \ifcase\@lock
            \or
               \@lock \tw@
            \or \or
               \@lock \z@
         \fi
         \ifcase\sub@lock
            \or
               \sub@lock \tw@
            \or \or
               \sub@lock \z@
         \fi
%    \end{macrocode}
%
% Now advance the visible line number, unless it has been locked.
%    \begin{macrocode}
         \ifsublines@
              \ifnum\sub@lock<\tw@
                \advance\subline@num \@ne
              \fi
         \else
              \ifnum\@lock<\tw@
                \advance\line@num \@ne \subline@num \z@
              \fi
         \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\last@page@num}
% \begin{macro}{\this@section@last@page@num}
% \begin{macro}{\@page}
%  \protect\cs{@page}  determines whether or not
% a new page has been started, based on the page values held by \protect\cs{@nl}.
%    \begin{macrocode}
\newcount\last@page@num
  \last@page@num=-10000

\newcount\this@section@last@page@num%
  \this@section@last@page@num=-10000%

\newcommand*{\@page}[1]{%
  \ifledRcol
    \ifnum #1=\last@page@numR
    \else
      \csnumgdef{@lastabsline@forpageR@\the\page@numR}{\the\absline@numR}%
      \csnumgdef{@lastline@forpageR@\the\page@numR}{\the\line@numR}%
      \csnumgdef{@lastsubline@forpageR@\the\page@numR}{\the\subline@numR}%
      \ifbypage@R
        \ifx\l@dchset@num\relax%Not resetting if preceded by a \setlinenum
          \ifboolexpr{%
            bool{resumenumberingR@start}%
            and test {\ifnumequal{\last@page@numR}{-10000}}%
          }%
          {}%
          {%
            \line@numR \z@%
            \subline@numR \z@%
            \global\csdef{reset@lineR\the\numexpr\absline@numR+1\relax @\the\section@numR}{}%
          }%
        \fi%
      \fi
      \page@numR=#1%
      \this@section@page@numR=#1%
      \last@page@numR=#1%
      \this@section@last@page@numR=#1%
      \def\next@page@numR{#1}%
      \gdef\this@section@next@page@numR{#1}%
    \fi
  \else
    \ifnum #1=\last@page@num
    \else
      \csnumgdef{@lastabsline@forpage@\the\page@num}{\the\absline@num}%
      \csnumgdef{@lastline@forpage@\the\page@num}{\the\line@num}%
      \csnumgdef{@lastsubline@forpage@\the\page@num}{\the\subline@num}%
      \ifbypage@
        \ifx\l@dchset@num\relax%Not resetting if preceded by a \setlinenum
          \line@num \z@%
          \subline@num \z@%
          \global\csdef{reset@line\the\numexpr\absline@num+1\relax @\the\section@num}{}%
        \fi%
      \fi
      \page@num=#1%
      \global\this@section@page@num=#1%
      \last@page@num=#1%
      \global\this@section@last@page@num=#1%
      \def\next@page@num{#1}%
%    \end{macrocode}
% And we set a flag that tells \cs{@nl} that a new page number is
% to be set, because other associated actions shouldn't occur until the
% next line-start occurs.
%    \begin{macrocode}
      \gdef\this@section@next@page@num{#1}%
      \listxadd{\normal@page@break}{\the\absline@num}
    \fi
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@pend}
% \begin{macro}{\@pendR}
% \begin{macro}{\@lopL}
% \begin{macro}{\@lopR}
% These do not do anything at this point, but will have been added to the
% auxiliary file(s) if the  \parpackage package has been used. They
% are just here to stop \macpackage\ from moaning if the \parpackage
% is used for one run and then not for the following one.
% \changes{v0.6.0}{2004/11/16}{Added \protect\cs{@pend},\protect\cs{@pendR}, \protect\cs{@lopL} and
%        \protect\cs{@lopR} in anticipation of parallel processing}
%    \begin{macrocode}
\newcommand*{\@pend}[1]{}
\newcommand*{\@pendR}[1]{}
\newcommand*{\@lopL}[1]{}
\newcommand*{\@lopR}[1]{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sub@on}
% \begin{macro}{\sub@off}
% The \protect\cs{sub@on} and \protect\cs{sub@off} macros
% turn sub-lineation on and off\/: but not directly, since such changes
% do not really take effect until the next line of text. Instead
% they set a flag that notifies \protect\cs{@nl} of the necessary action.
%    \begin{macrocode}
\newcommand*{\sub@on}{\ifsublines@
     \let\sub@change=\relax
  \else
     \def\sub@change{1}%
  \fi}
\newcommand*{\sub@off}{\ifsublines@
     \def\sub@change{-1}%
  \else
     \let\sub@change=\relax
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@adv}
% The \protect\cs{@adv}\marg{num} macro advances
% the current visible line number by the amount specified as
% its argument. This is used to implement \protect\cs{advanceline}.
%    \begin{macrocode}

\newcommand*{\@adv}[1]{%
  \ifsublines@
    \ifledRcol
      \advance\subline@numR by #1\relax
      \ifnum\subline@numR<\z@
        \led@warn@BadAdvancelineSubline
        \subline@numR \z@
      \fi
    \else
      \advance\subline@num by #1\relax
      \ifnum\subline@num<\z@
        \led@warn@BadAdvancelineSubline
        \subline@num \z@
      \fi
    \fi
  \else
    \ifledRcol
      \advance\line@numR by #1\relax
      \ifnum\line@numR<\z@
        \led@warn@BadAdvancelineLine
        \line@numR \z@
      \fi
    \else
      \advance\line@num by #1\relax
      \ifnum\line@num<\z@
        \led@warn@BadAdvancelineLine
        \line@num \z@
      \fi
    \fi
  \fi
  \set@line@action}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@set}
% The \protect\cs{@set}\marg{num} macro sets
% the current visible line number to the value specified as
% its argument.  This is used to implement \protect\cs{setline}.
%    \begin{macrocode}

\newcommand*{\@set}[1]{%
  \ifledRcol
    \ifsublines@
      \subline@numR=#1\relax
    \else
      \line@numR=#1\relax
    \fi
    \set@line@action
  \else
    \ifsublines@
      \subline@num=#1\relax
    \else
      \line@num=#1\relax
    \fi
    \set@line@action
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@d@set}
% \begin{macro}{\l@dchset@num}
% The \protect\cs{l@d@set}\marg{num} macro sets
% the line number for the next \protect\cs{pstart} to the value specified as
% its argument.  This is used to implement \protect\cs{setlinenum}.
%
% \protect\cs{l@dchset@num} is a flag to the \protect\cs{@nl}? macro. If it is not
% \protect\cs{relax} then a linenumber change is to be done.
%    \begin{macrocode}

\newcommand*{\l@d@set}[1]{%
  \ifledRcol
    \line@numR=#1\relax
    \advance\line@numR \@ne
    \def\l@dchset@num{#1}
  \else
    \line@num=#1\relax
    \advance\line@num \@ne
    \def\l@dchset@num{#1}
  \fi}
\let\l@dchset@num\relax

%    \end{macrocode}
% \end{macro}
% \end{macro}

%
% \begin{macro}{\page@action}
% \protect\cs{page@action}
% adds an entry to the action-code list to change the page number.
%    \begin{macrocode}

\newcommand*{\page@action}{%
  \ifledRcol
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR
    \xright@appenditem{\next@page@numR}\to\actions@listR
  \else
    \xright@appenditem{\the\absline@num}\to\actionlines@list
    \xright@appenditem{\next@page@num}\to\actions@list
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\set@line@action}
% \protect\cs{set@line@action} adds an entry to the action-code
% list to change the visible line number.
%    \begin{macrocode}

\newcommand*{\set@line@action}{%
  \ifledRcol
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR
    \ifsublines@
       \@l@dtempcnta=-\subline@numR
    \else
       \@l@dtempcnta=-\line@numR
    \fi
    \advance\@l@dtempcnta by -5000\relax
    \xright@appenditem{\the\@l@dtempcnta}\to\actions@listR
  \else
    \xright@appenditem{\the\absline@num}\to\actionlines@list
    \ifsublines@
       \@l@dtempcnta=-\subline@num
    \else
       \@l@dtempcnta=-\line@num
    \fi
    \advance\@l@dtempcnta by -5000\relax
    \xright@appenditem{\the\@l@dtempcnta}\to\actions@list
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sub@action}
% \protect\cs{sub@action}
% adds an entry to the action-code list to turn sub-lineation on or
% off, according to the current value of the \protect\cs{ifsublines@} flag.
%    \begin{macrocode}

\newcommand*{\sub@action}{%
  \ifledRcol
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR
    \ifsublines@
      \xright@appenditem{-1001}\to\actions@listR
    \else
      \xright@appenditem{-1002}\to\actions@listR
    \fi
  \else
    \xright@appenditem{\the\absline@num}\to\actionlines@list
    \ifsublines@
      \xright@appenditem{-1001}\to\actions@list
    \else
      \xright@appenditem{-1002}\to\actions@list
    \fi
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lock@on}
% \begin{macro}{\do@lockon}
% \begin{macro}{\do@lockonL}
% \protect\cs{lock@on}
% adds an entry to the action-code list to turn line number
% locking on. The current setting of the sub-lineation flag tells us
% whether this applies to line numbers or sub-line numbers.
%
% Adding commands to the action list is slow, and it is very often the
% case that a lock-on command is immediately followed by a lock-off
% command in the line-list file, and therefore really does nothing.
% We use a look-ahead scheme here to detect such pairs, and add nothing
% to the line-list in those cases.
%    \begin{macrocode}
\newcommand*{\lock@on}{\futurelet\next\do@lockon}

\newcommand*{\do@lockon}{%
  \ifx\next\lock@off
    \global\let\lock@off=\skip@lockoff
  \else
    \ifledRcol
      \do@lockonR
    \else
      \do@lockonL
    \fi
  \fi}


\newcommand*{\do@lockonL}{%
  \xright@appenditem{\the\absline@num}\to\actionlines@list
  \ifsublines@
    \xright@appenditem{-1005}\to\actions@list
    \ifnum\sub@lock=\z@
      \sub@lock \@ne
    \else
      \ifnum\sub@lock=\thr@@
        \sub@lock \@ne
      \fi
    \fi
  \else
    \xright@appenditem{-1003}\to\actions@list
    \ifnum\@lock=\z@
      \@lock \@ne
    \else
      \ifnum\@lock=\thr@@
        \@lock \@ne
      \fi
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lock@off}
% \begin{macro}{\do@lockoff}
% \begin{macro}{\do@lockoffL}
% \begin{macro}{\skip@lockoff}
% \protect\cs{lock@off} adds an entry to the action-code list
% to turn line number locking off.
%    \begin{macrocode}
\newcommand*{\do@lockoffL}{%
  \xright@appenditem{\the\absline@num}\to\actionlines@list
  \ifsublines@
    \xright@appenditem{-1006}\to\actions@list
    \ifnum\sub@lock=\tw@
      \sub@lock \thr@@
    \else
      \sub@lock \z@
    \fi
  \else
    \xright@appenditem{-1004}\to\actions@list
    \ifnum\@lock=\tw@
      \@lock \thr@@
    \else
      \@lock \z@
    \fi
  \fi}

\newcommand*{\do@lockoff}{%
  \reset@current@annot%
  \ifledRcol
    \do@lockoffR
  \else
    \do@lockoffL
  \fi}
\newcommand*{\skip@lockoff}{\global\let\lock@off=\do@lockoff}
\global\let\lock@off=\do@lockoff

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\n@num}
% These macros implement the \protect\cs{skipnumbering} command.
% They use action code 1007.
% \changes{v0.7.0}{2005/02/22}{Added \protect\cs{n@num}}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{n@num} defined only one time for both \Eledmac{} and \Eledpar{}}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{n@num@ref} deleted}
%    \begin{macrocode}
\newcommand*{\n@num}{%
  \ifledRcol%
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR
    \xright@appenditem{-1007}\to\actions@listR
  \else%
    \xright@appenditem{\the\absline@num}\to\actionlines@list%
    \xright@appenditem{-1007}\to\actions@list%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\n@num@stanza}
% This macro implements the \protect\cs{skipnumbering} for stanza command.
% It uses  action code 1008.
%    \begin{macrocode}
\newcommand*{\n@num@stanza}{%
  \ifledRcol%
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR%
    \xright@appenditem{-1008}\to\actions@listR%
  \else%
    \xright@appenditem{\the\absline@num}\to\actionlines@list%%
    \xright@appenditem{-1008}\to\actions@list%
  \fi%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ifl@dhidenumber}
% \begin{macro}{\hidenumbering}
% \begin{macro}{\hidenumberingonleftpage}
% \begin{macro}{\hidenumberingonrightpage}
% \protect\cs{hidenumbering} hides number in margin.
% It uses action code 1009.
% \cs{hidenumberingonleftpage} and \cs{hidenumberingonrightpage} ara variant, using action code only conditionnaly
% \begin{macro}{\h@num}
%    \begin{macrocode}
\newif\ifl@dhidenumber
\newcommand*{\hidenumbering}{%
  \ifledRcol%
    \write\linenum@outR{\string\hide@num}%
  \else%
    \write\linenum@out{\string\hide@num}%
  \fi%
}%
\newcommand*{\hide@num}{%
  \ifledRcol%
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR%
    \xright@appenditem{-1009}\to\actions@listR%
  \else%
    \xright@appenditem{\the\absline@num}\to\actionlines@list%%
    \xright@appenditem{-1009}\to\actions@list%
  \fi%
}
\newcommand*{\hidenumberingonleftpage}{%
  \ifledRcol%
    \write\linenum@outR{\string\hide@num@left}%
  \else%
    \write\linenum@out{\string\hide@num@left}%
  \fi%
}%

\newcommand*{\hide@num@left}{%
  \ifledRcol%
    \ifodd\page@numR\else%
      \xright@appenditem{\the\absline@numR}\to\actionlines@listR%
      \xright@appenditem{-1009}\to\actions@listR%
    \fi%
  \else%
    \ifodd\page@num\else%
      \xright@appenditem{\the\absline@num}\to\actionlines@list%%
      \xright@appenditem{-1009}\to\actions@list%
    \fi%
  \fi%
}%

\newcommand*{\hidenumberingonrightpage}{%
  \ifledRcol%
    \write\linenum@outR{\string\hide@num@right}%
  \else%
    \write\linenum@out{\string\hide@num@right}%
  \fi%
}%

\newcommand*{\hide@num@right}{%
  \ifledRcol%
    \ifodd\page@numR%
      \xright@appenditem{\the\absline@numR}\to\actionlines@listR%
      \xright@appenditem{-1009}\to\actions@listR%
    \fi%
  \else%
    \ifodd\page@num%
      \xright@appenditem{\the\absline@num}\to\actionlines@list%%
      \xright@appenditem{-1009}\to\actions@list%
    \fi%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\@ref}
% \begin{macro}{\insert@count}
% \protect\cs{@ref}
% marks the start of a passage, for creation of a footnote reference.
% It takes two arguments:
% \begin{itemize}
% \item \verb"#1", the number of entries to add to \protect\cs{insertlines@list}
% for this reference. \SpecialMainIndex{\insert@count}
% This value, here and within \protect\cs{edtext},
% which computes it and writes it to the line-list file,
% will be stored in the count \protect\cs{insert@count}.
%    \begin{macrocode}
\newcount\insert@count
%    \end{macrocode}
%
% \item \verb"#2", a sequence of other line-list-file commands, executed to
% determine the ending line-number. (This may also include other
% \protect\cs{@ref} commands, corresponding to uses of \protect\cs{edtext}
% within the first argument of another instance of \protect\cs{edtext}.)
% \end{itemize}
%
% \begin{macro}{\dummy@ref}
% When nesting of \protect\cs{@ref} commands does occur, it is necessary to
% temporarily redefine \protect\cs{@ref} within \protect\cs{@ref}, so that we are only
% doing one of these at a time.
%    \begin{macrocode}
\newcommand*{\dummy@ref}[2]{#2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ref@reg}
% The first thing \protect\cs{@ref} (i.e. \protect\cs{@ref@reg}) itself does is to add
% the specified number
% of items to the \protect\cs{insertlines@list} list.
% \changes{v0.7.0}{2005/02/22}{Added \protect\cs{@ref@reg}}
%    \begin{macrocode}
\newcommand*{\@ref}[2]{%
  \ifledRcol%
    \@ref@regR{#1}{#2}%
  \else%
    \@ref@reg{#1}{#2}%
  \fi%
}%
\newcommand*{\@ref@reg}[2]{%
  \global\insert@count=#1\relax
  \global\advance\@edtext@level by 1%
  \loop\ifnum\insert@count>\z@
    \xright@appenditem{\the\absline@num}\to\insertlines@list
    \global\advance\insert@count \m@ne
  \repeat
%    \end{macrocode}
%
% Next, process the second argument to determine the page
% and line numbers for the end of this lemma.
% We temporarily equate \protect\cs{@ref} to a different macro that just executes
% its argument, so that nested \protect\cs{@ref} commands are just skipped
% this time. Some other macros need to be temporarily redefined to
% suppress their action.
%    \begin{macrocode}
  \begingroup
    \let\@ref=\dummy@ref
    \let\@lopL\@gobble
    \let\page@action=\relax
    \let\sub@action=\relax
    \let\set@line@action=\relax
    \let\@lab=\relax
    \let\@lemma=\relax%
    \let\@sw\@gobblethree%
    \let\store@annot@to@absline\@gobble%
    #2
    \global\endpage@num=\page@num
    \global\endline@num=\line@num
    \global\endsubline@num=\subline@num
    \global\let\endcurrent@annot=\current@annot%
  \endgroup
%    \end{macrocode}
%
% Now store all the information about the location of the lemma's
% start and end in \protect\cs{line@list}.
%    \begin{macrocode}
    \xright@appenditem%
      {\the\page@num|\the\line@num|%
       \ifsublines@ \the\subline@num \else 0\fi|%
       \the\endpage@num|\the\endline@num|%
       \ifsublines@ \the\endsubline@num \else 0\fi}\to\line@list
    \xright@appenditem%
      {\current@annot|\endcurrent@annot}\to\annot@list%
%    \end{macrocode}
% And now, call \cs{@ref@reg@parsearg}, which can be also called by \cs{@ref@later}
%    \begin{macrocode}
     \@ref@reg@parse{#2}%
%    \end{macrocode}
% Decrease edtext level counter.
%    \begin{macrocode}
  \global\advance\@edtext@level by -1%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@ref@reg@parse}%
% The \cs{@ref@reg@parsearg} command parses the second argument of a \cs{@ref} or the unique argument of \cs{@ref@later} written in the auxiliary fill.
%
% First, create a list which stores every second argument of each \protect\cs{@sw}
% in this lemma, at this level.
% Also set the boolean about the use of lemma in this edtext level to false.
%    \begin{macrocode}
\newcommand{\@ref@reg@parse}[1]{%
     \expandafter\list@create\expandafter{\csname sw@list@edtext@tmp@\the\@edtext@level\endcsname}%
     \providebool{lemmacommand@\the\@edtext@level}%
     \boolfalse{lemmacommand@\the\@edtext@level}%
%    \end{macrocode}
% Execute the second argument of \protect\cs{@ref} again,
% to perform for real all the commands within it.
%    \begin{macrocode}
  #1%
%    \end{macrocode}
% Now, we store the list of \protect\cs{@sw} of this current \protect\cs{edtext} as an element of
% the global list of list of \protect\cs{@sw} for a \protect\cs{edtext} depth.
%    \begin{macrocode}
  \ifnum\@edtext@level>0%
    \def\create@this@edtext@level{\expandafter\list@create\expandafter{\csname sw@list@edtext@\the\@edtext@level\endcsname}}%
    \ifcsundef{sw@list@edtext@\the\@edtext@level}{\create@this@edtext@level}{}%
    \letcs{\@tmp}{sw@list@edtext@\the\@edtext@level}%
    \letcs{\@tmpp}{sw@list@edtext@tmp@\the\@edtext@level}
    \xright@appenditem{\expandonce\@tmpp}\to\@tmp%
    \global\cslet{sw@list@edtext@\the\@edtext@level}{\@tmp}%
  \fi%
%    \end{macrocode}
%    \begin{macrocode}
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\ref@reg@later}
% This macro is stored in the auxiliary file when using \cs{edtextlater}.
% It is used only to get the correct value for the \cs{sameword} tools.
%    \begin{macrocode}
\newcommand{\@ref@later}[1]{%
  \global\advance\@edtext@level by \@ne%
  \ifledRcol%
    \@ref@reg@parseR{#1}%
  \else%
    \@ref@reg@parse{#1}%
  \fi%
  \global\advance\@edtext@level by -\@ne%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Writing to the line-list file}
%
% We have now defined all the counters, lists, and commands involved in
% reading the line-list file at the start of a section. Now we will
% cover the commands that \macpackage\ uses within the text of a
% section to write commands out to the line-list.
%
% \begin{macro}{\linenum@out}
% The file will be opened on output stream \protect\cs{linenum@out}.
%    \begin{macrocode}
\newwrite\linenum@out
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\iffirst@linenum@out@}
% \begin{macro}{\first@linenum@out@true}
% \begin{macro}{\first@linenum@out@false}
% Once any file is opened on this stream, we keep it open forever, or
% else switch to another file that we keep open. The reason is that
% we want the output routine to write the page number for every page
% to this file; otherwise we would have to write it at the start of
% every line.
% But it is not very easy for the output routine to tell whether an
% output stream is open or not. There is no way to test the status of
% a particular output stream directly, and
% the asynchronous nature of output routines makes the
% status hard to determine by other means.
%
% We can manage pretty well by means of the \protect\cs{iffirst@linenum@out@}
% flag; its inelegant name suggests the nature of the problem that
% made its creation necessary. It is set
% to be \verb"true" before any \protect\cs{linenum@out} file is opened. When such a file
% is opened for the first time, it is done using \protect\cs{immediate}, so that
% it will at once be safe for the output routine to write to it; we then
% set this flag to \verb"false".
%    \begin{macrocode}
\newif\iffirst@linenum@out@
  \first@linenum@out@true
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\this@line@list@version}
% The commands allowed in the line-list file and their arguments
% can change between two version of \macpackage.
% The \protect\cs{this@line@list@version} command is upgraded when it happens.
% It is written in the file list.
% If we process a line-list file which used a older version, that means the commands used inside are deprecated, and we can't use them.
%    \begin{macrocode}
\newcommand{\this@line@list@version}{7}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\line@list@stuff}
% \begin{macro}{\next@line@list@stuff}
% The \protect\cs{line@list@stuff}\marg{file} macro, which
% is called by \protect\cs{beginnumbering}, performs
% all the line-list operations needed at the start of a section.
% Its argument is the name of the line-list file.
% \changes{v2.24.0}{2017/08/17}{Add \protect\cs{next@line@list@stuff} internal hook.}
%    \begin{macrocode}
\let\next@line@list@stuff\relax%
\newcommand*{\line@list@stuff}[1]{%
%    \end{macrocode}
% First, define a toggle set to true when we are not in the first run.
%    \begin{macrocode}
  \global\newtoggle{notfirstrun@#1}%
  \IfFileExists{\l@auxdir#1}%
    {\global\toggletrue{notfirstrun@#1}}%
    {\global\togglefalse{notfirstrun@#1}}%
%    \end{macrocode}
% A internal hook (not used yet).
%    \begin{macrocode}
  \next@line@list@stuff%
  \global\let\next@line@list@stuff\relax%
%    \end{macrocode}
% Use the commands of the previous section to interpret the
% line-list file from the last run.
%    \begin{macrocode}
  \read@linelist{#1}%
%    \end{macrocode}
%
% Now close the current output line-list file, if any, and open a new one.
% The first time we open a line-list file for output, we do it using
% \protect\cs{immediate}, and clear the \protect\cs{iffirst@linenum@out@} flag.
% \changes{v0.2.2}{2003/11/09}{Added initial write of page number in
%                           \protect\cs{line@list@stuff}}
% \changes{v0.7.0}{2005/02/25}{Deleted \protect\cs{page@start} from \protect\cs{line@list@stuff}}
% \changes{v1.15.1}{2015/01/16}{Revert modification of 1.5.2 which makes bug with numbering. Leave vertical mode to solve spurious space before minipage.}
% \Macpackage\ and \parpackage can fill the \cs{next@line@list@stuff} hook between a \cs{endnumbering} (associated with numbered file $n$) and a \cs{beginnumbering} (associated with numbered file $n+1$). It allows adding content to the numbered file $n+1$ and not $n$.
%    \begin{macrocode}
  \iffirst@linenum@out@
     \global\first@linenum@out@false%
     \immediate\openout\linenum@out=\l@auxdir#1\relax%
     \immediate\write\linenum@out{\string\line@list@version{\this@line@list@version}}%
     \ifl@dpaging%
       \immediate\write\linenum@out{\string\@par@sync@option{\@par@this@sync@option}}%
     \fi%
  \else
%    \end{macrocode}
% If we get here, then this is
% not the first line-list we have seen, so we
% do not open or close the files immediately.
%    \begin{macrocode}
     \if@minipage%
       \leavevmode%
     \fi%
     \closeout\linenum@out%
     \openout\linenum@out=\l@auxdir#1\relax%
     \write\linenum@out{\string\line@list@version{\this@line@list@version}}%
     \ifl@dpaging%
       \write\linenum@out{\string\@par@sync@option{\@par@this@sync@option}}%
     \fi%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\new@line}
% \begin{macro}{\set@this@c@page}
% The \protect\cs{new@line} macro sends the \protect\cs{@nl} command to the line-list
% file, to mark the start of a new text line, and its page number.
% \label{new@line@pagecounting}
% It writes the two forms of the page number:
% \begin{itemize}
%  \item Raw form (\cs{the}\cs{c@page}, which can be used for numeric tests.
%  \item Formatted form (for example, in Roman).
% \end{itemize}
% Actually, only the first form is used by \cs{@nl}.
% If we use the \cs{sameparallelpagenumber} option of \parpackage, we must write not the real page number (i.e. \verb+page+ counter, defined in standard \LaTeX) but the printed page number (i.e \verb+par@page+ counter, defined only on \macpackage).
% \begin{itemize}
%   \item For the raw form, we use \cs{the}\cs{c@page@page} macro, because the \verb+{par@page}+ counter is increased for each page.
%   \item For the formatted version, \cs{thepage} is patched through \cs{par@patch@thepage}. So we have nothing to change.
% \end{itemize}
% \changes{v0.6.0}{2004/11/16}{Extended \protect\cs{new@line} to output page numbers}
%    \begin{macrocode}
\newcommand*{\new@line}{%
  \set@this@c@page%
  \ifnumberline%
    \IfStrEq{\led@pb@setting}{after}%
      {\xifinlist{\the\absline@num}{\l@prev@nopb}%
        {\xifinlist{\the\absline@num}{\normal@page@break}%
          {\numgdef{\@next@page}{\c@par@page+\@ne}%
          \write\linenum@out{\string\@nl[\@next@page][\@next@page]}%
        }%
        {\write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}}%
      }%
      {\write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}}}%
    {}%
    \IfStrEq{\led@pb@setting}{before}%
      {\numdef{\next@absline}{\the\absline@num+\@ne}%
      \xifinlist{\next@absline}{\l@prev@nopb}%
        {\xifinlist{\the\absline@num}{\normal@page@break}%
          {\numgdef{\nc@page}{\c@par@page+\@ne}%
          \write\linenum@out{\string\@nl[\nc@page][\nc@page]}%
          }%
          {\write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}}%
        }%
        {\write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}}%
      }%
      {}%
    \IfStrEqCase{\led@pb@setting}%
      {%
      {before}{\relax}%
      {after}{\relax}%
    }[%
      \write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}%
    ]%
  \fi%
}

\newcount\@this@c@page%%
\newcommand{\set@this@c@page}{%
  \ifboolexpr{%
    bool{sameparallelpagenumber}%
    or bool{prevpgnotnumbered}%
  }%
  {\global\@this@c@page=\c@par@page}%
  {\global\@this@c@page=\c@page}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\if@noneed@Footnote}
% \protect\cs{if@noneed@Footnote} is a boolean to check if we have to print a error message when a \protect\cs{edtext} is called without any critical notes.
%
% \begin{macro}{\flag@start}
% \begin{macro}{\flag@end}
% \changes{v1.12.3}{2014/08/15}{\protect\cs{flag@start} and \protect\cs{flag@end} are now defined only one time for eledmac and eledpar}
% \changes{v1.12.3}{2014/08/15}{\protect\cs{flag@start} send a error message when a \protect\cs{edtext} is done without insert (note)}
% \changes{v1.12.8}{2014/09/12}{\protect\cs{flag@start} do not send a error message when a \protect\cs{edtext} is done without insert (note) but have a endnote}
% We enclose a lemma marked by \protect\cs{edtext} in
% \protect\cs{flag@start} and \protect\cs{flag@end}: these send the \protect\cs{@ref}
% command to the line-list file. \protect\cs{edtext} is responsible for
% setting the value of \protect\cs{insert@count} appropriately; it
% actually gets done by the various footnote macros.
%    \begin{macrocode}
\newif\if@noneed@Footnote%

\newcommand*{\flag@start}{%
  \ifledRcol%
    \edef\next{\write\linenum@outR{%
                  \string\@ref[\the\insert@countR][}}%
    \next%
    \ifnum\insert@countR<1%
      \if@noneed@Footnote\else%
        \led@err@EdtextWithoutFootnote%
      \fi%
    \fi%
  \else%
    \edef\next{\write\linenum@out{%
                  \string\@ref[\the\insert@count][}}%
    \next%
    \ifnum\insert@count<1%
      \if@noneed@Footnote\else%
        \led@err@EdtextWithoutFootnote%
      \fi%
    \fi%
  \fi}%

\newcommand*{\flag@end}{%
  \ifledRcol%
    \write\linenum@outR{]}%
  \else%
    \write\linenum@out{]}%
  \fi}%


%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\flag@start@RTL}
% \begin{macro}{\flag@end@RTL}
% With \XeLaTeX, there is a problem when using RTL: the writing of a command in the numbered auxiliary files (\verb+.1+, \verb+.2+ etc) is reversed when the first argument of \cs{edtext} is typset in one line, but it is \textbf{not} reversed when this first argument is typset in two lines or more.\footnote{This problem is caused by the way \XeTeX\ manages right-to-left typsetting. David Carlisle explains it on \url{http://tex.stackexchange.com/a/333373/7712} and provides a potential solution, using \cs{vadjust}. However in some cases this adds spurious vertical spaces in reledmac. That is why we are using the solution explained below.}
%
% To solve this problem, we use a crossref mechanism. At the first run, we put a label, but we do not write any \cs{@ref} command. When the value of the label can be tested, that is after three runs, we're doing:
% \begin{itemize}
%  \item If the first argument of \cs{edtext} is typeset on only one line, we first call \cs{flag@end}, at the point we normally call \cs{flag@start}, at the beginning of the content of the first argument, and we call \cs{flag@end} at the point we normally call \cs{flag@start}, at the end of the content of the first argument.
%  \item If the first argument of \cs{edtext} is typeset on only two lines, we use the normal order.
% \end{itemize}
% This system is a workaround for the problem of order when writing in auxiliary files.
%
% The \cs{flag@start@RTL} and \cs{flag@end@RTL} macro put the label, do the test and call the right commands.
%    \begin{macrocode}
\newcommand{\flag@start@RTL}{%
  \edlabel{edtext:start:\csuse{thisedtext@\the\@edtext@level}}%
  \IfStrEq{\xabslineref{edtext:start:\csuse{thisedtext@\the\@edtext@level}}}%
    {000}%
    {}%
    {%
    \ifnumequal%
      {\xabslineref{edtext:start:\csuse{thisedtext@\the\@edtext@level}}}%
      {\xabslineref{edtext:end:\csuse{thisedtext@\the\@edtext@level}}}%
      {\flag@end}%
      {\flag@start}%
  }%
}%

\newcommand{\flag@end@RTL}{%
  \edlabel{edtext:end:\csuse{thisedtext@\the\@edtext@level}}%
  \IfStrEq{\xabslineref{edtext:start:\csuse{thisedtext@\the\@edtext@level}}}%
      {000}%
      {}%
      {%
      \ifnumequal%
        {\xabslineref{edtext:start:\csuse{thisedtext@\the\@edtext@level}}}%
        {\xabslineref{edtext:end:\csuse{thisedtext@\the\@edtext@level}}}%
        {\flag@start}%
        {\flag@end}%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\flag@start@later}
% \begin{macro}{\flag@end@later}
% \protect\cs{flag@start@later} and \protect\cs{flag@end@later}: these send the\cs{@ref@later} to the line-list file
% command to the line-list file
%    \begin{macrocode}
\newcommand*{\flag@start@later}{%
  \ifledRcol%
    \write\linenum@outR{\string\@ref@later[}%
  \else%
    \write\linenum@out{\string\@ref@later[}%
  \fi%
}%
\newcommand{\flag@end@later}{%
  \ifledRcol%
    \write\linenum@outR{]}%
  \else%
    \write\linenum@out{]}%
  \fi%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\startsub}
% \begin{macro}{\endsub}
% \changes{v1.15.0}{2015/01/12}{Restore subline feature (disabled by mistake in v1.8.0).}
% \protect\cs{startsub} and \protect\cs{endsub}
% turn sub-lineation on and off, by writing
% appropriate instructions to the line-list file.  When
% sub-lineation is in effect, the line number counter is frozen and
% the sub-line counter advances instead. If one of these commands
% appears in the middle of a line, it does not take effect until the
% next line; in other words, a line is counted as a line or
% sub-line depending on what it started out as, even if that
% changes in the middle.
%
% We tinker with \protect\cs{lastskip} because a command of either sort
% really needs to be attached to the last word preceding the change, not
% the first word that follows the change. This is because sub-lineation
% will often turn on and off in mid-line---stage directions, for example,
% often are mixed with dialogue in that way---and when a line is mixed
% we want to label it using the system that was in effect at its start.
% But when sub-lineation begins at the very start of a line we have a
% problem, if we don't put in this code.
%    \begin{macrocode}


\newcommand*{\startsub}{\dimen0\lastskip
  \ifdim\dimen0>0pt \unskip \fi
  \ifledRcol \write\linenum@outR{\string\sub@on}%
  \else      \write\linenum@out{\string\sub@on}%
  \fi
  \ifdim\dimen0>0pt \hskip\dimen0 \fi}
\def\endsub{\dimen0\lastskip
  \ifdim\dimen0>0pt \unskip \fi
  \ifledRcol \write\linenum@outR{\string\sub@off}%
  \else      \write\linenum@out{\string\sub@off}%
  \fi
  \ifdim\dimen0>0pt \hskip\dimen0 \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\advanceline}
% You can use \protect\cs{advanceline}\marg{num}
% in running text to advance the current visible
% line-number by a specified value, positive or negative.
%    \begin{macrocode}
\newcommand*{\advanceline}[1]{\leavevmode%
  \ifledRcol \write\linenum@outR{\string\@adv[#1]}%
  \else      \write\linenum@out{\string\@adv[#1]}%
  \fi%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setline}
% You can use \protect\cs{setline}\marg{num}
% in running text (i.e., within \protect\cs{pstart}...\protect\cs{pend}) to set the
% current visible
% line-number to a specified positive value.
%    \begin{macrocode}

\newcommand*{\setline}[1]{%
 \leavevmode%
  \ifnum#1<\z@
    \led@warn@BadSetline%
  \else%
    \ifledRcol%
      \write\linenum@outR{\string\@set[#1]}%
    \else%
      \write\linenum@out{\string\@set[#1]}%
    \fi%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setlinenum}
% You can use \protect\cs{setlinenum}\marg{num}
% before a \protect\cs{pstart} to set the visible line-number to a specified
% positive value. It writes a \protect\cs{l@d@set} command to the line-list file.
%    \begin{macrocode}

\newcommand*{\setlinenum}[1]{%
  \ifnum#1<\z@
    \led@warn@BadSetlinenum
  \else
    \ifledRcol \write\linenum@outR{\string\l@d@set[#1]}
    \else      \write\linenum@out{\string\l@d@set[#1]} \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\startlock}
% \begin{macro}{\endlock}
% You can use \protect\cs{startlock} or \protect\cs{endlock}
% in running text to start or end line number locking at
% the current line. They decide whether line numbers or sub-line numbers
% are affected, depending on the current state of the sub-lineation flags.
%    \begin{macrocode}

\newcommand*{\startlock}{%
  \ifledRcol \write\linenum@outR{\string\lock@on}%
  \else      \write\linenum@out{\string\lock@on}%
  \fi}
\def\endlock{%
  \ifledRcol \write\linenum@outR{\string\lock@off}%
  \else      \write\linenum@out{\string\lock@off}%
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifl@dskipnumber}
% \begin{macro}{\ifl@dskipversenumber}
% \begin{macro}{\l@dskipnumbertrue}
% \begin{macro}{\l@dskipnumberfalse}
% \begin{macro}{\skipnumbering}
% In numbered text \protect\cs{skipnumbering} will suspend the numbering
% for that particular line.
% \changes{v0.7.0}{2005/02/22}{Added \protect\cs{skipnumbering} and supports}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{skipnumbering} defined only one time for both \Eledmac{} and \Eledpar{}.}
% \changes{v1.21.0}{2015/04/13}{Correct \protect\cs{skipnumbering} for stanza.}
% \changes{v1.21.0}{2015/04/13}{Delete \protect\cs{skipnumbering@reg}.}
%    \begin{macrocode}
\newif\ifl@dskipnumber
\newif\ifl@dskipversenumber%
\newcommand*{\skipnumbering}{%
  \leavevmode%
  \ifledRcol%
    \ifinstanza%
       \write\linenum@outR{\string\n@num@stanza}%
    \else%
      \write\linenum@outR{\string\n@num}%
    \fi%
    \advanceline{-1}%
  \else%
    \ifinstanza%
       \write\linenum@out{\string\n@num@stanza}%
    \else%
      \write\linenum@out{\string\n@num}%
    \fi%
    \advanceline{-1}%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \section{Marking text for notes}
% \label{text}\relax
%
% The \protect\cs{edtext} macro is used to create all
% footnotes and endnotes,
% as well as to print the portion of the main text to which a given note
% or notes is keyed. The idea is to have that lemma appear only once in
% the \file{.tex} file: all instances of it in the main text and in the
% notes are copied from that one appearance.
%
% The \protect\cs{edtext} macro takes two arguments.
% \begin{verbatim}
%    \edtext{#1}{#2}
% \end{verbatim}
%
% \begin{itemize}\addtolength{\itemsep}{-1ex}
% \item \verb"#1" is the piece of the main text being glossed;
% it gets added to the
% main text, and is also used as a lemma for notes to it.
%
% \item \verb"#2" is a series of subsidiary macros that generate
% various kinds of notes.
% \end{itemize}
%
% The \protect\cs{edtext} macro may be used (somewhat) recursively; that
% is, \protect\cs{edtext} may be used within its own first argument. The
% code would be much simpler without this feature, but nested notes
% will commonly be necessary: it is quite likely that we will have an
% explanatory note for a long passage and notes on variants for
% individual words within that passage. The situation we can't
% handle is overlapping notes that are not nested: for example, one
% note covering lines 10--15, and another covering 12--18.
% You can
% handle such cases by using the \protect\cs{lemma} and \protect\cs{linenum}
% macros within \verb"#2": they alter the copy of the lemma and the
% line numbers that are passed to the notes, and hence allow you to
% overcome any limitations of this system, albeit with extra
% effort.
%
% The recursive operation of \protect\cs{edtext} will fail if you try to use a copy
% that is called something other than \protect\cs{edtext}. In order to handle
% recursion, \protect\cs{edtext} needs to redefine its own definition temporarily
% at one point, and that does not work if the macro you are calling is
% not actually named \protect\cs{edtext}. There  is no problem as long as \protect\cs{edtext}
% is not invoked in the first argument. If you want to call \protect\cs{edtext}
% something else, it is best to create instead a macro that expands
% to an invocation of \protect\cs{edtext}, rather than copying \protect\cs{edtext} and giving
% it a new name; otherwise you will need to add an appropriate
% definition for your new macro to \protect\cs{morenoexpands}.
%
% Side-effects of our line-numbering code make it impossible to use
% the usual footnote macros directly within a paragraph whose lines are
% numbered (see comments to
% \protect\cs{do@line}, \reff{doline}).
% Instead, the appropriate note-generating command
% is appended to the list macro \protect\cs{inserts@list}, and when \protect\cs{pend}
% completes the paragraph it inserts all the notes at the proper places.
%
%
% Note that we do not provide previous-note information, although it is
% often wanted; your own macros must handle that. We ca not do it
% correctly without keeping track of what kind of notes have gone past:
% it is not just a matter of remembering the line numbers associated with
% the previous invocation of \protect\cs{edtext}, because that might have been for
% a different kind of note. It is preferable for your footnote macros
% to store and recall this kind of information if they need it.
%
%
% \subsection{\protect\cs{edtext}
%  itself}
%
% The various note-generating macros might want to request that
% commands be executed not at once, but in close connection with the
% start or end of the lemma. For example, footnote numbers in the text
% should be connected to the end of the lemma; or, instead of a single
% macro to create a note listing variants, you might want to use
% several macros in series to create individual variants, which would
% each add information to a private macro or token register, which in
% turn would be formatted and output when all of \verb"#2" for the lemma
% has been read.
%
% \begin{macro}{\end@lemmas}
% To accomodate this, we provide a list macro
% to which macros may add commands that should subsequently
% be executed at the end of the lemma when that lemma is added
% to the text of the paragraph. A macro should add its contribution to
% \protect\cs{end@lemmas} by using \protect\cs{xleft@appenditem}.
% (Anything that needs to be done at
% the \emph{start} of the lemma may be handled using \protect\cs{aftergroup}, since
% the commands specified within \protect\cs{edtext}'s second argument are
% executed within a group that ends just before the lemma is added to
% the main text.)
%
% \protect\cs{end@lemmas} is intended for the few things that need to be
% associated with the end of the lemma, like footnote numbers. Such
% numbers are not implemented in the current version, and indeed
% no use is currently made of \protect\cs{end@lemmas} or of the \protect\cs{aftergroup}
% trick. The general
% approach would be to define a macro to be used within the second
% argument of \protect\cs{edtext} that would add the appropriate command to
% \protect\cs{end@lemmas}.
%
% Commands that are added to this list should always take care
% not to do anything that adds possible line-breaks to the output;
% otherwise line numbering could be thrown off.
%    \begin{macrocode}
\list@create{\end@lemmas}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dummy@edtext}
% We now need to define a number of macros that allow us to weed out
% nested instances of \protect\cs{edtext}, and other problematic macros, from
% our lemma. This is similar to what we did in reading the line-list
% file using \protect\cs{dummy@ref} and various redefinitions---and that is
% because nested \protect\cs{edtext}s macros create nested \protect\cs{@ref} entries
% in the line-list file.
%
%
%    \begin{macrocode}
\newcommand{\dummy@edtext}[2]{#1}
%    \end{macrocode}
%
% \end{macro}
% \begin{macro}{\dummy@edtext@showlemma}
% Some time, we want to obtain only the first argument of \protect\cs{edtext}, while also wrapping it in \protect\cs{showlemma}. For example, when printing a \protect\cs{eledsection}.
%    \begin{macrocode}
\newcommand{\dummy@edtext@showlemma}[2]{\showlemma{#1}}%
%    \end{macrocode}
% \end{macro}
%
% We are going to need another macro that takes one argument and ignores
% it entirely. This is supplied by the \LaTeX\ \protect\cs{@gobble}\marg{arg}.
%
% \begin{macro}{\no@expands}
% \begin{macro}{\morenoexpands}
% We need to turn off macro expansion for certain sorts of macros we are
% likely to see within the lemma and within the notes.
%
% The first class is font-changing macros. We suppress expansion for
% them by letting them become equal to zero.\footnote{Since `control
% sequences equivalent to characters are not expandable'---\thetexbook,
% answer to Exercise 20.14.} This is done because we want to
% pass into our notes the generic commands to change to roman or
% whatever, and not their expansions that will ask for a particular style at
% a specified size.  The notes may well be in a smaller font, so the
% command should be expanded later, when the note's environment is in
% effect.
%
% A second sort to turn off includes a few of the accent macros.
% Most are not a problem: an accent that is expanded to an \protect\cs{accent}
% command may be harder to read but it works just the same. The
% ones that cause problems are: those that use alignments---\TeX\
% seems to get confused about the difference between alignment
% parameters and macro parameters; those that use temporary control
% sequences; and those that look carefully at what the current font
% is.
%
% (The \protect\cs{copyright} macro defined in \PlainTeX\ has this sort of
% problem as well, but is not used enough to bother with. That macro,
% and any other that causes trouble, will get by all right if you put
% a \protect\cs{protect} in front of it in your file.)
%
% We also need to eliminate all \macpackage\ macros like \protect\cs{edlabel} and
% \protect\cs{setline} that write things to auxiliary files: that writing
% should be done only once. And we make
% \protect\cs{edtext} itself, if it appears within its own
% argument, do nothing but copy its first argument.
%
% Finally, we execute \protect\cs{morenoexpands}. The version of
% \protect\cs{morenoexpands} defined here does nothing; but you may define
% a version of your own when you need to add more expansion
% suppressions as needed with your macros. That makes it possible
% to make such additions without needing to copy or modify the
% standard \macpackage\ code. If you define your own
% \protect\cs{morenoexpands}, you must be very careful about spaces: if the
% macro adds any spaces to the text when it runs, extra space
% will appear in the main text when \protect\cs{edtext} is used.
%
%
% The \cs{new@series} command also adds \cs{let}\cs{footnote\meta{X}}\cs{@gobble} to the end of the \cs{no@expands} macro for the series \meta{X}.
%
% (A related problem, not addressed by these two macros,
% is that of characters whose category code are changed by any of
% the macros used in the arguments to \protect\cs{edtext}. Since the
% category codes are set when the arguments are scanned, macros
% that depend on changing them will not work. We have most often
% encountered this with characters that are made `active' within
% text in some, but not all, of the languages used within the document.
% One way around the problem, if it takes this form,
% is to ensure that those characters are \emph{always} active. Within
% languages that make no special use of them, their associated
% control sequences should simply return the proper character. A simpler solution is to avoid active characters, using \LuaTeX\ or \XeLaTeX.)
% \changes{v0.2.0}{2003/07/25}{Added \protect\cs{l@dtabnoexpands} to \protect\cs{no@expands}}
% \changes{v0.2.1}{203/08/25}{Removed some \protect\cs{let}s from \protect\cs{no@expands}.
%    These were in \edmac{} but Peter Wilson feels that they should not have been as they
%    disabled page/line refs in a footnotes}
% \changes{v1.0.0}{2012/09/15}{Change to be compatible with new features}
%    \begin{macrocode}
\newcommand*{\no@expands}{%
  \let\select@@lemmafont=0%
  \let\startsub=\relax  \let\endsub=\relax
  \let\startlock=\relax \let\endlock=\relax
  \let\edlabel=\@gobble
  \let\setline=\@gobble \let\advanceline=\@gobble
  \let\sameword\sameword@inedtext%
  \let\edtext=\dummy@edtext
  \let\edindex\dummy@edindex%
  \l@dtabnoexpands
  \l@noexpands@edgl%
  \let\linenumannotation=\@gobble%
  \morenoexpands}
\let\morenoexpands=\relax

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@tag}
% Now, we define an empty \protect\cs{@tag} command. It will be redefine by \protect\cs{edtext}: its value is the first argument. It will be used by the \protect\cs{Xfootnote} commands.
%    \begin{macrocode}
\newcommand{\@tag}{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@edtext@level}
% \changes{v1.15.0}{2015/01/12}{New boolean \protect\cs{if@edtext@}.}
% \changes{v1.23.0}{2015/05/18}{The boolean \protect\cs{if@edtext@} becomes the counter \protect\cs{edtext@level}.}
% This counter is increased by 1 at each level of \protect\cs{edtext}.
%    \begin{macrocode}
\newcount\@edtext@level%
\@edtext@level=0%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\if@edtext@secondarg@}
% This boolean is set to TRUE before reading the second argument of a \cs{edtext}.
% It is tested on some macro which must be executed only inside a second argument.
%    \begin{macrocode}
\newif\if@edtext@secondarg@%
%    \end{macrocode}
% \end{macro}
% \changes{v1.16.0}{2014/01/23}{\protect\cs{edtext} is now defined only in \eledmac, not in \eledpar. Debug wrong numbering when using \protect\cs{sameword} + \protect\package{eledpar} + \protect\cs{tag} command.}
%
%
% \begin{macro}{\theedtext}
% The \verb+edtext+ counter is increased at each \cs{edtext} command.
% It is used to add to insert hyperlinks between a notes and the lemma.
%    \begin{macrocode}
\newcounter{edtext}
\renewcommand{\theedtext}{edtxt@\the\c@edtext}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\edtext}
% \changes{v0.4.0}{2004/02/29}{Added \protect\cs{showlemma} to \protect\cs{edtext}}
% \changes{v1.4.0}{2012/11/16}{Compatibility of \protect\cs{edtext} with the right-to-left direction (with Polyglossia).}
% \changes{v1.17.0}{2015/02/09}{Error message when calling \protect\cs{edtext} outside of a numbered paragraph.}
% When executed, \protect\cs{edtext} first ensures that we are in
% horizontal mode.
%    \begin{macrocode}
\newcommand{\edtext}[2]{\leavevmode%
%    \end{macrocode}
% Then, check if we are in a numbered paragraph (\protect\cs{pstart}\ldots\protect\cs{pend})..
%    \begin{macrocode}
  \ifnumberedpar@%
%    \end{macrocode}
% Check the content of the arguments, to be certain there is no forbidden command inside.
%    \begin{macrocode}%
      \@check@edtext@args{#1}{#2}%
%    \end{macrocode}
% We increment the \cs{@edtext@level} \TeX\ counter to know in which level of \protect\cs{edtext} we are.
%    \begin{macrocode}
      \global\advance\@edtext@level by 1%
%    \end{macrocode}
% We also increase the \verb+edtext+ \LaTeX\ counter to insert a hypertarget if the \package{hyperref} package is loaded, and also works with \cs{edtext} on right-to-left typesetting with \XeLaTeX.
%
% We store the value for the current level in a global macro. So we have one macro by level of \cs{edtext}. That is required, because \cs{edtext} can contain \cs{edtext}.
%    \begin{macrocode}
      \stepcounter{edtext}%
      \csxdef{thisedtext@\the\@edtext@level}{\theedtext}%
%    \end{macrocode}
% By default, we do not use \protect\cs{lemma}
%    \begin{macrocode}
      \global\@lemmacommand@false%
%    \end{macrocode}
%    \begin{macrocode}
      \begingroup%
%    \end{macrocode}
% We get the next series of samewords data in the list of samewords data for the current edtext level. We push them inside \protect\cs{sw@inthisedtext}.
%    \begin{macrocode}
        \ifledRcol%
          \ifcsvoid{sw@list@edtextR@\the\@edtext@level}%
                {\global\let\sw@inthisedtext\empty}%
                {\expandafter\gl@p\csname sw@list@edtextR@\the\@edtext@level\endcsname\to\sw@inthisedtext}%
        \else%
          \ifcsvoid{sw@list@edtext@\the\@edtext@level}%
                {\global\let\sw@inthisedtext\empty}%
                {\expandafter\gl@p\csname sw@list@edtext@\the\@edtext@level\endcsname\to\sw@inthisedtext}%
        \fi%
%    \end{macrocode}
% \begin{macro}{\@tag}
% \label{@tag}Our normal lemma is just argument \verb"#1"; but that argument could have
% further invocations of \protect\cs{edtext} within it. We get a copy of the
% lemma without any \protect\cs{edtext} macros within it by temporarily redefining
% \protect\cs{edtext} to just copy its first argument and ignore the other,
% and then expand \verb"#1" into \protect\cs{@tag}, our lemma.
%
% This is done within a group that starts here, in order to get the
% original \protect\cs{edtext} restored; within this group we have also turned
% off the expansion of those control sequences commonly found within text
% that can cause trouble for us.
%
%    \begin{macrocode}
        \global\renewcommand{\@tag}{%
          \no@expands #1%
        }%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\l@d@nums}
% \phantomsection\label{nums}
% Prepare more data for the benefit of note-generating macros: the line
% references and font specifier for this lemma go to \protect\cs{l@d@nums}.
%    \begin{macrocode}
        \set@line%
%    \end{macrocode}
% \end{macro}
% \protect\cs{insert@count} will be altered by the note-generating macros:
% it counts the number of deferred footnotes or other insertions
% generated by this instance of \protect\cs{edtext}.
% If we are in a right column (\parpackage), we use \protect\cs{insert@countR}
% instead of \protect\cs{insert@count}.
%    \begin{macrocode}
        \ifledRcol \global\insert@countR \z@%
        \else      \global\insert@count \z@ \fi%
%    \end{macrocode}
% Now process the note-generating macros in argument \verb"#2"
% (i.e., \protect\cs{Afootnote}, \protect\cs{lemma}, etc.). \protect\cs{ignorespaces} is here to
% skip over any spaces that might appear at the start of \verb"#2";
% otherwise they wind up in the main text. Footnote and other
% macros that are used within \verb"#2" should all end with
% \protect\cs{ignorespaces} as well, to skip any spaces between macros when
% several are used in series.
%    \begin{macrocode}
        \@edtext@secondarg@true%
        \ignorespaces #2\relax%
        \@edtext@secondarg@false%
%    \end{macrocode}
% With \XeLaTeX, you must track whether the language reads left to right (English) or right to left (Arabic). \reledmac defines an \cs{if@RTL} boolean test is not already defined.
%    \begin{macrocode}
        \if@RTL%
          \flag@start@RTL%
        \else%
          \flag@start%
        \fi%
%    \end{macrocode}
% We write in the numbered file wether the current \protect\cs{edtext} has a \protect\cs{lemma} in the the second argument.
%    \begin{macrocode}
       \if@lemmacommand@%
         \ifledRcol%
           \write\linenum@outR{\string\@lemma}%
         \else%
           \write\linenum@out{\string\@lemma}%
         \fi%
       \fi%
%    \end{macrocode}
% Finally, we are ready to admit the first argument into the current
% paragraph.
%
% It is important that we generate and output all the notes for this
% chunk of text \emph{before} putting the text into the paragraph: notes
% that are referenced by line number should generally be tied to the
% start of the passage they gloss, not the end. That should all be done
% within the expansion of \verb"#2" above, or in \protect\cs{aftergroup}
% commands within that expansion.
%    \begin{macrocode}
      \endgroup%
      \ifdef{\hypertarget}%
        {%
        \Hy@raisedlink@left{\hypertarget{\csuse{thisedtext@\the\@edtext@level}:start}{}}%
        \showlemma{#1}%
        \Hy@raisedlink{\hypertarget{\csuse{thisedtext@\the\@edtext@level}:end}{}}%
        }%
        {%
        \showlemma{#1}%
        }%
%    \end{macrocode}
%
% Finally, we add any insertions that are
% associated with the \emph{end} of
% the lemma. Footnotes that are identified by symbols rather than by
% where the lemma begins in the main text need to be done here, and
% not above.
%
%    \begin{macrocode}
      \ifx\end@lemmas\empty \else%
        \gl@p\end@lemmas\to\x@lemma%
        \x@lemma%
        \global\let\x@lemma=\relax%
      \fi%
      \if@RTL%
        \flag@end@RTL%
      \else%
        \flag@end%
      \fi%
%    \end{macrocode}
% We switch some flags to false.
% \begin{itemize}
%    \item The one that checks having footnotes inside a \protect\cs{edtext}.
%    \item The one that says we are inside a \protect\cs{edtext}. In fact, it is not a flag, but a counter which is increased to 1 in each leavel of \protect\cs{edtext}.
%    \item The one that says we are inside a \protect\cs{@lemma}.
% \end{itemize}
%    \begin{macrocode}
      \global\@noneed@Footnotefalse%
      \global\advance\@edtext@level by -1%
      \global\@lemmacommand@false%
%    \end{macrocode}
% We also reset \cs{@beforeinsertofthisedtext}
%    \begin{macrocode}
      \global\let\@beforeinsertofthisedtext\relax%
%    \end{macrocode}
% If we are outside of a numbered paragraph,
% we send an error message and print the first argument.
%    \begin{macrocode}
  \else%
  \showlemma{#1} (\textbf{\textsc{Edtext outside numbered paragraph}})\led@err@edtextoutsidepstart%
  \fi%
}%


%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@check@edtext@args}
% A macro which just checks the arguments of the \cs{edtext} and let know
% if there is some probleme, like, for example, \cs{pstart} inside.
%    \begin{macrocode}
\newcommand{\@check@edtext@args}[2]{%
  \begingroup%
    \noexpandarg%
    \IfSubStr{#1}{\pstart}{\led@err@PstartInEdtext{first}}{}%
    \IfSubStr{#1}{\pend}{\led@err@PendInEdtext{first}}{}%
    \IfSubStr{#2}{\pstart}{\led@err@PstartInEdtext{second}}{}%
    \IfSubStr{#2}{\pend}{\led@err@PendInEdtext{second}}{}%
  \endgroup%
}%
%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@beforeinsertofthisedtext}
% \cs{@beforeinsertofthisedtext} is an internal macro. \macpackage\ or \parpackage can add in this macro any content required to be executed before doing any \cs{insert} related to a \cs{edtext}.
% Its content is \cs{let} equal to \cs{relax} at the end of every \cs{edtext}.
%    \begin{macrocode}
\let\@beforeinsertofthisedtext\relax
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ifnumberline}
% The \protect\cs{ifnumberline} option can be set to FALSE to disable line numbering.
%  \begin{macrocode}
\newif\ifnumberline
\numberlinetrue
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\set@line}
% The \protect\cs{set@line} macro
% is called by \protect\cs{edtext} to put the line-reference field and
% font specifier for the current block of text into \protect\cs{l@d@nums}.
%
% One instance of \protect\cs{edtext} may generate several notes, or it
% may generate none\,---\,it is legitimate for argument \verb"#2" to \protect\cs{edtext} to
% be empty. But \protect\cs{flag@start} and \protect\cs{flag@end} induce the generation of
% a single entry in \protect\cs{line@list} during the next run, and it is vital
% to also remove one and only one \protect\cs{line@list} entry here.
%
% If no more lines are listed in \protect\cs{line@list}, something is
% wrong\,---\,probably just some change in the input. We set all the numbers
% to zeros, following an old publishing convention for numerical
% references that have not yet been resolved.
%    \begin{macrocode}
\newcommand*{\set@line}{%
  \ifledRcol
    \ifx\line@listR\empty
      \global\noteschanged@true
      \xdef\l@d@nums{000|000|000|000|000|000|\edfont@info}%
    \else
      \gl@p\line@listR\to\@tempb
      \xdef\l@d@nums{\@tempb|\edfont@info}%
      \global\let\@tempb=\undefined
    \fi
    \ifx\annot@listR\empty%
      \xdef\l@current@annotR{|}%
    \else%
      \gl@p\annot@listR\to\@tempb%
      \xdef\l@current@annotR{\@tempb}%
      \global\let\@tempb=\undefined%
    \fi%
  \else
    \ifx\line@list\empty
      \global\noteschanged@true
      \xdef\l@d@nums{000|000|000|000|000|000|\edfont@info}%
    \else
      \gl@p\line@list\to\@tempb
      \xdef\l@d@nums{\@tempb|\edfont@info}%
      \global\let\@tempb=\undefined
    \fi
    \ifx\annot@list\empty%
      \xdef\l@current@annot{|}%
    \else%
      \gl@p\annot@list\to\@tempb%
      \xdef\l@current@annot{\@tempb}%
      \global\let\@tempb=\undefined%
    \fi%
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\edfont@info}
% The macro \protect\cs{edfont@info} returns coded information about the
% current font.
%
%    \begin{macrocode}
\newcommand*{\edfont@info}{\f@encoding/\f@family/\f@series/\f@shape}

%    \end{macrocode}
% \end{macro}
%
% \subsection{Substitute lemma}
%
% \begin{macro}{\lemma}
% \changes{v1.23.0}{2015/05/18}{Fix spurious space after \protect\cs{lemma} command}
% The \protect\cs{lemma}\marg{text} macro allows you to change the lemma
% that is passed on to the notes.
% Read about \protect\cs{@tag} in normal \protect\cs{edtext} macro for more details about \protect\cs{sw@list@inedtext} and \protect\cs{no@expands} (\reff{@tag}).
%    \begin{macrocode}
\newcommand*{\lemma}[1]{%
  \global\@lemmacommand@true%
  \global\renewcommand{\@tag}{%
    \no@expands #1%
  }%
  \ignorespaces%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@lemma}
% The \protect\cs{@lemma} is written in the numbered file to set which \protect\cs{edtext} has an
% \protect\cs{lemma} as second argument.
%    \begin{macrocode}
\newcommand{\@lemma}{%
  \booltrue{lemmacommand@\the\@edtext@level}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\if@lemmacommand@}
% \changes{v1.15.0}{2015/01/12}{New boolean \protect\cs{iflemmacommand@}.}
% This boolean is set to TRUE inside a \protect\cs{edtext} (or \protect\cs{critext}) when a \protect\cs{lemma} command is called.
% That is useful for some commands which can have a different behavior if the lemma in the note is different from the lemma in the main text.
%    \begin{macrocode}
\newif\if@lemmacommand@%
%    \end{macrocode}
% \end{macro}
% \subsection{Substitute line numbers}
%
% \begin{macro}{\linenum}
% \label{linenumdef}
% The \protect\cs{linenum} macro can change any or all of
% the page and line numbers that are
% passed on to the notes.
%
% As argument \protect\cs{linenum} takes a set of seven parameters
% separated by vertical bars, in the format used internally for
% \protect\cs{l@d@nums} (see \reff{linenumbers}): the starting page,
% line, and sub-line numbers, followed by the ending page, line, and
% sub-line numbers, and then the font specifier for the lemma.
% However, you can omit any parameters you do not want to change, and
% you can omit a string of vertical bars at the end of the
% argument. Hence \verb"\linenum{18|4|0|18|7|1|0}" is an invocation
% that changes all the parameters, but \verb"\linenum{|3}" only
% changes the starting line number, and leaves the rest unaltered.
%
% We use \verb"\\" as an internal separator for the macro parameters.
%    \begin{macrocode}
\newcommand*{\linenum}[1]{%
  \xdef\@tempa{#1|||||||\noexpand\\\l@d@nums}%
  \global\let\l@d@nums=\empty
  \expandafter\line@set\@tempa|\\\ignorespaces}
%    \end{macrocode}
%
% \begin{macro}{\line@set}
% \protect\cs{linenum} calls \protect\cs{line@set} to do the actual work; it
% looks at the first number in the argument to \protect\cs{linenum},
% sets the corresponding value in \protect\cs{l@d@nums}, and then calls
% itself to process the next number in the \protect\cs{linenum}
% argument, if there are more numbers in \protect\cs{l@d@nums} to process.
%    \begin{macrocode}
\def\line@set#1|#2\\#3|#4\\{%
  \gdef\@tempb{#1}%
  \ifx\@tempb\empty
        \l@d@add{#3}%
  \else
        \l@d@add{#1}%
  \fi
  \gdef\@tempb{#4}%
  \ifx\@tempb\empty\else
      \l@d@add{|}\line@set#2\\#4\\%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@d@add}
% \protect\cs{line@set} uses \protect\cs{l@d@add} to tack numbers or vertical bars
% onto the right hand end of \protect\cs{l@d@nums}.
%    \begin{macrocode}
\newcommand{\l@d@add}[1]{\xdef\l@d@nums{\l@d@nums#1}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lineannot}
% \begin{macro}{\lineannot@set}
% Last but not least, \cs{lineannot} allows us to substitute line number annotation. It is different from \cs{linenum} for backward compatibility with older versions of \macpackage. It calls \cs{lineannot@set} to determine whether we must change only one annotation or two, or none.
%    \begin{macrocode}
\newcommand*{\lineannot}[1]{%
  \lineannot@set#1|%
}%
\def\lineannot@set#1|#2|{%
  \expandafter\parse@annot#1|#2|%
  \IfStrEq{#1}{}%
    {\let\@tempa\annot@start}%
    {\def\@tempa{#1}}%
  \IfStrEq{#2}{}%
    {\let\@tempb\annot@start}%
    {\def\@tempb{#2}}%
  \xdef\l@current@annot{\@tempa|\@tempb}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Lemma disambiguation}
% The mechanism which counts the occurrence of a same word in a same line is quite complex, because, when \LaTeX\ reads a command between a \protect\cs{pstart} and a \protect\cs{pend}, it does not know yet which are the line numbers.
%
% The general mechanism is the following:
% \begin{itemize}
%    \item \textbf{At the first run}, each \protect\cs{sameword} command increments an \protect\package{etoolbox} counter the name of which contains the argument of the \protect\cs{sameword} commands.
%    \item Then this counter associated with the argument of \protect\cs{sameword} is stored with the \protect\cs{@sw} command in the auxiliary file of the current \macpackage\ section (the \verb+.1+, \verb+.2+\ldots\ file).
%    \item \textbf{When this auxiliary file is read at the second run}, different operations are achieved:
%  \begin{enumerate}
%         \item  Get the rank of each \protect\cs{sameword} in a line (relative rank) from the rank of each \protect\cs{sameword} in all the numbered section (absolute rank):
%         \begin{itemize}
%            \item For each paired \protect\cs{sameword} argument and absolute line number, a counter is defined. Its value corresponds to the number of times \protect\cs{sameword}\marg{argument} is called from the beginning of  the lineation to the end of the current line. We also store the same data for the preceding absolute line number, if it does not have \protect\cs{sameword}\marg{argument}.
%            \item  For each \protect\cs{sameword} having the same argument,  we subtract from its absolute rank the number stored for the paired \protect\cs{sameword} argument and previous absolute line number. Consequently, we obtain the relative rank.
%             \item See the following example which explains how, for same \protect\cs{sameword}, absolute ranks are transformed to relative ranks.
%  \begin{verbatim}
%  At line 1:
%  absolute rank 1 becomes relative rank 1-0 = 1
%  1 is stored for this \sameword and line 1
%  At line 2:
%  absolute rank 2 becomes relative rank 2-1 = 1
%  absolute rank 3 becomes relative rank 3-1 = 2
%  3 is stored for this \sameword and line 2
%  At line 3:
%  no \sameword for this line.
%  3 is stored for this \sameword and line 3
%  At line 4:
%  absolute rank 4 becomes relative rank 4-3 = 1
%  4 is stored for this \sameword and line 4
%  \end{verbatim}
%        \end{itemize}
%        \item Create lists of lists of \protect\cs{sameword} by depth of \protect\cs{edtext}.
% That is: create a list for \protect\cs{edtext}s of level~1, a list for \protect\cs{edtext}s of level~2, a list for \protect\cs{edtext}s of level~3 etc.
% For each \protect\cs{edtext} in these lists, we store all of the relative ranks of \protect\cs{saweword} which are called as lemma information. That is: 1) either called in the first argument of \protect\cs{sameword}, or, 2) called in the \protect\cs{lemma} macro of the second argument of \protect\cs{sameword} AND marked by the optional argument of \protect\cs{saweword} in first argument of \protect\cs{edtext}.
%
% For example, suppose a line with nested \protect\cs{edtext}s which contains some
% word marked by \protect\cs{sameword} and having the following relative rank:\\
%
%
%\let\up\textsuperscript
%bar\up{1} \fbox{%
%      \fbox{foo\up{1} foo\up{2} bar\up{2} foo\up{3}} (A)(B)
%      foo\up{4} bar\up{3}%
%   } (C)
%   \fbox{%
%      \fbox{foo\up{5}} (D)
%      bar\up{4}
%   } (E)
%
% In this example, all lemma information for \protect\cs{edtext} is framed. The text in parenthesis is the content of critical notes associated to the preceding frame.
% As you can see, we have two levels of \protect\cs{edtext}.
%
%The list for \protect\cs{edtext}s of level~1 is $\{\{1,2,2,3,4,3\},\{5,4\}\}$.
%
%The list for \protect\cs{edtext}s of level~2 is $\{\{1,2,2,3\},\{5\}\}$.
%
% As you can see, the mandatory argument of \protect\cs{sameword} does not matter: we store the rank informations for every word potentially ambiguous.
%      \end{enumerate}
%  \item At the second run, when a critical notes is called, we associate it to the next item of the list associated to its \protect\cs{edtext} level. So, in the previous example:
%  \begin{itemize}
%      \item Critical notes (A) and (B) are associated with $\{1,2,2,3\}$.
%      \item Critical note (C) is associated with $\{1,2,2,3,4,3\}$.
%      \item Critical note (D) is associated with $\{5\}$.
%      \item Critical note (E) is associated with $\{5,4\}$.
%  \end{itemize}
%  \item At the second run, when a critical note is printed:
%    \begin{itemize}
%         \item The \protect\cs{sameword} command is let  \protect\cs{sameword@inedtext}.
%          \item At each call of this \protect\cs{sameword@inedtext}, we step to the next element of the list associated to the note. Let it be $r$.
%        \item For the word marked by \protect\cs{sameword}, we calculate how many time it is called in its line. To do it:
%          \begin{itemize}
%            \item We get the absolute line number of the current \protect\cs{sameword}. This absolute line number was stored with a list of relative ranks for the current \protect\cs{edtext}. That means, in the previous example, that if the absolute line number of \protect\cs{edtext} was 1, that critical notes (A) and (B) were not associated with  $\{1,2,2,3\}$ but with $\{(1,1),(2,1),(2,1),(3,1)\}$. Such a method of knowing the absolute line number associated to a \protect\cs{sameword} is required because a \protect\cs{edtext} can overlap many lines, but \protect\cs{sameword} can't get it.
%            \item When reading the auxiliary file, we get the value associated to the pair composed by the current marked word and the current absolute line number. To this value, we subtract the value associated to the pair composed by the current marked word and the previous absolute line number. Let the result be $n$.
%          \end{itemize}
%        \item If $n >1 $, that means the current word appears more than once in its line. In this case, we call \protect\cs{showwordrank} with the word as the first argument and $r$ as the second argument. If the word is called only once, we just print it.
%   \end{itemize}
% \end{itemize}
% After theory, implementation.
% First, getting a sanitized form of the argument of \cs{sameword}
% \begin{macro}{\get@sw@txt}
%    \begin{macrocode}
\newcommand{\get@sw@txt}[1]{%
  \begingroup%
    \swnoexpands%
%.   \end{macrocode}
% Using case sensibility option.
%    \begin{macrocode}
    \ifsw@caseinsensitive%
      \def\@tmpa##1{\lowercase{##1}}%
    \else%
      \def\@tmpa##1{##1}%
    \fi%
%    \end{macrocode}
% And now, define \cs{sw@txt}.
%   \begin{macrocode}
      \@tmpa{\protected@xdef\sw@txt{#1}}%
  \endgroup%
}%
%    \end{macrocode}
% \end{macro}
% Allow some macros inside \cs{sameword}.
% We use \cs{RenewExpandableDocumentCommand} to get expandable command with optional argument.
% Cf. \url{https://tex.stackexchange.com/a/384783/7712}.
% \begin{macro}{\sw@noexpand}
%    \begin{macrocode}
\newcommand{\swnoexpands}{%
    \let\sameword\l@secondmandarg%Allow to have nested \sameword
    \let\emph\@firstofone%
    \let\textit\@firstofone%
    \let\textbf\@firstofone%
    \let\textsc\@firstofone%
    \let\framebox\@firstofone%
    \let\edtext\dummy@edtext%
    \RenewExpandableDocumentCommand{\edindex}{om}{}%
    \ifdefined\index%
      \RenewExpandableDocumentCommand{\index}{om}{}%
    \fi%
    \let\selectlanguage\@gobble%
    \let\foreignlanguage\@secondoftwo%
    \ifdefined\xpg@loaded%
      \renewcommand\do[1]{%
        \expandafter\RenewExpandableDocumentCommand\expandafter{\csname text##1\endcsname}{om}{####2}%
      }%
      \expandafter\docsvlist\expandafter{\xpg@loaded}%
    \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\sameword}
% \changes{v1.23.0}{2015/05/18}{In order to allow use of \protect\cs{sameword} with inputenc, we detokenize its mandatory argument before using it in control sequence names.}
% The hight level macro \protect\cs{sameword}, used by the editor.
%    \begin{macrocode}
\newcommandx{\sameword}[2][1,usedefault]{%
     \ifxetex%
       \if@RTL%
        \led@err@samewordRTL%
       \fi%
     \fi%
     \leavevmode%
     \get@sw@txt{#2}%
%    \end{macrocode}
% Now, the real code. First, increment the counter corresponding to the argument.
%    \begin{macrocode}
  \unless\ifledRcol%
     \csnumgdef{sw@\sw@txt}{\csuse{sw@\sw@txt}+\@ne}%
%    \end{macrocode}
% Then, write its value to the numbered file.
%    \begin{macrocode}
     \protected@write\linenum@out{}{\string\@sw{\sw@txt}{\csuse{sw@\sw@txt}}{#1}}%
%    \end{macrocode}
% Do the same thing if we are in the right column.
%    \begin{macrocode}
  \else%
     \csnumgdef{sw@\sw@txt}{\csuse{sw@\sw@txt}+\@ne}%
     \protected@write\linenum@outR{}{\string\@sw{\sw@txt}{\csuse{sw@\sw@txt}}{#1}}%
  \fi%
%    \end{macrocode}
% And print the word.
%    \begin{macrocode}
  #2%
}%
%    \end{macrocode}
% \end{macro}
% A flag set to true if a \protect\cs{@sw} relative rank must be added to the list of ranks for a specific \protect\cs{edtext}.
% \begin{macro}{\if@addsw}
%    \begin{macrocode}
\newif\if@addsw%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@sw}
% The command printed in the auxiliary files.
%    \begin{macrocode}
\newcommand{\@sw}[3]{%
  \get@sw@txt{#1}%
  \unless\ifledRcol%
%    \end{macrocode}
% First, define a counter which store the second argument as value for a each paired absolute line number/first argument
%    \begin{macrocode}
    \csxdef{sw@\sw@txt @\the\absline@num @\the\section@num}{#2}%
%    \end{macrocode}
% If  such argument was not defined for the preceding line, define it.
%    \begin{macrocode}
    \numdef{\prev@line}{\the\absline@num-1}%
    \ifcsundef{sw@\sw@txt @\prev@line @\the\section@num}{%
      \csnumgdef{sw@\sw@txt @\prev@line @\the\section@num}{#2-1}%
     }{}%
%    \end{macrocode}
% Then, calculate the position of the word in the line.
%    \begin{macrocode}
    \numdef{\the@sw}{#2-\csuse{sw@\sw@txt @\prev@line @\the\section@num}}%
%    \end{macrocode}
% And do the same thing for the right side.
%    \begin{macrocode}
  \else%
    \csxdef{sw@\sw@txt @\the\absline@numR @\the\section@numR @R}{#2}%
    \numdef{\prev@line}{\the\absline@numR-1}%
    \ifcsundef{sw@\sw@txt @\prev@line @\the\section@numR @R}{%
      \csnumgdef{sw@\sw@txt @\prev@line @\the\section@numR @R}{#2-1}%
     }{}%
    \numdef{\the@sw}{#2-\csuse{sw@\sw@txt @\prev@line @\the\section@numR @R}}%
  \fi%
%    \end{macrocode}
%  And now, add it to the list of \protect\cs{@sw} for the current edtext, in all depth.
%    \begin{macrocode}
  \@tempcnta=\@edtext@level
  \@whilenum{\@tempcnta>0}\do{%
    \ifcsdef{sw@list@edtext@tmp@\the\@tempcnta}%
      {%
        \@addswfalse%
        \notbool{lemmacommand@\the\@tempcnta}%
          {\@addswtrue}%
          {\IfStrEq{#3}{inlemma}%
            {\@addswtrue}%
            {%
             \def\do##1{%
                \ifnumequal{##1}{\the\@tempcnta}%
                  {\@addswtrue\listbreak}%
                  {}%
             }%
             \docsvlist{#3}%
            }%
          }%
          \if@addsw%
            \letcs{\@tmp}{sw@list@edtext@tmp@\the\@tempcnta}%
            \ifledRcol%
              \xright@appenditem{{\the@sw}{\the\absline@numR}}\to\@tmp%
            \else%
              \xright@appenditem{{\the@sw}{\the\absline@num}}\to\@tmp%
            \fi%
            \cslet{sw@list@edtext@tmp@\the\@tempcnta}{\@tmp}%
          \fi%
      }%
      {}%
    \advance\@tempcnta by -1%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\sameword@inedtext}
% The command called when \protect\cs{sameword} is called in a \protect\cs{edtext}.
%    \begin{macrocode}
\newcommandx{\sameword@inedtext}[2][1,usedefault]{%
  \get@sw@txt{#2}%
  \unless\ifledRcol@%
%    \end{macrocode}
% Just a precaution.
%    \begin{macrocode}
      \ifx\sw@list@inedtext\empty%
        \def\the@sw{999}%
        \def\this@absline{-99}%
      \else%
%    \end{macrocode}
% But in many cases, at this step, we should have some content in the list \protect\cs{sw@list@inedtext}, which contains the reference for \protect\cs{edtext}.
%    \begin{macrocode}
        \gl@p\sw@list@inedtext\to\@tmp%
        \edef\the@sw{\expandafter\@firstoftwo\@tmp}%
        \edef\this@absline{\expandafter\@secondoftwo\@tmp}%
      \fi%
%    \end{macrocode}
% First, calculate the number of occurrences of the word in the current line
%    \begin{macrocode}
      \ifcsdef{sw@\sw@txt @\this@absline @\the\section@num}{%
        \numdef{\prev@line}{\this@absline-1}%
        \numdef{\sw@atthisline}{\csuse{sw@\sw@txt @\this@absline @\the\section@num}-\csuse{sw@\sw@txt @\prev@line @\the\section@num}}%
        }%
        {\numdef{\sw@atthisline}{0}}%
%    \end{macrocode}
% Finally, print the rank, but only if there is more than one occurrence of the word in the current line.
%    \begin{macrocode}
      \ifnumgreater{\sw@atthisline}{1}%
          {\showwordrank{#2}{\the@sw}}%
          {#2}%
%    \end{macrocode}
% And the same for right side.
%    \begin{macrocode}
  \else%
      \ifx\sw@list@inedtext\empty%
        \def\the@sw{999}%
        \def\this@absline{-99}%
      \else%
        \gl@p\sw@list@inedtext\to\@tmp%
        \edef\the@sw{\expandafter\@firstoftwo\@tmp}%
        \edef\this@absline{\expandafter\@secondoftwo\@tmp}%
      \fi%
      \ifcsdef{sw@\sw@txt @\this@absline @\the\section@numR @R}{%
        \numdef{\prev@line}{\this@absline-1}%
        \numdef{\sw@atthisline}{\csuse{sw@\sw@txt @\this@absline @\the\section@numR @R}-\csuse{sw@\sw@txt @\prev@line @\the\section@numR @R}}%
        }%
        {\numdef{\sw@atthisline}{0}}%
        \ifnumgreater{\sw@atthisline}{1}%
          {\showwordrank{#2}{\the@sw}}%
          {#2}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\showwordrank}
% Finally, the way the rank will be printed.
%    \begin{macrocode}
\newcommand{\showwordrank}[2]{%
  #1\textsuperscript{#2}%
}%
%    \end{macrocode}
% \end{macro}

% \section{Paragraph decomposition and reassembly}
% \label{paragraph}\relax
%
% In order to be able to count the lines of text and affix line
% numbers, we add an extra stage of processing for each paragraph.
% We send the paragraph into a box
% register, rather than straight onto the vertical list, and when
% the paragraph ends we
% slice the paragraph into its component lines; to each line we
% add any notes or line numbers, add a command to write to the
% line-list, and then at last send the line to the vertical list.
% This section contains all the code for this processing.
%
% \subsection{Boxes, counters, \protect\cs{pstart}
% and \protect\cs{pend}}
%
% \begin{macro}{\raw@text}
% \begin{macro}{\ifnumberedpar@}
% \begin{macro}{\numberedpar@true}
% \begin{macro}{\numberedpar@false}
% \begin{macro}{\num@lines}
% \begin{macro}{\one@line}
% \begin{macro}{\par@line}
% Here are numbers and flags that are used internally in the course
% of the paragraph decomposition.
%
% When we first form the paragraph, it goes into a box register,
% \protect\cs{raw@text}, instead of onto the current vertical list.
% The \protect\cs{ifnumberedpar@} flag will be \verb"true" while a paragraph is
% being processed in that way.
% \protect\cs{num@lines} will store the number of lines in the paragraph
% when it is complete. When we chop it up into lines, each line
% in turn goes into the
% \protect\cs{one@line} register, and \protect\cs{par@line} will be the number
% of that line within the paragraph.
%    \begin{macrocode}
\newbox\raw@text
\newif\ifnumberedpar@
\newcount\num@lines
\newbox\one@line
\newcount\par@line
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pstarts@typeset@L}
% \begin{macro}{\pstarts@read@L}
% The \cs{pstarts@typeset@L} counts the number of LEFT \cs{pstart} typeset.
% A left \cs{pstart} can be a \cs{pstart} typeset in normal mode, or \cs{pstart} typset in left column or page in parallel mode (with{\parpackage}).
% In the first case, its value is increased at every \cs{pstart} command.
% In the second case, its value is increased in \cs{Columns} or \cs{Pages} when we prepare to typeset a left \cs{pstart}.
% The \cs{pstarts@readL} counts the number of LEFT \cs{pstart} read.
% A left \cs{pstart} can be a  \cs{pstart} typeset in normal mode, or \cs{pstart} typset in left column or page in parallel mode (with{\parpackage}).
% In the first case, its value is increased at every \cs{pstart} command.
% In the second case, its value is increased at every \cs{pstarL}.
%
%    \begin{macrocode}
\newcount\pstarts@typeset@L%
\newcount\pstarts@read@L%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\pstart}
% \begin{macro}{\AtEveryPstart}
% \begin{macro}{\AtStartEveryPstart}
% \changes{v1.6.1}{2013/10/27}{Spurious space in \protect\cs{pstart}.}
% \changes{v1.12.0}{2014/08/05}{New optional argument for \protect\cs{pstart}, to execute code before it.}
% \begin{macro}{\numberpstarttrue}
% \begin{macro}{\numberpstartfalse}
% \begin{macro}{\labelpstarttrue}
% \begin{macro}{\labelpstartfalse}
% \begin{macro}{\thepstart}
% \begin{macro}{\ifat@every@pstart@star@}
% \protect\cs{pstart} starts the paragraph by
% clearing the \protect\cs{inserts@list} list and other
% relevant variables, and then arranges for the
% subsequent text to go into the
% \protect\cs{raw@text} box. \protect\cs{pstart} needs to appear at the start of
% every paragraph that is to be numbered; the \protect\cs{autopar} command below
% may be used to insert these commands automatically.
%
% Beware: everything that occurs between \protect\cs{pstart} and \protect\cs{pend}
% is happening within a group; definitions must be global if you want
% them to survive past the end of the paragraph.
% \changes{v1.13.1}{2014/09/25}{Add \protect\cs{l@dzeropenalties} in \protect\cs{pstart}}
%    \begin{macrocode}

\newcommand{\AtStartEveryPstart}[1]{%
  \ifstrempty{#1}%
    {\gdef\@at@start@every@pstart{}}%
    {\gdef\@at@start@every@pstart{#1}}%
}%
\def\@at@start@every@pstart{}%

\newif\ifat@every@pstart@star@%
\newcommand{\AtEveryPstart}[1]{%
  \ifstrempty{#1}%
    {\gdef\at@every@pstart{}}%
    {\gdef\at@every@pstart{\noindent#1}}%
 \global\at@every@pstart@star@false%
}%
\WithSuffix\newcommand\AtEveryPstart*[1]{%
  \ifstrempty{#1}%
    {\gdef\at@every@pstart{}}%
    {\gdef\at@every@pstart{#1}}%
  \global\at@every@pstart@star@true%
}%
\def\at@every@pstart{}%

\newcounter{pstart}
\renewcommand{\thepstart}{{\bfseries\@arabic\c@pstart}. }
\newif\ifnumberpstart
\numberpstartfalse
\newif\iflabelpstart
\labelpstartfalse
\newcommandx*{\pstart}[2][1,2,usedefault]{%
  \normal@pars%
  \ifboolexpr{%
    test {\ifstrempty{#1}}%
    and test {\ifstrempty{#2}}%
  }%
    {\at@every@pstart}%
    {%
    \ifstrempty{#1}{}{\noindent#1}%
    \ifstrempty{#2}{}{#2}%
    }%
  \ifautopar%
    \autopar%
  \fi%
  \ifluatex%
    \edef\l@luatextextdir@L{\the\textdir}%
  \fi%
  \@nobreaktrue%
  \ifnumbering \else%
    \led@err@PstartNotNumbered%
    \beginnumbering%
  \fi%
  \ifnumberedpar@%
    \led@err@PstartInPstart%
    \pend%
  \fi%
  \list@clear{\inserts@list}%
  \global\let\next@insert=\empty%
  \begingroup\normal@pars%
  \global\advance \l@dnumpstartsL\@ne
  \global\advance \pstarts@typeset@L\@ne%
  \global\advance \pstarts@read@L\@ne%
  \global\setbox\raw@text=\vbox\bgroup%
    \if@nobreak%
      \if@afterindent\else%
        \noindent%
        \global\@afterindenttrue%
      \fi%
    \fi%
    \ifboolexpr{%
      bool{autopar}%
      and  bool{by@autopar}%
    }%
    {}%
    {%
      \ifnumberpstart%
        \ifinstanza\else%
           \ifsidepstartnum\else%
             \thepstart%
           \fi%
        \fi%
      \fi%
    }%
  \numberedpar@true%
  \iflabelpstart%
    \protected@edef\@currentlabel{\p@pstart\thepstart}%
  \fi%
  \l@dzeropenalties%
  \@at@start@every@pstart%
  \global\by@autoparfalse%
  \ignorespaces%because not automatically ignored if an optional argument is used (classical TeX behavior for space after commands)
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\pend}
% \changes{v1.12.0}{2014/08/05}{New optional argument for \protect\cs{pend}, to execute code after it.}
% \changes{v1.6.1}{2013/10/27}{Spurious space in \protect\cs{pend}.}
% \protect\cs{pend} must be used to end a numbered paragraph.
%
%    \begin{macrocode}
\newcommandx*{\pend}[2][1,2,usedefault]{\ifnumbering \else%
    \led@err@PendNotNumbered%
  \fi%
  \global\l@dskipversenumberfalse%
  \ifnumberedpar@ \else%
    \led@err@PendNoPstart%
  \fi%
%    \end{macrocode}
% We set all the usual interline penalties to zero and then immediately
% call \protect\cs{endgraf} to end the paragraph; this ensures that there will
% be no large interline penalties to prevent us from slicing the
% paragraph into pieces. These penalties revert to the values
% that you set when the group for the \protect\cs{vbox} ends. Then we call
% \protect\cs{do@line} to slice a line off the top of the
% paragraph, add a line number and footnotes, and restore it to the page;
% we keep doing this until there are not any more lines left.
%    \begin{macrocode}
  \l@dzeropenalties%
  \@at@end@every@pend%
  \endgraf\global\num@lines=\prevgraf\egroup%
  \global\par@line=0%
  \get@firsthalf@antilabe@wd%
%    \end{macrocode}
% Output the lines.
%    \begin{macrocode}
  \loop\ifvbox\raw@text%
    \do@line%
  \repeat%
%    \end{macrocode}
% Deal with any leftover notes, and then end the group that was begun
% in the \protect\cs{pstart}.
%    \begin{macrocode}
  \flush@notes%
  \endgroup%
  \ignorespaces%
%    \end{macrocode}
% Increase pstart counter.
%    \begin{macrocode}
  \ifnumberpstart%
     \global\pstartnumtrue%
  \fi%
  \addtocounter{pstart}{1}%
  \ifcontinuousnumberingwithcolumns%
    \addtocounter{pstartL}{1}%
    \addtocounter{pstartR}{1}%
  \fi%
%    \end{macrocode}
% Print the optional arguments of \protect\cs{pend} or the content printed after every \protect\cs{pend}
%    \begin{macrocode}
  \normal@pars%
  \ifboolexpr{%
    test {\ifstrempty{#1}}%
    and test {\ifstrempty{#2}}%
  }%
    {\at@every@pend}%
    {%
    \ifstrempty{#1}{}{\noindent#1}%
    \ifstrempty{#2}{}{#2}%
    }%
%    \end{macrocode}
% Restore standard \enquote{nobreak} and \enquote{autopar} settings.
% Normally, \cs{if@nobreak} is true only immediately after a sectioning command (see latex.ltx file). As a \cs{pstart}\ldots\  \cs{pend} structure can't contain any sectioning command, we set \cs{if@nobreak} to false.
%    \begin{macrocode}
  \@nobreakfalse%
  \ifautopar%
    \autopar%
  \fi%
%    \end{macrocode}
% At the very end, we check if the lineation is made by \cs{pstart}. In this case, we reset the line number, using \cs{setlinenum}, as we are, technically, already out of \cs{pstart}\cs{pend} structure.
%    \begin{macrocode}
    \ifbypstart@%
       \begingroup%
         \let\leavevmode\relax%
         \setlinenum{0}%
       \endgroup%
       \resetprevline@%
    \fi%
}
%    \end{macrocode}
% \end{macro}
% Here, two macros to insert content after every \protect\cs{pend}, between numbered line.
% \protect\cs{AtEveryPend} is the user macro, \protect\cs{at@every@pend} is macro set by it.
%
% \begin{macro}{\AtEveryPend}
% \begin{macro}{\at@every@pend}
% \begin{macro}{\ifat@every@pend@star@}
%    \begin{macrocode}


\newif\ifat@every@pend@star@%
\newcommand{\AtEveryPend}[1]{%
  \ifstrempty{#1}%
    {\gdef\at@every@pend{}}%
    {\gdef\at@every@pend{\noindent#1}}%
  \global\at@every@pend@star@false%
}%
\WithSuffix\newcommand\AtEveryPend*[1]{%
  \ifstrempty{#1}%
    {\gdef\at@every@pend{}}%
    {\gdef\at@every@pend{#1}}%
  \global\at@every@pend@star@true%
}%
\xdef\at@every@pend{}%

%    \end{macrocode}
%  \end{macro}
%  \end{macro}
% \end{macro}
%
% \begin{macro}{\AtEndEveryPend}
% Here a macro to insert automatically any content at the end of \cs{pend}, in numbered lines.
%    \begin{macrocode}
\newcommand{\AtEndEveryPend}[1]{%
  \ifstrempty{#1}%
    {\xdef\@at@end@every@pend{}}%
    {\gdef\@at@end@every@pend{#1}}%
}%
\def\@at@end@every@pend{}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\l@dzeropenalties}
% A macro to zero penalties for \protect\cs{pend} or \protect\cs{pstart}.
% \changes{v0.7.0}{2005/02/22}{Added \protect\cs{l@dzeropenalties}}
%    \begin{macrocode}
\newcommand*{\l@dzeropenalties}{%
  \brokenpenalty \z@ \clubpenalty \z@
  \displaywidowpenalty \z@ \interlinepenalty \z@ \predisplaypenalty \z@
  \postdisplaypenalty \z@ \widowpenalty \z@}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\autopar}
% In most cases it is only an annoyance to have to label the paragraphs
% to be numbered with \protect\cs{pstart} and \protect\cs{pend}. \protect\cs{autopar} will
% do that automatically, allowing you to start a paragraph with its
% first word and no other preliminaries, and to end it with a blank line
% or a \protect\cs{par} command. The command should be issued within a
% group, after \protect\cs{beginnumbering} has been used to start the
% numbering; all paragraphs within the group will be affected.
%
% A few situations can cause problems. One is a paragraph that begins with
% a begin-group character or command: \protect\cs{pstart} will not get invoked
% until after such a group beginning is processed; as a result the
% character that ends the group will be mistaken for the end of the
% \protect\cs{vbox} that \protect\cs{pstart} creates, and the rest of the paragraph
% will not be numbered. Such paragraphs need to be started explicitly
% using \protect\cs{indent}, \protect\cs{noindent}, or \protect\cs{leavevmode}\,---\,or \protect\cs{pstart}, since
% you can still include your own \protect\cs{pstart} and \protect\cs{pend}
% commands even with \protect\cs{autopar} on.
%
% Prematurely ending the group within which \protect\cs{autopar} is in
% effect will cause a similar problem. You must either leave a
% blank line or use \protect\cs{par} to end the last paragraph before
% you end the group.
%
% The functioning of this macro is more tricky than the usual
% \protect\cs{everypar}: we do not want anything to go onto the vertical
% list at all, so we have to end the paragraph, erase any evidence
% that it ever existed, and start it again using \protect\cs{pstart}.
% We remove the paragraph-indentation box using \protect\cs{lastbox} and
% save the width, and then skip backwards over the \protect\cs{parskip}
% that has been added for this paragraph. Then we start again with
% \protect\cs{pstart}, restoring the indentation that we saved, and
% locally change \protect\cs{par} so that it will do our \protect\cs{pend} for us.
%
% The boolean \cs{ifautopar} is set to TRUE while \cs{autopar} is enabled, and the \cs{ifby@autopar} is set to TRUE at each \cs{pstart} automatically called by the \cs{autopar} feature. A manual \cs{pstart} will have a \cs{ifby@autopar} set to FALSE.
%
%    \begin{macrocode}
\newif\ifautopar
\newif\ifby@autopar%
\newcommand*{\autopar}{
  \ifledRcol
    \ifnumberingR \else
    \led@err@AutoparNotNumbered
    \beginnumberingR
    \fi
    \else
    \ifnumbering \else
    \led@err@AutoparNotNumbered
    \beginnumbering
    \fi
  \fi
  \autopartrue
  \everypar{\setbox0=\lastbox
    \endgraf \vskip-\parskip
    \global\by@autopartrue%
    \pstart \noindent \kern\wd0%
    \ifnumberpstart%
      \ifinstanza\else%
        \thepstart%
      \fi%
    \fi%
    \let\par=\pend}%
  \ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normal@pars}
% We also define a macro which we can rely on to turn off the
% \protect\cs{autopar} definitions at various important places, if they
% are in force. We will want to do this within a footnotes, for
% example.
%    \begin{macrocode}
\newcommand*{\normal@pars}{\everypar{}\let\par\endgraf}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifautopar@pause}
% We define a boolean test switched to true at the beginning
% of the \protect\cs{pausenumbering} command if the autopar is enabled.
% This boolean will be tested at the beginning of \protect\cs{resumenumbering}
% to continue the autopar if neeeded.
%    \begin{macrocode}
\newif\ifautopar@pause
%    \end{macrocode}
% \end{macro}
% \subsection{Processing one line}
%
% \subsubsection{General process}
% \begin{macro}{\do@line}\label{doline}
% \begin{macro}{\l@dunhbox@line}
% The \protect\cs{do@line} macro is called by \protect\cs{pend} to
% do all the processing for a single line of text.
% \changes{v1.6.1}{2013/10/27}{Move the call to \protect\cs{inserthangingsymbol} to allow use \protect\cs{hfill} inside.}
% \changes{v1.12.2}{2014/08/07}{Fix a bug with critical notes at the tops of pages (added by v12.0.0)}
% The \cs{l@dunhbox@line} macro only \cs{unhbox}es one line, but packages like \cs{microtype} can override it as required.
%
%    \begin{macrocode}
 \newcommand*{\l@dunhbox@line}[1]{\unhbox #1}
 \newcommand*{\do@line}{%
  {\vbadness=10000
   \splittopskip=\z@
   \do@linehook
\l@demptyd@ta
   \global\setbox\one@line=\vsplit\raw@text to\baselineskip}%
  \unvbox\one@line \global\setbox\one@line=\lastbox
  \getline@num
  \IfStrEq{\led@pb@setting}{before}{\led@check@pb\led@check@nopb}{}
  \ifnum\@lock>\@ne
    \inserthangingsymboltrue
  \else
    \inserthangingsymbolfalse
  \fi
  \check@pb@in@verse
  \ifl@dhidenumber%
    \global\l@dhidenumberfalse%
    \f@x@l@cks%
  \else%
    \affixline@num%
  \fi%
%    \end{macrocode}
% \changes{v1.12.0}{2014/08/05}{\protect\cs{do@line} is split in more little commands.}
% Depending weither a sectioning command is called at this pstart or not
% we print sectioning command or normal line,
%    \begin{macrocode}
  \xifinlist{\the\pstarts@typeset@L}{\eled@sections@@}%
     {\print@eledsection}%
     {\print@line}%
  \IfStrEq{\led@pb@setting}{after}{\led@check@pb\led@check@nopb}{}
  }%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Process for ``normal'' line}
% \begin{macro}{\print@line}
% \changes{v1.13.1}{2014/09/25}{Coming back of add@penalties, mistakenly deleted in version 0.17!}
% \changes{v1.18.0}{2015/02/23}{Compatibility with \LuaLaTeX\ RTL languages.}
% \protect\cs{print@line} is for normal line, i. e line without sectioning command.
%    \begin{macrocode}
\def\print@line{
%    \end{macrocode}
% Insert the pstart number inside, if we are in the first line of a pstart.
%    \begin{macrocode}
    \affixpstart@num%
%    \end{macrocode}
% The line will be boxed, to have the good width.
%    \begin{macrocode}
    \hb@xt@ \linewidth{%
%    \end{macrocode}
% User hooks.
%    \begin{macrocode}
        \do@insidelinehook%
        \csuse{insidethis@\the\absline@num @\the\section@num}%
        \global\csundef{insidethis@\the\absline@num @\the\section@num}%
%    \end{macrocode}
% Left line number
%    \begin{macrocode}
        \l@dld@ta%
%    \end{macrocode}
% Prepare text to be inserted before notes.
%    \begin{macrocode}
        \if@firstlineofpage%
          \set@Xtxtbeforenotes%
          \set@txtbeforenotesX%
          \global\@firstlineofpagefalse%
        \fi%
%    \end{macrocode}
% Insert footnotes made of manuscripts data and critical footnotes.
%    \begin{macrocode}
        \ifdefstring{\ms@data@position}{msdata-regular}{%
          \insert@msdata%
          \add@inserts%
          \add@Xgroupbyline%
        }{%
          \add@inserts%
          \add@Xgroupbyline%
          \insert@msdata%
        }%
%    \end{macrocode}
% Insert marginal notes.
%    \begin{macrocode}
        \affixside@note%
%    \end{macrocode}
% Print left notes.
%    \begin{macrocode}
        \l@dlsn@te
%    \end{macrocode}
% Boxes the line, writes information about new line in the numbered file.
%    \begin{macrocode}
        {\ledllfill\hb@xt@ \wd\one@line{%
          \new@line%
%    \end{macrocode}
% If we use the \option{continuousnumberingwithcolumns}, we increase right line number.
%    \begin{macrocode}
        \continuousnumberingwithcolumns@sync@linenumber@singletext%
%    \end{macrocode}
% If we use \LuaLaTeX\, then restore the direction.
%    \begin{macrocode}
          \ifluatex%
            \textdir\l@luatextextdir@L%
          \fi%
%    \end{macrocode}
% Insert, if needed, the hanging symbol.
%    \begin{macrocode}
          \inserthangingsymbol%
%    \end{macrocode}
% And so, print the line.
%    \begin{macrocode}
          \l@dunhbox@line{\one@line}}%
%    \end{macrocode}
% Right line number
%    \begin{macrocode}
          \ledrlfill\l@drd@ta%
%    \end{macrocode}
% Print right notes.
%    \begin{macrocode}
          \l@drsn@te%
      }}%
%    \end{macrocode}
%   And reinsert penalties (for page breaking)...
%    \begin{macrocode}
    \add@penalties%
}
%    \end{macrocode}
% \end{macro}
% \subsubsection{Process for line containing \protect\cs{eledsection} command}
% \begin{macro}{\print@eledsection}
% \protect\cs{print@eledsection} to print sectioning command with line number.
% It sets the correct spacing, depending whether a sectioning command was called at previous \protect\cs{pstart}, calls the sectioning command, prints the normal line outside of the paper, to be able to have critical footnotes.
% Because of how this prints, a vertical spacing correction is added.
%    \begin{macrocode}
\def\print@eledsection{%
    \disable@edindex%
    \if@firstlineofpage%
      \set@Xtxtbeforenotes%
      \set@txtbeforenotesX%
      \global\@firstlineofpagefalse%
    \fi%
    \ifdefstring{\ms@data@position}{msdata-regular}{%
      \insert@msdata%
      \add@inserts%
      \add@Xgroupbyline%
    }{%
      \add@inserts%
      \add@Xgroupbyline%
      \insert@msdata%
    }%
    \affixside@note%
    \numdef{\temp@}{\pstarts@typeset@L-1}%
    \xifinlist{\temp@}{\eled@sections@@}{\@nobreaktrue}{\@nobreakfalse}%
    \@eled@sectioningtrue%
    \csuse{eled@sectioning@\the\pstarts@typeset@L}%
    \@eled@sectioningfalse%
    \global\csundef{eled@sectioning@\the\pstarts@typeset@L}%
    \if@RTL%
      \hspace{-3\paperwidth}%
    {\hbox{\l@dunhbox@line{\one@line}} \new@line}%
    \else%
      \hspace{3\paperwidth}%
    {\new@line \hbox{\l@dunhbox@line{\one@line}}}%
    \fi%
    \vskip-\baselineskip%
    \continuousnumberingwithcolumns@sync@linenumber@singletext%
    \restore@edindex%
}
%    \end{macrocode}
% \end{macro}
% \subsubsection{Hooks}
% \begin{macro}{\do@linehook}
% \begin{macro}{\do@insidelinehook}
% Two hooks into \protect\cs{do@line}. The first is called at the beginning of \protect\cs{do@line}, the second is called in the line box.
% The second can, for example, have a \protect\cs{markboth} command inside, the first ca not.
% \changes{v0.7.0}{2005/02/18}{Added \protect\cs{do@linehook} for use in \protect\cs{do@line}}
% \changes{v1.5.0}{2013/07/11}{Added \protect\cs{do@insidelinehook} for use in \protect\cs{do@line}}
%    \begin{macrocode}
\newcommand*{\do@linehook}{}
\newcommand*{\do@insidelinehook}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\dolinehook}
% \begin{macro}{\doinsidelinehook}
% These hight level commands just redefine the low level commands.
% They have to be used be user, without \protect\cs{makeatletter}.
% \changes{v1.12.5}{2014/08/31}{Added \protect\cs{dolinehook} and \protect\cs{doinsidelinehook}}
%    \begin{macrocode}
\newcommand*{\dolinehook}[1]{\gdef\do@linehook{#1}}%
\newcommand*{\doinsidelinehook}[1]{\gdef\do@insidelinehook{#1}}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\doinsidethislinehook}
% \begin{macro}{\@insidethisline}
% The \cs{doinsidethislinehook} can be called directly in the main flood of a text.
% It will define a hook executed at a specific line, determined by the position of the command in the flood of the text.
%    \begin{macrocode}
\newcommand{\doinsidethislinehook}[1]{%
  \leavevmode%In case it begins with a \pstart, ensure the \@insidethisline is written after \@nl
  \ifledRcol%
    \write\linenum@outR{\string\@insidethisline[\unexpanded{#1}]}%
  \else%
    \write\linenum@out{\string\@insidethisline[\unexpanded{#1}]}%
  \fi%
}%
%    \end{macrocode}
% The auxiliary files command just store the information to be executed
% when typesseting the specific line.
%    \begin{macrocode}
\newcommand{\@insidethisline}[1]{%
  \ifledRcol%
    \csgappto{insidethisR@\the\absline@numR @\the\section@numR}{#1}%
  \else%
    \csgappto{insidethis@\the\absline@num @\the\section@num}{#1}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsubsection{Sidenotes and marginal line number initialization}
% \begin{macro}{\l@demptyd@ta}
% \begin{macro}{\l@dld@ta}
% \begin{macro}{\l@drd@ta}
% \begin{macro}{\l@dcsnotetext}
% \begin{macro}{\l@dcsnotetext@l}
% \begin{macro}{\l@dcsnotetext@r}
%  Nulls the \protect\cs{...d@ta}, which may later hold line numbers.
% Similarly for \protect\cs{l@dcsnotetext}, \protect\cs{l@dcsnotetext@l}, \protect\cs{l@dcsnotetext@r} for the texts of the sidenotes, left and right notes.
% \changes{v0.7.0}{2005/02/18}{Added \protect\cs{l@demptyd@ta}}
%    \begin{macrocode}
\newcommand*{\l@demptyd@ta}{%
  \gdef\l@dld@ta{}%
  \gdef\l@drd@ta{}%
  \gdef\l@dcsnotetext@l{}%
  \gdef\l@dcsnotetext@r{}%
  \gdef\l@dcsnotetext{}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dlsn@te}
% \begin{macro}{\l@drsn@te}
% Zero width boxes of the left and right sidenotes, together with their kerns, and, eventually, with additional space if we are in parallel columns typesetting.
% \changes{v0.7.0}{2005/02/18}{Added \protect\cs{l@dlsn@te} and \protect\cs{l@drsn@te}
%              for use in \protect\cs{do@line}}
%    \begin{macrocode}
\newcommand{\l@dlsn@te}{%
  \ifboolexpr{%
      bool {l@dprintingcolumns}%
      and bool {ledRcol@}%
  }{%  If we are on a right column
    \@tempdima=\@morespace@leftnote@rightcolumn%
  }{%
    \@tempdima=\z@%
  }%
  \hb@xt@ \z@{\hss\box\l@dlp@rbox\kern\ledlsnotesep\hskip\@tempdima}%
}%
\newcommand{\l@drsn@te}{%
  \ifboolexpr{%
      bool {l@dprintingcolumns}%
      and not bool {ledRcol@}%
  }{%  If we are on a left column
    \@tempdima=\@morespace@rightnote@leftcolumn%
  }{%
    \@tempdima=\z@%
  }%
  \hb@xt@ \z@{\hskip\@tempdima\kern\ledrsnotesep\box\l@drp@rbox\hss}%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\ledllfill}
% \begin{macro}{\ledrlfill}
%  These macros are called at the left (\protect\cs{ledllfill}) and the right
% (\protect\cs{ledllfill}) of each numbered line. The initial definitions
% correspond to the original code for \protect\cs{do@line}.
%    \begin{macrocode}
\newcommand*{\ledllfill}{\hfil}
\newcommand*{\ledrlfill}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{Line and page number computation}
%
% \begin{macro}{\getline@num}
% The \protect\cs{getline@num} macro
% determines the page and line numbers for the line we are about to
% send to the vertical list.
%    \begin{macrocode}
\newcommand*{\getline@num}{%
  \global\advance\absline@num \@ne%
  \do@actions
  \do@ballast
  \ifnumberline
      \ifsublines@
         \ifnum\sub@lock<\tw@
           \global\advance\subline@num \@ne
         \fi
      \else
        \ifnum\@lock<\tw@
           \global\advance\line@num \@ne
           \global\subline@num \z@
        \fi
      \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\do@ballast}
% \phantomsection\label{do@ballast}\relax
% The real work in the macro above is done in \protect\cs{do@actions}, but
% before we plunge into that, let's get \protect\cs{do@ballast} out of the
% way.  This macro looks to see if there is an action to be
% performed on the \emph{next} line, and if it is going to be a
% page break action, \protect\cs{do@ballast} decreases the count \protect\cs{ballast@count}
% counter
% by the amount of \verb"ballast".  This means, in practice, that when
% \protect\cs{add@penalties} assigns penalties at this point, \TeX\ will be
% given extra encouragement to break the page here (see
% \reff{add@penalties}).
%
% \begin{macro}{\ballast@count}
% \begin{macro}{\c@ballast}
% First we set up the required counters; they are initially
% set to zero, and will remain so unless you type
% \verb"\setcounter{ballast}"\marg{some figure} in your document.
%    \begin{macrocode}
\newcount\ballast@count
\newcounter{ballast}
  \setcounter{ballast}{0}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% And here is \protect\cs{do@ballast} itself. It advances \protect\cs{absline@num}
% within the protection of a group to make its check for what
% happens on the next line.
%    \begin{macrocode}
\newcommand*{\do@ballast}{\global\ballast@count \z@
  \begingroup
    \advance\absline@num \@ne
    \ifnum\next@actionline=\absline@num
      \ifnum\next@action>-1001\relax
        \global\advance\ballast@count by -\c@ballast
       \fi
     \fi
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\do@actions}
% \begin{macro}{\do@actions@next}
%
% The \protect\cs{do@actions} macro
% looks at the list of actions to take at particular absolute line
% numbers, and does everything that is specified for the current line.
%
% It may call itself recursively, and to do this efficiently (using
% \TeX's optimization for tail recursion), we define a control-sequence
% called \protect\cs{do@actions@next} that is always the last thing that
% \protect\cs{do@actions} does. If there could be more actions to process for
% this line, \protect\cs{do@actions@next} is set equal to \protect\cs{do@actions};
% otherwise it is just \protect\cs{relax}.
% \changes{v0.7.0}{2005/02/22}{Added number skipping to \protect\cs{do@actions}}
%    \begin{macrocode}
\newcommand*{\do@actions}{%
  \global\let\do@actions@next=\relax
  \ifnum\absline@num<\next@actionline\else
%    \end{macrocode}
%
% First, page number changes, which will generally be the most common
% actions. If we are restarting lineation on each page, this is where it
% happens.
%    \begin{macrocode}
    \ifnum\next@action>-1001
       \global\page@num=\next@action
       \ifresumenumbering@start%
         \setbox0=\hbox{}%Required to get the correct page number, when the \resumenumbering is just after a \newpage
         \ifnum\pausenumbering@page@num<\page@num%
           \global\resumenumbering@startfalse%
         \fi%
       \fi%
       \ifboolexpr{%
      	  bool{resumenumbering@start}%
          and test {\ifdimgreater{\pagedepth}{\z@}}%
       }%
         {}%
         {\global\@firstlineofpagetrue}%
       \ifcsdef{reset@line\the\absline@num @\the\section@num}%
         {%
         \global\line@num=\z@%
         \global\subline@num=\z@%
         \resetprevline@%
         }%
         {}%
       \global\resumenumbering@startfalse%
       \add@msdata@firstlineofpage%
%    \end{macrocode}
%
% Next, we handle
% commands that change the line-number values. (We subtract $5001$ rather
% than $5000$ here because the line number is going to be incremented
% automatically in \protect\cs{getline@num}.)
%    \begin{macrocode}
    \else
       \ifnum\next@action<-4999
          \@l@dtempcnta=-\next@action
          \advance\@l@dtempcnta by -5001
          \ifsublines@
             \global\subline@num=\@l@dtempcnta
          \else
             \global\line@num=\@l@dtempcnta
          \fi
%    \end{macrocode}
%
%  We rescale the value in
% \protect\cs{@l@dtempcnta} so that we can use a case statement.
%    \begin{macrocode}
       \else
          \@l@dtempcnta=-\next@action
          \advance\@l@dtempcnta by -1000
          \do@actions@fixedcode
       \fi
    \fi
%    \end{macrocode}
%
% Now we get information about the next action off the list,
% and then set \protect\cs{do@actions@next} so that we will
% call ourself recursively: the next action might also be for this
% line.
%
% There is no warning if we find \protect\cs{actionlines@list} empty,
% since that will always happen near the end of the section.
%
%    \begin{macrocode}
    \ifx\actionlines@list\empty
         \gdef\next@actionline{1000000}%
    \else
         \gl@p\actionlines@list\to\next@actionline
         \gl@p\actions@list\to\next@action
         \global\let\do@actions@next=\do@actions
    \fi
  \fi
%    \end{macrocode}
%
% Make the recursive call, if necessary.
%
%    \begin{macrocode}
\do@actions@next}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\do@actions@fixedcode}
% This macro handles the fixed codes for \protect\cs{do@actions}. It is
% one big case statement.
% \changes{v0.7.0}{2005/02/24}{Added \protect\cs{do@actions@fixedcode}}
% \changes{v2.11.0}{2016/06/02}{Add action 1010}
%    \begin{macrocode}
\newcommand*{\do@actions@fixedcode}{%
  \ifcase\@l@dtempcnta
  \or%                     % 1001 = starting sublineation
    \global\sublines@true
  \or%                     % 1002 = ending sublineation
    \global\sublines@false
  \or%                     % 1003 = starting locking number
      \global\@lock=\@ne
  \or%                     % 1004 = ending locking number
    \ifnum\@lock=\tw@
      \global\@lock=\thr@@
    \else
      \global\@lock=\z@
    \fi
  \or%                     % 1005 = starting locking subnumber
     \global\sub@lock=\@ne
  \or%                     % 1006 = ending locking subnumber
    \ifnum\sub@lock=\tw@
      \global\sub@lock=\thr@@
    \else
      \global\sub@lock=\z@
    \fi
  \or%                     % 1007 = skipping numbering
    \l@dskipnumbertrue
  \or%                     % 1008 = skipping numbering in stanza
    \l@dskipversenumbertrue%
  \or%                    % 1009 = hiding number
    \l@dhidenumbertrue
  \or%                    % 1010 = inserting msdata
    \add@msdata%
  \else
    \led@warn@BadAction
  \fi}


%    \end{macrocode}
% \end{macro}
% \subsection{Continuous line numbering between parallel typesetting and normal typesetting}
% \begin{macro}{\continuousnumberingwithcolumns@sync@linenumber@singletext}
% The \option{continuousnumberingwithcolumns}
%  option allows to alternate between single text and two parallel texts, keeping the same line numbers when switching from one layout to the other.
% The lines counter for the text in a single column and for the text in the left column in parallel typesetting is the same.
% But the lines counter for the text in the same column is the not the same.
%
% When typesetting single column text, if the option is enabled, we need to \enquote{simulate} typesetting right line, in order to keep the two counters synchronized.
% That is the aim of the \\
% \cs{continuousnumberingwithcolumns@sync@linenumber@singletext}\\
% macro.
%    \begin{macrocode}
\newcommand{\continuousnumberingwithcolumns@sync@linenumber@singletext}{%
  \ifcontinuousnumberingwithcolumns%
    \unless\ifafterendnumberingR%
      \new@lineR%
      \xappto\next@line@list@stuffR{%
        \unexpanded{\global\line@numR=}\the\line@num%
      }%
    \fi%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \section{Line number annotation}
% The \cs{linenumannotation} allows users  to add manual annotations to line numbers, for example to refer to line numbers from an older edition.
%
% That implies that annotations be added
% \begin{itemize}
%  \item in marginal line numbers. This feature is implemented by associating annotations with the absolute line numbers when reading the auxiliary numbered files (\verb+.1+, \verb+.2+ etc.).
%  \item in critical footnotes. This feature is implemented by associating start / end line number annotations with each \cs{edtext} when reading the auxiliary numbered files.
% \item to crossref commands which refer to line numbers (to be completed when I will have resolved this issue).
% \end{itemize}
% \begin{macro}{\linenumannotation}
% First, the user-level command, which only writes commands to the numbered files, storing the annotation.
%    \begin{macrocode}
\newcommand{\linenumannotation}[1]{%
  \leavevmode%In case it begins with a \pstart, ensure the \@annot is written after \@nl
  \ifledRcol%
    \write\linenum@outR{\string\@annot[#1]}%
  \else%
    \write\linenum@out{\string\@annot[#1]}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Xlinenumannotationposition@side}
% The \cs{Xlinenumannotationposition@side} macro, to determine the position of line number annotations in lines printed in the side, relative to the line number position.
% The default value is \enquote{after}, but it can be changed to \enquote{before}, using the \cs{Xlinenumannotationposition} macro.
%    \begin{macrocode}
\def\Xlinenumannotationposition@side{after}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Xwraplinenumannotation@ref}
% \begin{macro}{\Xwraplinenumannotation@side}
% The  \cs{Xwraplinenumannotation@ref} macro is applied to line annotations in crossref. The \cs{Xwraplinenumannotation@side} macro is applied to line annotation in sides.
% They must be modified by users using \cs{Xwraplinenumannotation}.
% By default, they call \cs{textsuperscript}.
%
% We also define toggle \verb+Xnoidenticallinenumannotation@ref+ and \verb+Xnoidenticallinenumannotation@ref+
%    \begin{macrocode}
\def\Xwraplinenumannotation@ref{\textsuperscript}%
\def\Xwraplinenumannotation@side{\textsuperscript}%
\newtoggle{Xnoidenticallinenumannotation@ref}%
\newtoggle{Xnoidenticallinenumannotation@side}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\@annot}
% \begin{macro}{\store@annot@to@absline}
% Then, the numbered files command \cs{@annot}, which
% \begin{itemize}
%  \item associates the annotation to the absolute lines number.
%  \item stores the current annotation in a macro to be used by the \cs{@ref@reg} macro, which manages all things related to \cs{edtext} in numbered files. As we don't want to store it multiple times in the event of nested \cs{edtext}, we use an auxiliary macro, \cs{store@annot@to@absline}, which is set to \cs{@gobble} when we parse nested \cs{edtext} in numbered auxiliary files.
% \end{itemize}
%    \begin{macrocode}
\newcommand{\@annot}[1]{%
  \store@annot@to@absline{#1}%
  \def\current@annot{#1}%
}%
\newcommand{\store@annot@to@absline}[1]{%
  \ifledRcol%
    \ifcsdef{annotR@\the\absline@numR @\the\section@numR}{%
      \csgappto{annotR@\the\absline@numR @\the\section@numR}{\@linenumannotationsep#1}%
    }{%
      \csgdef{annotR@\the\absline@numR @\the\section@numR}{#1}%
    }%
  \else%
    \ifcsdef{annot@\the\absline@num @\the\section@num}{%
      \csgappto{annot@\the\absline@num @\the\section@num}{\@linenumannotationsep#1}%
    }{%
      \csgdef{annot@\the\absline@num @\the\section@num}{#1}%
    }%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\current@annot}
% By default, there is no annotation to a line number, so we store an empty \cs{current@annot}
%    \begin{macrocode}
\let\current@annot=\empty%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\reset@current@annot}
% \cs{reset@current@annot} is called at each \cs{@nl} in numbered auxiliary files.
% It resets the annotation of line numbers at each line.
%    \begin{macrocode}
\newcommand{\reset@current@annot}{%
  \unless\ifnoresetlinenumannotation@
    \let\current@annot\empty%
  \fi
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\parse@annot}
% In the \cs{annot@list} list, each individual \cs{edtext} is associated with a starting and an ending line number annotation, which is stored this way: \verb+start annotation|end annotation+
% The \cs{parse@annot} reads the format and defines two global macros.
%    \begin{macrocode}
\def\parse@annot#1|#2|{%
  \gdef\annot@start{#1}%
  \gdef\annot@end{#2}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setlinenumannotationsep}
% \begin{macro}{\@linenumannotationsep}
% The separator between the annotations and the way to redefine it.
%    \begin{macrocode}
\newcommand{\setlinenumannotationsep}[1]{\gdef\@linenumannotationsep{#1}}%
\def\@linenumannotationsep{, }%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Line number printing}
%
% \begin{macro}{\affixline@num}
% \protect\cs{affixline@num}  just puts a left line number into \protect\cs{l@dld@ta}
% or a right line number into \protect\cs{l@drd@ta} as required.
%
% To determine whether we need to affix a line number to this line,
% we compute the following:
% \begin{tabbing}
%   \quad $m$ \=  \kill
%   $n$ \> $= \mbox{\it int\/} ( ( \mbox{\it linenum\/} -
%                              \mbox{\it firstlinenum\/} ) /
%                                \mbox{\it linenumincrement\/} )$ \\
%   $m$ \> $= \mbox{\it firstlinenum\/} +
%                   ( n \times \mbox{\it linenumincrement\/})$
% \end{tabbing}
% (where \emph{int} truncates a real number to an integer).
% $m$ will be equal to \emph{linenum} only
% if we are to paste a number on here.
% However, the formula breaks down for the first line to number (and any
% before that), so we check that case separately: if \protect\cs{line@num} $\le$
% \protect\cs{firstlinenum}, we compare the two directly instead of making these
% calculations.
%
% We compute, in the scratch counter \protect\cs{@l@dtempcnta}, the number
% of the next line that should be printed with a number ($m$ in the
% above discussion), and move the current line number into the
% counter \protect\cs{@l@dtempcntb} for comparison.
%
%
% First, the case when we are within a sub-line range.
% \changes{v0.5.1}{2004/04/10}{Changed \protect\cs{affixline@num} to cater for sidenotes}
% \changes{v0.7.0}{2005/02/22}{Added skipnumering to \protect\cs{affixline@num}}
%    \begin{macrocode}
\newcommand*{\affixline@num}{%
%    \end{macrocode}
% No number is attached if \protect\cs{ifl@dskipnumber} is TRUE (and then it
% is set to its normal FALSE value).
% No number is attached if \protect\cs{ifnumberline} is FALSE (the normal value is TRUE).
% \changes{v0.15.0}{2012/06/11}{Line numbering can be disabled.}
%    \begin{macrocode}
  \ifledgroupnotesL@\else
    \ifnumberline
      \ifl@dskipnumber
        \global\l@dskipnumberfalse
      \else
        \ifsublines@
           \@l@dtempcntb=\subline@num
           \ifnum\subline@num>\c@firstsublinenum
               \@l@dtempcnta=\subline@num
               \advance\@l@dtempcnta by-\c@firstsublinenum
               \divide\@l@dtempcnta by\c@sublinenumincrement
               \multiply\@l@dtempcnta by\c@sublinenumincrement
               \advance\@l@dtempcnta by\c@firstsublinenum
           \else
               \@l@dtempcnta=\c@firstsublinenum
           \fi
%    \end{macrocode}
%
% That takes care of computing the values for comparison, but if line
% number locking is in effect we have to make a further check. If this
% check fails, then we disable the line-number display by setting the
% counters to arbitrary but unequal values.
%    \begin{macrocode}
           \ch@cksub@l@ck
%    \end{macrocode}
%
% Now the line number case, which works the same way.
%    \begin{macrocode}
        \else
           \@l@dtempcntb=\line@num
%    \end{macrocode}
% Check on the \protect\cs{linenumberlist}
% If it is \protect\cs{empty} use the standard
% algorithm.
%    \begin{macrocode}
           \ifx\linenumberlist\empty
              \ifnum\line@num>\c@firstlinenum
                 \@l@dtempcnta=\line@num
                 \advance\@l@dtempcnta by-\c@firstlinenum
                 \divide\@l@dtempcnta by\c@linenumincrement
                 \multiply\@l@dtempcnta by\c@linenumincrement
                 \advance\@l@dtempcnta by\c@firstlinenum
              \else
                 \@l@dtempcnta=\c@firstlinenum
              \fi
           \else
%    \end{macrocode}
% The \protect\cs{linenumberlist} was not \protect\cs{empty}, so here is Wayne's
% numbering mechanism. This takes place in \TeX's mouth.
%    \begin{macrocode}
              \@l@dtempcnta=\line@num
              \edef\rem@inder{,\linenumberlist,\number\line@num,}%
              \edef\sc@n@list{\def\noexpand\sc@n@list
                ####1,\number\@l@dtempcnta,####2|{\def\noexpand\rem@inder{####2}}}%
              \sc@n@list\expandafter\sc@n@list\rem@inder|%
              \ifx\rem@inder\empty%
                \advance\@l@dtempcnta\@ne
              \fi
           \fi
%    \end{macrocode}
%
%
% A locking check for lines, just like the version for sub-line
% numbers above.
%    \begin{macrocode}
           \ch@ck@l@ck
        \fi
%    \end{macrocode}
%
% The following tests are true if we need to print a line number.
%    \begin{macrocode}
        \ifnum\@l@dtempcnta=\@l@dtempcntb
           \ifl@dskipversenumber\else
%    \end{macrocode}
%
% If we got here,
% we are going to print a line number; so now we need to
% calculate a number that will tell us which side of the page will get
% the line number. We start from \protect\cs{line@margin}, which asks for
% one side always if it is less than $2$; and then if the side does
% depend on the page number, we simply add the page number to this
% side code---because the values of \protect\cs{line@margin} have been devised so
% that this produces a number that is even for left-margin numbers and
% odd for right-margin numbers.
%
% For \LaTeX\ we have to consider two column documents as well. In this case
% Peter Wilson thought we need to put the numbers at the outside of the column ---
% the left of the first column and the right of the second. Do the twocolumn
% stuff before going on with the original code.
% \begin{macro}{\l@dld@ta}
% \begin{macro}{\l@drd@ta}
% A left line number is stored in \protect\cs{l@dld@ta} and a right one in
% \protect\cs{l@drd@ta}.
%
%    \begin{macrocode}
             \if@twocolumn
                \if@firstcolumn
                   \gdef\l@dld@ta{\llap{{\leftlinenum}}}%
                \else
                   \gdef\l@drd@ta{\rlap{{\rightlinenum}}}%
                \fi
             \else
                \ifboolexpr{bool {l@dprintingcolumns} and test {\ifnumgreater{\line@margin@columns}{\m@ne}}}%
                  {\@l@dtempcntb=\line@margin@columns}%
                  {\@l@dtempcntb=\line@margin}%
                \ifnum\@l@dtempcntb>\@ne
                   \advance\@l@dtempcntb \page@num
                \fi
                \ifboolexpr{%
                  bool {l@dprintingcolumns}%
                  and (%
                   (test {\ifdefstring{\linenum@OnlyPages@ForColumns}{left}}%
                   and test {\ifnumodd{\page@num}}%
                   )%
                   or%
                   (test {\ifdefstring{\linenum@OnlyPages@ForColumns}{right}}%
                   and not test {\ifnumodd{\page@num}}%
                   )%
                 )%
                }%
                {}%
                {%
	                \ifodd\@l@dtempcntb%
	                   \gdef\l@drd@ta{\rlap{{\rightlinenum}}}%
	                 \else%
	                   \gdef\l@dld@ta{\llap{{\leftlinenum}}}%
	                \fi%
	            }%
             \fi
          \fi
       \fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% Now fix the lock counters, if necessary.
% A value of $1$ is advanced to
% $2$; $3$ advances to $0$; other values are unchanged.
%    \begin{macrocode}
       \f@x@l@cks
      \fi
    \fi
  \fi
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ch@cksub@l@ck}
% \begin{macro}{\ch@ck@l@ck}
% \begin{macro}{\f@x@l@cks}
%  These macros handle line number locking for \protect\cs{affixline@num}.
% \changes{v0.7.0}{2005/02/24}{Added \protect\cs{ch@cksub@l@ck}, \protect\cs{ch@ck@l@ck}
%                          and \protect\cs{f@x@l@cks}}
%  \protect\cs{ch@cksub@l@ck} checks subline locking. If it fails, then we disable
% the line-number display by setting the counters to arbitrary but unequal
% values.
%    \begin{macrocode}
\newcommand*{\ch@cksub@l@ck}{%
    \ifcase\sub@lock
      \or
        \ifnum\sublock@disp=\@ne
           \@l@dtempcntb=\z@ \@l@dtempcnta=\@ne
        \fi
      \or
        \ifnum\sublock@disp=\tw@ \else
           \@l@dtempcntb=\z@ \@l@dtempcnta=\@ne
        \fi
      \or
        \ifnum\sublock@disp=\z@
           \@l@dtempcntb=\z@ \@l@dtempcnta=\@ne
        \fi
    \fi}
%    \end{macrocode}
% Similarly for line numbers.
%    \begin{macrocode}
\newcommand*{\ch@ck@l@ck}{%
    \ifcase\@lock
       \or
         \ifnum\lock@disp=\@ne
            \@l@dtempcntb=\z@ \@l@dtempcnta=\@ne
         \fi
       \or
         \ifnum\lock@disp=\tw@ \else
            \@l@dtempcntb=\z@ \@l@dtempcnta=\@ne
         \fi
       \or
         \ifnum\lock@disp=\z@
            \@l@dtempcntb=\z@ \@l@dtempcnta=\@ne
         \fi
    \fi}
%    \end{macrocode}
% Fix the lock counters.
% A value of $1$ is advanced to
% $2$; $3$ advances to $0$; other values are unchanged.
%    \begin{macrocode}
\newcommand*{\f@x@l@cks}{%
  \ifcase\@lock
  \or
    \global\@lock=\tw@
  \or \or
    \global\@lock=\z@
  \fi
  \ifcase\sub@lock
  \or
    \global\sub@lock=\tw@
  \or \or
    \global\sub@lock=\z@
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
%
% \section{Pstart number printing inside}
% Inside, the printing of the pstart number runs like the printing of the line number. There are only a few differences:
% \begin{macro}{\affixpstart@num}
% \begin{macro}{\pstartnum}
% \begin{itemize}
%  \item The pstarts counter is upgraded in the \protect\cs{pend} command. Consequently, the \protect\cs{affixpstart@num} command has not to upgrade it, unlike the \protect\cs{affixline@num} which upgrades the lines counter.
%  \item To print the pstart number only at the beginning of a pstart, and not in every line, a boolean test is made. The \protect\cs{pstartnum} boolean is set to TRUE at every \protect\cs{pend}. It is tried in the \protect\cs{leftpstartnum} and \protect\cs{rightstartnum} commands. After the try, it is set to FALSE.
% \end{itemize}
% \begin{macro}{\leftpstartnum}
% \begin{macro}{\rightstartnum}
% \begin{macro}{\ifsidepstartnum}
%  \begin{macrocode}

\newif\ifsidepstartnum
\newcommand*{\affixpstart@num}{%
    \ifsidepstartnum
        \if@twocolumn
            \if@firstcolumn
                  \gdef\l@dld@ta{\llap{{\leftpstartnum}}}%
            \else
                  \gdef\l@drd@ta{\rlap{{\rightpstartnum}}}%
            \fi
        \else
            \@l@dtempcntb=\line@margin%
            \ifnum\@l@dtempcntb>\@ne
                  \advance\@l@dtempcntb \page@num
            \fi
            \ifodd\@l@dtempcntb
                  \gdef\l@drd@ta{\rlap{{\rightpstartnum}}}%
            \else
                  \gdef\l@dld@ta{\llap{{\leftpstartnum}}}%
            \fi
        \fi
    \fi

}
%

\newif\ifpstartnum
\pstartnumtrue
\newcommand*{\leftpstartnum}{
    \ifpstartnum\thepstart
    \kern\linenumsep\fi
    \global\pstartnumfalse
}
\newcommand*{\rightpstartnum}{
    \ifpstartnum
    \kern\linenumsep
    \thepstart
    \fi
    \global\pstartnumfalse
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \section{Restoring footnotes and penalties}
% Because of the paragraph decomposition process in order to number line, \macpackage\ must hack the standard way \TeX\ works in order to manage insertion of footnotes,  both critical and familiar.
%
% We need to call the \protect\cs{insert} commands not when the content of \protect\cs{pstart}\ldots\protect\cs{pend} is read by \TeX\, by when each individual line is typeset.
%
% Consequently, when reading the content of \protect\cs{pstart}\ldots\protect\cs{pend}, we store the insertion (footnotes) in an specific \macpackage's list, and we restore them to the vertical list when printing each individual line.
%
% \subsection{Add insertions to the vertical list}
%
% \begin{macro}{\inserts@list}
% \protect\cs{inserts@list} is the list macro that contains the inserts that
% we save up for one paragraph.
%
%    \begin{macrocode}
\list@create{\inserts@list}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\add@inserts}
% \begin{macro}{\add@inserts@next}
% \protect\cs{add@inserts}
% is the penultimate macro used by \protect\cs{do@line}; it takes
% insertions saved in a list macro and sends them onto the vertical list.
%
% It may call itself recursively, and to do this efficiently (using
% \TeX's optimization for tail recursion), we define a control-sequence
% called \protect\cs{add@inserts@next} that is always the last thing that
% \protect\cs{add@inserts} does. If there could be more inserts to process for
% this line, \protect\cs{add@inserts@next} is set equal to \protect\cs{add@inserts};
% otherwise it is  just \protect\cs{relax}.
%
%    \begin{macrocode}
\newcommand*{\add@inserts}{%
  \global\let\add@inserts@next=\relax
%    \end{macrocode}
%
% If \protect\cs{inserts@list} is empty, there are not any more notes or insertions
% for this paragraph, and we need not waste our time.
%    \begin{macrocode}
  \ifx\inserts@list\empty \else
%    \end{macrocode}
%
% The \protect\cs{next@insert} macro records the number of the line that
% receives the next footnote or other insert; it is empty when we start
% out, and just after we have affixed a note or insert.
%    \begin{macrocode}
  \ifx\next@insert\empty
    \ifx\insertlines@list\empty
      \global\noteschanged@true
      \gdef\next@insert{100000}%
    \else
      \gl@p\insertlines@list\to\next@insert
    \fi
  \fi
%    \end{macrocode}
%
% If the next insert's for this line, tack it on (and then erase the
% contents of the insert macro, as it could be quite large).
% In that case, we also set \protect\cs{add@inserts@next} so that we will
% call ourself recursively: there might be another insert for this same
% line.
%
%    \begin{macrocode}
  \ifnum\next@insert=\absline@num
    \gl@p\inserts@list\to\@insert
    \@insert
    \global\let\@insert=\undefined
    \global\let\next@insert=\empty
    \global\let\add@inserts@next=\add@inserts
  \fi
\fi
%    \end{macrocode}
%
% Make the recursive call, if necessary.
%
%    \begin{macrocode}
\add@inserts@next}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\add@Xgroupbyline}
% If you use \cs{Xgroupbyline}, the insertion of the critical footnotes are not made immediately in \cs{add@inserts}, but the content to be inserted is stored, in order to be inserted later in one block.
% This insertion in one block is made by \cs{add@Xgroupbyline}.
%    \begin{macrocode}
\newcommand{\add@Xgroupbyline}{%
  \unless\ifnocritical@%
    \def\do##1{%Looping on the series
      \let\olddo\do%Save the old \do macro, that is this macro itself!
      \def\do####1{%Looping on the ##1@forinserting command
         \ifcsdef{##1@forinserting@####1}{%
           \X@beforeinsertion{##1}%
           \if@ledgroup%
             \global\setbox\@nameuse{mp##1footins}=\vbox%
           \else%
             \insert\csname ##1footins\endcsname%
           \fi%
           {%
             \Xsetparindent{##1}%
             \ifcsdef{Xhsize\csuse{series@display##1}@##1}%
               {\hsize \csuse{Xhsize\csuse{series@display##1}@##1}}%
               {}%
             \if@ledgroup%
               \unvbox\@nameuse{mp##1footins}%
             \fi%
             \X@atbegininsertion{##1}%
             \ifcsstring{series@display##1}{normal}%
               {%
                  \Xledsetnormalparstuff{##1}%
                  \rule\z@\splittopskip%
               }%
               {}%
             \csuse{##1@forinserting@####1}%
             \strut\par%
           }%
           \global\csundef{##1@forinserting@####1}%
           }%
           {}%
         }%
      \ifcsdef{##1@forinserting}{%
        \dolistcsloop{##1@forinserting}%
      }{}%
      \global\csundef{##1@forinserting}%
      \let\do\olddo%Restore old do
      }%
    \dolistloop{\@series}%
  \fi%
}%


%    \end{macrocode}
% \end{macro}
% \subsection{Penalties}
%
% \begin{macro}{\add@penalties}
% \protect\cs{add@penalties} is
% the last macro used by \protect\cs{do@line}. It adds up the club,
% widow, and interline penalties, and puts a single penalty
% of the appropriate size
% back into the paragraph; these penalties get
% removed by the \protect\cs{vsplit} operation. \protect\cs{displaywidowpenalty} and
% \protect\cs{brokenpenalty} are not restored, since we have no easy way to
% find out where we should insert them.
%
% \label{add@penalties}
% In this code, \protect\cs{num@lines} is the number of lines in the whole
% paragraph, and \protect\cs{par@line} is the line we are working on at the
% moment.  The count \protect\cs{@l@dtempcnta} is used to calculate and
% accumulate the penalty; it is initially set to the value of
% \protect\cs{ballast@count}, which has been worked out in \protect\cs{do@ballast}
% above (\reff{do@ballast}).  Finally, the penalty is
% checked to see that it does not go below $-10000$.
%    \begin{macrocode}
\newcommand*{\add@penalties}{\@l@dtempcnta=\ballast@count
  \ifnum\num@lines>\@ne
    \global\advance\par@line \@ne
    \ifnum\par@line=\@ne
      \advance\@l@dtempcnta \clubpenalty
    \fi
    \@l@dtempcntb=\par@line \advance\@l@dtempcntb \@ne
    \ifnum\@l@dtempcntb=\num@lines
      \advance\@l@dtempcnta \widowpenalty
    \fi
    \ifnum\par@line<\num@lines
      \advance\@l@dtempcnta \interlinepenalty
    \fi
  \fi
    \ifnum\@l@dtempcnta=\z@
      \relax
    \else
      \ifnum\@l@dtempcnta>-10000
        \penalty\@l@dtempcnta
      \else
        \penalty -10000
      \fi
    \fi}

%    \end{macrocode}
% \end{macro}
%
% \subsection{Printing leftover notes}
%
% \begin{macro}{\flush@notes}
% The \protect\cs{flush@notes}
% macro is called after the entire paragraph has been sliced up
% and sent on to the vertical list.
% If the number of notes to this paragraph has increased since the previous
% run of \TeX, then there can be leftover notes that have not yet been
% printed. An appropriate error message will be printed elsewhere; but
% it is best to go ahead and
% print these notes somewhere, even if it is not in quite the
% right place. What we do is dump them all out here, so that they should
% be printed on the same page as the last line
% of the paragraph. We can hope that is not
% too far from the proper location, to which they will move on the next
% run.
% For the first run, we do not flush the notes,
% as that means all the notes will be added at the end of numbered section,
% and so, very far of the expected position
%    \begin{macrocode}
\newcommand*{\flush@notes}{%
  \iftoggle{notfirstrun@\jobname.\extensionchars\the\section@num}{%
    \@xloop%
      \ifx\inserts@list\empty \else%
        \gl@p\inserts@list\to\@insert%
        \@insert%
        \global\let\@insert=\undefined%
    \repeat%
  }{}%
}%


%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xloop}
% \protect\cs{@xloop} is
% a variant of the \PlainTeX\ \protect\cs{loop} macro, useful when it's
% hard to construct a positive test using the \TeX\ \verb"\if" commands---as
% in \protect\cs{flush@notes} above. One types \protect\cs{@xloop} \verb"..." \verb"\if" \verb"..." \verb"\else"
% \verb"..." \verb"\repeat", and the action following \verb"\else" is repeated as long
% as the \verb"\if" test fails. (This macro will work wherever the \PlainTeX\
% \protect\cs{loop} is used, too, so we could just call it \protect\cs{loop};
% but it seems preferable not to change the definitions of any of
% the standard macros.)
%
% This variant of \protect\cs{loop} was introduced by
% Alois Kabelschacht\index{Kabelschacht, Alois} in
% \textit{TUGboat} \textbf{8} (1987), pp.\,184--5.
%
%    \begin{macrocode}
\def\@xloop#1\repeat{%
  \def\body{#1\expandafter\body\fi}%
  \body}

%    \end{macrocode}
% \end{macro}
% \subsection{Text before notes}
% \begin{macro}{\set@Xtxtbeforenotes}
% The \cs{set@Xtxtbeforenotes} macro resets the Xtxtbeforesnotes@\meta{series}@typeset boolean to false. Just before the first note of the \meta{series} in a page, the \cs{Xtextbeforenotes} will be inserted.
%    \begin{macrocode}
\newcommand{\set@Xtxtbeforenotes}{%
  \unless\ifnocritical@%
    \def\do##1{%
      \nottoggle{Xtxtbeforenotesonlyonce@##1}{%
        \global\togglefalse{Xtxtbeforesnotes@##1@typeset}%
      }{}%
    }%
    \dolistloop{\@series}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\set@txtbeforenotesX}
% The \cs{set@txtbeforenotesX} does the same for the \cs{textbeforenotesX}.
%    \begin{macrocode}
\newcommand{\set@txtbeforenotesX}{%
  \unless\ifnofamiliar@%
    \def\do##1{%
      \nottoggle{txtbeforenotesonlyonceX@##1}{%
        \global\togglefalse{txtbeforesnotesX@##1@typeset}%
      }{}%
    }%
    \dolistloop{\@series}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\insert@Xtxtbeforenotes}
% \begin{macro}{\insert@txtbeforenotesX}
% \cs{insert@Xtxtbeforenotes}\marg{series}, called when inserting a familiar footnote, will insert the text before the note if it is not already inserted.
% For paragraphed footnotes, it will insert it as a component of the first footnote.
% For other types of footnotes, it will insert it as a regular footnote.
%
% \cs{insert@txtbeforenotesX} is the same for familiar footnotes.
%    \begin{macrocode}
\newcommand{\insert@Xtxtbeforenotes}[1]{%
  \nottoggle{Xtxtbeforesnotes@#1@typeset}{%
    \global\toggletrue{Xtxtbeforesnotes@#1@typeset}%
    \ifcsvoid{Xtxtbeforenotes@#1}{}{%
      \ifcsstring{series@display#1}{paragraph}%
        {\noindent\csuse{Xtxtbeforenotes@#1}}%
        {\expandafter\insert\csname#1footins\endcsname%
          \bgroup%
            \noindent%
            \ifcsdef{\csuse{series@display#1}@begin@insert}{%
              \csuse{\csuse{series@display#1}@begin@insert}{#1}%
            }{}%
            \strut\csuse{Xnotefontsize@#1}%
            \csuse{Xtxtbeforenotes@#1}%
          \egroup%
        }%
    }%
  }%
  {}%
}%


\newcommand{\insert@txtbeforenotesX}[1]{%
  \nottoggle{txtbeforesnotesX@#1@typeset}{%
    \global\toggletrue{txtbeforesnotesX@#1@typeset}%
    \ifcsvoid{txtbeforenotesX@#1}{}{%
      \ifcsstring{series@displayX#1}{paragraph}%
        {\noindent\csuse{txtbeforenotesX@#1}}%
        {\expandafter\insert\csname footins#1\endcsname%
          \bgroup%
            \noindent%
            \ifcsdef{\csuse{series@displayX#1}@begin@insert}{%
              \csuse{\csuse{series@displayX#1}@begin@insert}{#1}%
            }{}%
            \strut\csuse{notefontsizeX@#1}\csuse{txtbeforenotesX@#1}%
          \egroup%
        }%
    }%
  }%
  {}%
}%


%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Critical footnotes}
% \label{footnotes}
%
% The footnote macros are adapted from those in \PlainTeX, but they
% differ in these respects: the outer-level commands must add other
% commands to a list macro rather than doing insertions immediately;
% there are many separate levels of the footnotes, not just one; and there
% are options to reformat footnotes into paragraphs or into multiple
% columns.
%
% \subsection{Fonts}
% \label{fontcode}\relax
% Before getting into the details of formatting the notes, we set
% up some font macros. It is the notes that present the greatest
% challenge for our font-handling mechanism, because we need to be
% able to take fragments of our main text and print them in
% different forms: it is common to reduce the size,
% for example, without otherwise changing the fonts used.
%
%
% \begin{macro}{\select@lemmafont}\label{notefonts}
% \begin{macro}{\select@@lemmafont}
% \protect\cs{select@lemmafont} is provided to set the right font for
% the lemma in a note. This macro extracts the font specifier
% from the line and page number cluster, and issues the associated
% font-changing command, so that the lemma is printed in its
% original font.
%    \begin{macrocode}
  \def\select@lemmafont#1|#2|#3|#4|#5|#6|#7|{\select@@lemmafont#7|}
  \def\select@@lemmafont#1/#2/#3/#4|%
    {\fontencoding{#1}\fontfamily{#2}\fontseries{#3}\fontshape{#4}%
    \selectfont}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Individual note options}
% \changes{v1.0.0}{2012/09/15}{Options of \protect\cs{Xfootnote}s.}
% \begin{macro}{\footnoteoptions@}
% The \protect\cs{footnoteoption@}\oarg{side}\marg{options}\marg{value} changes the value of on options of Xfootnote, to switch between true and false.
% \changes{v2.4.0}{2015/10/19}{First argument of \protect\cs{footnoteoption@} is now mandatory, not optional.}
%    \begin{macrocode}
\newcommand*{\footnoteoptions@}[3]{%
   \def\do##1{%
      \ifstrequal{#1}{L}{% On the left side
          \xright@appenditem{\noexpand\setkeys[mac]{#3footnoteoption}{\unexpanded{##1}}}\to\inserts@list%
         \global\advance\insert@count \@ne% Increment the left insert counter.
      }%
      {%
          \xright@appenditem{\noexpand\setkeys[mac]{#3footnoteoption}{\unexpanded{##1}}}\to\inserts@listR%
          \global\advance\insert@countR \@ne% Increment the right insert counter insert.
      }%
   }%
   \notblank{#2}{\docsvlist{#2}}{}% Parsing all options
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Notes language}
% \begin{macro}{\footnotelang@lua}
% \protect\cs{footnotelang@lua} is called to remember the information about the direction of a lemma when \LuaLaTeX\ is used.
%    \begin{macrocode}
\newcommandx*{\footnotelang@lua}[1][1=L,usedefault]{%
   \ifstrequal{#1}{L}{%
   \xright@appenditem{{\csxdef{footnote@luatextextdir}{\the\textdir}}}\to\inserts@list%Know the dir of lemma
    \global\advance\insert@count \@ne%
    \xright@appenditem{{\csxdef{footnote@luatexpardir}{\the\pardir}}}\to\inserts@list%Know the dir of lemma
    \global\advance\insert@count \@ne%
   }%
   {%
   \xright@appenditem{{\csxdef{footnote@luatextextdir}{\the\textdir}}}\to\inserts@listR%Know the dir of lemma
    \global\advance\insert@countR \@ne%
    \xright@appenditem{{\csxdef{footnote@luatexpardir}{\the\pardir}}}\to\inserts@listR%Know the dir of lemma
    \global\advance\insert@countR \@ne%
   }%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\footnotelang@poly}
% \protect\cs{footnotelang@poly} is called to remember the information about the language of a lemma when \protect\package{polyglossia} is used.
%    \begin{macrocode}
\newcommandx*{\footnotelang@poly}[1][1=L,usedefault]{%
   \ifstrequal{#1}{L}{%
    \if@RTL%
        \xright@appenditem{{\csxdef{footnote@dir}{@RTLtrue}}}\to\inserts@list%Know the language used in the lemma
        \global\advance\insert@count \@ne%
    \else
         \xright@appenditem{{\csxdef{footnote@dir}{@RTLfalse}}}\to\inserts@list%Know the language of lemma
         \global\advance\insert@count \@ne%
    \fi%
    \xright@appenditem{{\csxdef{footnote@lang}{\expandonce\languagename}}}\to\inserts@list%Know the language of lemma
    \global\advance\insert@count \@ne%
   }%
   {%
    \if@RTL
        \xright@appenditem{{\csxdef{footnote@dir}{@RTLtrue}}}\to\inserts@listR%Know the language of lemma
        \global\advance\insert@countR \@ne%
    \else
         \xright@appenditem{{\csxdef{footnote@dir}{@RTLfalse}}}\to\inserts@listR%Know the language of lemma
         \global\advance\insert@countR \@ne%
    \fi
    \xright@appenditem{{\csxdef{footnote@lang}{\expandonce\languagename}}}\to\inserts@listR%Know the language of lemma
    \global\advance\insert@countR \@ne%
   }%
}
%    \end{macrocode}
% \end{macro}
% \subsection{General survey of the way we manage notes}
%
% The processing of each note is done
% by four principal macros: the \protect\cs{vfootnote} macro takes the text
% of the footnote and does the \protect\cs{insert}; it calls on the
% \protect\cs{footfmt} macro to select the right fonts, print the line
% number and lemma, and do any other formatting needed for that individual
% note. Within the output routine, the two other macros, \protect\cs{footstart}
% and \protect\cs{footgroup}, are called; the first prints extra vertical
% space and a footnote rule, if desired; the second does any reformatting
% of the whole set of the footnotes in this series for this page---such
% as paragraphing or division into columns---and then sends them to the
% page.
%
% These four macros, and the other macros and parameters shown
% here, are distinguished by the `series letter'
% that indicates which set of the footnotes
% we are dealing with---\texttt{A}, \texttt{B}, \texttt{C}, \texttt{D}, or \texttt{E}.
% The series letter always precedes the string \verb"foot" in macro
% and parameter names. Hence, for the \texttt{A} series, the four macros
% are called \protect\cs{vAfootnote}, \protect\cs{Afootfmt}, \protect\cs{Afootstart},
% and \protect\cs{Afootgroup}.
%
% These macros are changed depending of the footnotes arrangement: ``normal'', ``paragraphed'', ``two columns'' or ``three columns''.
% \subsection{General setup}
% \begin{macro}{\footsplitskips}
% Some setup code that is common for a variety of the footnotes.
% The setup is for:
% \begin{itemize}
%    \item \protect\cs{interlinepenalty}.
%    \item \protect\cs{splittopskip} (skip before last part of notes that flow from one page to another).
%    \item \protect\cs{splitmaxdepth}.
%    \item \protect\cs{floatingpenalty}, that is penalty values being added when a long note flows from one page to another.
% Here, we let it to 0 when we are processing parallel pages in \protect\package{eledpar}, in order to allow notes to flow from left to right pages and \emph{vice-versa}.
% Otherwise, we let it to \protect\cs{@MM}, which is the standard \LaTeX\  \protect\cs{floatingpenalty}.
% \end{itemize}
% \changes{v0.7.0}{2005/02/18}{Added \protect\cs{footsplitskips} for use in many
%              footnote styles}
% \changes{v1.19.0}{2015/03/06}{\protect\cs{footsplitskips} doesn't set \protect\cs{floatingpenalty} to \protect\cs{@MM} when processing parallel pages.}
%    \begin{macrocode}
\newcommand*{\footsplitskips}{%
  \interlinepenalty=\interfootnotelinepenalty
  \unless\ifl@dprintingpages%
    \floatingpenalty=\@MM%
  \fi%
  \splittopskip=\ht\strutbox \splitmaxdepth=\dp\strutbox
  \leftskip=\z@skip \rightskip=\z@skip}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalfootnoterule}
% \protect\cs{normalfootnoterule} is
% a standard footnote-rule macro, for use by a \verb"footstart"
% macro: just the same as the \PlainTeX\ footnote rule.
%    \begin{macrocode}
\let\normalfootnoterule=\footnoterule
%    \end{macrocode}
% \end{macro}
% \subsection{Footnotes arrangement}
%
% \subsubsection{User level macro}
% \begin{macro}{\Xarrangement}
% \protect\cs{Xarrangement}\oarg{s}\marg{arrangement}
% The command calls, for each series, a specific command which set many counters and commands in order to define specific arrangement.
%
%    \begin{macrocode}
\newcommandx{\Xarrangement}[2][1,usedefault]{%
  \def\do##1{%
     \csname Xarrangement@#2\endcsname{##1}%
  }%
  \ifstrempty{#1}%
    {%
    \dolistloop{\@series}%
    }%
    {
    \docsvlist{#1}%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Normal footnote}
%
% \begin{macro}{\Xarrangement@normal}
% We can now define all the parameters for the  series of
% footnotes; initially they use the ``normal'' footnote formatting.
%
% What we want to do here is to insert something like the following
% for each footnote series. (This is an example, not part of the
% actual \macpackage{} code.)
% \begin{verbatim}
% \skip\Afootins=12pt plus5pt minus5pt
% \count\Afootins=1000
% \dimen\Afootins=0.8\vsize
% \let\vAfootnote=\normalvfootnote  \let\Afootfmt=\normalfootfmt
% \let\Afootstart=\normalfootstart  \let\Afootgroup=\normalfootgroup
% \let\Afootnoterule=\normalfootnoterule
% \end{verbatim}
% (Read \thetexbook\ in order to understand what are the counter, skip and dimen  associated to an insertion.)
%
% Instead of repeating ourselves, we define a \protect\cs{Xarrangement@normal}
% macro that makes all these assignments for us, for any given
% series letter.
% This command is called when people use \protect\cs{Xarrangement}\oarg{series}\verb+{normal}+

%
% Now we set up the \protect\cs{Xarrangement@normal} macro itself.  It takes
% one argument: the footnote series letter.
%    \begin{macrocode}
\newcommand*{\Xarrangement@normal}[1]{%
  \csgdef{series@display#1}{normal}
  \expandafter\let\csname #1footstart\endcsname=\normalfootstart
  \expandafter\let\csname v#1footnote\endcsname=\normalvfootnote
  \expandafter\let\csname #1footfmt\endcsname=\normalfootfmt
  \expandafter\let\csname #1footgroup\endcsname=\normalfootgroup
  \expandafter\let\csname #1footnoterule\endcsname=%
                                             \normalfootnoterule
  \count\csname #1footins\endcsname=1000
  \dimen\csname #1footins\endcsname=\csuse{Xmaxhnotes@#1}
  \skip\csname #1footins\endcsname=\csuse{Xbeforenotes@#1}%
  \advance\skip\csname #1footins\endcsname by\csuse{Xafterrule@#1}%
%    \end{macrocode}
%  The \parpackage provides tools in order to confine notes to one side.
% The mechanism is explained in the \parpackage's handbook.
% For now, just retain we need to store default value of the counter associated to the notes \TeX's inserts.

%    \begin{macrocode}
  \csxdef{default@#1footins}{1000}%Use this to confine the  notes to one side only
%    \end{macrocode}
% Now do the setup for minipage footnotes. We use as much as possible of the
% normal setup as we can (so the notes will have a similar layout).
% \changes{v0.4.0}{2004/02/29}{Added minpage footnote setup to \protect\cs{footnormal}}
%    \begin{macrocode}
  \ifnoledgroup@\else%
    \expandafter\let\csname mpv#1footnote\endcsname=\mpnormalvfootnote
    \expandafter\let\csname mp#1footgroup\endcsname=\mpnormalfootgroup
    \count\csname mp#1footins\endcsname=1000
    \dimen\csname mp#1footins\endcsname=\csuse{Xmaxhnotes@#1}
    \skip\csname mp#1footins\endcsname=\csuse{Xbeforenotes@#1}%
    \advance\skip\csname mp#1footins\endcsname by\csuse{Xafterrule@#1}%
  \fi
}

%    \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\normalvfootnote}
% We now begin a series of commands that do `normal' footnote
% formatting: a format much like that implemented
% in \PlainTeX{}, in which each footnote
% is a separate paragraph.
%
% \protect\cs{normalvfootnote} takes the series letter as \verb"#1"
% and the entire text of the footnote is \verb"#2". It does the
% \protect\cs{insert} for this note, calling on the \protect\cs{footfmt} macro for
% this note series to format the text of the note.
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\normalvfootnote}[2]{%
  \iftoggle{Xgroupbyline@#1}{%In the case we use \Xgroupbyline, the insertion is done later, in \add@Xgroupbyline.
    \prepare@Xgroupbyline{#1}{#2}{\normalvfootnote@inserted}%
  }{%In the case we don't use \Xgroupbyline, the insertion is made directly
    \X@beforeinsertion{#1}%
    \insert\csname #1footins\endcsname{%
      \X@atbegininsertion{#1}%
      \normalvfootnote@inserted{#1}{#2}%
    }%
  }%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalvfootnote@inserted}
% The \cs{normalvfootnote@inserted} macro is expanded to the content to be added to a \cs{insert} for normal critical footnote.
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\normalvfootnote@inserted}[2]{%
  \nottoggle{Xgroupbyline@#1}{\noindent}{}\csuse{Xbhooknote@#1}%
  \csuse{Xnotefontsize@#1}%
  \iftoggle{Xgroupbyline@#1}{\strut}{}%
  \footsplitskips
  \ifl@dpairing\ifl@dpaging\else%
    \setXnoteswidthliketwocolumns@{#1}%
  \fi\fi%
  \setXnotespositionliketwocolumns@{#1}%
  \spaceskip=\z@skip \xspaceskip=\z@skip%
  \csname #1footfmt\endcsname #2{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\X@beforeinsertion}
%    \begin{macrocode}
\newcommand{\X@beforeinsertion}[1]{%
  \if@ledgroup\else%
    \insert@Xtxtbeforenotes{#1}%
  \fi%
  \csuse{Xbeforeinserting@#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\beforeinsertion@X}
%    \begin{macrocode}
\newcommand{\beforeinsertion@X}[1]{%
  \if@ledgroup\else%
    \insert@txtbeforenotesX{#1}%
  \fi%
  \csuse{beforeinsertingX@#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\X@atbegininsertion}
%    \begin{macrocode}
\newcommand{\X@atbegininsertion}[1]{%
  \hsize=\expandafter\dimexpr\csuse{Xwidth@#1}\relax%
}%
%    \end{macrocode}
% \end{macro}
% And somewhat different versions of \cs{normalvfootnote} and \cs{normalvfootnote@inserted} for minipages.
% \begin{macro}{\mpnormalvfootnote}
% \changes{v0.4.0}{2004/02/29}{Added \protect\cs{mpnormalvfootnote}}
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\mpnormalvfootnote}[2]{%
  \iftoggle{Xgroupbyline@#1}{%
    \prepare@Xgroupbyline{#1}{#2}{\mpnormalvfootnote@inserted}%
  }%
  {%
      \global\setbox\@nameuse{mp#1footins}%
      \vbox{%
        \unvbox\@nameuse{mp#1footins}%
        \mpnormalvfootnote@inserted{#1}{#2}%
    }%
  }%
}%

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\mpnormalvfootnote@inserted}
%    \begin{macrocode}
\newcommand{\mpnormalvfootnote@inserted}[2]{%
    \noindent\csuse{Xbhooknote@#1}%
    \csuse{Xnotefontsize@#1}%
    \hsize\columnwidth%
    \@parboxrestore%
    \color@begingroup%
    \csname #1footfmt\endcsname #2{#1}\color@endgroup%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\normalfootfmt}
% \label{normalfootfmt}
% \protect\cs{normalfootfmt} is a `normal' macro
% to take the footnote line and page
% number information (see \reff{linenumbers}), and the
% desired text, and output what's to be printed.
% Argument \verb"#1" contains the line and page number information
% and lemma font specifier;
% \verb"#2" is the lemma;
% \verb"#3" is the note's text;
% \verb"#4" is the note's series.
% This version is very
% rudimentary---it uses \protect\cs{printlines}
% to print just the range of line numbers,
% followed by a square bracket, the lemma, and the note text.
%
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\normalfootfmt}[4]{%
  \Xstorelineinfo{#1}{#4}%
  \nottoggle{Xgroupbyline@#4}{\Xledsetnormalparstuff{#4}}{}%
  \Xsethangindent{#4}%
  \nottoggle{Xgroupbyline@#4}{\rule\z@\splittopskip}{}%
  {\printlinefootnote{#1}{#4}}%
  \print@lemma{#1}{#2}{#4}%
  \csuse{Xwrapcontent@#4}{#3}%
  \nottoggle{Xgroupbyline@#4}{\strut\par}{}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalfootstart}\label{normalvalues}
% \phantomsection\relax
% \protect\cs{normalfootstart}
% is a standard footnote-starting macro, called in the output
% routine whenever there are footnotes of this series to be
% printed: it skips a bit and then draws a rule.
%
% Any \protect\cs{footstart} macro must put onto the page something that
% takes up space exactly equal to the \protect\cs{skip}\protect\cs{Xfootins} value for
% the associated series of notes. \TeX\ makes page computations based
% on that \protect\cs{skip} value, and the output pages will suffer from
% spacing problems if what you add takes up a different amount of
% space.
%
% But if the skip \protect\cs{Xprenotes@} is greater than 0~pt,
% it is used instead of \protect\cs{skip}\protect\cs{footins} for the first printed series in one page.
%
% The \protect\cs{leftskip} and \protect\cs{rightskip} values
% are both zeroed here.
% \label{footskips}
% Similarly, these skips are cancelled in the \protect\cs{vfootnote} macros
% for the various types of notes. Strictly speaking,
% this is necessary only
% if you are using paragraphed footnotes, but we have put it here
% and in the other \protect\cs{vfootnote} macros too so that the behavior of
% \macpackage{} in this respect is general across all footnote types.
% What this means is that any \protect\cs{leftskip}
% and \protect\cs{rightskip} you specify applies to the main text, but not
% the footnotes.  The footnotes continue to be of width \protect\cs{hsize}.
%    \begin{macrocode}
\newcommand*{\normalfootstart}[1]{%
%    \end{macrocode}
% The first series of notes printed in a page can have a specific skip before it.
% In order to insert this specific skip without overlap the bottom margin of the page, Maïeul Rouquette have defined an algorithm explained in \reff{skipfirstseries}.
% Here is part of this algorithm, when the block of notes are ready to be printed.
%    \begin{macrocode}
  \ifdimequal{0pt}{\Xprenotes@}{}%
      {%
      \iftoggle{Xprenotes@}{%
            \togglefalse{Xprenotes@}%
            \skip\csname #1footins\endcsname=%
              \glueexpr\csuse{Xprenotes@}+\csuse{Xafterrule@#1}\relax%
            }%
          {}%
      }%
  \vskip\skip\csname #1footins\endcsname%
%    \end{macrocode}
%    And now, the problem of left and right skip for notes.
% Especially when using one feature of \parpackage which allows to have the footnotes horizontal size as the size of columns printed by \protect\cs{Columns}.
% Read \reff{width2columns} for the general description of the problem.
%   \begin{macrocode}
  \leftskip0pt \rightskip0pt
  \ifl@dpairing\else%
     \hsize=\old@hsize%
  \fi%
  \setXnoteswidthliketwocolumns@{#1}%
  \setXnotespositionliketwocolumns@{#1}%
%   \end{macrocode}
% And now, print the footnote's rule to finish the footnote's introduction.
%   \begin{macrocode}
  \print@Xfootnoterule{#1}%
}%
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\normalfootgroup}
% \protect\cs{normalfootgroup} is
% a standard footnote-grouping macro: it sends the
% contents of the footnote-insert box to the output page without
% alteration.
%    \begin{macrocode}
\newcommand*{\normalfootgroup}[1]{%
  \csuse{Xbhookgroup@#1}%
  \unvbox\csname #1footins\endcsname%
  \hsize=\old@hsize%
  }%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mpnormalfootgroup}
% A somewhat different version for minipages.
% Note that, in this case, we do not make distinctions between the \protect\cs{Xfootgroup} and \protect\cs{Xfootstarts} macros.
% \changes{v0.4.0}{2004/02/29}{Added \protect\cs{mpnormalfootgroup}}
%    \begin{macrocode}
\unless\ifnoledgroup@
\newcommand*{\mpnormalfootgroup}[1]{{
  \vskip\skip\@nameuse{mp#1footins}
  \ifl@dpairing\ifparledgroup%
    \leavevmode\marks\parledgroup@{begin}%
    \marks\parledgroup@series{#1}%
    \marks\parledgroup@type{Xfootnote}%
  \fi\fi\normalcolor%
  \ifparledgroup%
    \ifl@dpairing%
    \else%
      \setXnoteswidthliketwocolumns@{#1}%
      \setXnotespositionliketwocolumns@{#1}%
      \print@Xfootnoterule{#1}%%
    \fi%
  \else%
    \setXnoteswidthliketwocolumns@{#1}%
    \setXnotespositionliketwocolumns@{#1}%
    \print@Xfootnoterule{#1}%%
  \fi%
  \setlength{\parindent}{0pt}
 \csuse{Xbhookgroup@#1}%
 \unvbox\csname mp#1footins\endcsname}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Paragraphed footnotes}
%
% The paragraphed-footnote option
% reformats all the footnotes of one series for a page into
% a single paragraph; this is especially appropriate when the notes are
% numerous and brief. The code is based
% on \thetexbook, pp.\,398--400, with
% alterations for our environment. This algorithm uses a considerable
% amount of save-stack space: a \TeX\ of ordinary size may not be able
% to handle more than about $100$ notes of this kind on a page.
%
% \begin{macro}{\Xarrangement@paragraph}
% The \protect\cs{Xarrangement@paragraph} macro
% sets up everything for one series of the footnotes so that
% they will be paragraphed; it takes the series letter as argument.
% We include the setting of \verb"\count\footins" to $1000$ for the
% footnote series just in case user is switching to paragraphed
% footnotes after having columnar ones, since they change this
% value (see below).
%
% The argument of \protect\cs{Xarrangement@footparagraph} is the letter
%  denoting the series of notes to be paragraphed.
%    \begin{macrocode}
\newcommand*{\Xarrangement@paragraph}[1]{%
  \csgdef{series@display#1}{paragraph}
  \expandafter\let\csname #1footstart\endcsname=\parafootstart
  \expandafter\let\csname v#1footnote\endcsname=\paravfootnote
  \expandafter\let\csname #1footfmt\endcsname=\parafootfmt
  \expandafter\let\csname #1footgroup\endcsname=\parafootgroup
  \count\csname #1footins\endcsname=1000
  \csxdef{default@#1footins}{1000}%Use this to confine the  notes to one side only
  \dimen\csname #1footins\endcsname=\csuse{Xmaxhnotes@#1}
  \skip\csname #1footins\endcsname=\csuse{Xbeforenotes@#1}%
  \advance\skip\csname #1footins\endcsname by\csuse{Xafterrule@#1}%
  \para@footsetup{#1}
%    \end{macrocode}
% And the extra setup for minipages.
%    \begin{macrocode}
  \ifnoledgroup@\else
    \expandafter\let\csname mpv#1footnote\endcsname=\mpparavfootnote
    \expandafter\let\csname mp#1footgroup\endcsname=\mpparafootgroup
    \count\csname mp#1footins\endcsname=1000
    \dimen\csname mp#1footins\endcsname=\csuse{Xmaxhnotes@#1}
    \skip\csname mp#1footins\endcsname=\csuse{Xbeforenotes@#1}%
    \advance\skip\csname mp#1footins\endcsname by\csuse{Xafterrule@#1}%
  \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\footfudgefiddle}
% For paragraphed footnotes \TeX{} has to estimate the amount of space
% required. If it underestimates this then the notes may get too long and
% run off the bottom of the text block. \protect\cs{footfudgefiddle} can be increased
% from its default 64 (say, to 70) to increase the estimate.
% \changes{v0.2.2}{2003/11/04}{Added \protect\cs{footfudgefiddle}}
%    \begin{macrocode}
\providecommand{\footfudgefiddle}{64}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\para@footsetup}
% \protect\cs{footparagraph} calls the
% \protect\cs{para@footsetup} macro to calculate a special
% fudge factor, which is the ratio of the \protect\cs{baselineskip}
% to the \protect\cs{hsize}. We assume that the proper value of
% \protect\cs{baselineskip} for the footnotes (normally 9\,pt) has been set
% already.  The argument of the macro is
% again the note series letter.
%
% Peter Wilson thinks that \protect\cs{columnwidth} should be used here for \LaTeX\, not \protect\cs{hsize}.
% Peter Wilson have also included \protect\cs{footfudgefiddle}.
% \changes{v0.2.2}{2003/11/04}{Added \protect\cs{footfudgefiddle} to \protect\cs{para@footsetup}}
%    \begin{macrocode}
\newcommand*{\para@footsetup}[1]{{\csuse{Xbhookgroup@#1}\csuse{Xnotefontsize@#1}
  \setXnoteswidthliketwocolumns@{#1}%
  \ifcsempty{Xwidth@#1}%
    {}%
    {\columnwidth=\expandafter\dimexpr\csuse{Xwidth@#1}\relax}%
  \dimen0=\baselineskip
  \multiply\dimen0 by 1024
  \divide \dimen0 by \columnwidth \multiply\dimen0 by \footfudgefiddle\relax
  \csxdef{#1footfudgefactor}{%
    \expandafter\strip@pt\dimen0 }}}

%    \end{macrocode}
% \end{macro}
%
% \protect\cs{strip@pt}  strip the characters \verb"pt" from a dimen value.
%
% \begin{macro}{\parafootstart}
% \protect\cs{parafootstart} is the same as \protect\cs{normalfootstart}, but we give it
% again to ensure that \protect\cs{rightskip} and \protect\cs{leftskip} are
% zeroed (this needs to be done before \protect\cs{para@footgroup} in the
% output routine).    The size of
% paragraphed notes is calculated using a fudge factor which in
% turn is based on \protect\cs{hsize}.  So the paragraph of notes needs to be
% that wide.
%
% The argument of the macro is again the note series letter.
%    \begin{macrocode}
\newcommand*{\parafootstart}[1]{%
  \rightskip=0pt \leftskip=0pt%
  \Xsetparindent{#1}%
    \ifdimequal{0pt}{\Xprenotes@}{}%
      {%
      \iftoggle{Xprenotes@}{%
            \togglefalse{Xprenotes@}%
            \skip\csname #1footins\endcsname=%
              \glueexpr\csuse{Xprenotes@}+\csuse{Xafterrule@#1}\relax%
            }%
          {}%
      }%
  \vskip\skip\csname #1footins\endcsname%
  \setXnoteswidthliketwocolumns@{#1}%
  \setXnotespositionliketwocolumns@{#1}%
  \print@Xfootnoterule{#1}%
  \let\old@bidi@RTL@everypar\bidi@RTL@everypar%
  \let\bidi@RTL@everypar\@empty%
  \noindent\leavevmode%
  \let\bidi@RTL@everypar\old@bidi@RTL@everypar%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\paravfootnote}
% \protect\cs{paravfootnote}
% is a version of the \protect\cs{vfootnote} command that is used for
% paragraphed notes.  It gets appended to the \protect\cs{inserts@list} list
% by an outer-level footnote command like \protect\cs{Afootnote}.  The first
% argument is the note series letter; the second is the full text
% of the printed note itself, including line numbers, lemmata, and
% footnote text.
%
% The initial model for this insertion is, of course, the
% \verb"\insert\footins" definition in \thetexbook, p.\,398.
% There, the footnotes are first collected up in hboxes, and these
% hboxes are later unpacked and stuck together into a paragraph.
%
% However, Michael Downes\index{Downes, Michael} has pointed out
% that because text in hboxes gets typeset in restricted horizontal
% mode, there are some undesirable side-effects if you later want
% to break such text across lines.  In restricted horizontal mode,
% where \TeX\ does not expect to have to break lines, it does not
% insert certain items like \protect\cs{discretionary}s. If you later unbox
% these hboxes and stick them together, as the \texbook{}
% macros do to make these footnotes, you lose the ability to
% hyphenate after an explicit hyphen.  This can lead to overfull
% \protect\cs{hbox}es when you would not expect to find them, and to the
% uninitiated it might be very hard to see why the problem had
% arisen.\footnote{Michael Downes, `Line Breaking in \protect\cs{unhbox}ed
% Text', \textit{TUGboat} \textbf{11} (1990), pp.\,605--612.}
%
% Wayne Sullivan\index{Sullivan, Wayne} pointed out to us another
% subtle problem that arises from the same cause: \TeX\ also leaves
% the \protect\cs{language} whatsit nodes out of the horizontal
% list.\footnote{See \thetexbook, p.\,455 (editions after
% January 1990).}  So changes from one language to another will not
% invoke the proper hyphenation rules in such footnotes.  Since
% critical editions often do deal with several languages,
% especially in a footnotes, we really ought to get this bit of code
% right.
%
% To get around these problems, Wayne suggested emendations to the
% \texbook{} versions of these macros which are broadly the
% same as those described by Michael: the central idea (also
% suggested by Donald Knuth in a letter to Michael) is to avoid collecting
% the text in an \protect\cs{hbox} in the first place, but instead to collect
% it in a \protect\cs{vbox} whose width is (virtually)
% infinite.\label{hboxproblem} The text is therefore typeset in
% unrestricted horizontal mode, as a paragraph consisting of a
% single long line.  Later, there is an extra level of unboxing to
% be done: we have to unpack the \protect\cs{vbox}, as well as the hboxes
% inside it, but that is not too hard.  For details, we refer you to
% Michael's article, where the issues are clearly
% explained.\footnote{Wayne supplied his own macros to do this, but
% since they were almost identical to Michael's, Peter Wilson have used the
% latter's \protect\cs{Xunvxh} macro since it is publicly
% documented.}  Michael's unboxing macro is called \protect\cs{Xunvxh}: unvbox,
% extract the last line, and unhbox it.
%
% Doing things this way has an important
% consequence:\label{nobreaks-detail} as Michael
% pointed out, you really can't put an explicit line-break into a
% note built in a \protect\cs{vbox} the way we are doing.\footnote{`Line
% Breaking', p.\,610.}  In other words, be very careful not to use
% \protect\cs{break}, or \verb"\penalty-10000", or any equivalent inside your
% para-footnote.\label{nobreak}  If you do, most of the note will
% probably disappear.  You \emph{are} allowed to make strong
% suggestions; in fact \verb"\penalty-9999" will be quite okay.  Just
% do not make the break mandatory.  We have not applied any of
% Michael's solutions here, since we feel that the problem is
% exiguous, and \macpackage{} is quite baroque enough already.  If
% you think you are having this problem, look up Michael's
% solutions.
%
% One more thing; we set \protect\cs{leftskip} and \protect\cs{rightskip} to zero.
% This has the effect of neutralizing any such skips which may
% apply to the main text (cf.~\reff{footskips} above).
% We need to do this, since \protect\cs{footfudgefactor} is calculated on
% the assumption that the notes are \protect\cs{hsize} wide.
%
% So, finally, here is the modified foot-paragraph code, which
% sets the footnote in vertical mode so that language and
% discretionary nodes are included.
%
%    \begin{macrocode}
\newcommand*{\paravfootnote}[2]{%
  \csuse{Xbeforeinserting@#1}%
  \insert\csname #1footins\endcsname
  \bgroup
    \csuse{Xnotefontsize@#1}
    \footsplitskips
    \setbox0=\vbox{\hsize=\maxdimen%
      \let\bidi@RTL@everypar\@empty%
      \insert@Xtxtbeforenotes{#1}%
      \noindent\csuse{Xbhooknote@#1}%
      \csname #1footfmt\endcsname #2{#1}}%
    \setbox0=\hbox{\Xunvxh{0}{#1}}%
    \dp0=0pt
    \ht0=\csname #1footfudgefactor\endcsname\wd0
%    \end{macrocode}
% Here we produce the contents of the footnote from box $0$, and
% add a penalty of $0$ between boxes in this insert.
%    \begin{macrocode}
    \if@RTL\noindent \leavevmode\fi\box0%
    \penalty0
  \egroup}

%    \end{macrocode}
% The final penalty of $0$
% was added here at Wayne's\index{Sullivan, Wayne}
% suggestion to avoid a weird page-breaking problem, which occurs on
% those occasions when \TeX\ attempts to split foot paragraphs.
% After trying out such a split (see \thetexbook, p.\,124),
% \TeX\ inserts a penalty of $-10000$ here, which
% nearly always forces the break at the end of the whole footnote
% paragraph (since individual notes can't be split) even when this
% leads to an overfull vbox.  The change above results in a penalty
% of $0$ instead which allows, but does not force, such breaks. This
% penalty of $0$ is later removed, after page breaks have been
% decided, by the \protect\cs{unpenalty} macro in \protect\cs{makehboxofhboxes}. So it
% does not affect how the footnote paragraphs are typeset (the
% notes still have a penalty of $-10$ between them, which is added
% by \protect\cs{parafootfmt}).
% \end{macro}
%
% \begin{macro}{\mpparavfootnote}
% This version is for minipages.
%    \begin{macrocode}
\newcommand*{\mpparavfootnote}[2]{%
  \global\setbox\@nameuse{mp#1footins}\vbox{%
    \unvbox\@nameuse{mp#1footins}%
    \csuse{Xnotefontsize@#1}
    \footsplitskips
    \setbox0=\vbox{\hsize=\maxdimen%
      \let\bidi@RTL@everypar\@empty%
      \insert@Xtxtbeforenotes{#1}%
      \noindent\color@begingroup%
      \csuse{Xbhooknote@#1}%
      \csname #1footfmt\endcsname #2{#1}\color@endgroup}%
    \setbox0=\hbox{\Xunvxh{0}{#1}}%
    \dp0=\z@
    \ht0=\csname #1footfudgefactor\endcsname\wd0
    \box0
    \penalty0
}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Xunvxh}
% Here is (modified) Michael's\index{Downes, Michael} definition of \protect\cs{unvxh},
% used above.  Michael's macro also takes care to remove some
% unwanted penalties and glue that \TeX\ automatically attaches to
% the end of paragraphs.  When \TeX\ finishes a paragraph, it
% throws away any remaining glue, and then tacks on the following
% items: a \protect\cs{penalty} of $10000$, a \protect\cs{parfillskip} and a
% \protect\cs{rightskip} (\thetexbook, pp.\,99--100).  \protect\cs{unvxh}
% cancels these unwanted paragraph-final items using \protect\cs{unskip} and
% \protect\cs{unpenalty}.
%    \begin{macrocode}
\newcommand*{\Xunvxh}[2]{%
  \setbox0=\vbox{\unvbox#1%
    \global\setbox1=\lastbox}%
  \unhbox1
  \unskip            % remove \rightskip,
  \unskip            % remove \parfillskip,
  \unpenalty         % remove \penalty of 10000,
  \hskip\csuse{Xafternote@#2}\relax}% add the glue to go between the notes

%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\parafootfmt}
% \protect\cs{parafootfmt} is
% \protect\cs{normalfootfmt} adapted to do the special stuff
% needed for paragraphed notes --- leaving out the \protect\cs{endgraf} at the
% end, sticking in special penalties and kern and leaving out the
% \protect\cs{footstrut}. The first argument is the line and page
% number information, the second is the lemma, the third is the
% text of the footnote, and the fourth is the series (optional, for backward compatibility).
%    \begin{macrocode}
\newcommand*{\parafootfmt}[4]{%
  \Xstorelineinfo{#1}{#4}%
  \Xinsertparafootsep{#4}%
  \ledsetnormalparstuff@common%
  \printlinefootnote{#1}{#4}%
  \print@lemma{#1}{#2}{#4}%
  \csuse{Xwrapcontent@#4}{#3}%
  \penalty-10 }
%    \end{macrocode}
% Note that in the above definition, the penalty of $-10$
% encourages a line break between notes, so that notes have a
% slight tendency to begin on new lines.
% The \protect\cs{Xinsertparafootsep} command is used to insert the \protect\cs{Xparafootsep@series} between each note in the \emph{same} page.
% \end{macro}
%
% \begin{macro}{\parafootgroup}
% This \verb"footgroup" code is modelled on the macros in
% \thetexbook, p.\,399.  The only difference is the \protect\cs{unpenalty}
% in \protect\cs{makehboxofhboxes}, which is there to remove the penalty of
% $0$ which was added to the end of each footnote by
% \protect\cs{paravfootnote}.
%
% The call to \protect\cs{Xnotefontsize@\meta{s}} is to ensure that the correct
% \protect\cs{baselineskip} for the footnotes is used. The argument is the
% note series letter.
%    \begin{macrocode}
\newcommand*{\parafootgroup}[1]{%
  \hsize=\expandafter\dimexpr\csuse{Xwidth@#1}\relax%
  \unvbox\csname #1footins\endcsname
  \ifcsstring{Xragged@#1}{L}{\RaggedLeft}{}%
  \ifcsstring{Xragged@#1}{R}{\RaggedRight}{}%
  \makehboxofhboxes
  \setbox0=\hbox{\unhbox0 \removehboxes}%
  \csuse{Xbhookgroup@#1}%
  \csuse{Xnotefontsize@#1}%
  \unhbox0\par%
  \global\hsize=\old@hsize%
  }%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mpparafootgroup}
% The minipage version.
%    \begin{macrocode}
\newcommand*{\mpparafootgroup}[1]{{%
  \setXnoteswidthliketwocolumns@{#1}%
  \vskip\skip\@nameuse{mp#1footins}
  \ifl@dpairing\ifparledgroup%
    \leavevmode\marks\parledgroup@{begin}%
    \marks\parledgroup@series{#1}%
    \marks\parledgroup@type{Xfootnote}%
  \fi\fi\normalcolor
  \ifparledgroup%
    \ifl@dpairing%
    \else%
      \setXnoteswidthliketwocolumns@{#1}%
      \setXnotespositionliketwocolumns@{#1}%
      \print@Xfootnoterule{#1}%%
    \fi%
  \else%
      \setXnoteswidthliketwocolumns@{#1}%
      \setXnotespositionliketwocolumns@{#1}%
      \print@Xfootnoterule{#1}%
  \fi%
  \unvbox\csname mp#1footins\endcsname
  \ifcsstring{Xragged@#1}{L}{\RaggedLeft}{}%
  \ifcsstring{Xragged@#1}{R}{\RaggedRight}{}%
  \makehboxofhboxes
  \setbox0=\hbox{\unhbox0 \removehboxes}%
  \csuse{Xbhookgroup@#1}%
  \csuse{Xnotefontsize@#1}%
  \Xsetparindent{#1}%
  \unhbox0\par}}

%    \end{macrocode}
% \end{macro}
%
% And finally, the two macros which are required to transform the long horizontal box stored  in the insert' box to a printable text.
%
% \begin{macro}{\makehboxofhboxes}
% \begin{macro}{\removehboxes}
%    \begin{macrocode}
\newcommand*{\makehboxofhboxes}{\setbox0=\hbox{}%
  \loop
    \unpenalty
    \setbox2=\lastbox
  \ifhbox2
    \setbox0=\hbox{\box2\unhbox0}%
  \repeat}

\newcommand*{\removehboxes}{\setbox0=\lastbox
  \ifhbox0{\removehboxes}\unhbox0 \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \paragraph{Insertion of the footnotes separator}
%The command \protect\cs{Xinsertparafootsep}\marg{series} must be called at the beginning of \protect\cs{parafootftm}.
% \begin{macro}{\prevpage@num}
% \changes{v1.8.0}{2013/12/13}{Correct \protect\cs{parafootsep} when using with ledgroup.}
% \changes{v1.22.1}{2015/04/29}{Correct double symbol when using both \protect\cs{parafootsep} and \protect\cs{Xsymlinenum}.}
% \begin{macro}{\Xinsertparafootsep}
%    \begin{macrocode}
\newcommand{\Xinsertparafootsep}[1]{%
   \ifledRcol@%
     \ifnumequal{\csuse{#1prevpage@numR}}{\page@numR}%
        {\ifcsdef{prevline#1}% Be sur \prevline#1 exists.
          {\ifcsequal{prevline#1}{lineinfo@}%
             {\ifcsempty{Xsymlinenum@#1}{\csuse{Xparafootsep@#1}}{}}%
             {\csuse{Xparafootsep@#1}}%
          }%
          {\csuse{Xparafootsep@#1}}%
     }%
     {}%
     \global\csname #1prevpage@numR\endcsname=\page@numR%
   \else%
     \ifnumequal{\csuse{#1prevpage@num}}{\page@num}%
        {\ifcsdef{prevline#1}% Be sur \prevline#1 exists.
          {\ifcsequal{prevline#1}{lineinfo@}%
             {\ifcsempty{Xsymlinenum@#1}{\csuse{Xparafootsep@#1}}{}}%
             {\csuse{Xparafootsep@#1}}%
          }%
        {\csuse{Xparafootsep@#1}}%
     }%
     {}%
     \global\csname #1prevpage@num\endcsname=\page@num%
   \fi%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsubsection{Columnar footnotes}
%
% \paragraph{Common tools}
% \begin{macro}{\rigidbalance}
% \begin{macro}{\rigidbalanceX}
% \begin{macro}{\Xrigidbalance}
% \begin{macro}{\dosplits}
% \begin{macro}{\splitoff}
% \begin{macro}{\@h}
% \begin{macro}{\@k}
% We will now define macros for three-column notes and two-column
% notes. Both sets of macros will use \protect\cs{rigidbalance}, which splits a
% box (\verb"#1") into into a number (\verb"#2") of columns, each
% with a space (\verb"#3") between the top baseline and the top of
% the \protect\cs{vbox}.  The \protect\cs{rigidbalance} macro is taken from
% \thetexbook, p.\,397, with a slight change to the syntax of
% the arguments so that they do not depend on white space.  Note also
% the extra unboxing in \protect\cs{splitoff}, which allows the new \protect\cs{vbox} to
% have its natural height as it goes into the alignment.
%
% The \LaTeX\ \protect\cs{line} macro has no relationship to the
% TeX \protect\cs{line}. The \LaTeX\ equivalent is \protect\cs{@@line}.
% \changes{v2.7.0}{2015/11/29}{\protect\cs{rigidbalance} is split in \protect\cs{Xrigidbalance} and \protect\cs{rigidbalanceX}.}
%
% We do not call directly \cs{rigidbalance}, but we call \cs{Xrigidbalance} for critical notes and \cs{rigidbalanceX} for familiar notes. Both of them call \cs{rigidbalance}.
%    \begin{macrocode}
\newcount\@k \newdimen\@h
\newcommand*{\Xrigidbalance}[3]{%
    \hsize=\expandafter\dimexpr\csuse{Xwidth@\@currentseries}\relax%
    \rigidbalance{#1}{#2}{#3}%
}%

\newcommand*{\rigidbalanceX}[3]{%
    \hsize=\expandafter\dimexpr\csuse{widthX@\@currentseries}\relax%
    \rigidbalance{#1}{#2}{#3}%
}%

\newcommand*{\rigidbalance}[3]{%
  \setbox0=\box#1 \@k=#2 \@h=#3%
  \@@line{\splittopskip=\@h \vbadness=\@M \hfilneg
  \valign{##\vfil\cr\dosplits}}}

\newcommand*{\dosplits}{\ifnum\@k>0 \noalign{\hfil}\splitoff
  \global\advance\@k-1\cr\dosplits\fi}

\newcommand*{\splitoff}{\dimen0=\ht0
  \divide\dimen0 by\@k \advance\dimen0 by\@h
  \setbox2 \vsplit0 to \dimen0
  \unvbox2 }

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \paragraph{Three columns}
%
% \begin{macro}{\Xarrangement@threecol}
%    \begin{macrocode}
\newcommand*{\Xarrangement@threecol}[1]{%
  \csgdef{series@display#1}{threecol}
  \expandafter\let\csname v#1footnote\endcsname=\threecolvfootnote
  \expandafter\let\csname #1footfmt\endcsname=\threecolfootfmt
  \expandafter\let\csname #1footgroup\endcsname=\threecolfootgroup
  \dimen\csname #1footins\endcsname=\csuse{Xmaxhnotes@#1}%
  \skip\csname #1footins\endcsname=\csuse{Xbeforenotes@#1}%
  \advance\skip\csname #1footins\endcsname by\csuse{Xafterrule@#1}%
  \threecolfootsetup{#1}
%    \end{macrocode}
% The additional setup for minipages.
%    \begin{macrocode}
  \ifnoledgroup@\else
    \expandafter\let\csname mpv#1footnote\endcsname=\mpnormalvfootnote
    \expandafter\let\csname mp#1footgroup\endcsname=\mpthreecolfootgroup
    \skip\csname mp#1footins\endcsname=\csuse{Xbeforenotes@#1}%
    \advance\skip\csname mp#1footins\endcsname by\csuse{Xafterrule@#1}%
    \mpthreecolfootsetup{#1}
  \fi
}

%    \end{macrocode}
% The \protect\cs{footstart} and \protect\cs{footnoterule} macros for these notes assume
% the normal values (\reff{normalvalues} above).
% \end{macro}
%
% \begin{macro}{\threecolfootsetup}
% The \protect\cs{threecolfootsetup} macro calculates and sets some numbers
% for three-column footnotes.
%
% We set the \protect\cs{count} of the foot insert to $333$.
% Each footnote can be thought of as contributing only one third of
% its height to the page, since the footnote insertion has been
% made as a long narrow column, which then gets trisected by the
% \protect\cs{rigidbalance} routine (inside \protect\cs{threecolfootgroup}).
% These new, shorter columns are saved in a box, and then that box
% is \emph{put back} into the footnote insert, replacing the
% original collection of the footnotes.  This new box is, therefore,
% only about a third of the height of the original one.
%
% The \protect\cs{dimen} value for this note series has to change in the
% inverse way: it needs to be three times
% the actual limit on the amount of space these notes are allowed to
% fill on the page, because when \TeX\ is
% accumulating material for the page
% and checking that limit, it does not apply the \protect\cs{count} scaling.
%    \begin{macrocode}
\newcommand*{\threecolfootsetup}[1]{%
  \count\csname #1footins\endcsname 333
  \csxdef{default@#1footins}{333}%Use this to confine the  notes to one side only
  \multiply\dimen\csname #1footins\endcsname \thr@@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mpthreecolfootsetup}
% The setup for minipages.
%    \begin{macrocode}
\newcommand*{\mpthreecolfootsetup}[1]{%
  \count\csname mp#1footins\endcsname 333
  \multiply\dimen\csname mp#1footins\endcsname \thr@@}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\threecolvfootnote}
% \protect\cs{threecolvfootnote}
% This is the \protect\cs{vfootnote} command for three-column notes.
% However, most of the code is deported on \cs{threecolvfootnote@inserted}.
% The call to \protect\cs{Xnotefontsize@\meta{s}} ensures that the
% \protect\cs{splittopskip} and \protect\cs{splitmaxdepth} take their values
% from the right \protect\cs{strutbox}: the one used in a footnotes.
% Note especially the importance of temporarily reducing the
% \protect\cs{hsize} to $0.3$ of its normal value.  This determines the
% widths of the individual columns. So if the normal \protect\cs{hsize}
% is (say) 10\,cm, then each column will be $0.3\times10=3$\,cm
% wide, leaving a gap of 1\,cm spread equally between columns
% (i.e., .5\,cm between each).
%
% The arguments are \verb+#1+~the note series letter and \verb+#1+~the full text
% of the note (including numbers, lemma and text).
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\threecolvfootnote}[2]{%
  \iftoggle{Xgroupbyline@#1}{%
    \prepare@Xgroupbyline{#1}{#2}{\threecolvfootnote@inserted}%
  }%
  {%
    \let\bidi@RTL@everypar\relax%
    \X@beforeinsertion{#1}%
    \insert\csname #1footins\endcsname{%
      \threecolvfootnote@inserted{#1}{#2}%
    }%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\threecolvfootnote@inserted}%
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\threecolvfootnote@inserted}[2]{%
  \hsize=\expandafter\dimexpr\csuse{Xwidth@#1}\relax%
  \noindent\csuse{Xbhooknote@#1}%
  \csuse{Xnotefontsize@#1}%
  \footsplitskips%
  \csname #1footfmt\endcsname #2{#1}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\threecolfootfmt}
% \protect\cs{threecolfootfmt}
% is the command that formats one note.
% The arguments are \verb+#1+~the line numbers, \verb+#2+~the lemma and \verb+#4+~the
% text of the \verb"-footnote" command \verb+#4+ optional  (for backward compatibility): the series.
%
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\threecolfootfmt}[4]{%
  \Xstorelineinfo{#1}{#4}%
  \threecol@begin@insert{#4}%
  \hspace{\parindent}%
  \printlinefootnote{#1}{#4}%
  \print@lemma{#1}{#2}{#4}%
  \csuse{Xwrapcontent@#4}{#3}%
  \nottoggle{Xgroupbyline@#4}%
    {\strut\par\allowbreak}%
    {}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\threecol@begin@insert}
% The \cs{threecol@begin@insert} contains code used at the beginning of any \cs{insert} for critical footnotes in three columns. It is used both by \cs{threecolfootfmt} and by \cs{insert@Xtxtbeforenotes}.
%    \begin{macrocode}
\newcommand{\threecol@begin@insert}[1]{%
  \normal@pars%
  \nottoggle{Xgroupbyline@#1}%
    {\hsize \csuse{Xhsizethreecol@#1}}%
    {}%
  \Xsetparindent{#1}%
  \tolerance=5000%
  \Xsethangindent{#1}%
  \@tempdima=\parindent%
  \csuse{Xcolalign@#1}%
  \parindent=\@tempdima%
  \strut%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\threecolfootgroup}
% And here is the \verb"footgroup" macro that is called within the
% output routine to regroup the notes into three columns. Once
% again, the call to \protect\cs{Xnotefontsize@\meta{s}} is there to ensure that
% it is the right \protect\cs{splittopskip}---the one used in
% footnotes---which is used to provide the third argument for
% \protect\cs{rigidbalance}.  This third argument (\protect\cs{@h}) is the
% \verb"topskip" for the box containing the text of the
% footnotes, and does the job of making sure the top lines of the
% columns line up horizontally.  In \thetexbook, p.\,398,
% Donald Knuth suggests retrieving the ouput of \protect\cs{rigidbalance},
% putting it back into the insertion box, and then printing the
% box.  Here, we just print the \protect\cs{line} which comes out of
% \protect\cs{rigidbalance} directly, without any re-boxing.
%    \begin{macrocode}
\newcommand*{\threecolfootgroup}[1]{%
  \begingroup%
    \csuse{Xbhookgroup@#1}%
    \csuse{Xnotefontsize@#1}%
    \par%
    \splittopskip=\ht\strutbox%
    \expandafter%
    \Xrigidbalance\csname #1footins\endcsname \thr@@ \splittopskip%
  \endgroup%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mpthreecolfootgroup}
% The setup for minipages.
%    \begin{macrocode}
\newcommand*{\mpthreecolfootgroup}[1]{{%
  \vskip\skip\@nameuse{mp#1footins}
  \ifl@dpairing\ifparledgroup%
    \leavevmode\marks\parledgroup@{begin}%
    \marks\parledgroup@series{#1}%
    \marks\parledgroup@type{Xfootnote}%
  \fi\fi\normalcolor
  \ifparledgroup%
    \ifl@dpairing%
    \else%
      \setXnoteswidthliketwocolumns@{#1}%
      \setXnotespositionliketwocolumns@{#1}%
      \print@Xfootnoterule{#1}%
    \fi%
  \else%
    \setXnoteswidthliketwocolumns@{#1}%
    \setXnotespositionliketwocolumns@{#1}%
    \print@Xfootnoterule{#1}%
  \fi%
  \csuse{Xbhookgroup@#1}\par%
  \splittopskip=\ht\strutbox
  \expandafter
  \Xrigidbalance\csname mp#1footins\endcsname \thr@@ \splittopskip}}

%    \end{macrocode}
% \end{macro}
% \paragraph{Two columns}
%
% \begin{macro}{\Xarrangement@twocol}
%    \begin{macrocode}
\newcommand*{\Xarrangement@twocol}[1]{%
  \csgdef{series@display#1}{twocol}
  \expandafter\let\csname v#1footnote\endcsname=\twocolvfootnote
  \expandafter\let\csname #1footfmt\endcsname=\twocolfootfmt
  \expandafter\let\csname #1footgroup\endcsname=\twocolfootgroup
  \dimen\csname #1footins\endcsname=\csuse{Xmaxhnotes@#1}%
  \skip\csname #1footins\endcsname=\csuse{Xbeforenotes@#1}%
  \advance\skip\csname #1footins\endcsname by\csuse{Xafterrule@#1}%
  \twocolfootsetup{#1}
%    \end{macrocode}
% The additional setup for minipages.
%    \begin{macrocode}
  \ifnoledgroup@\else
    \expandafter\let\csname mpv#1footnote\endcsname=\mpnormalvfootnote
    \expandafter\let\csname mp#1footgroup\endcsname=\mptwocolfootgroup
    \skip\csname mp#1footins\endcsname=\csuse{Xbeforenotes@#1}%
    \advance\skip\csname mp#1footins\endcsname by\csuse{Xafterrule@#1}%
    \mptwocolfootsetup{#1}
  \fi
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\twocolfootsetup}
% \begin{macro}{\twocolvfootnote}
% \begin{macro}{\twocolvfootnote@inserted}
% \begin{macro}{\twocolfootfmt}
% \begin{macro}{\twocolfootgroup}
% Here is a series of macros which are very similar to their
% three-column counterparts. In this case,
% each note is assumed to contribute only a half a line of text.
% And the notes are set in columns
% giving a gap between them of one tenth
% of the \protect\cs{hsize}.
%    \begin{macrocode}
\newcommand*{\twocolfootsetup}[1]{%
  \count\csname #1footins\endcsname 500
  \csxdef{default@#1footins}{500}%
  \multiply\dimen\csname #1footins\endcsname \tw@}
%    \end{macrocode}
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\twocolvfootnote}[2]{%
  \iftoggle{Xgroupbyline@#1}{%
    \prepare@Xgroupbyline{#1}{#2}{\twocolvfootnote@inserted}%
  }{%
    \let\bidi@RTL@everypar\relax%
    \X@beforeinsertion{#1}%
    \insert\csname #1footins\endcsname{%
      \twocolvfootnote@inserted{#1}{#2}%
    }%
  }%
}%
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\twocolvfootnote@inserted}[2]{%
  \hsize=\expandafter\dimexpr\csuse{Xwidth@#1}\relax%
  \noindent\csuse{Xbhooknote@#1}%
  \csuse{Xnotefontsize@#1}%
  \footsplitskips%
  \csname #1footfmt\endcsname #2{#1}%
}%
%    \end{macrocode}
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\twocolfootfmt}[4]{% 4th arg is optional, for backward compatibility
  \Xstorelineinfo{#1}{#4}%
  \twocol@begin@insert{#4}%
  \hspace{\parindent}%
  \printlinefootnote{#1}{#4}%
  \print@lemma{#1}{#2}{#4}%
  \csuse{Xwrapcontent@#4}{#3}%
  \nottoggle{Xgroupbyline@#4}%
    {\strut\par\allowbreak}%
    {}%
}%
%    \end{macrocode}
%    \begin{macrocode}
\newcommand{\twocol@begin@insert}[1]{%
  \normal@pars%
  \nottoggle{Xgroupbyline@#1}%
    {\hsize \csuse{Xhsizetwocol@#1}}%
    {}%
  \Xsetparindent{#1}%
  \tolerance=5000%
  \Xsethangindent{#1}%
  \@tempdima=\parindent%
  \csuse{Xcolalign@#1}%
  \parindent=\@tempdima%
  \strut%
}%

\newcommand*{\twocolfootgroup}[1]{%
  \begingroup%
    \csuse{Xbhookgroup@#1}%
    \csuse{Xnotefontsize@#1}%
    \par%
    \splittopskip=\ht\strutbox%
    \expandafter%
    \Xrigidbalance\csname #1footins\endcsname \tw@ \splittopskip%
  \endgroup%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\mptwocolfootsetup}
% \begin{macro}{\mptwocolfootgroup}
% The versions for minipages.
%    \begin{macrocode}
\newcommand*{\mptwocolfootsetup}[1]{%
  \count\csname mp#1footins\endcsname 500
  \multiply\dimen\csname mp#1footins\endcsname \tw@}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*{\mptwocolfootgroup}[1]{{%
  \vskip\skip\@nameuse{mp#1footins}
  \ifl@dpairing\ifparledgroup%
    \leavevmode\marks\parledgroup@{begin}%
    \marks\parledgroup@series{#1}%
    \marks\parledgroup@type{Xfootnote}%
  \fi\fi\normalcolor
  \ifparledgroup%
    \ifl@dpairing%
    \else%
      \setXnoteswidthliketwocolumns@{#1}%
      \setXnotespositionliketwocolumns@{#1}%
      \print@Xfootnoterule{#1}%
    \fi%
  \else%
    \setXnoteswidthliketwocolumns@{#1}%
    \setXnotespositionliketwocolumns@{#1}%
    \print@Xfootnoterule{#1}%
  \fi%
   \csuse{Xbhookgroup@#1}\par%
  \splittopskip=\ht\strutbox
  \expandafter
  \Xrigidbalance\csname mp#1footins\endcsname \tw@ \splittopskip}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Footnote paragraph indent}
% \begin{macro}{\Xsetparindent}
% \begin{macro}{\setparindentX}
% These two commands set the paragraph indentation of the footnotes, depending of the settings of the user.
%    \begin{macrocode}
\newcommand{\Xsetparindent}[1]{%
  \nottoggle{Xparindent@#1}{%
    \parindent=\z@%
  }%
  {%
    \ifdef{\parindent@beforestanza}{\parindent=\parindent@beforestanza}{}%
  }%
}%
\newcommand{\setparindentX}[1]{%
  \nottoggle{parindentX@#1}{%
    \parindent=\z@%
  }%
  {%
    \ifdef{\parindent@beforestanza}{\parindent=\parindent@beforestanza}{}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Footnote hanging indent}
% \begin{macro}{\Xsethangindent}
% \begin{macro}{\sethangindentX}
% \cs{Xsethangindent} sets the hangindent for a critical footnote, while \cs{sethangindentX} does it for a familiar footnote.
%    \begin{macrocode}
\newcommand{\Xsethangindent}[1]{%
  \if@RTL%
    \hangindent=-\csuse{Xhangindent@#1}%
    \everypar{\hangindent=-\csuse{Xhangindent@#1}}%
  \else%
    \hangindent=\csuse{Xhangindent@#1}%
    \everypar{\hangindent=\csuse{Xhangindent@#1}}%
  \fi%
}%
\newcommand{\sethangindentX}[1]{%
  \if@RTL%
    \hangindent=-\csuse{hangindentX@#1}%
    \everypar{\hangindent=-\csuse{hangindentX@#1}}%
  \else%
    \hangindent=\csuse{hangindentX@#1}%
    \everypar{\hangindent=\csuse{hangindentX@#1}}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Critical notes presentation}
% Here, we define some commons macro which are used in order to print a critical notes, that is a note with 1) line number 2) lemma 3) lemma separator 4) text associated to the lemma.

% \subsubsection{Font tools}
% \begin{macro}{\endashchar}
% \begin{macro}{\fullstop}
% \begin{macro}{\rbracket}
% The fonts that are used for printing notes might not have the
% character mapping we expect: for example, the Computer Modern font
% that contains old-style numerals does not contain an en-dash or
% square brackets, and its period and comma are in odd locations.
% To allow use of the standard footnote macros with such fonts, we use
% the following macros for certain characters.
%
% The \protect\cs{endashchar} macro is simply an en-dash from the
% normal font and is immune to changes in the surrounding
% font.  The same goes for the full stop.  These two are used in
% \protect\cs{printlines}.  The right bracket macro is the same again;
% it crops up in \protect\cs{normalfootfmt} and the other footnote
% macros for controlling the format of the footnotes.
%
% Note that these commands are not directly called by \macpackage, but are enclosed as default value of specific hooks.
% Consequently, people should not redefine them, but use instead the \cs{Xlinerangeseparator}, \cs{Xendlinerangeseparator}, \cs{Xsublinesep}, \cs{Xendsublinesep} and \cs{Xlemmaseparator} macros.
%
% With \protect\package{polyglossia}, each critical note has a \protect\cs{footnote@lang} which shows the language of the lemma,
% and which can be used to switch the bracket from right to left.
% \changes{v1.4.0}{2012/11/16}{Switch the right bracket to a left bracket when the lemma is RTL (needs polyglossia or LuaTeX).}
%    \begin{macrocode}
\def\endashchar{\textnormal{--}}

\newcommand*{\fullstop}{\textnormal{.}}
\def\Xsublinesep@side{\fullstop}

\newcommand*{\rbracket}{\textnormal{%
   \csuse{text\csuse{footnote@lang}}{%
         \ifluatex%
         \ifdefstring{\footnote@luatextextdir}{TRT}{\thinspace[}{\thinspace]}%
            \else%
         \thinspace]%
         \fi}%
   }%
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Pstart number in footnote}
% \begin{macro}{\printpstart}
% The \protect\cs{printpstart} macro prints the pstart number for a note.
% \changes{v1.18.0}{2015/02/23}{Debug \protect\cs{Xpstart} with parallel pages and columns (eledpar)}
%    \begin{macrocode}
\newcommand{\printpstart}[0]{%
    \ifboolexpr{bool{l@dpairing} or bool{l@dprintingpages} or bool{l@dprintingcolumns}}{%
        \ifledRcol%
            \thepstartR%
        \else%
            \thepstartL%
        \fi%
    }{%
        \thepstart%
    }%
}
%    \end{macrocode}
%
% \end{macro}
% \subsubsection{Lemma printing}
%
% \begin{macro}{\print@lemma}
% \cs{print@lemma} is called inside critical footnotes to print the lemma and the lemma separator (\#1: line number and font information, \#2: lemma, \#3: series).
% \changes{v2.10.0}{2016/05/08}{Code refactoring between \protect\cs{parafootfmt}, \protect\cs{twocolfootfmt}, \protect\cs{threecolfootfmt} and \protect\cs{normalfootfmt}.}
%    \begin{macrocode}
%
\newcommand{\print@lemma}[3]{%
  \bgroup%
    \nottoggle{Xlemmadisablefontselection@#3}%
      {\select@lemmafont#1|}%
      {}%
    \bgroup%
      \csuse{Xlemmafont@#3}%Deprecated
      \csuse{Xwraplemma@#3}{#2}%
    \egroup%
  \egroup%
  \iftoggle{nosep@}{%
    \hskip\csuse{Xinplaceoflemmaseparator@#3}%
    \relax%
    }%
    {\ifcsempty{Xlemmaseparator@#3}%
      {%
        \hskip\csuse{Xinplaceoflemmaseparator@#3}%
        \relax%
      }%
      {%
        \nobreak%
        \hskip\csuse{Xbeforelemmaseparator@#3}%
        \csuse{Xlemmaseparator@#3}%
        \hskip\csuse{Xafterlemmaseparator@#3}%
        \relax%
      }%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Line number printing}
% \begin{macro}{\Xstorelineinfo}
% The \cs{Xstorelineinfo} macro is used to store some data about line number of the current critical footnote, data which will be reused later for the \cs{Xnumberonlyfirstinline} and related setting.
%
% \#1 footnote specification for the current footnote;
% \#2 footnote series.
%    \begin{macrocode}
\newcommand{\Xstorelineinfo}[2]{%
   \l@dp@rsefootspec#1|%
   \iftoggle{Xnumberonlyfirstintwolines@#2}{%
       \xdef\lineinfo@{\l@dparsedstartline - \l@dparsedstartsub - \l@dparsedendline - \l@dparsedendsub}%
       }%
       {%
       \xdef\lineinfo@{\l@dparsedstartline - \l@dparsedstartsub}%
       }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\printlinefootnote}
% The \protect\cs{printlinefootnote} macro is called in each \protect\cs{<type>footfmt} command.
% It controls whether the line number is printed or not, according to the series options. Its first argument is the information about lines; its second is the series of the footnote.
% The printing of the line number is shared in
% \protect\cs{printlinefootnotenumbers}.
% \changes{v1.18.0}{2015/02/23}{Code refactoring in \protect\cs{printlinefootnote}: the printing of the numbers are factorized in  \protect\cs{printlinefootnotearea}}
%  \begin{macrocode}
\newcommand{\printlinefootnote}[2]{%
   \xdef\@currentseries{#2}%
   \iftoggle{nonum@}{%Try if the line number must printed for this specific not (by default, yes)
   \hspace{\csuse{Xinplaceofnumber@#2}}%
   }%
   {%
       {%
           \iftoggle{Xnonumber@#2}%Try if the line number must printed (by default, yes)
           {%
           \hspace{\csuse{Xinplaceofnumber@#2}}%
           }%
           {%
              {\iftoggle{Xnumberonlyfirstinline@#2}% If for this series the line number must be printed only in the first time.
                 {%
                 \ifcsdef{prevline#2}%
                    {%Be sure the \prevline exists.
                    \ifcsequal{prevline#2}{lineinfo@}%Try it
                       {%
                       \ifcsempty{Xsymlinenum@#2}%
                        {%
                            \hspace{\csuse{Xinplaceofnumber@#2}}%
                        }%
                        {\printsymlinefootnotearea{#2}}%
                       }%
                       {%
                        \printlinefootnotearea{#1}{#2}%
                        }%
                    }%
                    {%
                    \printlinefootnotearea{#1}{#2}%
                    }%
              }%
              {%
              \printlinefootnotearea{#1}{#2}%
              }%
              \csxdef{prevline#2}{\lineinfo@}%
           }%
        }%
     }%
   }%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\printsymlinefootnotearea}
% This macro prints the space before the line symbol, changes the font, when prints the line symbol and the space after it.
%    \begin{macrocode}
\newcommand{\printsymlinefootnotearea}[1]{%
  \hspace{\csuse{Xbeforesymlinenum@#1}}%
  \csuse{Xnotenumfont@#1}%
  \ifdimequal{\csuse{Xboxsymlinenum@#1}}{\z@}%
     {\csuse{Xsymlinenum@#1}}%
     {\hbox to \csuse{Xboxsymlinenum@#1}%
       {\csuse{Xsymlinenum@#1}\hfill}%
     }%
  \hspace{\csuse{Xaftersymlinenum@#1}}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\printlinefootnotearea}
% This macro prints the space before the line number, changes the font, then prints the line number and the space after it.
% It is called by \protect\cs{printlinefootnote}
% depending of the options about repeating line numbers.
% The first argument is line information, the second is the notes series (A, B, C,  etc.)
%    \begin{macrocode}
\newcommand{\printlinefootnotearea}[2]{%
  \printXbeforenumber{#2}%
  \csuse{Xnotenumfont@#2}%
  \boxfootnotenumbers{#1}{#2}%
  \printXafternumber{#2}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\boxfootnotenumbers}
% Depending on the user settings, this macro will box line numbers (or not).
% The first argument is line information, the second is the notes series (A, B, C,  etc.)
% The previous \protect\cs{printlinefootnotearea} calls it.
%    \begin{macrocode}
\newcommand{\boxfootnotenumbers}[2]{%
  \ifdimequal{\csuse{Xboxlinenum@#2}}{0pt}{%
       \printlinefootnotenumbers{#1}{#2}%
     }%
     {%
       \hbox to \csuse{Xboxlinenum@#2}%
         {%
         \IfSubStr{RC}{\csuse{Xboxlinenumalign@#2}}{\hfill}{}%
         \printlinefootnotenumbers{#1}{#2}%
         \IfSubStr{LC}{\csuse{Xboxlinenumalign@#2}}{\hfill}{}%
         }%
     }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\printlinefootnotenumbers}
% This macro prints, if needed, the pstart number and the line number.
% The first argument is line information, the second is the notes series (A, B, C, etc.)
% The previous \protect\cs{boxlinefootnote} calls it.
%    \begin{macrocode}
\newcommand{\printlinefootnotenumbers}[2]{%
  \get@pstartcounter%
  \ifboolexpr{%
   (togl{Xpstart@#2} and bool{numberpstart})%
   or togl{Xpstarteverytime@#2}%
   and not (%
      togl{Xpstartonlyfirst@#2}%
      and test {\ifnumequal{\csuse{Xprevpstart@#2}}{\current@pstart}}%
   )%
  }%
  {%
    \printpstart%
    \csuse{Xpstartseparator@#2}%
  }{}%
  \global\cslet{Xprevpstart@#2}{\current@pstart}%
  \get@stanzacounter%
  \ifboolexpr{%
    togl{Xstanza@#2}%
    and bool {numberstanza}%
    and not (%
      togl{Xpstartonlyfirst@#2}%
      and test {\ifnumequal{\csuse{Xprevstanza@#2}}{\current@stanza}}%
    )%
  }{%
    \printstanza%
    \csuse{Xstanzaseparator@#2}%
  }{}%
  \global\cslet{Xprevstanza@#2}{\current@stanza}%
  \iftoggle{Xonlypstart@#2}{}{%
    \csuse{Xtxtbeforenumber@#2}%
    \printlines#1|\ifledRcol@\@Rlineflag\fi|}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\get@pstartcounter}
% A single macro to get the current pstart counter.
%    \begin{macrocode}
\newcommand{\get@pstartcounter}[0]{%
  \ifboolexpr{bool{l@dprintingpages} or bool{l@dprintingcolumns}}%
  {%
    \ifledRcol%
      \global\numdef\current@pstart{\the\c@pstartR}%
    \else%
      \global\numdef\current@pstart{\the\c@pstartL}%
    \fi%
  }%
  {%
    \global\numdef\current@pstart{\the\c@pstart}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\get@stanzacounter}
% The same to get the current stanza counter.
%    \begin{macrocode}
\newcommand{\get@stanzacounter}[0]{%
  \ifboolexpr{bool{l@dprintingpages} or bool{l@dprintingcolumns}}%
  {%
    \ifledRcol%
      \global\numdef\current@stanza{\the\c@stanzaR}%
    \else%
      \global\numdef\current@stanza{\the\c@stanzaL}%
    \fi%
  }%
  {%
    \global\numdef\current@stanza{\the\c@stanza}%
  }%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\printXbeforenumber}
% This macro prints a space (before the line number) in footnote.
% It is called by \protect\cs{printlinefootnotearea}.
% Its only argument is the note series (A, B, C, etc.)
%    \begin{macrocode}
\newcommand{\printXbeforenumber}[1]{%
  \hspace{\csuse{Xbeforenumber@#1}}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\printXafternumber}
% This macro prints the space, adding eventually a \protect\cs{nobreak},  after the line number, in footnote.
% It is called by \protect\cs{printlinefootnotearea}.
% Its only argument is the series
%    \begin{macrocode}
\newcommand{\printXafternumber}[1]{%
  \iftoggle{Xnonbreakableafternumber@#1}{\nobreak}{}%
  \hspace{\csuse{Xafternumber@#1}}%
}%
%    \end{macrocode}
% \end{macro}
%
% If we have decided to print the line number in a specific notes, the \protect\cs{printlines} macro prints the line
% numbers for a note---which, in the
% general case, is a rather complicated task.
% The seven parameters of the
% argument are the line numbers as stored in \protect\cs{l@d@nums}, in the
% form described on \reff{linenumbers}: the starting
% page, line, and sub-line numbers, followed by the ending page,
% line, and sub-line numbers, and then the font specifier for
% the lemma.
%
% \edmac' creator have defined six boolean in order to know which component of line number description we have to print:
% \begin{itemize}
% \item \protect\cs{ifl@d@pnum} for page numbers;
% \item \protect\cs{ifl@d@ssub} for starting sub-line;
% \item \protect\cs{ifl@d@elin} for ending line;
% \item \protect\cs{ifl@d@esl} for ending sub-line; and
% \item \protect\cs{ifl@d@dash} for the dash between the starting and ending groups.
% \end{itemize}
% There is no boolean for the line number because it is always printed.
%
% Maïeul Rouquette has added \protect\cs{ifl@d@Xtwolines} and \protect\cs{ifl@d@Xmorethantwolines}
% to print a symbol which stands for ``and subsequent`` when there are two, three or more lines.
% Is also defines \cs{@annot@start@print} and \cs{@annot@end@print} which define annotations associated with the starting and ending line numbers in critical footnotes.
% \begin{macro}{\ifl@d@pnum}
% \begin{macro}{\ifl@d@ssub}
% \begin{macro}{\ifl@d@elin}
% \begin{macro}{\ifl@d@esl}
% \begin{macro}{\ifl@d@dash}
% \begin{macro}{\ifl@d@Xtwolines}
% \begin{macro}{\ifl@d@Xmorethantwolines}
% \begin{macro}{\@annot@start@print}
% \begin{macro}{\@annot@end@print}
%    \begin{macrocode}
\newif\ifl@d@pnum
\newif\ifl@d@ssub
\newif\ifl@d@elin
\newif\ifl@d@esl
\newif\ifl@d@dash
\newif\ifl@d@Xtwolines%
\newif\ifl@d@Xmorethantwolines%
\let\@annot@start@print\relax%
\let\@annot@end@print\relax%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\l@dparsefootspec}
% \begin{macro}{\l@dp@rsefootspec}
% \begin{macro}{\l@dparsedstartpage}
% \begin{macro}{\l@dparsedstartline}
% \begin{macro}{\l@dparsedstartsub}
% \begin{macro}{\l@dparsedendpage}
% \begin{macro}{\l@dparsedendline}
% \begin{macro}{\l@dparsedendsub}
% \protect\cs{l@dparsefootspec}\marg{spec}\marg{lemma}\marg{text} parses a footnote
% specification. \meta{lemma} and \meta{text} are the lemma and text
% respectively. \meta{spec} is the line and page number and lemma font
% specifier in \protect\cs{l@d@nums} style format.
% The real work is done
% by \protect\cs{l@dp@rsefootspec} which defines macros holding the numeric values.
% In many cases, this last command is called directly.
% Just a reminder of the arguments: \\
% \verb?\printlines    #1      |  #2  |   #3    |    #4    |  #5  |  #6     |   #7?\\
% \verb?\printlines start-page | line | subline | end-page | line | subline | font?flag
%    \begin{macrocode}
\newcommand*{\l@dparsefootspec}[3]{\l@dp@rsefootspec#1|}
\def\l@dp@rsefootspec#1|#2|#3|#4|#5|#6|#7|{%
  \gdef\l@dparsedstartpage{#1}%
  \gdef\l@dparsedstartline{#2}%
  \gdef\l@dparsedstartsub{#3}%
  \gdef\l@dparsedendpage{#4}%
  \gdef\l@dparsedendline{#5}%
  \gdef\l@dparsedendsub{#6}%
}
%    \end{macrocode}
% Initialise the several number value macros.
%    \begin{macrocode}
\def\l@dparsedstartpage{0}%
\def\l@dparsedstartline{0}%
\def\l@dparsedstartsub{0}%
\def\l@dparsedendpage{0}%
\def\l@dparsedendline{0}%
\def\l@dparsedendsub{0}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \begin{macro}{\setprintlines}
%
% The macro \protect\cs{setprintlines} does the work of deciding what numbers should
% be printed. Its arguments are the same as the first 6 of \protect\cs{printlines}.
% \changes{v0.7.0}{2005/02/18}{Added \protect\cs{setprintlines} for use by \protect\cs{printlines}}
%    \begin{macrocode}
\newcommand*{\setprintlines}[6]{%
  \let\@annot@start@print\relax%
  \let\@annot@end@print\relax%
  \l@d@pnumfalse%
  \l@d@dashfalse%
  \l@d@elinfalse%
%    \end{macrocode}
% We print the page numbers only if\/: 1)~we are doing
% the lineation by page, and 2)~the ending page number is different
% from the starting page number.\label{printlines}a
%    \begin{macrocode}
  \ifbypage@
     \ifnum#4=#1 \else
        \l@d@pnumtrue
        \l@d@dashtrue
     \fi
  \fi
%    \end{macrocode}
%
% We print the ending line number if\/: (1)~we are printing the ending
% page number, or (2)~the ending line number is different from the starting line number.
% If either of these conditions is true, we also print the annotation linked to the ending line number annotations.
%    \begin{macrocode}
  \ifboolexpr{%
    bool{l@d@pnum}%
    or not test{\ifnumequal{#2}{#5}}%
   }{%
    \l@d@elintrue%
    \l@d@dashtrue%
    \unless\ifx\relax\annot@end%
      \def\@annot@end@print{%
        \l@wrapcs@ifnotemptybox{Xwraplinenumannotation@\@currentseries}{\annot@end}%
      }%
    \fi%
    }{}%
%    \end{macrocode}
%
% We define the starting line number annotation as a merge of the starting annotation and ending annotation if we don't print the ending line number.
% Otherwise, it is only the starting annotation.
%    \begin{macrocode}
  \ifl@d@elin%
    \def\@annot@start@print{%
      \l@wrapcs@ifnotemptybox{Xwraplinenumannotation@\@currentseries}{\annot@start}%
    }%
  \else%
    \ifx\annot@start\annot@end%
      \unless\ifx\@annot@start\relax%
        \def\@annot@start@print{%
          \l@wrapcs@ifnotemptybox{Xwraplinenumannotation@\@currentseries}{\annot@start}%
        }%
      \fi%
    \else%
      \ifx\@annot@end@print\relax%
        \def\@annot@start@print{%
          \l@wrapcs@ifnotemptybox{Xwraplinenumannotation@\@currentseries}{%
            \ifx\annot@start\empty\else%
              \annot@start%
              \ifdefined\linerangesep@%
                \linerangesep@%
              \else%
                \csuse{Xlinerangeseparator@\@currentseries}%
              \fi%
            \fi%
            \annot@end%
            }%
          }%
       \else%
         \let\@annot@start@print\@annot@end@print%
         \let\@annot@end@print\relax%
      \fi%
    \fi%
  \fi%
%    \end{macrocode}
% We print the starting sub-line if it is nonzero.
%    \begin{macrocode}
  \l@d@ssubfalse
  \ifnum#3=0 \else
      \l@d@ssubtrue
  \fi
%    \end{macrocode}
%
% We print the ending sub-line if it is nonzero and: (1)~it is different
% from the starting sub-line number, or (2)~the ending line number is
% being printed.
%    \begin{macrocode}
  \l@d@eslfalse
  \ifnum#6=0 \else
      \ifnum#6=#3
         \ifl@d@elin \l@d@esltrue \else \l@d@eslfalse \fi
      \else
         \l@d@esltrue
         \l@d@dashtrue
      \fi
  \fi%
%    \end{macrocode}
% However, if the \protect\cs{Xtwolines} is set for the current series, we do not print the last line number.
%    \begin{macrocode}
  \ifl@d@dash%
    \ifboolexpr{togl{fulllines@} or test{\ifcsempty{Xtwolines@\@currentseries}}}%
      {}%
      {%
      \setistwofollowinglines{#1}{#2}{#4}{#5}%
        \ifboolexpr{%
          (%
               togl {Xtwolinesbutnotmore@\@currentseries}%
               and not%
                 (%
                  bool {istwofollowinglines@}%
                 )%
          )%
          or%
          (%
             (not test{\ifnumequal{#1}{#4}})%
               and togl{Xtwolinesonlyinsamepage@\@currentseries}%
             )%
          }%
          {}%
          {%
          \l@d@dashfalse%
          \l@d@Xtwolinestrue%
          \l@d@elinfalse%
          \l@d@eslfalse%
          \ifcsempty{Xmorethantwolines@\@currentseries}%
            {}%
            {\ifistwofollowinglines@\else%
              \l@d@Xmorethantwolinestrue%
             \fi%
            }%
          }%
      }%
  \fi%
%    \end{macrocode}
% If the \cs{Xnoidenticallinenumannotation} is set for this series, we check if the ending annotation is identical to the starting.
% If true, we don't print the ending annotation
%    \begin{macrocode}
  \iftoggle{Xnoidenticallinenumannotation@\@currentseries}{%
    \ifx\annot@start\annot@end%
      \let\@annot@end@print\relax%
      \ifx\linenumrep\@gobble%Don't print the dash if we're not printing the line number
        \l@d@dashfalse%
      \fi%
    \fi%
  }{}%
%    \end{macrocode}
% Finally, we check for \cs{Xlinenumannotationonlyfirst} and \cs{Xlinenumannotationonlyfirstintwo}, and we redefine, if required, \cs{@annot@start@print} and \cs{annot@end@print}. We also store the current line number annotations.
%    \begin{macrocode}
  \iftoggle{Xlinenumannotationonlyfirst@\@currentseries}{%
    \ifboolexpr{%
      (%
        togl{Xlinenumannotationonlyfirstintwo@\@currentseries}%
        and test{\ifcsequal{annot@start}{prevannot@start@\@currentseries}}%
        and test{\ifcsequal{annot@end}{prevannot@end@\@currentseries}}%
      )%
      or%
      (%
        not togl{Xlinenumannotationonlyfirstintwo@\@currentseries}%
        test{\ifcsequal{annot@start}{prevannot@start@\@currentseries}}%
      )%
    }{%
      \def\@annot@start@print{%
        \l@wrapcs@ifnotemptybox{Xwraplinenumannotation@\@currentseries}{\csuse{Xsymlinenumannotation@\@currentseries}}%
      }%
      \let\@annot@end@print\relax%
      \ifx\linenumrep\@gobble%Don't print the dash if we're not printing the line number
        \l@d@dashfalse%
      \fi%
    }{}%
    \global\cslet{prevannot@start@\@currentseries}{\annot@start}%
    \global\cslet{prevannot@end@\@currentseries}{\annot@end}%
  }%
  {}%
%    \end{macrocode}
% End of \protect\cs{setprintlines}.
%    \begin{macrocode}
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setistwofollowinglines}
% The \protect\cs{ifistwofollowinglines} boolean, used by the \protect\cs{Xtwolines} and related setting, is set to true by \protect\cs{setistwofollowinglines}.
% This command takes the following arguments:
% \begin{itemize}
%  \item \verb+#1+ First page number.
%  \item \verb+#2+ First line number.
%  \item \verb+#3+ Last page number.
%  \item \verb+#4+ Last line number.
% \end{itemize}
% If \verb+#3+-\verb+#2+ = 1, then that means the two lines are subsequent, and consequently \protect\cs{ifistwofollowinglines} is set to true.
% However, if we use lineation by page, two given lines can be subsequent if:
% \begin{itemize}
%   \item The first line number is equal to the last line number of the first page.
%   \item The last line number is equal to 1.
%   \item \verb+#3+-\verb+#1+ is equal to 1.
% \end{itemize}
%    \begin{macrocode}
\newif\ifistwofollowinglines@%
\newcommand{\setistwofollowinglines}[4]{%
    \ifcsdef{lastlinenumberon@#1}%
      {\numdef{\tmp}{\csuse{lastlinenumberon@#1}}}%
      {\numdef{\tmp}{0}}%
    \istwofollowinglines@false%
    \ifnumequal{#4-#2}{1}%
    {\istwofollowinglines@true}%
    {\ifbypage@%
      \ifnumequal{#3-#1}{1}%
      {%
      \ifnumequal{#2}{\tmp}%
        {\ifnumequal{#4}{1}{\istwofollowinglines@true}{}}%
        {}%
      }%
      {}%
     \fi%
    }%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\printlines}
% \changes{v2.5.0}{2015/11/13}{\protect\cs{printlines} takes an eighth argument: the line flag}
% So, we have decided which part of line number sets will be printed depending of these value.
% Now we are ready to print them.
% If the lineation is by pstart, we print the pstart.
% \changes{v0.15.0}{2012/06/11}{Line numbering can be reset at each pstart.}
% Arguments are 1) start page number 2) start line number 3) start subline number 4) end page number 5) end line number 6) end subline number 7) font specification 8) side flag
%    \begin{macrocode}
\def\printlines#1|#2|#3|#4|#5|#6|#7|#8|{%
  \begingroup%
%    \end{macrocode}
% Decide which part of line number components we will print.
%    \begin{macrocode}
  \setprintlines{#1}{#2}{#3}{#4}{#5}{#6}%
%    \end{macrocode}
% One subtlety left here is when to print a period between
% numbers. But the only instance in which this is tricky is for the
% ending sub-line number: it could come after the starting
% sub-line number (in which case we want only the dash) or after an
% ending line number (in which case we need to insert a period).
% So, first, print the start line number.
%    \begin{macrocode}
  \ifdimequal{\csuse{Xboxstartlinenum@\@currentseries}}{0pt}%
    {\bgroup}%
    {\leavevmode\hbox to \csuse{Xboxstartlinenum@\@currentseries}\bgroup\hfill}%
  \ifcsstring{Xlinenumannotationposition@\@currentseries}{before}%
    {\@annot@start@print}%
    {}%
  \ifl@d@pnum%
    \wrap@edcrossref{\@this@crossref@start}{#1}%
    \csuse{Xpagelinesep@\@currentseries}%
  \fi%
  \wrap@edcrossref{\@this@crossref@start}{%
    \linenumrep{#2}%
    \iftoggle{Xlineflag@\@currentseries}{#8}{}%
  }%
  \ifl@d@ssub%
    \csuse{Xsublinesep@\@currentseries}%
    \wrap@edcrossref{\@this@crossref@start}{\sublinenumrep{#3}}%
  \fi
  \ifcsstring{Xlinenumannotationposition@\@currentseries}{after}%
    {\@annot@start@print}%
    {}%
  \egroup%
%    \end{macrocode}
% Then print the dash + end line number, or the range symbol.
% \changes{v0.3.0}{2004/02/14}{Added \protect\cs{linenumr@p} and \protect\cs{sublinenumr@p}
%        to \protect\cs{printlines}}
% \changes{v1.20.0}{2015/03/22}{Added \protect\cs{ifl@d@Xmorethantwolines} and \protect\cs{ifl@d@Xmorethantwolines} to \protect\cs{printlines}}
%    \begin{macrocode}
  \ifdimequal{\csuse{Xboxendlinenum@\@currentseries}}{0pt}%
    {\bgroup}%
    {\hbox to \csuse{Xboxendlinenum@\@currentseries}\bgroup}%
  \ifl@d@Xtwolines%
    \ifl@d@Xmorethantwolines%
      \csuse{Xmorethantwolines@\@currentseries}%
    \else%
      \csuse{Xtwolines@\@currentseries}%
    \fi%
  \else%
    \ifl@d@dash%
      \ifdefined\linerangesep@%
        \linerangesep@%
      \else%
        \csuse{Xlinerangeseparator@\@currentseries}%
      \fi%
    \fi%
    \ifcsstring{Xlinenumannotationposition@\@currentseries}{before}%
      {\@annot@end@print}%
      {}%
    \ifl@d@pnum%
       \wrap@edcrossref{\@this@crossref@end}{#4}%
       \csuse{Xpagelinesep@\@currentseries}%
    \fi%
    \ifl@d@elin%
      \wrap@edcrossref{\@this@crossref@end}{%
        \linenumrep{#5}%
        \iftoggle{Xlineflag@\@currentseries}{#8}{}%
       }%
    \fi%
    \ifl@d@esl%
       \ifl@d@elin%
         \csuse{Xsublinesep@\@currentseries}%
       \fi%
       \wrap@edcrossref{\@this@crossref@end}{\sublinenumrep{#6}}%
    \fi%
    \ifcsstring{Xlinenumannotationposition@\@currentseries}{after}%
      {\@annot@end@print}%
      {}%
  \fi%
  \ifdimequal{\csuse{Xboxendlinenum@\@currentseries}}{0pt}%
    {}%
    {\hfill}%Prevent underfull hbox
  \egroup%
  \endgroup%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Footnote grouped by line}
% \begin{macro}{\prepare@Xgroupbyline}
% \cs{prepare@Xgroupbyline} is a macro called on the \cs{meta{XXX}vfootnote} if \cs{Xgroupbyline} is set to true, instead of calling \cs{insert} directly.
% \#1 The series\\
% \#2 The content of the footnote, which is also the line number indication\\
% \#3 This macro, which prepares the contents of the insertion \\
%    \begin{macrocode}
\newcommand{\prepare@Xgroupbyline}[3]{%
  \iftoggle{Xgroupbylineseparetwolines@#1}{%
    \l@dparsefootspec#2%
    \ifcsdef{#1@forinserting@\l@dparsedendpage-\l@dparsedendline-\l@dparsedendsub}%
      {%
        \csgappto{#1@forinserting@\l@dparsedendpage-\l@dparsedendline-\l@dparsedendsub}{%
          \hskip\csuse{Xafternote@#1}\relax%
        }%
      }%
      {}%
    \add@hooktoggle@specific@to@cs{#1@forinserting@\l@dparsedendpage-\l@dparsedendline-\l@dparsedendsub}%
    \add@hookarg@specific@to@cs{#1@forinserting@\l@dparsedendpage-\l@dparsedendline-\l@dparsedendsub}%
    \csxappto%
      {#1@forinserting@\l@dparsedendpage-\l@dparsedendline-\l@dparsedendsub}%
      {%
        \keep@this@crossref@forinserting%
        \unexpanded{%
          \ifcsempty{Xsymlinenum@#1}%
            {\csuse{Xparafootsep@#1}}%
            {}%
          #3{#1}{#2}%
        }%
      }%
    \listcsxadd{#1@forinserting}{\l@dparsedendpage-\l@dparsedendline-\l@dparsedendsub}%
  }{%
  \ifcsdef{#1@forinserting@all}{%
    \csgappto%
      {#1@forinserting@all}%
      {\hskip\csuse{Xafternote@#1}\relax}%
    }{}%
  \add@hooktoggle@specific@to@cs{#1@forinserting@all}%
  \add@hookarg@specific@to@cs{#1@forinserting@all}%
  \csxappto%
    {#1@forinserting@all}%
    {%
      \keep@this@crossref@forinserting%
      \unexpanded{%
        \ifcsempty{Xsymlinenum@#1}%
          {\csuse{Xparafootsep@#1}}%
          {}%
        #3{#1}{#2}%
      }%
    }%
  }%
  \listcsgadd{#1@forinserting}{all}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\keep@this@crossref@forinserting}
% \cs{keep@this@crossref@forinserting} is called by \cs{prepare@Xgroupbyline}. It just ensures that \cs{@this@crossref@start} and \cs{this@crossref@end} value are kept in memory.
%    \begin{macrocode}
\newcommand{\keep@this@crossref@forinserting}{%
  \unexpanded{\gdef\@this@crossref@start}{\@this@crossref@start}%
  \unexpanded{\gdef\@this@crossref@end}{\@this@crossref@end}%
}%
%    \end{macrocode}
% \end{macro}
% \section{Familiar footnotes}
%
% \subsection{Adjacent footnotes}
%    The original \edmac{} provided users with five series of critical footnotes (\protect\cs{Afootnote} \protect\cs{Bfootnote}  \protect\cs{Cfootnote} \protect\cs{Dfootnote} \protect\cs{Efootnote}),
% and \LaTeX\ provides a single numbered footnote. The \macpackage{} package
% uses the \edmac{} mechanism to provide six series of numbered footnotes.
%
%    First, though, the \protect\package{footmisc} package has an option whereby
% two or more consecutive \protect\cs{footnote}s have their marks separated
% by commas. This seemed to Peter Wilson such a useful ability that it was provided
% automatically by \eledmac.
%
% Maïeul Rouquette has maintened this feature in \macpackage, despite he thought  that is not directly in relationship with the aim of \macpackage.
%
%
% \begin{macro}{\multiplefootnotemarker}
% \begin{macro}{\multfootsep}
% These macros may have been defined by the \protect\ltxclass{memoir} class,
% are provided by the \protect\package{footmisc} package and perhaps
% by other footnote packages.
% That is why we use \protect\cs{providecommand} and not \protect\cs{newcommand}.
%    \begin{macrocode}
\providecommand*{\multiplefootnotemarker}{3sp}
\providecommand*{\multfootsep}{\textsuperscript{\normalfont,}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\m@mmf@prepare}
% A pair of self-cancelling kerns. This may have been defined in the
% \protect\ltxclass{memoir} class.
%    \begin{macrocode}
\providecommand*{\m@mmf@prepare}{%
  \kern-\multiplefootnotemarker
  \kern\multiplefootnotemarker\relax}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\m@mmf@check}
% This may have been defined in the \protect\ltxclass{memoir} class. If it recognises
% the last kern as \protect\cs{multiplefootnotemarker} it typesets \protect\cs{multfootsep}.
%    \begin{macrocode}
\providecommand*{\m@mmf@check}{%
  \ifdim\lastkern=\multiplefootnotemarker\relax
    \edef\@x@sf{\the\spacefactor}%
    \unkern
    \multfootsep
    \spacefactor\@x@sf\relax
  \fi}

%    \end{macrocode}
% \end{macro}
%
% We have to modify \protect\cs{@footnotetext} and \protect\cs{@footnotemark}. However,
% if \protect\ltxclass{memoir} is used the modifications have already been made.
% \changes{v0.4.1}{2004/03/25}{Only change \protect\cs{@footnotetext} and
%                           \protect\cs{@footnotemark} if memoir not used}
%    \begin{macrocode}
\@ifclassloaded{memoir}{}{%
%    \end{macrocode}
% \begin{macro}{\@footnotetext}
% Add \protect\cs{m@mmf@prepare} at the end of \protect\cs{@footnotetext}.
%    \begin{macrocode}
\apptocmd{\@footnotetext}{\m@mmf@prepare}{}{}
%    \end{macrocode}
% \end{macro}
%
% \changes{v2.0.0}{2015/07/19}{Patch \protect\cs{@footnotemark} instead of redefine it}
% \begin{macro}{\@footnotemark}
% Modify \protect\cs{@footnotemark} to cater for adjacent \protect\cs{footnote}s.
%    \begin{macrocode}

\patchcmd{\@footnotemark}
  {\nobreak}
  {\m@mmf@check
  \nobreak
  }
  {}{}
\patchcmd{\@footnotemark}
  {\@makefnmark}
  {\@makefnmark
  \m@mmf@prepare
  }
  {}{}
%    \end{macrocode}
% \end{macro}
% Finished the modifications for the non-memoir case.
%    \begin{macrocode}
}

%    \end{macrocode}
%
% \subsection{Regular footnotes for numbered texts}
% \begin{macro}{\l@doldold@footnotetext}
% \begin{macro}{\@footnotetext}
% In order to enable the regular \protect\cs{footnote}s in numbered text
% we have to play around with its \protect\cs{@footnotetext}, using
% different forms for when in numbered or regular text.
% \changes{v0.5.0}{2004/04/03}{Enabled regular \protect\cs{footnote} in numbered text}
%    \begin{macrocode}
\pretocmd{\@footnotetext}{%
  \ifnumberedpar@
    \edtext{}{\l@dbfnote{#1}}%
  \else
  }{}{}
\apptocmd{\@footnotetext}{\fi}{}{}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dbfnote}
% \begin{macro}{\vl@dbfnote}
% \begin{macro}{\vl@dbfnote}
% \begin{macro}{\footnote}
% \begin{macro}{\get@fnmark}
% \begin{macro}{\get@thisfootnote}
% \protect\cs{l@dbfnote} adds the footnote to the insert list, and
% \protect\cs{vl@dbfnote} calls the original \protect\cs{@footnotetext}.
% \changes{v0.6.0}{2004/11/23}{Changed \protect\cs{l@dbfnote} and \protect\cs{vl@dbfnote} as
% originals could give incorrect markers in the footnotes}
% We also patch \cs{footnote} in order to get the correct footnote numbers when typesetting parallel texts. This is moved into a \cs{get@fnmark} command.
% \changes{v1.4.1}{2012/11/16}{Compatibility of standard footnotes with \eledmac when these footnotes contain any commands.}
%    \begin{macrocode}

\patchcmd%
  {\footnote}%
  {\stepcounter\@mpfn}%
  {%
  \ifboolexpr{bool{l@dpairing} or bool{l@dprintingpages} or bool{l@dprintingcolumns}}{%
    \global\advance\footnote@reading by \@ne%
    \get@thisfootnote%
    \get@fnmark{\thisc@footnote}%
    \ifcsdef{footnotereading\the\footnote@reading=typeset}%
      {\setcounter{\@mpfn}{\csuse{footnotereading\the\footnote@reading=typeset}}}%
      {\setcounter{\@mpfn}{\footnote@reading}}%
    }{%
      \stepcounter\@mpfn%
    }%
  }%
  {}
  {}

\newcommand{\get@thisfootnote}{%
    \ifboolexpr{bool{l@dpairing} or bool{l@dprintingpages} or bool{l@dprintingcolumns}}{%
      \protected@xdef\thisc@footnote{\the\footnote@reading}%
    }{%
      \protected@xdef\thisc@footnote{\the\c@footnote}%
    }%
}%

\newcommand{\l@dbfnote}[1]{%
 \get@thisfootnote%
  \gdef\@tag{#1\relax}%
    \ifledRcol%
      \xright@appenditem{%
          \ifdefined\Hy@footnote@currentHref%
            \noexpand\def\noexpand\Hy@footnote@currentHref{\Hy@footnote@currentHref}%
          \fi%
          \noexpand\vl@dbfnote{{\expandonce\@tag}}{\thisc@footnote}%
        }%
                         \to\inserts@listR
       \global\advance\insert@countR \@ne%
    \else%
      \xright@appenditem{%
          \ifdefined\Hy@footnote@currentHref%
            \noexpand\def\noexpand\Hy@footnote@currentHref{\Hy@footnote@currentHref}%
          \fi%
          \noexpand\vl@dbfnote{{\expandonce\@tag}}{\thisc@footnote}%
       }%
                         \to\inserts@list
      \global\advance\insert@count \@ne%
    \fi
  \ignorespaces%
}%

\newcommand{\get@fnmark}[1]{%
  \ifboolexpr{bool{l@dpairing} or bool{l@dprintingpages} or bool{l@dprintingcolumns}}%
    {%
      \stepcounter{footnote@typeset}%
      \setcounter{footnote}{\c@footnote@typeset}%
        \immediate\write\@mainaux{%
          \csgdef{footnotereading#1=typeset}{\the\c@footnote@typeset}%
         }%
      \def\@thefnmark{\thefootnote}%
    }%
    {%
      \setcounter{footnote}{#1}%
      \def\@thefnmark{\thefootnote}%
    }%
}%

\newcommand{\vl@dbfnote}[2]{%
  \get@fnmark{#2}%
  \@footnotetext{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Footnote formats}
%
% Some of the code for the various formats is remarkably similar to that
% in section~\ref{sec:nfootformat}.
%
% The following macros generally set things up for the `standard' footnote
% format.
%
% \begin{macro}{\prebodyfootmark}
% \begin{macro}{\postbodyfootmark}
% Two convenience macros for use by \protect\cs{...@footnotemark...} macros.
%    \begin{macrocode}
\newcommand*{\prebodyfootmark}{%
  \leavevmode
  \ifhmode
    \edef\@x@sf{\the\spacefactor}%
    \m@mmf@check
    \nobreak
  \fi}
\newcommand{\postbodyfootmark}{%
  \m@mmf@prepare
  \ifhmode\spacefactor\@x@sf\fi\relax}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Footnote arrangement}
%
% \subsubsection{User level macro}
% \begin{macro}{\arrangementX}
% \protect\cs{arrangementX}\oarg{s}\marg{arrangement}
%  command calls, for each series, a specific command which set many counters and commands in order to define specific arrangement.
%
%    \begin{macrocode}
\newcommandx{\arrangementX}[2][1,usedefault]{%
  \def\do##1{%
    \csname arrangementX@#2\endcsname{##1}%
  }%
  \ifstrempty{#1}%
    {%
    \dolistloop{\@series}%
    }%
    {
    \docsvlist{#1}%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Normal footnotes}
% \begin{macro}{\normal@footnotemarkX}
% \protect\cs{normal@footnotemarkX}\marg{series} sets up the typesetting of the
% marker at the point where the footnote is called for.
%    \begin{macrocode}
\newcommand*{\normal@footnotemarkX}[1]{%
  \prebodyfootmark
  \wrapped@bodyfootmarkX{#1}%
  \postbodyfootmark}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalbodyfootmarkX}
% The \protect\cs{normalbodyfootmarkX}\marg{series} \emph{really} typesets the
% in-text marker. The style is the normal superscript.
%    \begin{macrocode}
\newcommand*{\normalbodyfootmarkX}[1]{%
  \hbox{\textsuperscript{\normalfont\@nameuse{@thefnmark#1}}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalvfootnoteX}
% \changes{v1.5.1}{2013/08/16}{Fix a bug with normal familiar footnotes when mixing RTL and LTR text.}
% \protect\cs{normalvfootnoteX}\marg{series}\marg{text} does the \protect\cs{insert} for
% the \meta{series} and calls the series' \protect\cs{footfmt...} to format the
% \meta{text}.
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\normalvfootnoteX}[2]{%
  \beforeinsertion@X{#1}%
  \insert\@nameuse{footins#1}\bgroup
    \fontseries{\seriesdefault}%
    \fontshape{\shapedefault}%
    \hsize=\expandafter\dimexpr\csuse{widthX@#1}\relax%
    \noindent\csuse{bhooknoteX@#1}%
    \csuse{notefontsizeX@#1}%
    \footsplitskips
    \ifl@dpairing\ifl@dpaging\else%
      \setnoteswidthliketwocolumnsX@{#1}%
    \fi\fi%
    \setnotesXpositionliketwocolumns@{#1}%
    \spaceskip=\z@skip \xspaceskip=\z@skip
    \csuse{\csuse{footnote@dir}}\@nameuse{footfmt#1}{#1}{#2}\egroup}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mpnormalvfootnoteX}
% The minipage version.
%    \begin{macrocode}
\newcommand*{\mpnormalvfootnoteX}[3]{%
  \get@thisfootnoteX{#1}%
  \get@fnmarkX{#1}{\thisc@footnote}{#3}%
  \ifstrempty{#3}{%
    \edef\this@footnoteX@reading{\the\csname footnote#1@reading\endcsname}%
  }{%
    \edef\this@footnoteX@reading{###3}%
  }%
  \global\setbox\@nameuse{mpfootins#1}\vbox{%
    \unvbox\@nameuse{mpfootins#1}
    \noindent\csuse{bhooknoteX@#1}%
    \csuse{notefontsizeX@#1}%
    \hsize\columnwidth
    \@parboxrestore
    \color@begingroup
    \@nameuse{footfmt#1}{#1}{#2}\color@endgroup}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalfootfmtX}
% \protect\cs{normalfootfmtX}\marg{series}\marg{text} typesets the footnote text,
% prepended by the marker.
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\normalfootfmtX}[2]{%
 \ifluatex%
    \textdir\footnote@luatextextdir%
    \pardir\footnote@luatexpardir%
 \fi%
   \protected@edef\@currentlabel{%
       \@nameuse{@thefnmark#1}%
   }%
  \ledsetnormalparstuffX{#1}%
  \sethangindentX{#1}%
  \rule\z@\splittopskip%
  {{\csuse{notenumfontX@#1}\wrapped@footfootmarkX{#1}}%
    \csuse{wrapcontentX@#1}{#2}%
  \strut\par}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalfootfootmarkX}
% \protect\cs{normalfootfootmarkX}\marg{series} is called by \protect\cs{normalfootfmtX}
% to typeset the footnote marker in the footer before the footnote text.
%    \begin{macrocode}
\newcommand*{\normalfootfootmarkX}[1]{%
  \textsuperscript{\@nameuse{@thefnmark#1}}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalfootstartX}
% \protect\cs{normalfootstartX}\marg{series} is the \meta{series} footnote
% starting macro used in the output routine.
%    \begin{macrocode}
\newcommand*{\normalfootstartX}[1]{%
    \ifdimequal{0pt}{\prenotesX@}{}%
      {%
      \iftoggle{prenotesX@}{%
           \togglefalse{prenotesX@}%
           \skip\csname footins#1\endcsname=%
             \glueexpr\csuse{prenotesX@}+\csuse{afterruleX@#1}\relax%
           }%
          {}%
      }%
  \vskip\skip\csname footins#1\endcsname%
  \leftskip=\z@
  \rightskip=\z@
  \ifl@dpairing\else%
     \hsize=\old@hsize%
  \fi%
  \setnoteswidthliketwocolumnsX@{#1}%
  \setnotesXpositionliketwocolumns@{#1}%
  \print@footnoteXrule{#1}%
}%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalfootnoteruleX}
% The rule drawn before the footnote series group.
%    \begin{macrocode}
\let\normalfootnoteruleX=\footnoterule

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalfootgroupX}
% \protect\cs{normalfootgroupX}\marg{series} sends the contents of the \meta{series}
% insert box to the output page without alteration.
%    \begin{macrocode}
\newcommand*{\normalfootgroupX}[1]{%
  \csuse{bhookgroupX@#1}%
  \unvbox\@nameuse{footins#1}%
  \hsize=\old@hsize%
  }%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mpnormalfootgroupX}
% The minipage version.
%    \begin{macrocode}
\newcommand*{\mpnormalfootgroupX}[1]{%
  \vskip\skip\@nameuse{mpfootins#1}
  \ifl@dpairing\ifparledgroup%
    \leavevmode\marks\parledgroup@{begin}%
    \marks\parledgroup@series{#1}%
    \marks\parledgroup@type{footnoteX}%
  \fi\fi\normalcolor
  \ifparledgroup%
    \ifl@dpairing%
    \else%
      \setnoteswidthliketwocolumnsX@{#1}%
      \setnotesXpositionliketwocolumns@{#1}%
      \print@footnoteXrule{#1}%
    \fi%
  \else%
    \setnoteswidthliketwocolumnsX@{#1}%
    \setnotesXpositionliketwocolumns@{#1}%
    \print@footnoteXrule{#1}%
  \fi%
  \csuse{bhookgroupX@#1}%
  \unvbox\@nameuse{mpfootins#1}}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\normalbfnoteX}
% \changes{v0.7.0}{2005/02/18}{Removed extraneous space from \protect\cs{normalbfnoteX}}
% \changes{v1.4.9}{2013/07/10}{Allow to redefine \protect\cs{thefootnoteX} with \c{alph} when some packages are loaded.}
% \#1 = footnote series, \#2 = footnote content, \#3 manual footnote number
%    \begin{macrocode}

\newcommand{\normalbfnoteX}[3]{%
  \get@thisfootnoteX{#1}%
    \ifledRcol%
      \ifluatex
          \footnotelang@lua[R]%
      \fi
      \@ifundefined{xpg@main@language}%if polyglossia
        {}%
        {\footnotelang@poly[R]}%
      \xright@appenditem{%
        \noexpand\led@set@index@fornote{#1}%
        \noexpand\prepare@edindex@fornote{\l@d@nums}%
        \unexpanded{\gdef\@currentnotetype{familiar}}%
        \unexpanded{\def\this@footnoteX@reading}{\the\csname footnote#1@reading\endcsname}%
        \noexpand\vbfnoteX{#1}{#2}{\thisc@footnote}{#3}%
        \noexpand\led@reinit@index@fornote%
        \unexpanded{\advance\@edindex@fornote@\m@ne}%
      }%
                         \to\inserts@listR
       \global\advance\insert@countR \@ne%
    \else%
      \ifluatex
          \footnotelang@lua%
      \fi
      \@ifundefined{xpg@main@language}%if polyglossia
        {}%
        {\footnotelang@poly}%
      \xright@appenditem{%
        \noexpand\led@set@index@fornote{#1}%
        \noexpand\prepare@edindex@fornote{\l@d@nums}%
        \unexpanded{\gdef\@currentnotetype{familiar}}%
        \unexpanded{\def\this@footnoteX@reading}{\the\csname footnote#1@reading\endcsname}%
        \noexpand\vbfnoteX{#1}{#2}{\thisc@footnote}{#3}%
        \noexpand\led@reinit@index@fornote%
        \unexpanded{\advance\@edindex@fornote@\m@ne}%
      }%
                         \to\inserts@list
      \global\advance\insert@count \@ne%
    \fi
  \ignorespaces}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\get@thisfootnoteX}
% The macro \cs{get@thisfootnote} command just saves the footnote number in the \cs{thisfootnote} macro, depending on the use of pairing environments.
%    \begin{macrocode}
\newcommand{\get@thisfootnoteX}[1]{%
    \ifboolexpr{bool{l@dpairing} or bool{l@dprintingpages} or bool{l@dprintingcolumns}}{%
      \protected@xdef\thisc@footnote{\the\csname footnote#1@reading\endcsname}%
    }{%
      \protected@xdef\thisc@footnote{\the\csname c@footnote#1\endcsname}%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\vbfnoteX}
% This command calls the correct footnote-inserting commands.
% \#1 footnote series, \#2 footnote content, \#3 footnote counter, \#4 manual footnote mark
%    \begin{macrocode}
\newcommand{\vbfnoteX}[4]{%
  \get@fnmarkX{#1}{#3}{#4}\relax%
  \@nameuse{regvfootnote#1}{#1}{#2}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\get@fnmarkX}
% This command gets the correct footnote number when typesetting parallel texts.
% \#1 footnote series, \#2 footnote counter, \#3 manual footnote number
%    \begin{macrocode}
\newcommand{\get@fnmarkX}[3]{%
  \ifstrempty{#3}{%
    \ifboolexpr{bool{l@dpairing} or bool{l@dprintingpages} or bool{l@dprintingcolumns}}%
      {%
        \stepcounter{footnote#1@typeset}%
        \setcounter{footnote#1}{\value{footnote#1@typeset}}%
        \@namedef{@thefnmark#1}{\csuse{thefootnote#1}}%
          \immediate\write\@mainaux{%
            \csgdef{footnote#1reading#2=typeset}{\the\csname c@footnote#1@typeset\endcsname}%
           }%
      }%
      {%
        \setcounter{footnote#1}{#2}%
        \@namedef{@thefnmark#1}{\csuse{thefootnote#1}}%
      }%
  }%
  {%
    \csdef{@thefnmark#1}{#3}%
  }%
}%
%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\vnumfootnoteX}
% \changes{v0.7.0}{2005/02/18}{Removed extraneous space from \protect\cs{vnumfootnoteX}}
% \#1 footnote series, \#2 footnote content, \#3 manual footnote mark
%    \begin{macrocode}

\newcommand{\vnumfootnoteX}[3]{%
  \ifnumberedpar@
    \edtext{}{\normalbfnoteX{#1}{#2}{#3}}%
  \else
    \def\this@footnoteX@reading{\the\csname footnote#1@reading\endcsname}%
    \get@thisfootnoteX{#1}%
    \get@fnmarkX{#1}{\expandonce\thisc@footnote}{#3}%
    \@nameuse{regvfootnote#1}{#1}{#2}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{arrangementX@normal}
% \protect\cs{arrangementX@normal}\marg{series} initialises the settings for
% the \meta{series} footnotes. This should always be called for
% each series.
%    \begin{macrocode}
\newcommand*{\arrangementX@normal}[1]{%
  \csgdef{series@displayX#1}{normal}
  \expandafter\let\csname footstart#1\endcsname=\normalfootstartX
  \@namedef{@footnotemark#1}{\normal@footnotemarkX{#1}}
  \@namedef{bodyfootmark#1}{\normalbodyfootmarkX{#1}}
  \expandafter\let\csname regvfootnote#1\endcsname=\normalvfootnoteX
  \expandafter\let\csname vfootnote#1\endcsname=\vnumfootnoteX
  \expandafter\let\csname footfmt#1\endcsname=\normalfootfmtX
  \@namedef{footfootmark#1}{\normalfootfootmarkX{#1}}
  \expandafter\let\csname footgroup#1\endcsname=\normalfootgroupX
  \expandafter\let\csname footnoterule#1\endcsname=\normalfootnoteruleX
  \count\csname footins#1\endcsname=1000
  \csxdef{default@footins#1}{1000}%Use to have note only for one side
  \dimen\csname footins#1\endcsname=\csuse{maxhnotesX@#1}
  \skip\csname footins#1\endcsname=\csuse{beforenotesX@#1}%
  \advance\skip\csname footins#1\endcsname by\csuse{afterruleX@#1}%
%    \end{macrocode}
% Additions for minipages.
%    \begin{macrocode}
  \ifnoledgroup@\else%
    \expandafter\let\csname mpvfootnote#1\endcsname=\mpnormalvfootnoteX
    \expandafter\let\csname mpfootgroup#1\endcsname=\mpnormalfootgroupX
    \count\csname mpfootins#1\endcsname=1000
    \dimen\csname mpfootins#1\endcsname=\csuse{maxhnotesX@#1}
    \skip\csname mpfootins#1\endcsname=\csuse{beforenotesX@#1}%
    \advance\skip\csname mpfootins#1\endcsname by\csuse{afterruleX@#1}%
  \fi
}

%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Two columns footnotes}
%
%    The following macros set footnotes in two columns. It is assumed
% that the length of each footnote is less than the column width.
%
% \begin{macro}{\arrangementX@twocol}
%    \begin{macrocode}
\newcommand*{\arrangementX@twocol}[1]{%
  \csgdef{series@displayX#1}{twocol}
  \expandafter\let\csname regvfootnote#1\endcsname=\twocolvfootnoteX
  \expandafter\let\csname footfmt#1\endcsname=\twocolfootfmtX
  \expandafter\let\csname footgroup#1\endcsname=\twocolfootgroupX
  \dimen\csname footins#1\endcsname=\csuse{maxhnotesX@#1}%
  \skip\csname footins#1\endcsname=\csuse{beforenotesX@#1}%
  \advance\skip\csname footins#1\endcsname by \csuse{afterruleX@#1}\relax%
  \twocolfootsetupX{#1}
  \ifnoledgroup@\else%
    \expandafter\let\csname mpvfootnote#1\endcsname=\mpnormalvfootnoteX
    \expandafter\let\csname mpfootgroup#1\endcsname=\mptwocolfootgroupX
    \skip\csname mpfootins#1\endcsname=\csuse{beforenotesX@#1}%
    \advance\skip\csname mpfootins#1\endcsname by\csuse{afterruleX@#1}
    \mptwocolfootsetupX{#1}
  \fi%
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\twocolfootsetupX}
% \begin{macro}{\mptwocolfootsetupX}
%  \protect\cs{twocolfootsetupX}\marg{series}
%    \begin{macrocode}
\newcommand*{\twocolfootsetupX}[1]{%
  \count\csname footins#1\endcsname 500
  \csxdef{default@footins#1}{500}%Use this to confine the  notes to one side only
  \multiply\dimen\csname footins#1\endcsname by \tw@}
\newcommand*{\mptwocolfootsetupX}[1]{%
  \count\csname mpfootins#1\endcsname 500
  \multiply\dimen\csname mpfootins#1\endcsname by \tw@}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\twocolvfootnoteX}
% \protect\cs{twocolvfootnoteX}\marg{series}
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\twocolvfootnoteX}[2]{%
  \beforeinsertion@X{#1}%
  \let\bidi@RTL@everypar\relax%
  \insert\csname footins#1\endcsname\bgroup%
    \hsize=\expandafter\dimexpr\csuse{widthX@#1}\relax%
    \noindent\csuse{bhooknoteX@#1}%
    \csuse{notefontsizeX@#1}%
    \footsplitskips%
    \spaceskip=\z@skip \xspaceskip=\z@skip%
    \@nameuse{footfmt#1}{#1}{#2}\egroup}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\twocolfootfmtX}
%  \protect\cs{twocolfootfmtX}\marg{series}
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\twocolfootfmtX}[2]{%
   \protected@edef\@currentlabel{%
       \@nameuse{@thefnmark#1}%
   }%
  \normal@pars%
  \sethangindentX{#1}%
  \hsize \csuse{hsizetwocolX@#1}%
  \setparindentX{#1}%
  \tolerance=5000\relax%
  \par%
 \@tempdima=\parindent%
 \csuse{colalignX@#1}%
 \parindent=\@tempdima%
  {\hspace{\parindent}%
  \csuse{notenumfontX@#1}\wrapped@footfootmarkX{#1}\strut%
    \csuse{wrapcontentX@#1}{#2}%
    \strut\par}%
 \allowbreak%
}%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\twocolfootgroupX}
% \begin{macro}{\mptwocolfootgroupX}
% \protect\cs{twocolfootgroupX}\marg{series}
%    \begin{macrocode}
\newcommand*{\twocolfootgroupX}[1]{{\csuse{bhookgroupX@#1}\csuse{notefontsizeX@#1}
  \splittopskip=\ht\strutbox
  \expandafter
  \rigidbalanceX\csname footins#1\endcsname \tw@ \splittopskip}}

\newcommand*{\mptwocolfootgroupX}[1]{{%
  \vskip\skip\@nameuse{mpfootins#1}
  \ifl@dpairing\ifparledgroup%
    \leavevmode\marks\parledgroup@{begin}%
    \marks\parledgroup@series{#1}%
    \marks\parledgroup@type{footnoteX}%
  \fi\fi\normalcolor
  \ifparledgroup%
    \ifl@dpairing%
    \else%
      \setnoteswidthliketwocolumnsX@{#1}%
      \setnotesXpositionliketwocolumns@{#1}%
      \print@footnoteXrule{#1}%
    \fi%
  \else%
    \setnoteswidthliketwocolumnsX@{#1}%
    \setnotesXpositionliketwocolumns@{#1}%
    \print@footnoteXrule{#1}%
  \fi%
  \csuse{bhookgroupX@#1}%
  \splittopskip=\ht\strutbox
  \expandafter
  \rigidbalanceX\csname mpfootins#1\endcsname \tw@ \splittopskip}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Three columns footnotes}
%
%    The following macros set footnotes in three columns. It is assumed
% that the length of each footnote is less than the column width.
%
%
% \begin{macro}{\arrangementX@threecol}
%    \begin{macrocode}
\newcommand*{\arrangementX@threecol}[1]{%
  \csgdef{series@displayX#1}{threecol}
  \expandafter\let\csname regvfootnote#1\endcsname=\threecolvfootnoteX
  \expandafter\let\csname footfmt#1\endcsname=\threecolfootfmtX
  \expandafter\let\csname footgroup#1\endcsname=\threecolfootgroupX
  \dimen\csname footins#1\endcsname=\csuse{maxhnotesX@#1}%
  \skip\csname footins#1\endcsname=\csuse{beforenotesX@#1}%
  \advance\skip\csname footins#1\endcsname by \csuse{afterruleX@#1}\relax%
  \threecolfootsetupX{#1}
  \ifnoledgroup@\else%
    \expandafter\let\csname mpvfootnote#1\endcsname=\mpnormalvfootnoteX
    \expandafter\let\csname mpfootgroup#1\endcsname=\mpthreecolfootgroupX
    \skip\csname mpfootins#1\endcsname=\csuse{beforenotesX@#1}%
    \advance\skip\csname mpfootins#1\endcsname by\csuse{afterruleX@#1}
    \mpthreecolfootsetupX{#1}
  \fi%
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\threecolfootsetupX}
% \begin{macro}{\mpthreecolfootsetupX}
% \protect\cs{threecolfootsetupX}\marg{series}
%    \begin{macrocode}
\newcommand*{\threecolfootsetupX}[1]{%
  \count\csname footins#1\endcsname 333
  \csxdef{default@footins#1}{333}%Use this to confine the  notes to one side only
  \multiply\dimen\csname footins#1\endcsname by \thr@@}
\newcommand*{\mpthreecolfootsetupX}[1]{%
  \count\csname mpfootins#1\endcsname 333
  \multiply\dimen\csname mpfootins#1\endcsname by \thr@@}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\threecolvfootnoteX}
% \protect\cs{threecolvfootnoteX}\marg{series}\marg{text}
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\threecolvfootnoteX}[2]{%
  \let\bidi@RTL@everypar\relax%
  \beforeinsertion@X{#1}%
  \insert\csname footins#1\endcsname\bgroup%
    \hsize=\expandafter\dimexpr\csuse{widthX@#1}\relax%
    \noindent\csuse{bhooknoteX@#1}%
    \csuse{notefontsizeX@#1}%
    \footsplitskips%
    \@nameuse{footfmt#1}{#1}{#2}\egroup}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\threecolfootfmtX}
% \protect\cs{threecolfootfmtX}\marg{series}
%    \begin{macrocode}
\notbool{parapparatus@}{\newcommand*}{\newcommand}{\threecolfootfmtX}[2]{%
   \protected@edef\@currentlabel{%
       \@nameuse{@thefnmark#1}%
   }%
  \sethangindentX{#1}%
  \normal@pars%
  \hsize \csuse{hsizethreecolX@#1}%
  \setparindentX{#1}%
  \tolerance=5000\relax%
 \@tempdima=\parindent%
  \csuse{colalignX@#1}%
  \parindent=\@tempdima%
  {\hspace{\parindent}%
  \csuse{notenumfontX@#1}\wrapped@footfootmarkX{#1}\strut%
    \csuse{wrapcontentX@#1}{#2}%
    \strut\par}\allowbreak}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\threecolfootgroupX}
% \begin{macro}{\mpthreecolfootgroupX}
% \protect\cs{threecolfootgroupX}\marg{series}
%    \begin{macrocode}
\newcommand*{\threecolfootgroupX}[1]{{\csuse{bhookgroupX@#1}\csuse{notefontsizeX@#1}
  \splittopskip=\ht\strutbox
  \expandafter
  \rigidbalanceX\csname footins#1\endcsname \thr@@ \splittopskip}}

\newcommand*{\mpthreecolfootgroupX}[1]{{%
  \vskip\skip\@nameuse{mpfootins#1}
  \ifl@dpairing\ifparledgroup
    \leavevmode\marks\parledgroup@{begin}%
    \marks\parledgroup@series{#1}%
    \marks\parledgroup@type{footnoteX}%
  \fi\fi\normalcolor
  \ifparledgroup%
    \ifl@dpairing%
    \else%
      \setnoteswidthliketwocolumnsX@{#1}%
      \setnotesXpositionliketwocolumns@{#1}%
      \print@footnoteXrule{#1}%
    \fi%
  \else%
    \setnoteswidthliketwocolumnsX@{#1}%
    \setnotesXpositionliketwocolumns@{#1}%
    \print@footnoteXrule{#1}%
  \fi%
  \csuse{bhookgroupX@#1}%
  \splittopskip=\ht\strutbox
  \expandafter
  \rigidbalanceX\csname mpfootins#1\endcsname \thr@@ \splittopskip}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Paragraphed footnotes}
%
%    The following macros set footnotes as one paragraph.
%
% \begin{macro}{\arrangementX@paragraph}
% \changes{v1.15.0}{2015/01/12}{Correct bug with paragraphed familiar footnotes setting.}
% \protect\cs{footparagraphX}\marg{series}
%    \begin{macrocode}
\newcommand*{\arrangementX@paragraph}[1]{%
  \csgdef{series@displayX#1}{paragraph}%
  \expandafter\let\csname footstart#1\endcsname=\parafootstartX
  \expandafter\let\csname regvfootnote#1\endcsname=\para@vfootnoteX
  \expandafter\let\csname footfmt#1\endcsname=\parafootfmtX
  \expandafter\let\csname footgroup#1\endcsname=\para@footgroupX
  \expandafter\let\csname footnoterule#1\endcsname=\normalfootnoteruleX
  \count\csname footins#1\endcsname=1000
  \csxdef{default@footins#1}{1000}%Use this to confine the  notes to one side only
  \dimen\csname footins#1\endcsname=\csuse{maxhnotesX@#1}
  \skip\csname footins#1\endcsname=\csuse{beforenotesX@#1}%
  \advance\skip\csname footins#1\endcsname by\csuse{afterruleX@#1}%
  \para@footsetupX{#1}
  \ifnoledgroup@\else
    \expandafter\let\csname mpvfootnote#1\endcsname=\mppara@vfootnoteX
    \expandafter\let\csname mpfootgroup#1\endcsname=\mppara@footgroupX
    \count\csname mpfootins#1\endcsname=1000
    \dimen\csname mpfootins#1\endcsname=\csuse{maxhnotesX@#1}
    \skip\csname mpfootins#1\endcsname=\csuse{beforenotesX@#1}%
    \advance\skip\csname mpfootins#1\endcsname by\csuse{afterruleX@#1}%
  \fi
  }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\para@footsetupX}
% \protect\cs{para@footsetupX}\marg{series}
% \changes{v0.2.2}{2003/11/04}{Added \protect\cs{footfudgefiddle} to \protect\cs{para@footsetupX}}
% \changes{v1.13.0}{2014/09/16}{In \protect\cs{para@footsetupX}, use \protect\cs{columnwidth} instead of \protect\cs{hsize}}
%    \begin{macrocode}
\newcommand*{\para@footsetupX}[1]{{\csuse{bhookgroupX@#1}\csuse{notefontsizeX@#1}
  \setnoteswidthliketwocolumnsX@{#1}%
  \ifcsempty{widthX@#1}%
    {}%
    {\columnwidth=\expandafter\dimexpr\csuse{widthX@#1}\relax}%
  \dimen0=\baselineskip
  \multiply\dimen0 by 1024
  \divide\dimen0 by \columnwidth \multiply\dimen0 by \footfudgefiddle\relax%
  \expandafter
  \xdef\csname footfudgefactor#1\endcsname{%
    \expandafter\strip@pt\dimen0 }}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\parafootstartX}
% \protect\cs{parafootstartX}\marg{series}
%    \begin{macrocode}
\newcommand*{\parafootstartX}[1]{%
    \ifdimequal{0pt}{\prenotesX@}{}%
      {%
      \iftoggle{prenotesX@}{%
            \togglefalse{prenotesX@}%
            \skip\csname footins#1\endcsname=%
              \glueexpr\csuse{prenotesX@}+\csuse{afterruleX@#1}\relax%
            }%
          {}%
      }%
  \leftskip=\z@
  \rightskip=\z@
  \setparindentX{#1}%
  \vskip\skip\@nameuse{footins#1}%
  \setnoteswidthliketwocolumnsX@{#1}%
  \setnotesXpositionliketwocolumns@{#1}%
  \print@footnoteXrule{#1}%
  }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\para@vfootnoteX}
% \begin{macro}{\mppara@vfootnoteX}
% \protect\cs{para@vfootnoteX}\marg{series}\marg{text}
%    \begin{macrocode}
\newcommand*{\para@vfootnoteX}[2]{%
 \csuse{beforeinsertingX@#1}%
 \insert\csname footins#1\endcsname%
  \bgroup
    \csuse{notefontsizeX@#1}
    \footsplitskips
    \setbox0=\vbox{\hsize=\maxdimen%
      \let\bidi@RTL@everypar\@empty%
      \insert@txtbeforenotesX{#1}%
      \noindent\csuse{bhooknoteX@#1}%
      \@nameuse{footfmt#1}{#1}{#2}}%
    \setbox0=\hbox{\unvxhX{0}{#1}}%
    \dp0=\z@
    \ht0=\csname footfudgefactor#1\endcsname\wd0
    \box0
    \penalty0
  \egroup}
\newcommand*{\mppara@vfootnoteX}[3]{%
  \get@thisfootnoteX{#1}%
  \get@fnmarkX{#1}{\thisc@footnote}{#3}%
  \edef\this@footnoteX@reading{\the\csname footnote#1@reading\endcsname}%
  \global\setbox\@nameuse{mpfootins#1}\vbox{%
    \unvbox\@nameuse{mpfootins#1}
    \csuse{notefontsizeX@#1}
    \footsplitskips
    \setbox0=\vbox{\hsize=\maxdimen%
      \let\bidi@RTL@everypar\@empty%
      \noindent\color@begingroup%
      \csuse{bhooknoteX@#1}%
      \@nameuse{footfmt#1}{#1}{#2}\color@endgroup}%
    \setbox0=\hbox{\unvxhX{0}{#1}}%
    \dp0=\z@
    \ht0=\csname footfudgefactor#1\endcsname\wd0
    \box0
    \penalty0}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\unvxhX}
%    \begin{macrocode}
\newcommand*{\unvxhX}[2]{% 2th is optional for retro-compatibility
  \setbox0=\vbox{\unvbox#1%
    \global\setbox1=\lastbox}%
  \unhbox1
  \unskip            % remove \rightskip,
  \unskip            % remove \parfillskip,
  \unpenalty         % remove \penalty of 10000,
  \hskip\csuse{afternoteX@#2}%
  \relax}% but add the glue to go between the notes

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\parafootfmtX}
% \protect\cs{parafootfmtX}\marg{series}
%    \begin{macrocode}
\newcommand*{\parafootfmtX}[2]{%
   \protected@edef\@currentlabel{%
       \@nameuse{@thefnmark#1}%
   }%
  \insertparafootsepX{#1}%
  \ledsetnormalparstuff@common%
  {\csuse{notenumfontX@#1}%
   \csuse{notenumfontX@#1}%
   \wrapped@footfootmarkX{#1}%
   \strut%
    \csuse{wrapcontentX@#1}{#2}%
    \penalty-10}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\para@footgroupX}
% \begin{macro}{\mppara@footgroupX}
% \protect\cs{para@footgroupX}\marg{series}
%    \begin{macrocode}
\newcommand*{\para@footgroupX}[1]{%
  \hsize=\expandafter\dimexpr\csuse{widthX@#1}\relax%
  \unvbox\csname footins#1\endcsname
  \ifcsstring{raggedX@#1}{L}{\RaggedLeft}{}%
  \ifcsstring{raggedX@#1}{R}{\RaggedRight}{}%
  \makehboxofhboxes
  \setbox0=\hbox{\unhbox0 \removehboxes}%
  \csuse{bhookgroupX@#1}
  \csuse{notefontsizeX@#1}
  \unhbox0\par}

\newcommand*{\mppara@footgroupX}[1]{{%
  \setnoteswidthliketwocolumnsX@{#1}%
  \vskip\skip\@nameuse{mpfootins#1}
  \ifl@dpairing\ifparledgroup
    \leavevmode%
    \leavevmode\marks\parledgroup@{begin}%
    \marks\parledgroup@series{#1}%
    \marks\parledgroup@type{footnoteX}%
  \fi\fi\normalcolor
  \ifparledgroup%
    \ifl@dpairing%
    \else%
      \setnoteswidthliketwocolumnsX@{#1}%
      \setnotesXpositionliketwocolumns@{#1}%
      \print@footnoteXrule{#1}%
    \fi%
  \else%
      \setnoteswidthliketwocolumnsX@{#1}%
      \setnotesXpositionliketwocolumns@{#1}%
      \print@footnoteXrule{#1}%
  \fi%
  \unvbox\csname mpfootins#1\endcsname
  \ifcsstring{raggedX@#1}{L}{\RaggedLeft}{}%
  \ifcsstring{raggedX@#1}{R}{\RaggedRight}{}%
  \makehboxofhboxes
  \setbox0=\hbox{\unhbox0 \removehboxes}%
  \csuse{bhookgroupX@#1}%
  \csuse{notefontsizeX@#1}%
  \setparindentX{#1}%
  \unhbox0\par}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \paragraph{Insertion of the footnotes separator}
% The command \protect\cs{insertparafootsepX}\marg{series} must be called at the beginning of \protect\cs{parafootftmX}.
% \begin{macro}{\insertparafootsepX}
%    \begin{macrocode}
\newcommand{\insertparafootsepX}[1]{%
   \ifledRcol@%
     \ifnumequal{\csuse{prevpage#1@numR}}{\page@numR}%
        {\csuse{parafootsepX@#1}}%
        {}%
     \global\csname prevpage#1@numR\endcsname=\page@numR%
   \else%
     \ifnumequal{\csuse{prevpage#1@num}}{\page@num}%
        {\csuse{parafootsepX@#1}}%
        {}%
     \global\csname prevpage#1@num\endcsname=\page@num%
   \fi%
}
%    \end{macrocode}
% \end{macro}
% \subsection{Wrapping footnote marks in hyperlink}
% \begin{macro}{\wrapped@footfootmarkX}
% \cs{wrapped@footfootmarkX} prints the footnote mark of the footpage, wrapped in \package{hyperref} package's commands, if needed.
%    \begin{macrocode}
\newcommand{\wrapped@footfootmarkX}[1]{%
  \ifdefined\hypertarget%
    \hyperlink%
        {@bodyfootmark#1@\this@footnoteX@reading}%
        {\@nameuse{footfootmark#1}}%
    \Hy@raisedlink{%
      \hypertarget%
        {@footnotemark#1@\this@footnoteX@reading}%
        {}%
      }%
  \else%
    \@nameuse{footfootmark#1}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\wrapped@bodyfootmarkX}
% \cs{wrapped@bodyfootmarkX} prints the footnote mark of the text body, wrapped in \package{hyperref} package's commands, if needed.
%    \begin{macrocode}
\newcommand{\wrapped@bodyfootmarkX}[1]{%
  \ifdefined\hypertarget%
    \hyperlink%
        {@footnotemark#1@\expandafter\the\csname footnote#1@reading\endcsname}%
        {\@nameuse{bodyfootmark#1}}%
    \Hy@raisedlink{%
      \hypertarget%
        {@bodyfootmark#1@\expandafter\the\csname footnote#1@reading\endcsname}%
        {}%
      }%
  \else%
    \@nameuse{bodyfootmark#1}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \section{Code common to both critical and familiar footnote in normal arrangement}
% \protect\cs{par} should always be redefined to \protect\cs{endgraf} within
% the format macro (this is what \protect\cs{normal@pars} does),
% to override tricky material in the main text
% to get the lines numbered automatically (as set up by
% \protect\cs{autopar}, for example).
%
% In the case of footnote arranged in a ``normal'' way,  we also must set some setting for paragraph indent and text direction when using \LuaLaTeX.
%
% That why we have defined \protect\cs{ledsetnormalparstuff@common} in order to make this setting for both familiar and critical notes.
% This command is called by command to make specific setting to critical or familiar footnote.
%
% \begin{macro}{\ledsetnormalparstuff@common}
% \begin{macro}{\Xledsetnormalparstuff}
% \begin{macro}{\ledsetnormalparstuffX}
%
% \changes{v1.4.0}{2012/11/16}{Direction of footnotes with polyglossia.}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{ledsetnormalparstuff} is deprecated and becomes \protect\cs{ledsetnormalparstuffX} and \protect\cs{Xledsetnormalparstuff}.}
% \changes{v2.1.3}{2015/09/05}{Replaced \protect\cs{noindent} with \protect\cs{parindent} set to 0pt.}
%    \begin{macrocode}
\newcommand*{\ledsetnormalparstuff@common}{%
  \ifluatex%
   \ifdefstring{\footnote@luatextextdir}{TLT}{}%
     {\textdir\footnote@luatextextdir}%
   \pardir\footnote@luatexpardir%
  \fi%
  \csuse{\csuse{footnote@dir}}%
  \normal@pars%
  \parfillskip \z@ \@plus 1fil}%

\newcommand*{\Xledsetnormalparstuff}[1]{%
  \ledsetnormalparstuff@common%
  \Xsetparindent{#1}%
  \iftoggle{Xparindent@#1}{\hspace{\parindent}}{}%
}%

\newcommand*{\ledsetnormalparstuffX}[1]{%
  \ledsetnormalparstuff@common%
  \setparindentX{#1}%
  \iftoggle{parindentX@#1}{\hspace{\parindent}}{}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \section{Footnotes' width for two columns}\label{width2columns}
% We define here some commands which make sense only with \parpackage, but must be called when defining notes parameters.
% These commands change the width of block notes to allow them to have the same size than two parallel columns.
% \begin{macro}{\old@hsize}
% \begin{macro}{\setXnoteswidthliketwocolumns@}
% \begin{macro}{\setnoteswidthliketwocolumnsX@}
% These two commands are called at the beginning of critical or familiar notes groups.
% They set, if the option is enabled, the \protect\cs{hsize}. They are also called at the on the setup for paragraphed notes.
%    \begin{macrocode}

\newdimen\old@hsize%
\AtBeginDocument{\old@hsize=\hsize}%

\newcommand{\setXnoteswidthliketwocolumns@}[1]{%
  \global\let\hsize@fornote=\hsize%
  \global\old@hsize=\hsize%
  \let\old@columwidth=\columnwidth%
  \iftoggle{Xnoteswidthliketwocolumns@#1}%
    {%
    \setwidthliketwocolumns%
    \global\let\hsize@fornote=\hsize%
    }%
    {}%
  \let\hsize=\hsize@fornote%
  \let\columnwidth=\old@columwidth%
}%

\newcommand{\setnoteswidthliketwocolumnsX@}[1]{%
  \global\let\hsize@fornote=\hsize%
  \global\old@hsize=\hsize%
  \let\old@columwidth=\columnwidth%
  \iftoggle{noteswidthliketwocolumnsX@#1}%
    {%
    \setwidthliketwocolumns%
    \global\let\hsize@fornote=\hsize%
    }%
    {}%
  \let\hsize=\hsize@fornote%
  \let\columnwidth=\old@columwidth%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\setXnotespositionliketwocolumns@}
% \begin{macro}{\setnotesXpositionliketwocolumns@}
% These two commands set the position of the critical / familiar
% footnotes, depending on the hooks
% \verb+Xnoteswidthliketwocolumns+ and \verb+noteswidthliketwocolumnsX+.
% They call commands which are defined only in \parpackage, because this feature has no sens without \parpackage.
%    \begin{macrocode}
\newcommand{\setXnotespositionliketwocolumns@}[1]{%
  \iftoggle{Xnoteswidthliketwocolumns@#1}{%
    \csuse{setnotespositionliketwocolumns@\columns@position}%
  }{}%
}%

\newcommand{\setnotesXpositionliketwocolumns@}[1]{%
  \iftoggle{noteswidthliketwocolumnsX@#1}{%
    \csuse{setnotespositionliketwocolumns@\columns@position}%
  }{}%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Footnotes' order}
% \begin{macro}{\fnpos}
% \begin{macro}{\mpfnpos}
% \begin{macro}{\@fnpos}
% \begin{macro}{\@mpfnpos}
% The \protect\cs{fnpos} and \protect\cs{mpfnpos} simply place their arguments in \protect\cs{@fnpos} and \protect\cs{@mpfnpos}, which will be used later in the output routine.
%    \begin{macrocode}
\def\@fnpos{familiar-critical}
\def\@mpfnpos{critical-familiar}
\newcommand{\fnpos}[1]{\xdef\@fnpos{#1}}
\newcommand{\mpfnpos}[1]{\xdef\@mpfnpos{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \section{Footnotes' rule}
% Because the footnotes' rules can be shifted to the right when footnotes are set like two columns, we do not print them directly, but we put them in a \protect\cs{vbox}.
%
% \begin{macro}{\print@Xfootnoterule}
% \begin{macro}{\print@footnoteXrule}
% \changes{v1.21.0}{2015/04/13}{Code refactoring: the spaces after the footnote rules are directly managed in \protect\cs{print@Xfootnoterule} and \protect\cs{print@footnoteXrule}}
%    \begin{macrocode}
\newcommand{\print@Xfootnoterule}[1]{%
  \vskip-\csuse{Xafterrule@#1}%Because count in \dimen\csuse{#1footins}
  \nointerlineskip%
  \moveleft-\leftskip\vbox{\csuse{#1footnoterule}}%
  \nointerlineskip%
  \vskip\csuse{Xafterrule@#1}%
}%

\newcommand{\print@footnoteXrule}[1]{%
  \vskip-\csuse{afterruleX@#1}%Because count in \dimen\csuse{footins#1}
  \nointerlineskip%
  \moveleft-\leftskip\vbox{\csuse{footnoterule#1}}%
  \nointerlineskip%
  \vskip\csuse{afterruleX@#1}%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Specific skip for first series of footnotes}\label{skipfirstseries}
% \subsection{Overview}
% \protect\cs{Xbeforenotes} inserts a specific skip for the first series of notes in a page.
% As we can't know in advance which series will be the first, we call \protect\cs{prepare@Xprenotes} before inserting any critical notes in order to prevent page number overlapping.
% \begin{enumerate}
%   \item If it is the first note of the current page, it changes the footnote skip for the series to the value specified to \protect\cs{Xbeforenotes}. It also keeps the series of the note as the first one of the current page.
%   \item If it is not the first note of the current page:
%   \begin{itemize}
%     \item If the current series is printed after the series kept as the first of the current page, then nothing happens.
%     \item If the current series is printed before the series kept as the first of the current page, then it changes the footnote skip of the current series to the value normally used by the series which was marked as the first of the page. It also keeps the current series as the new first one of the current page.
%   \end{itemize}
% \end{enumerate}
%
%
% For example, suppose the series order is A,B. We call first a \protect\cs{Bfootnote} and a \protect\cs{Afootnote}. The only skips used are, finally, the skip specific to the first series of the page, and the skip for the B series. If we have not called \protect\cs{Afootnote}, the only skip used is the skip specific to the first series of the page.
%
% That is perfect.
%
%
% The series skip and the first series of the current page are reset before the footnotes are printed. Then, the footstart macros manage the problem of the first series of the page.
%
% After the rule, the space which is defined by \protect\cs{Xafterrule} does not depend on whether the series is the first one of the page or not. So we use its normal value for each series.
%
% And now, implementation !
% \subsection{User level command}
% \begin{macro}{\Xprenotes@}
% \begin{macro}{\Xprenotes}
% \changes{v1.1.0}{2012/09/25}{New skip \protect\cs{Xprenotes@}}
% \changes{v1.2.0}{2012/10/08}{Debug in familiar footnotes (bug introduced by v1.1).}
% If user redefines \protect\cs{Xprenotes@}, via \protect\cs{Xprenotes} to a value greater than 0~pt,
% this skip will be added before first series notes
% instead of the notes skip.
%    \begin{macrocode}
\newtoggle{Xprenotes@}%
\toggletrue{Xprenotes@}%
\newcommand{\Xprenotes@}{0pt}%
\newcommand*{\Xprenotes}[1]{\renewcommand{\Xprenotes@}{#1}}%
\newcommand{\preXnotes}[1]{\led@warning@preXnotes@deprecated\Xprenotes{#1}}%For compatibility
%    \end{macrocode}
% \end{macro}
% \end{macro}
% The same, but for familiar footnotes.
% \begin{macro}{\Xprenotes}
% \begin{macro}{\Xprenotes@}
%    \begin{macrocode}
\newtoggle{prenotesX@}
\toggletrue{prenotesX@}
\newcommand{\prenotesX@}{0pt}
\newcommand*{\prenotesX}[1]{\renewcommand{\prenotesX@}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Internal commands}
% \begin{macro}{firstXseries@}
% \begin{macro}{prepare@Xprenotes}
%    \begin{macrocode}
\gdef\firstXseries@{}
\newcommand{\prepare@Xprenotes}[1]{%
  \ifdimequal{0pt}{\Xprenotes@}%
  {}%
  {%
    \IfStrEq{\firstXseries@}{}{%
      \global\skip\csuse{#1footins}=\Xprenotes@%
      \global\advance\skip\csname #1footins\endcsname by\csuse{Xafterrule@#1}%
      \gdef\firstXseries@{#1}%
    }%
    {%
     \ifseriesbefore{#1}{\firstXseries@}%
       {%
       \global\skip\csuse{#1footins}=\csuse{Xbeforenotes@\firstXseries@}%
       \global\advance\skip\csname #1footins\endcsname by\csuse{Xafterrule@#1}%
       \gdef\firstXseries@{#1}%
       }%
       {}%
    }%
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The same thing is required for familiar notes and \protect\cs{prenotesX}.
% \begin{macro}{firstseriesX@}
% \begin{macro}{prepare@prenotesX}
%    \begin{macrocode}
\gdef\firstseriesX@{}
\newcommand{\prepare@prenotesX}[1]{%
  \ifdimequal{0pt}{\prenotesX@}%
  {}%
  {%
    \IfStrEq{\firstseriesX@}{}{%
      \global\skip\csuse{footins#1}=\prenotesX@%
      \global\advance\skip\csname footins#1\endcsname by\csuse{afterruleX@#1}%
      \gdef\firstseriesX@{#1}%
    }%
    {%
     \ifseriesbefore{#1}{\firstseriesX@}%
       {%
       \global\skip\csuse{footins#1}=\csuse{beforenotesX@\firstseriesX@}%
       \global\advance\skip\csname footins#1\endcsname by\csuse{afterruleX@#1}%
       \gdef\firstXseries@{#1}%
       }%
       {}%
    }%
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Endnotes}
% \changes{v1.8.1}{2013/12/15}{Debug endnotes when more than one series is used (change the position where tools for endnotes are defined).}
% \changes{v1.14.0}{2014/10/20}{Debug spurious characters before endnotes.}
% \label{endnotes}\relax
%
% First, check the noend option.
%    \begin{macrocode}
\ifbool{noend@}{}{%Used instead of \ifnoend@ to prevent expansion problem
%    \end{macrocode}
%
% \subsection{Internal commands}
% \begin{macro}{\l@dend@open}
% \begin{macro}{\l@dend@close}
% \protect\cs{l@dend@open} and \protect\cs{l@dend@close} are the
% macros that are used to open and close the endnote file. Note that
% all our writing to this file is \protect\cs{immediate}: all page and
% line numbers for the endnotes are generated by the same mechanism
% we use for the footnotes, so that there is no need to defer any
% writing to catch information from the output routine.
% The argument of these two command is the series letter.
%    \begin{macrocode}
\newcommand{\l@dend@open}[1]{%
  \global\booltrue{l@dend@#1}%
  \expandafter\immediate%
    \expandafter\openout%
      \csname l@d@#1end\endcsname%
      =\l@auxdir\jobname.#1end\relax%
}%
\newcommand{\l@dend@close}[1]{%
  \global\boolfalse{l@dend@#1}%
  \expandafter\immediate%
    \expandafter\closeout\csname l@d@#1end\endcsname%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dend@stuff}
% \protect\cs{l@dend@stuff} is used by \protect\cs{beginnumbering} to
% do everything that is necessary for the endnotes at the
% start of each section: it opens the \protect\cs{l@d@end} file, if necessary,
% and writes the section number to the endnote file.
%    \begin{macrocode}
\newcommand{\l@dend@stuff}{%
 \def\do##1{%
   \ifbool{l@dend@##1}{}%
     {\l@dend@open{##1}}%
   \expandafter\immediate\expandafter\write\csname l@d@##1end\endcsname{\string\l@d@section{\the\section@num}\@percentchar}%
   }%
 \dolistloop{\@series}%
}%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endprint}
% \begin{macro}{\l@d@section}
% The \protect\cs{endprint} here is nearly identical in its
% functioning to \protect\cs{normalfootfmt}.
%
% The endnote file also contains \protect\cs{l@d@section} commands, which
% supply the section numbers from the main text; standard \macpackage{} does
% nothing with this information, but it is there if you want to write
% custom macros to do something with it.
% \changes{v1.18.0}{2015/02/23}{Option parapparatus works for endnotes.}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{endnotes} take five arguments.}
% \changes{v2.5.0}{2015/11/13}{\protect\cs{endnotes} take six arguments.}
% \changes{v2.7.0}{2015/11/13}{\protect\cs{endnotes} take seven arguments.}
% \changes{v2.8.0}{2016/01/15}{\protect\cs{Xendhangindent} and \protect\cs{Xendafternote} can take values which are relative to the font size of the endnote.}
% Arguments are:
% \begin{itemize}
%   \item \verb+#1+ Line numbers and font selection.
%   \item \verb+#2+ Lemma.
%   \item \verb+#3+ Note content.
%   \item \verb+#4+ Series.
%   \item \verb+#5+ Optional argument of \protect\cs{Xendnote}.
%   \item \verb+#6+ Side (L or R).
%   \item \verb+#7+ Label for cross-referencing.
% \end{itemize}
%    \begin{macrocode}
\global\notbool{parapparatus@}{}{\long}\def\endprint#1#2#3#4#5#6#7{{%
  \iftoggle{Xendfirstnote@#4}{%
    \global\togglefalse{Xendfirstnote@#4}%
    \csuse{Xendtxtbeforenotes@#4}%
  }{}%
  \csuse{Xendbhooknote@#4}%
  \csuse{Xendnotefontsize@#4}%
  \hangindent=\csuse{Xendhangindent@#4}%
  \Xendstorelineinfo{#1}{#4}%
  \ifXendinsertsep@%
    \hskip\csuse{Xendafternote@#4}\relax%
    \ifcsdef{prevendline#4}%
      {\ifcsequal{prevendline#4}{lineinfo@}%
        {\ifcsempty{Xendsymlinenum@#4}{\csuse{Xendsep@#4}}{}}%
        {\csuse{Xendsep@#4}}%
      }%
      {\csuse{Xendsep@#4}}%
  \else%
    \iftoggle{Xendparagraph@#4}%
      {\global\Xendinsertsep@true}%
      {}%
  \fi%
  \xdef\@currentseries{#4}%
  \def\do##1{%
    \setkeys[mac]{truefootnoteoption}{##1}%
  }%
  \notblank{#5}{\docsvlist{#5}}{}%
  \IfStrEq{#6}{R}{\ledRcol@true}{}%
  \def\@this@crossref@start{#7:start}%
  \def\@this@crossref@end{#7:end}%
  \printlineendnote{#1}{#4}%
  \IfStrEq{#6}{R}{\ledRcol@false}{}%
  \nottoggle{Xendlemmadisablefontselection@#4}%
    {\select@lemmafont#1|}%
    {}%
  \bgroup%
    \csuse{Xendlemmafont@#4}%
    \csuse{Xendwraplemma@#4}{#2}%
  \egroup%
  \ifboolexpr{%
    togl {nosep@}%
    or test{\ifcsempty{Xendlemmaseparator@#4}}%
    }%
    {\hskip\csuse{Xendinplaceoflemmaseparator@#4}\relax}%
    {\nobreak%
     \hskip\csuse{Xendbeforelemmaseparator@#4}%
     \csuse{Xendlemmaseparator@#4}%
     \hskip\csuse{Xendafterlemmaseparator@#4}%
     \relax%
    }%
  \csuse{Xendwrapcontent@#4}{#3}%
  \nottoggle{Xendparagraph@#4}{\par}{}%
  \def\do##1{%
    \setkeys[mac]{falsefootnoteoption}{##1}%
  }%
  \notblank{#5}{\docsvlist{#5}}{}%
}}%

\let\l@d@section=\@gobble

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\Xendstorelineinfo}
% The \cs{Xendstorelineinfo} macro is used to store some data about line number of the current critical endnote, data which will be reused later for the \cs{Xnumberonlyfirstinline} and related setting.
%
% \#1 endnote specification for the current endnote;
% \#2 endnote series.
%    \begin{macrocode}
\newcommand{\Xendstorelineinfo}[2]{%
  \l@dp@rsefootspec#1|%
  \iftoggle{Xendnumberonlyfirstintwolines@#2}{%
    \xdef\lineinfo@{\l@dparsedstartpage - \l@dparsedstartline - \l@dparsedstartsub - \l@dparsedendpage - \l@dparsedendline - \l@dparsedendsub}%
  }%
  {%
    \xdef\lineinfo@{\l@dparsedstartpage - \l@dparsedstartline - \l@dparsedstartsub}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\printlineendnote}
% This macro controls, in endnote, whether the line number is printed or not, according to the series options. Its first argument is the information about lines; its second is the series of the footnote.
%    \begin{macrocode}
\newcommand{\printlineendnote}[2]{%
  \ifboolexpr{%
    togl {nonum@}%
    or togl {Xendnonumber@#2}%
    }%
    {\hspace{\csuse{Xendinplaceofnumber@#2}}}%
    {%
      \iftoggle{Xendnumberonlyfirstinline@#2}%
        {\ifcsdef{prevendline#2}%
          {\ifcsequal{prevendline#2}{lineinfo@}%
            {%
            \csuse{Xendbhookinplaceofnumber@#2}%
            \ifcsempty{Xendsymlinenum@#2}%
              {\hspace{\csuse{Xendinplaceofnumber@#2}}}%
              {\printsymlineendnotearea{#2}}%
            \csuse{Xendahookinplaceofnumber@2}%
            }%
            {\printlineendnotearea{#1}{#2}}}%
          {\printlineendnotearea{#1}{#2}}%
        }%
        {\printlineendnotearea{#1}{#2}}%We keep every time line
    \csxdef{prevendline#2}{\lineinfo@}%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\printsymlineendnotearea}
%    \begin{macrocode}
\newcommand{\printsymlineendnotearea}[1]{%
  \hspace{\csuse{Xendbeforesymlinenum@#1}}%
  \csuse{Xendnotenumfont@#1}%
  \ifdimequal{\csuse{Xendboxsymlinenum@#1}}{\z@}%
     {\csuse{Xendsymlinenum@#1}}%
     {\hbox to \csuse{Xendboxsymlinenum@#1}%
       {\csuse{Xendsymlinenum@#1}\hfill}%
     }%
  \hspace{\csuse{Xendaftersymlinenum@#1}}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\printlineendnotearea}
%
% This macro prints the space before the line number, changes the font, then prints the line number and the space after it.
% It is called by \protect\cs{endprint}
% depending of the options about repeating line numbers.
% The first argument is line information, the second is the notes series (A, B, C,  etc.)
%    \begin{macrocode}
\newcommand{\printlineendnotearea}[2]{%
  \csuse{Xendbhooklinenumber@#2}%
  \hspace{\csuse{Xendbeforenumber@#2}}%
  \bgroup%
    \csuse{Xendnotenumfont@#2}%
    \ifdimequal{\csuse{Xendboxlinenum@#2}}{0pt}%
      {\printendlines#1||\ifledRcol@\@Rlineflag\fi}%
      {\leavevmode%
       \hbox to \csuse{Xendboxlinenum@#2}%
       {%
       \IfSubStr{RC}{\csuse{Xendboxlinenumalign@#2}}{\hfill}{}%
       \printendlines#1||\ifledRcol@\@Rlineflag\fi%
       \IfSubStr{LC}{\csuse{Xendboxlinenumalign@#2}}{\hfill}{}%
      }}%
  \egroup%
  \hspace{\csuse{Xendafternumber@#2}}%
  \csuse{Xendahooklinenumber@#2}%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{User level commands}
% \subsubsection{Inserting contents to endnotes}
% The \cs{Xendnotes} commands are defined above, when defining apparatus commands by series.
% Here, we define
% only \cs{toendnotes} command not specific to a series, in order to insert arbitrary code.
% The regular version writes an unexpanded argument, while the regular version writes  a once-expanded argument.
%
% \begin{macro}{\toendnotes}
% \begin{macro}{\toendnotes*}
%    \begin{macrocode}
\newcommandx{\toendnotes}[2][1,usedefault]{%
  \ifboolexpr{bool{numbering} or bool{numberingR}}{%
    \def\do##1{%
      \expandafter\immediate\expandafter\write\csname l@d@##1end\endcsname%
        {\unexpanded{#2}\@percentchar}%
    }%
    \ifstrempty{#1}%
      {\dolistloop{\@series}}%
      {\docsvlist{#1}}%
  }{\led@err@toendnotes@outsidenumbering}%
}%
\WithSuffix\newcommandx\toendnotes*[2][1,usedefault]{%
  \ifboolexpr{bool{numbering} or bool{numberingR}}{%
    \def\do##1{%
      \expandafter\immediate\expandafter\write\csname l@d@##1end\endcsname%
        {#2\@percentchar}%
    }%
    \ifstrempty{#1}%
      {\dolistloop{\@series}}%
      {\docsvlist{#1}}%
  }{\led@err@toendnotes@outsidenumbering}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsubsection{Printing endnotes}
% \begin{macro}{\doendnotes}
% \begin{macro}{\ifXendinsertsep@}
% \protect\cs{doendnotes} is
% the command you use to print one series of endnotes; it
% takes one argument: the series letter of the note series you want
% to print.
% \protect\cs{Xendinsertsep@} is set to true at the first note of the series, and to false at the last one.
%    \begin{macrocode}
\newif\ifXendinsertsep@%
\newcommand*{\doendnotes}[1]{%
  \l@dend@close{#1}%
   \begingroup
      \csxdef{prevpagenum@#1}{}%
      \csxdef{prevpagerange@#1}{}%
      \global\toggletrue{Xendfirstnote@#1}%
      \makeatletter
      \expandafter\let\csname #1end\endcsname=\endprint
      \input\l@auxdir\jobname.#1end%
      \global\Xendinsertsep@false%
   \endgroup}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\doendnotesbysection}
% \protect\cs{doendnotesbysection} is a variant of the previous macro.
% While \protect\cs{doendnotes} print endnotes for all of numbered sections
% \protect\cs{doendnotesbysection} print the endnotes for the first numbered section at its first call for a series, then for the second section at its second call for the same series, then for the third section at its third call for the same series, and so on.
%    \begin{macrocode}
\newcommand*{\doendnotesbysection}[1]{%
 \l@dend@close{#1}%
 \csxdef{prevpagenum@#1}{}%
 \csxdef{prevpagerange@#1}{}%
 \global\expandafter\advance\csname #1end@bysection\endcsname by 1%
 \begingroup%
    \makeatletter%
    \def\l@d@section##1{%
      \global\toggletrue{Xendfirstnote@#1}%
      \ifnumequal{##1}{\csname #1end@bysection\endcsname}%
        {\cslet{#1end}{\endprint}}%
        {\cslet{#1end}{\@gobbleseven}}%
    }%
    \input\l@auxdir\jobname.#1end%
    \global\Xendinsertsep@false%
 \endgroup%
}%
%    \end{macrocode}
% \end{macro}
% We close now the conditional period, which depends on  \cs{ifnoend@}, because the following commands can be used by other commands than those speicific to endnotes.
%    \begin{macrocode}
}%
%    \end{macrocode}
% \begin{macro}{\setprintendlines}
% The \protect\cs{printendlines} macro is similar to \protect\cs{printlines} but is
% for printing endnotes rather than footnotes.
%
%    The principal difference between foot- and endnotes is that footnotes
% are printed on the page where they are specified but endnotes
% are printed at a different point in the document. We need an indication
% of the source of an endnote; \protect\cs{setprintendlines} provides this
% by always printing the page number. The coding is slightly simpler than
% \protect\cs{setprintlines}.
%
% from the starting page number.\label{printendlines}
% \changes{v0.7.0}{2005/02/18}{Added \protect\cs{setprintendlines} for use by
%              \protect\cs{printendlines}}
%    \begin{macrocode}
\newcommand*{\setprintendlines}[6]{%
  \let\@annot@start@print\relax%
  \let\@annot@end@print\relax%
  \l@d@pnumfalse%
  \l@d@dashfalse%
  \l@d@elinfalse%
%    \end{macrocode}
% First of all, we print the second page number only if
% the ending page number is different
%    \begin{macrocode}
  \ifnum#4=#1 \else
    \l@d@pnumtrue
    \l@d@dashtrue
  \fi
%    \end{macrocode}
%
% We print the ending line number if\/: (1)~we are printing the ending
% page number, or (2)~the ending line is different from the starting line number.
%    \begin{macrocode}
  \ifboolexpr{%
      bool{l@d@pnum}%
      or not test{\ifnumequal{#2}{#5}}%
     }{%
      \l@d@elintrue%
      \l@d@dashtrue%
      \l@d@elintrue
      \l@d@dashtrue
      \unless\ifx\relax\annot@end%
        \def\@annot@end@print{%
          \l@wrapcs@ifnotemptybox{Xendwraplinenumannotation@\@currentseries}{\annot@end}%
        }%
      \fi%
   }%
   {}%
%    \end{macrocode}
%
% We define the starting line number annotation as a merge of the starting annotation and ending annotation if we don't print the ending line number.
% Otherwise, it is only the starting annotation.
%    \begin{macrocode}
  \ifl@d@elin%
    \def\@annot@start@print{%
      \l@wrapcs@ifnotemptybox{Xendwraplinenumannotation@\@currentseries}{\annot@start}%
    }%
  \else%
    \ifx\annot@start\annot@end%
      \unless\ifx\@annot@start\relax%
        \def\@annot@start@print{%
          \l@wrapcs@ifnotemptybox{Xendwraplinenumannotation@\@currentseries}{\annot@start}%
        }%
      \fi%
    \else%
      \ifx\@annot@end@print\relax%
        \def\@annot@start@print{%
          \l@wrapcs@ifnotemptybox{Xendwraplinenumannotation@\@currentseries}{%
            \ifx\annot@start\empty\else%
              \annot@start%
              \ifdefined\linerangesep@%
                \linerangesep@%
              \else%
                \csuse{Xendlinerangeseparator@\@currentseries}%
              \fi%
            \fi%
            \annot@end%
            }%
          }%
       \else%
         \let\@annot@start@print\@annot@end@print%
         \let\@annot@end@print\relax%
      \fi%
    \fi%
  \fi%
%    \end{macrocode}
% We print the starting sub-line if it is nonzero.
%    \begin{macrocode}
  \l@d@ssubfalse
  \ifnum#3=0 \else
      \l@d@ssubtrue
  \fi
%    \end{macrocode}
%
% We print the ending sub-line if it is nonzero and: (1)~it is different
% from the starting sub-line number, or (2)~the ending line number is
% being printed.
%    \begin{macrocode}
  \l@d@eslfalse
  \ifnum#6=0 \else
      \ifnum#6=#3
         \ifl@d@elin \l@d@esltrue \else \l@d@eslfalse \fi
      \else
         \l@d@esltrue
         \l@d@dashtrue
      \fi
  \fi%
%    \end{macrocode}
%    \begin{macrocode}
  \ifl@d@dash%
    \ifboolexpr{togl{fulllines@} or test{\ifcsempty{Xendtwolines@\@currentseries}}}%
      {}%
      {%
      \setistwofollowinglines{#1}{#2}{#4}{#5}%
        \ifboolexpr{%
          (%
               togl {Xendtwolinesbutnotmore@\@currentseries}%
               and not%
                 (%
                  bool {istwofollowinglines@}%
                 )%
          )%
          or%
          (%
             (not test{\ifnumequal{#1}{#4}})%
               and togl{Xendtwolinesonlyinsamepage@\@currentseries}%
             )%
          }%
          {}%
          {%
          \l@d@dashfalse%
          \l@d@Xtwolinestrue%
          \l@d@elinfalse%
          \l@d@eslfalse%
          \ifcsempty{Xendmorethantwolines@\@currentseries}%
            {}%
            {\ifistwofollowinglines@\else%
              \l@d@Xmorethantwolinestrue%
             \fi%
            }%
          }%
      }%
  \fi%
%    \end{macrocode}
% If the \cs{Xendnoidenticallinenumannotation} is set for this series, we check if the ending annotation is identical to the starting.
% If true, we don't print the ending annotation
%    \begin{macrocode}
  \iftoggle{Xendnoidenticallinenumannotation@\@currentseries}{%
    \ifx\annot@start\annot@end%
      \let\@annot@end@print\relax%
      \ifx\linenumrep\@gobble%Don't print the dash if we're not printing the line number
        \l@d@dashfalse%
      \fi%
    \fi%
  }{}%
%    \end{macrocode}
% Finally, we check for \cs{Xendlinenumannotationonlyfirst} and \cs{Xendlinenumannotationonlyfirstintwo}, and we redefine, if required, \cs{@annot@start@print} and \cs{annot@end@print}. We also store the current line number annotations.
%    \begin{macrocode}
  \iftoggle{Xendlinenumannotationonlyfirst@\@currentseries}{%
    \ifboolexpr{%
      (%
        togl{Xendlinenumannotationonlyfirstintwo@\@currentseries}%
        and test{\ifcsequal{annot@start}{prevannot@start@\@currentseries}}%
        and test{\ifcsequal{annot@end}{prevannot@end@\@currentseries}}%
      )%
      or%
      (%
        not togl{Xendlinenumannotationonlyfirstintwo@\@currentseries}%
        test{\ifcsequal{annot@start}{prevannot@start@\@currentseries}}%
      )%
    }{%
      \def\@annot@start@print{%
        \l@wrapcs@ifnotemptybox{Xendwraplinenumannotation@\@currentseries}{\csuse{Xendsymlinenumannotation@\@currentseries}}%
      }%
      \let\@annot@end@print\relax%
      \ifx\linenumrep\@gobble%Don't print the dash if we're not printing the line number
        \l@d@dashfalse%
      \fi%
    }{}%
    \global\cslet{prevannot@start@\@currentseries}{\annot@start}%
    \global\cslet{prevannot@end@\@currentseries}{\annot@end}%
  }%
  {}%
%    \end{macrocode}
% End of \protect\cs{setprintendlines}.
%    \begin{macrocode}
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\printendlines}
% Now we are ready to print it all.
% \changes{v0.3.0}{2004/02/14}{Added \protect\cs{linenumr@p} and \protect\cs{sublinenumr@p}
%              to \protect\cs{printendlines}}
%    \begin{macrocode}
\def\printendlines#1|#2|#3|#4|#5|#6|#7|#8|{%
  \begingroup
  \setprintendlines{#1}{#2}{#3}{#4}{#5}{#6}%
%    \end{macrocode}
% The only subtlety left here is when to print a period between
% numbers. But the only instance in which this is tricky is for the
% ending sub-line number: it could be coming after the starting
% sub-line number (in which case we want only the dash) or after an
% ending line number (in which case we need to insert a period).
%
% So, first, start the starting line box, if needed.
%    \begin{macrocode}
  \ifdimequal{\csuse{Xendboxstartlinenum@\@currentseries}}{0pt}%
    {\bgroup}%
    {\leavevmode\hbox to \csuse{Xendboxstartlinenum@\@currentseries}\bgroup\hfill}%
%    \end{macrocode}
% Then, print the starting page number-
%    \begin{macrocode}
  \ifboolexpr{%
    (%
      test{\ifcsstring{prevpagenum@\@currentseries}{#1}}%
        and not%
      (togl{Xendpagenumberonlyfirstifsingle@\@currentseries} and bool{l@d@pnum})%
    )%
    or%
    (%
    test {\ifcsstring{prevpagerange@\@currentseries}{#1-#4}}%
    )%
  }%
    {%
    \ifcsempty{Xendsympagenum@\@currentseries}%
      {\hspace{\csuse{Xendinplaceofpagenumber@\@currentseries}}}%
      {\csuse{Xendsympagenum@\@currentseries}}%
    }%
    {%
    \wrap@edcrossref{\@this@crossref@start}{\printnpnum{#1}}%
    }%
%    \end{macrocode}
% Then, determine what must be printed before the start line.
%    \begin{macrocode}
  \ifl@d@dash%
    \ifl@d@pnum%
      \csuse{Xendlineprefixsingle@\@currentseries}%
    \else%
      \ifcsempty{Xendlineprefixmore@\@currentseries}%
        {\csuse{Xendlineprefixsingle@\@currentseries}}%
        {\csuse{Xendlineprefixmore@\@currentseries}}%
    \fi%
  \else%
    \csuse{Xendlineprefixsingle@\@currentseries}%
  \fi%
%    \end{macrocode}
% Then print the starting line, followed, if needed, by the side flag and the starting sub line number, then the line number annotation.
%    \begin{macrocode}
  \ifcsstring{Xendlinenumannotationposition@\@currentseries}{before}%
    {\@annot@start@print}%
    {}%
  \wrap@edcrossref{\@this@crossref@start}{%
    \ifledRcol@%
      \linenumrepR{#2}%
    \else%
      \linenumrep{#2}%
    \fi%
  }%
  \iftoggle{Xendlineflag@\@currentseries}{\ifledRcol@\@Rlineflag\fi}{}%
  \ifl@d@ssub%
    \csuse{Xendsublinesep@\@currentseries}%
    \wrap@edcrossref{\@this@crossref@start}{%
      \ifledRcol@%
        \sublinenumrepR{#3}%
      \else%
        \sublinenumrep{#3}%
      \fi%
    }%
  \fi%
  \ifcsstring{Xendlinenumannotationposition@\@currentseries}{after}%
    {\@annot@start@print}%
    {}%
%    \end{macrocode}
% Close the box.
%    \begin{macrocode}
  \egroup%
%    \end{macrocode}
% Open the box for the ending line number.
%    \begin{macrocode}
  \ifdimequal{\csuse{Xendboxendlinenum@\@currentseries}}{0pt}%
    {\bgroup}%
    {\hbox to \csuse{Xendboxendlinenum@\@currentseries}\bgroup}%
%    \end{macrocode}
% Print the dash + the ending line number, or the line number range symbol.
%    \begin{macrocode}
  \ifl@d@Xtwolines%
    \ifl@d@Xmorethantwolines%
      \csuse{Xendmorethantwolines@\@currentseries}%
    \else%
      \csuse{Xendtwolines@\@currentseries}%
    \fi%
  \else%
    \ifl@d@dash%
      \ifdefined\linerangesep@%
        \linerangesep@%
      \else%
        \csuse{Xendlinerangeseparator@\@currentseries}%
      \fi%
    \fi%
%    \end{macrocode}
% Print the ending page number.
%    \begin{macrocode}
    \ifl@d@pnum%
     \ifcsstring{prevpagerange@\@currentseries}{#1-#4}%
       {%
       \ifcsempty{Xendsympagenum@\@currentseries}%
         {\hspace{\csuse{Xendinplaceofpagenumber@\@currentseries}}}%
         {\csuse{Xendsympagenum@\@currentseries}}%
       }%
       {%
       \wrap@edcrossref{\@this@crossref@end}\printnpnum{#4}%
       }%
    \fi%
%    \end{macrocode}
% Print the ending line number, with, if needed, the line prefix, and followed by the side flag, the subline number, and line number annotation.
%    \begin{macrocode}
    \ifcsstring{Xendlinenumannotationposition@\@currentseries}{before}%
      {\@annot@end@print}%
      {}%
    \ifl@d@elin%
      \ifl@d@pnum\csuse{Xendlineprefixsingle@\@currentseries}\fi%
      \wrap@edcrossref{\@this@crossref@end}{%
        \ifledRcol@%
          \linenumrepR{#5}%
        \else%
          \linenumrep{#5}%
        \fi%
      }%
      \iftoggle{Xendlineflag@\@currentseries}{\ifledRcol@\@Rlineflag\fi}{}%
    \fi%
    \ifl@d@esl%
      \ifl@d@elin%
        \csuse{Xendsublinesep@\@currentseries}%
      \fi%
      \wrap@edcrossref{\@this@crossref@end}{%
        \ifledRcol@%
          \sublinenumrepR{#6}%
        \else%
          \sublinenumrep{#6}%
        \fi%
      }%
    \fi%
    \ifcsstring{Xendlinenumannotationposition@\@currentseries}{after}%
      {\@annot@end@print}%
      {}%
  \fi%
%    \end{macrocode}
% Close the ending line box.
%    \begin{macrocode}
  \ifdimequal{\csuse{Xendboxendlinenum@\@currentseries}}{0pt}%
    {}%
    {\hfill}%Prevent underfull hbox
  \egroup%
%    \end{macrocode}
% And, finally, save, if needed, the current page number for the Xendpagenumberonlyfirst hooks.
%    \begin{macrocode}
  \iftoggle{Xendpagenumberonlyfirst@\@currentseries}%
    {\iftoggle{Xendpagenumberonlyfirstintwo@\@currentseries}%
      {\csxdef{prevpagerange@\@currentseries}{#1-#4}}%
      {\csxdef{prevpagenum@\@currentseries}{#4}}%
    }%
    {}%
%    \end{macrocode}
% Now, the end of \cs{printendlines} macro.
%    \begin{macrocode}
  \endgroup%
}%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\printnpnum}
% A macro to print a page number in an endnote. Should not be override anymore
%    \begin{macrocode}
\newcommand*{\printnpnum}[1]{\csuse{Xendbeforepagenumber@\@currentseries}#1\csuse{Xendafterpagenumber@\@currentseries}}

%    \end{macrocode}
% \end{macro}
%
%
% \section{Generate series of notes}%
% In this section, X means the name of the series (A, B etc.)
% \begin{macro}{\series}
% \protect\cs{series}\protect\cs{series} creates one more new series. It is a public command, which just loops on the private command \protect\cs{newseries@}.
%    \begin{macrocode}
\newcommand{\newseries}[1]{%
    \def\do##1{\newseries@{##1}}%
    \docsvlist{#1}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@series}
% The \protect\cs{series@} macro is an \protect\package{etoolbox} list, which contains the name of all series.
%    \begin{macrocode}
\newcommand{\@series}{}
%    \end{macrocode}
% \end{macro}
% The command \protect\cs{newseries@}\protect\cs{series} creates a new series of the footnote.
% \begin{macro}{\newseries@}
%    \begin{macrocode}
\newcommand{\newseries@}[1]{
%    \end{macrocode}
% \subsection{Test if series is still existing}
%    \begin{macrocode}
    \xifinlist{#1}{\@series}{\led@warn@SeriesStillExist{#1}}%
    {%
%    \end{macrocode}
% \subsection{Init specific to \parpackage}
% When calling \protect\cs{newseries@} after having loaded \parpackage, we need to load specific setting.
%    \begin{macrocode}
      \ifdefined\newseries@par%
        \newseries@par{#1}%
      \fi%
%    \end{macrocode}
% \subsection{For critical footnotes}
% Critical footnotes are those which start with letters.
% We look for the \protect\cs{nocritical} option of \macpackage.
%    \begin{macrocode}
    \unless\ifnocritical@
%    \end{macrocode}
% \subsubsection{Options}
%    \begin{macrocode}
      \newtoggle{Xlineflag@#1}
      \newtoggle{Xparindent@#1}
      \newtoggle{Xlemmadisablefontselection@#1}
      \csgdef{Xwrapcontent@#1}{}%
      \csgdef{Xbeforeinserting@#1}{}%
      \csgdef{Xhangindent@#1}{0pt}%
      \csgdef{Xragged@#1}{}%
      \csgdef{Xhsizetwocol@#1}{0.45 \hsize}%
      \csgdef{Xhsizethreecol@#1}{.3 \hsize}%
      \csgdef{Xcolalign@#1}{\raggedright}%
      \csgdef{Xnotenumfont@#1}{\normalfont}%
      \csgdef{Xnotefontsize@#1}{\footnotesize}%
      \csgdef{Xbhooknote@#1}{}%
      \csgdef{Xbhookgroup@#1}{}%

      \csgdef{Xboxlinenum@#1}{0pt}%
      \csgdef{Xboxlinenumalign@#1}{L}%

      \csgdef{Xboxstartlinenum@#1}{0pt}%
      \csgdef{Xboxendlinenum@#1}{0pt}%

      \csgdef{Xboxsymlinenum@#1}{0pt}%
      \newtoggle{Xgroupbyline@#1}%
      \newtoggle{Xgroupbylineseparetwolines@#1}%

      \newtoggle{Xnumberonlyfirstinline@#1}%
      \newtoggle{Xnumberonlyfirstintwolines@#1}%

      \newtoggle{Xlinenumannotationonlyfirst@#1}%
      \newtoggle{Xlinenumannotationonlyfirstintwo@#1}%

      \csgdef{Xtwolines@#1}{}%
      \csgdef{Xmorethantwolines@#1}{}%
      \csgdef{Xsublinesep@#1}{\fullstop}%
      \csgdef{Xpagelinesep@#1}{\csname Xsublinesep@#1\endcsname}%for backward compatibility, call Xsublinesep@#1
      \newtoggle{Xtwolinesbutnotmore@#1}%
      \newtoggle{Xtwolinesonlyinsamepage@#1}%
      \newtoggle{Xonlypstart@#1}%
      \newtoggle{Xpstarteverytime@#1}%

      \newtoggle{Xpstart@#1}%
      \newtoggle{Xpstartonlyfirst@#1}%
      \csdef{Xprevpstart@#1}{0}%Not a hook, but a tool for the hook Xpstartonlyfirst
      \csgdef{Xpstartseparator@#1}{}%

      \newtoggle{Xstanza@#1}%
      \newtoggle{Xstanzaonlyfirst@#1}%
      \csdef{Xprevstanza@#1}{0}%Not a hook, but a tool for the hook Xstanzaonlyfirst

      \csgdef{Xstanzaseparator@#1}{}%

      \csgdef{Xsymlinenum@#1}{}%
      \csgdef{Xsymlinenumannotation@#1}{}%

      \newtoggle{Xnonumber@#1}%
      \csgdef{Xbeforenumber@#1}{0pt}%
      \csgdef{Xtxtbeforenumber@#1}{}%
      \csgdef{Xafternumber@#1}{0.5em}%
      \newtoggle{Xnonbreakableafternumber@#1}%
      \csgdef{Xbeforesymlinenum@#1}{\csuse{Xbeforenumber@#1}}%
      \csgdef{Xaftersymlinenum@#1}{\csuse{Xafternumber@#1}}%
      \csgdef{Xinplaceofnumber@#1}{1em}%
      \global\cslet{Xlemmaseparator@#1}{\rbracket}%
      \csgdef{Xbeforelemmaseparator@#1}{0em}%
      \csgdef{Xafterlemmaseparator@#1}{0.5em}%
      \csgdef{Xinplaceoflemmaseparator@#1}{1em}%
      \csgdef{Xbeforenotes@#1}{1.2em \@plus .6em \@minus .6em}
      \csgdef{Xafterrule@#1}{0pt}

      \csgdef{Xtxtbeforenotes@#1}{}
      \newtoggle{Xtxtbeforesnotes@#1@typeset}%Not directly used by user, but internal
      \newtoggle{Xtxtbeforenotesonlyonce@#1}%

      \csgdef{Xmaxhnotes@#1}{0.8\vsize}
      \newtoggle{Xnoteswidthliketwocolumns@#1}%
      \csgdef{Xparafootsep@#1}{}%
      \csgdef{Xafternote@#1}{1em plus.4em minus.4em}
      \csgdef{Xlinerangeseparator@#1}{\endashchar}%

      \csgdef{Xlemmafont@#1}{}%
      \csgdef{Xwraplemma@#1}{}
      \csgdef{Xwidth@#1}{\hsize}%
      \csgdef{Xwraplinenumannotation@#1}{\textsuperscript}%
      \csgdef{Xlinenumannotationposition@#1}{after}%
      \expandafter\csgdef{Xinnotemark@#1}##1{\ledinnotemark{##1}}%
      \newtoggle{Xnoidenticallinenumannotation@#1}%
%    \end{macrocode}
% \subsubsection{Create inserts, needed to add notes in foot}
% As regards inserts, see chapter 15 of \thetexbook\ by D. Knuth.
%    \begin{macrocode}
      \expandafter\newinsert\csname #1footins\endcsname%
      \unless\ifnoledgroup@%
        \expandafter\newinsert\csname mp#1footins\endcsname%
      \fi%
%    \end{macrocode}
% \subsubsection{Create commands for critical apparatus, \protect\cs{Afootnote}, \protect\cs{Bfootnote} etc.}
% Note the double \# in command: it is because command it is made inside another command.
% \changes{v1.4.0}{2012/11/16}{Remembers the language of the lemma, in order to create a correct direction for the footnote separator.}
% \changes{v1.23.0}{2015/04/29}{Prevent spurious spaces when \protect\cs{Afootnote} and similar commands are followed by spaces (bug added on 1.0.0!).}
%    \begin{macrocode}
      \global\notbool{parapparatus@}{\expandafter\newcommand\expandafter *}{\expandafter\newcommand}\csname #1footnote\endcsname[2][]{%
          \if@edtext@secondarg@%
            \ifledRcol%
              \ifcsstring{Xonlyside@#1}{L}{\led@error@note@called@onrightside{#1footnote}}{}%
            \else%
              \ifcsstring{Xonlyside@#1}{R}{\led@error@note@called@onleftside{#1footnote}}{}%
            \fi%
            \begingroup%
            \newcommand{\content}{##2}%
            \ifnumberedpar@%
                \ifledRcol%
                   \ifluatex%
                       \footnotelang@lua[R]%
                   \fi%
                   \@ifundefined{xpg@main@language}%if polyglossia
                         {}%
                         {\footnotelang@poly[R]}%
                    \footnoteoptions@{R}{##1}{true}%
                    \xright@appenditem{%
                      \ifbool{indtl@innote}%
                        {\unexpanded{\let\index\nindex}}%
                        {}%
                      \ifbool{indtl@notenumber}%
                        {\unexpanded{\let\index\nindex}}%There is no note number... so
                        {}%
                      \noexpand\Xnote@true%
                      \unexpanded{\gdef\@currentnotetype{critical}}%
                      \noexpand\prepare@Xprenotes{#1}%
                      \noexpand\prepare@edindex@fornote{\l@d@nums}%
                      \unexpanded{\def\sw@list@inedtext}{\expandafter\unexpanded\expandafter{\sw@inthisedtext}}%The value of the \sw@inthisedtext of current \edtext will be pushed to  \sw@list@inedtext when the notes are expanded.
                      \noexpand\setcounter{stanzaR}{\the\c@stanzaR}%Save stanzaR counter for footnote
                      \unexpanded{\def\@this@crossref@start}{\theedtext:start}%
                      \unexpanded{\def\@this@crossref@end}{\theedtext:end}%
                      \expandonce{\@beforeinsertofthisedtext}% Internal for now, no reason to make it public
                      \noexpand\parse@annot\l@current@annotR|%
                      \noexpand\csuse{v#1footnote}{#1}%
                       {{\l@d@nums}{\expandonce\@tag}{\expandonce\content}}%
                      \noexpand\Xnote@false%
                      \unexpanded{\advance\@edindex@fornote@\m@ne}%
                      \ifbool{indtl@innote}%
                        {\unexpanded{\let\index\orig@@index}}%
                        {}%
                      \ifbool{indtl@notenumber}%
                        {\unexpanded{\let\index\orig@@index}}%
                        {}%
                    }\to\inserts@listR
                    \footnoteoptions@{R}{##1}{false}%
                    \global\advance\insert@countR \@ne%
                \else%
                     \ifluatex%
                       \footnotelang@lua%
                     \fi%
                   \@ifundefined{xpg@main@language}%if polyglossia
                         {}%
                         {\footnotelang@poly}%
                    \footnoteoptions@{L}{##1}{true}%
                    \xright@appenditem{%
                      \ifbool{indtl@innote}%
                        {\unexpanded{\let\index\nindex}}%
                        {}%
                      \ifbool{indtl@notenumber}%
                        {\unexpanded{\let\index\nindex}}%There is no note number... so
                        {}%
                      \noexpand\Xnote@true%
                      \unexpanded{\gdef\@currentnotetype{critical}}%
                      \noexpand\prepare@Xprenotes{#1}%
                      \noexpand\prepare@edindex@fornote{\l@d@nums}%
                      \unexpanded{\def\sw@list@inedtext}{\expandafter\unexpanded\expandafter{\sw@inthisedtext}}%The value of the \sw@inthisedtext of current edtext will be pushed to \sw@list@inedtext when the notes are expanded.
                      \ifl@dpairing%
                        \noexpand\setcounter{stanzaL}{\the\c@stanzaL}%Save stanzaR counter for footnote
                      \fi%
                      \unexpanded{\def\@this@crossref@start}{\theedtext:start}%
                      \unexpanded{\def\@this@crossref@end}{\theedtext:end}%
                      \expandonce{\@beforeinsertofthisedtext}%Internal for now, no reason to make it public
                      \noexpand\parse@annot\l@current@annot|%
                      \noexpand\csuse{v#1footnote}%
                         {#1}%
                         {{\l@d@nums}{\expandonce\@tag}{\expandonce\content}}%
                      \noexpand\Xnote@false%
                      \unexpanded{\advance\@edindex@fornote@\m@ne}%
                      \ifbool{indtl@innote}%
                        {\unexpanded{\let\index\orig@@index}}%
                        {}%
                      \ifbool{indtl@notenumber}%
                        {\unexpanded{\let\index\orig@@index}}%
                        {}%
                     }\to\inserts@list
                    \global\advance\insert@count \@ne%
                    \footnoteoptions@{L}{##1}{false}%
                \fi
            \else
                \csuse{v#1footnote}{#1}{{0|0|0|0|0|0|0}{}{##1}}%
            \fi%
            \endgroup%
          \else%
            \led@err@FootnoteNotInSecondArgEdtext{#1}%
          \fi%
   \ignorespaces%
          }
%    \end{macrocode}
% Create counter used to determine on which page the previous note was called.
%    \begin{macrocode}
      \expandafter\newcount\csname #1prevpage@num\endcsname%
      \expandafter\newcount\csname #1prevpage@numR\endcsname%
%    \end{macrocode}
% We need to be able to modify \macpackage's footnote macros and restore their
%    \begin{macrocode}
      \global\csletcs{#1@@footnote}{#1footnote}
%    \end{macrocode}
% \subsubsection{Set standard display}
%    \begin{macrocode}
      \Xarrangement@normal{#1}%
%    \end{macrocode}
% End of for critical footnotes.
%    \begin{macrocode}
    \fi
%    \end{macrocode}
% \subsection{For familiar footnotes}
% Familiar footnotes are those which end with letters.
% We look for the \verb+nofamiliar+ option of \macpackage.
%    \begin{macrocode}
    \unless\ifnofamiliar@
%    \end{macrocode}
% \subsubsection{Options}
%    \begin{macrocode}
      \newtoggle{parindentX@#1}
      \csgdef{wrapcontentX@#1}{}%
      \csgdef{hangindentX@#1}{0pt}%
      \csgdef{beforeinsertingX@#1}{}%
      \csgdef{raggedX@#1}{}%
      \csgdef{hsizetwocolX@#1}{0.45 \hsize}%
      \csgdef{hsizethreecolX@#1}{.3 \hsize}%
      \csgdef{colalignX@#1}{\raggedright}%
      \csgdef{notenumfontX@#1}{\normalfont}%
      \csgdef{notefontsizeX@#1}{\footnotesize}%
      \csgdef{bhooknoteX@#1}{}%
      \csgdef{bhookgroupX@#1}{}%
      \csgdef{afterruleX@#1}{0pt}
      \csgdef{beforenotesX@#1}{1.2em \@plus .6em \@minus .6em}
      \csgdef{maxhnotesX@#1}{0.8\vsize}%
      \newtoggle{noteswidthliketwocolumnsX@#1}%
      \csgdef{parafootsepX@#1}{}%
      \csgdef{afternoteX@#1}{1em plus.4em minus.4em}
      \csgdef{widthX@#1}{\hsize}%
      \expandafter\csgdef{innotemarkX@#1}##1{\ledinnotemark{##1}}%
      \csgdef{txtbeforenotesX@#1}{}%
      \newtoggle{txtbeforesnotesX@#1@typeset}%Not directly used by user, but internal
      \newtoggle{txtbeforenotesonlyonceX@#1}%
% End of for familiar footnotes.
% \subsubsection{Create inserts, needed to add notes in foot}
% As regards inserts, see chapter 15 of the TeXBook by D. Knuth.
%    \begin{macrocode}
      \expandafter\newinsert\csname footins#1\endcsname%
      \unless\ifnoledgroup@%
        \expandafter\newinsert\csname mpfootins#1\endcsname%
      \fi%
%    \end{macrocode}
%\subsubsection{Create tools for familiar footnotes (\protect\cs{footnoteX})}
% First, create the \protect\cs{footnoteX} command.
% Note the double \# in command: it is because a command is called inside another command.
%    \begin{macrocode}

      \global\expandafter\newcommand\csname footnote#1\endcsname[2][]{%
          \begingroup%
              \prepare@prenotesX{#1}%
              \newcommand{\content}{##2}%
%    \end{macrocode}
% If we are using the \cs{csquotes} package, we reset the quotation level.
%    \begin{macrocode}
              \ifdefined\csq@qlevel%
                \csq@qlevel=0\relax%
              \fi%
%    \end{macrocode}
% If we are preparing parallel typesetting, we cannot just increase the footnote counter.
% Read \parpackage's handbook about that (\reff{reledpar-familiarfootnotenumber}).
% If we have a manual footnote mark, use it.
%    \begin{macrocode}
               \global\expandafter\advance\csname footnote#1@reading\endcsname by \@ne%
               \ifstrempty{##1}{%
                 \ifboolexpr{bool{l@dpairing} or bool{l@dprintingpages} or bool{l@dprintingcolumns}}{%
                   \ifcsdef{footnote#1reading\the\csname footnote#1@reading\endcsname=typeset}%
                   {\setcounter{footnote#1}{\csuse{footnote#1reading\the\csname footnote#1@reading\endcsname=typeset}}}%
                   {\setcounter{footnote#1}{\the\csname footnote#1@reading\endcsname}}%
                 }{%
                   \stepcounter{footnote#1}%
                 }%
               }{}%
%    \end{macrocode}
% We also have to check consistency with \cs{onlysideX} setting.
%    \begin{macrocode}
            \ifledRcol%
              \ifcsstring{onlysideX@#1}{L}{\led@error@note@called@onrightside{footnote#1}}{}%
            \else%
              \ifcsstring{onlysideX@#1}{R}{\led@error@note@called@onleftside{footnote#1}}{}%
            \fi%
%    \end{macrocode}
% And now, the feature not depending of wether we are preparing parallel typesetting
%    \begin{macrocode}
              \ifstrempty{##1}%
                {\protected@csxdef{@thefnmark#1}{\csuse{thefootnote#1}}}%
                {\protected@csxdef{@thefnmark#1}{##1}}%
              \nottoggle{nomk@}%Nomk is set to true when using \footnoteXnomk with \parpackage
                 {\csuse{@footnotemark#1}}%
                 {}%
              \ifluatex%
                \xdef\footnote@luatextextdir{\the\textdir}%
                \xdef\footnote@luatexpardir{\the\pardir}%
              \fi%
              \if@ledgroup%
                \led@set@index@fornote{#1}%
              \fi%
              \csuse{vfootnote#1}{#1}{\expandonce\content}{##1}\m@mmf@prepare%
              \ifbool{indtl@innote}%
                {\let\index\orig@@index}%
                {}%
              \ifbool{indtl@notenumber}%
                {\let\index\orig@@index}%
                {}%
          \endgroup%
      }
%    \end{macrocode}
% Then define the counters.
% The \LaTeX\ counter \verb+footnoteX+ is the only one manipulated by the user. This is the one which is printed.
% The \TeX\ counter \cs{footnoteX@reading} is increased at each footnote. It is used for hyperlinks,  for using \package{hyperlink} package, and for getting the correct footnote number when using parallel typesetting (\reff{reledpar-familiarfootnotenumber}).
%    \begin{macrocode}
      \newcounter{footnote#1}
        \global\expandafter\renewcommand\csname thefootnote#1\endcsname{\arabic{footnote#1}}
      \expandafter\newcount\csname footnote#1@reading\endcsname%
%    \end{macrocode}
% Create counter used to determine on which page the previous note was called.
%    \begin{macrocode}
      \expandafter\newcount\csname prevpage#1@num\endcsname%
      \expandafter\newcount\csname prevpage#1@numR\endcsname%
%    \end{macrocode}
% Add \cs{let}\cs{footnoteX}\cs{@gobble} to \cs{no@expands}.
%    \begin{macrocode}
      \expandafter\gappto\expandafter\no@expands\expandafter{\expandafter\let\csname footnote#1\endcsname\@gobble}%
%    \end{macrocode}
%    And now, define \cs{footnoteXmark} and \cs{footnoteXtext}, equivalent to classical \cs{footnotemark} and \cs{footnotetext}.
%    \begin{macrocode}
      \expandafter\newcommand\csname footnote#1mark\endcsname[1][]{%
         \begingroup%
            \prepare@prenotesX{#1}%
            \ifstrempty{##1}{%
              \stepcounter{footnote#1}%
            }{%
              \setcounter{footnote#1}{##1}%
            }%
            \protected@csxdef{@thefnmark#1}{\csuse{thefootnote#1}}%
            \csuse{@footnotemark#1}%
            \m@mmf@prepare%
         \endgroup%
      }%
      \expandafter\newcommand\csname footnote#1text\endcsname[2][]{%
         \begingroup%
           \csuse{vfootnote#1}{#1}{\expandonce{##2}}{##1}%
         \endgroup%
      }%
%    \end{macrocode}
% Do not forget to initialize the series.
%    \begin{macrocode}
     \arrangementX@normal{#1}%
  \fi
%    \end{macrocode}
% \subsection{The endnotes}
% \changes{v2.0.0}{2015/07/19}{One endnotes file by series.}
% Endnotes are commands like \protect\cs{Xendnote}, where X is a series letter.
% First, we check for the \verb+noend+ options.
%    \begin{macrocode}
  \unless\ifnoend@
%    \end{macrocode}
% \subsubsection{The auxiliary file}
% \begin{macro}{\l@d@Xend}
% \begin{macro}{\ifl@dend@X}
% \begin{macro}{\l@dend@Xtrue}
% \begin{macro}{\l@dend@Xfalse}
% Endnotes of all varieties are saved up in a file, one by series, typically named
% \meta{jobname}\file{.Xend}.
% \protect\cs{l@d@end} is the output stream number for
% this file, and \protect\cs{ifl@dend@X} is a flag that is \verb"true" when the file is open.
%
%
%    \begin{macrocode}
      \expandafter\newwrite\csname l@d@#1end\endcsname%
      \expandafter\newif\csname ifl@dend@#1\endcsname%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsubsection{The main macro}
% The \protect\cs{Xendnote} macro functions to
% write one endnote to the \file{.Xend} file. We change
% \protect\cs{newlinechar} so that in the file every space becomes the
% start of a new line; this generally ensures that a long note does not
% exceed restrictions on the length of lines in files.
%    \begin{macrocode}

      \global\expandafter\newcommandx\csname #1endnote\endcsname[2][1,usedefault]{%
         \bgroup%
         \newlinechar='40%
         \global\@noneed@Footnotetrue%
         \newcommand{\content}{##2}%
         \stepcounter{labidx}%
         \expandafter\immediate\expandafter\write\csname l@d@#1end\endcsname{%
           \unexpanded{\def\sw@list@inedtext}%
           {\expandafter\unexpanded\expandafter{\sw@inthisedtext}}%
           \@percentchar\space%Explicit space, to add a linebreak in the output file
           \noexpand\parse@annot\l@current@annot|\@percentchar\space%
           \expandafter\string\csname #1end\endcsname%
           {\ifnumberedpar@\l@d@nums\fi}%
           {\ifnumberedpar@\expandonce\@tag\fi}%
           {\expandonce\content}%
           {#1}%
           {\unexpanded{##1}}%
           {\ifledRcol R\else L\fi}%
           {\theedtext}%
           \@percentchar%
         }%
         \egroup%
         \ignorespaces%
     }%
%    \end{macrocode}
% \subsubsection{Tools}
% The \cs{Xtoendnotes} command inserts any arbitrary content into the endnote file.
% It is an alias of the more generalist \cs{addtoendnotes}
%    \begin{macrocode}

     \global\expandafter\newcommand\csname #1toendnotes\endcsname[1]{%
       \toendnotes[#1]{##1}%
     }%

     \expandafter\WithSuffix\expandafter\newcommand\csname #1toendnotes\endcsname*[1]{%
       \toendnotes*[#1]{##1}%
     }%

%    \end{macrocode}
% \subsubsection{Internal commands}
% \protect\cs{Xendnote}  commands called \protect\cs{Xend} commands on to the endnote file; these are analogous to the various
% \verb"footfmt" commands above, and they take the same arguments.
% When we process this file, we want to pick out the notes of one
% series and ignore all the rest. To do that, we equate the \verb"end"
% command for the series we want to \protect\cs{endprint}, and leave the
% rest equated to \protect\cs{@gobbleseven}, which just skips over its seven
% arguments.
%    \begin{macrocode}

      \global\cslet{#1end}{\@gobbleseven}
%    \end{macrocode}
% We need to store the number of times \protect\cs{doendnotesbysection} is called for one series.
%    \begin{macrocode}
   \global\expandafter\newcount\csname #1end@bysection\endcsname%
%    \end{macrocode}
%
% \subsubsection{The options}
%    \begin{macrocode}
      \csgdef{Xendwraplemma@#1}{}
      \csgdef{Xendwrapcontent@#1}{}%
      \csgdef{Xendtwolines@#1}{}%
      \csgdef{Xendmorethantwolines@#1}{}%
      \newtoggle{Xendtwolinesbutnotmore@#1}{}%
      \newtoggle{Xendtwolinesonlyinsamepage@#1}{}%
      \newtoggle{Xendlemmadisablefontselection@#1}%
      \csgdef{Xendnotenumfont@#1}{\normalfont}%
      \csgdef{Xendnotefontsize@#1}{\footnotesize}%
      \csgdef{Xendbhooknote@#1}{}%

      \csgdef{Xendsublinesep@#1}{\fullstop}%

      \csgdef{Xendbeforenumber@#1}{0pt}
      \csgdef{Xendafternumber@#1}{0.5em}

      \csgdef{Xendboxlinenum@#1}{0pt}%
      \csgdef{Xendboxlinenumalign@#1}{L}%

      \csgdef{Xendboxstartlinenum@#1}{0pt}%
      \csgdef{Xendboxendlinenum@#1}{0pt}%

      \csgdef{Xendlemmaseparator@#1}{}%
      \csgdef{Xendbeforelemmaseparator@#1}{0em}%
      \csgdef{Xendafterlemmaseparator@#1}{0.5em}%
      \csgdef{Xendinplaceoflemmaseparator@#1}{0.5em}%

      \newtoggle{Xendparagraph@#1}%
      \csgdef{Xendafternote@#1}{1em plus.4em minus.4em}%
      \csgdef{Xendsep@#1}{}%

      \csgdef{Xendinplaceofnumber@#1}{0pt}%
      \newtoggle{Xendnonumber@#1}%

      \csgdef{Xendhangindent@#1}{0pt}%

      \newtoggle{Xendnumberonlyfirstinline@#1}%
      \newtoggle{Xendnumberonlyfirstintwolines@#1}%

      \newtoggle{Xendlinenumannotationonlyfirst@#1}%
      \newtoggle{Xendlinenumannotationonlyfirstintwo@#1}%

      \csgdef{Xendbeforesymlinenum@#1}{\csuse{Xendbeforenumber@#1}}%
      \csgdef{Xendaftersymlinenum@#1}{\csuse{Xendafternumber@#1}}%

      \csgdef{Xendsymlinenum@#1}{}%
      \csgdef{Xendsymlinenumannotation@#1}{}%

      \csgdef{Xendboxsymlinenum@#1}{0pt}%

      \csgdef{Xendbhooklinenumber@#1}{}%
      \csgdef{Xendehooklinenumber@#1}{}%
      \csgdef{Xendbhookinplaceofnumber@#1}{}%
      \csgdef{Xendehookinplaceofnumber@#1}{}%

      \csgdef{Xendlinerangeseparator@#1}{\endashchar}%

      \csgdef{Xendbeforepagenumber@#1}{p.}%
      \csgdef{Xendafterpagenumber@#1}{) }%
      \csgdef{Xendlineprefixsingle@#1}{}%
      \csgdef{Xendlineprefixmore@#1}{}%

      \newtoggle{Xendlineflag@#1}

      \csgdef{Xendlemmafont@#1}{}%

      \csgdef{Xendlinenumannotationposition@#1}{after}%
      \csgdef{Xendwraplinenumannotation@#1}{\textsuperscript}%
      \newtoggle{Xendnoidenticallinenumannotation@#1}%

      \newtoggle{Xendpagenumberonlyfirst@#1}%
      \newtoggle{Xendpagenumberonlyfirstifsingle@#1}%
      \newtoggle{Xendpagenumberonlyfirstintwo@#1}%
      \csgdef{Xendsympagenum@#1}{}%
      \csgdef{Xendinplaceofpagenumber@#1}{0pt}%

      \csgdef{Xendtxtbeforenotes@#1}{}%
      \newtoggle{Xendfirstnote@#1}%Not a hook, but used to apply Xendtxtbeforenotes

%    \end{macrocode}
% End of endnotes declaration
%    \begin{macrocode}
  \fi%
%    \end{macrocode}
% Dump series in \protect\cs{@series}
%    \begin{macrocode}
    \listxadd{\@series}{#1}
  }
}% End of \newseries
%    \end{macrocode}
% \end{macro}
% \subsection{Init standards series (A,B,C,D,E)}
%    \begin{macrocode}
\expandafter\newseries\expandafter{\default@series}
%    \end{macrocode}
% \section{Setting series display}
% \subsection{Change series order}
% \changes{v1.1.0}{2012/09/25}{New tools to change order of series}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{seriesatbegin} and \protect\cs{seriesatbegin} more efficient}
% \begin{macro}{\seriesatbegin}
% \protect\cs{seriesatbegin}\marg{s} changes the order of series, to put the series \meta{s} at the beginning of the list.
% The series can be the result of a command.
%    \begin{macrocode}
\newcommand{\seriesatbegin}[1]{%
   \StrDel{\@series}{#1}[\@series]%
   \edef\@new{}%
   \listeadd{\@new}{#1}%
   \listeadd{\@new}{\@series}%
   \xdef\@series{\@new}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\seriesatend}
% \changes{v1.21.0}{2015/04/13}{Fix spurious space in \protect\cs{seriesatend}}
%  And \protect\cs{seriesatend} moves the series to the end of the list.
%    \begin{macrocode}
\newcommand{\seriesatend}[1]{%
   \StrDel{\@series}{#1}[\@series]%
   \edef\@new{}%
   \listeadd{\@new}{\@series}%
   \listeadd{\@new}{#1}%
   \xdef\@series{\@new}%
}
%    \end{macrocode}
% \end{macro}
% \subsection{Test series order}
% \begin{macro}{\ifseriesbefore}
% \protect\cs{ifseriesbefore}\marg{seriesA}\marg{seriesB}\marg{true}\marg{false} expands to \meta{true} if \meta{seriesA} is printed before \meta{seriesB}, or to \meta{false} otherwise.
%    \begin{macrocode}
\newcommand{\ifseriesbefore}[4]{%
 \StrPosition{\@series}{#1}[\@first]%
 \StrPosition{\@series}{#2}[\@second]%
 \ifnumgreater{\@second}{\@first}{#3}{#4}%
}
%    \end{macrocode}
% \end{macro}
% \subsubsection{Get the first series}
% In some specific case, we need to know the first series of the list of series.
% \begin{macro}{\@getfirstseries}
%    \begin{macrocode}
\newcommand{\@getfirstseries}{%
 \ifdefempty{\@series}%
   {\xdef\@firstseries{}}%
   {\StrChar{\@series}{1}[\@firstseries]}%
}%
%    \end{macrocode}
% \end{macro}
% \changes{v1.0.0}{2012/09/15}{New generic commands to customize footnote display.}
% \subsection{Series setting}
% \subsubsection{General way of working}
% The setting's command (like \protect\cs{numberonlyfirstinline}), also called ``hooks'' can be divided in two categories: those which require a string values and those which require a boolean value.
% The first category includes those which require a length value, because we store the length's expression send by user and we evaluate it only in the commands which requires to know the setting.
% The second category require boolean value only when it is set to FALSE.
% Otherwise, we understand the insinuated value is TRUE.
%
% For each ``hook'' command, we store the value in  commands (first category) or a \protect\package{etoolbox}'s toggle (second category) which names are in the form \protect\cs{<hook>@<series>}.
% For example, when calling \protect\cs{twolines}\marg{sq.}, we store \verb+sq.+ in commands \protect\cs{twolines@A}, \protect\cs{twolines@B}, \protect\cs{twolines@C}\ldots for each series defined for use with \macpackage, or, if the \oarg{series} optional argument was send, for each series of this argument.
%
% These values are tested in some specific places, scattered in all the code, depending of their effects.
% The default values are defined by the \protect\cs{newseries@} command.
%
%
% In order to prevent code duplication, we have created some generic commands.
% Some of them change the value of any hook send as argument.
% Some other, getting a hook name, generate the user level commands.
%
%
%
% \subsubsection{Tools to set options}
% \begin{macro}{\settoggle@series}
% \changes{v1.1.0}{2012/09/25}{\protect\cs{settoggle@series} switch the global value of the toggle, not only the local value.}
% \changes{v1.13.0}{2014/09/16}{\protect\cs{settoggle@series} can take an optional arguments to reload series setup.}
% \protect\cs{settoggle@series}\marg{series}\marg{toggle}\marg{value} is a generic command to switch toggles for some series.
% The arguments are:
% \begin{itemize}
%   \item \verb+#1+ (mandatory): the series for which the hooks should be set. If empty, all the series will be affected.
%   \item \verb+#2+ (mandatory): the name of the hook.
%   \item \verb+#3+ (mandatory): the new value of toggle (true or false).
%   \item \verb+#4+ (optional): if equal to \verb+reload+, reload the footnote setting (call again \protect\cs{Xarrangement} or \protect\cs{arrangementX} or \ldots\ depending of the footnote display).
%   \item \verb+#5+ (optional): if not empty, and if \verb+#1+ is empty, change the hook setting for pseudo-series, as \verb+appref+.
% \end{itemize}
%    \begin{macrocode}
\newcommandx{\settoggle@series}[5][4,5,usedefault]{%
    \def\do##1{%
      \ifcsdef{etb@tgl@#2@##1}{%
        \global\settoggle{#2@##1}{#3}%
      }{%
        \led@warn@BadHookSeries{##1}{#2}%
      }%
      \ifstrequal{#4}{critical}{
          \csuse{Xarrangement@\csuse{series@display##1}}{##1}%
      }{}
      \ifstrequal{#4}{familiar}{%
          \csuse{arrangementX@\csuse{series@displayX##1}}{##1}%
      }{}%
    }%
    \ifstrempty{#1}{%
              \dolistloop{\@series}%
              \ifstrempty{#5}{}{%
                 \docsvlist{#5}%
               }
           }%
           {%
              \docsvlist{#1}%
           }%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setcommand@series}
% \protect\cs{setcommand@series}\marg{series}\marg{command}\marg{value} is a generic command to store a hook's value into commands specific to some  series.
% The arguments are:
% \begin{itemize}
%   \item \verb+#1+ (mandatory): the series for which the hooks should be set. If empty, all the series will be affected.
%   \item \verb+#2+ (mandatory): the name of the hook.
%   \item \verb+#3+ (mandatory): the new value of the hook/command.
%   \item \verb+#4+ (optional): if equal to \verb+reload+, reload the footnote setting (call \protect\cs{footnormal} or \protect\cs{footparagraph} or \ldots\ depending of the footnote display).
%   \item \verb+#5+ (optional): if not empty, and if \verb+#1+ is empty, change the hook setting for pseudo-series, as \verb+appref+.
%   \item \verb+#6+ (optional): the number of arguments of the hook.
% \end{itemize}
%    \begin{macrocode}
\newcommandx{\setcommand@series}[6][4,5,6=0,usedefault]{%
    \def\do##1{
      \ifcsdef{#2@##1}{%
        \expandafter\global\expandafter\renewcommand\csname#2@##1\endcsname[#6]{#3}%
      }{%
        \led@warn@BadHookSeries{##1}{#2}%
      }%
      \ifstrequal{#4}{critical}{%
            \csuse{Xarrangement@\csuse{series@display##1}}{##1}%
      }{}
      \ifstrequal{#4}{familiar}{%
          \csuse{arrangementX@\csuse{series@displayX##1}}{##1}%
      }{}%
    }%
    \ifstrempty{#1}{%
              \dolistloop{\@series}%
              \ifstrempty{#5}{}{%
                 \docsvlist{#5}
               }
    }%
    {%
              \docsvlist{#1}%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Tools to generate options commands}
% \begin{macro}{\newhookcommand@series}
% \protect\cs{newhookcommand@series}\protect\cs{command names} is a generic command to add new commands for hooks, like \protect\cs{Xhsizetwocol}.
% The first argument is the name of the hook, the second a comma-separated list of pseudo-series where the hook can be used, like \verb+appref+ in the case of \protect\cs{Xtwolines}.
% The second argument is also used to create commands named \protect\cs{<hookname><pseudoseries>},
% like \protect\cs{Xtwolinesappref}.
% The third argument
% \changes{v2.33.0}{2020/05/31}{\protect\cs{newhookcommand@series} can take an second optional argument (third argument).}
% \changes{v1.21.0}{2015/04/13}{\protect\cs{newhookcommand@series} can take an optional argument.}
%    \begin{macrocode}
\newcommandx{\newhookcommand@series}[3][2,3=0,usedefault]{%
  \global\expandafter\newcommand\expandafter*\csname #1\endcsname[2][]{%
    \setcommand@series{##1}{#1}{##2}[][#2][#3]%
  }%
  \ifstrempty{#2}{}{%
    \def\do##1{%
      \global\expandafter\newcommand\expandafter*\csname #1##1\endcsname[1]{%
        \csuse{#1}[##1]{####1}%
      }%
    }%
    \docsvlist{#2}%
  }%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\newhooktoggle@series}
%\protect\cs{newhooktoggle@series}\protect\cs{command names} is a generic command to add new commands for a new toggle hook, like \protect\cs{Xnumberonlyfirstinline}.
% The second argument is also used to create commands named \protect\cs{<hookname><pseudoseries>},
% like \protect\cs{Xtwolinesbutnotmoreappref}.
% \changes{v1.21.0}{2015/04/13}{\protect\cs{newhooktoggle@series} can take an optional argument.}
%    \begin{macrocode}
\newcommandx{\newhooktoggle@series}[2][2,usedefault]{%
  \global\expandafter\newcommandx\expandafter*\csname #1\endcsname[2][1,2={true},usedefault]{%
    \settoggle@series{##1}{#1}{##2}[][#2]%
    }%
  \ifstrempty{#2}{}{%
    \def\do##1{%
      \global\expandafter\newcommand\expandafter*\csname #1##1\endcsname{%
        \csuse{#1}[##1]%
      }%
    }%
    \docsvlist{#2}%
  }%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\newhooktoggle@series@reload}
% \changes{v1.13.0}{2014/09/16}{Add \protect\cs{newhookcommand@toggle@reload}}
% \protect\cs{newhookcommand@toggle@reload} does the same thing as \protect\cs{newhooktoggle@series}
% but the commands created by this macro also reload the series arrangement, depending of type os notes
%    \begin{macrocode}
\newcommand{\newhooktoggle@series@reload}[2]{%
  \global\expandafter\newcommandx\expandafter*\csname #1\endcsname[2][1,2={true},usedefault]{%
    \settoggle@series{##1}{#1}{##2}[#2]%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\newhookcommand@series@reload}
% \changes{v1.8.0}{2013/11/24}{Debug \protect\cs{beforenotesX} and  \protect\cs{maxhnotesX} which did not work.}
% \changes{v1.12.0}{2014/08/05}{Debug \protect\cs{beforenotesX} and  \protect\cs{maxhnotesX} which did not work when called after \protect\cs{footparagraphX}.}
% \changes{v1.12.0}{2014/08/05}{Debug \protect\cs{Xbeforenotes} and  \protect\cs{Xmaxhnotes} which did not work when called after \protect\cs{footparagraph}.}
% \protect\cs{newhookcommand@series@reload} does the same thing as \protect\cs{newhookcommand@series}
% but the commands created by this macro also reload the series' arrangement.
%
%    \begin{macrocode}
\newcommand{\newhookcommand@series@reload}[2]{%
  \global\expandafter\newcommand\expandafter*\csname #1\endcsname[2][]{%
    \setcommand@series{##1}{#1}{##2}[#2]%
  }%
}
%    \end{macrocode}
% \end{macro}
% \subsubsection{Options for critical notes}
% Before generating the commands that are used to set the critical notes, such as \protect\cs{Xnumberonlyfirstinline}, \protect\cs{Xlemmaseparator} and the like, we check the \verb+nocritical+ option.
%    \begin{macrocode}
\unless\ifnocritical@
  \newhookcommand@series{Xwrapcontent}%
  \newhookcommand@series{Xbeforeinserting}%
  \newhookcommand@series{Xlemmafont}%
  \newhookcommand@series{Xwraplemma}%
  \newhooktoggle@series{Xparindent}
  \newhookcommand@series{Xhangindent}
  \newhookcommand@series{Xragged}
  \newhookcommand@series{Xhsizetwocol}
  \newhookcommand@series{Xhsizethreecol}
  \newhookcommand@series{Xcolalign}%
  \newhookcommand@series{Xnotenumfont}
  \newhookcommand@series{Xbhooknote}
  \newhookcommand@series@reload{Xbhookgroup}{critical}
  \newhookcommand@series{Xboxsymlinenum}%
  \newhookcommand@series{Xsymlinenum}
  \newhookcommand@series{Xsymlinenumannotation}%
  \newhookcommand@series{Xbeforenumber}
  \newhookcommand@series{Xtxtbeforenumber}
  \newhookcommand@series{Xafternumber}
  \newhookcommand@series{Xbeforesymlinenum}
  \newhookcommand@series{Xaftersymlinenum}
  \newhookcommand@series{Xinplaceofnumber}
  \newhookcommand@series{Xlemmaseparator}
  \newhookcommand@series{Xbeforelemmaseparator}
  \newhookcommand@series{Xafterlemmaseparator}
  \newhookcommand@series{Xinplaceoflemmaseparator}
  \newhookcommand@series{Xtxtbeforenotes}
  \newhooktoggle@series{Xtxtbeforenotesonlyonce}%
  \newhookcommand@series@reload{Xafterrule}{critical}
  \newhooktoggle@series{Xnumberonlyfirstinline}
  \newhooktoggle@series{Xnumberonlyfirstintwolines}
  \newhooktoggle@series{Xlinenumannotationonlyfirst}%
  \newhooktoggle@series{Xlinenumannotationonlyfirstintwo}%
  \newhooktoggle@series{Xgroupbyline}%
  \newhooktoggle@series{Xgroupbylineseparetwolines}%
  \newhooktoggle@series{Xnonumber}

  \newhooktoggle@series{Xpstart}
  \newhooktoggle@series{Xpstartonlyfirst}%
  \newhooktoggle@series{Xpstarteverytime}%
  \newhookcommand@series{Xpstartseparator}%

  \newhooktoggle@series{Xstanza}%
  \newhooktoggle@series{Xstanzaonlyfirst}%
  \newhookcommand@series{Xstanzaseparator}%

  \newhooktoggle@series{Xonlypstart}
  \newhooktoggle@series{Xnonbreakableafternumber}
  \newhooktoggle@series{Xlemmadisablefontselection}
  \newhookcommand@series@reload{Xmaxhnotes}{critical}
  \newhookcommand@series@reload{Xbeforenotes}{critical}
  \newhooktoggle@series@reload{Xnoteswidthliketwocolumns}{critical}%
  \newhookcommand@series@reload{Xnotefontsize}{critical}

  \newhookcommand@series{Xboxlinenum}%
  \newhookcommand@series{Xboxlinenumalign}%

  \newhookcommand@series{Xboxstartlinenum}%
  \newhookcommand@series{Xboxendlinenum}%

  \newhookcommand@series{Xafternote}%
  \newhookcommand@series{Xparafootsep}
  \newhookcommand@series@reload{Xwidth}{critical}%

  \newhookcommand@series{Xinnotemark}[][1]%

  \ifundef{\Xhsize}%
    {%
      \newcommandx{\Xhsize}[2][1,usedefault]{%
        \led@warning@Xhsize@deprecated%
        \Xwidth[#1]{#2}%
      }%
    }%
    {}%
\fi
%    \end{macrocode}
% Now, hooks for critical notes which also apply to crossreferencing and line numbering at the sides of the page.
%    \begin{macrocode}
\newhooktoggle@series{Xlineflag}[appref,SEref]
\newhookcommand@series{Xtwolines}[appref,SEref]
\newhookcommand@series{Xmorethantwolines}[appref,SEref]
\newhookcommand@series{Xsublinesep}[appref,SEref,side]%
\newhookcommand@series{Xpagelinesep}[appref,SEref,side]%
\newhooktoggle@series{Xtwolinesbutnotmore}[appref,SEref]
\newhooktoggle@series{Xtwolinesonlyinsamepage}[appref,SEref]
\newhookcommand@series{Xlinerangeseparator}[appref,SEref]
\newhookcommand@series{Xlinenumannotationposition}[side,appref,SEref]%
\newhookcommand@series{Xwraplinenumannotation}[side,ref,appref,SEref]%
\newhooktoggle@series{Xnoidenticallinenumannotation}[side,ref,appref,SEref]%
%    \end{macrocode}
% \subsubsection{Options for familiar notes}
% Before generating the optional commands for familiar notes, we check the \protect\cs{nofamiliar} option.
%    \begin{macrocode}
\unless\ifnofamiliar@
  \newhookcommand@series{wrapcontentX}%
  \newhookcommand@series{beforeinsertingX}%
  \newhooktoggle@series{parindentX}
  \newhookcommand@series{hangindentX}
  \newhookcommand@series{raggedX}
  \newhookcommand@series{hsizetwocolX}
  \newhookcommand@series{hsizethreecolX}
  \newhookcommand@series{colalignX}%
  \newhookcommand@series{notenumfontX}
  \newhookcommand@series{bhooknoteX}
  \newhookcommand@series@reload{bhookgroupX}{familiar}
  \newhookcommand@series@reload{beforenotesX}{familiar}
  \newhookcommand@series@reload{maxhnotesX}{familiar}
  \newhooktoggle@series@reload{noteswidthliketwocolumnsX}{familiar}%
  \newhookcommand@series@reload{afterruleX}{familiar}
  \newhookcommand@series@reload{notefontsizeX}{familiar}
  \newhookcommand@series{afternoteX}
  \newhookcommand@series{parafootsepX}
  \newhookcommand@series{txtbeforenotesX}%
  \newhooktoggle@series{txtbeforenotesonlyonceX}%
  \newhookcommand@series@reload{widthX}{familiar}%
  \newhookcommand@series{innotemarkX}[][1]%

  \ifundef{\hsizeX}%
    {%
      \newcommandx{\hsizeX}[2][1,usedefault]{%
        \led@warning@hsizeX@deprecated%
        \widthX[#1]{#2}%
      }%
    }%
    {}%
\fi
%    \end{macrocode}
% \subsubsection{Options for endnotes}
% Before generating the commands that are used to set the endnotes, such as \protect\cs{Xnumberonlyfirstinline}, \protect\cs{Xlemmaseparator}+ and the like, we check the \verb+noend+ option.
%    \begin{macrocode}
\unless\ifnoend@
  \newhookcommand@series{Xendwraplemma}
  \newhookcommand@series{Xendwrapcontent}
  \newhookcommand@series{Xendnotenumfont}
  \newhookcommand@series{Xendlemmafont}%
  \newhookcommand@series{Xendbhooknote}

  \newhookcommand@series{Xendboxlinenum}%
  \newhookcommand@series{Xendboxlinenumalign}%

  \newhookcommand@series{Xendboxstartlinenum}%
  \newhookcommand@series{Xendboxendlinenum}%

  \newhookcommand@series{Xendnotefontsize}
  \newhooktoggle@series{Xendlemmadisablefontselection}
  \newhookcommand@series{Xendlemmaseparator}
  \newhookcommand@series{Xendbeforelemmaseparator}
  \newhookcommand@series{Xendafterlemmaseparator}
  \newhookcommand@series{Xendinplaceoflemmaseparator}

  \newhookcommand@series{Xendbeforenumber}%
  \newhookcommand@series{Xendafternumber}%

  \newhooktoggle@series{Xendparagraph}
  \newhookcommand@series{Xendafternote}
  \newhookcommand@series{Xendsep}

  \newhookcommand@series{Xendinplaceofnumber}%
  \newhooktoggle@series{Xendnonumber}%

  \newhooktoggle@series{Xendnumberonlyfirstinline}%
  \newhooktoggle@series{Xendnumberonlyfirstintwolines}%

  \newhooktoggle@series{Xendlinenumannotationonlyfirst}%
  \newhooktoggle@series{Xendlinenumannotationonlyfirstintwo}%

  \newhookcommand@series{Xendsymlinenum}%
  \newhookcommand@series{Xendbeforesymlinenum}%
  \newhookcommand@series{Xendaftersymlinenum}%
  \newhookcommand@series{Xendboxsymlinenum}%

  \newhookcommand@series{Xendsymlinenumannotation}%

  \newhookcommand@series{Xendbhooklinenumber}%
  \newhookcommand@series{Xendahooklinenumber}%
  \newhookcommand@series{Xendbhookinplaceofnumber}%
  \newhookcommand@series{Xendahookinplaceofnumber}%

  \newhookcommand@series{Xendhangindent}%

  \newhooktoggle@series{Xendpagenumberonlyfirst}%
  \newhooktoggle@series{Xendpagenumberonlyfirstifsingle}%
  \newhooktoggle@series{Xendpagenumberonlyfirstintwo}%
  \newhookcommand@series{Xendsympagenum}%
  \newhookcommand@series{Xendinplaceofpagenumber}%

  \newhookcommand@series{Xendtxtbeforenotes}%

\fi
\newhooktoggle@series{Xendlineflag}[apprefwithpage,SErefwithpage]
\newhookcommand@series{Xendtwolines}[apprefwithpage,SErefwithpage]
\newhookcommand@series{Xendmorethantwolines}[apprefwithpage,SErefwithpage]
\newhooktoggle@series{Xendtwolinesbutnotmore}[apprefwithpage,SErefwithpage]
\newhooktoggle@series{Xendtwolinesonlyinsamepage}[apprefwithpage,SErefwithpage]
\newhookcommand@series{Xendlinerangeseparator}[apprefwithpage,SErefwithpage]
\newhookcommand@series{Xendbeforepagenumber}[apprefwithpage,SErefwithpage,SErefonlypage]
\newhookcommand@series{Xendafterpagenumber}[apprefwithpage,SErefwithpage]
\newhookcommand@series{Xendlineprefixsingle}[apprefwithpage,SErefwithpage]
\newhookcommand@series{Xendlineprefixmore}[apprefwithpage,SErefwithpage]
\newhookcommand@series{Xendsublinesep}[apprefwithpage,SErefwithpage]

\newhookcommand@series{Xendlinenumannotationposition}[apprefwithpage,SErefwithpage]%
\newhookcommand@series{Xendwraplinenumannotation}[apprefwithpage,SErefwithpage]%
\newhooktoggle@series{Xendnoidenticallinenumannotation}[apprefwithpage,SErefwithpage]%
%    \end{macrocode}
% \subsection{Hooks for a particular footnote}
% \begin{macro}{\newhooktoggle@specific}
% \cs{newhooktoggle@specific} is a generic command to create boolean hook specific to a note.
%    \begin{macrocode}
\newcommand{\newhooktoggle@specific}[1]{%
  \newtoggle{#1@}%
  \listgadd{\hooktoggle@specific}{#1}%
  \define@key[mac]{truefootnoteoption}{#1}[]{\global\settoggle{#1@}{true}}%When enabling footnote option
  \define@key[mac]{falsefootnoteoption}{#1}[]{\global\settoggle{#1@}{false}}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\newhookarg@specific}
% \cs{newhookarg@specific} is a generic command to create argumen hook specific to a note.
%    \begin{macrocode}
\newcommand{\newhookarg@specific}[1]{%
  \listgadd{\hookarg@specific}{#1}%
  \define@key[mac]{truefootnoteoption}{#1}{\csgdef{#1@}{##1}}%When enabling footnote option
  \define@key[mac]{falsefootnoteoption}{#1}{\global\csundef{#1@}}%When disabling footnote option
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\hooktoggle@specific}
% \begin{macro}{\add@hooktoggle@specific@to@cs}
% The \cs{add@hooktoggle@specific@to@cs} macro stores to a macro
% all the current values of hook toggle specific to a command.
% It is useful for the \cs{Xgroupbyline} option, which does not immediately add notes to the inserts list.
% It uses the \cs{hooktoggle@specific} list.
%    \begin{macrocode}
\def\hooktoggle@specific{}%
\newcommand{\add@hooktoggle@specific@to@cs}[1]{%
  \def\do##1{%
    \iftoggle{##1@}{%
      \ifcsdef{#1}{%
        \csgappto{#1}{\toggletrue{##1@}}%
      }{%
        \csgdef{#1}{\toggletrue{##1@}}%
      }%
    }{%
      \ifcsdef{#1}{%
        \csgappto{#1}{\togglefalse{##1@}}%
      }{%
        \csgdef{#1}{\togglefalse{##1@}}%
      }%
    }%
  }%
  \dolistloop{\hooktoggle@specific}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\hookarg@specific}
% \begin{macro}{\add@hookarg@specific@to@cs}
% The same, but for optional argument of critical footnotes with assigned value.
%    \begin{macrocode}
\def\hookarg@specific{}%
\newcommand{\add@hookarg@specific@to@cs}[1]{%
  \def\do##1{%
    \ifcsvoid{##1@}{}{%
      \ifcsdef{#1}{%
        \csxappto{#1}{%
          \noexpand\csdef%
            {##1@}{\csname##1@\endcsname}%
          }%
      }{%
        \csxdef{#1}{%
          \noexpand\csdef%
            {##1@}{\csname##1@\endcsname}%
          }%
      }%
    }%
  }%
  \dolistloop{\hookarg@specific}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% And now, we define some hooks specific to a note.
%    \begin{macrocode}
\newhooktoggle@specific{fulllines}%
\newhooktoggle@specific{nonum}
\newhooktoggle@specific{nosep}
\newhooktoggle@specific{noprefix}%
\newhooktoggle@specific{prefixmore}%
\newhookarg@specific{linerangesep}
%    \end{macrocode}
% \begin{macro}{linerangesep@}
% \cs{linerangesep@} is defined by the option \option{linerangesep} of critical notes to change temporarily the line range separator for a specific line.
% As we have to define it before typesetting the line and undefine it after, we use the family of \package{xkeyval} package's key.
%    \begin{macrocode}
%    \end{macrocode}
%
%
% \end{macro}
% \begin{macro}{\nomk@}
%\protect\cs{nomk@} toggle is used by \parpackage{} to remove the footnote mark in the text when using \protect\cs{footnoteXmk}. Read \parpackage handbook.
%    \begin{macrocode}
\newtoggle{nomk@}%
%    \end{macrocode}
% \end{macro}
% \subsection{Alias}
% \begin{macro}{\Xnolemmaseparator}
%\protect\cs{Xnolemmaseparator}\oarg{series} is just an alias for \protect\cs{Xlemmaseparator}\oarg{series}\verb|{}|.
%    \begin{macrocode}
\newcommandx*{\Xnolemmaseparator}[1][1]{\Xlemmaseparator[#1]{}}
%    \end{macrocode}
% \end{macro}
%
%
% \section{Output routine}\label{output}
%
%
% Now we begin the output routine and associated things.
%
%
%
%
% \subsection{Extra footnotes output}
%
%    With luck we might only have to change \protect\cs{@makecol} and
% \protect\cs{@reinserts} of \LaTeX's kernel.
% Since \reledmac, we use \protect\package{etoolbox}'s patching commands instead of overriding.
% It should provides better compatibility with other package which modify these commands

%
% \begin{macro}{\l@ddoxtrafeet}
% \protect\cs{l@ddoxtrafeet} is the code extending \protect\cs{@makecol} to cater for
% the extra \macpackage\ feet. We have two categories of extra footnotes.
% By default, we order the footnote inserts so that the regular footnotes of \LaTeX\ are first,
% then familiar familiar footnotes and finally
% the critical footnotes.
% \changes{v0.2.1}{2003/09/13}{Renamed \protect\cs{doxtrafeet} to \protect\cs{l@ddoxtrafeet}}
% \changes{v1.9.0}{2014/02/05}{Add \protect\cs{fnpos} to choice the order of footnotes.}
%    \begin{macrocode}
\newcommand*{\l@ddoxtrafeet}{%
  \IfStrEq{familiar-critical}{\@fnpos}
    {\do@feetX\do@Xfeet}%
    {%
    \IfStrEq{critical-familiar}{\@fnpos}%
        {\do@Xfeet\do@feetX}%
        {%
          \setbox\@outputbox \vbox{%
            \unvbox\@outputbox%
            \do@feet@custom@order{}{\@fnpos}%
          }%
        }%
    }%
}%

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\do@feet@custom@order}
% \cs{do@feet@custom@order} is called when \cs{@fnpos} is neither `familiar-critical', nor `critical-familiar', that is, when the order is more complex.
% In this case, people must define the order for all footnote series.
% If they don't, \LaTeX\ could perform an infinite run.
%    \begin{macrocode}
\newcommand{\do@feet@custom@order}[2]{%
  \def\do##1{%
    \edef\@@notesseries{\@firstoftwo##1}%
    \edef\@@notetype{\@secondoftwo##1}%
    \ifdefstring{\@@notetype}{critical}%
      {\csuse{#1append@Xnotes}{\@@notesseries}}%
      {\ifdefstring{\@@notetype}{familiar}%
        {\csuse{#1append@notesX}{\@@notesseries}}%
        {}%
      }%
  }%
  \expandafter\docsvlist\expandafter{#2}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\do@Xfeet}
% \protect\cs{do@Xfeet} is the code extending \protect\cs{@makecol} to cater to
% the extra critical feet.
% \changes{v0.4.1}{2004/03/06}{Changed \protect\cs{do@Xfeet} code for easier extensions}
%    \begin{macrocode}
\newcommand*{\do@Xfeet}{%
  \setbox\@outputbox \vbox{%
    \unvbox\@outputbox
    \@opXfeet}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@opXfeet}
% \begin{macro}{\append@Xnotes}
% \begin{macro}{\print@Xnotes}
% The extra critical feet to be added to the output.
% \changes{v0.4.1}{2004/03/06}{Added \protect\cs{@opXfeet}}.
% A macro which appends critical notes to the output's routine, also adding vertical space before notes
%    \begin{macrocode}
\newcommand{\append@Xnotes}[1]{%
  \ifvoid\csuse{#1footins}\else%
      \global\skip\csuse{#1footins}=\csuse{Xbeforenotes@#1}%
      \global\advance\skip\csuse{#1footins} by\csuse{Xafterrule@#1}%
      \print@Xnotes{#1}%
   \fi%
}%
%    \end{macrocode}
% The normal way to add one series,
% \protect\cs{print@Xnotes}, is replaced by \parpackage when using \protect\cs{Pages}.
%    \begin{macrocode}
\newcommand\print@Xnotes[1]{%
  \xdef\@currentseries{#1}%
  \csuse{#1footstart}{#1}%
  \csuse{#1footgroup}{#1}%%
}%
%    \end{macrocode}
% We print all series of notes by looping on them.
% We check before printing them that they are not voided.
%    \begin{macrocode}
\newcommand*{\@opXfeet}{%
  \unless\ifnocritical@%
    \gdef\firstXseries@{}%
    \def\do##1{%
      \append@Xnotes{##1}%
      }%
    \dolistloop{\@series}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\l@ddodoreinxtrafeet}
% \protect\cs{l@ddodoreinxtrafeet} is the code catering for the extra footnotes
% within \protect\cs{@reinserts}.
% We use the same category and ordering as in \protect\cs{l@ddoxtrafeet}.
% \changes{v0.2.1}{203/09/13}{Renamed \protect\cs{dodoreinxtrafeet} to \protect\cs{l@ddodoreinxtrafeet}}
%    \begin{macrocode}
\newcommand*{\l@ddodoreinxtrafeet}{%
  \IfStrEq{familiar-critical}{\@fnpos}
    {\@doreinfeetX\X@doreinfeet}%
    {%
    \IfStrEq{critical-familiar}{\@fnpos}%
        {\X@doreinfeet\@doreinfeetX}%
        {\@doreinfeetX\X@doreinfeet}%
    }%
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\X@doreinfeet}
% \protect\cs{X@doreinfeet} is the code for catering for the
%  extra critical footnotes
% within \protect\cs{@reinserts}.
%    \begin{macrocode}
\newcommand*{\X@doreinfeet}{%
  \unless\ifnocritical@%
    \def\do##1{%
      \ifvoid\csuse{##1footins}\else%
        \insert\csuse{##1footins}{\unvbox\csuse{##1footins}}%
      \fi}%
    \dolistloop{\@series}
  \fi%
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\print@notesX}
% \begin{macro}{\append@notesX}
% \begin{macro}{\do@feetX}
% \begin{macro}{\@doreinfeetX}
% We have to add all the new kinds of familiar footnotes to the output
% routine.
% A macro which appends the familiar footnotes of one series onto the output routine, also adding vertical skip before notes.
%    \begin{macrocode}
\newcommand{\append@notesX}[1]{%
  \ifvoid\csuse{footins#1}\else%
      \global\skip\csuse{footins#1}=\csuse{beforenotesX@#1}%
      \global\advance\skip\csuse{footins#1} by\csuse{afterruleX@#1}%
      \print@notesX{#1}%
  \fi%
}%
%    \end{macrocode}
% The normal way to print one series of notes.
% \protect\cs{print@Xnotes} is replaced by \parpackage when using \protect\cs{Pages}.
%    \begin{macrocode}
\newcommand\print@notesX[1]{%
  \xdef\@currentseries{#1}%
  \csuse{footstart#1}{#1}%
  \csuse{footgroup#1}{#1}%
}%
%    \end{macrocode}
% We print all the series of notes by looping over them.
% We check before printing them that they are not voided.
%    \begin{macrocode}
\newcommand*{\do@feetX}{%
  \unless\ifnofamiliar@%
    \gdef\firstseriesX@{}%
    \setbox\@outputbox \vbox{%
      \unvbox\@outputbox%
      \def\do##1{%
        \append@notesX{##1}%
      }%
      \dolistloop{\@series}}%
  \fi%
}%

\newcommand{\@doreinfeetX}{%
  \unless\ifnofamiliar@%
    \def\do##1{%
      \ifvoid\csuse{footins##1}\else
        \insert%
          \csuse{footins##1}
          {\unvbox\csuse{footins##1}}%
       \fi%
    }%
    \dolistloop{\@series}%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Patching standard output's commands}
% The \protect\ltxclass{memoir} class does not use the `standard' versions of
% \protect\cs{@makecol} and \protect\cs{@reinserts}, due to its sidebar insert.
% We had better add that code if \protect\ltxclass{memoir} is used. (It can
% be awkward dealing with |\if| code within |\if| code, so don't use
% |\ifl@dmemoir| here.)
% \changes{v0.2.1}{2003/09/13}{Major changes to insert code when memoir is loaded}
% \changes{v2.0.0}{2015/07/19}{\protect\cs{@makecol}, \protect\cs{@reinserts} and \protect\cs{@doclearpage} are patched instead of begin redefined}
% \changes{v2.0.0}{2015/07/19}{\protect\cs{doxtrafeeti} becomes \protect\cs{Xdo@feet};
% \protect\cs{doxtrafeetii} becomes \protect\cs{do@Xfeet};
% \protect\cs{@opxtrafeeti} becomes \protect\cs{@opfeetX};
% \protect\cs{doreinxtrafeetii} becomes \protect\cs{X@doreinfeet};
% \protect\cs{doreinxtrafeeti} becomes \protect\cs{@doreinfeetX}.}
% \changes{v2.16.0}{2016/10/02}{\protect\cs{Xdo@feet} becomes \protect\cs{do@Xfeet}}
% \changes{v2.16.0}{2016/10/02}{More explicit error message in case the stanza indentation is not defined.}
%    \begin{macrocode}
\@ifclassloaded{memoir}{%
%    \end{macrocode}
% \protect\ltxclass{memoir} is loaded so we use \protect\ltxclass{memoir}'s built in hooks.
%    \begin{macrocode}
  \g@addto@macro{\m@mdoextrafeet}{\l@ddoxtrafeet}%
  \g@addto@macro{\m@mdodoreinextrafeet}{\l@ddodoreinxtrafeet}%
  }{%
%    \end{macrocode}
% \protect\ltxclass{memoir} has not been loaded, so patch \protect\cs{@makecol} and
% \protect\cs{@reinserts}.
% If the \package{fancyhdr} package $<$ version 3.8 has been loaded, we patch the \cs{latex@makecol} command, because this package redefines the standard \cs{@makecol} in the preamble to call \cs{latex@makecol}, which has been \cs{let} to \cs{@makecol}.
% If this package is not loaded, we directly patch \cs{@makecol}.
% If the \package{fancyhdr} package $\geq$ version 3.8, we also directly patch \cs{@makecol}, because \package{fancyhdr} does its own patch \cs{AtBeginDocument}.
%    \begin{macrocode}
  \ifboolexpr{%
    test{\@ifpackageloaded{fancyhdr}}%
    and test {\ifdef{\latex@makecol}}%
  }{%
    \patchcmd%
      {\latex@makecol}%
      {\xdef\@freelist{\@freelist\@midlist}}%
      {\xdef\@freelist{\@freelist\@midlist}\l@ddoxtrafeet}%
      {}%
      {\led@error@fail@patch@@makecol}%
    }{%
    \patchcmd%
      {\@makecol}%
      {\xdef\@freelist{\@freelist\@midlist}}%
      {\xdef\@freelist{\@freelist\@midlist}\l@ddoxtrafeet}%
      {}%
      {\led@error@fail@patch@@makecol}%
    }%

  \patchcmd%
    {\@reinserts}%
    {\ifvbox}%
    {\l@ddodoreinxtrafeet\ifvbox}%
    {}%
    {\led@error@fail@patch@@reinserts}%
}

%    \end{macrocode}
%
%

%   It turns out that \protect\cs{@doclearpage} also needs modifying.
% \changes{v0.4.1}{2004/03/25}{Added code for changing \protect\cs{@doclearpage}}
% \begin{macro}{\if@led@nofoot}
% We have to check if there are any leftover feet.
%    \begin{macrocode}
\newif\if@led@nofoot

%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\@ifclassloaded{memoir}{%
%    \end{macrocode}
% If the \protect\ltxclass{memoir} class is loaded, we hook into its modified
% \verb?\@doclearpage?.
% \begin{macro}{\@mem@extranofeet}
%    \begin{macrocode}
\g@addto@macro{\@mem@extranofeet}{%%
  \def\do#1{%
    \unless\ifnocritical@%
      \ifvoid\csuse{#1footins}\else\@mem@nofootfalse\fi%
    \fi%
    \unless\ifnofamiliar@%
      \ifvoid\csuse{footins#1}\else\@mem@nofootfalse\fi%
    \fi%
    }
  \dolistloop{\@series}%
  }%
}{%
%    \end{macrocode}
% \end{macro}
% As \protect\ltxclass{memoir} is not loaded we have patch \protect\cs{@doclearpage}.
% \begin{macro}{\@led@testifnofoot}
% \begin{macro}{\@doclearpage}
%    \begin{macrocode}
\newcommand*{\@led@testifnofoot}{%
  \@led@nofoottrue%
  \ifvoid\footins\else%
    \@led@nofootfalse%
  \fi%
  \def\do##1{%
    \unless\ifnocritical@%
      \ifvoid\csuse{##1footins}\else%
        \@led@nofootfalse%
      \fi%
    \fi%
    \unless\ifnofamiliar@%
      \ifvoid\csuse{footins##1}\else%
        \@led@nofootfalse%
      \fi%
    \fi%
  }%
  \dolistloop{\@series}%
}%

\pretocmd%
 {\@doclearpage}%
 {\@led@testifnofoot}%
 {}%
 {\led@error@fail@patch@@doclearpage}%

\patchcmd%
 {\@doclearpage}%
 {\ifvoid\footins}%
 {\if@led@nofoot}%
 {}%
 {\led@error@fail@patch@@doclearpage}%

}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{Page numbering in parallel typsetting}
% The \parpackage\ package has two options which change the way page numbering works.
% We need to implement these options on \macpackage and not on \parpackage because they have some consequences for the \macpackage auxiliary files (numbered file; see~\reff{new@line@pagecounting}).
% The \verb+sameparallelpagenumber+ option allows the same page number on both left and right side
% The \verb+prevpgnotnumbered+ option allows an empty (not numbered) right-side page before \cs{Pages}.
%
%
% We cannot implement these two options by changing the value of the \verb|page| counter, since its value is used by many \LaTeX\ features to determine whether a page is left (even numbered) or right (odd numbered).
% Consequently, we have to do it by patching \cs{thepage}, in order to use the value of the \verb+par@page+ counter instead of the value of the \verb+page+ counter.
%
% This counter will be increased in a patched version of \LaTeX's \protect\cs{@outputpage} macro, as is the \verb+page+ counter in this macro. However, this increase will take account of the options.
%

%

% \begin{macro}{\par@patch@thepage}
% \begin{macro}{\par@patch@pagenumbering}
% \cs{par@patch@thepage} patches \cs{thepage} in order to use the value of \verb+par@page+ counter and not the value of \verb+page+.
% It must be called after any redefinition of \cs{thepage}.
% That is why we insert it at the end of the \LaTeX\ macro \cs{pagenumbering}, which is called by some \cs{xxxmatter} commands.
% In cases when we are using the \ltxclass{memoir} class, we insert it at the end of  \cs{@mempnum}.
% When using \cs{pagenumbering}, we also need to reset the \verb+par@page+ counter. Consequently, we put \cs{par@patch@thepage} and counter reset in \cs{par@patch@pagenumbering}
% We also call \cs{par@patch@thepage} at the beginning of the document.
%    \begin{macrocode}

\newcommand{\par@patch@thepage}{%
  \ifboolexpr{%
    bool{sameparallelpagenumber}%
    or bool{prevpgnotnumbered}%
  }%
  {%
    \patchcmd{\thepage}%
      {page}{par@page}%
      {}%
      {\led@error@fail@patch@thepage}%
  }{}%
}%

\newcommand{\par@patch@pagenumbering}{%
  \setcounter{par@page}{1}%
  \par@patch@thepage%
}%

\ifl@dmemoir%
  \apptocmd{\@mempnum}%
    {\par@patch@pagenumbering}%
    {}%%
    {\led@error@fail@patch@@mempnum}%

\else%
  \apptocmd{\pagenumbering}%
    {\par@patch@pagenumbering}%
    {}%
    {\led@error@fail@patch@pagenumbering}%
\fi%

\AtBeginDocument{\par@patch@thepage}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\@outputpage}
% As its name says, \cs{@outputpage} is a \LaTeX\ macro called in the output routine. It is this macro which increases the \verb+page+ counter.
% We patch it in order to increase, conditionally, the \verb+par@page+ counter.
%    \begin{macrocode}
\AtBeginDocument{%
  \apptocmd{\@outputpage}{%
    \ifsameparallelpagenumber%
      \ifl@dprintingpages%
        \ifodd\c@page\else%
          \stepcounter{par@page}%
        \fi%
      \else%
        \stepcounter{par@page}%
      \fi%
    \else%
      \stepcounter{par@page}%
    \fi%
    }%
    {}%
    {\led@error@fail@patch@@outputpage}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thepar@page}
% The  \verb+par@page+ counter.
%    \begin{macrocode}
\newcounter{par@page}%
\setcounter{par@page}{1}%
%    \end{macrocode}
% \end{macro}
%
% \section{Cross referencing}
% \label{xref}\relax
%
%
%
% You can mark a place in the text using a command of the form
% \protect\cs{edlabel}\marg{foo}, and later refer to it using the label
% \meta{foo} by typing \protect\cs{edpageref}\marg{foo}, or \protect\cs{lineref}\marg{foo} or
% \protect\cs{sublineref}\marg{foo} or \protect\cs{pstartref}. These reference commands will produce,
% respectively, the page, line sub-line and pstart on which the
% \protect\cs{edlabel}\marg{foo} command occurred.
%
% The reference macros warn you if a reference is made to an
% undefined label.
% If \marg{foo} has been used as a label before,
% the \protect\cs{edlabel}\marg{foo} command will issue a complaint; subsequent
% \protect\cs{edpageref} and \protect\cs{edlineref} commands will refer to the
% latest occurrence of \protect\cs{edlabel}\marg{foo}.
%
% \begin{macro}{\labelref@list}
% Set up a new list, \protect\cs{labelref@list}, to hold the page, line and
% sub-line numbers for each label.
%    \begin{macrocode}
\list@create{\labelref@list}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\zz@@@}
% \begin{macro}{\zz@@@@}
% Two convenience macros to zero three / four labeling counters in one go.
%    \begin{macrocode}
\newcommand*{\zz@@@}{000|000|000}% Set three counters to zero in one go
\newcommand*{\zz@@@@}{000|000|000|000}% Set four counters to zero in one go

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\edlabel}
% The \protect\cs{edlabel} command first writes a \protect\cs{@lab} macro to
% the \protect\cs{linenum@out} file.  It then checks to see that the
% \protect\cs{labelref@list} actually has something in it (if not, it
% creates a dummy entry), and pops the next value for the current
% label, storing it in \protect\cs{label@refs}. Finally it defines the
% label to be \protect\cs{empty} so that any future check will turn up
% the fact that it has been used.\footnote{The remaining macros
% in this section were kindly revised by Wayne
% Sullivan,\index{Sullivan, Wayne}  who
% substantially improved their efficiency and flexibility.}
%
% This version of the original \edmac{} \protect\cs{label} uses \protect\cs{@bsphack}
% and \protect\cs{@esphack} to eliminate extra space problems and also use the \LaTeX\
% write methods for the \file{.aux} file.
%
%    Jesse Billett\footnote{(\url{jdb43@cam.ac.uk}) via the \texttt{ctt}
% thread `ledmac cross referencing', 25 August 2003.}
% found that the original code could be off by several pages. This version,
% hopefully cures that, and also allows for non-arabic page numbering.
%
% \changes{v0.2.1}{2003/08/26}{Tweaked \protect\cs{edlabel} to get correct page numbers}
% \changes{v0.14.0}{2012/04/04}{Tweaked \protect\cs{edlabel} to get correct line number if the command is first element of a paragraph.}
% \changes{v1.18.0}{2015/02/23}{\protect\cs{edlabel} is now defined only one time for both \eledmac and \eledpar}
% \changes{v2.5.0}{2015/11/13}{Fix a bug when calling\protect\cs{edlabel} in a footnotes of the right side}
%    \begin{macrocode}
\newcommand*{\edlabel}[1]{%
  \leavevmode%
  \@bsphack%
  \ifboolexpr{bool{ledRcol} or bool{ledRcol@}}{%
    \ifXnote@%
     \protected@write\@auxout{}%
      {\string\l@dmake@labelsR\space\thepage|\l@dparsedstartline|\l@dparsedstartsub||\annot@start|\the\c@pstartR|{#1}}%
      \ifdef{\hypertarget}%
        {\Hy@raisedlink{\hypertarget{#1}{}}}%
        {}%
    \else%
      \write\linenum@outR{\string\@lab}%
      \ifx\labelref@listR\empty%
        \xdef\label@refs{\zz@@@@}%
      \else%
        \gl@p\labelref@listR\to\label@refs%
      \fi%
      \ifvmode%
          \advancelabel@refs%
      \fi%
%    \end{macrocode}
% Use code from the kernel \protect\cs{label} command to write the correct
% page number.
% Also define an hypertarget if \protect\package{hyperref} package is loaded.
%    \begin{macrocode}
      \protected@write\@auxout{}%
        {\string\l@dmake@labelsR\space\thepage|\label@refs|\the\c@pstartR|{#1}}%
      \ifdef{\hypertarget}%
        {\Hy@raisedlink{\hypertarget{#1}{}}}%
        {}%
    \fi%
  }{%
    \ifXnote@%
       \ifl@dpairing%pstart or pstartL?
         \protected@write\@auxout{}%
          {\string\l@dmake@labels\space\thepage|\l@dparsedstartline|\l@dparsedstartsub||\annot@start|\the\c@pstartL|{#1}}%
          \ifdef{\hypertarget}%
            {\Hy@raisedlink{\hypertarget{#1}{}}}%
            {}%
        \else%
          \protected@write\@auxout{}%
          {\string\l@dmake@labels\space\thepage|\l@dparsedstartline|\l@dparsedstartsub||\annot@start|\the\c@pstart|{#1}}%
          \ifdef{\hypertarget}%
            {\Hy@raisedlink{\hypertarget{#1}{}}}%
            {}%
        \fi%
    \else%
      \write\linenum@out{\string\@lab}%
      \ifx\labelref@list\empty%
        \xdef\label@refs{\zz@@@@}%
      \else%
        \gl@p\labelref@list\to\label@refs%
      \fi%
      \ifvmode%
          \advancelabel@refs%
      \fi%
      \ifl@dpairing%Pstart or PstartL?
        \protected@write\@auxout{}%
          {\string\l@dmake@labels\space\thepage|\label@refs|\the\c@pstartL|{#1}}%
          \ifdef{\hypertarget}%
            {\Hy@raisedlink{\hypertarget{#1}{}}}%
            {}%
       \else%
         \protected@write\@auxout{}%
          {\string\l@dmake@labels\space\thepage|\label@refs|\the\c@pstart|{#1}}%
          \ifdef{\hypertarget}%
            {\Hy@raisedlink{\hypertarget{#1}{}}}%
            {}%
       \fi%
    \fi%
  }%
\@esphack}%

%    \end{macrocode}
% \end{macro}
%
%
%\begin{macro}{\advancelabel@refs}
%\begin{macro}{\labelrefsparseline}
%\begin{macro}{\labelrefsparsesubline}
% \changes{v1.4.1}{2012/11/16}{Fix a bug with \protect\cs{edlabel}.}
%In cases where \protect\cs{edlabel} is the first element in a paragraph, we have a problem with line counts, because line counts change only at the first horizontal box of the paragraph.
%Hence, we need to test \protect\cs{edlabel} if it occurs at the start of a paragraph.  To do so, we use \protect\cs{ifvmode}. If the test is true, we must advance by one unit the amount of text we write into the \verb].aux] file.
% We do so with the \protect\cs{advancelabel@refs} command.
%    \begin{macrocode}
\newcounter{line}%
\newcounter{subline}%
\newcounter{absline}%
\newcommand{\advancelabel@refs}{%
    \setcounter{line}{\expandafter\labelrefsparseline\label@refs}%
    \stepcounter{line}%
    \setcounter{absline}{\expandafter\labelrefsparseabsline\label@refs}%
    \stepcounter{absline}%
    \ifsublines@%
        \setcounter{subline}{\expandafter\labelrefsparsesubline\label@refs}%
        \stepcounter{subline}{1}%
        \def\label@refs{\theline|\thesubline|\theabsline}%
    \else%
        \def\label@refs{\theline|0|\theabsline}%
    \fi%
}
\def\labelrefsparseline#1|#2|#3{#1}%
\def\labelrefsparsesubline#1|#2|#3{#2}%
\def\labelrefsparseabsline#1|#2|#3{#3}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\l@dmake@labels}
% The \protect\cs{l@dmake@labels} macro gets executed when the labels file is
% read. For each label it defines a macro, whose name is made up
% partly from the label you supplied, that contains the page, line
% and sub-line numbers.  But first it checks to see whether the
% label has already been used (and complains if it has).
%
% The initial use of \protect\cs{newcommand} is to catch if \protect\cs{l@dmake@labels}
% has been previously defined (by a class or package).
%
% \verb+#1+ page number, \verb+#2+ line number, \verb-#3- sub-line number, \verb+#4+ absolute line number, \verb+#5+ line number annotation, \verb+#6+ pstart number, \verb+#7+ label.
%
%    \begin{macrocode}
\newcommand*{\l@dmake@labels}{}
\def\l@dmake@labels#1|#2|#3|#4|#5|#6|#7{%
  \expandafter\ifx\csname the@label\csuse{XR@prefix}#7\endcsname%
    \relax%
  \else%
    \led@warn@DuplicateLabel{\csuse{XR@prefix}#7}%
  \fi
  \global\providetoggle{label@#7@ledRcol}%False is the default value of this toggle, which tells us whether a label is linked to the right or left side
  \csgdef{the@label\csuse{XR@prefix}#7}{#1|#2|#3|#4|#5|#6|\relax}%
  \ignorespaces}

%    \end{macrocode}
% \end{macro}
%
%  \LaTeX\ reads the \verb+aux+ file at both the beginning and end of
% the document, so we have to switch off duplicate label checking
% after the first time the file is read.
%
%    \begin{macrocode}
\AtBeginDocument{%
  \def\l@dmake@labels#1|#2|#3|#4|#5|#6|#7{}%
}

%    \end{macrocode}
%
% \begin{macro}{\@lab}
% The \protect\cs{@lab} command, which appears in the \protect\cs{linenum@out} file,
% appends the current value of page, line, sub-line, and absolute line to the
% \protect\cs{labelref@list}.
% These values are defined by the earlier
% \protect\cs{@page}, \protect\cs{@nl}, and the \protect\cs{sub@on} and \protect\cs{sub@off} commands
% appearing in the \protect\cs{linenum@out} file.
%
% \LaTeX\ uses the \texttt{page} counter for page numbers. However,
% it appears that this is not the right place to grab the page number.
% That task is now done in the \protect\cs{edlabel} macro. This version
% of \protect\cs{@lab} appends just the current line and sub-line numbers
% to \protect\cs{labelref@list}.
% \changes{v0.2.1}{2003/08/26}{Removed page setting from \protect\cs{@lab}}
% \changes{v0.3.0}{2004/02/14}{Replaced \protect\cs{the}\protect\cs{line@num} by
%                          \protect\cs{linenumr@p}\protect\cs{line@num} in
%                          \protect\cs{@lab}, and similar for sub-lines}
%    \begin{macrocode}

\newcommand*{\@lab}{%
  \ifledRcol
    \xright@appenditem{\linenumr@p{\line@numR}|%
      \ifsublines@ \sublinenumr@p{\subline@numR}\else 0\fi|%
      \the\absline@numR|%
      \current@annot%
      }%
      \to\labelref@listR
  \else
    \xright@appenditem{%
      \linenumr@p{\line@num}|%
      \ifsublines@ \sublinenumr@p{\subline@num}\else 0\fi|%
      \the\absline@num|%
      \current@annot%
      }%
      \to\labelref@list
  \fi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\applabel}
% \protect\cs{applabel}, if called in \protect\cs{edtext} will insert automatically both a starting and an ending label for the current edtext lines.
%    \begin{macrocode}
\newcommand*{\applabel}[1]{%
  \if@edtext@secondarg@%
%    \end{macrocode}
% Label should not be already defined.
%    \begin{macrocode}
      \ifcsundef{the@label#1}{%
        \csdef{the@label#1}{applabel}%
       }%
       {%
         \led@warn@DuplicateLabel{#1 (applabel)}%
       }%
%    \end{macrocode}
% Parse the \protect\cs{edtext} line numbers and annotations.
%    \begin{macrocode}
     \expandafter\l@dp@rsefootspec\l@d@nums|%
     \expandafter\parse@annot\l@current@annot|%
%    \end{macrocode}
% Use the \LaTeX\ standard hack for label.
%    \begin{macrocode}
     \@bsphack%
%    \end{macrocode}
% And now, write the data in the auxiliary file.
%    \begin{macrocode}
      \ifledRcol%
        \protected@write\@auxout{}%
          {\string\l@dmake@labelsR\space\l@dparsedstartpage|\l@dparsedstartline|\l@dparsedstartsub||\annot@start|\the\c@pstartR|{#1:start}}%
        \ifdef{\hypertarget}%
          {\Hy@raisedlink{\hypertarget{#1:start}{}}}%
          {}%
        \protected@write\@auxout{}%
          {\string\l@dmake@labelsR\space\l@dparsedendpage|\l@dparsedendline||\l@dparsedendsub||\annot@end|\the\c@pstartR|{#1:end}}%
      \else%
        \ifl@dpairing%pstart or pstartL?
          \protected@write\@auxout{}%
            {\string\l@dmake@labels\space\l@dparsedstartpage|\l@dparsedstartline|\l@dparsedstartsub||\annot@start|\the\c@pstartL|{#1:start}}%
          \ifdef{\hypertarget}%
            {\Hy@raisedlink{\hypertarget{#1:start}{}}}%
            {}%
          \protected@write\@auxout{}%
            {\string\l@dmake@labels\space\l@dparsedendpage|\l@dparsedendline|\l@dparsedendsub||\annot@end|\the\c@pstartL|{#1:end}}%
         \else%
            \protected@write\@auxout{}%
              {\string\l@dmake@labels\space\l@dparsedstartpage|\l@dparsedstartline|\l@dparsedstartsub||\annot@start|\the\c@pstart|{#1:start}}%
            \ifdef{\hypertarget}%
              {\Hy@raisedlink{\hypertarget{#1:start}{}}}%
              {}%
            \protected@write\@auxout{}%
              {\string\l@dmake@labels\space\l@dparsedendpage|\l@dparsedendline|\l@dparsedendsub||\annot@end|\the\c@pstart|{#1:end}}%
         \fi%
      \fi%
%    \end{macrocode}
% Use the \LaTeX\ standard hack for label.
%    \begin{macrocode}
      \@esphack%
%    \end{macrocode}
% Warning if \protect\cs{applabel} is called outside of \protect\cs{edtext}.
%    \begin{macrocode}
  \else%
    \led@warn@AppLabelOutSecondArgEdtext{#1}%
  \fi%
%    \end{macrocode}
% End of \protect\cs{applabel}
%    \begin{macrocode}
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\edlabelS}
% \begin{macro}{\edlabelE}
% \begin{macro}{\edlabelSE}
% \cs{edlabelS} and \cs{edlabelE} are just used to mark the beginning and the end of a passage.
%    \begin{macrocode}
\newcommand{\edlabelS}[1]{%
  \edlabel{#1:start}%
}
\newcommand{\edlabelE}[1]{%
  \edlabel{#1:end}%
}
\newcommand{\edlabelSE}[1]{%
  \edlabelS{#1}%
  \edlabelE{#1}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\wrap@edcrossref}
% \changes{v1.12.1}{2014/08/06}{Fix spurious spaces.}
% \changes{v1.12.7}{2014/09/07}{\protect\cs{wrap@edcrossref} is now robust}
% \protect\cs{wrap@edcrossref} is called around all \macpackage\ crossref commands, except those which start with x.
% It adds the hyperlink.
%    \begin{macrocode}
\newrobustcmd{\wrap@edcrossref}[2]{%
  \ifdef{\hyperlink}%
    {\hyperlink{#1}{#2}}%
    {#2}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\edpageref}
% \begin{macro}{\xpageref}
% If the specified label exists, \protect\cs{edpageref} gives its page number.
%
% For this reference command, as for the other two, a special
% version with prefix \verb"x" is provided for use in places where the
% command is to be scanned as a number, as in \protect\cs{linenum}. These
% special versions have two limitations: they do not print error
% messages if the reference is unknown, and they can't appear as
% the first label or reference command in the file; you must ensure
% that a \protect\cs{edlabel} or a normal reference command appears first, or
% these x-commands will always return zeros.
%
% \LaTeX\ already defines a \protect\cs{pageref}, so changing the name
%  to \protect\cs{edpageref}.
%    \begin{macrocode}
\newcommand*{\edpageref}[1]{\l@dref@undefined{#1}\wrap@edcrossref{#1}{\l@dgetref@num{1}{#1}}}
\newcommand*{\xpageref}[1]{\l@dgetref@num{1}{#1}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\edlineref}
% \begin{macro}{\xlineref}
% \changes{v1.16.1}{2015/02/05}{\protect\cs{lineref} is not defined if defined by some other package, like lineno.
% \Eledmac provides \protect\cs{edlineref} instead.}
% \changes{v2.5.0}{2015/11/13}{\protect\cs{xlineref} does not include anymore the side flag. Use \protect\cs{xflagref} to get it. Not that \protect\cs{edlineref} still contains the flag.}
% If the specified label exists, \protect\cs{lineref} gives its line number.
%    \begin{macrocode}
\newcommand*{\edlineref}[1]{%
  \l@dref@undefined{#1}%
  \wrap@edcrossref{#1}{%
    \providetoggle{label@#1@ledRcol}%Required for the first run, when the label has not yet been parsed on the .aux file
    \iftoggle{label@#1@ledRcol}%
        {\linenumrepR{\l@dgetref@num{2}{#1}}}%
        {\linenumrep{\l@dgetref@num{2}{#1}}}%
    \xflagref{#1}%
  }%
}%
\newcommand*{\xlineref}[1]{\l@dgetref@num{2}{#1}}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sublineref}
% \begin{macro}{\xsublineref}
% If the specified label exists, \protect\cs{sublineref} gives its sub-line number.
%    \begin{macrocode}
\newcommand*{\sublineref}[1]{%
  \l@dref@undefined{#1}%
  \wrap@edcrossref{#1}{%
    \providetoggle{label@#1@ledRcol}%Required for the first run, when the label has not yet been parsed on the .aux file
    \iftoggle{label@#1@ledRcol}%
      {\sublinenumrepR{\l@dgetref@num{3}{#1}}}%
      {\sublinenumrep{\l@dgetref@num{3}{#1}}}%
  }%
}%
\newcommand*{\xsublineref}[1]{\l@dgetref@num{3}{#1}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\xabslineref}
% If the specified label exists, \cs{xabslineref} gives its absolute line number.
% This is generally used only by \macpackage\ internal macros.
%    \begin{macrocode}
\newcommand*{\xabslineref}[1]{\l@dgetref@num{4}{#1}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\annotationref}
% \begin{macro}{\xannotationref}
% If the specified label exists, \cs{edannotationref} gives the line number annotation with which it is associated.
%    \begin{macrocode}
\newcommand*{\annotationref}[1]{%
  \l@dref@undefined{#1}%
  \wrap@edcrossref{#1}{%
    \l@wrap@ifnotemptybox{\Xwraplinenumannotation@ref}{%
      \l@dgetref@num{5}{#1}%
    }%
  }%
}%
\newcommand*{\xannotationref}[1]{%
  \l@dgetref@num{5}{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\pstarteref}
% \begin{macro}{\xpstartref}
% If the specified label exists, \protect\cs{pstartref} gives its pstart number.
%    \begin{macrocode}
\newcommand*{\pstartref}[1]{\l@dref@undefined{#1}\wrap@edcrossref{#1}{\l@dgetref@num{6}{#1}}}%
\newcommand*{\xpstartref}[1]{\l@dgetref@num{6}{#1}}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\xflagref}
% \cs{xflagref} finds the side flag of any ref defined with \cs{edlabel}.
%    \begin{macrocode}
\newcommand*{\xflagref}[1]{\l@dgetref@num{7}{#1}}%
%    \end{macrocode}
% \end{macro}
% The next three macros are used by the referencing commands above,
% and do the job of extracting the right numbers from the label
% macro that contains the page, line, and sub-line number.
%
% \begin{macro}{\l@dref@undefined}
% The \protect\cs{l@dref@undefined} macro is called when you refer to a label with
% the normal referencing macros. Its argument is a label, and it
% just checks that the label has been defined.
%
%    \begin{macrocode}
\newcommand*{\l@dref@undefined}[1]{%
  \expandafter\ifx\csname the@label#1\endcsname\relax
    \led@warn@RefUndefined{#1}%
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dgetref@num}
% Next, \protect\cs{l@dgetref@num} fetches the number we want.  It has two
% arguments: the first is simply a digit, specifying whether to
% fetch a page (1), line (2),  sub-line (3), (4) pstart number or (5) side flag.  (This
% switching is done by calling \protect\cs{l@dlabel@parse}.) The second argument
% is the label-macro, which because of the \protect\cs{@lab} macro above is
% defined to be a string of the type \verb"123|456|789".
%    \begin{macrocode}
\newcommand*{\l@dgetref@num}[2]{%
  \expandafter
  \ifx\csname the@label#2\endcsname \relax
    000%
  \else
    \expandafter\expandafter\expandafter
    \l@dlabel@parse\csname the@label#2\endcsname|#1%
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dlabel@parse}
% Notice that we slipped another \verb"|" delimiter into the
% penultimate line of \protect\cs{l@dgetref@num}, to
% keep the `switch-number' separate from the reference numbers.  This
% \verb"|" is used as another parameter delimiter by \protect\cs{l@dlabel@parse},
% which extracts the appropriate number from its first argument.
% The \verb"|"-delimited arguments consist of the expanded label-macro
% (three reference numbers), followed by the switch-number (1,
% 2, 3, 4, 5, 6) which defines which of the former seven numbers to
% extract. (It was given earlier as the first argument of
% \protect\cs{l@dgetref@num}.)
%    \begin{macrocode}
\newcommand*{\l@dlabel@parse}{}
\def\l@dlabel@parse#1|#2|#3|#4|#5|#6|#7|#8{%
  \ifcase #8%
  \or #1%
  \or #2%
  \or #3%
  \or #4%
  \or #5%
  \or #6%
  \or #7%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xxref}
% \changes{v1.19.0}{2015/03/06}{\protect\cs{xxref} works also with right side numbers, when \protect\cs{@Rlineflag} is not empty.}
% \changes{v1.20.0}{2015/03/22}{Debug \protect\cs{xxref} when not loading \eledpar (Fix a bug added in 1.19.0).}
% The \protect\cs{xxref} command takes two arguments, both of which are
% labels, e.g., \protect\cs{xxref}\verb+{mouse}{elephant}+.  It first does some
% checking to make sure that the labels do exist (if one does not,
% those numbers are set to zero).  Then it calls \protect\cs{linenum} and sets
% the beginning page, line, and sub-line numbers to those of the
% place where \protect\cs{label}\verb+{mouse}+ was placed, and the ending
% numbers to those at \verb+{elephant}+.  The point of this is
% to be able to manufacture footnote line references to passages
% which cannot be specified in the normal way as the first argument
% to \protect\cs{edtext} for one reason or another.  Using \protect\cs{xxref} in the
% second argument of \protect\cs{edtext} lets you set things up at least
% semi-automatically.
%    \begin{macrocode}
\newcommand*{\xxref}[2]{%
  {%
   \expandafter\ifx\csname the@label#1\endcsname\relax%
      \let\@tempa\zz@@@%
      \def\@tempc{}%
    \else%
      \def\@tempa{%
        \l@dgetref@num{1}{#1}|%
        \l@dgetref@num{2}{#1}|%
        \l@dgetref@num{3}{#1}%
      }%
      \edef\@tempc{%
        \l@dgetref@num{5}{#1}%
      }%
   \fi%
   \expandafter\ifx\csname the@label#2\endcsname\relax%
      \let\@tempb\zz@@@%
      \def\@tempd{}%
   \else%
      \def\@tempb{%
        \l@dgetref@num{1}{#2}|%
        \l@dgetref@num{2}{#2}|%
        \l@dgetref@num{3}{#2}%
      }%
      \edef\@tempd{%
        \l@dgetref@num{5}{#2}%
      }%
   \fi%
   \global\appto\@beforeinsertofthisedtext{%
     \def\@this@crossref@start{#1}%
   }%
   \global\appto\@beforeinsertofthisedtext{%
     \def\@this@crossref@end{#2}%
   }%
   \linenum{\@tempa|\@tempb}%
   \edef\@tempe{\@tempc|\@tempd}%
   \expandafter\lineannot\expandafter{\@tempe}%
 }%
}%


%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\appref}
% \begin{macro}{\apprefwithpage}
% \begin{macro}{\SEref}
% \begin{macro}{\SErefwithpage}
% \begin{macro}{\SErefwithpage}
% \protect\cs{appref}, \cs{SEref}, \cs{apprefwithpage}, \cs{SErefwithpage} and \cs{SEonlypage}    print crossref to some start / end lines defined by specific commands.
% It prints the lines as they should be printed in the apparatus (critical notes for not suffixed versions, endnotes for suffixed versions).
%
% Here we define hooks similar to some those related to critical footnotes or endnotes.
%
% So, first declare the default value of the hooks for the pseudo-series.
% Also declare the internal toggle which are switch by \macpackage{}.
%    \begin{macrocode}
\def\Xtwolines@appref{}%
\def\Xtwolines@SEref{}%

\def\Xmorethantwolines@appref{}%
\def\Xmorethantwolines@SEref{}%

\def\Xlinerangeseparator@appref{\endashchar}%
\def\Xlinerangeseparator@SEref{\endashchar}%

\def\Xsublinesep@appref{\fullstop}%
\def\Xsublinesep@SEref{\fullstop}%

\def\Xpagelinesep@appref{\fullstop}%
\def\Xpagelinesep@SEref{\fullstop}%


\newtoggle{Xtwolinesbutnotmore@appref}%
\newtoggle{Xtwolinesbutnotmore@SEref}%

\newtoggle{Xtwolinesonlyinsamepage@appref}%

\newtoggle{Xtwolinesonlyinsamepage@SEref}%

\newtoggle{Xlineflag@appref}%
\toggletrue{Xlineflag@appref}%Here exception
\newtoggle{Xlineflag@SEref}%
\toggletrue{Xlineflag@SEref}%%Here exception

\newtoggle{Xlinenumannotationonlyfirst@SEref}%Never changed, just for the test in \setprintlines
\newtoggle{Xlinenumannotationonlyfirst@appref}%Idem

\def\Xlinenumannotationposition@appref{after}%
\def\Xlinenumannotationposition@SEref{after}%

\def\Xwraplinenumannotation@appref{\textsuperscript}%
\def\Xwraplinenumannotation@SEref{\textsuperscript}%
\newtoggle{Xnoidenticallinenumannotation@appref}%
\newtoggle{Xnoidenticallinenumannotation@SEref}%

\def\Xendtwolines@apprefwithpage{}%
\def\Xendtwolines@SErefwithpage{}%

\def\Xendmorethantwolines@apprefwithpage{}%
\def\Xendmorethantwolines@SErefwithpage{}%

\def\Xendlinerangeseparator@apprefwithpage{\endashchar}
\def\Xendlinerangeseparator@SErefwithpage{\endashchar}
\def\Xendlinerangeseparator@SErefonlypage{\endashchar}

\def\Xendbeforepagenumber@apprefwithpage{p.}%
\def\Xendbeforepagenumber@SErefwithpage{p.}%
\def\Xendbeforepagenumber@SEonlypage{p.}%

\def\Xendafterpagenumber@apprefwithpage{) }%
\def\Xendafterpagenumber@SErefwithpage{) }%


\def\Xendlineprefixsingle@apprefwithpage{}%
\def\Xendlineprefixsingle@SErefwithpage{}%

\def\Xendlineprefixmore@apprefwithpage{}%
\def\Xendlineprefixmore@SErefwithpage{}%

\newtoggle{Xendtwolinesbutnotmore@apprefwithpage}%
\newtoggle{Xendtwolinesbutnotmore@SErefwithpage}%

\def\Xendsublinesep@apprefwithpage{\fullstop}%
\def\Xendsublinesep@SErefwithpage{\fullstop}%

\newtoggle{Xendtwolinesonlyinsamepage@apprefwithpage}%
\newtoggle{Xendtwolinesonlyinsamepage@SErefwithpage}%

\newtoggle{Xendlineflag@apprefwithpage}
\toggletrue{Xendlineflag@apprefwithpage}%Here, exception
\newtoggle{Xendlineflag@SErefwithpage}
\toggletrue{Xendlineflag@SErefwithpage}%Here, exception


\newtoggle{Xendlinenumannotationonlyfirst@SEref}%Never changed, just for the test in \setprintendlines
\newtoggle{Xendlinenumannotationonlyfirst@appref}%Idem

\def\Xendlinenumannotationposition@apprefwithpage{after}%
\def\Xendlinenumannotationposition@apprefwithpage@SErefwithpage{after}%

\def\Xendwraplinenumannotation@apprefwithpage{\textsuperscript}%
\def\Xendwraplinenumannotation@SErefwithpage{\textsuperscript}%

\newtoggle{Xendnoidenticallinenumannotation@apprefwithpage}%
\newtoggle{Xendnoidenticallinenumannotation@SErefwithpage}%
%    \end{macrocode}
% Note that some of these hooks are declared but no user command can change their values. Such hooks are not pertinent for \verb+appref+ and \verb+apprefwithpage+ pseudo-series, but their values are nonetheless tested in some  macros.
%    \begin{macrocode}

\gdef\Xboxstartlinenum@appref{0pt}
\gdef\Xboxstartlinenum@SEref{0pt}

\gdef\Xboxendlinenum@appref{0pt}
\gdef\Xboxendlinenum@SEref{0pt}

\gdef\Xendboxstartlinenum@apprefwithpage{0pt}
\gdef\Xendboxstartlinenum@SErefwithpage{0pt}

\gdef\Xendboxendlinenum@apprefwithpage{0pt}
\gdef\Xendboxendlinenum@SErefwithpage{0pt}

\newtoggle{Xendpagenumberonlyfirst@apprefwithpage}
\newtoggle{Xendpagenumberonlyfirst@SErefwithpage}

\newtoggle{Xendpagenumberonlyfirstifsingle@apprefwithpage}
\newtoggle{Xendpagenumberonlyfirstifsingle@SErefwithpage}

\newtoggle{Xendpagenumberonlyfirstintwo@apprefwithpage}
\newtoggle{Xendpagenumberonlyfirstintwo@SErefwithpage}

\gdef\Xendsympagenum@apprefwithpage{}
\gdef\Xendsympagenum@SErefwithpage{}

\gdef\Xendinplaceofpagenumber@apprefwithpage{}
\gdef\Xendinplaceofpagenumber@SErefwithpage{}

%    \end{macrocode}
% Now, declare the default values of \protect\cs{@apprefprefixsingle} and \protect\cs{@apprefprefixmore}, \cs{@SErefprefix}, \cs{@SErefprefixmore} and the commands which defines them.
% \changes{v2.5.0}{2015/11/13}{Debug \protect\cs{setapprefprefixsingle}}
%    \begin{macrocode}
\newcommand\@apprefprefixsingle{}%
\newcommand\@SErefprefixsingle{}%

\newcommand\@apprefprefixmore{}%
\newcommand\@SErefprefixmore{}%

\newcommand{\setapprefprefixsingle}[1]{%
  \gdef\@apprefprefixsingle{#1}%
}
\newcommand{\setSErefprefixsingle}[1]{%
  \gdef\@SErefprefixsingle{#1}%
}

\newcommand{\setapprefprefixmore}[1]{%
  \gdef\@apprefprefixmore{#1}%
}
\newcommand{\setSErefprefixmore}[1]{%
  \gdef\@SErefprefixmore{#1}%
}

%    \end{macrocode}
% And not \cs{setSErefonlypageprefixsingle} and \cs{setSErefonlypageprefixmore}.
%    \begin{macrocode}
\newcommand{\setSErefonlypageprefixsingle}[1]{%
  \gdef\SErefonlypage@prefixsingle{#1}%
}%
\newcommand{\setSErefonlypageprefixmore}[1]{%
  \gdef\SErefonlypage@prefixmore{#1}%
}%
%    \end{macrocode}
% \changes{v1.23.0}{2015/05/18}{Debug \protect\cs{Xendtwolines}, \protect\cs{Xendmorethantwolines}, \protect\cs{Xendtwolinesbutnotmore} and \protect\cs{Xendtwolinesonlyinsamepage} when using \protect\cs{apprefwithpage}.}
% And now, the main commands: \protect\cs{appref}, \protect\cs{apprefwithpage}, \cs{SEref} and \cs{SErefwithpage}.
% These commands call \cs{refformated@} and \protect\cs{refformatedwithpage}, which calls \cs{printlines} and \cs{printendlines} . That is why we have previously declared all hooks values tested inside these last commands.
%    \begin{macrocode}

\newcommandx{\appref}[2][1,usedefault]{\refformated@{#1}{#2}{appref}}
\newcommandx{\SEref}[2][1,usedefault]{\refformated@{#1}{#2}{SEref}}

\newcommandx{\apprefwithpage}[2][1,usedefault]{\refformatedwithpage@{#1}{#2}{appref}}
\newcommandx{\SErefwithpage}[2][1,usedefault]{\refformatedwithpage@{#1}{#2}{SEref}}
\newcommandx{\SErefonlypage}[2][1,usedefault]{\refformatedonlypage@{#1}{#2}{SEref}}


\newcommand{\refformated@}[3]{%
  \def\do##1{%
    \setkeys[mac]{truefootnoteoption}{##1}%
  }%
 \notblank{#1}{\docsvlist{#1}}{}%
 \xdef\@currentseries{#3}%
 \iftoggle{noprefix@}{}%
  {%
    \ifcsempty{@#3prefixmore}%
    {\@apprefprefixsingle}%
    {%
      \IfEq{\xlineref{#2:start}}{\xlineref{#2:end}}%
      {\iftoggle{prefixmore@}%
        {\csuse{@#3prefixmore}}%
        {\csuse{@#3prefixsingle}}%
      }%
      {\csuse{@#3prefixmore}}%
    }%
  }%
 \ifboolexpr{%
   test{\ifcsundef{the@label#2:start}}%
   or test{\ifcsundef{the@label#2:end}}%
  }%
   {\led@warn@pairRefUndefined{#2}\nfss@text{\reset@font\bfseries ??}}%
   {%
    \def\@this@crossref@start{#2:start}%
    \def\@this@crossref@end{#2:end}%
    \xdef\annot@start{\xannotationref{#2:start}}%
    \xdef\annot@end{\xannotationref{#2:end}}%
    \printlines\xpageref{#2:start}|\xlineref{#2:start}|\xsublineref{#2:start}|\xpageref{#2:end}|\xlineref{#2:end}|\xsublineref{#2:end}|\relax|\xflagref{#2:start}|%
   }%
  \def\do##1{%
    \setkeys[mac]{falsefootnoteoption}{##1}%
  }%
 \notblank{#1}{\docsvlist{#1}}{}%
}%

\newcommand{\refformatedwithpage@}[3]{%
  \def\do##1{%
    \setkeys[mac]{truefootnoteoption}{##1}%
  }%
 \notblank{#1}{\docsvlist{#1}}{}%
 \xdef\@currentseries{#3withpage}%
 \ifboolexpr{%
   test{\ifcsundef{the@label#2:start}}%
   or test{\ifcsundef{the@label#2:end}}%
  }%
   {\led@warn@pairRefUndefined{#2}\nfss@text{\reset@font\bfseries ??}}%
   {%
   \def\@this@crossref@start{#2:start}%
   \def\@this@crossref@end{#2:end}%
   \printendlines\xpageref{#2:start}|\xlineref{#2:start}|\xsublineref{#2:start}|\xpageref{#2:end}|\xlineref{#2:end}|\xsublineref{#2:end}|\relax|\xflagref{#2:start}|%
   }%
  \def\do##1{%
    \setkeys[mac]{falsefootnoteoption}{##1}%
  }%
 \notblank{#1}{\docsvlist{#1}}{}%
}%

\newcommand{\refformatedonlypage@}[3]{%
  \def\do##1{%
    \setkeys[mac]{truefootnoteoption}{##1}%
  }%
 \notblank{#1}{\docsvlist{#1}}{}%
 \xdef\@currentseries{#3onlypage}%
 \ifboolexpr{%
   test{\ifcsundef{the@label#2:start}}%
   or test{\ifcsundef{the@label#2:end}}%
  }%
   {\led@warn@pairRefUndefined{#2}\nfss@text{\reset@font\bfseries ??}}%
   {\ifnumequal{\xpageref{#2:end}}{\xpageref{#2:start}}%
       {%
       \ifcsvoid{#3onlypage@prefixsingle}%
         {}%
         {\csletcs{Xendbeforepagenumber@#3onlypage}{#3onlypage@prefixsingle}}%
       \printnpnum{%
         \wrap@edcrossref{#2:start}{\xpageref{#2:start}}%
         }%
       }%
     {%
      \ifcsvoid{#3onlypage@prefixmore}%
        {}%
        {\csletcs{Xendbeforepagenumber@#3onlypage}{#3onlypage@prefixmore}}%
      \ifdefined\linerangesep@%
        \printnpnum{%
          \wrap@edcrossref{#2:start}{\xpageref{#2:start}}%
          \linerangesep@%
          \wrap@edcrossref{#2:end}{\xpageref{#2:end}}%
        }%
      \else%
        \printnpnum{%
          \wrap@edcrossref{#2:start}{\xpageref{#2:start}}%
          \csuse{Xendlinerangeseparator@\@currentseries}%
          \wrap@edcrossref{#2:end}{\xpageref{#2:end}}%
        }%
      \fi%
     }%
   }%
  \def\do##1{%
    \setkeys[mac]{falsefootnoteoption}{##1}%
  }%
 \notblank{#1}{\docsvlist{#1}}{}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\edmakelabel}
% Sometimes the \protect\cs{edlabel} command cannot be used to specify
% exactly the page and line desired; you can use the \protect\cs{edmakelabel} macro
% make your own label.  For example, if you insert
% \protect\cs{edmakelabel}\verb+{elephant}{10|25|0}+ you will have created a
% new label, and a later call to \protect\cs{edpageref}\verb+{elephant}+ would
% print `10' and \protect\cs{lineref}\verb+{elephant}+ would print `25'.
% The sub-line number here is zero.
% \protect\cs{edmakelabel} takes a label, followed by a page and a line number(s)
% as arguments.
% \LaTeX\ defines a \protect\cs{makelabel} macro which is used in lists.
%          Peter Wilson has changed the name to \protect\cs{edmakelabel}.
%    \begin{macrocode}
\newcommand*{\edmakelabel}[2]{\expandafter\xdef\csname the@label#1\endcsname{#2}}

%    \end{macrocode}
% (If you are only going to refer to such a label using
% \protect\cs{xxref}, then you can omit entries in the same way as with
% \protect\cs{linenum} (see \reff{linenumdef} and
% \reff{linenumbers}), since \protect\cs{xxref} makes a call to
% \protect\cs{linenum} in order to do its work.)
% \end{macro}
%
%
% \subsection{Compatibility with \package{xref}}
% Here, we provide compatibility with the \package{xref} to enable \macpackage's cross-referencing to external documents.
% We assume that the user loads \package{xref} \emph{before} \package{reledmac}, but uses \cs{externaldocument} \emph{after} loading \package{reledmac}.
%
% \begin{macro}{\XR@test}
% First, we patch the \package{xr} macro \cs{XR@test}, which is called on every line of the external \verb+.aux+ file, in order to also call macros specific to \macpackage.
%    \begin{macrocode}
\pretocmd{\XR@test}%
  {\XR@test@mac+++#1#2#3#4+++}%
  {}%
  {}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\XR@test@mac}
%  The \cs{XR@test@mac} takes the full content of a line of the external \verb+.aux+ files, with the three final dots added by \package{xr}.
%    \begin{macrocode}
\long\def\XR@test@mac+++#1+++{\XR@test@mac@test#1}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\XR@test@mac@test}
% And finally, \cs{XR@test@mac@test} does the job.
% This code is based on the \cs{XR@test} macro of the \package{xr} package. However, not that the \cs{XR@prefix} is not called here, but it is integrated directly in \cs{l@dmake@labels} and  \cs{l@dmake@labelsR}.
%    \begin{macrocode}
\long\def\XR@test@mac@test#1#2...{%The triple dots (NOT \ldots) are because of the line 22 of xr.sty  v5.02 1994/05/28
  \ifx#1\l@dmake@labels%
   \l@dmake@labels#2%
  \else
    \ifx#1\l@dmake@labelsR%
      \l@dmake@labelsR #2%
    \fi%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \section{Sidenotes}
%
%    Regular \protect\cs{marginpar}s do not work inside numbered text\,---\,they
% do not produce any note but do put an extra unnumbered blank line into
% the text.
%
% \begin{macro}{\@xympar}
% Changing \protect\cs{@xympar} a little at least ensures that \protect\cs{marginpar}s
% in numbered text do not disturb the flow.
% \changes{v0.5.0}{2004/04/01}{Eliminated \protect\cs{marginpar} disturbance}
% \changes{v2.0.0}{2104/06/28}{Patching \protect\cs{@xympar} instead of redefining it}
%
%    \begin{macrocode}
\pretocmd{\@xympar}%
  {\ifnumberedpar@
    \led@warn@NoMarginpars
    \@esphack
  \else}%
  {}%
  {}%

\apptocmd{\@xympar}%
  {\fi}%
  {}
  {}

%    \end{macrocode}
% \end{macro}
%
%  We provide sidenotes as replacement for \protect\cs{marginpar} in numbered text.
% \changes{v0.5.0}{2004/04/03}{Added left and right sidenotes}
% \changes{v0.5.1}{2004/04/10}{Added moveable sidenote}
%
% \begin{macro}{\sidenote@margin}
% \begin{macro}{\sidenotemargin}
% \begin{macro}{\l@dgetsidenote@margin}
% These are the sidenote equivalents to \protect\cs{line@margin} and \protect\cs{linenummargin}
% for specifying which margin. The default is the right margin (opposite to
% the default for line numbers).
% \protect\cs{l@dgetsidenote@margin} returns the number associated to sidenote margin:
% \begin{description}
%   \item[left:] 0
%    \item[right:] 1
%    \item[outer:] 2
%    \item[inner:] 3
% \end{description}
% \changes{v0.5.1}{2004/04/10}{Added \protect\cs{sidenotemargin} and \protect\cs{sidenote@margin}}
% \changes{v0.7.0}{2005/02/23}{Added \protect\cs{l@dgetsidenote@margin}}
% \changes{v1.12.0}{2014/08/05}{\protect\cs{sidenotemargin} is now directly defined in \protect\package{eledmac} to be able to manage \protect\package{eledpar}.}
%    \begin{macrocode}
\newcount\sidenote@margin
\newcommand*{\sidenotemargin}[1]{{%
  \l@dgetsidenote@margin{#1}%
  \ifnum\@l@dtempcntb>\m@ne
    \ifledRcol
      \global\sidenote@marginR=\@l@dtempcntb
    \else
      \global\sidenote@margin=\@l@dtempcntb
    \fi
  \fi}}
\newcommand*{\l@dgetsidenote@margin}[1]{%
  \def\@tempa{#1}\def\@tempb{left}%
  \ifx\@tempa\@tempb
    \@l@dtempcntb \z@
  \else
    \def\@tempb{right}%
    \ifx\@tempa\@tempb
      \@l@dtempcntb \@ne
    \else
      \def\@tempb{outer}%
      \ifx\@tempa\@tempb
        \@l@dtempcntb \tw@
      \else
        \def\@tempb{inner}%
        \ifx\@tempa\@tempb
          \@l@dtempcntb \thr@@
        \else
          \led@warn@BadSidenotemargin
          \@l@dtempcntb \m@ne
        \fi
      \fi
    \fi
  \fi}
\sidenotemargin{right}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dlp@rbox}
% \begin{macro}{\l@drp@rbox}
% We need two boxes to store sidenote texts.
%    \begin{macrocode}
\newbox\l@dlp@rbox
\newbox\l@drp@rbox

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\ledlsnotewidth}
% \begin{macro}{\ledrsnotewidth}
% \begin{macro}{\ledlsnotesep}
% \begin{macro}{\ledrsnotesep}
% \begin{macro}{\ledlsnotefontsetup}
% \begin{macro}{\ledrsnotefontsetup}
% These specify the width of the left/right boxes (initialised to
% \protect\cs{marginparwidth}), their distance from
% the text (initialised to \protect\cs{linenumsep}), and the fonts used.
%    \begin{macrocode}
\newdimen\ledlsnotewidth \ledlsnotewidth=\marginparwidth
\newdimen\ledrsnotewidth \ledrsnotewidth=\marginparwidth
\newdimen\ledlsnotesep \ledlsnotesep=\linenumsep
\newdimen\ledrsnotesep \ledrsnotesep=\linenumsep
\newcommand*{\ledlsnotefontsetup}{\raggedleft\footnotesize}
\newcommand*{\ledrsnotefontsetup}{\raggedright\footnotesize}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\ledleftnote}
% \begin{macro}{\ledrightnote}
% \begin{macro}{\ledinnernote}
% \begin{macro}{\ledouternote}
% \begin{macro}{\ledsidenote}
% \protect\cs{ledleftnote}, \protect\cs{ledrightnote}, \protect\cs{ledinnernote}, \protect\cs{ledouternote} are the
% user commands for left, right, inner and outer sidenotes.
% The two last one are just alias for the two first one, depending of the page number.
% \protect\cs{ledsidenote}\marg{text} is the command for a moveable sidenote.
%    \begin{macrocode}
\newcommand*{\ledleftnote}[1]{\edtext{}{\l@dlsnote{#1}}}
\newcommand*{\ledrightnote}[1]{\edtext{}{\l@drsnote{#1}}}
\newcommand*{\ledsidenote}[1]{\edtext{}{\l@dcsnote{#1}}}%
\newcommand*{\ledinnernote}[1]{\edtext{}{\l@disnote{#1}}}%
\newcommand*{\ledouternote}[1]{\edtext{}{\l@dosnote{#1}}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\l@dlsnote}
% \begin{macro}{\l@drsnote}
% \begin{macro}{\l@dcsnote}
% \begin{macro}{\l@desnote}
% \begin{macro}{\l@disnote}
% \changes{v1.12.0}{2014/08/05}{\protect\cs{l@dlsnote},\protect\cs{l@drsnote} and \protect\cs{l@dcsnote} defined only one time, in \eledmac, including needs for eledpar case.}.
% The `footnotes' for left, right, and moveable sidenotes. The whole
% scheme is reminiscent of the critical footnotes code.
%    \begin{macrocode}
\newif\ifrightnoteup
  \rightnoteuptrue

\newcommand*{\l@dlsnote}[1]{%
  \begingroup%
  \newcommand{\content}{#1}%
  \ifnumberedpar@
    \ifledRcol%
      \xright@appenditem{\noexpand\vl@dlsnote{\expandonce\content}}%
                         \to\inserts@listR
      \global\advance\insert@countR \@ne%
    \else%
      \xright@appenditem{\noexpand\vl@dlsnote{\expandonce\content}}%
                         \to\inserts@list
      \global\advance\insert@count \@ne%
    \fi
  \fi%
  \ignorespaces%
  \endgroup%
}%

\newcommand*{\l@drsnote}[1]{%
  \begingroup%
  \newcommand{\content}{#1}%
  \ifnumberedpar@
    \ifledRcol%
      \xright@appenditem{\noexpand\vl@drsnote{\expandonce\content}}%
                         \to\inserts@listR
       \global\advance\insert@countR \@ne%
    \else%
      \xright@appenditem{\noexpand\vl@drsnote{\expandonce\content}}%
                         \to\inserts@list
      \global\advance\insert@count \@ne%
    \fi
  \fi\ignorespaces%
  \endgroup%
}%

\newcommand*{\l@dcsnote}[1]{%
  \begingroup%
  \newcommand{\content}{#1}%
  \ifnumberedpar@
    \ifledRcol%
      \xright@appenditem{\noexpand\vl@dcsnote{\expandonce\content}}%
                         \to\inserts@listR
       \global\advance\insert@countR \@ne%
    \else%
      \xright@appenditem{\noexpand\vl@dcsnote{\expandonce\content}}%
                         \to\inserts@list
      \global\advance\insert@count \@ne%
    \fi
  \fi\ignorespaces%
  \endgroup%
}%

\newcommand*{\l@disnote}[1]{%
  \begingroup%
  \newcommand{\content}{#1}%
  \ifnumberedpar@%
    \ifledRcol%
      \xright@appenditem{\noexpand\vl@disnote{\expandonce\content}}%
                         \to\inserts@listR%
       \global\advance\insert@countR \@ne%
    \else%
      \xright@appenditem{\noexpand\vl@disnote{\expandonce\content}}%
                         \to\inserts@list%
      \global\advance\insert@count \@ne%
    \fi%
  \fi\ignorespaces%
  \endgroup%
}%

\newcommand*{\l@dosnote}[1]{%
  \begingroup%
  \newcommand{\content}{#1}%
  \ifnumberedpar@%
    \ifledRcol%
      \xright@appenditem{\noexpand\vl@dosnote{\expandonce\content}}%
                         \to\inserts@listR%
       \global\advance\insert@countR \@ne%
    \else%
      \xright@appenditem{\noexpand\vl@dosnote{\expandonce\content}}%
                         \to\inserts@list%
      \global\advance\insert@count \@ne%
    \fi%
  \fi\ignorespaces%
  \endgroup%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\vl@dlsnote}
% \begin{macro}{\vl@drsnote}
% \begin{macro}{\vl@dcsnote}
% \begin{macro}{\vl@disnote}
% \begin{macro}{\vl@dosnote}
% Put the left/right text into boxes, but just save the moveable text.
% \protect\cs{l@dcsnotetext}, \protect\cs{l@dcsnotetext@l} and \protect\cs{l@dcsnotetext@r} are \protect\package{etoolbox}'s  lists which will store the content of sidenotes.
% We store the content in lists, because we need to loop later on them, in case many sidenote co-exist for the same line.
% That is there some special test to do, in order to:
% \begin{itemize}
%   \item Store the content of \protect\cs{ledsidenote} to \protect\cs{l@dcsnotetext} in any cases.
%   \item Store the content of \protect\cs{rightsidenote} to:
%        \begin{itemize}
%             \item \protect\cs{l@dcsnotetext} if \protect\cs{ledsidenote} is to be put on right.
%             \item \protect\cs{l@dcsnotetext@r} if \protect\cs{ledsidenote} is to be put on left.
%        \end{itemize}
%   \item Store the content of \protect\cs{leftsidenote} to:
%        \begin{itemize}
%             \item \protect\cs{l@dcsnotetext} if \protect\cs{ledsidenote} is to be put on left.
%             \item \protect\cs{l@dcsnotetext@l} if \protect\cs{ledsidenote} is to be put on right.
%        \end{itemize}
% \end{itemize}
% \cs{vl@disnote} and \cs{vl@dosnote} just call \cs{vl@dlsnote} or \cs{vl@drsnote}, depending of the page.
%    \begin{macrocode}
\newcommand*{\vl@dlsnote}[1]{%
  \ifledRcol@%
    \@l@dtempcntb=\sidenote@marginR%
    \ifnum\@l@dtempcntb>\@ne%
      \advance\@l@dtempcntb by\page@numR%
    \fi%
  \else%
    \@l@dtempcntb=\sidenote@margin%
    \ifnum\@l@dtempcntb>\@ne%
      \advance\@l@dtempcntb by\page@num%
    \fi%
  \fi%
  \ifodd\@l@dtempcntb%
    \listgadd{\l@dcsnotetext@l}{#1}%
  \else%
    \listgadd{\l@dcsnotetext}{#1}%
  \fi
}
\newcommand*{\vl@drsnote}[1]{%
  \ifledRcol@%
    \@l@dtempcntb=\sidenote@marginR%
    \ifnum\@l@dtempcntb>\@ne%
      \advance\@l@dtempcntb by\page@numR%
    \fi%
  \else%
    \@l@dtempcntb=\sidenote@margin%
    \ifnum\@l@dtempcntb>\@ne%
      \advance\@l@dtempcntb by\page@num%
    \fi%
  \fi%
  \ifodd\@l@dtempcntb%
    \listgadd{\l@dcsnotetext}{#1}%
  \else%
    \listgadd{\l@dcsnotetext@r}{#1}%
  \fi%
}
\newcommand*{\vl@dcsnote}[1]{\listgadd{\l@dcsnotetext}{#1}}

\newcommand{\vl@disnote}[1]{%
  \ifledRcol@%
    \@tempcnta=\page@numR%
  \else%
    \@tempcnta=\page@num%
  \fi%
  \ifodd\@tempcnta% ODD => right page => inner side =  left side
    \vl@dlsnote{#1}%
  \else%
    \vl@drsnote{#1}%
  \fi%
}%

\newcommand{\vl@dosnote}[1]{%
  \ifledRcol@%
    \@tempcnta=\page@numR%
  \else%
    \@tempcnta=\page@num%
  \fi%
  \ifodd\@tempcnta% ODD => right page => outer side = right side
    \vl@drsnote{#1}%
  \else%
    \vl@dlsnote{#1}%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\setl@dlp@rbox}
% \begin{macro}{\setl@drpr@box}
% \protect\cs{setl@dlprbox}\marg{lednums}\marg{tag}\marg{text} puts \meta{text}
% into the \protect\cs{l@dlp@rbox} box. And similarly for the right side box.
% It is these boxes that finally
% get displayed in the margins.
%    \begin{macrocode}
\newcommand*{\setl@dlp@rbox}[1]{%
   \begingroup%
     \parindent\z@\hsize=\ledlsnotewidth%
     \ledlsnotefontsetup%We kept it outside of the vbox, because can affect the ragging
     \global\setbox\l@dlp@rbox%
     \ifleftnoteup%
       =\vbox to\z@{{\ledlsnotefontsetup\vss #1}}%We put \ledlsnotefontsetup inside footnote because required for color command. Note the {} to keep setting local.
     \else%
       =\vbox to 0.70\baselineskip{{\ledlsnotefontsetup\strut#1\vss}}%
     \fi%
   \endgroup%
}

\newcommand*{\setl@drp@rbox}[1]{%
  \begingroup%
     \parindent\z@\hsize=\ledrsnotewidth%
     \ledrsnotefontsetup%We kept it outside of the vbox, because can affect the ragging
     \global\setbox\l@drp@rbox%
     \ifrightnoteup%
       =\vbox to\z@{{\ledrsnotefontsetup\vss#1}}%We put \ledrsnotefontsetup inside footnote because required for color command. Note the {} to keep setting local.
     \else%
       =\vbox to0.7\baselineskip{{\ledrsnotefontsetup\strut#1\vss}}%
     \fi%
  \endgroup%
}%
\newif\ifleftnoteup
  \leftnoteuptrue
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@sidenotesep}
% This macro is used to separate sidenotes of the same line.
%    \begin{macrocode}
\newcommand{\setsidenotesep}[1]{\gdef\@sidenotesep{#1}}
\newcommand{\@sidenotesep}{, }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\affixside@note}
% This macro puts any moveable sidenote text into the left or right sidenote
% box, depending on which margin it is meant to go in. It's a very much
% stripped down version of \protect\cs{affixline@num}.
%
% Before do it, we concatenate all moveable sidenotes of the line, using \protect\cs{@sidenotesep} as separator.
% It is the result that we put on the sidenote.
% \changes{v1.4.1}{2012/11/16}{Remove spurious spaces.}
%    \begin{macrocode}
\newcommand*{\affixside@note}{%
    \prepare@edindex@fornote{\the\page@num|\the\line@num|\the\subline@num|\the\page@num|\the\line@num|\the\subline@num|}%
    \def\sidenotecontent@{}%
    \numgdef{\itemcount@}{0}%
    \def\do##1{%
        \ifnumequal{\itemcount@}{0}%
            {%
            \appto\sidenotecontent@{##1}}% Not print not separator before the 1st note
            {\appto\sidenotecontent@{\@sidenotesep ##1}%
            }%
            \numgdef{\itemcount@}{\itemcount@+\@ne}%
    }%
    \dolistloop{\l@dcsnotetext}%
    \ifnumgreater{\itemcount@}{1}{\led@err@ManySidenotes}{}%
%    \end{macrocode}
% And we do the same for left and right notes (not movable).
% \begin{macrocode}
  \gdef\@templ@d{}%
  \gdef\@templ@n{\l@dcsnotetext\l@dcsnotetext@l\l@dcsnotetext@r}%
  \ifx\@templ@d\@templ@n \else%
    \if@twocolumn%
      \if@firstcolumn%
        \setl@dlp@rbox{##1}{\sidenotecontent@}%
      \else%
        \setl@drp@rbox{\sidenotecontent@}%
      \fi%
    \else%
      \@l@dtempcntb=\sidenote@margin%
      \ifnum\@l@dtempcntb>\@ne%
        \advance\@l@dtempcntb by\page@num%
      \fi%
      \ifodd\@l@dtempcntb%
        \setl@drp@rbox{\sidenotecontent@}%
        \gdef\sidenotecontent@{}%
        \numgdef{\itemcount@}{0}%
        \dolistloop{\l@dcsnotetext@l}%
        \ifnumgreater{\itemcount@}{1}{\led@err@ManyLeftnotes}{}%
        \setl@dlp@rbox{\sidenotecontent@}%
      \else%
        \setl@dlp@rbox{\sidenotecontent@}%
        \gdef\sidenotecontent@{}%
        \numgdef{\itemcount@}{0}%
        \dolistloop{\l@dcsnotetext@r}%
        \ifnumgreater{\itemcount@}{1}{\led@err@ManyRightnotes}{}%
        \setl@drp@rbox{\sidenotecontent@}%
      \fi%
    \fi%
  \fi%
  \advance\@edindex@fornote@\m@ne%
}
%    \end{macrocode}
% \end{macro}%
%
%
%
%
% \section{Minipages and such}
%
%    We can put footnotes into minipages. The preparatory code has
% been set up earlier, all that remains is to ensure that it is available
% inside a minipage box. This requires some alteration to the kernel code,
% specifically the \protect\cs{@iiiminipage} and \protect\cs{endminipage} macros.
% We will arrange this so that additional series can be easily added.
%
% \begin{macro}{\l@dfeetbeginmini}
% \begin{macro}{\l@dfeetendmini}
% \changes{v1.9.0}{2014/02/05}{Add \protect\cs{mpfnpos} to choice the order of footnotes in minipage / ledgroup.}
% These will be the hooks in \protect\cs{@iiiminpage} and \protect\cs{endminipage}.
%
% They can be extended to handle other things if necessary.
% \changes{v0.4.0}{2004/02/29}{Added \protect\cs{l@dfeetbeginmini}, \protect\cs{l@dfeetendmini}
%                           and all their supporting code}
%    \begin{macrocode}
\ifnoledgroup@\else%
\newcommand*{\l@dfeetbeginmini}{\@ledgrouptrue\l@dedbeginmini\l@dfambeginmini}
\newcommand*{\l@dfeetendmini}{%
    \IfStrEq{critical-familiar}{\@mpfnpos}%
        {\l@dedendmini\l@dfamendmini}%
        {%
            \IfStrEq{familiar-critical}{\@mpfnpos}%
                {\l@dfamendmini\l@dedendmini}%
                {\do@feet@custom@order{mp@}{\@mpfnpos}}%
        }%
    }%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dedbeginmini}
% \begin{macro}{\l@dedendmini}
% \begin{macro}{\mp@append@Xnotes}
% These handle the initiation and closure of critical footnotes in a
% minipage environment.
%    \begin{macrocode}
\newcommand*{\l@dedbeginmini}{%
  \unless\ifnocritical@%
    \def\do##1{%
      \csletcs{v##1footnote}{mpv##1footnote}%
    }%
    \dolistloop{\@series}%
  \fi%
  }
\newcommand*{\l@dedendmini}{%
  \unless\ifnocritical@%
    \ifl@dpairing%
      \ifledRcol%
        \flush@notesR%
      \else%
        \flush@notes%
      \fi%
    \fi
    \def\do##1{%
      \mp@append@Xnotes{##1}%
    }%
    \dolistloop{\@series}%
  \fi%
}%
\newcommand{\mp@append@Xnotes}[1]{%
\ifvoid\csuse{mp#1footins}\else%
  \ifl@dpairing%
    \ifparledgroup%
      \ifledRcol%
        \dimgdef{\parledgroup@beforenotesR}{\parledgroup@beforenotesR+\skip\@nameuse{mp#1footins}}%
      \else%
         \dimgdef{\parledgroup@beforenotesL}{\parledgroup@beforenotesL+\skip\@nameuse{mp#1footins}}%
      \fi%
     \fi%
   \fi%
  \ifcsstring{series@display#1}{paragraph}{}{%
    \setbox\@nameuse{mp#1footins}=\vbox{%
      \csuse{Xnotefontsize@#1}%
      \ifcsdef{Xhsize\csuse{series@display#1}@#1}{%
        \hsize\csuse{Xhsize\csuse{series@display#1}@#1}%
      }{}%
      \noindent\csuse{Xtxtbeforenotes@#1}%
      \unvbox\@nameuse{mp#1footins}%
      \@parboxrestore%
    }%
  }%
  \csuse{mp#1footgroup}{#1}%
\fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dfambeginmini}
% \begin{macro}{\l@dfamendmini}
% \begin{macro}{\mp@append@notesX}
% These handle the initiation and closure of familiar footnotes in a
% minipage environment.
%    \begin{macrocode}
\newcommand*{\l@dfambeginmini}{%
 \unless\ifnofamiliar@%
   \def\do##1{\csletcs{vfootnote##1}{mpvfootnote##1}}%
     \dolistloop{\@series}%
 \fi%
}%

\newcommand*{\l@dfamendmini}{%
 \unless\ifnofamiliar@%
   \def\do##1{%
     \mp@append@notesX{##1}%
   }%
   \dolistloop{\@series}%
 \fi%
}%
\newcommand{\mp@append@notesX}[1]{%
  \ifvoid\csuse{mpfootins#1}\else%
    \ifcsstring{series@displayX#1}{paragraph}{}{%
      \setbox\@nameuse{mpfootins#1}=\vbox{%
        \csuse{notefontsizeX@#1}%
        \ifcsdef{hsize\csuse{series@display#1}X@#1}{%
          \hsize\csuse{hsize\csuse{series@display#1}X@#1}%
        }{}%
        \noindent\csuse{txtbeforenotesX@#1}%
        \unvbox\@nameuse{mpfootins#1}%
        \@parboxrestore%
      }%
    }%
    \csuse{mpfootgroup#1}{#1}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@iiiminipage}
% This is our extended form of the kernel \protect\cs{@iiiminipage} defined in
% \file{ltboxes.dtx}.
% \changes{v0.4.0}{2004/02/29}{Modified kernel \protect\cs{@iiiminipage} and
%                          \protect\cs{endminipage} to cater for critical footnotes}
% \changes{v2.0.0}{2015/07/19}{Patch \protect\cs{@iiiminipage} instead of redefining it.}
%    \begin{macrocode}
\patchcmd%
  {\@iiiminipage}%
  {\let\@footnotetext\@mpfootnotetext}%
  {\let\@footnotetext\@mpfootnotetext\l@dfeetbeginmini}%
  {}%
  {\led@error@fail@patch@@iiiminipage}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endminipage}
% This is our extended form of the kernel \protect\cs{endminipage} defined in
% \file{ltboxes.dtx}.
% \changes{v2.0.0}{2015/07/19}{Patch \protect\cs{endminipage} instead of redefining it.}
%    \begin{macrocode}
\patchcmd%
  {\endminipage}%
  {\footnoterule}%
  {\footnoterule\l@advance@parledgroup@beforenormalnotes}%
  {}%
  {\led@error@fail@patch@endminipage}

\patchcmd%
  {\endminipage}%
  {\@minipagefalse}%
  {\l@dfeetendmini\@minipagefalse}%
  {}%
  {\led@error@fail@patch@endminipage}

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\l@dunboxmpfoot}%
% \begin{macro}{\l@advance@parledgroup@beforenormalnotes}%
% \changes{v0.7.0}{2005/02/18}{Added \protect\cs{l@dunboxmpfoot} containing
%              some common code}
% \changes{v2.0.0}{2015/07/19}{Some conde of \protect\cs{l@dumboxmpfoot} moved to \protect\cs{l@advance@parledegroup@beforenormalnotes}}
% \protect\cs{@ldunboxmpfoot} insert normal footnotes for ledgroup.
%    \begin{macrocode}
\newcommand*{\l@dunboxmpfoot}{%
    \vskip\skip\@mpfootins
    \normalcolor
    \footnoterule
    \l@advance@parledgroup@beforenormalnotes
    \unvbox\@mpfootins%
}
%    \end{macrocode}
% When using parallel ledgroup, we need to store the vertical space added before footnote, in order to compensate them between left and right pages.
%    \begin{macrocode}
\newcommand{\l@advance@parledgroup@beforenormalnotes}{%
  \ifparledgroup
    \ifl@dpairing
      \ifledRcol
          \dimgdef{\parledgroup@beforenotesR}{\parledgroup@beforenotesR+\skip\@mpfootins}
      \else
          \dimgdef{\parledgroup@beforenotesL}{\parledgroup@beforenotesL+\skip\@mpfootins}
      \fi
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{environment}{ledgroup}
% This environment puts footnotes at the end, even if that happens to
% be in the middle of a page, or crossing a page boundary. It is a sort
% of unboxed, fixed width minipage.
% \changes{v0.4.0}{2004/02/29}{Added ledgroup environment}
%    \begin{macrocode}

\newenvironment{ledgroup}{%
  \resetprevpage@num%
  \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@%
  \let\@footnotetext\@mpfootnotetext
  \l@dfeetbeginmini%
}{%
  \par
  \unskip
  \ifvoid\@mpfootins\else
    \l@dunboxmpfoot
  \fi
  \l@dfeetendmini%
  \@ledgroupfalse%
}


%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{ledgroupsized}
% \verb?\begin{ledgroupsized}?\oarg{pos}\marg{width} \\
% This environment puts footnotes at the end, even if that happens to
% be in the middle of a page, or crossing a page boundary. It is a sort
% of unboxed, variable \meta{width} minipage. The optional \meta{pos}
% controls the sideways position of numbered text.
% \changes{v0.4.0}{2004/02/29}{Added ledgroupsized environment}
% \changes{v0.5.1}{2004/04/10}{Only change \protect\cs{hsize} in ledgroupsized
%        environment otherwise page number can be in wrong place}
%    \begin{macrocode}
\newenvironment{ledgroupsized}[2][l]{%
%    \end{macrocode}
% Set the various text measures.
%    \begin{macrocode}
  \hsize #2\relax
%    \end{macrocode}
% Initialize fills for centering.
%    \begin{macrocode}
  \let\ledllfill\hfil
  \let\ledrlfill\hfil
  \def\@tempa{#1}\def\@tempb{l}%
%    \end{macrocode}
% Left adjusted numbered lines
%    \begin{macrocode}
      \ifx\@tempa\@tempb
    \let\ledllfill\relax
  \else
    \def\@tempb{r}%
    \ifx\@tempa\@tempb
%    \end{macrocode}
% Right adjusted numbered lines
%    \begin{macrocode}
      \let\ledrlfill\relax
    \fi
  \fi
%    \end{macrocode}
% Set up the footnoting.
%    \begin{macrocode}
  \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
  \let\@footnotetext\@mpfootnotetext
  \l@dfeetbeginmini%
}{%
  \par
  \unskip
  \ifvoid\@mpfootins\else
    \l@dunboxmpfoot
  \fi
  \l@dfeetendmini%
}

%    \end{macrocode}
% \end{environment}
%
% Close the \protect\cs{ifnoledgroup@}\protect\cs{else}.
%    \begin{macrocode}
\fi%
%    \end{macrocode}
% \begin{macro}{\ifledgroupnotesL@}
% \begin{macro}{\ifledgroupnotesR@}
% These boolean tests check if we are in the notes of a ledgroup.
% If we are, we do not number the lines.
% It could be useful for parallel ledgroup of \parpackage.
%
%    \begin{macrocode}
\newif\ifledgroupnotesL@
\newif\ifledgroupnotesR@
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Indexing}
% \changes{v1.5.0}{2013/07/11}{Correct indexing when the call is made in critical notes.}
% \changes{v1.8.0}{2014/07/21}{If \protect\package{imakeidx} and \protect\package{hyperref} are loaded, adds hyperref in the index.}
% \changes{v1.8.5}{2014/08/28}{Debug indexing in right column, with eledpar.}
% Here is some code for indexing using page and line numbers.
%
% \subsection{Looking on package order}
% First, ensure that \protect\package{imakeidx} or \protect\package{indextools} is loaded \emph{before} \protect\package{eledmac}.
% \changes{v1.12.0}{2014/08/05}{Ensure that \protect\package{imakeidx} is loaded \emph{before} \protect\package{eledmac}}
%    \begin{macrocode}
\AtBeginDocument{%
  \unless\ifl@imakeidx%
    \@ifpackageloaded{imakeidx}{\led@error@PackageAfterEledmac{imakeidx}}{}%
  \fi%
  \unless\ifl@indextools%
    \@ifpackageloaded{indextools}{\led@error@PackageAfterEledmac{indextools}}{}%
  \fi%
  \unless\ifl@footmisc%
    \@ifpackageloaded{footmisc}{\led@error@PackageAfterEledmac{footmisc}}{}%
  \fi%
}
%    \end{macrocode}
% \subsection{Auxiliary macros for \cs{edindex}}
% \begin{macro}{\pagelinesep}
% \begin{macro}{\edindexlab}
% \begin{macro}{\c@labidx}
% In order to get a correct line number we have to use the label/ref
% mechanism. These macros are for that.
%    \begin{macrocode}
\newcommand{\pagelinesep}{-}
\newcommand{\edindexlab}{$&}
\newcounter{labidx}
\setcounter{labidx}{0}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\doedindexlabel}
% This macro sets an \protect\cs{edlabel}.
%    \begin{macrocode}
\newcommand{\doedindexlabel}{%
  \stepcounter{labidx}%
  \edlabel{\edindexlab\thelabidx}%
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thepageline}
% This macro makes up the page/line number combo from the label/ref.
% The associated counter is never directly used, but it is required in order to not have any error message with \cs{edgls}.
%    \begin{macrocode}
\newcounter{pageline}%
\renewcommand{\thepageline}{%
  \thepage%
  \pagelinesep%
  \xlineref{\edindexlab\thelabidx}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thestartpageline}
% \begin{macro}{\theendpageline}
% These macros make up the page/line start/end number when the \protect\cs{edindex} command is called in critical notes.
%    \begin{macrocode}
\newcommand{\thestartpageline}{%
  \l@dparsedstartpage%
  \pagelinesep%
  \l@dparsedstartline%
}
\newcommand{\theendpageline}{%
  \l@dparsedendpage%
  \pagelinesep%
  \l@dparsedendline%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Code specific to \cs{edindex} in critical footnotes}
% \begin{macro}{\@edindex@fornote@}
% This counter is incremented at the beginning of each note (either a footnote or a sidenote), and decremented at the end of each note.
% If its value is greater than 0, that means we are inside a note.
%    \begin{macrocode}
\newcount\@edindex@fornote@
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\prepare@edindex@fornote}
% This macro is called at the beginning of each critical note.
% It switches some parameters,
% to allow index referring to this note, with reference to page and line number.
% It also defines \protect\cs{@ledinnote@command} which will be printed as an encapsulating command after the \verb+|+.
%    \begin{macrocode}
\newcommand{\prepare@edindex@fornote}[1]{%
    \l@dp@rsefootspec#1|%
    \advance\@edindex@fornote@\@ne%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\get@edindex@ledinnote@command}
% The \protect\cs{get@edindex@ledinnote@command} macro defines
% a \protect\cs{@ledinnote@command} command which is added as an attribute (text inserted after \verb+|+) of the next index entry.
%
% Consequently, we write the definition of the location reference attribute in the \verb+.xdy+ file.
%    \begin{macrocode}
\newcommand{\get@edindex@ledinnote@command}{%
  \ifxindy@%
    \gdef\@ledinnote@command{%
      ledinnote\thelabidx%
    }%
    \ifxindyhyperref@%
      \immediate\write\eledmac@xindy@out{%
        (define-attributes ("ledinnote\thelabidx"))^^J
        \space\space(markup-locref^^J
          \eledmacmarkuplocrefdepth^^J
          :open "\string\ledinnote[\edindexlab\thelabidx]{\@index@command}{\@currentseries}{\@currentnotetype}{"^^J
          :close "}"^^J
          :attr "ledinnote\thelabidx"^^J
          )
        }%
    \else%
      \immediate\write\eledmac@xindy@out{%
        (define-attributes ("ledinnote\thelabidx"))^^J
        \space\space(markup-locref^^J
          \eledmacmarkuplocrefdepth^^J
          :open "\string\ledinnote{\@index@command}{\@currentseries}{\@currentnotetype}{"^^J
          :close "}"^^J
          :attr "ledinnote\thelabidx"^^J
          )
        }%
    \fi%
%    \end{macrocode}
% If we do not use \verb+xindy+ option, \protect\cs{@ledinnote@command} will produce
% something like \verb+ledinnote{formattingcommand}+.
%    \begin{macrocode}
  \else%
    \gdef\@ledinnote@command{%
      ledinnote[\edindexlab\thelabidx]{\@index@command}{\@currentseries}{\@currentnotetype}%
    }%
  \fi%
}
%    \end{macrocode}
% \end{macro}
% \subsection{Analysis of command in indexed text}
% \begin{macro}{\get@index@command}
% This macro is used to analyze if a text to be indexed has a command after a \verb+|+.
% \changes{v1.8.0}{2014/07/21}{Debug \protect\cs{get@index@command} and compatibility with \protect\package{hyperref} package.}
%    \begin{macrocode}
\def\get@index@command#1|#2+{%
  \gdef\@index@txt{#1}%
  \gdef\@index@command{#2}%
  \xdef\@index@parenthesis{}%
  \IfBeginWith{\@index@command}{(}{%
    \StrGobbleLeft{\@index@command}{1}[\@index@command@]%
    \global\let\@index@command\@index@command@%
    \xdef\@index@parenthesis{(}%
    }{}%
  \IfBeginWith{\@index@command}{)}{%
    \StrGobbleLeft{\@index@command}{1}[\@index@command@]%
    \global\let\@index@command\@index@command@%
    \xdef\@index@parenthesis{)}%
    }{}%
}
%    \end{macrocode}
% \end{macro}
% \subsection{Code for the formatted index}
% \begin{macro}{\ledinnote}
% \changes{v1.22.0}{2015/04/25}{\protect\cs{ledinnote} takes a first optional argument, which is the label for hyperlinks.}
% \begin{macro}{\ledinnotemark}
% \changes{v1.21.0}{2015/04/13}{Add \protect\cs{ledinnotemark}.}
% \changes{v2.33.0}{2020/05/31}{\protect\cs{ledinnotemark} redefinition is deprecated, use \protect\cs{Xinnotemark} and \protect\cs{innotemarkX} instead.}
% These macros are used to specify that an index reference points to a note.
% Arguments of \protect\cs{ledinnote}  are:
% \begin{itemize}
% \item \verb+#1+ (optional): the label for the hyperlink;
% \item \verb+#2+: command applied to the number;
% \item \verb+#3+: the note series;
% \item \verb+#4+: the type of note (critical/familiar).
% \item \verb+#5+: the number itself.
% \end{itemize}
%    \begin{macrocode}
\newcommandx{\ledinnote}[5][1,usedefault]{%
  \IfStrEq{#4}{critical}{%
    \def\tmp{Xinnotemark}%
  }{%
    \def\tmp{innotemarkX}%
  }%
  \ifboolexpr{%
    test{\ifdefequal{\iftrue}{\ifHy@hyperindex}}%
    or%
    bool {xindyhyperref@}%
    }%
    {%
      \csuse{#2}{\hyperlink{#1}{\csuse{\tmp @#3}{#5}}}%
    }%
    {%
    \csuse{#2}{\csuse{\tmp @#3}{#5}}%
    }%
}%
\newcommand{\ledinnotemark}[1]{#1\emph{n}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Main code}
% \changes{v2.0.0}{2015/07/19}{Suppress indexing command specific to \protect\ltxclass{memoir}.}
% \Eledmac and \ledmac were using the specific indexing tools of the \protect\ltxclass{memoir} in order to allow multiple index.
% However, \eledmac used \protect\package{imakeidx} or \protect\package{indextools}  tools when one these two package was loaded.
% This system forced to maintained a double code, which was not very useful.
% Since \reledmac, we use only the \protect\package{imakeidx} or \protect\package{indextools}  tools.
%
%    The \protect\package{memoir} class provides more flexible indexing than the
% standard classes. We need different code if the \protect\package{memoir}
% class is being used, except if \protect\package{imakeidx} or \protect\package{indextools} is used.
% \begin{macro}{\edindex}
% \changes{v0.4.1}{2003/03/29}{Let eledmac take advantage of memoir's indexing}
% \changes{v1.5.0}{2013/07/11}{Compatibility with \protect\package{imakeidx} package, and possibility to use multiple index with \protect\cs{edindex}.}
% \changes{v1.12.0}{2014/08/05}{Use correctly default index when \protect\package{imakeidx} is loaded.}
% \changes{v1.14.0}{2014/10/27}{Let eledmac take advantage of imakeidx even when memoir class is used}
% \begin{macro}{\@wredindex}
% \begin{macro}{\dummy@edindex}
% Write the index information to the \file{idx} file.
%    \begin{macrocode}
\newcommandx{\@wredindex}[2][1=\expandonce\jobname,usedefault]{%#1 = the index name, #2 = the text
  \begingroup%
    \let\emph\@firstofone%
    \let\textbf\@firstofone%
    \let\textit\@firstofone%
    \let\textmd\@firstofone%
    \let\textnormal\@firstofone%
    \let\textrm\@firstofone%
    \let\textsc\@firstofone%
    \let\textsf\@firstofone%
    \let\textsl\@firstofone%
    \let\texttt\@firstofone%
    \let\textup\@firstofone%
    \xdef\@tmp{#2}%To be used in IfSubStr instead of #2 directly. Avoid some expansion bugs (for example with \edindex{textsc{something}})
  \endgroup%
  \ifl@imakeidx%
    \ifnum\@edindex@fornote@>\z@%
      \IfSubStr[1]{\@tmp}{|}{\get@index@command#2+}{\get@index@command#2|+}%
      \get@edindex@ledinnote@command%
      \expandafter\imki@wrindexentry{#1}{\@index@txt|(\@ledinnote@command}{\thestartpageline}%
      \expandafter\imki@wrindexentry{#1}{\@index@txt|)\@ledinnote@command}{\theendpageline}%
    \else%
      \get@edindex@hyperref{#2}%
      \imki@wrindexentry{#1}{\@index@txt\@edindex@hyperref}{\thepageline}%
    \fi%
  \else%
    \ifnum\@edindex@fornote@>\z@%
      \IfSubStr[1]{\@tmp}{|}{\get@index@command#2+}{\get@index@command#2|+}%
      \get@edindex@ledinnote@command%
      \expandafter\protected@write\@indexfile{}%
  {\string\indexentry{\@index@txt|(\@ledinnote@command}{\thestartpageline}
  }%
      \expandafter\protected@write\@indexfile{}%
  {\string\indexentry{\@index@txt|)\@ledinnote@command}{\theendpageline}
       }%
    \else%
      \protected@write\@indexfile{}%
  {\string\indexentry{#2}{\thepageline}
  }%
    \fi%
   \fi%
   \endgroup
   \@esphack%
}
%    \end{macrocode}
% Need to add the definition of \protect\cs{edindex} to \protect\cs{makeindex}, and initialise
% \protect\cs{edindex} to do nothing.
%    \begin{macrocode}
\pretocmd{\makeindex}{%
  \def\edindex{%
    \ifboolexpr{bool{numbering} or bool{numberingR} or bool{l@dprintingpages} or bool{l@dprintingcolumns}}{%
      \@bsphack%
      \doedindexlabel%
      \begingroup%
      \@sanitize%
      \@wredindex%
    }%
    {%
      \led@warn@edinde@outsidenumbering%
      \index%
    }%
  }%
}%
{}%
{\led@error@fail@patch@makeindex}%
\newcommand{\edindex}[1]{\@bsphack\@esphack}
\newcommandx{\dummy@edindex}[2][1=\expandonce\jobname,usedefault]{}%
\newcommand{\disable@edindex}{\let\old@edindex\edindex\let\edindex\dummy@edindex}%
\newcommand{\restore@edindex}{\let\edindex\old@edindex}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Hyperlink}
% \begin{macro}{\hyperlinkformat}
% \protect\cs{hyperlinkformat} command is to be used to have both a internal hyperlink and a format, when indexing.
%    \begin{macrocode}
\newcommand{\hyperlinkformat}[3]{%
  \ifstrempty{#1}%
    {\hyperlink{#2}{#3}}%
    {\csuse{#1}{\hyperlink{#2}{#3}}%
  }}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\hyperlinkR}
% \protect\cs{hyperlinkR} command is to be used to create a internal hyperlink and \protect\cs{ledRflag}, when indexing.
%    \begin{macrocode}
\newcommand{\hyperlinkR}[2]{%
 \hyperlink{#1}{#2\@Rlineflag}%
}%

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\hyperlinkformatR}
% \protect\cs{hyperlinkformatR} command is to be used to create a internal hyperlink, a format and a \protect\cs{@Rlineflag}, when indexing.
%    \begin{macrocode}
\newcommand{\hyperlinkformatR}[3]{%
  \hyperlinkformat{#1}{#2}{#3\@Rlineflag}%
}%

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\get@edindex@hyperref}
% \begin{macro}{\@edindex@hyperref}
% \changes{v1.12.5}{2014/08/28}{Debug \protect\cs{edindex} when \protect\package{hyperref} is not loaded}
% \protect\cs{get@edindex@hyperref} is to be used to define the \protect\cs{@edindex@hyperref} macro, which, in index, links to the point where the index was called (with \protect\package{hyperref}.
% \changes{v1.18.0}{2014/08/21}{Fix spurious space with \protect\cs{edindex} when using \protect\package{imakeidx}/\protect\package{indextools} + hyperref.}
% \changes{v1.21.0}{2015/0}{Look at the hyperindex option of hyperref before inserting hyperref}
%    \begin{macrocode}
\newcommand{\get@edindex@hyperref}[1]{%
%    \end{macrocode}
% We have to disable temporary spaces to work through a \protect\package{xstring} bug (or feature?)
%    \begin{macrocode}
  \edef\temp@{%
  \catcode`\ =9 %space need for catcode
  \detokenize{#1}%For active character in unicode
  \catcode`\ =10 % space need for catcode
  }%
%    \end{macrocode}
% Now, we define \protect\cs{@edindex@hyperref} if the \verb+hyperindex+ of \protect\package{hyperref} is enabled.
%    \begin{macrocode}
  \ifdefequal{\iftrue}{\ifHy@hyperindex}{%
    \IfSubStr{\temp@}{|}%
      {\get@index@command#1+%
      \ifledRcol%
        \gdef\@edindex@hyperref{|\@index@parenthesis %space kept
        hyperlinkformatR{\@index@command}%
        {\edindexlab\thelabidx}}%
      \else%
        \gdef\@edindex@hyperref{|\@index@parenthesis %space kept
        hyperlinkformat{\@index@command}%
        {\edindexlab\thelabidx}}%
      \fi%
      }%
      {\get@index@command#1|+%
       \ifledRcol%
        \gdef\@edindex@hyperref{|hyperlinkR{\edindexlab\thelabidx}}%
       \else%
        \gdef\@edindex@hyperref{|hyperlink{\edindexlab\thelabidx}}%
       \fi%
      }%
    }%
%    \end{macrocode}
%    \begin{macrocode}
% If we use both xindy and hyperref, first get the \protect\cs{index@command} command.
% Then define \protect\cs{@edindex@hyperref} in the form \verb+eledmacXXX+
%    \begin{macrocode}
    {\ifxindyhyperref@%
      \IfSubStr{\temp@}{|}%
        {\get@index@command#1+}%
        {\get@index@command#1|+}%
     \gdef\@edindex@hyperref{|eledmac\thelabidx}%
%    \end{macrocode}
% If we start a reference range by a opening parenthesis,
% store the \protect\cs{thelabidx} for the current \protect\cs{edindex}, then define \protect\cs{@edindex@hyperref} in the form \verb+|(eledmac\thelabidx+.
%    \begin{macrocode}
      \IfStrEq{\@index@parenthesis}{(}%
        {%
        \csxdef{xindyparenthesis@\@index@txt}{\thelabidx}%
        \gdef\@edindex@hyperref{|(eledmac\thelabidx}%
        }%
        {}%
%    \end{macrocode}
% This \protect\cs{thelabidx} will be called back at the closing parenthesis, to have the same number in
% \protect\cs{@edindex@hyperref} command that we had at the opening parenthesis.
% \protect\cs{@edindex@hyperref} start by a closing parenthesis, then followed by \verb+eledmacXXX+ where \verb+XXX+ is the \protect\cs{thelabidx} of the opening \protect\cs{edindex}.
%    \begin{macrocode}
      \IfStrEq{\@index@parenthesis}{)}%
        {%
        \xdef\@edindex@hyperref{|)eledmac\csuse{xindyparenthesis@\@index@txt}}%
        \global\csundef{xindyparenthesis@\@index@txt}%
        }%
%    \end{macrocode}
% Write in the .xdy file the attributes of the location.
%    \begin{macrocode}
        {%
        \immediate\write\eledmac@xindy@out{%
          (define-attributes ("eledmac\thelabidx"))^^J
          \space\space(markup-locref^^J
            \eledmacmarkuplocrefdepth^^J
            :open "\string\hyperlink%
                   \ifledRcol R\fi%
                   {\edindexlab\thelabidx}%
                   {\ifdefempty{\@index@command}%
                     {}%
                     {\@backslashchar\@index@command}%
                   {"^^J
            :close "}}"^^J
            :attr "eledmac\thelabidx"^^J
            )
          }%
        }%
%    \end{macrocode}
% And now, in any other case.
%    \begin{macrocode}
    \else%
      \gdef\@index@txt{#1}%
      \gdef\@edindex@hyperref{}%
    \fi%
    }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \changes{v1.14.0}{2014/10/27}{Delete previous override of \protect\cs{l@d@@wrindexhyp} at the beginning of a document when hyperref is not loaded.}
%
% \subsection{`innote' and `notenumber' option of \package{indextols} package}
% \begin{macro}{\led@set@index@fornote}
% The \cs{led@set@index@fornote} is called when a familiar footnote is inserted --- and not when it is read --- and changes the \cs{index} command depending of the option of the \package{indextools} package.
% Its only argument is the note series.
%    \begin{macrocode}
\newcommand{\led@set@index@fornote}[1]{%
  \ifbool{indtl@innote}%
    {\let\index\nindex}%
    {}%
  \ifbool{indtl@notenumber}%
    {%
    \renewcommand{\index}[2][\indtl@jobname]{%
      \orig@@index[##1]{%
        ##2|innotenumber{\this@footnoteX@reading}%
        }%
      }%
    }%
    {}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@reinit@index@fornote}
% The \cs{led@reinit@index@fornote} just reset the default value of \cs{index}.
%    \begin{macrocode}
\newcommand{\led@reinit@index@fornote}{%
  \ifbool{indtl@innote}%
    {\let\index\orig@@index}%
    {}%
 \ifbool{indtl@notenumber}%
  {\let\index\orig@@index}%
  {}%
}%
%    \end{macrocode}
% \end{macro}
% \section{Glossaries}
% Here, we define the \cs{gls}-like commands prefixed by \verb+ed+, only if the package \package{glossaries} is loaded.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{glossaries}{%
%    \end{macrocode}
% First those which arguments are \oarg{options}\marg{label}\oarg{insert}.
%    \begin{macrocode}
    \gdef\edglsomo{}%
    \listgadd{\edglsomo}{gls}%
    \listgadd{\edglsomo}{Gls}%
    \listgadd{\edglsomo}{GLS}%
    \listgadd{\edglsomo}{glspl}%
    \listgadd{\edglsomo}{Glspl}%
    \listgadd{\edglsomo}{GLSpl}%
    \listgadd{\edglsomo}{glstext}%
    \listgadd{\edglsomo}{Glstext}%
    \listgadd{\edglsomo}{GLStext}%
    \listgadd{\edglsomo}{Glsfirst}%
    \listgadd{\edglsomo}{GLSfirst}%
    \listgadd{\edglsomo}{glsplural}%
    \listgadd{\edglsomo}{Glsplural}%
    \listgadd{\edglsomo}{GLSplural}%
    \listgadd{\edglsomo}{glsfirstplural}%
    \listgadd{\edglsomo}{Glsfirstplural}%
    \listgadd{\edglsomo}{GLSfirstplural}%
    \listgadd{\edglsomo}{glsname}%
    \listgadd{\edglsomo}{Glsname}%
    \listgadd{\edglsomo}{GLSname}%
    \listgadd{\edglsomo}{glssymbol}%
    \listgadd{\edglsomo}{Glssymbol}%
    \listgadd{\edglsomo}{GLSsymbol}%
    \listgadd{\edglsomo}{glsdesc}%
    \listgadd{\edglsomo}{Glsdesc}%
    \listgadd{\edglsomo}{GLSdesc}%
    \listgadd{\edglsomo}{glsuseri}%
    \listgadd{\edglsomo}{Glsuseri}%
    \listgadd{\edglsomo}{GLSuseri}%
    \listgadd{\edglsomo}{glsuserii}%
    \listgadd{\edglsomo}{Glsuserii}%
    \listgadd{\edglsomo}{GLSuserii}%
    \listgadd{\edglsomo}{glsuseriii}%
    \listgadd{\edglsomo}{Glsuseriii}%
    \listgadd{\edglsomo}{GLSuseriii}%
    \listgadd{\edglsomo}{glsuseriv}%
    \listgadd{\edglsomo}{Glsuseriv}%
    \listgadd{\edglsomo}{GLSuseriv}%
    \listgadd{\edglsomo}{glsuserv}%
    \listgadd{\edglsomo}{Glsuserv}%
    \listgadd{\edglsomo}{GLSuserv}%
    \listgadd{\edglsomo}{glsuservi}%
    \listgadd{\edglsomo}{Glsuservi}%
    \listgadd{\edglsomo}{GLSuservi}%
    \renewcommand{\do}[1]{%
      \expandafter\DeclareRobustCommandx\csname ed#1\endcsname[3][1,3,usedefault]{%
        \doedindexlabel%
        \ifdef{\hypertarget}{%
          \Hy@raisedlink@left{\hypertarget{pageline.\thepageline}{}}%
        }{}%
        \csname#1\endcsname[counter=pageline,##1]{##2}[##3]%
      }%
      \expandafter\WithSuffix\expandafter\DeclareRobustCommandx\csname ed#1\endcsname*[3][1,3,usedefault]{%
        \doedindexlabel%
        \ifdef{\hypertarget}{%
          \Hy@raisedlink@left{\hypertarget{pageline.\thepageline}{}}%
        }{}%
        \csname#1\endcsname*[counter=pageline,##1]{##2}[##3]%
      }%
    }%
    \dolistloop{\edglsomo}%
%    \end{macrocode}
% Then those which arguments are \oarg{options}\marg{label}\marg{link text}.
%    \begin{macrocode}
    \gdef\edglsomm{}%
    \listgadd\edglsomm{glsdisp}%
    \listgadd\edglsomm{glslink}%
    \renewcommand{\do}[1]{%
      \expandafter\DeclareRobustCommandx\csname ed#1\endcsname[3][1,usedefault]{%
        \doedindexlabel%
        \ifdef{\hypertarget}{%
          \Hy@raisedlink@left{\hypertarget{pageline.\thepageline}{}}%
        }{}%
        \csname#1\endcsname[counter=pageline,##1]{##2}{##3}%
      }%
      \expandafter\WithSuffix\expandafter\DeclareRobustCommandx\csname ed#1\endcsname*[3][1,usedefault]{%
        \doedindexlabel%
        \ifdef{\hypertarget}{%
          \Hy@raisedlink@left{\hypertarget{pageline.\thepageline}{}}%
        }{}%
        \csname#1\endcsname*[counter=pageline,##1]{##2}{##3}%
      }%
    }%
    \dolistloop{\edglsomm}%
%    \end{macrocode}
% Then those which arguments are \oarg{options}\marg{label}.
%    \begin{macrocode}
    \gdef\edglsom{}%
    \listgadd\edglsom{glsadd}%
    \renewcommand{\do}[1]{%
      \expandafter\DeclareRobustCommandx\csname ed#1\endcsname[2][1,usedefault]{%
        \doedindexlabel%
        \ifdef{\hypertarget}{%
          \Hy@raisedlink@left{\hypertarget{pageline.\thepageline}{}}%
        }{}%
        \csname#1\endcsname[counter=pageline,##1]{##2}%
      }%
      \expandafter\WithSuffix\expandafter\DeclareRobustCommandx\csname ed#1\endcsname*[2][1,usedefault]{%
        \doedindexlabel%
        \ifdef{\hypertarget}{%
          \Hy@raisedlink@left{\hypertarget{pageline.\thepageline}{}}%
        }{}%
        \csname#1\endcsname*[counter=pageline,##1]{##2}%
      }%
    }%
    \dolistloop{\edglsom}%
%    \end{macrocode}
% \cs{l@noexpands@edgl} is a macro to avoid expanding glossaries macros in \cs{edtext} first argument. It is called by \cs{no@expands}.
% Its definition is made dynamically.
% \begin{macro}{\l@noexpands@edgl}
%    \begin{macrocode}
    \def\l@noexpands@edgl{}%
    \renewcommand\do[1]{%
      \xappto\l@noexpands@edgl{%
        \noexpand\RenewDocumentCommand\csname ed#1\endcsname{omos}{}%
      }%
    }%
    \dolistloop{\edglsomo}%
    \renewcommand\do[1]{%
      \xappto\l@noexpands@edgl{%
        \noexpand\RenewDocumentCommand\csname ed#1\endcsname{omms}{}%
      }%
    }%
    \dolistloop{\edglsomm}%
    \renewcommand\do[1]{%
      \xappto\l@noexpands@edgl{%
        \noexpand\RenewDocumentCommand\csname ed#1\endcsname{oms}{}%
      }%
    }%
    \dolistloop{\edglsom}%
  }{\let\l@noexpands@edgl\relax}%
}%
%    \end{macrocode}
% \end{macro}
% \section{Verse}
%
% The original code is principally Wayne Sullivan's\index{Sullivan, Wayne}
% code from \edstanza.
% However, the code has been many time modified by Maïeul Rouquette in order to obtain new features and improved compatibility with \parpackage.
%
% \subsection{Hanging symbol management}
%
% \begin{macro}{\@hangingsymbol}
% \begin{macro}{\sethangingsymbol}
% \begin{macro}{\ifinstanza}
% The macro \protect\cs{@hangingsymbol} is used to insert a symbol on each hanging of verses. It is set by user level macro \protect\cs{sethangingsymbol}.
%
% For example, in French typography, the symbol is `['. We obtain it by means of the following code:
%\begin{verbatim}
%\sethangingsymbol{[\,}
%\end{verbatim}
% The \protect\cs{ifinstanza} boolean is used to ensure that we are in a stanza part.
%    \begin{macrocode}
\def\@hangingsymbol{}
\newcommand*{\sethangingsymbol}[1]{%
  \gdef\@hangingsymbol{#1}%
}%
\newif\ifinstanza
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\inserthangingymbol}
% \begin{macro}{\ifinserthangingsymbol}
% The boolean \protect\cs{ifinserthangingsymbol} is set to TRUE when \protect\cs{@lock} is greater than 1, i.e. when we are not in the first line of a verse. The switch of \protect\cs{ifinserthangingsymbol} is  made in \protect\cs{do@line} before the printing of line but after the line number calculation.
%\changes{v0.15.0}{2012/06/11}{New management of hangingsymbol insertion, preventing undesirable insertions.}
%\changes{v0.17.0}{2012/08/03}{New new management of hangingsymbol insertion, preventing undesirable insertions.}
% \changes{v1.6.1}{2013/10/27}{Hang verse is now not automatically flush right.}
%    \begin{macrocode}
\newif\ifinserthangingsymbol
\newcommand{\inserthangingsymbol}{%
\ifinserthangingsymbol%
   \ifinstanza%
      \@hangingsymbol%
   \fi%
\fi%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Using \& character}
% \begin{macro}{\ampersand}
% Within a stanza the \verb?\&? macro is going to be usurped.
% We need an
% alias in case an \& needs to be typeset in a stanza. Define it rather
% than letting it in case some other package has already defined it.
%    \begin{macrocode}
\newcommand*{\ampersand}{\char`\&}

%    \end{macrocode}
% \end{macro}
%
% \subsection{Code category setting}
% \begin{macro}{\stanza@count}
% \begin{macro}{\stanzaindentbase}
% Before we can define the main macros we need to save and reset
% some category codes. To save the current values we use
% \protect\cs{next} and \protect\cs{body} from the \protect\cs{loop} macro.
%    \begin{macrocode}
  \chardef\body=\catcode`\@
  \catcode`\@=11
  \chardef\next=\catcode`\&
  \catcode`\&=\active

%    \end{macrocode}
% \subsection{Stanza count and indent}
% A count register is allocated for counting lines in a stanza; also allocated
% is a dimension register which is used to specify the base value for
% line indentation; all stanza indentations are multiples of this
% value. The default value of \protect\cs{stanzaindentbase} is 20pt.
%    \begin{macrocode}
  \newcount\stanza@count
  \newlength{\stanzaindentbase}
  \setlength{\stanzaindentbase}{20pt}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\strip@szacnt}
% \begin{macro}{\setstanzavalues}
% The indentations of stanza lines are non-negative integer multiples of the
% unit called
% \protect\cs{stanzaindentbase}. To make it easier for the user to specify these
% numbers, some list macros are defined. These take numerical values
% in a list separated by commas and assign the values to special control
% sequences using \protect\cs{mathchardef}. Though this does limit the range
% from 0 to 32767, it should suffice for most applications,
% including \emph{penalties}, which will be discussed below.
%    \begin{macrocode}
\def\strip@szacnt#1,#2|{\def\@tempb{#1}\def\@tempa{#2|}}
\newcommand*{\setstanzavalues}[2]{\def\@tempa{#2,,|}%
        \stanza@count\z@
     \def\next{\expandafter\strip@szacnt\@tempa
            \ifx\@tempb\empty\let\next\relax\else
            \expandafter\mathchardef\csname #1@\number\stanza@count
            @\endcsname\@tempb\relax
            \advance\stanza@count\@ne\fi\next}%
      \next}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\setstanzaindents}
% \begin{macro}{\setstanzapenalties}
% In the original \edmac, \protect\cs{setstanzavalues}\verb+{sza}+\marg{...} had to be called to
% set the indents, and similarly \protect\cs{setstanzavalues}\verb+{szp}+\marg{...}.
% to set the penalties.
% \protect\cs{setstanzaindents} and \protect\cs{setstanzapenalties} macros are a convenience to give
% the user one less thing to worry about (misspelling the first argument).
%
%    \begin{macrocode}
\newcommand*{\setstanzaindents}[1]{\setstanzavalues{sza}{#1}}
\newcommand*{\setstanzapenalties}[1]{\setstanzavalues{szp}{#1}}
%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\managestanza@modulo}
% Since the \verb+stanzaindentsrepetition+ counter  can be used when the indentation is repeated every $n$ verses.
%
% The \verb+startstanzaindentsrepetition+ counter tells in which line of verse the repetition of indent starts.
%
% The \protect\cs{managestanza@modulo} macro modifies the counter stanza@modulo. The command adds 1 to stanza@modulo, but if stanza@modulo is equal to the stanzaindentsrepetition counter, the command restarts it.
%\changes{v0.13.0}{2011/11/08}{New stanzaindentsrepetition counter to repeat stanza indents every \emph{n} verses.}
% % \changes{v1.5.1}{2013/08/16}{Correct stanzaindentsrepetition counter}
%    \begin{macrocode}
\newcounter{stanzaindentsrepetition}
\newcounter{startstanzaindentsrepetition}%
\setcounter{startstanzaindentsrepetition}{1}%
\newcount\stanza@modulo

\newcommand*{\managestanza@modulo}[0]{%
    \advance\stanza@modulo\@ne%
    \ifnum\stanza@modulo>\value{stanzaindentsrepetition}%
     \stanza@modulo\@ne%
    \fi%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\stanzaindent}
% \begin{macro}{\stanzaindent*}
% The macro \protect\cs{stanzaindent}, when called at the beginning of a verse, changes the indentation normally defined for this verse by \protect\cs{setstanzaindent}.
% The starred version skips the current verse for the repetition of stanza indent.
%    \begin{macrocode}
\newcommand{\stanzaindent}[1]{%
  \hspace{\dimexpr#1\stanzaindentbase-\parindent\relax}%
  \ignorespaces%
}%
\WithSuffix\newcommand\stanzaindent*[1]{%
  \stanzaindent{#1}%
  \global\advance\stanza@modulo-\@ne%
  \ifnum\stanza@modulo=0%
    \global\stanza@modulo=\value{stanzaindentsrepetition}%
  \fi%
  \ignorespaces%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Numbering stanza}
% Here, macro for numbering stanza.
% First, the stanza counter.
% \begin{macro}{\thestanza}
%    \begin{macrocode}
\newcounter{stanza}
\renewcommand{\thestanza}{%
  \textbf{\arabic{stanza}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ifnumberstanza}
% Then, macro to activate automatically numbering of stanza.
%    \begin{macrocode}
\newif\ifnumberstanza%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@insertstanzanumber}
% Now, macro called at the first line of of verse of a stanza.
%    \begin{macrocode}
\newcommand{\@insertstanzanumber}[0]{%
  \ifnumberstanza%
    \ifl@dpairing%
      \ifledRcol%
      \stanzanumwrapper{\thestanzaR}%
      \else%
      \stanzanumwrapper{\thestanzaL}%
      \fi%
    \else%
      \stanzanumwrapper{\thestanza}%
    \fi%
    \setline{1}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@advancestanzanumber}
% Also a command to advance the counter of stanza.
%    \begin{macrocode}
\newcommand{\@advancestanzanumber}[0]{%
  \ifnumberstanza%
    \ifl@dpairing%
      \ifledRcol%
        \addtocounter{stanzaR}{1}%
      \else%
        \addtocounter{stanzaL}{1}%
      \fi%
    \else%
      \addtocounter{stanza}{1}%
    \fi%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\stanzanumwrapper}
% And finally, the wrapper for stanza number
%    \begin{macrocode}
\newcommand{\stanzanumwrapper}[1]{%
  \flagstanza{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Stanza number in note}
% Here, the command called when printing stanza number in notes.
%    \begin{macrocode}
\newcommand{\printstanza}[0]{%
   \ifboolexpr{bool{l@dpairing} or bool{l@dprintingpages} or bool{l@dprintingcolumns}}{%
        \ifledRcol@%
            \thestanzaR%
        \else%
            \thestanzaL%
        \fi%
    }{%
        \thestanza%
    }%
}
%    \end{macrocode}
% \subsection{Main work}
% \begin{macro}{\stanza@line}
% \begin{macro}{\stanza@hang}
% \begin{macro}{\stanza@indent}
% \begin{macro}{\sza@penalty}
% Now we arrive at the main works. \protect\cs{stanza@line} sets the
% indentation for the line and starts a numbered paragraph---each
% line is treated as a paragraph. \protect\cs{stanza@hang} sets the
% hanging indentation to be used if the stanza line requires
% more than one print line.

%If it is known that each stanza line
% will fit on one print line, it is advisable to set the
% hanging indentation to zero. \protect\cs{sza@penalty} places the
% specified penalty following each stanza line.
% By default, this
% facility is turned off so that no penalty is included. However,
% the user may initiate these penalties to indicate good and bad
% places in the stanza for page breaking.
%    \begin{macrocode}
\newcommandx{\stanza@line}[2][1,2,usedefault]{%
  \stanza@indent%
  \pstart[#1][#2]\stanza@hang\ignorespaces%
}%
\newcommand{\stanza@indent}{%
    \ifboolexpr{%
      test {\ifnumequal{\value{stanzaindentsrepetition}}{0}}%
      or%
      test {\ifnumless{\number\stanza@count}{\value{startstanzaindentsrepetition}}}%
    }{%
        \ifcsdef{sza@\number\stanza@count @}%
          {%
          \parindent=\csname sza@\number\stanza@count  @\endcsname\stanzaindentbase%
          }{%
          \led@err@StanzaIndentNotDefined%
          }%
    }{%
        \ifcsdef{sza@\number\stanza@modulo @}{%
          \count0=\numexpr%
            \stanza@modulo%
            - 1%
            + \value{startstanzaindentsrepetition}%
          \relax%
          \parindent=\csname sza@\number\count0 @\endcsname\stanzaindentbase%
          \managestanza@modulo%
        }%
        {%
        \led@err@StanzaIndentNotDefined%
        }%
    }%
}%
\xdef\stanza@hang{\noexpand\leavevmode\noexpand\startlock
            \hangindent\expandafter
            \noexpand\csname sza@0@\endcsname\stanzaindentbase
            \hangafter\@ne}
\def\sza@penalty{\count@\csname szp@\number\stanza@count @\endcsname
         \ifnum\count@>\@M\advance\count@-\@M\penalty-\else
         \penalty\fi\count@}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@startstanza}
% \begin{macro}{\stanza}
% \changes{v1.12.0}{2014/08/05}{Add \protect\cs{newverse} macro, \protect\cs{falseverse} deprecated.}
% \changes{v1.12.0}{2014/08/05}{\protect\cs{Stanza} can have an optional argument: content to be printed before.}
% \changes{v1.12.0}{2014/08/05}{\ampersand can have an optional argument: content to be printed after.}
% \changes{v1.20.0}{2015/03/22}{\ampersand\ and \textbackslash\ampersand\ can be preceded by spaces.}
% \begin{macro}{\@stopstanza}
% \begin{macro}{\AtEveryStopStanza}
% \begin{macro}{\AtEveryStanza}
% \begin{macro}{\AtStartEveryStanza}
% \begin{macro}{\BeforeEveryStopStanza}
% \begin{macro}{\newverse}
% \changes{v1.6.0}{2013/10/09}{Add \protect\cs{falseverse} macro.}
% Now we have the components of the \protect\cs{stanza} macro,
% which appears at the start of a group of lines. This macro
% initializes the count and checks to see if hanging indentation
% and penalties are to be included. Hanging indentation suspends
% the line count, so that the enumeration is by verse line
% rather than by print line. If the print line count is desired,
% invoke \protect\cs{let}\protect\cs{startlock}\protect\cs{relax} and do the same for
% \protect\cs{endlock}. Here and above we have used \protect\cs{xdef} to
% make the stored macros take up a bit less space, but it also
% makes them more obscure to the reader. Lines of the stanza are
% delimited by ampersands \&.
% The last line of the stanza must
% end with \verb+\&+.
%
%
%
%    \begin{macrocode}
\xdef\@startstanza[#1][#2]{%
   \noexpand\instanzatrue\expandafter
   \begingroup%
   \catcode`\noexpand\&\active%
   \unexpanded{\newdimen\parindent@beforestanza%
   \parindent@beforestanza=\parindent}%Keep in memory the standard \parindent
   \global\stanza@count\@ne\stanza@modulo\@ne
   \noexpand\ifnum\expandafter\noexpand\csname sza@0@\endcsname=\z@%
      \let\noexpand\stanza@hang\relax%
      \let\noexpand\endlock\relax%
   \noexpand\else%
     \interlinepenalty%
     \@M\rightskip\z@ plus 1fil\relax%
   \noexpand\fi%
   \noexpand\ifnum\expandafter\noexpand\csname szp@0@\endcsname=\z@%
     \let\noexpand\sza@penalty%
   \relax\noexpand\fi%
   \def\noexpand&{%
         \noexpand\newverse[][]}%
   \def\noexpand\&{\noexpand\@stopstanza}%
   \noexpand\@advancestanzanumber%
   \noexpand\stanza@line[#1][#2]%
   \noexpand\@insertstanzanumber%
   \let\par\relax\ignorespaces%No paragraph in verses
}

\newcommandx{\stanza}[2][1,2,usedefault]{%
  \ifboolexpr{%
    not test{\ifdefvoid{\at@every@stanza}}%
    and test{\ifstrempty{#1}}%
    and test{\ifstrempty{#2}}}%
    {\@startstanza[][\at@every@stanza]\at@start@every@stanza}%
    {\@startstanza[#1][#2]\at@start@every@stanza}%
}%

\newcommandx{\@stopstanza}[2][1,2,usedefault]{%
  \unskip%
  \endlock%
  \ifboolexpr{%
    not test{\ifdefvoid{\at@every@stop@stanza}}%
    and test{\ifstrempty{#1}}%
    and test{\ifstrempty{#2}}}%
      {\before@every@stop@stanza\pend[][\at@every@stop@stanza]}%
      {\before@every@stop@stanza\pend[#1][#2]}%
  \endgroup%
  \instanzafalse%
  \global\undef\parindent@beforestanza%
}

\newcommand{\AtEveryStopStanza}[1]{%
  \ifstrempty{#1}%
    {\gdef\at@every@stop@stanza{}}%
    {\gdef\at@every@stop@stanza{\noindent#1}}%
}%
\WithSuffix\newcommand\AtEveryStopStanza*[1]{%
  \ifstrempty{#1}%
    {\gdef\at@every@stop@stanza{}}%
    {\gdef\at@every@stop@stanza{#1}}%
}%
\def\at@every@stop@stanza{}%

\newcommand{\AtEveryStanza}[1]{%
  \ifstrempty{#1}%
    {\gdef\at@every@stanza{}}%
    {\gdef\at@every@stanza{\noindent#1}}%
}%
\WithSuffix\newcommand\AtEveryStanza*[1]{%
  \ifstrempty{#1}%
    {\gdef\at@every@stanza{}}%
    {\gdef\at@every@stanza{#1}}%
}%



\newcommand{\AtStartEveryStanza}[1]{%
  \ifstrempty{#1}%
    {\gdef\at@start@every@stanza{}}%
    {\gdef\at@start@every@stanza{#1}}%
}%
\def\at@start@every@stanza{}%

\newcommand{\BeforeEveryStopStanza}[1]{%
  \ifstrempty{#1}%
    {\gdef\before@every@stop@stanza{}}%
    {\gdef\before@every@stop@stanza{#1}}%
}%
\def\before@every@stop@stanza{}%

\newcommandx*{\newverse}[4][1,2,3,4,usedefault]{%
  \unskip%
  \endlock\pend[#1][#3]\sza@penalty\global%
  \advance\stanza@count\@ne\stanza@line[#2][#4]%
  }

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\flagstanza}
% Use \verb?\flagstanza[len]{text}? at the start of a line to put \texttt{text}
% a distance \texttt{len} before the start of the line. The default for
% \texttt{len} is \verb?\stanzaindentbase?.
%    \begin{macrocode}
\newcommand*{\flagstanza}[2][\stanzaindentbase]{%
  \hskip -#1\llap{#2}\hskip #1\ignorespaces}

%    \end{macrocode}
% \end{macro}
%
% \subsection{Restore catcode and penalties}
% The ampersand \& is used to mark the end of each stanza line, except the
% last, which is marked with \verb+\&+. This means that \verb+\halign+ may
% not be used directly within a stanza line. This does not affect macros
% involving alignments defined outside \verb+\stanza  \&+. Since these
% macros usurp the control sequence \verb+\&+, the replacement
% \verb+\ampersand+ is defined to be used if this symbol is needed in a
% stanza. Also we reset the modified category codes and initialize the
% penalty default.
%    \begin{macrocode}
  \catcode`\&=\next
  \catcode`\@=\body
  \setstanzavalues{szp}{0}

%    \end{macrocode}
% \subsection{Dealing with antilabe}
% \begin{macro}{\firsthalf@antilabe@wd}
% \begin{macro}{\get@firsthalf@antilabe@wd}
% \begin{macro}{\antilabe}
% If the \option{antilabe} option is enabled, after having vboxded
% the content of \cs{pstart}\ldots{pend} structure, we get
% the width of the last line of the \cs{pend}.
%    \begin{macrocode}
\ifantilabe@%
  \newdimen\firsthalf@antilabe@wd%
  \newcommand\get@firsthalf@antilabe@wd{%
    \ifboolexpr{bool {instanza} or bool {inastanzaL} or bool {inastanzaR}}{%
      \vbadness=10000%
      \splittopskip=\z@%
      \ifl@dpairing%
        \ifledRcol%
          \setbox0=\copy\csname l@dRcolrawbox\the\l@dnumpstartsR\endcsname%
        \else%
          \setbox0=\copy\csname l@dLcolrawbox\the\l@dnumpstartsL\endcsname%
        \fi%
      \else%
        \setbox0=\copy\raw@text%
      \fi%
      \dimen0=\dimexpr\ht0+\dp0-\baselineskip\relax%
      \ifdim\dimen0>0pt%
        \setbox1=\vsplit0 to \dimen0%
      \fi%
      \setbox0=\vbox{\unvbox0\global\setbox1=\lastbox}%
      \setbox1=\hbox{\noindent\unhbox1}%
      \global\firsthalf@antilabe@wd=\wd1%
    }{}%
  }%
  \def\beforeantilabe{}%
  \def\afterantilabe{}%
  \newcommand{\antilabe}[1]{%
    \beforeantilabe\hbox to\firsthalf@antilabe@wd{#1\hfill}\afterantilabe%
  }%
\else%
  \let\get@firsthalf@antilabe@wd\relax%
\fi%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \section{Apparatus of Manuscripts}
% \subsection{User level macro}
% \begin{macro}{\msdata}
% \begin{macro}{\msdata@c}
% \begin{macro}{\msdata@cR}
% The user level \cs{msdata} command only writes the manuscripts data in a numbered auxiliary file. There are two associated etoolbox counters.
%    \begin{macrocode}
\def\msdata@c{}%
\def\msdata@cR{}%
\newcommand{\msdata}[1]{%
  \leavevmode%
  \unless\ifstopmsdata@inserted@%
    \stopmsdata%
    \led@warning@msdatawithoutstop%
  \fi%
  \global\stopmsdata@inserted@false%
  \unless\ifledRcol%
    \numgdef{\msdata@c}{\msdata@c+1}%
    \ifdef{\hypertarget}{%
      \edlabel{\msdata@c:start:msdata}%
    }{}%
    \protected@write\linenum@out{}{%
      \string\@msd{#1}%
    }%
  \else%
    \numgdef{\msdata@cR}{\msdata@cR+1}%
    \ifdef{\hypertarget}{%
      \edlabel{\msdata@cR:start:msdata}%
    }{}%
    \protected@write\linenum@outR{}{%
      \string\@msd{#1}%
    }%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\stopmsdata}
% The user level \cs{stopmsdata} command only writes information about the end of manuscripts data in numbered auxiliary file.
%    \begin{macrocode}
\newcommand{\stopmsdata}[0]{%
  \leavevmode%
  \unless\ifledRcol%
    \protected@write\linenum@out{}{%
      \string\@stopmsd%
    }%
    \ifdef{\hypertarget}{%
      \edlabel{\msdata@c:end:msdata}%
    }{}%
  \else%
    \protected@write\linenum@outR{}{%
      \string\@stopmsd%
    }%
   \ifdef{\hypertarget}{%
     \edlabel{\msdata@cR:end:msdata}%
   }{}%
  \fi%
  \global\stopmsdata@inserted@true%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ifstopmsdata@inserted@}
% The \cs{ifstopmsdata@inserted@} boolean is set to TRUE at every \cs{stopmsdata} and reset to FALSE at all \cs{msdata}. It also set to TRUE at every \cs{beginnumbering}.
% It is used to automatically insert \cs{stopmsdata} if forgotten before \cs{msdata}
%    \begin{macrocode}
\newif\ifstopmsdata@inserted@%
%    \end{macrocode}
% \end{macro}
% \subsection{Setting macro}
% Setting macros for the manuscripts apparatus tools is very easy: they just save their argument in an internal macro.
% \begin{macro}{\setmsdataseries}
% In which series of notes will be printed the apparatus of manuscripts?
%    \begin{macrocode}
\newcommand{\setmsdataseries}[1]{%
  \gdef\@msdata@series{#1}%
}%
\def\@msdata@series{A}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setmsdataposition}
% The label for the manuscripts data.
%    \begin{macrocode}
\def\ms@data@position{msdata-regular}%
\newcommand{\setmsdataposition}[1]{%
  \gdef\ms@data@position{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setmsdatalabel}
% The label for the manuscripts data.
%    \begin{macrocode}
\def\ms@data@label{Ms.}%
\newcommand{\setmsdatalabel}[1]{%
  \gdef\ms@data@label{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Counters and lists}
% \begin{macro}{\@msd@c}
% \cs{@msd@c} is a counter incremented at each \cs{@msd} read in auxiliary file.
%    \begin{macrocode}
\numdef{\@msd@c}{0}
\numdef{\@msd@cR}{0}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\add@msd@}
% \cs{add@msd@} is a counter incremented at each \cs{add@msddata}, that is at each time we prepare the insertion of manuscripts data footnote.
%    \begin{macrocode}
\numdef{\add@msd@c}{0}%
\numdef{\add@msd@cR}{0}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@msdata@list}
% The \cs{@msdata@list} will contain, for each line, the lists of command to be executed to insert the manuscripts apparatus.
% It will be filled on \cs{add@msdata} and looped  on  \cs{insert@msdata}, then emptied.
%    \begin{macrocode}
\def\@msdata@list{}%
%    \end{macrocode}
% \end{macro}
% \subsection{Auxiliary file macros}
% \begin{macro}{\@msd}
% The \cs{@msd} macro is written in the auxiliary file.
% It just defines three macros by \cs{msdata} macro, which allow us to know the manuscripts data, the line number and the absolute line number where it was called
%
% It also stores the action code $1010$ in the list of actions by line.
%    \begin{macrocode}
\newcommand{\@msd}[1]{%
  \unless\ifledRcol%
    \global\numdef{\@msd@c}{\@msd@c+\@ne}%
    \csgdef{@msdata@\@msd@c @data}{#1}%
    \csxdef{@msdata@\@msd@c @linenumber}{\the\line@num}%
    \csxdef{@msdata@\@msd@c @sublinenumber}{\the\subline@num}%
    \csxdef{@msdata@\@msd@c @abslinenumber}{\the\absline@num}%
    \xright@appenditem{\the\absline@num}\to\actionlines@list%
    \xright@appenditem{-1010}\to\actions@list%
  \else%
    \global\numdef{\@msd@cR}{\@msd@cR+\@ne}%
    \csgdef{@msdata@\@msd@cR @dataR}{#1}%
    \csxdef{@msdata@\@msd@cR @linenumberR}{\the\line@numR}%
    \csxdef{@msdata@\@msd@cR @sublinenumberR}{\the\subline@numR}%
    \csxdef{@msdata@\@msd@cR @abslinenumberR}{\the\absline@numR}%
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR%
    \xright@appenditem{-1010}\to\actions@listR%
 \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@stopmsd}
% Inserted in the auxiliary file by \cs{stopmsd}, the \cs{@stopmsd} macro will store in two commands the line number and the absolute line number on which it is called.
%    \begin{macrocode}
\newcommand{\@stopmsd}[0]{%
  \unless\ifledRcol%
     \ifcsundef{@msdata@\@msd@c @stoplinenumber}{%
       \csxdef{@msdata@\@msd@c @stopabslinenumber}{\the\absline@num}%
       \csxdef{@msdata@\@msd@c @stoplinenumber}{\the\line@num}%
       \csxdef{@msdata@\@msd@c @stopsublinenumber}{\the\subline@num}%
     }{}%
  \else%
     \ifcsundef{@msdata@\@msd@cR @stoplinenumberR}{%
       \csxdef{@msdata@\@msd@cR @stopabslinenumberR}{\the\absline@numR}%
       \csxdef{@msdata@\@msd@cR @stoplinenumberR}{\the\line@numR}%
       \csxdef{@msdata@\@msd@cR @stopsublinenumberR}{\the\subline@numR}%
     }%
     {}%
 \fi%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Action macro}
% \begin{macro}{\add@msdata}
% \cs{add@msdata} is executed on each line when action code $1010$ is seen.
% It will not insert immediately the manuscript data footnote, as action code are executed before the line be typeset, and, consequently, could be on the previous page.
% So it just stores the manuscript data footnote to \cs{@msdata@list}.
%    \begin{macrocode}
\newcommand{\add@msdata}{%
  \bgroup%
  \normalfont%
  \unless\ifledRcol@%
    \numgdef{\add@msd@c}{\add@msd@c+\@ne}%
      \ifcsdef{@msdata@\add@msd@c @data}{%
        \letcs{\@data}{@msdata@\add@msd@c @data}%
        \edef\l@d@nums{%
          000|% Start page = we don't print it
          \csuse{@msdata@\add@msd@c @linenumber}|% Start line number
          \csuse{@msdata@\add@msd@c @sublinenumber}|% Start subline number
          000|% End page number, we don't print it
          \ifnumless{\csuse{@msdata@\add@msd@c @stopabslinenumber}}{\csuse{@lastabsline@forpage@\the\page@num}}%
            {\csuse{@msdata@\add@msd@c @stoplinenumber}}%End line number if in the same page
            {\csuse{@lastline@forpage@\the\page@num}}%Otherwise, last number of the page
          |%
          \ifnumless{\csuse{@msdata@\add@msd@c @stopabslinenumber}}{\csuse{@lastabsline@forpage@\the\page@num}}%
            {\csuse{@msdata@\add@msd@c @stopsublinenumber}}%End subline number if in the same page
            {\csuse{@lastsubline@forpage@\the\page@num}}%Otherwise, last subnumber of the page
          |%
          \edfont@info%Font
          }%
          \@msd@options@fullpagefalse%
          \if@firstlineofpage%Try if the data are for the full page. If yes, will add options to the list.
            \unless\if@msdata@insertedfrompreviouspage%
              \ifnumless{\csuse{@lastabsline@forpage@\the\page@num}}{\csuse{@msdata@\add@msd@c @stopabslinenumber}+\@ne}%
              {%
              \numdef{\@tmp}{\add@msd@c+\@ne}%
              \ifcsdef{@msdata@\@tmp @abslinenumber}%
                {\ifnumequal{\csuse{@msdata@\@tmp @abslinenumber}}{\csuse{@lastabsline@forpage@\the\page@num}}%
                  {}%
                  {\@msd@options@fullpagetrue}%
                }%
                {\@msd@options@fullpagetrue}%
              }%
             {}%
            \fi%
          \fi%
          \listxadd{\@msdata@list}{%
            \@msd@options@iffullpage%
            \ifluatex%
              \csxdef{footnote@luatextextdir}{\the\textdir}%
              \csxdef{footnote@luatexpardir}{\the\pardir}%
            \fi%
            \csdef{@this@crossref@start}{\add@msd@c:start:msdata}%
             \csdef{@this@crossref@end}{\add@msd@c:end:msdata}%
             \unexpanded{%
               \def\annot@start{}%
               \def\annot@end{}%
             }%
            \noexpand\csuse{v\@msdata@series footnote}{\@msdata@series}{{\expandonce\l@d@nums}{\ms@data@label}{\expandonce\@data}}%
            \reset@msd@options@iffullpage%
         }%
      }%
      {}%
  \else%
    \numgdef{\add@msd@cR}{\add@msd@cR+\@ne}%
      \ifcsdef{@msdata@\add@msd@cR @dataR}{%
        \letcs{\@data}{@msdata@\add@msd@cR @dataR}%
        \edef\l@d@nums{%
          000|% Start page = we don't print it
          \csuse{@msdata@\add@msd@cR @linenumberR}|% Start line number
          \csuse{@msdata@\add@msd@cR @sublinenumberR}|% Start subline number, for now, not used
          000|% End page number, we don't print it
          \ifnumless{\csuse{@msdata@\add@msd@cR @stopabslinenumberR}}{\csuse{@lastline@forpageR@\the\page@numR}}%
            {\csuse{@msdata@\add@msd@cR @stoplinenumberR}}%End line number if in the same page
            {\csuse{@lastline@forpageR@\the\page@numR}}%Otherwise, last number of the page
          |%
          \ifnumless{\csuse{@msdata@\add@msd@cR @stopabslinenumberR}}{\csuse{@lastline@forpageR@\the\page@numR}}%
            {\csuse{@msdata@\add@msd@cR @stopsublinenumberR}}%End subline number if in the same page
            {\csuse{@lastsubline@forpageR@\the\page@numR}}%Otherwise, last number of the page
          000|% End sub line number, for now, not used
          \edfont@info%Font
          }%
          \@msd@options@fullpagefalse%
          \if@firstlineofpageR%
            \unless\if@msdata@insertedfrompreviouspage%
              \ifnumless{\csuse{@lastabsline@forpageR@\the\page@numR}}{\csuse{@msdata@\add@msd@c @stopabslinenumberR}+\@ne}%
              {%
              \numdef{\@tmp}{\add@msd@cR+\@ne}%
              \ifcsdef{@msdata@\@tmp @abslinenumberR}%
                {\ifnumequal{\csuse{@msdata@\@tmp @abslinenumberR}}{\csuse{@lastabsline@forpageR@\the\page@numR}}%
                  {}%
                  {\@msd@options@fullpagetrue}%
                }%
                {\@msd@options@fullpagetrue}%
              }%
             {}%
            \fi%
          \fi%
          \listxadd{\@msdata@list}{%
            \@msd@options@iffullpage%
            \ifluatex%
              \csxdef{footnote@luatextextdir}{\the\textdir}%
              \csxdef{footnote@luatexpardir}{\the\pardir}%
            \fi%
            \csdef{@this@crossref@start}{\add@msd@cR:start:msdata}%
             \csdef{@this@crossref@end}{\add@msd@cR:end:msdata}%
             \unexpanded{%
               \def\annot@start{}%
               \def\annot@end{}%
             }%
            \noexpand\csuse{v\@msdata@series footnote}{\@msdata@series}{{\expandonce\l@d@nums}{\ms@data@label}{\expandonce\@data}}%
            \reset@msd@options@iffullpage%
         }%
      }%
      {}%
  \fi%
  \egroup%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@msdata@insertedfrompreviouspage}
% The \cs{if@msdata@insertedfrompreviouspage} boolean is set to TRUE if \macpackage\ automatically inserts data from previous page in the first line of a page.
%    \begin{macrocode}
\newif\if@msdata@insertedfrompreviouspage%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\add@msdata@firstlineofpage}
% \cs{add@msdata@firstlineofpage} is called at the first line of every page. It inserts manuscript data which start on one of the previous pages and continue on this page.
%    \begin{macrocode}
\newcommand{\add@msdata@firstlineofpage}{%
  \bgroup%
  \normalfont%
  \unless\ifledRcol@%
    \ifcsdef{@msdata@\add@msd@c @data}{%
    \ifnumless{\the\absline@num-\@ne}{\csuse{@msdata@\add@msd@c @stopabslinenumber}}%
      {%
      \global\@msdata@insertedfrompreviouspagetrue%
      \letcs{\@data}{@msdata@\add@msd@c @data}%
      \edef\l@d@nums{%
          000|% Start page = we don't print it
          \numexpr\the\line@num+\@ne\relax|% Start line number = first line of the page. As \add@msdata@firstlineofpage is called before line number has been incremented, we increment it for printing
          000|% Start subline number, for now, not used
          000|% End page number, we don't print it
          \ifnumless{\csuse{@msdata@\add@msd@c @stopabslinenumber}}{\csuse{@lastabsline@forpage@\the\page@num}}%
            {\csuse{@msdata@\add@msd@c @stoplinenumber}}%End line number if in the same page
            {\csuse{@lastline@forpage@\the\page@num}}%Otherwise, last number of the page
          |%
          000|% End sub line number, for now, not used
          \edfont@info%Font
          }%
          \@msd@options@fullpagefalse%
          \ifnumless{\csuse{@lastabsline@forpage@\the\page@num}}{\csuse{@msdata@\add@msd@c @stopabslinenumber}+\@ne}%We will test if the ms data is for the full page
          {%
          \numdef{\@tmp}{\add@msd@c+\@ne}%
          \ifcsdef{@msdata@\@tmp @abslinenumber}%
            {\ifnumequal{\csuse{@msdata@\@tmp @abslinenumber}}{\csuse{@lastabsline@forpage@\the\page@num}}%
              {}%
              {\@msd@options@fullpagetrue}%
            }%
            {\@msd@options@fullpagetrue}%
          }%
         {}%
         \listxadd{\@msdata@list}{%
          \@msd@options@iffullpage%
          \ifluatex%
            \csxdef{footnote@luatextextdir}{\the\textdir}%
            \csxdef{footnote@luatexpardir}{\the\pardir}%
          \fi%
          \csdef{@this@crossref@start}{\add@msd@c:start:msdata}%
           \csdef{@this@crossref@end}{\add@msd@c:end:msdata}%
           \unexpanded{%
             \def\annot@start{}%
             \def\annot@end{}%
           }%
          \noexpand\csuse{v\@msdata@series footnote}{\@msdata@series}{{\expandonce\l@d@nums}{\ms@data@label}{\expandonce\@data}}%
          \reset@msd@options@iffullpage%
        }%
      }%
      {\global\@msdata@insertedfrompreviouspagefalse}%
  }{}%
  \else%
    \ifcsdef{@msdata@\add@msd@cR @dataR}{%
    \ifnumless{\the\absline@numR-\@ne}{\csuse{@msdata@\add@msd@cR @stopabslinenumberR}}%
          {%
          \global\@msdata@insertedfrompreviouspagetrue%
          \letcs{\@data}{@msdata@\add@msd@cR @dataR}%
          \edef\l@d@nums{%
          000|% Start page = we don't print it
          \numexpr\the\line@numR+\@ne\relax|% Start line number = first line of the page. As \add@msdata@firstlineofpage is called before line number has been incremented, we increment it for printing
          000|% Start subline number, for now, not used
          000|% End page number, we don't print it
          \ifnumless{\csuse{@msdata@\add@msd@cR @stopabslinenumberR}}{\csuse{@lastline@forpageR@\the\page@numR}}%
            {\csuse{@msdata@\add@msd@cR @stoplinenumberR}}%End line number if in the same page
            {\csuse{@lastline@forpageR@\the\page@numR}}%Otherwise, last number of the page
          |%
          000|% End sub line number, for now, not used
          \edfont@info%Font
          }%
          \@msd@options@fullpagefalse%
          \ifnumless{\csuse{@lastabsline@forpageR@\the\page@numR}}{\csuse{@msdata@\add@msd@cR @stopabslinenumberR}+\@ne}%
          {%
          \numdef{\@tmp}{\add@msd@cR+\@ne}%
          \ifcsdef{@msdata@\@tmp @abslinenumberR}%
            {\ifnumequal{\csuse{@msdata@\@tmp @abslinenumberR}}{\csuse{@lastabsline@forpageR@\the\page@numR}}%
              {}%
              {\@msd@options@fullpagetrue}%
            }%
            {\@msd@options@fullpagetrue}%
          }%
         {}%
         \listxadd{\@msdata@list}{%
           \@msd@options@iffullpage%
           \ifluatex%
             \csxdef{footnote@luatextextdir}{\the\textdir}%
             \csxdef{footnote@luatexpardir}{\the\pardir}%
           \fi%
          \csdef{@this@crossref@start}{\add@msd@cR:start:msdata}%
           \csdef{@this@crossref@end}{\add@msd@cR:end:msdata}%
           \unexpanded{%
             \def\annot@start{}%
             \def\annot@end{}%
           }%
           \noexpand\csuse{v\@msdata@series footnote}{\@msdata@series}{{\expandonce\l@d@nums}{\ms@data@label}{\expandonce\@data}}%
           \reset@msd@options@iffullpage%
        }%
     }%
     {\global\@msdata@insertedfrompreviouspagefalse}%
  }{}%
  \fi%
  \egroup%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Inserting footnote}
% Just before inserting standard insert (familiar and critical footnotes, sidenotes), we call \cs{insert@msdata} to insert manuscripts data's footnotes.
% \begin{macro}{\insert@msdata}
%    \begin{macrocode}
\newcommand{\insert@msdata}{%
  \def\do##1{##1}%
  \dolistloop{\@msdata@list}%
  \global\let\@msdata@list\relax%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Other}
% \begin{macro}{\@msd@options@iffullpage}
% \begin{macro}{\reset@msd@options@iffullpage}
% \cs{@msd@options@iffullpage} sets some options if the manuscripts data are for all the page.
% \cs{reset@msd@options@iffullpage} resets them after the footnote.
% \cs{if@msd@options@fullpage} is switch to true in \protect{add@msdata@firstlineofpage} if these option must be inserted.
%    \begin{macrocode}
\newif\if@msd@options@fullpage%
\newcommand{\@msd@options@iffullpage}[0]{%
  \if@msd@options@fullpage%
    \noexpand\toggletrue{nonum@}%
    \ifdefvoid{\ms@data@label}%
      {\noexpand\toggletrue{nosep@}}%
      {}%
  \fi%
}%
\newcommand{\reset@msd@options@iffullpage}[0]{%
  \noexpand\togglefalse{nonum@}%
  \noexpand\togglefalse{nosep@}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Arrays and tables}
% \subsection{Preamble: macro as environment}
%
%
%    The following is borrowed, and renamed, from the \protect\package{amsmath}
% package. See also the CTT thread `eeq and amstex', 1995/08/31, started
% by Keith Reckdahl and ended definitively by David M. Jones.
%
%
% Several of the [math] macros scan their body twice. This means we must
% collect all text in the body of an environment form before calling
% the macro.
%
% \begin{macro}{\@emptytoks}
% This is actually defined in the \protect\package{amsgen} package.
%    \begin{macrocode}
\newtoks\@emptytoks

%    \end{macrocode}
% \end{macro}
%
% The rest is from \protect\package{amsmath}.
%
% \begin{macro}{\l@denvbody}
% A token register to contain the body.
%    \begin{macrocode}
\newtoks\l@denvbody

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\addtol@denvbody}
% |\addtol@denvdody{arg}| adds |arg| to the token register |\l@denvbody|.
%    \begin{macrocode}
\newcommand{\addtol@denvbody}[1]{%
  \global\l@denvbody\expandafter{\the\l@denvbody#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@edtabular}
% A boolean set to true inside a \macpackage' tabular environnment.
%    \begin{macrocode}
\newif\if@edtabular%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dcollect@body}
% The macro \protect\cs{l@dcollect@body} starts the scan for the \protect\cs{end}\marg{env} command
% of the current environment. It takes a macro name as argument. This macro
% is supposed to take the whole body of the environment as its argument.
% For example, given |cenv#1{...}| as a macro that processes |#1|, then
% the environment form, |\begin{env}| would call |\l@dcollect@body\cenv|.
%
%    \begin{macrocode}
\newcommand{\l@dcollect@body}[1]{%
  \\%Ensure that we don't have spurious indentation at the very first line, caused by some text before.
  \l@denvbody{\expandafter#1\expandafter{\the\l@denvbody}}%
  \edef\processl@denvbody{\the\l@denvbody\noexpand\end{\@currenvir}}%
  \l@denvbody\@emptytoks \def\l@dbegin@stack{b}%
  \begingroup
    \@edtabulartrue%
    \expandafter\let\csname\@currenvir\endcsname\l@dcollect@@body
    \edef\processl@denvbody{\expandafter\noexpand\csname\@currenvir\endcsname}%
    \processl@denvbody%
    }%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dpush@begins}
% When adding a piece of the current environment's contents to \protect\cs{l@denvbody},
% we scan it to check for additional \protect\cs{begin} tokens, and add a `b' to the
% stack for any that we find.
%    \begin{macrocode}
\def\l@dpush@begins#1\begin#2{%
  \ifx\end#2\else b\expandafter\l@dpush@begins\fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dcollect@@body}
% \protect\cs{l@dcollect@@body} takes two arguments: the first will consist of all text
% up to the next |\end| command, and the second will be the \protect\cs{end} command's
% argument. If there are any extra \protect\cs{begin} commands in the body text,
% a marker is pushed onto a stack by the \protect\cs{l@dpush@begins} function.
% Empty state for this stack means we have reached the \protect\cs{end} that matches
% our original \protect\cs{begin}. Otherwise we need to include the \protect\cs{end} and its
% argument in the material we are adding to the environment body accumulator.
%    \begin{macrocode}
\def\l@dcollect@@body#1\end#2{%
  \edef\l@dbegin@stack{\l@dpush@begins#1\begin\end
                       \expandafter\@gobble\l@dbegin@stack}%
  \ifx\@empty\l@dbegin@stack
    \endgroup
    \@checkend{#2}%
    \addtol@denvbody{#1}%
  \else
    \addtol@denvbody{#1\end{#2}}%
  \fi
  \processl@denvbody % A little tricky! Note the grouping
}

%    \end{macrocode}
% \end{macro}
%
%    There was a question on CTT about how to use \protect\cs{collect@body} for a macro
% taking an argument. The following is part of that thread.
% \begin{verbatim}
% From: Heiko Oberdiek <oberdiek@uni-freiburg.de>
% Newsgroups: comp.text.tex
% Subject: Re: Using \collect@body with commands that take >1 argument
% Date: Fri, 08 Aug 2003 09:03:20 +0200
%
% eed132@psu.edu (Evan) wrote:
% > I'm trying to make a new Latex environment that acts like the>
%  \colorbox command that is part of the color package. I looked through
% > the FAQ and ran across this bit about using the \collect@body command
% > that is part of AMSLaTeX:
% > http://www.tex.ac.uk/cgi-bin/texfaq2html?label=cmdasenv
% >
% > It almost works. If I do something like the following:
% >   \newcommand{\redbox}[1]{\colorbox{red}{#1}}
% >
% >   \makeatletter
% >   \newenvironment{redbox}{\collect@body \redbox}{}
%
% You will get an error message: Command \redbox already defined.
% Thus you must rename either the command \redbox or the environment
% name.
%
% >   \begin{coloredbox}{blue}
% >     Yadda yadda yadda... this is on a blue background...
% >   \end{coloredbox}
% > and can't figure out how to make the \collect@body take this.
%
% >   \collect@body \colorbox{red}
% >   \collect@body {\colorbox{red}}
%
% The argument of \collect@body has to be one token exactly.
%
% \documentclass{article}
% \usepackage{color}
% \usepackage{amsmath}
%
% \newcommand{\redbox}[1]{\colorbox{red}{#1}}
% \makeatletter
% \newenvironment{coloredbox}[1]{%
%   \def\next@{\colorbox{#1}}%
%   \collect@body\next@
% }{}
%
% % ignore spaces at begin and end of environment
% \newenvironment{coloredboxII}[1]{%
%   \def\next@{\mycoloredbox{#1}}%
%   \collect@body\next@
% }{}
% \newcommand{\mycoloredbox}[2]{%
%   \colorbox{#1}{\ignorespaces#2\unskip}%
% }
%
% % support of optional color model argument
% \newcommand\coloredboxIII\endcsname{}
% \def\coloredboxIII#1#{%
%   \@coloredboxIII{#1}%
% }
% \def\@coloredboxIII#1#2{%
%   \def\next@{\mycoloredboxIII{#1}{#2}}%
%   \collect@body\next@
% }
% \newcommand{\mycoloredboxIII}[3]{%
%   \colorbox#1{#2}{\ignorespaces#3\unskip}%
% }
%
% \makeatother
%
% \begin{document}
%   Black text before
%   \begin{coloredbox}{blue}
%    Hello World
%   \end{coloredbox}
%   Black text after
%
%   Black text before
%   \begin{coloredboxII}{blue}
%    Hello World
%   \end{coloredboxII}
%   Black text after
%
%   Black text before
%   \begin{coloredboxIII}[rgb]{0,0,1}
%    Hello World
%   \end{coloredboxIII}
%   Black text after
%
% \end{document}
%
% Yours sincerely
%   Heiko <oberdiek@uni-freiburg.de>
% \end{verbatim}
%
%
% \subsection{Tabular environments}
% This is based on the work by Herbert Breger\index{Breger, Herbert}
%  in developing \file{tabmac.tex}.
%
% The original \file{tabmac.tex} file was void of comments or any explanatory
% text other than the above notice. The algorithm is Breger's. Peter Wilson have made
% some cosmetic changes to the original code and reimplemented some things
% so they are more LaTeX-like. All the commentary are from Peter Wilson, as are any mistake
% or errors.
%
% However, Maïeul Rouquette has modified code in order to add new features of \eledmac and \reledmac.
% \subsubsection{Disabling and restoring commands}
% \begin{macro}{\l@dtabnoexpands}
% More no expansion for critical and familiar footnotes in tabular environment.
%
%    \begin{macrocode}
\newcommand*{\l@dtabnoexpands}{%
  \let\rtab=0%
  \let\ctab=0%
  \let\ltab=0%
  \let\rtabtext=0%
  \let\ltabtext=0%
  \let\ctabtext=0%
  \let\edbeforetab=0%
  \let\edaftertab=0%
  \let\edatleft=0%
  \let\edatright=0%
  \let\edvertline=0%
  \let\edvertdots=0%
  \let\edrowfill=0%
}

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\disable@familiarnotes}
% \begin{macro}{\restore@familiarnotes}
% Macros to disable and restore familiar notes, to prevent them from printing multiple times in edtabularx and edarrayx environments.
%    \begin{macrocode}
\newcommand{\disable@familiarnotes}{%
  \unless\ifnofamiliar@%
    \def\do##1{%
        \csletcs{footnote@@##1}{footnote##1}%
        \expandafter\renewcommand \csname footnote##1\endcsname[1]{%
          \protected@csxdef{@thefnmark##1}{\csuse{thefootnote##1}}%
          \csuse{@footnotemark##1}%
        }%
    }%
    \dolistloop{\@series}%
  \fi%
}%
\newcommand{\restore@familiarnotes}{%
  \unless\ifnofamiliar@%
    \def\do##1{%
        \csletcs{footnote##1}{footnote@@##1}%
    }%
    \dolistloop{\@series}%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\disable@sidenotes}
% \begin{macro}{\restore@sidenotes}
% The same for sidenotes.
%    \begin{macrocode}
\newcommand{\disable@sidenotes}{%
  \let\@@ledrightnote\ledrightnote%
  \let\@@ledleftnote\ledleftnote%
  \let\@@ledsidenote\ledsidenote%
  \let\ledrightnote\@gobble%
  \let\ledleftnote\@gobble%
  \let\ledsidenote\@gobble%
}%
\newcommand{\restore@sidenotes}{%
  \let\ledrightnote\@@ledrightnote%
  \let\ledleftnote\@@ledleftnote%
  \let\ledsidenote\@@ledsidenote%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\disable@endnotes}
% \begin{macro}{\restore@endnotes}
% The same for endnotes.
%    \begin{macrocode}
\newcommand{\disable@endnotes}{%
  \unless\ifnoend@%
    \def\do##1{%
        \csletcs{##1@@endnote}{##1endnote}%
        \expandafter\renewcommand \csname ##1endnote\endcsname[1]{}%
    }%
    \dolistloop{\@series}%
  \fi%
}%
\newcommand{\restore@endnotes}{%
  \unless\ifnofamiliar@%
    \def\do##1{%
        \csletcs{##1endnote}{##1@@endnote}%
    }%
    \dolistloop{\@series}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\disable@notes}
% \begin{macro}{\restore@notes}
% Disable/restore side, familiar and end notes.
%    \begin{macrocode}
\newcommand{\disable@notes}{%
  \disable@sidenotes%
  \disable@familiarnotes%
  \disable@endnotes%
}%
\newcommand{\restore@notes}{%
  \restore@sidenotes%
  \restore@familiarnotes%
  \restore@endnotes%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\EDTEXT}
% \begin{macro}{\xedtext}
% We need to be able to modify the \protect\cs{edtext} macros
% and also restore their original definitions.
%    \begin{macrocode}
\let\EDTEXT=\edtext
\newcommand{\xedtext}[2]{\EDTEXT{#1}{#2}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\EDLABEL}
% \begin{macro}{\xedlabel}
% We need to be able to modify and restore the \protect\cs{edlabel} macro.
%    \begin{macrocode}
\let\EDLABEL=\edlabel
\newcommand*{\xedlabel}[1]{\EDLABEL{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\xedindex}
% \begin{macro}{\nulledindex}
% Macros supporting modification and restoration of \protect\cs{edindex}.
%    \begin{macrocode}
\AtBeginDocument{\let\xedindex\edindex}%
\newcommand{\nulledindex}[2][\jobname]{\@bsphack\@esphack}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@line@@num}
% Macro supporting restoration of |\linenum|.
%    \begin{macrocode}
\let\@line@@num=\linenum
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dgobbleoptarg}
% \protect\cs{l@dgobbleoptarg}\oarg{arg}\marg{arg} replaces these two arguments (first is optional) by \protect\cs{relax}.
% \changes{v1.12.5}{2014/08/28}{\protect\cs{l@dgobblearg} becomes \protect\cs{l@dgobbeloptarg}}
%    \begin{macrocode}
\newcommand*{\l@dgobbleoptarg}[2][]{\relax}%

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\l@secondmandarg}
% \protect\cs{l@secondoptarg}\oarg{arg}\marg{arg} gobble the first (optional) argument, and expand to the second (mandatory) argument.
%    \begin{macrocode}
\NewExpandableDocumentCommand{\l@secondmandarg}{om}{#2}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Relax}
% \begin{macro}{\NEXT}
%    \begin{macrocode}
\let\Relax=\relax
\let\NEXT=\next

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\l@dmodforedtext}
% \begin{macro}{\l@drestoreforedtext}
% Modify and restore various macros for when |\edtext| is used.
% \changes{v1.12.5}{2014/08/28}{Debug optional arguments of \protect\cs{Xfootnote} in tabular context}
%    \begin{macrocode}
\newcommand{\l@dmodforedtext}{%
  \let\edtext\relax
  \def\do##1{\global\csletcs{##1footnote}{l@dgobbleoptarg}}%
  \dolistloop{\@series}%
  \let\edindex\nulledindex
  \let\linenum\@gobble}
\newcommand{\l@drestoreforedtext}{%
  \def\do##1{\global\csletcs{##1footnote}{##1@@footnote}}
  \dolistloop{\@series}%
  \let\edindex\xedindex}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dnullfills}
% \begin{macro}{\l@drestorefills}
% Nullify and restore some column fillers, etc.
%    \begin{macrocode}
\newcommand{\l@dnullfills}{%
  \def\edlabel##1{}%
  \def\edrowfill##1##2##3{}%
}
\newcommand{\l@drestorefills}{%
  \def\edrowfill##1##2##3{\@EDROWFILL@{##1}{##2}{##3}}%
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\letsforverteilen}
% Gathers some lets and other code that is common to the |*verteilen*| macros.
%    \begin{macrocode}
\newcommand{\letsforverteilen}{%
  \let\edtext\xedtext
  \let\edindex\xedindex
  \def\do##1{\global\csletcs{##1footnote}{##1@@footnote}}
  \dolistloop{\@series}%
  \let\linenum\@line@@num
  \hilfsskip=\l@dcolwidth%
  \advance\hilfsskip by -\wd\hilfsbox
  \def\edlabel##1{\xedlabel{##1}}}

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\disablel@dtabfeet}
% \begin{macro}{\enablel@dtabfeet}
% Declarations for using  or using \protect\cs{edtext} inside
% tabulars.
% The default at this point is for \protect\cs{edtext}.
%    \begin{macrocode}
\newcommand\disablel@dtabfeet{\l@dmodforedtext}%
\newcommand\enablel@dtabfeet{\l@drestoreforedtext}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsubsection{Counters, boxes and lengths}
% \begin{macro}{\l@dampcount}
% \begin{macro}{\l@dcolcount}
% \protect\cs{l@dampcount} is a counter for the \& column dividers and
% \protect\cs{l@dcolcount} is a counter for the columns.
%    \begin{macrocode}
\newcount\l@dampcount
  \l@dampcount=1\relax
\newcount\l@dcolcount
  \l@dcolcount=0\relax

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hilfsbox}
% \begin{macro}{\hilfsskip}
% \begin{macro}{\Hilfsbox}
% \begin{macro}{\hilfscount}
% Some (temporary) helper items.
%    \begin{macrocode}
\newbox\hilfsbox
\newskip\hilfsskip
\newbox\Hilfsbox
\newcount\hilfscount

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% 30 columns should be adequate (compared to the original 60).
% These are the column widths. (Originally these were German spelled numbers
% e.g., |\eins|, |\zwei|, etc).
%    \begin{macrocode}
\newdimen\dcoli
\newdimen\dcolii
\newdimen\dcoliii
\newdimen\dcoliv
\newdimen\dcolv
\newdimen\dcolvi
\newdimen\dcolvii
\newdimen\dcolviii
\newdimen\dcolix
\newdimen\dcolx
\newdimen\dcolxi
\newdimen\dcolxii
\newdimen\dcolxiii
\newdimen\dcolxiv
\newdimen\dcolxv
\newdimen\dcolxvi
\newdimen\dcolxvii
\newdimen\dcolxviii
\newdimen\dcolxix
\newdimen\dcolxx
\newdimen\dcolxxi
\newdimen\dcolxxii
\newdimen\dcolxxiii
\newdimen\dcolxxiv
\newdimen\dcolxxv
\newdimen\dcolxxvi
\newdimen\dcolxxvii
\newdimen\dcolxxviii
\newdimen\dcolxxix
\newdimen\dcolxxx
\newdimen\dcolerr   % added for error handling

%    \end{macrocode}
%
% \begin{macro}{\l@dcolwidth}
%  This is a cunning way of storing the columnwidths indexed by
% the column number \protect\cs{l@dcolcount}, like an array. (was |\Dimenzuordnung|)
%    \begin{macrocode}
\newcommand{\l@dcolwidth}{\ifcase \the\l@dcolcount \dcoli %???
  \or \dcoli \or \dcolii \or \dcoliii
  \or \dcoliv \or \dcolv \or \dcolvi
  \or \dcolvii \or \dcolviii \or \dcolix \or \dcolx
  \or \dcolxi \or \dcolxii \or \dcolxiii
  \or \dcolxiv \or \dcolxv \or \dcolxvi
  \or \dcolxvii \or \dcolxviii \or \dcolxix \or \dcolxx
  \or \dcolxxi \or \dcolxxii \or \dcolxxiii
  \or \dcolxxiv \or \dcolxxv \or \dcolxxvi
  \or \dcolxxvii \or \dcolxxviii \or \dcolxxix \or \dcolxxx
  \else \dcolerr \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\stepl@dcolcount}
% This increments the column counter, and issues an error message
% if it is too large.
%    \begin{macrocode}
\newcommand*{\stepl@dcolcount}{\advance\l@dcolcount\@ne
  \ifnum\l@dcolcount>30\relax
    \led@err@TooManyColumns
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dsetmaxcolwidth}
% Sets the column width to the maximum value seen so far.
%    \begin{macrocode}
\newcommand{\l@dsetmaxcolwidth}{%
  \ifdim\l@dcolwidth < \wd\hilfsbox
    \l@dcolwidth = \wd\hilfsbox
  \else \relax \fi}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\measuremcell}
% Measure (recursively) the width required for a math cell.
%    \begin{macrocode}
\def\measuremcell #1&{%
    \ifx #1\\ \ifnum\l@dcolcount=0\let\NEXT\relax%
              \else\l@dcheckcols%
                    \l@dcolcount=0%
                    \let\NEXT\measuremcell%
              \fi%
    \else\setbox\hilfsbox=\hbox{$\displaystyle{#1}$}%
      \stepl@dcolcount%
      \l@dsetmaxcolwidth%
      \let\NEXT\measuremcell%
    \fi\NEXT}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\measuretcell}
% Measure (recursively) the width required for a text cell.
%    \begin{macrocode}
\def\measuretcell #1&{%
    \ifx #1\\ \ifnum\l@dcolcount=0\let\NEXT\relax%
              \else\l@dcheckcols%
                    \l@dcolcount=0%
                    \let\NEXT\measuretcell%
              \fi%
    \else\setbox\hilfsbox=\hbox{#1}%
      \stepl@dcolcount%
      \l@dsetmaxcolwidth%
      \let\NEXT\measuretcell%
    \fi\NEXT}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\measuremrow}
% Measure (recursively) the width required for a math row.
%    \begin{macrocode}
\def\measuremrow #1\\{%
   \ifx #1&\let\NEXT\relax%
   \else\measuremcell #1&\\&\\&%
      \let\NEXT\measuremrow%
   \fi\NEXT}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\measuretrow}
% Measure (recursively) the width required for a text row.
%    \begin{macrocode}
\def\measuretrow #1\\{%
   \ifx #1&\let\NEXT\relax%
   \else\measuretcell #1&\\&\\&%
     \let\NEXT\measuretrow%
   \fi\NEXT}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\edtabcolsep}
% The length \protect\cs{edtabcolsep} controls the distance between columns.
%    \begin{macrocode}
\newskip\edtabcolsep
\global\edtabcolsep=10pt

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\variab}
%    \begin{macrocode}
\newcommand{\variab}{\relax}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dcheckcols}
% Check that the number of columns is consistent.
%    \begin{macrocode}
\newcommand*{\l@dcheckcols}{%
  \ifnum\l@dcolcount=1\relax
  \else
    \ifnum\l@dampcount=1\relax
    \else
      \ifnum\l@dcolcount=\l@dampcount\relax
      \else
        \l@d@err@UnequalColumns
      \fi
    \fi
    \l@dampcount=\l@dcolcount
  \fi}

%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\edfilldimen}
% A length.
%    \begin{macrocode}
\newdimen\edfilldimen
\edfilldimen=0pt

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@addcolcount}
% \begin{macro}{\theaddcolcount}
% A counter to hold the number of a column. We use a roman number so
% that we can grab the column dimension from \protect\cs{dcol}.
% We do not use the \cs{roman} \LaTeX\ command, because some packages, like \package{babel} can override it in some specific cases (Greek, for example).
%    \begin{macrocode}
\newcounter{addcolcount}
  \renewcommand{\theaddcolcount}{\romannumeral \c@addcolcount}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsubsection{Tabular typesetting}
% \begin{macro}{\setmcellright}
% Typeset (recursively) cells of display math right justified.
%    \begin{macrocode}
\def\setmcellright #1&{\def\edlabel##1{}%
       \let\edindex\nulledindex
       \ifx #1\\ \ifnum\l@dcolcount=0%\removelastskip
                     \let\Next\relax%
                \else\l@dcolcount=0%
                      \let\Next=\setmcellright%
                \fi%
       \else%
           \disablel@dtabfeet%
           \stepl@dcolcount%
           \disable@notes%
           \setbox\hilfsbox=\hbox{$\displaystyle{#1}$}%
           \restore@notes%
           \letsforverteilen%
           \hskip\hilfsskip$\displaystyle{#1}$%
           \hskip\edtabcolsep%
           \let\Next=\setmcellright%
       \fi\Next}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\settcellright}
% Typeset (recursively) cells of text right justified.
%    \begin{macrocode}
\def\settcellright #1&{\def\edlabel##1{}%
       \let\edindex\nulledindex
       \ifx #1\\ \ifnum\l@dcolcount=0%\removelastskip
                    \let\Next\relax%
                \else\l@dcolcount=0%
                      \let\Next=\settcellright%
                \fi%
       \else%
           \disablel@dtabfeet%
           \stepl@dcolcount%
           \disable@notes%
           \setbox\hilfsbox=\hbox{#1}%
           \restore@notes%
           \letsforverteilen%
           \hskip\hilfsskip#1%
           \hskip\edtabcolsep%
           \let\Next=\settcellright%
       \fi\Next}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmcellleft}
% Typeset (recursively) cells of display math left justified.
%    \begin{macrocode}
\def\setmcellleft #1&{\def\edlabel##1{}%
    \let\edindex\nulledindex
    \ifx #1\\ \ifnum\l@dcolcount=0 \let\Next\relax%
              \else\l@dcolcount=0%
                    \let\Next=\setmcellleft%
              \fi%
     \else   \disablel@dtabfeet%
              \stepl@dcolcount%
              \disable@notes%
              \setbox\hilfsbox=\hbox{$\displaystyle{#1}$}%
              \restore@notes%
              \letsforverteilen%
              $\displaystyle{#1}$\hskip\hilfsskip\hskip\edtabcolsep%
              \let\Next=\setmcellleft%
     \fi\Next}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\settcellleft}
% Typeset (recursively) cells of text left justified.
%    \begin{macrocode}
\def\settcellleft #1&{\def\edlabel##1{}%
    \let\edindex\nulledindex
    \ifx #1\\ \ifnum\l@dcolcount=0 \let\Next\relax%
              \else\l@dcolcount=0%
                    \let\Next=\settcellleft%
              \fi%
     \else   \disablel@dtabfeet%
              \stepl@dcolcount%
              \disable@notes%
              \setbox\hilfsbox=\hbox{#1}%
              \restore@notes%
              \letsforverteilen%
              #1\hskip\hilfsskip\hskip\edtabcolsep%
              \let\Next=\settcellleft%
     \fi\Next}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmcellcenter}
% Typeset (recursively) cells of display math centered.
%    \begin{macrocode}
\def\setmcellcenter #1&{\def\edlabel##1{}%
    \let\edindex\nulledindex
    \ifx #1\\ \ifnum\l@dcolcount=0\let\Next\relax%
             \else\l@dcolcount=0%
                   \let\Next=\setmcellcenter%
             \fi%
    \else    \disablel@dtabfeet%
             \stepl@dcolcount%
             \disable@notes%
             \setbox\hilfsbox=\hbox{$\displaystyle{#1}$}%
             \restore@notes%
             \letsforverteilen%
             \hskip 0.5\hilfsskip$\displaystyle{#1}$\hskip0.5\hilfsskip%
             \hskip\edtabcolsep%
             \let\Next=\setmcellcenter%
     \fi\Next}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\settcellcenter}
% Typeset (recursively) cells of text centered.
%    \begin{macrocode}
\def\settcellcenter #1&{\def\edlabel##1{}%
    \let\edindex\nulledindex
    \ifx #1\\ \ifnum\l@dcolcount=0 \let\Next\relax%
              \else\l@dcolcount=0%
                    \let\Next=\settcellcenter%
              \fi%
     \else   \disablel@dtabfeet%
              \stepl@dcolcount%
              \disable@notes%
              \setbox\hilfsbox=\hbox{#1}%
              \restore@notes%
              \letsforverteilen%
              \hskip 0.5\hilfsskip #1\hskip 0.5\hilfsskip%
              \hskip\edtabcolsep%
              \let\Next=\settcellcenter%
     \fi\Next}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NEXT}
%    \begin{macrocode}
\let\NEXT=\relax

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmrowright}
% Typeset (recursively) rows of right justified math.
%    \begin{macrocode}
\def\setmrowright #1\\{%
    \ifx #1& \let\NEXT\relax
    \else \centerline{\setmcellright #1&\\&\\&}
          \let\NEXT=\setmrowright
    \fi\NEXT}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\settrowright}
% Typeset (recursively) rows of right justified text.
%    \begin{macrocode}
\def\settrowright #1\\{%
    \ifx #1& \let\NEXT\relax
    \else \centerline{\settcellright #1&\\&\\&}
          \let\NEXT=\settrowright
    \fi\NEXT}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmrowleft}
% Typeset (recursively) rows of left justified math.
%    \begin{macrocode}
\def\setmrowleft #1\\{%
    \ifx #1&\let\NEXT\relax
    \else \centerline{\setmcellleft #1&\\&\\&}
          \let\NEXT=\setmrowleft
    \fi\NEXT}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\settrowleft}
% Typeset (recursively) rows of left justified text.
%    \begin{macrocode}
\def\settrowleft #1\\{%
    \ifx #1& \let\NEXT\relax
    \else \centerline{\settcellleft #1&\\&\\&}
          \let\NEXT=\settrowleft
    \fi\NEXT}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmrowcenter}
% Typeset (recursively) rows of centered math.
%    \begin{macrocode}
\def\setmrowcenter #1\\{%
    \ifx #1& \let\NEXT\relax%
    \else \centerline{\setmcellcenter #1&\\&\\&}
          \let\NEXT=\setmrowcenter
     \fi\NEXT}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\settrowcenter}
% Typeset (recursively) rows of centered text.
%    \begin{macrocode}
\def\settrowcenter #1\\{%
    \ifx #1& \let\NEXT\relax
    \else \centerline{\settcellcenter #1&\\&\\&}
          \let\NEXT=\settrowcenter
    \fi\NEXT}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\nullsetzen}
%
%    \begin{macrocode}
\newcommand{\nullsetzen}{%
    \stepl@dcolcount%
    \l@dcolwidth=0pt%
    \ifnum\l@dcolcount=30\let\NEXT\relax%
          \l@dcolcount=0\relax
    \else\let\NEXT\nullsetzen%
    \fi\NEXT}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\edatleft}
% \protect\cs{edatleft}\oarg{math}\marg{symbol}\marg{len}.
% Left \meta{symbol}, 2\meta{len} high with prepended \meta{math} vertically centered.
%    \begin{macrocode}
\newcommand{\edatleft}[3][\@empty]{%
  \ifx#1\@empty
    \vbox to 10pt{\vss\hbox{$\left#2\vrule width0pt height #3
                           depth 0pt \right. $\hss}\vfil}
  \else
    \vbox to 4pt{\vss\hbox{$#1\left#2\vrule width0pt height #3
                depth 0pt \right. $}\vfil}
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\edatright}
% \protect\cs{edatright}\oarg{math}\marg{symbol}\marg{len}.
% Right \meta{symbol}, 2\meta{len} high with appended \meta{math} vertically centered.
%    \begin{macrocode}
\newcommand{\edatright}[3][\@empty]{%
  \ifx#1\@empty
    \vbox to 10pt{\vss\hbox{$\left.\vrule width0pt height #3
                depth 0pt \right#2 $\hss}\vfil}
  \else
    \vbox to 4pt{\vss\hbox{$\left.\vrule width0pt height #3
                depth 0pt \right#2 #1 $}\vfil}
  \fi}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\edvertline}
% \protect\cs{edvertline}\marg{len} vertical line \meta{len} high.
%    \begin{macrocode}
\newcommand{\edvertline}[1]{\vbox to 8pt{\vss\hbox{\vrule height #1}\vfil}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\edvertdots}
% \protect\cs{edvertdots}\marg{len} vertical dotted line \meta{len} high.
%    \begin{macrocode}
\newcommand{\edvertdots}[1]{\vbox to 1pt{\vss\vbox to #1%
         {\cleaders\hbox{$\m@th\hbox{.}\vbox to 0.5em{ }$}\vfil}}}

%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\l@dtabaddcols}
%  \protect\cs{l@dtabaddcols}\marg{startcol}\marg{endcol} adds the widths of
% the columns \meta{startcol} through \meta{endcol} to \protect\cs{edfilldimen}.
% It is a \LaTeX\ style
% reimplementation of the original \protect\cs{@add@}.
%    \begin{macrocode}
\newcommand{\l@dtabaddcols}[2]{%
  \l@dcheckstartend{#1}{#2}%
  \ifl@dstartendok
  \setcounter{addcolcount}{#1}%
  \@whilenum \value{addcolcount}<#2\relax \do
  {\advance\edfilldimen by \the \csname dcol\theaddcolcount\endcsname
   \advance\edfilldimen by \edtabcolsep
   \stepcounter{addcolcount}}%
  \advance\edfilldimen by \the \csname dcol\theaddcolcount\endcsname
  \fi
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifl@dstartendok}
% \begin{macro}{\l@dcheckstartend}
% \protect\cs{l@dcheckstartend}\marg{startcol}\marg{endcol} checks that the values
% of \meta{startcol} and \meta{endcol} are sensible. If they are then
% \protect\cs{ifl@dstartendok} is set TRUE, otherwise it is set FALSE.
%    \begin{macrocode}
\newif\ifl@dstartendok
\newcommand{\l@dcheckstartend}[2]{%
  \l@dstartendoktrue
  \ifnum #1<\@ne
    \l@dstartendokfalse
    \led@err@LowStartColumn
  \fi
  \ifnum #2>30\relax
    \l@dstartendokfalse
    \led@err@HighEndColumn
  \fi
  \ifnum #1>#2\relax
    \l@dstartendokfalse
    \led@err@ReverseColumns
  \fi
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\edrowfill}
% \begin{macro}{\@edrowfill@}
% \begin{macro}{\@EDROWFILL@}
% \protect\cs{edrowfill}\marg{startcol}\marg{endcol}{fill}
% fills columns \meta{startcol} to \meta{endcol} inclusive with
% \meta{fill} (e.g. \protect\cs{hrulefill}, \protect\cs{upbracefill}).
% This is a \LaTeX\ style reimplementation and generalization of the
% original \protect\cs{waklam}, \protect\cs{Waklam}, \protect\cs{waklamec}, \protect\cs{wastricht}
% and \protect\cs{wapunktel} macros.
%    \begin{macrocode}
\newcommand*{\edrowfill}[3]{%
  \l@dtabaddcols{#1}{#2}%
  \hb@xt@ \the\l@dcolwidth{\hb@xt@ \the\edfilldimen{#3}\hss}}
\let\@edrowfill@=\edrowfill
\def\@EDROWFILL@#1#2#3{\@edrowfill@{#1}{#2}{#3}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \DescribeMacro{\edbeforetab}
% \DescribeMacro{\edaftertab}
% The macro \protect\cs{edbeforetab}\marg{text}\marg{math} puts \meta{text} at
% the left margin before array cell entry \meta{math}. Conversely,
% the macro \protect\cs{edaftertab}\marg{math}\marg{text} puts \meta{text}
% at the right margin after array cell entry \meta{math}.
% \protect\cs{edbeforetab} should be in the first column and \protect\cs{edaftertab} in the
% last column.
% The following macros support these.
%
% \begin{macro}{\leftltab}
% \protect\cs{leftltab}\marg{text} for \protect\cs{edbeforetab} in \protect\cs{ltab}.
%    \begin{macrocode}
\newcommand{\leftltab}[1]{%
  \hb@xt@\z@{\vbox{\edtabindent%
  \moveleft\Hilfsskip\hbox{\ #1}}\hss}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\leftrtab}
% \protect\cs{leftrtab}\marg{text}\marg{math} for \protect\cs{edbeforetab} in \protect\cs{rtab}.
%    \begin{macrocode}
\newcommand{\leftrtab}[2]{%
  #2\hb@xt@\z@{\vbox{\edtabindent%
    \advance\Hilfsskip by\dcoli%
    \moveleft\Hilfsskip\hbox{\ #1}}\hss}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\leftctab}
% \protect\cs{leftctab}\marg{text}\marg{math} for \protect\cs{edbeforetab} in \protect\cs{ctab}.
%    \begin{macrocode}
\newcommand{\leftctab}[2]{%
        \hb@xt@\z@{\vbox{\edtabindent\l@dcolcount=\l@dampcount%
        \advance\Hilfsskip by 0.5\dcoli%
        \setbox\hilfsbox=\hbox{\def\edlabel##1{}%
        \disablel@dtabfeet$\displaystyle{#2}$}%
        \advance\Hilfsskip by -0.5\wd\hilfsbox%
        \moveleft\Hilfsskip\hbox{\ #1}}\hss}%
        #2}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rightctab}
% \protect\cs{rightctab}\marg{math}\marg{text} for \protect\cs{edaftertab} in \protect\cs{ctab}.
%    \begin{macrocode}
\newcommand{\rightctab}[2]{%
        \setbox\hilfsbox=\hbox{\def\edlabel##1{}%
        \disablel@dtabfeet#2}\l@dampcount=\l@dcolcount%
        #1\hb@xt@\z@{\vbox{\edtabindent\l@dcolcount=\l@dampcount%
        \advance\Hilfsskip by 0.5\l@dcolwidth%
        \advance\Hilfsskip by -\wd\hilfsbox%
        \setbox\hilfsbox=\hbox{\def\edlabel##1{}%
        \disablel@dtabfeet$\displaystyle{#1}$}%
        \advance\Hilfsskip by -0.5\wd\hilfsbox%
        \advance\Hilfsskip by \edtabcolsep%
        \moveright\Hilfsskip\hbox{ #2}}\hss}%
        }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rightltab}
% \protect\cs{rightltab}\marg{math}\marg{text} for \protect\cs{edaftertab} in \protect\cs{ltab}.
%    \begin{macrocode}
\newcommand{\rightltab}[2]{%
        \setbox\hilfsbox=\hbox{\def\edlabel##1{}%
        \disablel@dtabfeet#2}\l@dampcount=\l@dcolcount%
        #1\hb@xt@\z@{\vbox{\edtabindent\l@dcolcount=\l@dampcount%
        \advance\Hilfsskip by\l@dcolwidth%
        \advance\Hilfsskip by-\wd\hilfsbox%
        \setbox\hilfsbox=\hbox{\def\edlabel##1{}%
        \disablel@dtabfeet$\displaystyle{#1}$}%
        \advance\Hilfsskip by-\wd\hilfsbox%
        \advance\Hilfsskip by\edtabcolsep%
        \moveright\Hilfsskip\hbox{ #2}}\hss}%
        }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rightrtab}
% \protect\cs{rightrtab}\marg{math}\marg{text} for \protect\cs{edaftertab} in \protect\cs{rtab}.
%    \begin{macrocode}
\newcommand{\rightrtab}[2]{%
        \setbox\hilfsbox=\hbox{\def\edlabel##1{}%
        \disablel@dtabfeet#2}%
        #1\hb@xt@\z@{\vbox{\edtabindent%
        \advance\Hilfsskip by-\wd\hilfsbox%
        \advance\Hilfsskip by\edtabcolsep%
        \moveright\Hilfsskip\hbox{ #2}}\hss}%
        }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rtab}
% \begin{macro}{\edbeforetab}
% \begin{macro}{\edaftertab}
% \protect\cs{rtab}\marg{body} typesets \meta{body} as an array with the
% entries right justified.
%
%
%    The process is first to measure the \meta{body} to get the column
% widths, and then in a second pass to typeset the body.
%    \begin{macrocode}
\newcommand{\rtab}[1]{%
  \l@dnullfills
    \def\edbeforetab##1##2{\leftrtab{##1}{##2}}%
    \def\edaftertab##1##2{\rightrtab{##1}{##2}}%
    \measurembody{#1}%
  \l@drestorefills
    \variab
    \setmrowright #1\\&\\%
    \enablel@dtabfeet}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\measurembody}
% \protect\cs{measurembody}\marg{body} measures the array \meta{body}.
%    \begin{macrocode}
\newcommand{\measurembody}[1]{%
  \disablel@dtabfeet%
  \l@dcolcount=0%
  \nullsetzen%
  \l@dcolcount=0
  \measuremrow #1\\&\\%
  \global\l@dampcount=1}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rtabtext}
% \protect\cs{rtabtext}\marg{body} typesets \meta{body} as a tabular with the
% entries right justified.
%    \begin{macrocode}
\newcommand{\rtabtext}[1]{%
 \l@dnullfills
    \measuretbody{#1}%
 \l@drestorefills
    \variab
    \settrowright #1\\&\\%
    \enablel@dtabfeet}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\measuretbody}
% \protect\cs{measuretbody}\marg{body} measures the tabular \meta{body}.
%    \begin{macrocode}
\newcommand{\measuretbody}[1]{%
  \disable@notes%
  \disablel@dtabfeet%
  \l@dcolcount=0%
  \nullsetzen%
  \l@dcolcount=0
  \measuretrow #1\\&\\%
  \restore@notes%
  \global\l@dampcount=1}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ltab}
% \begin{macro}{\edbeforetab}
% \begin{macro}{\edaftertab}
% Array with entries left justified.
%    \begin{macrocode}
\newcommand{\ltab}[1]{%
 \l@dnullfills
    \def\edbeforetab##1##2{\leftltab{##1}{##2}}%
    \def\edaftertab##1##2{\rightltab{##1}{##2}}%
    \measurembody{#1}%
  \l@drestorefills
    \variab
    \setmrowleft #1\\&\\%
    \enablel@dtabfeet}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ltabtext}
% Tabular with entries left justified.
%    \begin{macrocode}
\newcommand{\ltabtext}[1]{%
  \l@dnullfills
    \measuretbody{#1}%
  \l@drestorefills
    \variab
    \settrowleft #1\\&\\%
    \enablel@dtabfeet}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ctab}
% \begin{macro}{\edbeforetab}
% \begin{macro}{\edaftertab}
% Array with centered entries.
%    \begin{macrocode}
\newcommand{\ctab}[1]{%
  \l@dnullfills
    \def\edbeforetab##1##2{\leftctab{##1}{##2}}%
    \def\edaftertab##1##2{\rightctab{##1}{##2}}%
    \measurembody{#1}%
  \l@drestorefills
    \variab
    \setmrowcenter #1\\&\\%
    \enablel@dtabfeet}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ctabtext}
% Tabular with entries centered.
%    \begin{macrocode}
\newcommand{\ctabtext}[1]{%
  \l@dnullfills
    \measuretbody{#1}%
  \l@drestorefills
    \variab
    \settrowcenter #1\\&\\%
    \enablel@dtabfeet}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\spreadtext}
%
%    \begin{macrocode}
\newcommand{\spreadtext}[1]{%\l@dcolcount=\l@dampcount%
   \hb@xt@ \the\l@dcolwidth{\hbox{#1}\hss}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\spreadmath}
%
%    \begin{macrocode}
\newcommand{\spreadmath}[1]{%
  \hb@xt@ \the\l@dcolwidth{\hbox{$\displaystyle{#1}$}\hss}}

%    \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\HILFSskip}
% \begin{macro}{\Hilfsskip}
% More helpers.
%    \begin{macrocode}
\newskip\HILFSskip
\newskip\Hilfsskip

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\EDTABINDENT}
%
%    \begin{macrocode}
\newcommand{\EDTABINDENT}{%
    \ifnum\l@dcolcount=30\let\NEXT\relax\l@dcolcount=0%
    \else\stepl@dcolcount%
         \advance\Hilfsskip by\l@dcolwidth%
         \ifdim\l@dcolwidth=0pt\advance\hilfscount\@ne
         \else\advance\Hilfsskip by \the\hilfscount\edtabcolsep%
         \hilfscount=1\fi%
         \let\NEXT=\EDTABINDENT%
    \fi\NEXT}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\edtabindent}
% (was |\tabindent|)
%    \begin{macrocode}
\newcommand{\edtabindent}{%
    \l@dcolcount=0\relax
    \Hilfsskip=0pt%
    \hilfscount=1\relax
    \EDTABINDENT%
    \hilfsskip=\hsize%
    \advance\hilfsskip -\Hilfsskip%
    \Hilfsskip=0.5\hilfsskip%
    }%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\EDTAB}
% (was |\TAB|)
%    \begin{macrocode}
\def\EDTAB #1|#2|{%
    \setbox\tabhilfbox=\hbox{$\displaystyle{#1}$}%
    \setbox\tabHilfbox=\hbox{$\displaystyle{#2}$}%
    \advance\tabelskip -\wd\tabhilfbox%
    \advance\tabelskip -\wd\tabHilfbox%
    \unhbox\tabhilfbox\hskip\tabelskip%
    \unhbox\tabHilfbox}%

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\EDTABtext}
% (was |\TABtext|)
%    \begin{macrocode}
\def\EDTABtext #1|#2|{%
    \setbox\tabhilfbox=\hbox{#1}%
    \setbox\tabHilfbox=\hbox{#2}%
    \advance\tabelskip -\wd\tabhilfbox%
    \advance\tabelskip -\wd\tabHilfbox%
    \unhbox\tabhilfbox\hskip\tabelskip%
    \unhbox\tabHilfbox}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tabhilfbox}
% \begin{macro}{\tabHilfbox}
% Further helpers.
%    \begin{macrocode}
\newbox\tabhilfbox
\newbox\tabHilfbox

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsubsection{Environments}
% \begin{environment}{edarrayl}
% \begin{environment}{edarrayc}
% \begin{environment}{edarrayr}
% The `environment' forms for \protect\cs{ltab}, \protect\cs{ctab} and \protect\cs{rtab}.
%    \begin{macrocode}
\newenvironment{edarrayl}{\l@dcollect@body\ltab}{}
\newenvironment{edarrayc}{\l@dcollect@body\ctab}{}
\newenvironment{edarrayr}{\l@dcollect@body\rtab}{}

%    \end{macrocode}
% \end{environment}
% \end{environment}
% \end{environment}
%
% \begin{environment}{edtabularl}
% \begin{environment}{edtabularc}
% \begin{environment}{edtabularr}
% The `environment' forms for \protect\cs{ltabtext}, \protect\cs{ctabtext} and \protect\cs{rtabtext}.
%    \begin{macrocode}
\newenvironment{edtabularl}{\l@dcollect@body\ltabtext}{}
\newenvironment{edtabularc}{\l@dcollect@body\ctabtext}{}
\newenvironment{edtabularr}{\l@dcollect@body\rtabtext}{}

%    \end{macrocode}
% \end{environment}
% \end{environment}
% \end{environment}
%
%
% \section{Quotation's commands}
% \begin{macro}{\initnumbering@quote}
% This macro, called at the beginning of any numbered section, locally redefines the \verb+quotation+ and \verb+quote+ environments, in order to allow their use inside of numbered sections.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{initnumbering@sectcmd} becomes \protect\cs{initnumbering@quote}}
% \begin{macro}{\quotation}
% \begin{macro}{\endquotation}
% \begin{macro}{\quote}
% \begin{macro}{\endquote}
% \changes{v1.12.0}{2014/08/05}{\protect\cs{ledxxx} sectioning commands are deprecated and replaced by \protect\cs{eledxxx} commands.}
% \changes{v1.2.0}{2012/10/08}{Compatibility of \protect\cs{ledchapter} with the \emph{memoir} class.}
% \changes{v1.3.0}{2012/11/01}{\emph{Quotation} and {quote} environment inside numbered sections.}
% \changes{v1.4.1}{2012/11/16}{New option \emph{noquotation}.}
% \changes{v1.4.7}{2012/06/07}{Compatibility of sectioning commands with \protect\cs{autopar}.}
% \changes{v1.8.0}{2013/12/13}{Correction of sectioning commands in parallel texts.}
% \changes{v1.10.0}{2014/02/27}{Correction of sectioning commands in parallel texts.}
% \protect\cs{initnumbering@quote} defines  quotation environment.
%    \begin{macrocode}
\newcommand{\initnumbering@quote}{
    \ifnoquotation@\else
    \renewcommand{\quotation}{\par\leavevmode%
                                \parindent=1.5em%
                                \skipnumbering%
                                \ifautopar%
                                    \vskip-\parskip%
                                \else%
                                    \vskip\topsep%
                                \fi%
                                \global\leftskip=\leftmargin%
                                \global\rightskip=\leftmargin%
                            }
    \renewcommand{\endquotation}{\par%
                             \global\leftskip=0pt%
                                \global\rightskip=0pt%
                                \leavevmode%
                                \skipnumbering%
                                \ifautopar%
                                    \vskip-\parskip%
                                \else%
                                    \vskip\topsep%
                                \fi%
                                }
    \renewcommand{\quote}{\par\leavevmode%
                                \parindent=0pt%
                                \skipnumbering%
                                \ifautopar%
                                    \vskip-\parskip%
                                \else%
                                    \vskip\topsep%
                                \fi%
                                \global\leftskip=\leftmargin%
                                \global\rightskip=\leftmargin%
    }
    \renewcommand{\endquote}{\par%
                                \global\leftskip=0pt%
                                \global\rightskip=0pt%
                                \leavevmode%
                                \skipnumbering%
                                \ifautopar%
                                    \vskip-\parskip%
                                \else%
                                    \vskip\topsep%
                                \fi%
                                }
    \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \section{Section's title commands}
% \subsection{Commands to disable some feature}
% \begin{macro}{\ledsectnotoc}
% The \protect\cs{ledsectnotoc} only disables the \protect\cs{addcontentsline} macro.
%    \begin{macrocode}
\newcommand{\ledsectnotoc}{\let\addcontentsline\@gobblethree}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ledsectnomark}
% The \protect\cs{ledsectnomark} only disables the \protect\cs{chaptermark}, \protect\cs{sectionmark} and \protect\cs{subsectionmark} macros.
%    \begin{macrocode}
\newcommand{\ledsectnomark}{%
  \let\chaptermark\@gobble%
  \let\sectionmark\@gobble%
  \let\subsectionmark\@gobble%
}
%    \end{macrocode}
% \end{macro}
% \subsection{General overview}
% The system of \protect\cs{eledxxxx} commands to section text work like this:
% \begin{enumerate}
%     \item When one of these commands is called, \macpackage\  writes to an auxiliary files:
%     \begin{itemize}
%           \item The section level.
%           \item The section title.
%           \item The side (when \parpackage\  is used).
%           \item The pstart where the command is called.
%           \item If we have starred version or not.
%     \end{itemize}
%   \item \macpackage\ adds the title of the section to pstart, as  normal content. This is to enable critical notes.
%   \item When \LaTeX\ is run a other time, this file is read. That:
%    \begin{itemize}
%         \item Adds the pstart number to a list of pstarts where a sectioning command is used.
%         \item Defines a command, the name of which contains the pstart number, and which calls the normal \LaTeX\ sectioning command.
%    \end{itemize}
%   \item This last command is called when the pstart is effectively printed.
% \end{enumerate}
% \subsection{\protect\cs{beforeeledchapter} command}
% We do not define commands for \protect\cs{eledsection} and related if the \verb+noeledsec+ option is loaded.
% We use \protect\package{etoolbox} tests and not the \protect\cs{ifxxx}\ldots\protect\cs{else}\ldots\protect\cs{fi} structure to prevent problem of expansions with command after the \protect\cs{ifxxx} which contains \protect\cs{fi}.
% As we patch command inside this test, we need to change the category code of \# character \emph{before} \protect\cs{notbool} statement, because the second argument is read with the standard catcode (read \thetexbook to understand when the catcode's change has effect).
%    \begin{macrocode}
\catcode`\#=12
\notbool{@noeled@sec}{%
%    \end{macrocode}
% \begin{macro}{\beforeeledchapter}
% For technical reasons, not yet solved, page-breaking before chapters can't be made automatically by eledmac. Users have to use \protect\cs{beforeeledchapter}.
%    \begin{macrocode}
\ifl@dmemoir
  \newcommand\beforeeledchapter{%
  \clearforchapter%
}
\else
  \newcommand\beforeeledchapter{%
  \if@openright%
   \cleardoublepage%
  \else%
   \clearpage%
  \fi%
}
\fi
%    \end{macrocode}
% \end{macro}
% \subsection{Auxiliary commands}
% \begin{macro}{\print@leftmargin@eledsection}
% \begin{macro}{\print@rightmargin@eledsection}
% \protect\cs{print@leftmargin@eledsection} and \protect\cs{print@rightmargin@eledsection} are added by \macpackage\ inside the code of sectioning command, in order to affix lines numbers.
% They include tests for RTL languages.
%    \begin{macrocode}
\def\print@rightmargin@eledsection{%
  \if@eled@sectioning%
    \begingroup%
    \if@RTL%
        \let\llap\rlap%
        \let\leftlinenum\rightlinenum%
        \let\leftlinenumR\rightlinenumR%
        \let\l@drd@ta\l@dld@ta%
        \let\l@drsn@te\l@dlsn@te%
    \fi%
    \hfill\l@drd@ta \csuse{LR}{\l@drsn@te}%
    \endgroup%
  \fi%
}%

\def\print@leftmargin@eledsection{%
  \if@eled@sectioning%
    \leavevmode%
    \begingroup%
    \if@RTL%
        \let\rlap\llap%
        \let\rightlinenum\leftlinenum%
        \let\rightlinenumR\leftlinenumR%
        \let\l@dld@ta\l@drd@ta%
        \let\l@dlsn@te\l@drsn@te%
    \fi%
    \l@dld@ta\csuse{LR}{\l@dlsn@te}%
    \endgroup%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Patching standard commands}
% \begin{macro}{\M@sect}
% \begin{macro}{\@mem@old@ssect}
% \begin{macro}{\@makechapterhead}
% \begin{macro}{\@makechapterhead}
% \begin{macro}{\@makeschapterhead}
% \begin{macro}{\@sect}
% \begin{macro}{\@ssect}
% \changes{v1.12.5}{2014/08/28}{Debug \protect\cs{eledchapter} in parallel with \protect\package{memoir}}
% \changes{v1.14.2}{2014/12/17}{Debug \protect\cs{edtext} after starred sectioning commands when using \protect\ltxclass{memoir} class.}
% We have to patch \LaTeX, \protect\ltxclass{book} and \protect\ltxclass{memoir} sectioning commands in order to:
% \begin{itemize}
%  \item Disable \protect\cs{edtext} inside.
%  \item Disable page breaking (for \protect\cs{chapter}).
%  \item Add line numbers and sidenotes.
% \end{itemize}
% Unfortunately, Maïeul Rouquette was not able to try if \protect\ltxclass{memoir} is loaded. That is why \protect\package{eledmac} tries to define for both standard class and \protect\ltxclass{memoir} class.
%
%
%    \begin{macrocode}
\AtBeginDocument{%


\pretocmd{\M@sect}
  {\let\old@edtext=\edtext%
  \let\edtext=\dummy@edtext@showlemma%
  }
  {}
  {}

\apptocmd{\M@sect}
  {\let\edtext=\old@edtext}
  {}
  {}

\patchcmd{\M@sect}
  { #9}
  { #9%
  \print@rightmargin@eledsection%
  }
  {}
  {}

\patchcmd{\M@sect}
  {\hskip #3\relax}
  {\hskip #3\relax%
  \print@leftmargin@eledsection%
  }
  {}
  {}

\patchcmd{\@mem@old@ssect}
  {#5}
  {#5%
  \print@leftmargin@eledsection%
  }
  {}
  {}

\patchcmd{\@mem@old@ssect}
  {\hskip #1}
  {\hskip #1%
  \print@rightmargin@eledsection%
  }
  {}
  {}



\patchcmd{\scr@startchapter}{\if@openright\cleardoublepage\else\clearpage\fi}{%
  \if@eled@sectioning\else%
    \ifl@dprintingpages\else%
      \if@openright\cleardoublepage\else\clearpage\fi%No clearpage inside a \Pages: will keep critical notes from printing on the title page. Here for scrbook.
    \fi%
  \fi%
  }
  {}
  {}

\patchcmd{\@makechapterhead}
  {#1}
  {\print@leftmargin@eledsection%
    #1%
  \print@rightmargin@eledsection%
  }
  {}
  {}

\patchcmd{\@makechapterhead}% For BIDI
  {\if@RTL\raggedleft\else\raggedright\fi}%
  {\if@eled@sectioning\else%
    \if@RTL\raggedleft\else\raggedright\fi%
  \fi%
  }%
  {}%
  {}%

\patchcmd{\@makeschapterhead}
  {#1}
  {\print@leftmargin@eledsection%
    #1%
   \print@rightmargin@eledsection%
  }
  {}
  {}

\pretocmd{\@sect}
  {\let\old@edtext=\edtext
  \let\edtext=\dummy@edtext@showlemma%
  }
  {}
  {}

\apptocmd{\@sect}
  {\let\edtext=\old@edtext}
  {}
  {}

\pretocmd{\@ssect}
  {\let\old@edtext=\edtext%
  \let\edtext=\dummy@edtext@showlemma%
  }
  {}
  {}

\apptocmd{\@ssect}
  {\let\edtext=\old@edtext}
  {}
  {}

%    \end{macrocode}
% \changes{v1.14.1}{2014/12/15}{Debug sectioning commands when using both \protect\package{handout} and \protect\package{hyperref} package.}
% \protect\package{hyperref} also redefines  \protect\cs{@sect}. That is why, when manipulating arguments, we patch \protect\cs{@sect} and the same only if \protect\package{hyperref} is not used. If it is, we patch the \protect\cs{NR} commands.
%    \begin{macrocode}
\@ifpackageloaded{nameref}{

  \patchcmd{\NR@sect}
    {#8}
    {#8%
    \print@rightmargin@eledsection%
    }
    {}
    {}

  \patchcmd{\NR@sect}
    {\hskip #3\relax}
    {\hskip #3\relax%
    \print@leftmargin@eledsection%
    }
    {}
    {}

  \patchcmd{\NR@ssect}
    {#5}
    {#5%
    \print@rightmargin@eledsection%
    }
    {}
    {}

  \patchcmd{\NR@ssect}
    {\hskip #1}
    {\hskip #1%
    \print@leftmargin@eledsection%
    }
    {}
    {}
  }%
  {
  \patchcmd{\@sect}
    {#8}
    {#8%
    \print@rightmargin@eledsection%
    }
    {}
    {}

  \patchcmd{\@sect}
    {\hskip #3\relax}
    {\hskip #3\relax%
    \print@leftmargin@eledsection%
    }
    {}
    {}

  \patchcmd{\@ssect}
    {#5}
    {#5%
    \print@rightmargin@eledsection%
    }
    {}
    {}

  \patchcmd{\@ssect}
    {\hskip #1}
    {\hskip #1%
    \print@leftmargin@eledsection%
    }
    {}
    {}
  }%
}%
%    \end{macrocode}
% Close the \verb+\notbool{@noeled@sec}+ statement.
% Also, we have finished patching the commands, using \# with a catcode equal to 12, so we are restoring the normal catcode for \#.
%    \begin{macrocode}
{}}%
\protect\catcode`\#=6 %Space NEEDS by \catcode
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\chapter}
% We patch the \protect\cs{chapter} command even if the \option{noeledsec} option is called, because we can use \cs{chapter} in the optional argument of a \cs{pstart} in parallel typesetting.
%    \begin{macrocode}
\AtBeginDocument{%
\patchcmd{\chapter}{\clearforchapter}{%
  \if@eled@sectioning\else%
    \ifl@dprintingpages\else%
      \clearforchapter%
    \fi%
  \fi%
  }%
  {}%
  {}%

\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{%
  \if@eled@sectioning\else%
    \ifl@dprintingpages%
      \endgraf%
    \else%
      \if@openright\cleardoublepage\else\clearpage\fi%No clearpage inside a \Pages: will keep critical notes from printing on the title page. Here for classical  classes
    \fi%
  \fi%
  }%
  {}%
  {}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\if@eled@sectioning}
% The boolean \protect\cs{if@eled@sectioning} is set to true when a sectioning command is called by a \protect\cs{eledxxx} command, and set to false after. It is used to enable/disable line number printing.
%    \begin{macrocode}
\newif\if@eled@sectioning%
%    \end{macrocode}
% \end{macro}
%  We reopen a new \verb+\notbool{@noeled@sec}+ statement, as we will define the \cs{elesection} commands.
%    \begin{macrocode}
\notbool{@noeled@sec}{%
%    \end{macrocode}
% \subsection{Main code of \protect\cs{eledxxx} commands}
% \begin{macro}{\eled@sectioning@out}
% \protect\cs{eled@sectioning@out} is the output file, to dump the pstarts where a sectioning command is used.
%    \begin{macrocode}
\newwrite\eled@sectioning@out
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\eledchapter}
% \begin{macro}{\eledsection}
% \begin{macro}{\eledsubsection}
% \begin{macro}{\eledsubsubsection}
% \begin{macro}{\eledchapter*}
% \begin{macro}{\eledsection*}
% \begin{macro}{\eledsubsection*}
% \begin{macro}{\eledsubsubsection*}
% And now, the user sectioning commands, which write to the file, and also add content as a ``normal'' line.
%    \begin{macrocode}
\newcommand{\eledchapter}[2][]{%
  \disable@familiarnotes%
  #2%
  \restore@familiarnotes%
  \ifledRcol%
    \immediate\write\eled@sectioningR@out{%
      \string\eled@chapter{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{}{R}
      }%
  \else%
    \immediate\write\eled@sectioning@out{%
      \string\eled@chapter{#1}{\unexpanded{#2}}{\the\pstarts@read@L}{}{}%
      }%
  \fi%
}

\newcommand{\eledsection}[2][]{%
  \disable@familiarnotes%
  #2%
  \restore@familiarnotes%
  \ifledRcol%
    \immediate\write\eled@sectioningR@out{%
      \string\eled@section{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{}{R}
      }%
  \else%
    \immediate\write\eled@sectioning@out{%
      \string\eled@section{#1}{\unexpanded{#2}}{\the\pstarts@read@L}{}{}%
      }%
  \fi%
}

\newcommand{\eledsubsection}[2][]{%
  \disable@familiarnotes%
  #2%
  \restore@familiarnotes%
  \ifledRcol%
    \immediate\write\eled@sectioningR@out{%
      \string\eled@subsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{}{R}
      }%
  \else%
    \immediate\write\eled@sectioning@out{%
      \string\eled@subsection{#1}{\unexpanded{#2}}{\the\pstarts@read@L}{}{}%
      }%
  \fi%
}
\newcommand{\eledsubsubsection}[2][]{%
  \disable@familiarnotes%
  #2%
  \restore@familiarnotes%
  \ifledRcol%
    \immediate\write\eled@sectioningR@out{%
      \string\eled@subsubsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{}{R}
      }%
  \else%
    \immediate\write\eled@sectioning@out{%
      \string\eled@subsubsection{#1}{\unexpanded{#2}}{\the\pstarts@read@L}{}{}%
      }%
  \fi%
}


\WithSuffix\newcommand\eledchapter*[2][]{%
  \disable@familiarnotes%
  #2%
  \restore@familiarnotes%
  \ifledRcol%
    \immediate\write\eled@sectioningR@out{%
      \string\eled@chapter{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{*}{R}
      }%
  \else%
    \immediate\write\eled@sectioning@out{%
      \string\eled@chapter{#1}{\unexpanded{#2}}{\the\pstarts@read@L}{*}{}%
      }%
  \fi%
}

\WithSuffix\newcommand\eledsection*[2][]{%
  \disable@familiarnotes%
  #2%
  \restore@familiarnotes%
  \ifledRcol%
    \immediate\write\eled@sectioningR@out{%
      \string\eled@section{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{*}{R}
      }%
  \else%
    \immediate\write\eled@sectioning@out{%
      \string\eled@section{#1}{\unexpanded{#2}}{\the\pstarts@read@L}{*}{}%
      }%
  \fi%
}

\WithSuffix\newcommand\eledsubsection*[2][]{%
  \disable@familiarnotes%
  #2%
  \restore@familiarnotes%
  \ifledRcol%
    \immediate\write\eled@sectioningR@out{%
      \string\eled@subsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{*}{R}
      }%
  \else%
    \immediate\write\eled@sectioning@out{%
      \string\eled@subsection{#1}{\unexpanded{#2}}{\the\pstarts@read@L}{*}{}%
      }%
  \fi%
}

\WithSuffix\newcommand\eledsubsubsection*[2][]{%
  \disable@familiarnotes%
  #2%
  \restore@familiarnotes%
  \ifledRcol%
    \immediate\write\eled@sectioningR@out{%
      \string\eled@subsubsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{*}{R}
      }%
  \else%
    \immediate\write\eled@sectioning@out{%
      \string\eled@subsubsection{#1}{\unexpanded{#2}}{\the\pstarts@read@L}{*}{}%
      }%
  \fi%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Macros written in the auxiliary file}
% \begin{macro}{\eled@chapter}
% \begin{macro}{\eled@section}
% \begin{macro}{\eled@subsection}
% \begin{macro}{\eled@subsubsection}
% The sectioning macros, called in the auxiliary file. They have five arguments:
% \begin{enumerate}
%   \item Optional arguments of \LaTeX\ sectioning command.
%   \item Mandatory arguments of \LaTeX\ sectioning command.
%   \item Pstart number.
%   \item Side: \verb+R+ if right, nothing if left.
%   \item Starred or not.
% \end{enumerate}
%    \begin{macrocode}
\def\eled@chapter#1#2#3#4#5{%
    \ifstrempty{#4}%
      {%
      \ifstrempty{#1}%
        {%
        \csgdef{eled@sectioning@#3#5}{\let\edtext=\dummy@edtext@showlemma\chapter{#2}}%
        \csgdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\chaptermark{#2}}%
        }%Need for \pairs, because of using parbox.
        {%
        \csgdef{eled@sectioning@#3#5}{\let\edtext=\dummy@edtext@showlemma\chapter[#1]{#2}}%
        \csgdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\chaptermark{#2}}%Need for \pairs, because of using parbox.
        }%
      }%
      {%
      \ifstrempty{#1}%
        {\csgdef{eled@sectioning@#3#5}{\let\edtext=\dummy@edtext@showlemma\chapter*{#2}}}%
        {\csgdef{eled@sectioning@#3#5}{\let\edtext=\dummy@edtext@showlemma\chapter*[#1]{#2}}}%Bug in LaTeX!
      }%
  \listcsgadd{eled@sections#5@@}{#3}%
    }
\def\eled@section#1#2#3#4#5{%
    \ifstrempty{#4}%
      {\ifstrempty{#1}%
        {%
        \csgdef{eled@sectioning@#3#5}{\section{#2}}%
        \csgdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\sectionmark{#2}}%Need for \pairs, because of using parbox.
        }%
        {%
        \csgdef{eled@sectioning@#3#5}{\section[#1]{#2}}%
        \csgdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\sectionmark{#1}}%Need for \pairs, because of using parbox.
        }%
      }%
      {\ifstrempty{#1}%
        {\csgdef{eled@sectioning@#3#5}{\section*{#2}}}%
        {\csgdef{eled@sectioning@#3#5}{\section*[#1]{#2}}}%Bug in LaTeX!
      }
  \listcsgadd{eled@sections#5@@}{#3}%
    }
\def\eled@subsection#1#2#3#4#5{%
    \ifstrempty{#4}%
      {\ifstrempty{#1}%
        {%
        \csgdef{eled@sectioning@#3#5}{\subsection{#2}}%
        \csgdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\csuse{subsectionmark}{#2}}%Need for \pairs, because of using parbox. \csuse in case of \subsectionmark is not defined (book)
        }%
        {%
        \csgdef{eled@sectioning@#3#5}{\subsection[#1]{#2}}%
        \csgdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\csuse{subsectionmark}{#1}}%Need for \pairs, because of using parbox. \csuse in case of \subsectionmark is not defined (book)
        }%
      }%
      {\ifstrempty{#1}%
        {\csgdef{eled@sectioning@#3#5}{\subsection*{#2}}}%
        {\csgdef{eled@sectioning@#3#5}{\subsection*[#1]{#2}}}%Bug in LaTeX!
      }
  \listcsgadd{eled@sections#5@@}{#3}%
    }
\def\eled@subsubsection#1#2#3#4#5{%
    \ifstrempty{#4}%
      {\ifstrempty{#1}%
        {\csgdef{eled@sectioning@#3#5}{\subsubsection{#2}}}%
        {\csgdef{eled@sectioning@#3#5}{\subsubsection[#1]{#2}}}%
      }%
      {\ifstrempty{#1}%
        {\csgdef{eled@sectioning@#3#5}{\subsubsection*{#2}}}%
        {\csgdef{eled@sectioning@#3#5}{\subsubsection*[#1]{#2}}}%Bug in LaTeX!
      }
  \listcsgadd{eled@sections#5@@}{#3}%
    }

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% End of the conditional test about \verb+noeledsec+ option.
%    \begin{macrocode}
}{}
%    \end{macrocode}
% \section{Page breaking or no page breaking depending of specific lines}
% By default, page breaks are automatic.  However, the user can define lines which will force page breaks, or prevent page breaks around one specific line.
% On the first run, the line-list file records the line number of where the page break is being changed (either forced, or prevented).
% On the next run, page breaks occur either before or after this line, depending on how the user sets the command.  The default setting is after the line.
% \begin{macro}{\normal@page@break}
% \protect\cs{normal@page@break} is an \protect\package{etoolbox} list which contains the absolute line number of the last line, for each page.
%    \begin{macrocode}
\def\normal@page@break{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\prev@pb}
% \begin{macro}{\prev@nopb}
% The \protect\cs{l@prev@pb} macro is a \protect\package{etoolbox} list, which contains the lines in which page breaks occur (before or after).
% The \protect\cs{l@prev@nopb} macro is a \protect\package{etoolbox} list, which contains the lines with NO page break before or after.
%    \begin{macrocode}
\def\l@prev@pb{}
\def\l@prev@nopb{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\ledpb}
% \begin{macro}{\ledpbnum}
% \begin{macro}{\lednopb}
% \begin{macro}{\lednopbnum}
% The \protect\cs{ledpb} macro writes the call to \protect\cs{led@pb} in line-list file.
% The \protect\cs{ledpbnum} macro writes the call to \protect\cs{led@pbnum} in line-list file.
% The \protect\cs{lednopb} macro writes the call to \protect\cs{led@nopb} in line-list file.
% The \protect\cs{lednopbnum} macro writes the call to \protect\cs{led@nopbnum} in line-list file.
%    \begin{macrocode}
\newcommand{\ledpb}{\write\linenum@out{\string\led@pb}}
\newcommand{\ledpbnum}[1]{\write\linenum@out{\string\led@pbnum{#1}}}
\newcommand{\lednopb}{\write\linenum@out{\string\led@nopb}}
\newcommand{\lednopbnum}[1]{\write\linenum@out{\string\led@nopbnum{#1}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@pb}
% \begin{macro}{\led@pbnum}
% \begin{macro}{\led@nopb}
% \begin{macro}{\led@nopbnum}
% The \protect\cs{led@pb} adds the absolute line number in the \protect\cs{prev@pb} list.
% The \protect\cs{led@pbnum} adds the argument in the \protect\cs{prev@pb} list.
% The \protect\cs{led@nopb} adds the absolute line number in the \protect\cs{prev@nopb} list.
% The \protect\cs{led@nopbnum} adds the argument in the \protect\cs{prev@nopb} list.
%    \begin{macrocode}
\newcommand{\led@pb}{\listxadd{\l@prev@pb}{\the\absline@num}}
\newcommand{\led@pbnum}[1]{\listxadd{\l@prev@pb}{#1}}
\newcommand{\led@nopb}{\listxadd{\l@prev@nopb}{\the\absline@num}}
\newcommand{\led@nopbnum}[1]{\listxadd{\l@prev@nopb}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\ledpbsetting}
% \begin{macro}{\led@pb@setting}
% The \protect\cs{ledpbsetting} macro only changes the value of \protect\cs{led@pb@macro}, for which the default value is \verb+before+.
%    \begin{macrocode}
\def\led@pb@setting{before}
\newcommand{\ledpbsetting}[1]{\gdef\led@pb@setting{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@check@pb}
% \begin{macro}{\led@check@nopb}
% The \protect\cs{led@check@pb} and \protect\cs{led@check@nopb} are called before or after each line.
% They check if a page break must occur, depending on the current line and on the content of \protect\cs{l@pb}.
%    \begin{macrocode}
\newcommand{\led@check@pb}{\xifinlist{\the\absline@num}{\l@prev@pb}{\pagebreak[4]}{}}
\newcommand{\led@check@nopb}{%
    \IfStrEq{\led@pb@setting}{before}{%
      \xifinlist{\the\absline@num}{\l@prev@nopb}%
         {\numdef{\abs@prevline}{\the\absline@num-1}%
         \xifinlist{\abs@prevline}{\normal@page@break}%
           {\nopagebreak[4]\enlargethispage{\baselineskip}}%
           {}}%
         {}}%
       {}%
     {}%
    \IfStrEq{\led@pb@setting}{after}{%
      \xifinlist{\the\absline@num}{\l@prev@nopb}{%
        \xifinlist{\the\absline@num}{\normal@page@break}%
          {\nopagebreak[4]\enlargethispage{\baselineskip}}%
            {}%
}%
         {}}%
       {}%
     {}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Long verse: prevents being separated by a page break}
% \begin{macro}{\iflednopbinverse}
% The \protect\cs{lednopbinverse} boolean is set to false by default.
% If set to true, \macpackage\ will automatically prevent page breaks inside verse.
% The declaration is made at the beginning of the file, because it is used as a package option.
% \end{macro}
% \begin{macro}{\check@pb@in@verse}
% The \protect\cs{check@pb@in@verse} checks if a verse is broken in two page.
% If true, it adds:
% \begin{itemize}
%  \item The absolute line number of the first line of the verse -1  in the \protect\cs{led@pb} list, if the page break must occur before the verse.
%  \item The absolute line number of the first line of the verse -1  in the \protect\cs{led@nopb} list, if the page break must occur after the verse.
% \end{itemize}
%    \begin{macrocode}
\newcommand{\check@pb@in@verse}{%
    \ifinstanza\iflednopbinverse\ifinserthangingsymbol% Using stanzas and enabling page breaks in verse control, while on a hanging verse.
        \ifnum\page@num=\last@page@num\else%If we have change page
          \IfStrEq{\led@pb@setting}{before}{%
              \numgdef{\abs@line@verse}{\the\absline@num-1}%
              \ledpbnum{\abs@line@verse}%
            }{}%
          \IfStrEq{\led@pb@setting}{after}{%
              \numgdef{\abs@line@verse}{\the\absline@num-1}%
              \lednopbnum{\abs@line@verse}%
          }{}%
        \fi%
    \fi\fi\fi%
}
%    \end{macrocode}
% \end{macro}
% \section{Tools for \package{hyperref} package}
% \begin{macro}{\Hy@raisedlink@left}
% The \package{hyperref} package provides a \cs{Hy@raisedlink} command, to be used to add an anchor to the top of a line and not to the bottom of it.\footnote{\url{http://tex.stackexchange.com/a/17138/7712}.}
%
% However, this command disrupts the line breaking mechanism when it is called before any word.
% This is why \macpackage\ defines \cs{Hy@raisedlink@left} that is called to the left of words, at the beginning of \cs{edtext} or inside the \cs{edlabel} commands.\footnote{The code is inspired by an answer given by @unbonpetit.
% Thanks to him.
% \url{http://texnique.fr:80/osqa/questions/781/hyraisedlink-perturbe-la-maniere-dont-se-fait-la-coupure-de-ligne/801}.}
%
%    \begin{macrocode}
\def\Hy@raisedlink@left#1{%
    \ifvmode
        #1%
    \else
        \Hy@SaveSpaceFactor
        \llap{\smash{%
        \begingroup
            \let\HyperRaiseLinkLength\@tempdima
            \setlength\HyperRaiseLinkLength\HyperRaiseLinkDefault
            \HyperRaiseLinkHook
        \expandafter\endgroup
        \expandafter\raise\the\HyperRaiseLinkLength\hbox{%
            \Hy@RestoreSpaceFactor
            #1%
            \Hy@SaveSpaceFactor
        }%
        }}%
        \Hy@RestoreSpaceFactor
        \penalty\@M\hskip\z@\relax
    \fi
}
%    \end{macrocode}
% \end{macro}
% \section{Compatibility with \eledmac}
%
% Here, we define some commands for the \verb+eledmac-compat+ option.
%
%    \begin{macrocode}
\ifeledmaccompat@%

  \newcommand{\footnormalX}[1]{\arrangementX[#1]{normal}}%
  \newcommand{\footparagraphX}[1]{\arrangementX[#1]{paragraph}}%
  \newcommand{\foottwocolX}[1]{\arrangementX[#1]{twocol}}%
  \newcommand{\footthreecolX}[1]{\XarrangementX[#1]{threecol}}%

  \unless\ifnocritical@
    \newcommand{\footnormal}[1]{\Xarrangement[#1]{normal}}%
    \newcommand{\footparagraph}[1]{\Xarrangement[#1]{paragraph}}%
    \newcommand{\foottwocol}[1]{\Xarrangement[#1]{twocol}}%
    \newcommand{\footthreecol}[1]{\Xarrangement[#1]{threecol}}%
    \let\hsizetwocol\Xhsizetwocol
    \let\hsizethreecol\Xhsizethreecol
    \let\bhookXnote\Xbhooknote
    \let\boxsymlinenum\Xboxsymlinenum
    \let\symlinenum\Xsymlinenum
    \let\beforenumberinfootnote\Xbeforenumber
    \let\afternumberinfootnote\Xafternumber
    \let\beforeXsymlinenum\Xbeforesymlinenum
    \let\afterXsymlinenum\Xaftersymlinenum
    \let\inplaceofnumber\Xinplaceofnumber
    \let\Xlemmaseparator\lemmaseparator
    \let\afterlemmaseparator\Xafterlemmaseparator
    \let\beforelemmaseparator\Xbeforelemmaseparator
    \let\inplaceoflemmaseparator\Xinplaceoflemmaseparator
    \let\txtbeforeXnotes\Xtxtbeforenotes
    \let\afterXrule\Xafterrule
    \let\numberonlyfirstinline\Xnumberonlyfirstinline
    \let\numberonlyfirstintwolines\Xnumberonlyfirstintwolines
    \let\nonumberinfootnote\Xnonumberinfootnote
    \let\pstartinfootnote\Xpstart
    \let\pstartinfootnoteeverytime\Xpstarteverytime
    \let\onlyXpstart\Xonlypstart
    \let\Xnonumberinfootnote\Xnonumber
    \let\nonbreakableafternumber\Xnonbreakableafternumber
    \let\maxhXnotes\Xmaxhnotes
    \let\beforeXnotes\Xbeforenotes
    \let\boxlinenum\Xboxlinenum
    \let\boxlinenumalign\Xboxlinenumaligm
    \let\boxstartlinenum\Xboxstartlinenum
    \let\boxendlinenum\Xboxendlinenum
    \let\twolines\Xtwolines
    \let\morethantwolines\Xmorethantwolines
    \let\twolinesbutnotmore\Xtwolinesbutnotmore
    \let\twolinesonlyinsamepage\Xtwolinesonlyinsamepage
  \fi

  \unless\ifnofamiliar@
    \let\notesXwidthliketwocolumns\noteswidthliketwocolumnsX
  \fi
  \newcommandx{\parafootsep}[2][1,usedefault]{%
      \Xparafootsep[#1]{#2}%
      \parafootsepX[#1]{#2}
  }%

  \newcommandx{\afternote}[2][1,usedefault]{%
      \Xafternote[#1]{#2}%
      \afternoteX[#1]{#2}%
  }%

  \unless\ifnoend@
    \let\XendXtwolines\Xendtwolines
    \let\XendXmorethantwolines\Xendmorethantwolines
    \let\bhookXendnote\Xendbhooknote
    \let\boxXendlinenum\Xendboxlinenum%
    \let\boxXendlinenumalign\Xendboxlinenumalign%
    \let\boxXendstartlinenum\Xendboxstartlinenum%
    \let\boxXendendlinenum\Xendboxendlinenum%
    \let\XendXlemmaseparator\Xendlemmaseparator
    \let\XendXbeforelemmaseparator\Xendbeforelemmaseparator
    \let\XendXafterlemmaseparator\Xendafterlemmaseparator
    \let\XendXinplaceoflemmaseparator\Xendinplaceoflemmaseparator
  \fi

  \AtBeginDocument{%
    \ifdef\lineref{}{\let\lineref\edlineref}%
  }%


\fi%
%    \end{macrocode}
%
%</code>
% \newpage
% \appendix
% \let\oldthesection\thesection
% \renewcommand{\thesection}{Appendix \oldthesection}
% \renewcommand{\thesubsection}{\oldthesection.\arabic{subsection}}
% \section{Things to do when changing versions}
% \input{doc-include/migrate-mac.dtx}
% \section{Auxiliary softwares}
% This appendix lists some software and tools related to \package{reledmac} that may be useful.
% \subsection{\emph{samewords}}
% The \emph{samewords} program (Michael Stenskjær Christensen) automatically adds \cs{sameword} commands (\reff{sameword}) into a \verb+.tex+ file. \\
% \url{https://samewords.readthedocs.io/en/latest/}
% \subsection{critical-keys for \emph{Emacs}}
% The \emph{Emacs} editor has a package to help inserting \macpackage's commands (Juan Manuel Macías Chaín).\\
% \url{https://gitlab.com/maciaschain/critical-keys}
% \subsection{critical-marks for \emph{Emacs}}
% A set of functions for \emph{Emacs} that run in the export process from Org Mode to
% LaTeX and replace a series of simple textual marks with the basic \macpackage's commands (Juan Manuel Macías Chaín)
% \url{https://gitlab.com/maciaschain/critical-marks}
%\subsection{Import from TEI}
% \subsection{Import from TEI}
% There are multiple tools to convert from XML-TEI to \emph{reledmac}. Here is a non exhaustive-list:
% \begin{itemize}
% \item \url{http://ciham-digital.huma-num.fr/teicat/}
% \item \url{https://github.com/fizzbucket/tei_transformer}
% \item \url{https://github.com/TEIC/Stylesheets}
% \item \url{http://lombardpress.org/print/}
% \item \url{https://github.com/Jean-Baptiste-Camps/TEItoLaTeX}
% \end{itemize}
% Please, tell us if you know of other tools.
% \clearpage
% \bibliographystyle{alpha}
% \phantomsection
% \addcontentsline{toc}{section}{References}
% \begin{thebibliography}{WWW99}
%
% \bibitem[Bre96]{TABMAC}
% Herbert Breger.
% \newblock \tabmac.
% \newblock October 1996.
% \newblock (Available from CTAN in
%          \texttt{macros/plain/contrib/tabmac})
%
% \bibitem[Bur01]{POEMSCOLTUG}
% John Burt.
% \newblock `Typesetting critical editions of poetry'.
% \newblock \emph{TUGboat}, \textbf{22}, 4, pp 353--361, December 2001.
% \newblock (Code available from CTAN in
%          \texttt{macros/latex/contrib/poemscol})
%
% \bibitem[Eck03]{PARALLEL}
% Matthias Eckermann.
% \newblock \emph{The \protect\package{Parallel}-Package}.
% \newblock April 2003.
% \newblock (Available from CTAN in
%          \texttt{macros/latex/contrib/parallel})
%
% \bibitem[Fai03]{FOOTMISC}
% Robin Fairbairns.
% \newblock \emph{\protect\package{footmisc}\,---\,a portmanteau package for
%          customising footnotes in \LaTeX}.
% \newblock February 2003.
% \newblock (Available from CTAN in
%          \texttt{macros/latex/contrib/footmisc})
%
%
% \bibitem[LW90]{EDMACTUG}
% John Lavagnino and Dominik Wujastyk.
% \newblock `An overview of \edmac: a \textsc{Plain} TeX format for
%          critical editions'.
% \newblock \emph{TUGboat}, \textbf{11}, 4, pp. 623--643, November 1990.
% \newblock (Code available from CTAN in
%          \texttt{macros/plain/contrib/edmac})
%
% \bibitem[L\"{u}c03]{EDNOTES}
% Uwe L\"{u}ck.
% \newblock `\textsf{ednotes}\,---\,critical edition typesetting with LaTeX'.
% \newblock \emph{TUGboat}, \textbf{24}, 2, pp. 224--236, 2003.
% \newblock (Code available from CTAN in
%          \texttt{macros/latex/contrib/ednotes})
%
% \bibitem[Sul92]{EDSTANZA}
% Wayne G.~Sullivan.
% \newblock \emph{The file \texttt{edstanza.doc}}.
% \newblock June 1992.
% \newblock (Available from CTAN in
%          \texttt{macros/plain/contrib/edmac})
%
% \bibitem[Wil02]{MEMOIR}
% Peter Wilson.
% \newblock \emph{The \protect\package{memoir} class for configurable typesetting}.
% \newblock November 2002.
% \newblock (Available from CTAN in
%          \texttt{macros/latex/contrib/memoir})
%
% \bibitem[Wil04]{ELEDPAR}
% Peter Wilson and Maïeul Rouquette.
% \newblock \emph{Parallel typesetting for critical editions:
%               the \protect\package{eledpar} package}.
% \newblock December 2004.
% \newblock (Available from CTAN in
%          \texttt{macros/latex/contrib/ledmmac})
%
% \end{thebibliography}
%
% \Finale
% \phantomsection
% \addcontentsline{toc}{section}{Index}
% \PrintIndex
%
% \phantomsection
% \addcontentsline{toc}{section}{Change History}
% \PrintChanges
% \endinput
\endinput

% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%    Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%