aboutsummaryrefslogtreecommitdiff
path: root/ekdosis.dtx
blob: b925713e94e0f156d6a8d521fa860aee125e7727 (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
% \iffalse meta-comment
% 
% ekdosis -- Typesetting TEI xml-compliant critical editions
% Copyright (C) 2020--2021  Robert Alessi
% 
% Please send error reports and suggestions for improvements to Robert
% Alessi <alessi@robertalessi.net>
% 
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% 
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see
% <http://www.gnu.org/licenses/>.
% 
%<*internal>
\iffalse
%</internal>
%<*luapre>
--[[
This file is part of the `ekdosis' package

ekdosis -- Typesetting TEI xml-compliant critical editions
Copyright (C) 2020--2021  Robert Alessi

Please send error reports and suggestions for improvements to Robert
Alessi <alessi@robertalessi.net>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see
<http://www.gnu.org/licenses/>.
--]]

%</luapre>
%<*internal>
\fi
%</internal>
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{ekdosis.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{ekdosis}
%<*package>
    [2021/05/07 v1.3-dev Typesetting TEI xml-compliant critical editions]
%</package>
%<*driver>
\begin{filecontents}[noheader,overwrite]{bibdata.xml}
<?xml version="1.0" encoding="utf-8"?>
<listBibl xmlns="http://www.tei-c.org/ns/1.0">
  <biblStruct type="book" xml:id="ReynoldsWilson1991">
    <monogr>
      <title level="m">Scribes and Scholars</title>
      <author>
        <forename>L. D.</forename>
        <surname>Reynolds</surname>
      </author>
      <author>
        <forename>N. G.</forename>
        <surname>Wilson</surname>
      </author>
      <edition>3</edition>
      <imprint>
        <pubPlace>Oxford</pubPlace>
        <publisher>Clarendon Press</publisher>
        <date>1991</date>
      </imprint>
    </monogr>
  </biblStruct>
  <biblStruct type="book" xml:id="sDrak">
    <monogr>
      <title level="m">Punicorum libri septemdecim</title>
      <author>
        <forename>Tiberius Catius</forename>
        <surname>Silius Italicus</surname>
      </author>
      <editor>
        <forename>Arnold</forename>
        <surname>Drakenborch</surname>
      </editor>
      <edition>Trajecti ad Rhenum</edition>
      <imprint>
        <pubPlace>Utrecht</pubPlace>
        <date>1717</date>
      </imprint>
    </monogr>
  </biblStruct>
  <biblStruct type="book" xml:id="shGildon1710">
    <monogr>
      <title level="m">Works of Mr. William Shakespeare</title>
      <editor>
        <forename>Charles</forename>
        <surname>Gildon</surname>
      </editor>
      <imprint>
        <biblScope unit="volume">17</biblScope>
        <publisher>E. Curl and E. Sanders</publisher>
        <date>1710</date>
      </imprint>
    </monogr>
  </biblStruct>
  <biblStruct type="book" xml:id="shGildon1714">
    <monogr>
      <title level="m">Works of Mr. William Shakespeare</title>
      <editor>
        <forename>Charles</forename>
        <surname>Gildon</surname>
      </editor>
      <edition>2</edition>
      <imprint>
        <biblScope unit="volume">17</biblScope>
        <publisher>E. Curl and E. Sanders</publisher>
        <date>1714</date>
      </imprint>
    </monogr>
  </biblStruct>
  <biblStruct type="book" xml:id="shSewell1725">
    <monogr>
      <title level="m">Venus and Adonis, Tarquin and Lucrece, and Mr. Shakespeare's Miscellany Poems</title>
      <editor>
        <name>Sewell</name>
      </editor>
      <imprint>
        <publisher>A. Bettesworth</publisher>
        <date>1725</date>
      </imprint>
    </monogr>
  </biblStruct>
  <biblStruct type="book" xml:id="shEwing1771">
    <monogr>
      <title level="m">Poems, containing I. Venus and Adonis... IV. Sonnets</title>
      <author>
        <forename>William</forename>
        <surname>Shakespeare</surname>
      </author>
      <editor>
        <forename>T.</forename>
        <surname>Ewing</surname>
      </editor>
      <imprint>
        <pubPlace>Dublin</pubPlace>
        <date>1771</date>
      </imprint>
    </monogr>
  </biblStruct>
  <biblStruct type="book" xml:id="shHudson1856">
    <monogr>
      <title level="m">Works of W. Shakespeare</title>
      <editor>
        <forename>H.N.</forename>
        <surname>Hudson</surname>
      </editor>
      <imprint>
        <pubPlace>Boston</pubPlace>
        <publisher>Munroe</publisher>
        <date>1856</date>
      </imprint>
    </monogr>
  </biblStruct>
  <biblStruct type="book" xml:id="shWalsh1908">
    <monogr>
      <title level="m">Shakespeare's Complete Sonnets</title>
      <editor>
        <forename>C.M.</forename>
        <surname>Walsh</surname>
      </editor>
      <imprint>
        <date>1908</date>
      </imprint>
    </monogr>
  </biblStruct>
  <biblStruct type="book" xml:id="shButler1899">
    <monogr>
      <title level="m">Shakespeare's Sonnets</title>
      <editor>
        <forename>Samuel</forename>
        <surname>Butler</surname>
      </editor>
      <imprint>
        <publisher>Fifield</publisher>
        <date>1899</date>
      </imprint>
    </monogr>
  </biblStruct>
</listBibl>
\end{filecontents}
\begin{filecontents}[overwrite]{\jobname.bib}
@Article{Alessi2020,
  author =	 {Alessi, Robert},
  title =	 {ekdosis: Using Lua\LaTeX{} for Producing \texttt{TEI
                  xml}-Compliant Critical Editions and Highlighting
                  Parallel Writings},
  journaltitle = {Journal of Data Mining and Digital Humanities},
  date =	 {2020-11},
  issuetitle =   {Collecting, Preserving, and Disseminating Endangered
                  Cultural Heritage for New Understandings through
                  Multilingual Approaches},
  eprinttype =	 {jdmdh},
  eprint =	 {6536}
}

@Book{Caesar-BG-v2,
  author =	 {{Caesar}},
  title =	 {Gallic War},
  origtitle =	 {Guerre des Gaules},
  date =	 1987,
  origdate =	 1926,
  editor =	 {Constans, L.-A.},
  volume =	 2,
  pagination =	 {none},
  series =	 {Collection des Universités de France},
  publisher =	 {Les Belles Lettres},
  location =	 {Paris}
}

@Book{CaesarTr,
  author = 	 {{Caesar}},
  title = 	 {Gallic War},
  date =	 1869,
  editor =	 {McDevitte, W. A., and Bohn, W. S.},
  edition =	 1,
  series =	 {Harper's New Classical Library},
  publisher =	 {Harper \& Brothers},
  location =	 {New York}}

@MVBook{HomerMurray,
  author =	 {{Homer}},
  title =	 {The Odyssey},
  date =	 1919,
  editor =	 {Murray, A.T\adddot},
  volumes =	 2,
  publisher =	 {Harvard University Press -- William Heinemann},
  location =	 {Cambridge, MA. -- London}
}

@Book{McDonald1916,
  editor =	 {MacDonald Alden, Raymond},
  shorteditor =	 {MacDonald},
  title =	 {The Sonnets of Shakespeare},
  date =	 1916,
  titleaddon =	 {From the Quarto of 1609 with Variorum Readings and
                  Commentary},
  organization = {Houghton Mifflin Co.},
  publisher =	 {The Riverside Press Cambridge},
  options =	 {useauthor=false, useeditor=true},
  location =	 {Boston \& New York}
}

@Book{ReynoldsWilson1991,
  author =	 {Reynolds, L. D. and Wilson, N. G},
  title =	 {Scribes and Scholars},
  year =	 {1991},
  subtitle =	 {A Guide to the Translation of Greek and Latin
                  Literature},
  edition =	 {3},
  publisher =	 {Clarendon Press},
  location =	 {Oxford}
}

@Book{West1973,
  author =	 {West, Martin L.},
  title =	 {Textual Criticism and Editorial Technique},
  date =	 1973,
  titleaddon =	 {Applicable to Greek and Latin Texts},
  publisher =	 {B. G. Teubner},
  location =	 {Stuttgart}
}

@Online{DLL-TC,
  author =	 {{Digital Latin Library}},
  title =	 {Textual Criticism},
  url =
  {https://digitallatin.org/library-digital-latin-texts/textual-criticism},
  urldate =	 {2020-05-24}
}

@Online{Mastronarde.Tarrant2017,
  author =	 {Mastronarde, Donald J. and Tarrant, Richard J.},
  title =	 {Review: Guidelines for Encoding Critical Editions
                  for the Library of Digital Latin Texts},
  date =	 {2017-12-04},
  url =
  {https://classicalstudies.org/scs-blog/donald-j-mastronarde/review-guidelines-encoding-critical-editions-library-digital-latin},
  organization = {Society for Classical Studies}
}

@Online{TBE,
  author =	 {Van den Branden, Ron and Terras, Melissa and
                  Vanhoutte, Edward},
  title =	 {TEI by Example},
  urldate =	 {2020-08-04},
  url =		 {http://www.teibyexample.org}
}

@Software{extdash,
  title =	 {The Extdash package},
  titleaddon =	 {A range of dash commands for compound words},
  author =	 {Rozhenko, Alexander I.},
  url =		 {http://www.ctan.org/pkg/extdash},
  date =	 {2018-06-24},
  version =	 {1.3}
}

@Software{fnpos,
  title =	 {The Fnpos package},
  titleaddon =	 {Control the position of footnotes on the page},
  author =	 {Nakashima, Hiroshi},
  url =		 {http://www.ctan.org/pkg/fnpos},
  date =	 {2018-09-03},
  version =	 {1.0}
}

@Software{lineno,
  title =	 {The Lineno package},
  titleaddon =	 {Line numbers on paragraphs},
  author =	 {Lück, Uwe and Böttcher, Stephan},
  url =		 {http://www.ctan.org/pkg/lineno},
  date =	 {2005-11-02},
  version =	 {4.41}
}

@Software{memoir,
  title =	 {The Memoir package},
  titleaddon =	 {Typeset fiction, non-fiction and mathematical books},
  author =	 {Madsen, Lars and Wilson, Peter R.},
  url =		 {http://www.ctan.org/pkg/memoir},
  date =	 {2021-03-23},
  version =	 {3.7o}
}

@Software{paracol,
  title =	 {The Paracol package},
  titleaddon =	 {Multiple columns with texts “in parallel”},
  author =	 {Nakashima, Hiroshi},
  url =		 {http://www.ctan.org/pkg/paracol},
  date =	 {2018-12-31},
  version =	 {1.35}
}

@Software{polyglossia,
  title =	 {The Polyglossia package},
  titleaddon =	 {An alternative to babel for XeLaTeX and LuaLaTeX},
  author =	 {Charette, François and Reutenauer, Arthur},
  url =		 {http://www.ctan.org/pkg/polyglossia},
  date =	 {2020-04-08},
  version =	 {1.49}
}

@Software{babel,
  title =	 {The Babel package},
  titleaddon =	 {Multilingual support for Plain TeX or LaTeX},
  author =	 {Bezos López, Javier and Braams, Johannes L.},
  url =		 {http://www.ctan.org/pkg/babel},
  date =	 {2020-07-13},
  version =	 {3.47}
}

@Software{verse,
  title =	 {The Verse package},
  titleaddon =	 {Aids for typesetting simple verse},
  author =	 {Wilson, Peter R. and Robertson, Will},
  url =		 {http://www.ctan.org/pkg/verse},
  date =	 {2014-05-10},
  version =	 {2.4b}
}

@Software{arabluatex,
  title =	 {The Arabluatex package},
  titleaddon =	 {ArabTeX for LuaLaTeX},
  author =	 {Alessi, Robert},
  url =		 {http://ctan.org/pkg/arabluatex},
  date =	 {2020-03-23},
  version =	 {1.20}
}

@Software{icite,
  title =	 {The Icite package},
  titleaddon =	 {Indices locorum citatorum},
  author =	 {Alessi, Robert},
  url =		 {http://ctan.org/pkg/icite},
  date =	 {2020-03-05},
  version =	 {1.3a}
}

@Software{arabtex,
  title =	 {The Arabtex package},
  titleaddon =	 {Macros and fonts for typesetting Arabic},
  author =	 {Lagally, Klaus},
  url =
  {http://baobab.informatik.uni-stuttgart.de/ifi/bs/research/arab_e.html},
  date =	 {2004-03-11},
  version =	 {4.00}
}
\end{filecontents}
\begin{filecontents}[overwrite]{\jobname-ekd.cfg}
\footnotelayout{m}
\EnvtoTEI{ancientgreek}{p}[xml:lang="grc"]
\DeclareApparatus{fontium}[
        delim=\hskip0.75em,
        bhook=\textbf{Sources:}]
\DeclareApparatus{default}[
        delim=\hskip0.75em]
\DeclareApparatus{ltr}[
        delim=\hskip0.75em]
\DeclareApparatus{rtl}[
        direction=RL,
        sep={[ },
        delim=\hskip0.75em]
\DeclareWitness{M}{M}{\emph{Marcianus Gr.} 269}[
        settlement=Venice,
        institution=Marciana Library,
        msName=Marcianus Gr.,
        idno=269,
        origDate=s. X]
\DeclareHand{M1}{M}{M\textsuperscript{1}}[Emendatio scribae ipsius]
\DeclareHand{M2}{M}{M\textsuperscript{2}}[Manus posterior]
% Peter and John Story:
\DeclareWitness{pjA}{A}{Manuscript A Call No 123}
\DeclareWitness{pjB}{B}{Manuscript B Call No 456}
\DeclareWitness{pjC}{C}{Manuscript C Call No 789}
% Caesar's Gallic War:
\DeclareWitness{cA}{A}{\emph{Bongarsianus} 81}[
               msName=Bongarsianus,
               settlement=Amsterdam,
               idno=81,
               institution=University Library,
               origDate=s. IX--X]
\DeclareHand{cA1}{cA}{A\textsuperscript{1}}[\emph{Emendationes
               scribae ipsius}]
\DeclareWitness{cM}{M}{\emph{Parisinus Lat.} 5056}[
               origDate={s. XII}]
\DeclareWitness{cB}{B}{\emph{Parisinus Lat.} 5763}[
               origDate={s. IX--X}]
\DeclareWitness{cR}{R}{\emph{Vaticanus Lat.} 3864}[
               origDate={s. X}]
\DeclareWitness{cS}{S}{\emph{Laurentianus} R 33}[
               origDate={s. X}]
\DeclareWitness{cL}{L}{\emph{Londinensis} Br. Mus. 10084}[
               origDate={s. XI}]
\DeclareWitness{cN}{N}{\emph{Neapolitanus} IV, c. 11}[
               origDate={s. XII}]
\DeclareWitness{cT}{T}{\emph{Parisinus Lat.} 5764}[
               origDate={s. XI}]
\DeclareWitness{cf}{\emph{f}}{\emph{Vindobonensis} 95}[
               origDate={s. XII}]
\DeclareWitness{cU}{U}{\emph{Vaticanus Lat.} 3324}[
               origDate={s. XI}]
\DeclareWitness{cl}{\emph{l}}{\emph{Laurentianus} Riccard. 541}[
               origDate={s. XI--XII}]
\DeclareShorthand{ca}{α}{cA,cM,cB,cR,cS,cL,cN}
\DeclareShorthand{cb}{β}{cT,cf,cU,cl}
% Hippocrates Epidemics, Book 2:
\DeclareWitness{hV}{V}{\emph{Vaticanus Gr.} 276}
\DeclareWitness{hI}{I}{\emph{Parisinus Gr.} 2140}
\DeclareHand{hIac}{hI}{I\textsuperscript{ac}}[Lectio ante correctionem]
\DeclareHand{hIpc}{hI}{I\textsuperscript{pc}}[Lectio post correctionem]
\DeclareWitness{hR}{R}{\emph{Vaticanus Gr.} 277}
\DeclareWitness{hH}{H}{\emph{Parisinus Gr.} 2142}
\DeclareWitness{hGalE1.Q}{Gal.E1(Q)}{\emph{Parisinus Gr.}
  2174}[origDate=s. XIV]
\DeclareWitness{hGalE1.M}{Gal.E1(M)}{\emph{Monacencis Gr.}
  231}[origDate=s. XVI]
  \DeclareShorthand{hGalE1.M.Q}{Gal.E1(MQ)}{hGalE1.M,hGalE1.Q}
\DeclareSource{Lit}{Littré}
\DeclareSource{Erm}{Ermerins}
\DeclareSource{Sm}{Smith}
\DeclareSource{Gal}{Gal.}
\DeclareScholar{ego}{ego}[
                forename=Robert,
                surname=Alessi]
\DeclareShorthand{egomute}{\unskip}{ego}
\DeclareShorthand{hcodd}{codd.}{hV,hI,hR,hH}
\DeclareShorthand{hedd}{edd.}{Lit,Erm,Sm}
\DeclareShorthand{hegoscr}{\emph{scripsi}}{ego}
% Silius Italicus' Punica, IX, 30--2:
\DeclareWitness{sL}{L}{Laurentianus, plut, XXXVII, cod. 16}[
                      origDate=s. XV]
\DeclareWitness{sF}{F}{Florentianus, Bibl. Aed. Fl. Eccl. CXCVI}[
                      origDate=s. XV]                      
\DeclareWitness{sO}{O}{Oxoniensis Collegii Reginensis CCCXIV}[
                      origDate=s. XV]                      
\DeclareWitness{sV}{V}{Vaticanus lat. 1652}[
                      origDate=s. XV]
\DeclareSource{sDrak}{\emph{Drakenborch}}
% Homer, Odyssey
\DeclareScholar{hZen}{Zen.}[rawname=Zenodotus]
% Shakespeare's Sonnets:
\NewDocumentEnvironment{ekdcenter}{}{\par\centering}{\nobreak\par}
\NewDocumentCommand{\ekdlettrine}{mm}{%
  \adjustbox{valign=t,raise=-0.75ex}{\Huge #1}\textsc{#2}%
}
\TeXtoTEIPat{\ekdlettrine {#1}{#2}}{<hi rend="smallcaps">#1#2</hi>}
\DeclareSource{shGildon1710}{G}
\DeclareSource{shGildon1714}{G\textsuperscript{2}}
\DeclareSource{shSewell1725}{S}
\DeclareSource{shEwing1771}{E}
\DeclareSource{shHudson1856}{Hu\textsuperscript{2}}
\DeclareSource{shButler1899}{But}
\DeclareSource{shWalsh1908}{Wa}
\DeclareScholar{shGod}{Godwin}[rawname=Godwin]
\DeclareScholar{shStee}{Stee}[rawname=Steevens, note=Notes in Malone]
\end{filecontents}
\documentclass{ltxdoc}
 %\usepackage[letterpaper,margin=25mm,left=50mm,nohead]{geometry}
\usepackage[letterpaper,margin=1.25in,left=50mm,nohead]{geometry}
\usepackage{dox}
\doxitem{Option}{option}{options}
\usepackage{microtype}
\usepackage[no-math]{fontspec}
\defaultfontfeatures{Renderer=Harfbuzz}
\usepackage[latin.classic,greek.ancient,american]{babel}
\babelfont{rm}{Old Standard}
\babelfont{sf}[ItalicFont=NewCMSans10-BookOblique,
               BoldFont=NewCMSans10-Bold,
               BoldItalicFont=NewCMSans10-BoldOblique]
               {NewCMSans10-Book}
\babelfont{tt}[ItalicFont=NewCMMono10-BookItalic,
               BoldFont=NewCMMono10-Bold,
               BoldItalicFont=NewCMMono10-BoldOblique]
               {NewCMMono10-Book}
\babelfont[greek]{rm}[
      Script=Greek,
      RawFeature={+ss05;+ss06}
      ]{Old Standard}
\babelfont[greek]{sf}[Script=Greek]{NewCMSans10-Book}
\babelfont[greek]{tt}[Script=Greek]{NewCMMono10-Book}
\newfontfamily{\junicode}{Junicode}[
                Ligatures=TeX,
                RawFeature={+hist}]
\babeltags{ancientgreek = greek}
\def\sg#1{\textancientgreek{#1}}
\usepackage[Old Standard]{mathfont}
\usepackage[biblatex=true]{embrac}
\usepackage{chifoot}
\usepackage{arabluatex}
\usepackage[parnotes=roman, teiexport=tidy, poetry=verse]{ekdosis}
\AddxmlBibResource{bibdata.xml}
\usepackage{booktabs}
\usepackage{xltabular}
\usepackage[prevent-all]{widows-and-orphans}
\usepackage[shortcuts,nospacearound]{extdash}
\usepackage[american]{isodate}
\usepackage{nextpage}
\usepackage{spacingtricks}
\usepackage{csquotes}
\usepackage{relsize}
\usepackage{enumitem}
\setlist{nosep}
\setlist[itemize]{label=\textendash}
\setlist[enumerate,1]{label=(\alph*)}
\newlist{remarks}{enumerate}{10}
\setlist[remarks]{
  label*=\textsc{Rem.} \arabic*,
  left=0.25in,
  before=\smaller}
\usepackage{manfnt}
\usepackage{lettrine}
\newcommand\danger{\lettrine[loversize=-.5]{\textdbend}{\hskip6pt}}
\usepackage{metalogox}
\usepackage{hologo}
\usepackage{xcolor}
\newbool{nocolordoc}
\definecolor{ekdcolor}{RGB}{243,241,235}
\definecolor{cinnamon}{rgb}{0.82, 0.41, 0.12}
\ifbool{nocolordoc}{
  \colorlet{ekdcolor}{white}
  \colorlet{cinnamon}{black}}{}
\definecolor{gainsboro}{RGB}{222,222,222}
\PassOptionsToPackage{bookmarks=true}{hyperref}
\usepackage[obeyspaces]{url}
\usepackage[numbered]{hypdoc}
\usepackage[loadlang=en]{metastr}
\hypersetup{
  colorlinks,
  allcolors=cinnamon,
  linktocpage=true,
  pdftype={Text}
}
\usepackage{uri}
\labelformat{section}{sect.~#1}
\labelformat{subsection}{sect.~#1}
\labelformat{subsubsection}{sect.~#1}
\labelformat{figure}{fig.~#1}
\usepackage[defaultindex=none,citecmd=autocite]{icite}
\bibinput{ekdosis}
\usepackage[nospace,american]{varioref}
\newcommand\phts{\phantomsection}
\usepackage[style=oxnotes-inote,dashed]{biblatex}
\DeclareSourcemap{
    \maps[datatype=bibtex]{
      \map{
        \step[fieldsource=issuetitle]
        \step[fieldset=journalsubtitle,origfieldval]
    }
  }
}
\ifbool{nocolordoc}
{
  \usepackage{academicons}
  \def\oasymbol{\aiOpenAccess}
  \usepackage{biblatex-ext-oa}
}
{\usepackage[symbolpackage=tikz]{biblatex-ext-oa}}
\DeclareDelimFormat[bib,biblist]{nametitledelim}{\addcomma\space}
\DeclareDelimFormat[bib,biblist]{innametitledelim}{\addcomma\space}
\renewcommand*\newunitpunct{\addcomma\space}
\newcommand*{\halurl}[1]{http://hal.archives-ouvertes.fr/#1}
\DeclareFieldFormat{eprint:hal}{%
  \ifhyperref
    {\href{\halurl{#1}}{hal:~\nolinkurl{#1}}}
    {hal:~\nolinkurl{#1}}}
\DeclareFieldAlias{eprint:HAL}{eprint:hal}
\DeclareOpenAccessEprintUrl[always]{hal}{%
  http://hal.archives-ouvertes.fr/\thefield{eprint}}
\DeclareOpenAccessEprintAlias{HAL}{hal}
\newcommand*{\jdmdhurl}[1]{https://jdmdh.episciences.org/#1}
\DeclareFieldFormat{eprint:jdmdh}{%
  \ifhyperref
    {\href{\jdmdhurl{#1}}{jdmdh:~\nolinkurl{#1}}}
    {jdmdh:~\nolinkurl{#1}}}
\DeclareFieldAlias{eprint:JDMDH}{eprint:jdmdh}
\DeclareOpenAccessEprintUrl[always]{jdmdh}{%
  https://jdmdh.episciences.org/\thefield{eprint}}
\DeclareOpenAccessEprintAlias{JDMDH}{jdmdh}
\addbibresource{ekdosis.bib}
\metaset{titletext}{%
  \metapick[#1]{title}%
  \metacompose[#1]{subtitle}{\metaget[sep]{subtitle}}{}{}}
\metaset[print]{titletext}{%
  \metatitleline[print]{title}%
  \metatitleline[print]{subtitle}%
  \metatitleline[print]{author}%
  \metatitleline[print]{contactemail}%
  \metatitlelinetwo[print]{date}[print]{draft}}
\metaset[skip]{subtitle}{\vspace{1ex}}
\metaset[skip]{author}{\vspace{2ex}}
\metaset[skip]{date}{\vspace{1ex}}
\metaset[style]{title}{\LARGE}
\metaset[style]{author}{\large}
\metaset[sep]{draft}{ -- }
\metasetlang{en-US}
\metaset{title}{ἔκδοσις}
\metaset{date}{\filedate}
\metaset{draft}{\fileversion}
\metaset{subject}{TEI xml-compliant critical editions}
\metaset{subtitle}{Typesetting TEI xml-Compliant Critical Editions}
\metaset[print]{subtitle}{Typesetting \texttt{TEI xml}-Compliant
  Critical Editions}
\metaset{author}{Robert Alessi}
\metaset{keywords}{LaTeX, Lua, TEI xml, multilingual critical
  editions, alignment, segmentation}
\metaset{contactemail}{alessi@roberalessi.net}
\metaset[print]{contactemail}{\mailto[ekdosis]{alessi@robertalessi.net}}
\metaset{contacturl}{http://www.roberalessi.net}
\metaset{partof}{The ekdosis Package}
\metaset[print]{partof}{The \textsf{ekdosis} Package}
\metaset{copyrightowner}{\metapick[#1]{author}}
\metaset{copyrightdate}{2020--2021}
\metaset{licensemessage}{Permission is granted to copy, distribute
  and/or modify this document under the terms of the GNU Free
  Documentation License, Version 1.3 or any later version published by
  the Free Software Foundation; with no Invariant Sections, no
  Front-Cover Texts, and no Back-Cover Texts.  A copy of the license
  is included in the section entitled ``GNU Free Documentation
  License''.}
\metaset{licenseurl}{https://www.gnu.org/licenses/fdl-1.3.html}
\metaset[print]{licenseurl}{%
  \url{https://www.gnu.org/licenses/fdl-1.3.html}}
\metaset[cmd]{licenselogo}{\includegraphics[scale=0.75]{#1}}
\metawritepdfinfo
\metawritepdfaux
\metawritepdfpreamble
\metawritepdfcontact
\metawritepdfrights
\usepackage{multicol}
\setlength\IndexMin{100pt}
\usepackage{tocloft}
\newlistof{listing}{lol}{List of listings}
\renewcommand\cfttocprehook{\begin{multicols}{2}}
\renewcommand\cfttocposthook{\end{multicols}}
\renewcommand\cfttoctitlefont{\Large\bfseries}
\renewcommand\cftlolprehook{\begin{multicols}{2}}
\renewcommand\cftlolposthook{\end{multicols}}
\renewcommand\cftloltitlefont{\Large\bfseries}
\usepackage{units}
\newcommand*\tred[1]{\textcolor{red}{#1}}
\usepackage{fbox}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\NewDocumentCommand{\pointto}{m}{%
  \tikz[remember picture] \draw[>->,color=blue,overlay] (0em,0.5ex) to
  ([shift={(0.5em,0pt)}]pic cs:#1);%
  \tikz[remember picture] \draw[color=gray, overlay]
  ([shift={(0.5em,0.5ex)}]pic cs:#1) circle [radius=8pt];}
\NewDocumentCommand{\pointtol}{m}{%
  \tikz[remember picture] \draw[>->,color=blue,overlay] (0em,0.5ex) to
  [bend left] ([shift={(0.5em,0pt)}]pic cs:#1);%
  \tikz[remember picture] \draw[color=gray, overlay]
  ([shift={(0.5em,0.5ex)}]pic cs:#1) circle [radius=8pt];}
\NewDocumentCommand{\pointtor}{m}{%
  \tikz[remember picture] \draw[>->,color=blue,overlay] (0em,0.5ex) to
  [bend right] ([shift={(0.5em,0pt)}]pic cs:#1);%
  \tikz[remember picture] \draw[color=gray, overlay]
  ([shift={(0.5em,0.5ex)}]pic cs:#1) circle [radius=8pt];}
\NewDocumentCommand{\pointtoer}{m}{%
  \tikz[remember picture] \draw[>->,color=blue,overlay] (0em,0.5ex) to
  [bend right] ([shift={(0em,0pt)}]pic cs:#1);%
  \tikz[remember picture] \draw[color=gray, overlay]
  ([shift={(-0.5em,0.5ex)}]pic cs:#1) ellipse [x radius=45pt, y
  radius=6pt];}
\usepackage[breakable, skins, xparse]{tcolorbox}
\tcbset{colback=white, boxrule=0.4pt, colframe=cinnamon,
  breakable}
\usepackage[newfloat]{minted}
\labelformat{listing}{listing~#1}
\ifbool{nocolordoc}{\usemintedstyle{bw}}{}
\setminted{bgcolor=ekdcolor,linenos, fontsize=\small}
\newminted[ekdlua]{lua}{bgcolor={}, linenos, fontsize=\relsize{-0.5},
  xleftmargin=12pt, breaklines, numberblanklines=false, numbersep=3pt}
\renewcommand{\theFancyVerbLine}{\normalfont\smaller\arabic{FancyVerbLine}}
\usepackage[contents]{colordoc}
\newcommand{\cls}[1]{\textsf{#1}\index{#1=#1 (class)}}
\newcommand{\pkg}[1]{\textsf{#1}\index{#1=#1 (package)}}
\newcommand{\env}[1]{\texttt{#1}\index{#1=#1 (environment)}}
\backgroundcolor{c}{ekdcolor}
\usepackage{caption}
\captionsetup[listing]{position=above,skip=-1ex}
\usepackage{needspace}
\NewDocumentCommand{\captof}{O{listing} m O{}}{%
  \bgroup
  \needspace{5\baselineskip}%
  \vskip 1ex plus 2pt minus 2pt%
  \captionof{#1}{#2}%
  #3%
  \egroup}
\NewDocumentCommand{\newfeature}{o}{%
  \leavevmode
  \IfNoValueTF{#1}
  {\marginpar{\hfill\emph{New feature}}}
  {\marginpar{\hfill\emph{New feature} #1}}%
  \ignorespaces
}
% \usepackage{etoc}
% \etocsettocdepth{paragraph}
% \newcommand{\ekdtableofcontents}{%
%   \begingroup
%   \etocsetstyle{section}{}{}
%   {\etocsavedsectiontocline{%
%       \numberline{\etocnumber}\etocname}{\etocpage}}{}
%   \etocsetstyle{subsection}{}{}
%   {\etocsavedsubsectiontocline{%
%       \numberline{\etocnumber}\etocname}{\etocpage}}{}%
%   \etocsetstyle{subsubsection}{}{}
%   {\etocsavedsubsubsectiontocline{%
%       \numberline{\etocnumber}\etocname}{\etocpage}}{}%
%   \etocsetstyle{paragraph}{}{\leftskip2cm\rightskip 2.2em \parfillskip
%     0pt plus 1fil\relax \nobreak}
%   {\noindent\etocname{} \etocpage{} }{\par}%
%   \etocmulticolstyle[2]{\section*{Contents}}
%   \pdfbookmark[1]{Contents}{toc}
%   \tableofcontents
%   \endgroup}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
 %\OnlyDescription
\begin{document}
\DocInput{\jobname.dtx}
\PrintChanges
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \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         \~}
%
% \GetFileInfo{\jobname.dtx}
% \DoNotIndex{\newcommand,\newenvironment,\begin,\begingroup}
% \DoNotIndex{\bgroup,\def,\edef,\egroup,\else,\expandafter,\endgroup}
% \DoNotIndex{\fi,\ifdefined,\luadirect,\luastring,\luastringN}
% \DoNotIndex{\luastringO,\NewDocumentCommand,\space,\unexpanded}
%
% \pdfbookmark[1]{\metaterm{title}}{title}
% \begin{tcolorbox}[
%   colframe=black,
%   enhanced,
%   drop lifted shadow,
%   colback=white,
%   boxrule=.25mm,
%   halign=center,
%   center
%   ]
%   \metapick[print]{titletext}
% \end{tcolorbox}
%
% \tableofcontents
% \listoflistings
%
% \changes{v0.99a}{2020/07/08}{First public release (documentation in
% progress)}
% \changes{v1.0}{2020/08/14}{Documentation complete}
%
% \begin{abstract}
%   \pkg{ekdosis} is a Lua\LaTeX{} package designed for
%   multilingual critical editions. It can be used to typeset texts
%   and different layers of critical notes in any direction accepted
%   by Lua\TeX. Texts can be arranged in running paragraphs or on
%   facing pages, in any number of columns which in turn can be
%   synchronized or not. In addition to printed texts,
%   \pkg{ekdosis} can convert \texttt{.tex} source files so as to
%   produce \texttt{TEI xml}-compliant critical
%   editions. Database-driven encoding under \LaTeX{} then allows
%   extraction of texts entered segment by segment according to
%   various criteria: main edited text, variant readings, translations
%   or annotated borrowings between texts. It is published under the
%   terms of the GNU General Public License (GPL) version 3.
% \end{abstract}
%
% \section*{License and Disclaimer}
% \addcontentsline{toc}{section}{License and disclamer}
% \subsection*{License Applicable to this Document}
% \pdfbookmark[2]{Licence applicable to this document}{copyright-doc}
% \leavevmode\marginpar{\hfill\texttt{fdl1.3}}
% \metapick[print]{rightstext} (See below \vref{sec:fdl}.)
%
% \subsection*{License Applicable to the Software}
% \pdfbookmark[2]{Licence applicable to the software}{copyright-soft}
% \label{sec:license-software}
%
% \pkg{ekdosis} --- \metapick[print]{subtitle}
% \metapick[print]{copyrightstatement}
%
% Please send error reports and suggestions for improvements to Robert
% Alessi:
% \begin{itemize}
% \item email: \mailto[ekdosis package]{Robert Alessi <alessi@roberalessi.net>}
% \item website: \url{http://www.robertalessi.net/ekdosis}
% \item development: \url{http://git.robertalessi.net/ekdosis}
% \item comments, feature requests, bug reports:
% \url{https://gitlab.com/ralessi/ekdosis/issues}
% \end{itemize}
%
% \leavevmode\marginpar{\hfill\texttt{gpl3+}}
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see
% \href{http://www.gnu.org/licenses}%
% {\texttt{<http://www.gnu.org/licenses/>}}.
%
% This release of \pkg{ekdosis} consists of the following
% source files:
% \begin{itemize}
% \item |ekdosis.ins|
% \item |ekdosis.dtx|
% \item |ekdosis.el|
% \item |Makefile|
% \end{itemize}
%
% \section{Introduction}
% \label{sec:introduction}
% \begin{comment}
%   \begin{keyfigure}{l={fig:grid-typesetting},c={Grid Typesetting
%     (which never came into existence)}, t={Each square in the grid
%     has a side length of \unit[10]{pt}. Therefore, the distance
%     between the last line of the text and the first line of the
%     apparatus is here approximately \unit[25]{pt}.}}
%     \centering
%     \begin{tikzpicture}
%       \draw[gainsboro,thin] (0.5,0.5) grid [step=10pt] (10,5); %
%       \path node [align=justify, text width=8cm] at (5.5,3) {%
%       I saw my friend Peter at the station yesterday. We were both
%       in a great mood.  \enquote{How nice to find you here!} he
%       said. I chuckled to myself, recalling the last time we
%       met.\par
%       \rule{3cm}{0.01cm}\par\footnotesize%
%       \textbf{1}~saw A] met B\hskip1em Peter A] John B \hskip1em
%       \textbf{2}~great A] good B\hskip1em \textbf{2--3}~How
%       nice... said A] \emph{om.} B\hskip1em \textbf{4} \emph{post}
%       met \emph{add.} there B.}; \node at (0,3) {\scriptsize
%       $\approx$ \unit[25]{pt}}; \draw [->] (0,2.875) -- (0,2.025);
%     \end{tikzpicture}
%   \end{keyfigure}
% \end{comment}
% 
% The reader will find here, by way of introduction, a summarized
% version of the first part of an article published in the
% \mkbibemph{\citefield{Alessi2020}{journaltitle}} as a contribution
% to a Digital Humanities workshop held at Stanford University
% (\printdate{2019-04-15}).\footcite{Alessi2020}
%
% The name of this package, \pkg{ekdosis}, derives from a Greek
% action noun\---\sg{ἔκδοσις}\---the meaning of which is:
% \enquote{publishing a book}, and also in concrete sense: \enquote{a
% publication, treatise}. For us moderns, this term refers to a long
% tradition of scholarly work consisting in establishing from
% manuscript evidence the texts of Greek and Latin classics that were
% handled down through the Middle Ages to the time of the first
% printed editions. Of course, this definition is extendible to other
% languages as well. The basic premise is that critical editions
% exhibit reconstructed texts from manuscript evidence either under
% the title of the edited text (direct tradition) or from explicit
% citations or parallel passages or translations in other languages
% (indirect tradition).
%
% Whether in print or digital, critical editions come with an
% apparatus criticus in which is mentioned all the evidence that was
% used to build the edited text. Arguably, it is precisely on this
% common point that the two kind of editions part ways for reading a
% traditional, well written apparatus criticus is only meant for
% experienced readers. Getting oneself familiarized with its many
% conventional rules is not unrelated to learning a language, equipped
% with technical terms, grammar rules and style embellishments, which
% came into existence out of over three centuries of scholarly
% attainments. Nevertheless, whereas this language is immediately
% accessible to human mind's ability to use language and interpret
% conventional symbols, it is quite inaccessible to a computer unless
% every item of information has been encoded in the rather dumb format
% that is suited to machines.
%
% On the other hand, editions in print have their own limitations. For
% example, every detail that editors of classical texts decide to
% discard to save space, regardless to its relevance to the purpose of
% the edition, is lost permanently as in the case of dialectal
% coloring of ancient books. Furthermore, passages collected as
% indirect tradition are only available as references in the
% \emph{apparatus testium} and cannot be referred to the original
% text. As a result, the reader is refrained from bestowing attention
% upon major parallel passages to understand better difficult passages.
%
% To conclude on these issues, print publications and digital editions
% are often contrasted as they belonged to two different
% worlds.\footnote{For a good illustration of this point, see
% \cite[\mkbibquote{Content, not Display}]{DLL-TC}.}  It is commonly
% said that the content of editions in print is the result of the
% binding of the book itself as an object, whereas digital editions,
% in which format and presentation are by definition separated from
% content, are free from limitations coming from such bindings. To sum
% up from the foregoing considerations, this statement is likely to be
% qualified: as already seen above, the apparatus criticus must be
% looked at as a brilliant production of mind refined by centuries of
% scholarly tradition\---and surely tradition must go on\---arguably
% not as compact paragraphs that require special and painful training
% to be \enquote*{decoded}. On the other hand, what editions in print
% do not provide are what \citename{Mastronarde.Tarrant2017}{author}
% have called \enquote{actionable texts for use in digital research},%
% {\interfootnotelinepenalty=10000\footcite{Mastronarde.Tarrant2017}}
% namely database-driven texts allowing the reader to select
% annotations and display or arrange translations, parallel passages
% or borrowings in a variety of ways.
% 
% \pkg{ekdosis} can be seen as an attempt at combining the two
% approaches.
%
% \subsection{Requirements}
% \label{sec:requirements}
% Please refer to \vref{ref:ekdrequirements}.
%
% \subsection{Features}
% \label{sec:features}
% A list of the main features of \pkg{ekdosis} follows:---
% \begin{enumerate}
% \item \phts\label{it:multicol-feature}\emph{Multilingual critical
%   editions\/}: \pkg{ekdosis} can be used to typeset any number of
%   texts in any direction accepted by \hologo{LuaTeX}. Running
%   paragraphs of text can be arranged in any number of columns,
%   either on single or facing pages, which in turn can be
%   synchronized or not. \pkg{ekdosis} is also suitable for complex
%   layouts as in the case of Arabic poetry or images where three-way
%   alignment is required, or diagrams, \emph{\&c}.
% \item \phts\label{it:multilayer-feature}\emph{Apparatus criticus\/}:
%   Edited texts can receive multiple layers of apparatus, e.g.\
%   apparatus criticus (to record variant readings), apparatus fontium
%   (to collect references to texts quoted or cited in the edited
%   text), apparatus testium (to collect testimonia or parallel
%   passages), or any kind of short notes to be printed on the same
%   page as the edited text, \emph{\&c}.
% \item \texttt{TEI xml} output: \pkg{ekdosis} can be instructed to
%   output both PDF and \texttt{TEI xml} files at the same time.
% \item \emph{Database-driven encoding} under \LaTeX{} of texts
%   entered segment by segment allows for alignment of parallel texts
%   from multilingual corpora.
% \end{enumerate}
%
% Before going into detail, the following simple example will give the
% reader a general idea of the method of encoding with
% \pkg{ekdosis} authoritative texts composed of lemmata, in a way
% that is very close to \texttt{TEI xml} encoding:---
%
% \captof{The \enquote{Peter/John} basic example}[\label{lst:pj1}]
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\begin{ekdosis}
  I 
  \app{
    \lem{saw}
    \rdg{met}
  }
  my friend \app{\lem{Peter}\rdg{John}} at the station yesterday.
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% PDF output:---
% \medskip
% 
% \needspace{7\baselineskip}
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%   I 
%   \app{
%     \lem{saw}
%     \rdg{met}
%     }
%   my friend
%   \app{
%     \lem{Peter}
%     \rdg{John}
%     }
%   at the station yesterday.
%   \end{specimen}
% \end{alignment}
%
% \texttt{TEI xml} output:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>I 
<app>
  <lem>saw</lem>
  <rdg>met</rdg>
</app>my friend 
<app>
  <lem>Peter</lem>
  <rdg>John</rdg>
</app>at the station yesterday.</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% As can be seen from \vref{lst:pj1}, the edition text is inserted in
% the \env{ekdosis} environment (l.~1 to 8). Then two
% \cs{app}\marg{apparatus entry} commands (ll.~3 and 7) contain the
% lemma (\cs{lem}\marg{lemma}), namely the reading that is accepted by
% the editor, and at least one variant reading
% (\cs{rdg}\marg{reading}, ll.~5 and 7). As the listing shows, the
% editor is free to lay out the code in a legible manner to the eye:
% the first lemma above spans several lines whereas the second one is
% written in sequence without spaces.
%
% In the PDF output, the edition text is printed in the upper part of
% the page, above the line, and naturally shows the accepted
% readings. The margins are used for numeration. In the apparatus
% criticus, below the line, reference to the text is made by
% specifying the number of the line and if several entries refer to
% the same line, numbers are not repeated. Instead, entries are
% separated from one another by a broad horizontal space. Finally, a
% square bracket is used inside entries to distinguish the lemma from
% the variant readings.
%
% Furthermore, as said above, if a \texttt{TEI xml} output be
% required, \pkg{ekdosis} compiles an additional |.xml| file an
% excerpt of which is provided above.
%
% \section{The Basics of \pkg{ekdosis}}
% \label{sec:ekdosis-basics}
%
% \subsection{Loading the Package\---General Options}
% \label{sec:load-general-options}
%
% \pkg{ekdosis} is loaded in the preamble like so:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\usepackage{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
% 
% \pkg{ekdosis} may be loaded with five optional \enquote*{named
% arguments} either of which is set using the syntax
% \meta{key}$=$\meta{value}. The description of the optional arguments
% follows.
%
% \danger The reader is invited to refer to the relevant sections of
% this documentation for more information on how to use them.
% 
% \DescribeOption{layout}\phts\label{ref:layout-opt}
% |layout|$=$\verb+float|footins+\hfill\tcboxverb{Default: float}\\
% By default, layers of critical notes are inserted as a floating
% environment to be printed at the bottom of pages. |layout=footins|
% can be set to insert critical notes in the default footnote block
% which can be considered to be a special kind of float that is
% printed at the bottom of pages. In this case, the apparatus criticus
% will be inserted between regular numbered footnotes, but will carry
% no footnote mark of its own.
%
% \DescribeOption{divs}\phts\label{ref:divs-opt}
% |divs|$=$\verb+ekdosis|latex+\hfill\tcboxverb{Default: ekdosis}\\
% In many occasions, \LaTeX{} standard textual divisions do not meet
% the specific requirements of classical and literary texts, the
% divisions of which may depend on many different received
% traditions. \pkg{ekdosis} provides a flexible mechanism in which
% format and presentation have been carefully separated from
% content. It is designed to build un-numbered \texttt{TEI} divisions
% allowed to nest recursively.\footnote{See below,
% \vref{sec:body-divisions}.} However, if |divs| be set to |latex|,
% \LaTeX{} standard textual divisions can be used and will be
% translated into \texttt{TEI} numbered |<div>| elements.
%
% \danger It must be noted that the two styles are mutually exclusive.
% \vskip\baselineskip
%
% \DescribeOption{poetry}\phts\label{ref:poetry-opt}
% \newfeature[v1.2] |poetry|$=$\verb+verse+
% \hfill\tcboxverb{Default: not set}\\
% |poetry=verse| instructs \pkg{ekdosis} to load and use the facilites
% supplied by the \pkg{verse} package for the typesetting of lines of
% poetry.\footnote{\texttt{verse} does not need to be set if the
% \cls{memoir} class be used. See \vref{sec:verse-package} for more
% detail.} The \env{ekdverse} environment must then be used instead of
% the \env{verse} environment that is provided by the \pkg{verse}
% package as described below in \vref{sec:verse-package}.
%
% \DescribeOption{parnotes}\phts\label{ref:parnotes-opt}
% |parnotes|$=$\verb+true|false|roman+%
% \hfill\tcboxverb{Default: not set}\\
% This named argument does not need a value as it defaults to |true|
% if used. Apparatus criticus typeset by \pkg{ekdosis} may contain
% notes and footnotes. The latter can be laid out as paragraphed notes
% below the block of critical notes by means of the \pkg{parnotes}
% package. Additionally, |parnotes=roman| prints these footnotes
% numbered with Roman numerals.
%
% \DescribeOption{teiexport}\phts\label{ref:teiexport-option}
% |teiexport|$=$\verb+true|false|tidy+%
% \hfill\tcboxverb{Default: not set}\\
% This named argument does not need a value as it defaults to |true|
% if used. If |teiexport| be set to |true|, \pkg{ekdosis} is
% instructed to output both PDF and \texttt{TEI xml} files at the same
% time. By default, the \texttt{TEI} file will receive the same
% basename as the |.tex| source file, suffixed with |-tei.xml|. The
% raw |.xml| file that is produced by \pkg{ekdosis} can be further
% processed by the \textsf{tidy} console application.\footnote{See
% \url{http://www.html-tidy.org}.} To make this happen, \textsf{tidy}
% must be installed and the |.tex| source file must be compiled with
% the |--shell-escape| facility so that spawning programs from
% \LaTeX{} can be allowed.\footnote{See
% \url{https://texfaq.org/FAQ-spawnprog} for more information on how
% to do this.}
%
% As an example, the following line loads \pkg{ekdosis} and instructs
% it to output a \texttt{TEI xml} file (in addition to the PDF one)
% and to use \pkg{parnotes} to format with Roman numerals the footnotes
% that are inserted in the apparatus criticus:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\usepackage[teiexport, parnotes=roman]{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Using a Configuration File}
% \label{sec:using-conf-file}
% Complex editions may use a large number of witnesses, sources and
% scholars. It may also be required to define a multiple-layer
% apparatus criticus, several text environments to be aligned and
% quite a number of new commands. \pkg{ekdosis} provides a convenient
% way to avoid overloading the document preamble: all the settings
% related to the critical edition can be gathered in a separate
% configuration file named |\jobname-ekd.cfg|. If such a file can be
% found, its contents is automatically read and used by
% \pkg{ekdosis}.
%
% \subsection{Witnesses, Hands, Sources, Scholars \& Shorthands}
% \label{sec:declarations}
% \paragraph{Terminology}
% \label{sec:terminology}
% Strictly speaking, the term \enquote{witness} should apply to any
% manuscript evidence dating back to the Middle Ages used by the
% editor to establish the edition text. That said, editors often
% consult many other types of documents, such as modern editions,
% articles, notes, correspondence and the like, all of which fall into
% the category of \enquote{sources}. Furthermore, unpublished
% conjectures are also taken into account, not to mention the
% corrections and emendations that are proposed in many places by the
% editor of the text. As it is necessary to refer to scholars as
% individuals, \enquote{scholars} naturally emerges as a third
% category.
%
% Any reference that is to be used in the apparatus criticus must be
% \enquote{declared} in the preamble beforehand, namely: manuscript
% sigla (either for single manuscripts or manuscript families, primary
% or later hands, \emph{\&c.}), abbreviated last names of sources
% and scholars.  To that effect, \pkg{ekdosis} provides the following
% preamble-only commands:---
% 
% \paragraph{Witnesses}
% \DescribeMacro{\DeclareWitness} \cs{DeclareWitness}\marg{unique
% id}\marg{rendition}\marg{description}\oarg{options}
% \phts\label{ref:declarewitness}\\
% This command requires three mandatory arguments enclosed between
% curly braces used to specify consecutively:
% \begin{enumerate}
% \item The unique identifier of the witness to be used both in the
%   |.tex| source file and as an |xml:id| in the \texttt{TEI xml}
%   output if any.
% \item The rendition to be used in the printed apparatus criticus,
%   which also will be found within the |<sourceDesc>| element of the
%   \texttt{TEI} header where the description of the witness occurs,
%   within a |<abbr type="siglum">| element.
% \item A basic description of the manuscript to be found in a typical
%   printed Conspectus Siglorum, namely: the name of the manuscript
%   followed by its call number.
% \end{enumerate}
% Finally, the optional argument of \cs{DeclareWitness} accepts a
% comma-separated list of the following \enquote{name=value} arguments
% the first six of which are used to collect items of information to
% be found within the |<msIdentifer>| element in the \texttt{TEI}
% header:\footnote{See
% \url{https://tei-c.org/release/doc/tei-p5-doc/en/html/MS.html\#msid}
% for detailed information on these elements.}---\\
% \DescribeOption{settlement} |settlement|$=$\meta{name}: The name of
% a city or administrative unit.\\
% \DescribeOption{institution} |institution|$=$\meta{name}: The name
% of an institution such as a university or library.\\
% \DescribeOption{repository} |repository|$=$\meta{name}: The name of
% the repository within which the witness is stored.\\
% \DescribeOption{collection} |collection|$=$\meta{name}: The name of
% a collection of manuscripts.\\
% \DescribeOption{idno} |idno|$=$\meta{call \#}: Any form of call
% number.\\
% \DescribeOption{msName} |msName|$=$\meta{name}: The name commonly
% used for the witness.\\
% \DescribeOption{origDate} |origDate|$=$\meta{date}: Any form of date
% used to identify the date of origin for the witness.\\
% \DescribeOption{locus} |locus|$=$\meta{locus}\newfeature[v1.3]: The
% sequence of folio references where the edition text is found in the
% manuscript.
%
% \phts\label{ref:marcianus-b}
% To take here one example, a witness such as the \emph{Marcianus
% Graecus}~269, referred to as manuscript \enquote*{M} in the
% editions, which contains sixty treatises transmitted under the name
% of Hippocrates, could be declared as follows:\footnote{The locus
% specified refers to Hippocrates' \emph{Epidemics}, Book~6.}---
%
%\iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\DeclareWitness{M}{M}{\emph{Marcianus Gr.} 269}[
        settlement=Venice,
        institution=Marciana Library,
        msName=Marcianus Gr.,
        idno=269,
        origDate=s. X,
        locus=fol. 416\textsuperscript{v}–426\textsuperscript{v}]
\end{minted}
% \iffalse
%</example>
% \fi
%
% \paragraph{Hands} 
% \DescribeMacro{\DeclareHand} \cs{DeclareHand}\marg{unique
% id}\marg{base ms.}\marg{rendition}\oarg{note}\\
% This command requires three mandatory arguments enclosed between
% curly braces and one optional argument between square brackets used
% to specify consecutively:---
% \begin{enumerate}
% \item The unique identifier of the hand to be used both in the
% |.tex| source file and as an |xml:id| in the \texttt{TEI xml} output
% if any.
% \item The unique identifier of the witness the hand is related
% to. Of course, this witness must have been declared beforehand.
% \item The rendition to be used in the printed apparatus criticus,
% which also will be found within the |<handNote>| element of the
% \texttt{TEI} header where the description of the hand occurs, within
% a |<abbr type="siglum">| element.
% \item Some further information about the hand.
% \end{enumerate}
%
% To continue the preceding example, here is how additions and
% corrections found in the \emph{Marcianus Gr.}~269 could be declared
% after this witness has been declared itself:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\DeclareHand{M1}{M}{M\textsuperscript{1}}[Emendatio scribae ipsius]
\DeclareHand{M2}{M}{M\textsuperscript{2}}[Manus posterior]
\end{minted}
% \iffalse
%</example>
% \fi
%
% As can be seen, values such as |M|, |M1| and |M2| in the |.tex|
% source file will be printed as \getsiglum{M}, \getsiglum{M1} and
% \getsiglum{M2} respectively. Not only the code gains legibility, but
% also flexibility for simply changing any declared rendition will
% update corresponding sigla throughout the entire edition.
%
% As a final example, here is how \pkg{ekdosis} would encode
% information as declared above for the \emph{Marcianus Gr.}~269
% should a \texttt{TEI} output be required:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<sourceDesc>
  <listWit>
    <witness xml:id="M">
    <abbr type="siglum">M</abbr>
    <emph>Marcianus Gr.</emph>269 
    <msDesc>
      <msIdentifier>
        <settlement>Venice</settlement>
        <institution>Marciana Library</institution>
        <idno>269</idno>
        <msName>
          Marcianus Gr.
        </msName>
      </msIdentifier>
      <physDesc>
        <handDesc hands="2">
          <handNote xml:id="M1">
            <abbr type="siglum">M
            <hi rend="sup">1</hi></abbr>
            <p>Emendatio scribae ipius</p>
          </handNote>
          <handNote xml:id="M2">
            <abbr type="siglum">M
            <hi rend="sup">2</hi></abbr>
            <p>Manus posterior</p>
          </handNote>
        </handDesc>
      </physDesc>
      <history>
        <origin>
          <origDate>s. X</origDate>
        </origin>
      </history>
    </msDesc></witness>
  </listWit>
</sourceDesc>
\end{minted}
% \iffalse
%</example>
% \fi
% \phts\label{ref:marcianus-e}
%
% \paragraph{Sources}
% \phts\label{ref:declare-source}
% \DescribeMacro{\DeclareSource} \cs{DeclareSource}\marg{unique
% label}\marg{rendition}\newfeature[v1.1]\\
% The \emph{Conspectus Siglorum} that is placed ahead of the edition
% text is traditionally divided into two parts: a)~\emph{Codices},
% which provides the list of sigla used in the apparatus,
% b)~\emph{Editiones uel Studia}, which provides references to
% sources, either published or unpublished, which contain conjectures
% used in the apparatus criticus. \cs{DeclareSource} takes two
% mandatory arguments used to specify consecutively:---
% \begin{enumerate}
% \item A unique label used in the |.tex| source file to refer to the
%   work where the conjecture is found.
% \item The rendition to be used in the printed apparatus criticus.
% \end{enumerate}
%
% \danger As \pkg{ekdosis} can include and use \texttt{TEI
% xml}-compliant lists of references,\footnote{See below
% \vref{sec:references-cited-works}.} it is advisable to use
% Bib\hologo{(La)TeX} labels in the first argument of
% \cs{DeclareSource}. Otherwise, the unique label used to declare the
% source would point to no |xml:id| and the \texttt{TEI xml} would not
% be valid. Likewise, shorthands fields from the bibliographical
% database can be recalled from within the second argument of
% \cs{DeclareSource}:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\DeclareSource{Wil}{Wilamowitz}
% or for example:
\DeclareSource{Wil}{\citename{Wil}{shorteditor}}
\end{minted}
% \iffalse
%</example>
% \fi
% \phts\label{sec:declarations-end}
%
% \paragraph{Scholars}
% \phts\label{ref:declare-scholar}
% \DescribeMacro{\DeclareScholar}\cs{DeclareScholar}\marg{unique
% id}\marg{rendition}\oarg{options}\newfeature[v1.1]\\
% Occasionally, it is necessary to refer to a scholar as a person. For
% example, corrections and conjectures are commonly inserted as
% self-references to the editor of the text in the apparatus criticus
% in print with such words as \emph{scripsi}, \emph{addidi},
% \emph{correxi} and the like. Other examples come from unpublished
% conjectures of other scholars found in private
% libraries. \cs{DeclareScholar} takes two mandatory arguments to
% specify consecutively:---
% \begin{enumerate}
% \item The unique identifier of the scholar to be used both in the
% |.tex| source file and as an |xml:id| in the \texttt{TEI xml} output
% if any.
% \item The rendition to be used in the apparatus criticus in print,
% which also will be found within the |<sourceDesc>| element of the
% \texttt{TEI} header where the description of the persons cited
% occurs, within an |<abbr type="siglum">| element.
% \end{enumerate}
% Finally, the optional argument of \cs{DeclareScholar} accepts the
% following comma-separated list of |key-value| arguments:---\\
% \DescribeOption{rawname}|rawname|$=$\meta{name}\\
% |rawname| refers to a name that is not to be dissected into name
% part components such as forename, surname and the like. If |rawname|
% be used, then \pkg{ekdosis} will ignore the following three optional
% arguments: |forename|, |surname| and |addname|.\\
% \DescribeOption{forename}|forename|$=$\meta{forename}\\
% |forename| refers to first and middle names or initials.\\
% \DescribeOption{surname}|surname|$=$\meta{surname}\\
% |surname| stores the last name.\\
% \DescribeOption{addname} |addname|$=$\meta{additional name}\\
% |addname| refers to an additional or alternate name by which the
% scholar is known viz.\ a Latinized form of the name, a nickname, an
% epithet or alias.\\
% \DescribeOption{note} |note|$=$\meta{note}\\
% |note| may hold any relevant information about the material used by
% the editor. For example, a note may specify that this material has
% been found as marginal notes by the hand of the scholar in some
% edition in print.
%
% \paragraph{Shorthands}
% \DescribeMacro{\DeclareShorthand} \cs{DeclareShorthand}\marg{unique
% id}\marg{rendition}\marg{csv list of identifiers}\\
% This command provides a convenient way to declare \emph{families} of
% witnesses. It takes three mandatory arguments used to specify
% consecutively:---
% \begin{enumerate}
% \item The unique identifier of the family to be used in the |.tex|
%   source file.
% \item The rendition to be used in the printed apparatus criticus.
% \item A comma-separated list of previously declared witnesses.
% \end{enumerate}
%
% As an example, the manuscripts of Caesar's \emph{Gallic War} are
% divided into two families: α, which includes mss.\ A, M, B, R, S, L
% and N, and β, which includes mss.\ T, f, U and l. Therefore,
% provided that all these witnesses have been already declared, here
% is how the two families α  and β could be
% declared:\footnote{These witnesses are used in the example
% provided below in \vref{lst:caesar-bg}.}---
% \phts\label{ref:caesar-bg-sigla}
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\DeclareShorthand{a}{α}{A,M,B,R,S,L,N}
\DeclareShorthand{b}{β}{T,f,U,l}
\end{minted}
% \iffalse
%</example>
% \fi
%
% Then, symbols |a| and |b| can be used in the |.tex| source file in
% place of manuscripts that belong to either family.
%
% That said, \cs{DeclareShorthand} is not meant to be restricted to
% declared witnesses. On the contrary, it also applies to any declared
% sources and scholars by means of \cs{DeclareSource} and
% \cs{DeclareScholar}. As an example, assuming that a self-reference
% to the person responsible for the edition has been set in the
% preamble, an associated shorthand can be defined like so:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\DeclareScholar{ego}{ego}[
     forename=John,
     surname=Smith,
     note=Main editor of the text]
\DeclareShorthand{egoscr}{\emph{scripsi}}{ego}
\end{minted}
% \iffalse
%</example>
% \fi
%
% Then, the shorthand |egoscr| (l.~5) can be used to print in the
% apparatus criticus the technical term \emph{scripsi} and use at the
% same time the pointer |#ego| that is expected in the \texttt{TEI
% xml} output file. Detailed examples of this technique will be
% provided below in \vref{sec:emendations-conjectures}.
%
% \subsubsection{Printing Formatted Witnesses
% --- Conspectus Siglorum}
% \label{sec:print-witnesses}
% Once witnesses, hands, scholars and sources have been declared,
% \pkg{ekdosis} provides two commands to have them printed as declared
% from their identifiers.
%
% \DescribeMacro{\getsiglum} \cs{getsiglum}\marg{csv list of witnesses
% or single witness} behaves exactly as the |wit| optional argument of
% \cs{lem} and \cs{rdg} described below on pages~\pageref{ref:lem-wit}
% and \pageref{ref:rdg-wit}. From a single identifier or from a
% comma-separated list of identifiers, it returns their formatted
% counterparts. To return to the example provided
% \vpagerefrange{ref:marcianus-b}{ref:marcianus-e}, |\getsiglum{M}|
% would return \getsiglum{M}, while |\getsiglum{M1}| would return
% \getsiglum{M1}.
%
% \DescribeMacro{\SigLine} \cs{SigLine}\marg{unique id} returns from
% \meta{unique id} used in the first argument of
% \cs{DeclareWitness}\footnote{See above
% \vpageref{ref:declarewitness}.} a line ready to be inserted in a
% table set to print a Conspectus Siglorum with the following items of
% information separated by the symbol |&|: the siglum referring to the
% witness, the contents of the |description| field, followed if
% applicable by the sequence of folios that refers to the edition
% text, and the contents of the |origDate| field. An example of how
% one could print the Conspectus Siglorum of the manuscripts of
% Caesar's \emph{Gallic War} from the list provided
% \vpageref{ref:caesar-bg-sigla} follows:---
%
% \captof{Conspectus Siglorum of Caesar's \emph{Gallic War}}
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\begin{xltabular}[c]{0.75\linewidth}{lXl}
  \caption*{\textbf{Conspectus siglorum}}\\
  \multicolumn{3}{c}{\emph{Familia} \getsiglum{a}}\\
  \SigLine{A}\\
  & \getsiglum{A1} \emph{Emendationes scribae ipsius} & \\
  \SigLine{M}\\
  [...]
  \SigLine{N}\\
  \multicolumn{3}{c}{\emph{Familia} \getsiglum{b}}\\
  \SigLine{T}\\
  [...]
  \SigLine{l}\\
\end{xltabular}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \begin{xltabular}[c]{0.75\linewidth}{lXl}
%   \caption*{\textbf{Conspectus siglorum}}\\
%   \multicolumn{3}{c}{\emph{Familia} \getsiglum{ca}}\\
%   \SigLine{cA}\\
%   & \getsiglum{cA1} \emph{Emendationes scribae ipsius} & \\
%   \SigLine{cM}\\
%   \SigLine{cB}\\
%   \SigLine{cR}\\
%   \SigLine{cS}\\
%   \SigLine{cL}\\
%   \SigLine{cN}\\
%   \multicolumn{3}{c}{\emph{Familia} \getsiglum{cb}}\\
%   \SigLine{cT}\\
%   \SigLine{cf}\\
%   \SigLine{cU}\\
%   \SigLine{cl}\\
% \end{xltabular}
%
% \subsection{Editing a Single Text}
% \label{sec:single-text-editing}
% \DescribeEnv{ekdosis}
% Running paragraphs of one single text to be edited should be
% inserted in the \env{ekdosis} environment, like so:\footnote{See
% above \vref{lst:pj1}.}---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\begin{ekdosis}
  Edition text goes here.
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
% 
% \paragraph{Apparatus Entries}
% \DescribeMacro{\app} \cs{app}|[type=|\meta{type}|]|\marg{apparatus
% entries}\phts\label{ref:app-cmd}\\
% This command takes one mandatory argument and accepts one optional
% argument.  Once references to be used as witnesses in the apparatus
% criticus have been declared in the preamble as described in
% \ref{sec:declarations}
% \vpagerefrange{sec:declarations}{sec:declarations-end}, the \cs{app}
% command is used for inserting entries in the apparatus criticus,
% either lemmata, readings or notes, like so:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
I saw my friend \app{\lem{Peter}\rdg{John}} yesterday.
or:
I saw my friend
  \app{
    \lem{Peter}
    \rdg{John}
  }
yesterday.
\end{minted}
% \iffalse
%</example>
% \fi
% \cs{app} accepts one further optional argument:---\\
% \DescribeOption{type} |type|$=$\meta{type}\phts\label{ref:app-type}
% \hfill\tcboxverb{Default: default}\\
% As will be described below in \vref{sec:multilayer-apparatus},
% \pkg{ekdosis} initially sets one layer of notes\--- the |default|
% layer\---in the apparatus criticus. This layer is fit to receive
% notes related to variant readings from witnesses and sources used by
% the editor to establish the edition text. Additional layers can be
% defined to receive other kinds of notes, such as references to texts
% quoted or cited in the text of the edition (\emph{apparatus
% fontium}), references to testimonia, or quotations of the edited
% text by other authors (\emph{apparatus testium}), explanatory notes,
% and so forth.\footnote{See below, \vref{ref:type-note}.} Once
% additional layers have been defined and assigned to new
% \enquote*{types}, such as \enquote*{testium} and the like, these
% types can be used as values appended to the |type| \enquote*{named
% option}. For more information about inserting notes in
% multiple-layer apparatus, see \vref{sec:notes-in-multilayer-app}.
%
% \paragraph{Base text and variants} As can be seen in the example
% above, there are two kinds of individual readings: the \emph{lemma},
% which contains the base text accepted by the editor, and the
% \emph{reading}, which contains deviant readings rejected by the
% editor.
%
% \danger What follows refers to the notions of \enquote{witness},
% \enquote{source} and \enquote{scholar} as defined above
% \vpageref{sec:terminology}.
%
% \paragraph{Lemmata} \phts\label{ref:lemmata}\DescribeMacro{\lem}
% \cs{lem}\oarg{options}\marg{lemma text}\\
% As \meta{lemma text} is a word or a phrase judged by the editor to
% be authentic or authoritative, \cs{lem} prints it by default both in
% the edition text and as the first part of a new entry in the
% apparatus criticus, preceded by the line number where it occurs or a
% broad space when the entry refers to the same line as the preceding
% entry. \phts\label{ref:lem-opts-b}The optional argument of \cs{lem}
% accepts the following
% comma-separated list of \enquote{name$=$value} arguments:---\\
% \DescribeOption{wit} |wit|$=$\meta{csv list of
% witnesses}\phts\label{ref:lem-wit}\\
% While a single witness may be recorded as in |wit=A|,
% comma-separated lists of multiple witnesses must obviously be
% enclosed in curly braces, like so:
% |wit={A,B,C}|. \phts\label{ref:mss-sep-families}It must be noted
% that witnesses can be grouped by using spaces as separators, like
% so: \verb*|wit={A,B,C, D,E,F}|. Although any unique identifiers or
% labels used to \enquote{declare} sources and scholars as described
% above \vpagerefrange{ref:declare-source}{ref:declare-scholar} can
% also be used as values of the |wit| optional argument, it is
% recommended to use |sources| and |resp| to refer to either category
% respectively as described below.\\
% \DescribeOption{source} |source|$=$\meta{csv list of
% sources}\phts\label{ref:lem-source}\newfeature[v1.1]\\
% A \enquote{source} refers to any type of document consulted by the
% editor to establish the edition text. Most commonly, corrections and
% emendations from previous editions are cited in the apparatus
% criticus.\footnote{For edition texts used as sources, see examples
% below in \vref{sec:emendations-conjectures} and
% \vref{sec:references-cited-works}.}\\
% \DescribeOption{resp} |resp|$=$\meta{csv list of
% scholars}\phts\label{ref:lem-resp}\newfeature[v1.1]\\
% |resp| refers to scholars responsible for the emendations,
% conjectures and corrections that are cited in the apparatus
% criticus.\footnote{See detailed examples in
% \vref{sec:emendations-conjectures}.}\\
% \DescribeOption{alt} |alt|$=$\meta{alternate lemma}\\
% While the mandatory argument of \cs{lem}, \meta{lemma text}, is
% always used to print the edition text in the upper part of the page,
% \meta{alternate lemma}, if specified, supersedes what is printed in
% the related entry of the apparatus criticus. This mechanism is
% useful in more than one respect. For instance, it can be used to
% insert abbreviated lemmata in the apparatus criticus, or to
% introduce an alternate way of writing entries with Latin technical
% terms in the apparatus criticus as will be demonstrated below in the
% example
% provided by \vref{lst:pj2}.\\
% \DescribeOption{sep} |sep|$=$\meta{separator}\\
% |sep| allows to change the symbol used to separate the lemma text
% from deviant readings, which is by default the closing square
% bracket (|]|)\\
% \DescribeOption{nosep} |nosep|$=$\verb+true|false+\\
% This named argument does not need a value as it defaults to |true|
% if used. |nosep| removes the separator mentioned above. Obviously,
% |nosep| must be used when for some reason no \cs{rdg} command
% follows a \cs{lem} command that has just been used, as shown below
% in \vref{lst:emend-coni-corr}, l.~7.
% \danger \DescribeMacro{\ekdsep} If |nosep| be used so as to insert
% an explanatory note after the lemma text with the \cs{note} command
% described below \vpageref{ref:editorial-notes}, then \cs{ekdsep} can
% be used\---for instance as value of the |post| optional argument of
% the note\---to put back in the separator. This technique is
% demonstrated below in \vref{lst:emend-coni-corr}, ll.~23--5.\\
% \DescribeOption{nolem} |nolem|$=$\verb+true|false+\\
% This named argument does not need a value as it defaults to |true|
% if used. |nolem| completely removes the lemma text from the related
% entry in the apparatus criticus.\\
% \DescribeOption{type} |type|$=$\meta{value}\\
% This named argument has no effect on the apparatus criticus of the
% edition in print, but it is used in the \texttt{TEI xml} output to
% classify the variation recorded in the entry according to some
% convenient typology. Categories such as lexical, morphological,
% orthographical and the like may apply. Obviously, |type=emendation|
% should be restricted to lemma texts and |type=conjecture| to variant
% readings recorded by means of \cs{rdg} described below.
% 
% \needspace{2\baselineskip}
% \noindent
% \DescribeOption{num} (no-value
% argument)\phts\label{ref:lem-num}\newfeature[v1.3]\\
% |num| takes no value. If used, this argument instructs to print any
% line number that \pkg{ekdosis} may have decided not to print in the
% apparatus criticus before the lemma text.\\
% \DescribeOption{nonum} (no-value
% argument)\phts\label{ref:lem-nonum}\newfeature[v1.3]\\
% Compared to |num|, |nonum| does the opposite. If used, any number
% that \pkg{ekdosis} may have decided to print before the lemma text
% is suppressed.
%
% \needspace{11\baselineskip}
% Finally, four named arguments can be used to insert words at the
% following specific places in the lemma text:\\
% \noindent
% \fparbox*{\centered{\textbf{1} \tikzmark{pre}\tred{pre} Peter
% \tikzmark{post}\tred{post} \tikzmark{prewit}\tred{prewit}
% \getsiglum{pjA}
% \tikzmark{postwit}\tred{postwit}] John \getsiglum{pjB}}}\\
% \DescribeOption{pre} |pre|$=$\meta{words}\pointtol{pre}\\
% |pre| inserts \meta{words} \emph{before} the lemma text.\\
% \DescribeOption{post} |post|$=$\meta{words}\pointto{post}\\
% |post| inserts \meta{words} \emph{after} the lemma text.\\
% \DescribeOption{prewit} |prewit|$=$\meta{words}\pointto{prewit}\\
% |prewit| inserts \meta{words} \emph{before} the list of witnesses.\\
% \DescribeOption{postwit} |postwit|$=$\meta{words}\pointtor{postwit}\\
% |postwit| inserts \meta{words} \emph{after} the list of witnesses.
% \phts\label{ref:lem-opts-e}
%
% \paragraph{Readings} \DescribeMacro{\rdg}
% \cs{rdg}\oarg{options}\marg{variant reading}\\
% As \meta{reading} is a word or a phrase judged by the editor to be
% unsatisfactory or corrupted, \cs{rdg} prints it by default in the
% last part of the corresponding entry in the apparatus criticus,
% after the symbol that is used to separate words of the base text
% (the lemma text) from words rejected by the editor.  The optional
% argument of \cs{rdg} accepts a comma-separated list of
% \enquote{name$=$value} arguments that is almost identical to
% \cs{app}. Therefore, emphasis will be placed here only on the
% differences. The reader is invited to refer to the description
% provided above \vpagerefrange{ref:lem-opts-b}{ref:lem-opts-e} for
% more detailed information:---\\
% \DescribeOption{wit} |wit|$=$\meta{csv list of
% witnesses}\phts\label{ref:rdg-wit}\\
% \DescribeOption{source} |source|$=$\meta{csv list of sources}\\
% \DescribeOption{resp} |resp|$=$\meta{csv list of scholars}\\
% \DescribeOption{alt} |alt|$=$\meta{alternate reading}\\
% \DescribeOption{nordg} |nordg|$=$\verb+true|false+\\
% This named argument does not need a value as it defaults to |true|
% if used. |nordg| completely removes the variant reading from
% the related entry in the apparatus criticus.\\
% \DescribeOption{type} |type|$=$\meta{value}\\
% Obviously, |type=conjecture| should be restricted to variant
% readings and |type=emendation| to lemma texts recorded by means of
% \cs{lem} described above.\\
% \DescribeOption{pre} |pre|$=$\meta{words}\\
% \DescribeOption{post} |post|$=$\meta{words}\\
% \DescribeOption{prewit} |prewit|$=$\meta{words}\\
% \DescribeOption{postwit} |postwit|$=$\meta{words}\\
%
% \paragraph{Notes}
% \DescribeMacro{\note}\phts\label{ref:notes-b}\DescribeMacro{\note*}
% \cs{note}\oarg{options}\marg{text} or
% \cs{note*}\oarg{options}\marg{text}\phts\label{ref:editorial-notes}\\
% It may happen that editorial notes are needed to record short
% comments of general nature \emph{between} lemmata and
% readings. \cs{note} inserts inline comments while \cs{note*} places
% comments below the entire apparatus block. Furthermore, if
% \pkg{ekdosis} be loaded with the |parnotes| option as described
% above \vpageref{ref:parnotes-opt}, \cs{note*} will use the
% \pkg{parnotes} package to lay out the notes as an additional
% paragraph below the apparatus criticus. The optional argument of
% \cs{note}/\cs{note*} accepts the following comma-separated list of
% \enquote{name$=$value}
% arguments:---\\
% \DescribeOption{pre} |pre|$=$\meta{words}\\
% |pre| inserts \meta{words} immediately before the note.\\
% \DescribeOption{post} |post|$=$\meta{words}\\
% |post| inserts \meta{words} immediately after the note.\\
%
% \danger Under no circumstances is it permitted to insert this
% command \cs{note} or \cs{note*} inside the argument of \cs{lem} or
% \cs{rdg}. \cs{note}/\cs{note*} must go \emph{between} these
% commands. As a general rule, within \cs{app}|{}| elements, notes are
% inserted immediately \emph{after} the lemma or the variant reading
% they are related to. However, as will be described below in
% \vref{ref:type-note}, the command \cs{note}\---with no star
% appended\---that is used to insert explanatory notes or references
% to sources or testimonia is permitted within the mandatory argument
% of \cs{lem}|{}|, although it is subject to a very strict syntax.
%
% \Vref{lst:pj2} provides an illustration of some of the possibilities
% afforded by the commands just described:---
%
% \captof{The \enquote{Peter/John} full example}[\label{lst:pj2}]
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\begin{ekdosis}
  I 
  \app{
    \lem[wit=A]{saw}
    \rdg[wit=B]{met}}
  my friend
  \app{
    \lem{Peter}
    \rdg{John}
  }
  at the station yesterday. We were both in a
  \app{
    \lem[wit=A]{great}
    \rdg[wit=B]{good}}
  mood.
  \app{
    \lem[wit=A, alt={How nice... said}]{\enquote{How nice to find
        you here!} he said.}
    \note*{There are no quotation marks in the mss.}
    \rdg[wit=B, alt=\emph{om.}]{}}
  I chuckled to myself, recalling the last time we
  \app{
    \lem[wit=A,nolem]{met}
    \rdg[wit=B, alt={\emph{post} met \emph{add.} there}]{met
      there}
    \note*{Ms. \getsiglum{B} provides other additions of this kind.}}.
\end{ekdosis}
\end{minted}
% \iffalse
%</example> 
% \fi
%
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%     I \app{\lem[wit=pjA]{saw}\rdg[wit=pjB]{met}} my friend
%     \app{
%     \lem{Peter}
%     \rdg{John}
%   }
%     at the station yesterday. We were both in a
%     \app{
%     \lem[wit=pjA]{great}
%     \rdg[wit=pjB]{good}}
%     mood.
%     \app{
%     \lem[wit=pjA, alt={\textooquote How nice... said}]{\enquote{How
%     nice to find you here!} he said.}
%     \note*{There are no quotation marks in the mss.}
%     \rdg[wit=pjB, alt=\emph{om.}]{}}
%     I chuckled to myself, recalling the last time we
%     \app{
%     \lem[wit=pjA,nolem]{met}
%     \rdg[wit=pjB, alt={\emph{post} met \emph{add.} there}]{met
%     there}
%     \note*{Ms. \getsiglum{pjB} provides other additions of this kind.}}.
%   \end{specimen}
% \end{alignment}
%
% \begin{remarks}
% \item Close examination of lines~17--8 from \vref{lst:pj2} shows how
%   |alt| has been used to insert an abridged lemma text in the
%   apparatus criticus in print while keeping safe what is to be found
%   in the \texttt{TEI xml} output.
% \item The same technique has been used at line~24 to insert
%   alternate words, including Latin technical terms, in place of the
%   variant reading. Hence the use of |nolem| at line~23 to remove the
%   lemma text from the apparatus criticus in print.
% \item \cs{note*} has been used to insert short annotations in two
%   places (ll.~19 and 26).
% \item For an example of the use of |nordg|, see below
% \vref{lst:caesar-bg}, l.~11.
% \end{remarks}
%
% The corresponding \texttt{TEI xml} output produced by \pkg{ekdosis}
% from the \LaTeX{} source file follows:---
% 
% \captof{The \enquote{Peter/John} full example: \texttt{TEI xml}
% output}[\label{lst:pj2-tei}]
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>I 
<app>
  <lem wit="#A">saw</lem>
  <rdg wit="#B">met</rdg>
</app>my friend 
<app>
  <lem>Peter</lem>
  <rdg>John</rdg>
</app>at the station yesterday. We were both in a
<app>
  <lem wit="#A">great</lem>
  <rdg wit="#B">good</rdg>
</app>mood. 
<app>
  <lem wit="#A">
  <quote>How nice to find you here!</quote> he said.</lem>
  <note>There are no quotation marks in the mss.</note>
  <rdg wit="#B" />
</app>I chuckled to myself, recalling the last time we 
<app>
  <lem wit="#A">met</lem>
  <rdg wit="#B">met there</rdg>
  <note>Ms. 
  <ref target="#B">B</ref>provides other additions of
  this kind.</note>
</app>.</p>
\end{minted}
% \iffalse
%</example>
% \fi
% \phts\label{ref:notes-e}
%
% \subsection{Indicating Subvariation in Apparatus Entries}
% \label{sec:indic-subv-appar}
% It must be noted that grouping readings so as to keep emphasis on
% subvariation, regardless of its cause, is entirely optional.
% Furthermore, the applicability of this technique is limited to the
% \texttt{TEI xml} output as it helps the machines to understand a
% grouping otherwise immediately accessible to human mind from the
% information that is available in well-written
% apparatus. \pkg{ekdosis} provides two ways of expressing
% subvariation.
%
% \subsubsection{Implicit Grouping}
% \label{sec:implicit-grouping}
% Because apparatus entries may nest recursively, the \cs{app} command
% can be used to group similar readings.
%
% \danger However, for nesting to work, the |alt| optional argument
% must be used in every \cs{lem} and \cs{rdg} command involved in the
% nesting. This rule applies to both parent and child commands, as
% demonstrated in the following example:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
As I was walking home through Times Square, I saw my friend
\app{
  \lem[wit={A,B}, alt={Peter\---Street}]{Peter at the
    \app{
      \lem[wit=A, alt=station]{station}
      \rdg[wit=B, alt=bookstore]{bookstore}
    }
    on 42nd Street}
  \rdg[wit=C, alt={John on Broadway}]{John on Broadway}
}.
\end{minted}
% \iffalse
%</example>
% \fi
%
% PDF output:---
% \medskip
% 
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%    As I was walking home through Times Square, I saw my friend
%    \app{
%      \lem[wit={pjA,pjB}, alt={Peter\---Street}]{Peter at the
%        \app{
%          \lem[wit=pjA, alt=station]{station}
%          \rdg[wit=pjB, alt=bookstore]{bookstore}}
%        on 42nd Street}
%      \rdg[wit=pjC, alt={John on Broadway}]{John on Broadway}}.
%   \end{specimen}
% \end{alignment}
% 
% \begin{remarks}
% \item[\textsc{Rem.}] Two \cs{app} commands naturally insert two
%   entries in the apparatus criticus. As the subvariation comes
%   first, what ms.\ C reads is only mentioned in the subsequent
%   entry.
% \end{remarks}
% 
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>As I was walking home through Times Square, I saw my
friend 
<app>
  <lem wit="#A #B">Peter at the 
  <app>
    <lem wit="#A">station</lem>
    <rdg wit="#B">bookstore</rdg>
  </app>on 42nd Street</lem>
  <rdg wit="#C">John on Broadway</rdg>
</app>.</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \danger It must be noted that from a technical standpoint, albeit
% the nested lemmas are printed \emph{before} their parents in the
% apparatus criticus, they are seen by \pkg{ekdosis} \emph{after} the
% latter as the source file is compiled. As a result, notably when the
% whole nested group of lemmas falls on the same line without being
% preceded by an apparatus entry on this line, it may be needed to
% suppress redundant numbers that \pkg{ekdosis} may have decided to
% print in the appartus criticus. Conversely, it may be needed to
% print numbers that \pkg{ekdosis} may have decided not to print. To
% both ends, the |num| and |nonum| optional arguments of the \cs{lem}
% command can be used as described above
% \vpagerefrange{ref:lem-num}{ref:lem-nonum}.
%
% \subsubsection{Explicit Grouping}
% \label{sec:explicit-grouping}
% \DescribeMacro{\rdgGrp} \cs{rdgGrp}\oarg{options}\marg{lemma text
% \textbar\ readings}\newfeature[v1.1]\\
% Explicit grouping of readings can be achieved by means of the
% \cs{rdgGrp} command. It takes as mandatory argument the commands
% used for inserting lemma texts, readings and notes that are
% described \vpagerefrange{ref:lemmata}{ref:notes-e}, viz.\ \cs{lem},
% \cs{rdg} and \cs{note}. \cs{rdgGrp} accepts one further optional
% argument:---\\
% \DescribeOption{type} |type|$=$\meta{value}\\
% This named argument is used in the \texttt{TEI xml} output to
% define an attribute common to all elements representing the
% variation.
%
% Here follows how the technique of explicit grouping would apply to
% the same passage as above:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
As I was walking home through Times Square, I saw my friend
\app{
  \rdgGrp[type=subvariation]{
    \lem[wit=A, alt={Peter\---Street}]{Peter at the station
      on 42nd Street}
    \rdg[wit=B, alt={bookstore \emph{pro} station}]{Peter at the
      bookstore on 42nd Street}
  }
  \rdg[wit=C]{John on Broadway}
}.
\end{minted}
% \iffalse
%</example>
% \fi
% 
% PDF output:---
% \medskip
% 
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
% As I was walking home through Times Square, I saw my friend
% \app{
%   \rdgGrp[type=subvariation]{
%     \lem[wit=pjA, alt={Peter\---Street}]{Peter at the station
%       on 42nd Street}
%     \rdg[wit=pjB, alt={bookstore \emph{pro} station}]{Peter at the
%       bookstore on 42nd Street}
%   }
%   \rdg[wit=pjC]{John on Broadway}
% }.
%   \end{specimen}
% \end{alignment}
% 
% \begin{remarks}
% \item[\textsc{Rem.}] In this example, the subvariation is emphasized
%   with a Latin technical term and may be expressed in one single
%   entry in a more economical manner.
% \end{remarks}
% 
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>As I was walking home through Times Square, I saw my
friend 
<app>
  <rdgGrp type="subvariation">
    <lem wit="#A">Peter at the station on 42nd
    Street</lem>
    <rdg wit="#B">Peter at the bookstore on 42nd
    Street</rdg>
  </rdgGrp>
  <rdg wit="#C">John on Broadway</rdg>
</app>.</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \section{Emendations and Conjectures}
% \label{sec:emendations-conjectures}
% From a technical standpoint, \enquote{conjectures} are readings that
% are not supported by manuscript evidence, but are instead proposed
% by scholars to be taken into consideration for establishing the
% edition text. A conjecture is called an \enquote{emendation} when it
% is adopted in place of what is provided by or missing from the text
% provided by the manuscripts. Emendations and conjectures are
% therefore readings and as such expected to be found within |<lem>|
% or |<rdg>| elements. However, as both come from editions or
% scholars, not from manuscripts, they are naturally associated with
% |source| or |resp| attributes as described above
% \vpagerefrange{ref:lem-source}{ref:lem-resp},\footnote{See also
% \vpagerefrange{ref:declare-source}{ref:declare-scholar}.} and can be
% distinguished from one another by the |type| attribute, eg.\ either
% |emendation| or |conjecture|.
%
% As an example, the representation of witnesses, editors and
% shorthands of Hippocrates' \emph{Epidemics}, Book~2 could be
% summarized as follows:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
% Witnesses:
\DeclareWitness{V}{V}{\emph{Vaticanus Gr.} 276}
\DeclareWitness{I}{I}{\emph{Parisinus Gr.} 2140}
\DeclareHand{Iac}{I}{I\textsuperscript{ac}}[Lectio ante correctionem]
\DeclareHand{Ipc}{I}{I\textsuperscript{pc}}[Lectio post correctionem]
\DeclareWitness{R}{R}{\emph{Vaticanus Gr.} 277}
\DeclareWitness{H}{H}{\emph{Parisinus Gr.} 2142}
% Sources (the first arguments below must refer to biblatex labels and
% an xml bibliographical database must be supplied):
\DeclareSource{Lit}{Littré}
\DeclareSource{Erm}{Ermerins}
\DeclareSource{Sm}{Smith}
% Persons:
\DeclareScholar{ego}{ego}[
                forename=Robert,
                surname=Alessi]
% Useful shorthands:
\DeclareShorthand{codd}{codd.}{V,I,R,H}
\DeclareShorthand{edd}{edd.}{Lit,Erm,Sm}
\DeclareShorthand{egoscr}{\emph{scripsi}}{ego}
\end{minted}
% \iffalse
%</example>
% \fi
%
% As can be seen from lines~18--20, three useful shorthands have been
% defined: |codd| prints \enquote{codd.} for Latin pl.\ \emph{codices}
% viz.\ \enquote{all manuscripts} and refers to the three \texttt{xml}
% identifiers |V|, |I|, |R| and |H| declared at ll.~2--3 and 6--7;
% |edd| prints \enquote{edd.} for Latin pl.\ \emph{editores} viz.\
% \enquote{all editors} and refers to the three \texttt{xml}
% identifiers |Lit|, |Erm| and |Sm| declared at
% ll.~10--12;\footnote{For detailed information on how to use
% \cs{DeclareSource} and insert references to cited works, the reader
% is invited to refer to \vref{sec:references-cited-works}.} finally,
% |egoscr| (l.~20) is used to print the technical Latin term
% \enquote{\emph{scripsi}}, \enquote{I wrote}, to denote a personal
% conjecture. Then, the |.tex| source file can be structured as
% follows:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\begin{ekdosis}
  καὶ ἐγίνετο μᾶλλον \app{
    \lem[wit={V, Ipc,R,H}]{νότῳ}
    \rdg[wit=Iac]{νότου}
    \rdg[source=Erm, type=conjecture]{ἐν νώτῳ}}· [...] % conjecture
  
  εἰ
  \app{
    \lem[resp=egoscr, type=emendation]{μὲν} % emendation
    \rdg[wit=codd, source=edd]{μὴ}
  } εἴη διὰ ταῦτα [...]
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
% 
% \begin{remarks}
% \item Line~5 introduces a \emph{conjecture} which has been annotated
%   with |type=conjecture| to facilitate its identification. Other
%   optional arguments could have been used, such as
%   |prewit=|\texttt{coni.} or |prewit=|\texttt{falso coni.}, to print
%   explanatory words in the apparatus criticus before the abridged
%   name of the scholar.
% \item \phts\label{it:egomute}Conversely, line~9 introduces an
%   \emph{emendation} for which the shorthand |egoscr| has been used
%   to print the exact term \emph{scripsi} in the apparatus criticus
%   while keeping |ego| as an |xml:id| for the \texttt{TEI xml} output
%   file. Other strategies could have been used. For example, one
%   could have defined a specific shorthand to print nothing in place
%   of |ego| and leave the insertion of technical terms to the |post|
%   optional argument of \cs{lem}, like so:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
% Preamble:
% (\unskip is for removing the space left by the empty 2nd argument
% below.)
\DeclareShorthand{egomute}{\unskip}{ego}

% Document:
  \app{
    \lem[resp=egomute, post=\emph{scripsi}, type=emendation]{μὲν}
    \rdg[wit=codd, source=edd]{μὴ}
  } εἴη διὰ ταῦτα [...]
\end{minted}
% \iffalse
%</example>
% \fi
% \end{remarks}
% 
% PDF output:---
% \medskip
%
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%     \begin{ancientgreek}
%       καὶ ἐγίνετο μᾶλλον \app{
%       \lem[wit={hV, hIpc,hR,hH}]{νότῳ}
%       \rdg[wit=hIac]{νότου}
%       \rdg[source=Erm, type=conjecture]{ἐν νώτῳ}}· [...]
%
%       εἰ \app{
%       \lem[resp=hegoscr, type=emendation]{μὲν}
%       \rdg[wit=hcodd, source=hedd]{μὴ}
%     } εἴη διὰ ταῦτα [...]
%     \end{ancientgreek}
%   \end{specimen}
% \end{alignment}
%
% \texttt{TEI xml} output:---
% \enlargethispage{\baselineskip}
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p xml:lang="grc">καὶ ἐγίνετο μᾶλλον 
<app>
  <lem wit="#V #Ipc #R #H">νότῳ</lem>
  <rdg wit="#Iac">νότου</rdg>
  <rdg source="#Erm" type="conjecture">ἐν νώτῳ</rdg>
</app>· [...]</p>
<p>εἰ 
<app>
  <lem resp="#ego" type="emendation">μὲν</lem>
  <rdg wit="#V #I #R #H" source="#Lit #Erm #Sm">
  μὴ</rdg>
</app>εἴη διὰ ταῦτα [...]</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Editorial Addition and Deletion}
% \label{sec:editorial-add-del}
% \pkg{ekdosis} provides a set of commands to indicate that text has
% been supplied or removed by conjecture. As regards critical
% symbols conventionally used for representing emendations, lacunae,
% omissions, gaps, editorial deletions or additions and the like,
% \pkg{ekdosis} follows the standards as described by
% \textcite[80--82]{West1973}:---
% \begin{description}[font=\ttfamily]
% \item[<>] text added by conjecture or from a parallel source.
% \item[***] lacuna in the whole textual tradition.
% \item[<***>] conjectured lacuna.
% \item[\{\}] editorial deletion.
% \item[\dag\dag] text judged by the editor to be corrupt. Note that if
% only one word be suspect, only one crux is needed. 
% \end{description}
%
% \DescribeMacro{\SetCritSymbols}\newfeature[v1.1]
% \cs{SetCritSymbols}\marg{csv list of options} can be used to change
% the critical symbols described above. This command accepts the
% following list of |key-value|
% optional arguments:---\\
% \DescribeOption{suppbegin}|suppbegin|$=$\meta{symbol}
% \hfill\tcboxverb{Default: <}\\
% The opening symbol used to mark the text that is supplied.\\
% \DescribeOption{suppend}|suppend|$=$\meta{symbol}
% \hfill\tcboxverb{Default: >}\\
% The closing symbol used to mark the text that is supplied.\\
% \DescribeOption{delbegin}|delbegin|$=$\meta{symbol}
% \hfill\tcboxverb|Default: {|\\
% The opening symbol used to mark the text that is deleted.\\
% \DescribeOption{delend}|delend|$=$\meta{symbol}
% \hfill\tcboxverb|Default: }|\\
% The closing symbol used to mark the text that is deleted.\\
% \DescribeOption{sicbegin}|sicbegin|$=$\meta{symbol}
% \hfill\tcboxverb{Default: †}\\
% The opening symbol used to mark the text that is deemed to be
% suspect.\\
% \DescribeOption{sicend}|sicend|$=$\meta{symbol}
% \hfill\tcboxverb{Default: †}\\
% The closing symbol used to mark the text that is deemed to be
% suspect.\\
% \DescribeOption{gapmark}|gapmark|$=$\meta{symbols}
% \hfill\tcboxverb{Default: ***}\\
% The symbols used to mark lacunae.\\
%
% As an example, what follows sets |[]| for deletions and |...| for
% lacunae:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\SetCritSymbols{
  delbegin = [,
  delend = ],
  gapmark = \dots
}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \danger If modified, brackets can be adapted to languages that are
% written from right to left. To that effect, \pkg{ekdosis} provides a
% boolean expression |al@rlmode| which is evaluated as |true| if the
% writing direction be set from right to left and as |false|
% otherwise. As the \pkg{etoolbox} package is loaded by \pkg{ekdosis},
% \cs{ifboolean}|{al@rlmode}|\marg{rtl symbol}\marg{ltr symbol} can be
% used to perform the test.
%
% \paragraph{Editorial Addition}
% \DescribeMacro{\supplied}\newfeature[v1.1]\cs{supplied}\marg{text}
% is used to mark \meta{text} that is by definition missing from the
% tradition as supplied by the editor or some other scholar. This
% command is normally expected in \cs{lem}|{}| or \cs{rdg}|{}|.
%
% \paragraph{Editorial Deletion}
% \DescribeMacro{\surplus}\newfeature[v1.1] \cs{surplus}\marg{text}
% is used to mark \meta{text} that is deemed to be inauthentic, but
% nevertheless retained between braces in the edition text as it is
% transmitted by all witnesses. This command is normally expected in
% \cs{lem}|{}| or \cs{rdg}|{}|.
%
% \paragraph{Crux}
% \DescribeMacro{\sic}\newfeature[v1.1] \cs{sic}\marg{text} takes as
% mandatory argument the text deemed by the editor to be readable but
% not understandable. \cs{sic} inserts \meta{text} between cruces
% while \cs{sic*} prints only one crux before \meta{text}.
%
% \paragraph{Lacuna}
% \DescribeMacro{\gap}\newfeature[v1.1] \cs{gap}\marg{csv list of
% options} indicates that some amount of text has fallen away from the
% entire tradition. It takes as mandatory argument a comma-separated
% list of options that can be used to further specify the reason for
% omission, the unit of measurement, the quantity or the extent, as
% follows:---\\
% \DescribeOption{reason}|reason|$=$\meta{reason}\\
% |reason| gives the reason for omission.\\
% \DescribeOption{unit} |unit|$=$\meta{unit}\\
% |unit| provides some regularized measurement, such as |character|,
% |word|, |line| and the like.
% \DescribeOption{quantity} |quantity|$=$\meta{n}\\
% |quantity| specifies the number of the given unit that comprise the
% measurement.\\
% \DescribeOption{extent} |extent|$=$\meta{description}\\
% |extent| describes the size, including quantity and unit in a single
% string of words.
%
% \paragraph{Conjectured Lacuna}
% Assumably, the conjectured lacuna should be enclosed by
% \cs{supplied} and as such contained by \cs{lem} with
% |type=emendation| to indicate that the lacuna has been accepted by
% the editor.
%
% Examples follow:\footnote{On the use of \texttt{egomute} (l.~2), see
% above \vref{it:egomute}.}---
%
% \captof{Emendations, conjectures and
% corrections}[\label{lst:emend-coni-corr}]
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
% Preamble:
\DeclareShorthand{egomute}{\unskip}{ego}

% Document:
\begin{ekdosis}
  σχεδὸν \app{
    \lem[resp=egomute, nosep, post={post σχεδὸν quattuor uerba
      excidisse uid.}, type=emendation]{\supplied{\gap{reason=lost,
          unit=word, quantity=4}}}
  } οὗτοι

  subsidiis magnis \sic*{epicuri} constabilitas

  declinare quis est qui \sic{possit cernere sese}.

  \app{
    \lem[resp=egomute, type=emendation, nosep, post={ante
      ὑπογίν.}]{\surplus{καὶ}}
    \note{deleui e Gal.P}
  } ὑπογίνονται

  Πάντων δὲ \app{
    \lem[resp=egomute, type=emendation, nosep]{\supplied{τῶν πυρετῶν}}
    \note[post=\ekdsep]{addidi (\arb{^gamI`a 'l-.hummayAti}
      \getsiglum{Gal})}
    \rdg[nordg, source=Gal]{\arb{al-.hummayAti}}
    \rdg[wit=codd, source=edd, alt=om.]{}
  },
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \needspace{11\baselineskip}
% PDF output:---
% \medskip
% 
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%  σχεδὸν \app{
%    \lem[resp=egomute, nosep, post={post σχεδὸν quattuor uerba
%      excidisse uid.}, type=emendation]{\supplied{\gap{reason=lost,
%          unit=word, quantity=4}}}
%  } οὗτοι
%
%  subsidiis magnis \sic*{epicuri} constabilitas
%
%  declinare quis est qui \sic{possit cernere sese}.
%
%  \app{
%    \lem[resp=egomute, type=emendation, nosep, post={ante
%      ὑπογίν.}]{\surplus{καὶ}}
%    \note{deleui e Gal.P}
%  } ὑπογίνονται
%
%
%  Πάντων δὲ \app{
%    \lem[resp=egomute, type=emendation, nosep]{\supplied{τῶν πυρετῶν}}
%    \note[post=\ekdsep]{addidi (\arb{^gamI`a 'l-.hummayAti}
%      \getsiglum{Gal})}
%    \rdg[nordg, source=Gal]{\arb{al-.hummayAti}}
%    \rdg[wit=hcodd, source=hedd, alt=om.]{}
%  },
%   \end{specimen}
% \end{alignment}
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>σχεδὸν 
<app>
  <lem resp="#ego" type="emendation">
    <supplied>
      <gap reason="lost" unit="word" quantity="4" />
    </supplied>
  </lem>
</app>οὗτοι</p>
<p>subsidiis magnis 
<sic>epicuri</sic> constabilitas</p>
<p>declinare quis est qui 
<sic>possit cernere sese</sic>.</p>
<p>
<app>
  <lem resp="#ego" type="emendation">
    <surplus>καὶ</surplus>
  </lem>
  <note>deleui e Gal.P</note>
</app>ὑπογίνονται</p>
<p>Πάντων δὲ 
<app>
  <lem resp="#ego" type="emendation">
    <supplied>τῶν πυρετῶν</supplied>
  </lem>
  <note>addidi (
  <foreign xml:lang="ar-Latn" type="transliterated"
  subtype="arabtex">^gamI`a 'l-.hummayAti</foreign>
  <ref target="#Gal">Gal.</ref>)</note>
  <rdg source="#Gal">
    <foreign xml:lang="ar-Latn" type="transliterated"
    subtype="arabtex">al-.hummayAti</foreign>
  </rdg>
  <rdg wit="#V #I #R #H" source="#Lit #Erm #Sm" />
</app>,</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \section{Alignment of Parallel Texts}
% \label{sec:alignment-basic}
% As already said above,\footnote{See point
% \vref{it:multicol-feature}.} \pkg{ekdosis} can arrange sundry texts
% in parallel columns\---synchronized or not\---either on the same
% page or on facing pages. Depending on what is needed, any text can
% be equipped with an apparatus criticus. The most common example is
% that of an edition of a classical text with an apparatus criticus
% accompanied by a translation into a modern language on the facing
% page. One can also imagine an edition of two classical texts or two
% different recensions of the same text, each of which provides
% variants recorded in separate apparatus criticus, laid out on the
% left-hand pages, with one or more translations on the corresponding
% right-hand pages, and so forth.
%
% \paragraph{The \env{alignment} Environment}
% \DescribeEnv{alignment} \cs{begin}|{alignment}|\oarg{options}\dots
% \cs{end}|{alignment}|\phts\label{ref:alignment-syntax}\\
% This environment can be used as it is provided to typeset a standard
% critical edition, namely an edition text, equipped with an apparatus
% criticus and laid out on the left-hand pages, accompanied by a
% translation into a modern language on the facing pages.
%
% \DescribeEnv{edition}\DescribeEnv{translation} Within
% \env{alignment}, two environments are available by default:
% \cs{begin}|{edition}|\allowbreak\dots
% \cs{end}|{ed|\allowbreak|ition}| and \cs{begin}|{translation}|\dots
% \cs{end}|{translation}|. Obviously, the former is used to typeset
% the edition text with an apparatus criticus on the left, while the
% latter is used to typeset the translation on the right, like so:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\begin{alignment}
  \begin{edition}
    First § of the edition text.
  \end{edition}
  \begin{translation}
    First § of the translation.
  \end{translation}
  \begin{edition}
    Second § of the edition text.
  \end{edition}
  \begin{translation}
    Second § of the translation.
  \end{translation}
\end{alignment}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \DescribeEnv{edition*}
% \DescribeEnv{translation*}
% \phts\label{ref:starred-envs} Furthermore, so-called
% \enquote{starred} versions of these environments can be used at any
% point to synchronize texts, that is to print them in such a way that
% the tops of all paragraphs are vertically aligned. To that effect,
% it must be noted that merely applying this command on a single
% environment\---for instance the leftmost one\---will have all other
% associated paragraphs printed aligned.
%
% \danger While the whole edition text and the whole translation can
% be inserted in a single \env{edition}/\env{translation} environment
% respectively, it is recommended to enter both texts paragraph by
% paragraph as shown in the example above. Not only this method of
% encoding allows not to lose sight of paragraphs that are meant to be
% read together, but it is also the only way to align paragraphs in
% print, and it is much more suitable to mark up correspondence
% between spans of texts.
%
% As an illustration, a short extract of Caesar's \emph{Gallic War},
% VI, XIII.1 follows.\footnote{Latin text: \cite{Caesar-BG-v2};
% English translation: \cite{CaesarTr}.} See the list of sigla for
% manuscripts and manuscript families above
% \vpageref{ref:caesar-bg-sigla}. As this document is not set for
% duplex printing, both texts have been put together on the same
% page. However, the reader will find the full |.tex| source file in
% \vref{sec:caesar-gw-tex} and \texttt{TEI xml} output in
% \vref{sec:caesar-gw-tei}. The corresponding PDF output is available
% in \href{samples/Caesar_BG-6-13-1.pdf}{a separate file}:\footnote{On
% the use of \cs{ekddiv} (ll.~3 and 20), see below
% \vref{sec:ekddiv}.}---
%
% \captof{Caesar's \emph{Gallic War}, VI, 13.1}[\label{lst:caesar-bg}]
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\begin{alignment}
  \begin{edition}
    \ekddiv{head=XIII, depth=2, n=6.13, type=section}
    In omni Gallia eorum hominum qui \app{
      \lem[wit=a]{aliquo}
      \rdg[wit=b, alt=in al-]{in aliquo}}
    sunt numero atque honore genera sunt duo. Nam plebes paene
    seruorum habetur loco, quae \app{
      \lem[wit={A,M}, alt={nihil audet (aut et \getsiglum{A1})
        per se}]{nihil audet per se}
      \rdg[wit=A1,nordg]{nihil aut et per se}
      \rdg[wit={R,S,L,N}]{nihil habet per se}
      \rdg[wit=b]{per se nihil audet}}, \app{
      \lem[wit=a]{nullo}
      \rdg[wit=b]{nulli}} adhibetur \app{
      \lem{consilio}
      \rdg[wit={T, U}, alt=conc-]{concilio}}.
  \end{edition}
  \begin{translation}
    \ekddiv{head=XIII, depth=2, n=6.13, type=section}
      Throughout all Gaul there are two orders of those men who are of
      any rank and dignity: for the commonality is held almost in the
      condition of slaves, and dares to undertake nothing of itself,
      and is admitted to no deliberation.
  \end{translation}
\end{alignment}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \begingroup
% \needspace{7\baselineskip}
% \resetlinenumber
% \FormatDiv{2}{}{.}
% \begin{alignment}[flush,lcols=2,
%                   texts=edition[xml:lang="la"];
%                   translation[xml:lang="en"]]
% \AtBeginEnvironment{edition}{\selectlanguage{latin}}
% \AtBeginEnvironment{translation}{\selectlanguage{american}}
%   \begin{edition}
%     \ekddiv{head=XIII, depth=2, n=6.13, type=section}
%     In omni Gallia eorum hominum qui \app{
%       \lem[wit=ca]{aliquo}
%       \rdg[wit=cb, alt=in al-]{in aliquo}}
%     sunt numero atque honore genera sunt duo. Nam plebes paene
%     seruorum habetur loco, quae \app{
%       \lem[wit={cA,cM}, alt={nihil audet (aut et \getsiglum{cA1})
%         per se}]{nihil audet per se}
%       \rdg[wit=cA1,nordg]{nihil aut et per se}
%       \rdg[wit={cR,cS,cL,cN}]{nihil habet per se}
%       \rdg[wit=cb]{per se nihil audet}}, \app{
%       \lem[wit=ca]{nullo}
%       \rdg[wit=cb]{nulli}} adhibetur \app{
%       \lem{consilio}
%       \rdg[wit={cT, cU}, alt=conc-]{concilio}}.
%   \end{edition}
%   \begin{translation}
%     \ekddiv{head=XIII, depth=2, n=6.13, type=section}
%       Throughout all Gaul there are two orders of those men who are of
%       any rank and dignity: for the commonality is held almost in the
%       condition of slaves, and dares to undertake nothing of itself,
%       and is admitted to no deliberation.
%   \end{translation}
% \end{alignment}
% \endgroup
%
% \begin{remarks}
% \item As can be seen from the apparatus entry related to l.~4 above,
%   a subvariant has been inserted in the lemma part: \enquote{(aut et
%   \getsiglum{cA1})}. This was done by using |alt| in
%   \vref{lst:caesar-bg}, ll.~9--10. But as this variant is already
%   recorded\---and printed\---in the lemma part, it was necessary to
%   remove the entire otherwise redundant variant from the apparatus
%   criticus in print. Hence the use of |nordg| at l.~11.
% \item For examples of abbreviations, see ll.~6 and 17.
% \item Line~17 shows how mss.\ T and U (which belong to two distinct
%   subfamilies) have been separated from one another: %
%   \verb*+wit={T, U}+. See above \vpageref{ref:mss-sep-families} for
%   more information on this technique.
% \end{remarks}
%
% Finally, the corresponding \texttt{TEI xml} output follows:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<div xml:id="div-edition_1" xml:lang="la">
  <div type="section" n="6.13">
    <head>XIII</head>
    <p>In omni Gallia eorum hominum qui 
    <app>
      <lem wit="#A #M #B #R #S #L #N">aliquo</lem>
      <rdg wit="#T #f #U #l">in aliquo</rdg>
    </app>sunt numero atque honore genera sunt duo. Nam
    plebes paene seruorum habetur loco, quae 
    <app>
      <lem wit="#A #M">nihil audet per se</lem>
      <rdg wit="#A1">nihil aut et per se</rdg>
      <rdg wit="#R #S #L #N">nihil habet per se</rdg>
      <rdg wit="#T #f #U #l">per se nihil audet</rdg>
    </app>, 
    <app>
      <lem wit="#A #M #B #R #S #L #N">nullo</lem>
      <rdg wit="#T #f #U #l">nulli</rdg>
    </app>adhibetur 
    <app>
      <lem>consilio</lem>
      <rdg wit="#T #U">concilio</rdg>
    </app>.</p>
  </div>
</div>
<div xml:id="div-translation_1" xml:lang="en">
  <div type="section" n="6.13">
    <head>XIII</head>
    <p>Throughout all Gaul there are two orders of those men
    who are of any rank and dignity: for the commonality is
    held almost in the condition of slaves, and dares to
    undertake nothing of itself, and is admitted to no
    deliberation.</p>
  </div>
</div>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Alignment of Several Texts}
% \label{sec:multiple-alignment}
% As described above \vpageref{ref:alignment-syntax}, the
% \env{alignment} environment may receive an optional argument in
% which
% the following \enquote{name$=$value} arguments are accepted:---\\
% \DescribeOption{tcols}
% |tcols|$=$\meta{number}\hfill\tcboxverb{Default: 2}\\
% |tcols| stores the \underLine{t}otal number of
% \underLine{col}umn\underLine{s} of text to be aligned.\\
% \DescribeOption{lcols}
% |lcols|$=$\meta{number}\hfill\tcboxverb{Default: 1}\\
% |lcols| stores the number of \underLine{col}umn\underLine{s} to be
% printed on the \underLine{l}eft-hand page, \emph{out of the total
% number} of columns specified with |tcols|. As can be seen from the
% preceding two default values, \env{alignment} initially sets two
% columns of text on facing pages. Of course, for this setting to work
% properly, one must ensure that the \env{alignment} environment is
% started on a
% left page.\\
% \DescribeOption{texts}
% |texts|$=$\meta{\underLine{semicolon}-separated
% values}\hfill\tcboxverb{Default: edition;translation}\\
% Depending on the total number of columns that has been specified
% with |tcols| above, |texts| is then used to define the names of the
% environments that shall receive edition texts, translations,
% \emph{\&c.} Furthermore, as described \vpageref{ref:starred-envs},
% \pkg{ekdosis} also defines \enquote{starred} versions of these
% environments to be used to synchronize columns so that corresponding
% paragraphs are printed vertically aligned. Some very important
% points need to be emphasized in this respect:---
% \begin{enumerate}
% \item Only unaccented letters of the alphabet (whatever the case)
%   are allowed to compose the names of \LaTeX{} environments.
% \item These names must be separated from one another by
%   \emph{semicolons}, as shown in red in the listing below at the end
%   of lines~1 and 2.
%   \begin{enumerate}
%   \item[\dbend] The colon at the end of line~3 closes the whole
%     value of |text| and acts as a higher level separator.
%   \end{enumerate}
% \item \phts\label{it:lang-subopt} Each name may be followed by a
%   \enquote*{suboptional} argument between square brackets which will
%   then be used to insert \texttt{TEI xml} attributes in the
%   corresponding |<div>| element. For example, \iffalse
%<*example>
% \fi
\begin{minted}[escapeinside=++]{latex}
texts=latin[xml:lang="la"]+\textcolor{red}{;}+
      english[xml:lang="en"]+\textcolor{red}{;}+
      french[xml:lang="fr"]+\textcolor{red}{,}+
\end{minted}
% \iffalse
%</example>
% \fi
% will be converted into \texttt{TEI xml} as follows:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<div xml:id="div-latin_1" xml:lang="la">
...
</div>
<div xml:id="div-english_1" xml:lang="en">
...
</div>
<div xml:id="div-french_1" xml:lang="fr">
...
</div>
\end{minted}
% \iffalse
%</example>
% \fi
%   \begin{enumerate}
%   \item[\dbend] As can be seen, \pkg{ekdosis} takes care of
%     computing and inserting the |xml:id| attributes which are
%     therefore not accepted in the \enquote*{suboptional} arguments
%     of |texts|.
%   \end{enumerate}
% \item The names of the environments must be specified in exactly the
%   same order as they are supposed to appear in the print edition,
%   from left to right.
% \end{enumerate}
% \DescribeOption{apparatus}
% |apparatus|$=$\meta{\underLine{semicolon}-separated
% values}\hfill\tcboxverb{Default: edition}\\
% Then, the |apparatus| option, just as |texts|, takes a
% \underLine{semicolon}-separated list of previously defined
% environments that shall receive at least one layer of apparatus
% criticus.\\
% \DescribeOption{paired} |paired|$=$\verb+true|false+%
% \hfill\tcboxverb{Default: true (initially not set)}\\
% This named argument does not need a value as it defaults to |true|
% if used. By default, \pkg{ekdosis} follows the \LaTeX{} page
% numbering scheme when multiple texts are arranged on facing
% pages. The |paired| option leaves every right-hand page number
% unchanged, so that both facing pages hold the same page number.\\
% \DescribeOption{lineation} |lineation|$=$\verb+page|document+
% \hfill\tcboxverb{Default: document}\\
% This option applies to edition texts initially set to receive an
% apparatus criticus. By default, lines are continuously numbered
% throughout the document. |lineation=page| sets the numbering to
% start afresh at the top of each page.\\
% \DescribeOption{flush} |flush|$=$\verb+true|false+
% \hfill\tcboxverb{Default: false}\\
% This named argument does not need a value as it defaults to |true|
% if used. This option applies when two or more distinct
% \env{alignment} environments are started on the same page. Should
% this happen, any subsequent \env{alignment} environment must be set
% with the |flush| option so that every one of them carry its own
% apparatus criticus.
%
% As an example, the alignment of the Latin edition text of Caesar's
% \emph{Gallic War}, printed on left-hand pages, along with two
% translations into English and French, printed on right-hand pages,
% can be set as follows:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\begin{alignment}[tcols=3,
                  lcols=1,
                  texts=latin[xml:lang="la"];
                        english[xml:lang="en"];
                        french[xml:lang="fr"],
                  apparatus=latin,
                  lineation=page]
  \begin{latin}
    Gallia est omnis divisa in partes tres quarum unam incolunt
    Belgae, [...]
  \end{latin}
  \begin{english}
    All Gaul is divided into three parts, one of which the Belgae
    inhabit, [...]
  \end{english}
  \begin{french}
    L'ensemble de la Gaule est divisé en trois parties: l'une est
    habitée par les Belges, [...]
  \end{french}
\end{alignment}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \DescribeMacro{\SetAlignment}
% \cs{SetAlignment}\marg{alignment settings}\\
% If the same alignment settings be shared by several \env{alignment}
% environments, common settings can be collected in the argument of
% \cs{SetAlignment}, like
% so:---\\
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\SetAlignment{
  tcols=3,
  lcols=1,
  texts=latin[xml:lang="la"];
        english[xml:lang="en"];
        french[xml:lang="fr"],
  apparatus=latin,
  lineation=page
}
\begin{alignment}
  ...
\end{alignment}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \cs{SetAlignment} can be used either in the preamble or at
% any point of the document to set or to modify alignment settings.
%
% \subsubsection{Appending Hooks to Environments}
% \label{sec:alignment-hooks}
% \DescribeMacro{\AtBeginEnvironment} Once environments corresponding
% to texts to be aligned have been defined, it is advisable to use the
% \cs{AtBeginEnvironment}\marg{environment}\marg{code} command to
% further adjust languages, hyphenation rules, and/or fonts to be
% applied in each environment. To return to the example provided
% above, once \cs{SetAlignment} has been used, the languages can be
% set as follows:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\AtBeginEnvironment{latin}{\selectlanguage{latin}}
\AtBeginEnvironment{english}{\selectlanguage{english}}
\AtBeginEnvironment{french}{\selectlanguage{french}}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Laying Out Parallel Texts}
% \label{sec:laying-out-parallel}
% As \pkg{ekdosis} uses the \pkg{paracol} package for the layout of
% parallel texts, most of the commands provided by this package
% apply. In this respect, quite useful are the commands described in
% sections 7.3 to 7.6 on pp.~15--21 of the documentation of this
% package.\footcite{paracol}
%
% \danger It must be noted that all these commands are to be inserted
% \emph{before} the \env{alignment} environments on which they are
% supposed to operate.
%
% \subsubsection{Columns and Gutters}
% \label{sec:columns-gutters}
% 
% \paragraph{Column Ratio on Single Pages}
% \DescribeMacro{\columnratio}
% \cs{columnratio}\marg{r\textsubscript{1}, r\textsubscript{2}, \dots\
% , r\textsubscript{n}}, where \emph{r\textsubscript{1}} refers to the
% leftmost column, can be used to set the ratio of the columns in
% relation to each other.  Depending on the total number of columns on
% which one wishes to operate, a comma-separated list of decimal
% numbers is expected. As an example, \cs{columnratio}|{0.6}| will
% instruct \pkg{ekdosis} to have the first column spread over 60~\% of
% the total width of the text block, minus the total width of
% intercolumnar gutters.
%
% \paragraph{Column Ratio on Facing Pages}
% \cs{columnratio} accepts an optional argument which can be used as
% described above to set the ratio of columns to be printed on
% right-hand pages, like so: \cs{columnratio}\marg{r\textsubscript{1},
% r\textsubscript{2}, \dots\ ,
% r\textsubscript{n}}\oarg{r\textsubscript{1}, r\textsubscript{2},
% \dots\ , r\textsubscript{n}}.
%
% \paragraph{Column Width on Single Pages}
% \DescribeMacro{\setcolumnwidth}
% \cs{setcolumnwidth}\marg{w\textsubscript{1}, w\textsubscript{2},
% \dots\ , w\textsubscript{n}} operates the same way as
% \cs{columnratio} described above, except that dimensions are
% expected instead of ratios. As an example,
% \cs{setcolumnwidth}|{1in}| will have the width of the first column
% set to \unit[1]{in}.
%
% \paragraph{Gutter Width}
% Each value accepted by \cs{setcolumnwidth} can be expressed as a
% pair as in
% \cs{setcolumnwidth}\marg{w\textsubscript{1}/g\textsubscript{1},
% w\textsubscript{2}/g\textsubscript{2}, \dots\ ,
% w\textsubscript{n}/g\textsubscript{n}} where the character |/| acts
% as a separator, in which case \emph{g\textsubscript{x}} is used to
% set the width of the gutter that follows the
% \emph{x}\textsuperscript{th} column. As an example,
% \cs{setcolumnwidth}|{1in/0.25in}| will print a
% \unit[1]{in} first column, followed by a \unit[0.25]{in} gutter.
%
% \paragraph{Automatically Computed Values}
% Widths of columns and widths of gutters can be replaced with
% \cs{fill} and \cs{columnsep} respectively. As an example,
% \cs{setcolumnwidth}|{\fill/0.25|\allowbreak|in}| will only operate
% on the width that follows the first column, all remaining values
% being computed automatically.
%
% \paragraph{Column and Gutter Width on Facing Pages}
% Just like \cs{columnratio}, \cs{setcolumnwidth} accepts an optional
% argument which can be used to set the width of columns and gutters
% to be printed on right-hand pages, like so:
% \cs{setcolumnwidth}\marg{w\textsubscript{1}, w\textsubscript{2},
% \dots\ , w\textsubscript{n}}\oarg{w\textsubscript{1},
% w\textsubscript{2}, \dots\ , w\textsubscript{n}} for columns only,
% and \cs{setcolumnwidth}\marg{w\textsubscript{1}/g\textsubscript{1},
% w\textsubscript{2}/g\textsubscript{2}, \dots\ ,
% w\textsubscript{n}/g\textsubscript{n}}%
% \oarg{w\textsubscript{1}/g\textsubscript{1},
% w\textsubscript{2}/g\textsubscript{2}, \dots\ ,
% w\textsubscript{n}/g\textsubscript{n}} for columns and gutters.
%
% \paragraph{Vertical Rules}
% Vertical rules between columns can be drawn by setting the length of
% the \LaTeX\ \cs{columnseprule} register to a non-zero value, like
% so:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\setlength{\columnseprule}{0.4pt}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsubsection{Marginal Notes}
% \label{sec:marginal-notes}
% By default, marginal notes that refer to the first column are
% printed in the left margin, while notes that refer to subsequent
% columns are printed in the right margin.
%
% \DescribeMacro{\marginparthreshold} \cs{marginparthreshold}\marg{n},
% where \emph{n} is an integer, can be used to change the default
% settings. This command instructs \pkg{ekdosis} that columns of text,
% up to the \emph{n}\textsuperscript{th} column included, shall have
% their marginal notes printed to the left. As a result, to take an
% example, \cs{marginparthreshold}|{0}| will have all marginal notes
% printed in the right margin. \cs{marginparthreshold} also accepts an
% optional argument, namely
% \cs{marginparthreshold}\allowbreak\marg{n}\oarg{n'}, that can be
% used to set the threshold for columns printed in right-hand pages.
%
% \subsubsection{Regular Footnotes}
% \label{sec:regular-footnotes}
% \DescribeMacro{\footnotelayout} By default, regular footnotes are
% printed at the bottom of the column on which they are
% called. \cs{footnotelayout}\marg{key-letter} can be used to change
% this setting. This command accepts as mandatory argument a
% key-letter which can be either |c|, |p| or |m|. |c| means
% \emph{column-wise} footnotes, which is the default value. |p| means
% \emph{page-wise}: footnotes from all columns are gathered in a
% single spanning block at the bottom of the page. Finally, |m| stands
% for \emph{merge}, which means that all footnotes that are called on
% a given page, including notes that are called outside the
% \env{alignment} environment, are printed in a single spanning block
% at the bottom of the page.
%
% \danger Regular footnotes are printed above the block of critical
% notes. The respective places of these blocks can be interchanged by
% just loading the \pkg{fnpos} package in the
% preamble.\footcite{fnpos}
%
% \section{Laying Out the Apparatus Criticus}
% \label{sec:apparatus-layout}
%
% \subsection{General Hooks}
% \label{sec:general-hooks}
% Some hooks are shared by all layers of notes that are inserted in
% the apparatus criticus (e.g. sources, testimonia, variant readings
% \emph{\&c.})
%
% \DescribeMacro{\SetHooks} \cs{SetHooks}\marg{csv list of hooks} can
% be used either in the preamble or at any point of the document. The
% list of accepted
% hooks at the time of writing follows:---\\
% \DescribeOption{appfontsize} |appfontsize|$=$\meta{command}
% \hfill\tcboxverb{Default: \footnotesize}\\
% This option sets the size of the font to be used in the whole
% apparatus criticus. By default, it is the same as the size used for
% footnotes.\\
% \DescribeOption{refnumstyle} |refnumstyle|$=$\meta{command}
% \hfill\tcboxverb{Default: \bfseries}\\
% |refnumstyle| can be used to set the family, series or shape of the
% font used to print references to line numbers in the apparatus
% criticus. By default, numbers are printed in bold face. As an
% example, |refnumstyle=\normalfont| will have them printed in the
% font and shape selected by default for the document, while
% |refnumstyle=\bfseries\itshape| will have them
% printed in bold and italic.\\
% \DescribeOption{postrefnum} |postrefnum|$=$\meta{command \textbar\
% chars}\hfill\tcboxverb{Default: ~}\\
% |postrefnum| can be used to set what immediately follows the
% reference to line numbers. By default, it is |~|, namely an
% unbreakable space. As an example, |postrefnum=\hskip 0.5em| will
% insert a \unit[0.5]{em} space between the numerals and the beginning
% of all subsequent notes.\\
% \DescribeOption{lemmastyle} |lemmastyle|$=$\meta{command}
% \hfill\tcboxverb{Default: not set}\\
% \newfeature[v1.2] |lemmastyle| can be used to set the family, series
% or shape of the font used to print lemma texts in the apparatus
% criticus. For example, |lemmastyle=|\cs{bfseries} will print all
% instances of lemma text in bold while
% |lemmastyle=|\cs{color}|{blue}| will print them in blue.
% \DescribeOption{readingstyle} |readingstyle|$=$\meta{command}
% \hfill\tcboxverb{Default: not set}\\
% \newfeature[v1.2] |readingstyle| operates in the same way as
% |lemmastyle| but applies to variant readings.\\
% \DescribeOption{initialrule} |initialrule|$=$\meta{command}
% \phts\label{ref:initialrule}\hfill\bgroup\footnotesize
% \tcboxverb{Default: \rule{0.4\columnwidth}{0.4pt} (initially not set)}%
% \egroup
% \newfeature[v1.2] |initialrule| draws a separating rule between the
% edition text and all subsequent layers of critical notes. Of course,
% this option only makes sense when multiple-layer apparatus criticus
% are set. Therefore, it has no effect on single-layer apparatus
% criticus.\\
% \DescribeOption{noinitialrule}\hfill\tcboxverb{Default: not set}\\
% This is a no-value option. It removes any previously set
% |initialrule|.
%
% An example of the way these hooks may be used is provided below in
% \vref{lst:shak-sonnet1}.
%
% \subsection{Single-Layer Apparatus Criticus}
% \label{sec:single-layer-app}
% \paragraph{Specific Commands}
% Single-layer apparatus criticus can be laid out in a variety of
% ways with the following specialized commands, all of which can be
% used in the preamble or at any point of the document:---
%
% \DescribeMacro{\SetLTRapp}
% \DescribeMacro{\SetRTLapp}
% \cs{SetLTRapp} and \cs{SetRTLapp} are two argument-less commands to
% set the direction of the apparatus criticus, either left-to-right or
% right-to-left.
%
% \DescribeMacro{\SetSeparator} \cs{SetSeparator}\marg{separator} is
% used to change the separator between lemma texts and variants
% readings. By default, the separator is a closing square bracket
% followed by a space (\verb*+] +).
%
% \DescribeMacro{\SetBeginApparatus}
% \cs{SetBeginApparatus}\marg{characters\textbar commands} can be used
% to append \meta{characters} or \meta{commands} at the beginning of
% the apparatus block. By default, nothing is appended. For instance,
% |\SetBeginApparatus{\textbf{Apparatus:}}| will append
% \enquote{\textbf{Apparatus:}} at the beginning of the apparatus
% block, while |\SetBeginApparatus{\hskip 1em}| will set an
% indentation of one em.
%
% \DescribeMacro{\SetEndApparatus}\phts\label{ref:setendapparatus}
% \cs{SetEndApparatus}\marg{characters} can be used to append
% \meta{characters} at the end of the apparatus block. By default,
% nothing is appended. \phts\label{ref:ending-dot}As an example of
% use, |\SetEndApparatus{.}| will have a period printed at the end of
% the apparatus as it is customary in some
% editions.\footnote{\label{fn:rm-dots}See also below
% \vpageref{sec:superfluous-dots} on how to remove superfluous dots.}
%
% \DescribeMacro{\SetUnitDelimiter}
% \cs{SetUnitDelimiter}\marg{delimiter} can be used to set the
% delimiter between entries in the apparatus criticus. By default,
% there is no delimiter except a simple space. \meta{delimiter} can be
% a broad space (such as |\hskip 0.75em| for instance as in the OCT
% series) or the divider-sign (‖, as in the Budé series).
%
% \DescribeMacro{\SetDefaultRule}
% By default, \pkg{ekdosis} draws a separating line between the
% edition text and the apparatus criticus. This line is initially
% defined as
% |\rule{0.4\columnwidth}{0.4pt}|. \cs{SetDefaultRule}\marg{line
% definition} can be used in the preamble or at any point of the
% document to change the default setting. Leaving this argument empty
% as in \cs{SetDefaultRule}|{}| removes the line.
%
% \DescribeMacro{\SetApparatusLanguage}
% \phts\label{ref:app-lang}\newfeature[v1.2]
% \cs{SetApparatusLanguage}\marg{languagename} can be used when it is
% needed to apply in the apparatus criticus a language different from
% the one that is selected in the edition text.
% 
% \DescribeMacro{\SetApparatusNoteLanguage}
% \phts\label{ref:app-note-lang}\newfeature[v1.3]
% \cs{SetApparatusNoteLanguage}\marg{languagename} can be used when it
% is needed to apply in text entries introduced by the mandatory
% argument of the \cs{note} command as described in
% \vref{ref:type-note}\===namely
% \cs{note}\oarg{options}\marg{text}\===a language different from the
% one that is selected in the edition text.
% 
% \paragraph{General Command}
% \DescribeMacro{\SetApparatus} \cs{SetApparatus}\marg{csv list of
% apparatus settings}\phts\label{ref:apparatus-settings-b}\\
% Finally, all the settings described above can also be collected in
% the argument of \cs{SetApparatus}. \cs{SetApparatus} accepts the
% following list of comma-separated |key=value| options:---\\
% \DescribeOption{direction} |direction|$=$\verb+LR|RL+
% \hfill\tcboxverb{Default: LR}\\
% The writing direction of the apparatus criticus, either
% left-to-right (|LR|) or right-to-left (|LR|).\\
% \DescribeOption{sep} |sep|$=$\meta{command \textbar\ chars}
% \hfill\tcboxverb{Default: ]␣}\\
% The separator between lemma texts and variant readings.\\
% \DescribeOption{delim} |delim|$=$\meta{delimiter}
% \hfill\tcboxverb{Default: not set}\\
% The delimiter between entries in the apparatus criticus. As said
% above, there is no default delimiter except a simple space.\\
% \DescribeOption{bhook} |bhook|$=$\meta{characters\textbar commands}
% \hfill\tcboxverb{Default: empty}\\
% The characters or commands to be appended at the beginning of the
% apparatus block.\\
% \DescribeOption{ehook} |ehook|$=$\meta{characters}
% \hfill\tcboxverb{Default: empty}\\
% The characters to be appended at the end of the apparatus
% block.\footnote{See also n.~\vref{fn:rm-dots}.}\\
% \DescribeOption{rule} |rule|$=$\meta{command}\verb+|+|none|
% \hfill\tcboxverb{Default: \rule{0.4\columnwidth}{0.4pt}}\\
% As described above, |rule| is used to draw the separating line
% between the edition text and the apparatus criticus. |rule=none| can
% also be used to remove the line.\\
% \DescribeOption{norule}\hfill\tcboxverb{Default: not set}\\
% |norule| does not accept any value and has the same effect as
% |rule=none|.\phts\label{ref:apparatus-settings-e}\\
% \DescribeOption{lang} |lang|$=$\meta{languagename}
% \newfeature[v1.2]\phts\label{ref:app-lang-opt}
% \hfill\tcboxverb{Default: not set}\\
% |lang=<languagename>| is used as described
% \vpageref[above]{ref:app-lang} when it is needed to apply in the
% apparatus criticus a language different from the one that is
% selected in the edition text. |languagename| can be any value
% accepted by \pkg{babel} or \pkg{polyglossia}.
% \DescribeOption{notelang} |notelang|$=$\meta{languagename}
% \newfeature[v1.3]\phts\label{ref:app-note-lang-opt}
% \hfill\tcboxverb{Default: not set}\\
% |notelang=<languagename>| is used as described
% \vpageref[above]{ref:app-note-lang} when is needed to apply in text
% entries introduced by the mandatory argument of the \cs{note}
% command as described in \vref{ref:type-note}\===namely
% \cs{note}\oarg{options}\marg{text}\===a language different from the
% one that is selected in the edition text. |languagename| can be any
% value accepted by \pkg{babel} or \pkg{polyglossia}.
% 
% As an example, an apparatus criticus with references to line numbers
% printed in normal font, a colon as a separator between lemma texts
% and variant readings, a broad space as a delimiter between entries
% and a \unit[0.7]{in} line above could be laid out as follows:---
%
% \phts\label{ex:single-layer-app-layout}
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\SetHooks{
  refnumstyle=\normalfont
}
\SetApparatus{
  sep={: },
  delim=\hskip 1em,
  rule=\rule{0.7in}{0.4pt}
}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \paragraph{Footnote Separator}
% \DescribeMacro{\footnoteruletrue} \DescribeMacro{\footnoterulefalse}
% As already seen above, \pkg{ekdosis} takes care of drawing a
% separating line between the edition text and the apparatus
% criticus. Therefore, it may be not desirable to have the standard
% \LaTeX\ \enquote{footnoterule} printed on every page where regular
% footnotes are found. \cs{footnoterulefalse} removes it while
% \cs{footnoteruletrue} leaves it untouched. The latter is set by
% default.
%
% \subsection{Multiple-Layer Apparatus Criticus}
% \label{sec:multilayer-apparatus}
% As said above in \vref{it:multilayer-feature}, \pkg{ekdosis} can
% print edition texts equipped with multiple-layer apparatus
% criticus. To take an example, most classical editions provide at
% least two layers of notes: one to collect references to testimonia
% or parallel passages (apparatus testium) and the other to record
% variant readings (the apparatus criticus \emph{stricto sensu}). The
% former is always printed above the latter.
%
% \danger The default single-layer apparatus criticus that is
% described above in \vref{sec:single-layer-app} is called |default|
% internally. If any additional layer of notes be declared in the
% preamble, this |default| layer must be included in the list of
% declared layers.\\
% \DescribeMacro{\SetDefaultApparatus}\phts\label{ref:ekd-default-app}
% \cs{SetDefaultApparatus}\marg{name} can be used at any point of the
% document to change the name to be used as the default one by
% \pkg{ekdosis}.
%
% \subsubsection{Declaring Additional Layers}
% \label{sec:declaring-layers}
% \DescribeMacro{\DeclareApparatus}
% \cs{DeclareApparatus}\marg{name}\oarg{csv list of apparatus
% settings} is a preamble-only command. As a mandatory argument, it
% takes the name of the new layer of notes to be inserted in the
% apparatus block. Declared layers are then printed one below the
% other in the exact same order as they are declared in the
% preamble. Therefore, one additional layer meant to print the
% testimonia above the variant readings (apparatus testium) can be
% declared as follows:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
% preamble:
\DeclareApparatus{testium}
\DeclareApparatus{default}
\end{minted}
% \iffalse
%</example>
% \fi
%
% In this example, |testium| is a new name for |default|, as said
% just above, is already known to \pkg{ekdosis} and used as the
% default layer of notes. Furthermore, as |testium| is declared before
% |default|, \pkg{ekdosis} will print the testimonia at the top of the
% apparatus block.
%
% \subsubsection{Laying Out Layers With The Optional Argument
% of \cs{DeclareApparatus}}
% \label{sec:layout-layers}
% \DescribeOption{direction}
% \DescribeOption{sep}
% \DescribeOption{delim}
% \DescribeOption{bhook}
% \DescribeOption{ehook}
% \DescribeOption{rule}
% \DescribeOption{norule}
% \DescribeOption{lang}\phts\label{ref:apps-lang-opt}
% \DescribeOption{notelang}
% With regard to layout, any declared layer inherits the default values
% described above in \vref{sec:single-layer-app}. That said, as the
% optional argument of \cs{DeclareApparatus} accepts the exact same
% |key-value| options as \cs{SetApparatus} described
% \vpagerefrange{ref:apparatus-settings-b}{ref:apparatus-settings-e},
% \pkg{ekdosis} provides a straightforward mechanism to have any layer
% printed in a distinct layout.
%
% To return to the example provided
% \vpageref[above]{ex:single-layer-app-layout}, one could keep the
% same settings as above for the variant readings, declare an
% apparatus testium with a closing square bracket as a separator and
% finally remove the line between the testimonia and the variant
% readings like so:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\SetHooks{
  refnumstyle=\normalfont,
  initialrule=\rule{0.7in}{0.4pt}
}
\DeclareApparatus{testium}[
  sep={] },
  delim=\hskip 1em,
  norule
]
\DeclareApparatus{default}[
  sep={: },
  delim=\hskip 1em,
  rule=\relax
]
\end{minted}
% \iffalse
%</example>
% \fi
%
% \begin{remarks}
% \item The general hook \texttt{initialrule} used here (l.~3) is
%   described above \vpageref{ref:initialrule}.
% \item \cs{relax} (l.~13) is a \TeX\ primitive that instructs to do
%   nothing. Therefore, |rule=\relax| is not strictly equivalent to
%   |norule|: with the former, \cs{relax} removes the rule but leaves
%   untouched the subsequent carriage return: as a result, the layers
%   are visually separated from one another by a blank line. With the
%   latter everything is removed, carriage return included.
% \end{remarks}
%
% \paragraph{Limiting the Number of Entries per Page}
% \phts\label{ref:maxentries}
% In some instances, it can be useful to set a limit to the number of
% entries per page that a given layer of critical notes may accept,
% notably when entries are so abundant in number that \pkg{ekdosis}
% may oscillate indefinitely between different sets of page decisions
% without being able to settle down.\\
% \DescribeOption{maxentries} |maxentries|=\meta{n} (where $n \geq
% 10$) \hfill\tcboxverb{Default: not set}\\
% If |maxentries|$=$\meta{n} be set, then \pkg{ekdosis} will issue
% \cs{pagebreak} (namely \cs{penalty}|-10000|) just after the
% \emph{n\textsuperscript{th}} entry has been inserted in the layer of
% the apparatus criticus this option is related to. As a result, the
% page will actually break at the end of the current line. The
% particulars of this technique will be discussed below in
% \vref{sec:oscillating-problem}.
%
% \section{Inserting Notes in Multiple-Layer Apparatus}
% \label{sec:notes-in-multilayer-app}
% As said above in \vref{sec:multilayer-apparatus}, \pkg{ekdosis}
% initially sets one layer of notes that is called the
% \textooquote|default|\textcoquote\ layer. As a result, any note
% inserted within the argument of \cs{app}|{}| as described
% \vpageref{ref:app-cmd} will go into that layer of the apparatus,
% unless \cs{SetDefaultApparatus} has been used to set another
% name for the default layer (see above
% \vpageref{ref:ekd-default-app}).
%
% \subsection{Variant Readings}
% \label{sec:variant-readings}
% In most cases, all variant readings go into the
% \textooquote|default|\textcoquote\ layer of the apparatus
% criticus. But in some other cases, for example when the manuscripts
% used refer to different recensions, it may happen that one wishes to
% record the related variants in separate layers. As already described
% \vpageref{ref:app-type}, the |type| optional argument of the
% \cs{app} command can be used to insert lemma texts and associated
% variants in any other \enquote*{declared} layer of the apparatus
% criticus.
%
% The following example assumes that some edition text is received in
% two different recensions and the variant readings that belong to the
% first recension are recorded in the default layer of notes while
% those of the second recension are to be printed in a second layer,
% below the default one. First, both layers must be declared in the
% preamble in sequence, like so:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\DeclareApparatus{default} % default layer
\DeclareApparatus{rec2} % additional layer below the default one
\end{minted}
% \iffalse
%</example>
% \fi
%
% Should one wish to refer to |rec1| as the default layer, then
% \cs{SetDefaultApparatus} must be used, like so:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\SetDefaultApparatus{rec1}
\DeclareApparatus{rec1} % new layer set as default
\DeclareApparatus{rec2} % additional layer below the default one
\end{minted}
% \iffalse
%</example>
% \fi
%
% Then, whatever option has been chosen, lemma texts and variants
% inserted with \cs{app}|{}| will go into the upper, default layer of
% notes, while those inserted with \cs{app}|[type=rec2]{}| will go
% into the lower one:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
Some \app{
  \lem{word}
  \rdg{reading}
} to go into the default layer of notes.

Some \app[type=rec2]{
  \lem{note}
  \rdg{comment}
} to be recorded as part of the second recension.
\end{minted}
% \iffalse
%</example>
% \fi
%
% \danger At any rate, |type=default| or |type=rec1|, depending on
% what has been chosen, must be used should the editor wish to retain
% that information in the \texttt{TEI xml} output file.
%
% \subsection{Other Notes for Comments, Sources or Testimonia}
% \label{ref:type-note}
% Additional layers of notes can be used to print short comments or to
% record references to texts quoted by the author of the edited text
% or references to the edited text by other authors or
% translators. The former set is called an \emph{apparatus fontium}
% while the latter is called an \emph{apparatus testium}.
%
% \danger From a technical standpoint, these notes are very different
% from the short editorial notes inserted between lemma texts and
% variant readings that have been described above
% \vpageref{ref:editorial-notes}. However, for the sake of consistency
% with \texttt{TEI xml} encoding, \pkg{ekdosis} uses the same command
% \cs{note} to insert both kinds of notes.
%
% \danger One must also keep in mind that the notes that are described
% in this section refer either to a single word or to a span of
% text. By consequence, as boundaries must always be set outside spans
% of text, notes must be inserted immediately before the word or words
% they are related to. As a result of this rule, all spaces subsequent
% to \cs{note} are ignored.
%
% \DescribeMacro{\note} \cs{note}\oarg{options}\marg{text}\\
% As said above, \cs{note}, when found outside \cs{app}|{}|, is used
% to insert in additional layers of the apparatus short comments or
% references to texts quoted or cited in the edition text. It accepts
% the following comma-separated list of |key-value| optional
% arguments:---\\
% \DescribeOption{type} |type|$=$\meta{type}\\
% |type| is used to specify the name of the layer where the note is to
% be printed.\footnote{See \vref{sec:declaring-layers} to learn how to
% declare and lay out new layers of notes.}\\
% \DescribeOption{sep} |sep|$=$\meta{command \textbar\ chars}\\
% The separator between the lemma text and the contents of the note.\\
% \DescribeOption{nosep} |nosep|$=$\verb+true|false+\\
% This named argument does not need a value as it defaults to |true|
% if used. Obviously, |nosep| removes the separator mentioned
% above.\\
% \DescribeOption{lem} |lem|$=$\meta{lemma text}\\
% |lem| is the span of text the note is about. It may consist of one
% or more words, or of an abridged lemma text.\\
% \DescribeOption{num} (no-value argument)\newfeature[v1.3]\\
% |num| takes no value. If used, this argument instructs to print any
% line number that \pkg{ekdosis} may have decided not to print in the
% apparatus criticus before the note.\\
% \DescribeOption{nonum} (no-value argument)\\
% Compared to |num|, |nonum| does the opposite. If used, any number
% that \pkg{ekdosis} may have decided to print before the note
% is suppressed.\\
% \DescribeOption{labelb} |labelb|$=$\meta{label}
% \hfill\tcboxverb{Mandatory}\\
% |labelb| is the unique label to serve as a reference for the point
% immediately preceding the lemma text.  \danger |labelb| is used by
% \pkg{ekdosis} to print the line numbers in the apparatus criticus
% and to set the |left()| XPointer should \texttt{TEI} output be
% required. Therefore, it must be specified. Otherwise, \pkg{ekdosis}
% will issue an error message. However, two strictly consecutive
% \cs{note} commands are allowed to share the same |labelb| value for
% it may happen that consecutive notes need to refer to spans of text
% that begin at the exact same location. In this case, \pkg{ekdosis}
% generates only one \cs{linelabel} and one corresponding
% |<anchor>| element in the \texttt{TEI xml} file.\\
% \DescribeOption{labele} |labele|$=$\meta{label}\\
% |labele| is the unique label to serve as a reference for the point
% immediately following the lemma text. Contrary to |labelb|, |labele|
% may be left unspecified if the note be only about one word. If the
% note be about a span, then |labele| must be specified.\\
% \DescribeMacro{\linelabel} \cs{linelabel}\marg{label}\\
% If |labele|$=$\meta{some\_label} be specified in the optional
% argument of \cs{note}, \cs{linelabel}\marg{some\allowbreak\_label}
% must be inserted immediately after the span of text that the note is
% about so that \pkg{ekdosis} can locate the exact point where the
% lemma text addressed by the note ends, like so:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
% Preamble:
% \DeclareApparatus{fontium}[
%         delim=\hskip0.75em,
%         bhook=\textbf{Sources:},
%         ehook=.]
% \DeclareApparatus{default}[
%         delim=\hskip0.75em,
%         ehook=.]
% Document:
\begin{ekdosis}
  The oldest monument of the Germans is their language, which, before
  untold centuries, was the companion of their travels from central
  Asia; a language, copious, elastic, inviting self-explaining
  combinations and independent development; lending itself alike to
  daily life and imagination, to description and abstract thought.
  \note[type=fontium, labelb=B61e, labele=B62a, lem={They
    had... slave}]{Waitz, \emph{Deutsche Verfassungs Geschichte},
    i. 86} They had a class of nobles, but their tongue knew no word
  for slave.\linelabel{B62a}\footnote{George Bancroft, \emph{History
      of the United States from the Discovery of the American
      Continent}, II.61--2.}
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% PDF output:---
% \medskip
% 
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%     The oldest monument of the Germans is their language, which,
%     before untold centuries, was the companion of their travels from
%     central Asia; a language, copious, elastic, inviting
%     self-explaining combinations and independent development;
%     lending itself alike to daily life and imagination, to
%     description and abstract thought.  \note[type=fontium,
%     labelb=B61e, labele=B62a, lem={They had... slave}]{Waitz,
%     \emph{Deutsche Verfassungs Geschichte}, i. 86} They had a class
%     of nobles, but their tongue knew no word for
%     slave.\linelabel{B62a}\footnote{George Bancroft, \emph{History of
%     the United States from the Discovery of the American Continent},
%     II.61--2.}
%   \end{specimen}
% \end{alignment}
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>The oldest monument of the Germans is their language,
which, before untold centuries, was the companion of their
travels from central Asia; a language, copious, elastic,
inviting self-explaining combinations and independent
development; lending itself alike to daily life and
imagination, to description and abstract thought. 
<note type="fontium" target="#range(right(B61e),left(B62a))">Waitz, 
<emph>Deutsche Verfassungs Geschichte</emph>, i. 86</note>
<anchor xml:id="B61e" />They had a class of nobles, but
their tongue knew no word for slave.
<anchor xml:id="B62a" />
<note place="bottom">George Bancroft, 
<emph>History of the United States from the Discovery of
the American Continent</emph>, II.61--2.</note></p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \paragraph{\cs{note} or \cs{linelabel} inside \cs{lem}}
% It may happen that the \cs{note} or \cs{linelabel} command is found
% inside the argument of \cs{lem}. Obviously, inserting such a command
% in the apparatus criticus in print makes no sense and will lead to
% an error. The solution is to insert in the value of the |alt|
% optional argument of \cs{lem} a duplicate of the lemma text devoid
% of that command, like so:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
This is some \app{
  \lem[alt=dummy]{\note[type=fontium, labelb=bnote, labele=enote,
    lem=dummy... command]{Text of the note.}
    dummy}
  \rdg{pseudo}}
text to demonstrate how to insert a note in the argument of the
\emph{lem} command.\linelabel{enote}
\end{minted}
% \iffalse
%</example>
% \fi
%
% PDF output:---
% \medskip
% 
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
% This is some \app{
%   \lem[alt=dummy]{\note[type=fontium, labelb=bnote, labele=enote,
%     lem=dummy... command]{Text of the note.}
%     dummy}
%   \rdg{pseudo}}
% text to demonstrate how to insert a note in the argument of the
% \emph{lem} command.\linelabel{enote}
%   \end{specimen}
% \end{alignment}
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}{xml}
<p>This is some 
<app>
  <lem>
  <anchor xml:id="bnote" />dummy</lem>
  <note type="fontium"
  target="#range(right(bnote),left(enote))">Text of the
  note.</note>
  <rdg>pseudo</rdg>
</app>text to demonstrate how to insert a note in the
argument of the 
<emph>lem</emph>command.
<anchor xml:id="#enote" /></p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% As can be seen from the \texttt{TEI xml} output above, the span of
% text the note is about has been carefully delimited by two anchors
% (ll.~4 and 12), the first of which falls within |<lem>| (l.~4), but
% \pkg{ekdosis} has taken care of moving the note itself out of this
% element (ll.~5--7). Otherwise, the \texttt{TEI} output would not be
% valid.
%
% \needspace{4\baselineskip}
% \section{Poetry}
% \label{sec:poetry}
% \subsection[The Standard \textsf{verse} Environment]{The Standard
% \env{verse} Environment}
% \label{sec:stand-verse-env}
%
% In order to typeset verse texts or poems, \LaTeX\ provides the
% standard \env{verse} environment. Within this environment, |\\| is
% normally used to end lines, with the exception of the last line. As
% a result, stanzas are separated from one another by a blank line.
%
% \pkg{ekdosis} provides \env{ekdverse} which is recommended for use
% in place of the standard \env{verse} environment. By default,
% \env{ekdverse} produces the same result as \env{verse}.  However,
% \pkg{ekdosis} deviates a little from the standard usage for it needs
% all lines of poetry to be ended by |\\| as a distinct marker. In the
% following listing, stanzas are visually separated from one another
% by an additional vertical space of \unit[2]{ex} (l.~5). Between
% stanzas, |%| is used to prevent \TeX\ from
% introducing a blank line. But a blank line\===or even no blank
% line\===would produce the exact same result:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\begin{ekdverse}
  It is an ancient Mariner,\\
  And he stoppeth one of three.\\
  ‘By thy long grey beard and glittering eye,\\
  Now wherefore stopp'st thou me?\\[2ex]
  %
  The Bridegroom's doors are opened wide,\\
  And I am next of kin;\\
  The guests are met, the feast is set:\\
  May'st hear the merry din.’\\
\end{ekdverse}
\end{minted}
% \iffalse
%</example>
% \fi
%
% PDF output:---
% \medskip
% \SetLineation{vmodulo=0}
% \begingroup
% \needspace{7\baselineskip}
% \resetlinenumber\resetvlinenumber
% \begin{alignment}[flush,tcols=1,texts=coleridge,apparatus=coleridge]
%   \begin{coleridge}
%     \begin{verse}
%       It is an ancient Mariner,\\
%       And he stoppeth one of three.\\
%       ‘By thy long grey beard and glittering eye,\\
%       Now wherefore stopp'st thou me?\\[2ex]
%
%       The Bridegroom's doors are opened wide,\\
%       And I am next of kin;\\
%       The guests are met, the feast is set:\\
%       May'st hear the merry din.’\\
%     \end{verse}
%   \end{coleridge}
% \end{alignment}
% \endgroup
% \SetLineation{vmodulo=1}
% \medskip
% 
% \indent\texttt{TEI xml} output:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<lg>
  <l>It is an ancient Mariner,</l>
  <l>And he stoppeth one of three.</l>
  <l>‘By thy long grey beard and glittering eye,</l>
  <l>Now wherefore stopp'st thou me?</l>
  <l>The Bridegroom's doors are opened wide,</l>
  <l>And I am next of kin;</l>
  <l>The guests are met, the feast is set:</l>
  <l>May'st hear the merry din.’</l>
</lg>
\end{minted}
% \iffalse
%</example>
% \fi
%
% One would have expected here the |<lg>| element to be used as
% delimiter to encode the stanzaic verse forms. But as can be seen,
% only the outermost level of line group has been converted into
% \texttt{TEI xml}, let alone the vertical spacing between stanzas
% which has been ignored.  This is because it is about as much as the
% standard \env{verse} environment provides.
%
% \subsection[The \textsf{verse} Package]{The \pkg{verse} Package}
% \label{sec:verse-package}
% \newfeature[v1.2]
% \pkg{ekdosis} can use the facilities offered by the excellent
% \pkg{verse} package\footcite{verse} to which it adds a specific
% environment for the encoding of line groups such as
% stanzas. Furthermore, as the \pkg{verse} package provides its own
% numbering mechanism, the lines can be numbered independently of
% prose text.\footnote{See \vpageref{ref:verse-lineation} for
% details.}
%
% \danger For what is described in this section to operate,
% \pkg{ekdosis} must be loaded with the global option |poetry=verse|
% as explained above \vpageref{ref:poetry-opt}. Simply loading the
% \pkg{verse} package by means of \cs{usepackage} will have no effect.
%
% \danger The foregoing does not apply if the \cls{memoir} class be
% used.\footcite{memoir} In this case, \pkg{ekdosis} automatically
% uses the code provided by this class without the need to set
% the global option |poetry=verse|.
%
% \paragraph{Compatible Verse Commands}
% The reader is invited to refer to the documentation of the
% \env{verse} package for detailed information.  Within the
% \env{ekdverse} environment, |\\| \emph{must be used} at the end of
% each line, as follows:---
% \begin{enumerate}
% \item |\\| is the standard command to be used at the end of each
%   line.
% \item |\\!| must be used at the end of stanzas or line groups
%   instead of |\\|.
% \item |\\*| does the same as |\\| except that it prohibits a page
%   break after the line.
% \item |\\>| is for line breaks within a verse line.
% \end{enumerate}
%
% All of these commands can take a dimension as optional argument,
% like so: |\\[30pt]|, |\\![30pt]|, |\\*[30pt]| or |\\>[30pt]|. If
% |\\|, |\\!| or |\\*| be used, a vertical space of the dimension
% specified is added between lines, whereas |\\>[...]| adds an
% horizontal space after the line break.
%
% \DescribeMacro{\vin} \phts\label{ref:verse-vin}\cs{vin} indents a
% verse line by a length which is by default \unit[1.5]{em}. This
% length is stored as \cs{vgap} and can be changed by \cs{setlength}
% or \cs{addtolength}.
%
% \paragraph{The \env{ekdverse} Environment}
% \DescribeEnv{ekdverse} \cs{begin}|{ekdverse}|\oarg{options} \dots\
% \cs{end}|{ekdverse}|\phts\label{ref:ekdverse-syntax}\\
% This environment is used to hold verse lines as described above and
% may receive an optional argument in which the following
% \enquote{name$=$value} arguments are accepted:---\\
% \DescribeOption{width} |width|$=$\meta{length}
% \hfill\tcboxverb{Default: \linewidth}\\
% If |width| be supplied, it is taken as a length in relation to which
% the entire contents of the environment is to be horizontally
% centered. If given, this dimension may correspond to an average line
% or to the longest line of the line group. To this end, the standard
% \LaTeX\ command \cs{settowidth} can be used, like so:--- %
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\settowidth{\versewidth}{This is the average line,}
\begin{ekdverse}[width=\versewidth]
...
\end{ekdverse}
\end{minted}
% \iffalse
%</example>
% \fi %
% \begin{remarks}
% \item[\textsc{Rem.}] \cs{versewidth} is provided by the \env{verse}
%   package as a convenience and can be used by \env{ekdosis}.
% \end{remarks}
% \DescribeOption{type} |type|$=$\meta{type}
% \hfill\tcboxverb{Default: not set}\\
% This named argument is used in the \texttt{TEI xml} output to
% name the type of unit encoded within the |<lg>| element, viz.\
% \enquote{sonnet}, \enquote{quatrain}, \enquote{couplet} and the
% like.
%
% \danger Unlike the \texttt{TEI xml} element |<lg>|, \env{ekdverse}
% may not nest hiearchichally. Within this environment,
% \env{ekdstanza} must be used instead to encode stanzas as described
% \vpageref[below][below]{ref:ekdstanza}.
%
% As an example, the first five lines of Homer's \emph{Odyssey} could
% be encoded like so:\footcite{HomerMurray}---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\begin{alignment}[tcols=2,
                  lcols=2,
                  texts=homer[xml:lang="grc"];murray[xml:lang="en"],
                  apparatus=homer]
  \begin{homer}
    \begin{ekdverse}
       Ἄνδρα μοι ἔννεπε, Μοῦσα, πολύτροπον, ὃς μάλα πολλὰ \\
       πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν· \\
       πολλῶν δ' ἀνθρώπων ἴδεν ἄστεα καὶ
                     \app{\lem{νόον}
                          \rdg[resp=Zen]{νόμον}
                          \note{Cf. Schol.}} ἔγνω, \\
       πολλὰ δ' ὅ γ' ἐν πόντῳ πάθεν ἄλγεα ὃν κατὰ θυμόν, \\ 
       ἀρνύμενος ἥν τε ψυχὴν καὶ νόστον ἑταίρων. \\
     \end{ekdverse}
  \end{homer}
  \begin{murray}
    Tell me, O Muse, of the man of many devices, who wandered full
    many ways after he had sacked the sacred citadel of Troy. Many
    were the men whose cities he saw and whose mind he learned, aye,
    and many the woes he suffered in his heart upon the sea, seeking
    to win his own life and the return of his
    comrades.
  \end{murray}
\end{alignment}
\end{minted}
% \iffalse
%</example>
% \fi
%
% PDF output:---
% \medskip
% \begingroup
% \setcolumnwidth{0.6\textwidth}
% \setlength{\leftmargini}{0em}
% \needspace{7\baselineskip}
% \resetlinenumber\resetvlinenumber
% \begin{alignment}[flush,
%   lcols=2,
%   texts=homer[xml:lang="grc"];murray[xml:lang="en"],
%   apparatus=homer]
%   \AtBeginEnvironment{homer}{\selectlanguage{greek}}
%   \setlength{\vrightskip}{0.25em}
%   \begin{homer}
%     \begin{ekdverse}
%        Ἄνδρα μοι ἔννεπε, Μοῦσα, πολύτροπον, ὃς μάλα πολλὰ \\
%        πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν· \\
%        πολλῶν δ' ἀνθρώπων ἴδεν ἄστεα καὶ
%                      \app{\lem{νόον}
%                           \rdg[resp=hZen]{νόμον}
%                           \note{Cf. Schol.}} ἔγνω, \\
%        πολλὰ δ' ὅ γ' ἐν πόντῳ πάθεν ἄλγεα ὃν κατὰ θυμόν, \\ 
%        ἀρνύμενος ἥν τε ψυχὴν καὶ νόστον ἑταίρων. \\
%      \end{ekdverse}
%   \end{homer}
%   \begin{murray}
%     Tell me, O Muse, of the man of many devices, who wandered full
%     many ways after he had sacked the sacred citadel of Troy. Many
%     were the men whose cities he saw and whose mind he learned, aye,
%     and many the woes he suffered in his heart upon the sea, seeking
%     to win his own life and the return of his comrades.
%   \end{murray}
% \end{alignment}
% \endgroup
% \medskip
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<div xml:id="div-homer_1" xml:lang="grc">
  <lg>
    <l>Ἄνδρα μοι ἔννεπε, Μοῦσα, πολύτροπον, ὃς μάλα πολλὰ</l>
    <l>πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·</l>
    <l>πολλῶν δ' ἀνθρώπων ἴδεν ἄστεα καὶ 
    <app>
      <lem>νόον</lem>
      <rdg resp="#Zen">νόμον</rdg>
      <note>Cf. Schol.</note>
    </app>ἔγνω,</l>
    <l>πολλὰ δ' ὅ γ' ἐν πόντῳ πάθεν ἄλγεα ὃν κατὰ θυμόν,</l>
    <l>ἀρνύμενος ἥν τε ψυχὴν καὶ νόστον ἑταίρων.</l>
  </lg>
</div>
<div xml:id="div-murray_1" xml:lang="en">
  <p>Tell me, O Muse, of the man of many devices, who
  wandered full many ways after he had sacked the sacred
  citadel of Troy. Many were the men whose cities he saw and
  whose mind he learned, aye, and many the woes he suffered
  in his heart upon the sea, seeking to win his own life and
  the return of his comrades.</p>
</div>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \paragraph{Stanzas}
% As can be seen above, the \LaTeX\ \env{ekdverse} environment is
% translated into the \texttt{TEI xml} |<lg>| element. The |type|
% attribute may then be used to name the type of unit encoded by this
% element.
%
% \DescribeEnv{ekdstanza} \cs{begin}|{ekdstanza}|\oarg{options} \dots\
% \cs{end}|{ekdstanza}| \phts\label{ref:ekdstanza}\\
% This environment is used within \env{ekdverse} to encode succeeding
% stanzaic forms. Within \env{ekdstanza}, the last line is ended by
% |\\!| or |\\| depending on whether an additional vertical space is
% required between stanzas. This environment may receive an optional
% argument in which the following \enquote{name$=$value} argument is
% accepted:---\\
% \DescribeOption{type} |type|$=$\meta{type}
% \hfill\tcboxverb{Default: not set}\\
% As in the case of \env{ekdverse}, this named argument is used in the
% \texttt{TEI xml} output to name the type of unit encoded within the
% |<lg>| element, viz.\ \enquote{quatrain}, \enquote{couplet} and the
% like.
%
% \paragraph{Indentation Patterns}
% \pkg{ekdosis} can use the \env{patverse} environment and its
% associated command \cs{indentpattern} that are provided by the
% \pkg{verse} package. As described in the documentation of this
% package,\footcite[6]{verse} the indentation pattern consists of an
% array of digits, \emph{d\textsubscript{1}} to
% \emph{d\textsubscript{n}}, where the \emph{n\textsuperscript{th}}
% line is indented by \emph{d\textsubscript{n}} times the amount of
% \cs{vgap} described above \vpageref{ref:verse-vin}.
%
% The overall structure of lines grouped into stanzas may look as
% follows:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[escapeinside=++]{latex}
\begin{ekdverse}[type={+\emph{overall type}+}]
  \identpattern{+\emph{digits}+}
  \begin{patverse}
    \begin{ekdstanza}[type={+\emph{stanza 1 type}+}]
      line 1 \\
      line 2 \\
      [...]
      final line \\!
    \end{ekdstanza}
  \end{patverse}
\end{ekdverse}
\end{minted}
% \iffalse
%</example>
% \fi
%
% Of course, if no indentation pattern be required or be only required
% occasionally, \env{patverse} (ll.~3 and 10) and \cs{indentpattern}
% (l.~2) are of no use:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[escapeinside=++]{latex}
\begin{ekdverse}[type={+\emph{overall type}+}]
  \begin{ekdstanza}[type={+\emph{stanza 1 type}+}]
    line 1 \\
    line 2 \\
    \vin indented line 3 \\
    [...]
    final line \\!
  \end{ekdstanza}
\end{ekdverse}
\end{minted}
% \iffalse
%</example>
% \fi
%
% A detailed example follows. It is taken from
% \citename{McDonald1916}{editor}'s edition of Shakespeare's
% \emph{Sonnets} from the Quarto of 1609 with variorum
% readings.\footcite[Sonnet~1, \pno~15]{McDonald1916} Compared to
% \citename{McDonald1916}{shorteditor}'s edition, an effort has been
% made to use the typography and punctuation of the original edition
% which can be consulted online at the British Library's
% website.\footnote{Shake-speares \emph{Sonnets}. Neuer before
% Imprinted. (A Louers Complaint. By William
% Shake-speare.). \url{https://www.bl.uk/collection-items/first-edition-of-shakespeares-sonnets-1609}.
% Call number \texttt{C.21.c.44}, fol.~B.} However, this typographical
% refinement has been retained for the sonnet only. For the sake of
% clarity, the line numbers and the apparatus criticus use modern
% typography. The references to line numbers in the apparatus criticus
% have been made consistent with
% \citename{McDonald1916}{shorteditor}'s edition, as have the entries
% in the apparatus criticus, namely the bare line number followed by a
% dot, then the lemma text in bold face, then the variant in italic
% shape:---
%
% \captof{Poetry: Shakespeare's Sonnet~1}[\label{lst:shak-sonnet1}]
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\junicode % Use the Junicode font with 'hist' feature enabled for
          % long-s
% MacDonald's style for numbers and entries in the apparatus
% criticus:
\SetHooks{
  refnumstyle=\normalfont,
  postrefnum=.~,
  lemmastyle=\bfseries,
  readingstyle=\itshape
}
% The lines are to be centered horizontally:
\settowidth{\versewidth}{Feed'st thy lights flame with selfe
substantiall fewell,}
% Format of the outermost <div> element:
\NewDocumentEnvironment{ekdcenter}{}{\par\centering}{\nobreak\par}
\FormatDiv{1}{\begin{ekdcenter}}{\end{ekdcenter}}
\begin{ekdosis}
  \ekddiv{type=sonnets, n=1, head=1}
  \begin{ekdverse}[type=sonnet, width=\versewidth]
    \indentpattern{00000000000011}
    \begin{patverse}
      \begin{ekdstanza}[type=quatrain]
        \ekdlettrine{F}{r}om fairest creatures we desire
        increase,\\
        That thereby beauties \emph{Rose}
        \app{
          \lem{might}
          \rdg[source={Gildon1710, Sewell1725, Ewing1771}]{may}
        } neuer die,\\
        But as the riper should by time
        \app{
          \lem{decease}
          \rdg[source=Hudson1856]{decrease}
        },\\
        His tender heire might beare his memory:\\
      \end{ekdstanza}
      \begin{ekdstanza}[type=quatrain]
        But thou contracted to thine owne bright eyes,\\
        Feed'st thy
        \app{
          \lem{lights}
          \rdg[source={Butler1899, Walsh1908}]{life's}
        } flame with
        \app{
          \lem{selfe substantiall}
          \rdg[source=Gildon1714,
          alt={\textnormal{Hyphened by}}]{selfe-substantiall}
          \note{etc.}} fewell,\\
        Making a famine where aboundance lies,\\
        Thy selfe thy foe,to thy sweet selfe too cruell:\\
      \end{ekdstanza}
      \begin{ekdstanza}[type=quatrain]
        Thou that art now the worlds fresh ornament,\\
        And
        \app{
          \lem{only}
          \rdg[resp=God, type=conjecture]{early}
          \note{conj.}
        } herauld to the gaudy spring,\\
        Within thine owne bud buriest thy content,\\
        And tender
        \app{
          \lem{chorle}
          \rdg[source=Gildon1710]{churl}
          \note{etc.}
        } makst wast in niggarding:\\
      \end{ekdstanza}
      \begin{ekdstanza}[type=couplet]
        Pitty the world,or else this glutton be,\\
        To eate the worlds due,\app{
          \lem{by the}
          \rdg[resp=Stee, type=conjecture]{be thy}
          \note{conj.}
          \rdg[resp=God, type=conjecture]{by thy}
          \note{conj.}
        } graue
        \app{
          \lem{and}
          \rdg[resp=God, type=conjecture]{as}
          \note{conj.}
        } thee.\\!
      \end{ekdstanza}
    \end{patverse}
  \end{ekdverse}
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
% 
% \begin{remarks}
% \item |Gildon1710|, |Gildon1714|, |Sewell1725|, |Ewing1771|,
%   |Hudson1856|, |Butler1899| and |Walsh1908| have been declared as
%   sources.\footnote{See above \vpageref{ref:declare-source} and
%   below \vref{sec:references-cited-works}.}  |God| and |Stee|,
%   resp.\ Godwin and Steevens, have been declared as
%   scholars.\footnote{See above \vpageref{ref:declare-scholar}.}
% \item \cs{ekdlettrine} (l.~23) is a specific command for the
%   \pkg{lettrine} package does not work in list
%   environments. \cs{TeXtoTEIPat} has been used as described below
%   \vpageref{ref:textoteipat} to instruct \pkg{ekdosis} to convert
%   this command into an acceptable \texttt{TEI} equivalent. The
%   definition of \cs{ekdlettrine} follows:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
% Preamble:
\usepackage{adjustbox}
% This basic command actually requires an adjustment of the vertical
% space at the end of the current line (eg. \\[-1.875ex]) and \vin at
% the beginning of the next line:---
\NewDocumentCommand{\ekdlettrine}{mm}{%
\adjustbox{valign=t,raise=-0.75ex}{\Huge #1}\textsc{#2}%
}
\TeXtoTEIPat{\ekdlettrine {#1}{#2}}{<hi rend="smallcaps">#1#2</hi>}
\end{minted}
% \iffalse
%</example>
% \fi
% \end{remarks}
%
% PDF output:---
% \medskip
%
% \begingroup
% \junicode
% \SetHooks{
%   refnumstyle=\normalfont,
%   postrefnum=.~,
%   lemmastyle=\bfseries,
%   readingstyle=\itshape
% }
% \renewcommand\thelinenumber{}
% \settowidth{\versewidth}{Feed'st thy lights flame with selfe
% substantiall fewell,}
% \FormatDiv{1}{\begin{ekdcenter}}{\end{ekdcenter}}
% \needspace{7\baselineskip}
% \resetlinenumber\resetvlinenumber
% \begin{alignment}[flush,
%   tcols=1,
%   texts=shakespeare[xml:lang="en"],
%   apparatus=shakespeare]
%   \setlength{\vrightskip}{-0.75in}
%   \begin{shakespeare}
%    \ekddiv{type=sonnets, n=1, head=1}
%    \begin{ekdverse}[type=sonnet, width=\versewidth]
%      \indentpattern{00000000000011}
%      \begin{patverse}
%        \begin{ekdstanza}[type=quatrain]
%          \ekdlettrine{F}{r}om fairest creatures we desire
%          increase,\\[-1.875ex] 
%          \vin That thereby beauties \emph{Rose}
%            \app{
%              \lem{might}
%              \rdg[source={shGildon1710, shSewell1725, shEwing1771}]{may}
%           } neuer die,\\
%          But as the riper should by time
%            \app{
%              \lem{decease}
%              \rdg[source=shHudson1856]{decrease}
%            },\\
%          His tender heire might beare his memory:\\
%        \end{ekdstanza}
%        \begin{ekdstanza}[type=quatrain]
%          But thou contracted to thine owne bright eyes,\\
%          Feed'st thy
%            \app{
%              \lem{lights}
%              \rdg[source={shButler1899, shWalsh1908}]{life's}
%            } flame with
%            \app{
%              \lem{selfe substantiall}
%              \rdg[source=shGildon1714,
%                   alt={\textnormal{Hyphened by}}]{selfe-substantiall}
%              \note{etc.}} fewell,\\
%          Making a famine where aboundance lies,\\
%          Thy selfe thy foe,to thy sweet selfe too cruell:\\
%        \end{ekdstanza}
%        \begin{ekdstanza}[type=quatrain]
%          Thou that art now the worlds fresh ornament,\\
%          And
%            \app{
%              \lem{only}
%              \rdg[resp=shGod, type=conjecture]{early}
%              \note{conj.}
%            } herauld to the gaudy spring,\\
%          Within thine owne bud buriest thy content,\\
%          And tender
%            \app{
%              \lem{chorle}
%              \rdg[source=shGildon1710]{churl}
%              \note{etc.}
%            } makst wast in niggarding:\\
%        \end{ekdstanza}
%        \begin{ekdstanza}[type=couplet]
%          Pitty the world,or else this glutton be,\\
%          To eate the worlds due,\app{
%            \lem{by the}
%            \rdg[resp=shStee, type=conjecture]{be thy}
%            \note{conj.}
%            \rdg[resp=shGod, type=conjecture]{by thy}
%            \note{conj.}
%            } graue
%              \app{
%                \lem{and}
%                \rdg[resp=shGod, type=conjecture]{as}
%                \note{conj.}
%              } thee.\\!
%        \end{ekdstanza}
%      \end{patverse}
%    \end{ekdverse}
%   \end{shakespeare}
% \end{alignment}
% \endgroup
%
% \texttt{TEI xml} output:---
% \medskip
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<div type="sonnets" n="1">
  <head>1</head>
  <lg type="sonnet">
    <lg type="quatrain">
      <l>
      <hi rend="smallcaps">Fr</hi>om fairest creatures we
      desire increase,</l>
      <l>That thereby beauties 
      <emph>Rose</emph>
      <app>
        <lem>might</lem>
        <rdg source="#Gildon1710 #Sewell1725 #Ewing1771">
        may</rdg>
      </app>neuer die,</l>
      <l>But as the riper should by time 
      <app>
        <lem>decease</lem>
        <rdg source="#Hudson1856">decrease</rdg>
      </app>,</l>
      <l>His tender heire might beare his memory:</l>
    </lg>
    <lg type="quatrain">
      <l>But thou contracted to thine owne bright eyes,</l>
      <l>Feed'st thy 
      <app>
        <lem>lights</lem>
        <rdg source="#Butler1899 #Walsh1908">
        life's</rdg>
      </app>flame with 
      <app>
        <lem>selfe substantiall</lem>
        <rdg source="#Gildon1714">
        selfe-substantiall</rdg>
        <note>etc.</note>
      </app>fewell,</l>
      <l>Making a famine where aboundance lies,</l>
      <l>Thy selfe thy foe,to thy sweet selfe too
      cruell:</l>
    </lg>
    <lg type="quatrain">
      <l>Thou that art now the worlds fresh ornament,</l>
      <l>And 
      <app>
        <lem>only</lem>
        <rdg resp="#God" type="conjecture">early</rdg>
        <note>conj.</note>
      </app>herauld to the gaudy spring,</l>
      <l>Within thine owne bud buriest thy content,</l>
      <l>And tender 
      <app>
        <lem>chorle</lem>
        <rdg source="#Gildon1710">churl</rdg>
        <note>etc.</note>
      </app>makst wast in niggarding:</l>
    </lg>
    <lg type="couplet">
      <l>Pitty the world,or else this glutton be,</l>
      <l>To eate the worlds due,
      <app>
        <lem>by the</lem>
        <rdg resp="#Stee" type="conjecture">be thy</rdg>
        <note>conj.</note>
        <rdg resp="#God" type="conjecture">by thy</rdg>
        <note>conj.</note>
      </app>graue 
      <app>
        <lem>and</lem>
        <rdg resp="#God" type="conjecture">as</rdg>
        <note>conj.</note>
      </app>thee.</l>
    </lg>
  </lg>
</div>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \section{Lineation Settings}
% \label{sec:lineation}
% \danger \pkg{ekdosis} uses \pkg{lineno} internally for line
% numbering.\footcite{lineno} But it must be noted that \pkg{ekdosis}
% strictly prohibits the \enquote{pagewise} mode of operation that is
% provided by \pkg{lineno}. As a result of this hinderance, all
% \enquote{margin switching} functions of \pkg{lineno} are disabled
% within the environments that are specific to \pkg{ekdosis},
% viz. \env{ekdosis} and \env{alignment}.
%
% That said, \pkg{ekdosis} provides equivalents of its own to handle
% the line numbers the same way as \pkg{lineno}'s \enquote{pagewise}
% mode of operation does.
%
% \DescribeMacro{\SetLineation} \cs{SetLineation}\marg{csv list of
% options} may be used in the preamble or at any point of the document
% to set lineation preferences. Its argument processes the |key=value|
% options that follow:---\\
% \textbf{General Options}\\
% \DescribeOption{lineation} |lineation|$=$\verb+page|document+
% \hfill\tcboxverb{Default: document}\\
% |lineation=document| has the lines numbered continuously throughout
% the document while |lineation=page| instructs \pkg{ekdosis} that the
% numbering should start afresh at the top of each page.\\
% \DescribeOption{modulo} |modulo| \hfill\tcboxverb{Default: not set}\\
% |modulo| does not accept any value. When this option is set, every
% fifth line is numbered.\\
% \DescribeOption{modulonum} |modulonum|$=$\emph{n} (where \emph{n} is
% an integer)\hfill\tcboxverb{Default: not set}\\
% |modulonum| allows to modify the interval between the numbers that
% are printed. |modulo| must be set for this option to have effect. As
% examples, |modulo, modulonum=3| has every third line numbered and
% |modulonum=1| disables modulo numbering.\\
% \DescribeOption{margin} |margin|$=$\verb+right|left|inner|outer+
% \hfill\tcboxverb{Default: left}\\
% |margin| sets the margin in which the line numbers are to be
% printed.\\
% \DescribeOption{numbers} |numbers|$=$\verb+elided|full+
% \hfill\tcboxverb{Default: elided}\\
% This option only has effect on the numbers that are printed in the
% apparatus criticus. |numbers=elided| applies on spans of numbers and
% elides the last number of a range to the fewest number of figures
% possible\---viz. 35--7, 129--31 \emph{\&c.}\---without eliding
% digits in the group 10 to 19 in each hundred\---viz. 17--19, 115--18
% \emph{\&c.} |numbers=full| leaves the numbers untouched.\\
% \DescribeMacro{\innerlinenumbers} \DescribeMacro{\outerlinenumbers}
% \cs{innerlinenumbers} and \cs{outerlinenumbers} are equivalent to
% \cs{SetLineation}|{numb|\allowbreak|ers=outer}| and
% \cs{SetLineation}|{numbers=inner}| respectively. Both commands are
% complementary to \cs{rightlinenumbers} and \cs{leftlinenumbers}
% already provided by the \pkg{lineno} package.\\
% \textbf{Options Specific to the |poetry=verse| Global
% Setting}\footnote{See above
% \vref{sec:verse-package}.}\phts\label{ref:verse-lineation}\\
% \DescribeOption{vlineation} |vlineation|$=$\verb+page|document+
% \hfill\tcboxverb{Default: document}\\
% |vlineation| operates on verse texts in the same way as |lineation|
% on prose texts.\\
% \DescribeOption{vmodulo} |vmodulo|$=$\emph{n} (where \emph{n} is
% an integer)\hfill\tcboxverb{Initially: 1, Default: 5}\\
% |vmodulo|$=$\emph{n} has every \emph{n\textsuperscript{th}} lines of
% verse printed in the margin. If used without value, this option is
% equivalent to |vmodulo=5|. |vmodulo=0| prevents the
% numbers from being printed.\\
% \DescribeOption{vmargin} |vmargin|$=$\verb+right|left+
% \hfill\tcboxverb{Default: right}\\
% |vmargin| sets the margin in which the verse line numbers are to be
% printed.\\
% \DescribeOption{continuousvnum}\hfill\tcboxverb{Default: not set}\\
% The |poetry=verse| global option has the succeeding lines of verse
% numbered independently of prose text. |continuousvnum| has all lines
% numbered continuously, irrespective of whether they are lines of
% prose or poetry text.
%
%
% \paragraph{Useful Lineation Commands}
% As implied above, pretty much all commands that are provided by the
% \enquote{running} mode of operation of the \pkg{lineno} package will
% work with \pkg{ekdosis}, notably the following:---\\
% \DescribeMacro{\modulolinenumbers} \cs{modulolinenumbers}\oarg{n}
% can be used to enable modulo line numbering as described above.\\
% \DescribeMacro{\resetlinenumber} \cs{resetlinenumber}\oarg{n} resets
% the line number to one or to \emph{n} if specified.\\
% \DescribeMacro{\linenumberfont}
% \cs{renewcommand}|{\linenumberfont}|\marg{commands} can be used to
% set the font used for the line numbers that are printed in the
% margins. By default, the definition is
% \cs{normalfont}\cs{footnotesize}.\\
% \DescribeMacro{\linenumbersep} \cs{linenumbersep} is the distance
% between the numbers and the margin. By default, this distance is set
% to \unit[10]{pt}. It can be redefined like so:
% \cs{setlength}\cs{linenumbersep}\marg{length}.
%
% \paragraph{Poetry Lineation Commands}
% In addition to these commands, if \pkg{ekdosis} be loaded with the
% global option |poetry=verse| as described above in
% \vref{sec:verse-package}, the commands dedicated to line numbering
% that are provided by the \pkg{verse} package can be used.\\
% \DescribeMacro{\resetvlinenumber} \cs{resetvlinenumber}\oarg{n} has
% for lines of verse the same effect as \cs{resetlinenumber} for
% lines of prose text.\\
% \DescribeMacro{\verselinenumfont}
% \cs{verselinenumfont}\marg{commands} can be used to set the font
% used for lines of verse. By default, the definition is
% |\normalfont\footnotesize|. \danger If the \cls{memoir} class be
% loaded, this command is replaced with \cs{linenumberfont} described
% above.\\
% \DescribeMacro{\vrightskip} The \pkg{verse} package prints the
% numbers at the distance \cs{vrightskip} into the right margin. This
% distance can be redefined by means of \cs{setlength} like so:
% \cs{setlength}\cs{vrightskip}\allowbreak\marg{length}.
%
%
% \paragraph{Labels}
% \DescribeMacro{\linelabel} \DescribeMacro{\ref} In prose as well
% as in poetry texts, \cs{linelabel}\marg{label} sets a line label
% that can be referred to with \cs{ref}\marg{label}.
%
% As an example, what follows has every fifth line number printed in
% the inner margins. Additionally, the numbering shall start afresh at
% the top of each page:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\SetLineation{
  lineation=page,
  modulo,
  margin=inner
}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \section{Languages}
% \label{sec:languages}
% \danger \pkg{ekdosis} is fully compatible with \pkg{babel}.
% \enquote{Fully compatible} means that all features provided by
% \pkg{babel}, including language switching commands, are supported by
% \pkg{ekdosis}. \pkg{ekdosis} is also compatible with
% \pkg{polyglossia} with one notable exception: \pkg{luabidi}, which
% \pkg{polyglossia} loads for languages written from right to left, is
% not supported by \pkg{ekdosis}, and most probably never will
% be. That said, as far as the author could see, single-layer
% apparatus, as described in \vref{sec:single-layer-app}, can be
% typeset within the Arabic environment that is provided by
% \pkg{polyglossia}. Unfortunately, the same cannot be said for
% multiple-layer apparatus.
%
% Whether \pkg{babel} or \pkg{polyglossia} is used, \pkg{ekdosis}
% automatically applies the current language to the entries of the
% apparatus criticus, including the fonts that may have been
% associated to the languages in the preamble. In this respect, as
% \pkg{polyglossia} can use the same language switching commands as
% \pkg{babel},\footcite[See][3.2 \pno~14]{polyglossia} the general
% advice given above in \vref{sec:alignment-hooks} applies in all
% cases. As regards setting languages in the \texttt{TEI xml} output
% file, the reader is invited to refer to point \vref{it:lang-subopt}
% and \vref{sec:teixml-output}.
%
% \danger In some cases, it may be needed to apply in the apparatus
% criticus a language different from the one that is selected in the
% edition text.  To this end, \pkg{ekdosis} provides a set of
% facilities which are described
% \vpagerefrange{ref:app-lang}{ref:app-lang-opt} for single-layer
% apparatus and \vpageref{ref:apps-lang-opt} for multiple-layer
% apparatus.
%
% \subsection{Languages Written From Right to Left}
% \label{sec:rtl-languages}
% As said above, \pkg{polyglossia} is not supported by \pkg{ekdosis}
% for languages that are written and read from right to left, like
% Arabic, Hebrew or Syriac. However, as \pkg{babel} is supported and
% can be loaded concurrently with \pkg{polyglossia}, an easy way is to
% use \pkg{babel} to print such languages.
%
% \danger The reader is invited to refer to and become acquainted with
% the relevant parts of the documentation of the \pkg{babel}
% package.\footcite{babel}
%
% \paragraph{\pkg{babel} Only}
% In the following example, \pkg{babel} is used exclusively to set
% three different languages: Arabic, ancient Greek and English:---
%
% \captof{Multilingual editions with \pkg{babel} only}
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\usepackage{fontspec}

\usepackage[greek.ancient,english]{babel}
\babelprovide[onchar=fonts]{arabic}

\babelfont{rm}{Old Standard}
\babelfont[greek]{rm}[RawFeature={+ss05;+ss06}]{Old Standard}
\babelfont[*arabic]{rm}{Amiri}

\babeltags{ancientgreek = greek}
\newcommand{\sg}[1]{\textancientgreek{#1}}

\newcommand{\RL}[1]{\bgroup\textdir TRT#1\egroup}
\newenvironment{Arabic}{\par\pardir TRT\textdir TRT}{\par}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \begin{remarks}
% \item As can be seen, \pkg{fontspec} has been loaded before
%   \pkg{babel}. To the author's knowledge, this gives better results
%   when \cs{babelfont} is used.
% \item Line~3 loads \pkg{babel} and instructs it to use English as
%   the default language and ancient Greek as a second optional
%   language. The built-in |bidi| mechanism provided by \pkg{babel} is
%   not enabled. As a result, specific language switching commands for
%   Arabic must be defined just as it must be for every other
%   language.
% \item Line~4 does not load any Arabic, but instructs \pkg{babel}
%   that it should use the Arabic font that is set below with
%   \cs{babelfont} whenever an Arabic letter is encountered.
% \item Lines~6--8 select the fonts: |Old Standard| is the default
%   font to be used for Roman shape (l.~6); the same font is used for
%   Greek, with some additional Open Type features enabled; finally,
%   the |Amiri| font is used for Arabic.
% \item Lines~10--11 define so-called \enquote{tags} for easier access
%   to ancient Greek through \cs{begin}|{ancient|\allowbreak|greek}|
%   \dots\ \cs{end}|{ancientgreek}| for running paragraphs and
%   \cs{textancientgreek}\marg{text} for short insertions of Greek in
%   English text. \cs{sg}\marg{text} is just a shorthand for this
%   latter command.
% \item Finally, lines~13--14 define simple language switching
%   commands for Arabic. As can be seen, no commands other than the
%   \LuaTeX\ primitives \cs{pardir} and \cs{textdir} have been used
%   for \pkg{babel} already takes care of selecting the Arabic
%   font. \cs{RL} is for short insertions of Arabic words in English
%   paragraphs while \cs{begin}|{Arabic}| \dots\ \cs{end}|{Arabic}| is
%   for running paragraphs of Arabic text.
% \end{remarks}
%
% \paragraph{Changing the Writing Direction}
% \DescribeMacro{\setRL} \DescribeMacro{\setLR} \cs{setRL} and
% \cs{setLR} are two argument-less commands provided by \pkg{ekdosis}
% that can be used to change the writing direction of running
% paragraphs. The former sets the direction from right to left and the
% latter form left to right. If \pkg{babel} be set as above,
% \cs{setRL} \dots\ \cs{setLR} can be used in place of
% \cs{begin}|{Arabic}| \dots\ \cs{end}|{Arabic}|.
% 
% \paragraph{\pkg{polyglossia} Associated With \cs{babelprovide}}
% What follows illustrates how \pkg{babel} can be used conjointly with
% \pkg{polyglossia} for the same three languages as above without
% having to load \pkg{luabidi}:---
%
% \captof{Multilingual editions with \pkg{babel} and
% \pkg{polyglossia}}
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\usepackage{fontspec}

\usepackage{babel}
\babelprovide[onchar=fonts]{arabic}

\setmainfont{Old Standard}
\newfontfamily\greekfont{Old Standard}[RawFeature={+ss05;+ss06}]
\babelfont[*arabic]{rm}{Amiri}

\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage[variant=ancient]{greek}

\newcommand{\textarabic}[1]{\bgroup\textdir TRT#1\egroup}
\newenvironment{Arabic}{\par\pardir TRT\textdir TRT}{\par}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \begin{remarks}
% \item Line~3 just loads \pkg{babel} with no default language.
% \item Lines~4 and 8 are used to have the Arabic font automatically
%   selected as above.
% \item Lines~14--15 define the exact language switching commands that
%   would have been defined if \pkg{polyglossia} and \pkg{luabidi} had
%   been used for Arabic.
% \end{remarks}
%
% As one can see, the important points about languages written from
% right to left are to use \pkg{babel} only to select the Arabic
% fonts, avoid using the bidirectional mechanism it provides and
% define commands and environments that use only \LuaTeX\ primitives
% to set the writing direction. Then, an Arabic edition text\---to
% continue with this example\---can be entered as plainly as
% follows:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false,escapeinside=++]{latex}
\begin{ekdosis}
  \begin{Arabic}
    +\txarb{إِنَّ أَبِي كَانَ مِنَ}+ \app{
      \lem{+\txarb{ٱلْمُقَاتِلَةِ}+}
      \rdg{+\txarb{ٱلْمُقَاتِلِينَ}+}
      } +\txarb{وَ كَانَتْ أُمِّي مِنْ عُظَمَآءِ بُيُوتِ ٱلزَّمَازِمَةِ۔}+
  \end{Arabic}
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% It should be reminded that the writing direction of the apparatus
% criticus itself is independent of that of the edition text and must
% be set either with \cs{Set(LTR{\textbar}RTL)app} or with the
% |direction| optional argument of \cs{SetApparatus} for single-layer
% apparatus criticus, or by means of \cs{DeclareApparatus} for
% multiple-layer apparatus criticus.\footnote{See above
% \vref{sec:single-layer-app} (single-layer apparatus criticus) and
% \vref{sec:multilayer-apparatus} (multiple-layer apparatus
% criticus).}
%
% The PDF output with left-to-right apparatus criticus follows:---
% \medskip
% 
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%     \begin{arab}[fullvoc]
%       'inna 'abI kAna mina \app[type=ltr]{
%       \lem{'l-muqAtilaTi}
%       \rdg{'l-muqAtilIna}}
%       wa-kAnat 'ummI min `u.zamA'i buyUti 'l-zamAzimaTi.
%     \end{arab}
%   \end{specimen}
% \end{alignment}
%
% \needspace{5\baselineskip}
% And here follows the PDF output with right-to-left apparatus
% criticus:---
% \medskip
% 
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%     \begin{arab}[fullvoc]
%       'inna 'abI kAna mina \app[type=rtl]{
%       \lem{'l-muqAtilaTi}
%       \rdg{'l-muqAtilIna}}
%       wa-kAnat 'ummI min `u.zamA'i buyUti 'l-zamAzimaTi.
%     \end{arab}
%   \end{specimen}
% \end{alignment}
%
% \subsection{Using \pkg{arabluatex}}
% \label{sec:using-arabluatex}
% \pkg{arabluatex} is a \hologo{LuaLaTeX} package that provides
% commands and environments which return Arabic writing from an ASCII
% transliteration (either Arab\TeX\ or Buckwalter
% scheme).\footcite{arabluatex} It is particularly well-suited for
% complex documents such as critical editions where a lot of commands
% intertwine with Arabic writing. \pkg{arabluatex} can output Unicode
% Arabic in the same modes as \pkg{arabtex}\footcite{arabtex} or in
% different accepted standards of romanization. It is also able to
% produce a duplicate of the original |.tex| source file in which all
% |arabtex| or |buckwalter| strings are replaced with Unicode
% equivalents, either in Arabic script or in any accepted standard of
% transliteration.\footcite[\mkbibquote{Exporting Unicode Arabic
% to an External File}]{arabluatex}
%
% \pkg{arabluatex} is fully supported by \pkg{ekdosis}. The following
% example illustrates how \pkg{arabluatex} and \pkg{ekdosis} interact
% with each other to produce distinct \texttt{TEI xml} outputs from a
% single |.tex| source file:---
%
% \captof{\pkg{ekdosis} and \pkg{arabluatex}}[\label{lst:arabluatex-ekd}]
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
% Preamble:
% load ekdosis and ask for TEI xml output:
\usepackage[teiexport]{ekdosis}
% load arabluatex and request a LaTeX output with Unicode Arabic:
\usepackage[export,fullvoc]{arabluatex}

% document:
\begin{arabexport} % export arabtex strings to Unicode Arabic
  \begin{ekdosis}
    \begin{arab}
      'inna 'abI kAna mina 
      \app{
        \lem{'l-muqAtilaTi}
        \rdg{'l-muqAtilIna}
      }
      wa-kAnat 'ummI min `u.zamA'i buyUti 'l-zamAzimaTi.
    \end{arab}
  \end{ekdosis}
\end{arabexport}
\end{minted}
% \iffalse
%</example>
% \fi
%
% The PDF output with left-to-right apparatus criticus is of course
% the same as above:---
% \medskip
% 
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%     \begin{arab}[fullvoc]
%       'inna 'abI kAna mina \app[type=ltr]{
%       \lem{'l-muqAtilaTi}
%       \rdg{'l-muqAtilIna}}
%       wa-kAnat 'ummI min `u.zamA'i buyUti 'l-zamAzimaTi.
%     \end{arab}
%   \end{specimen}
% \end{alignment}
%
% However, assuming that the source file is called |source.tex|,
% \pkg{ekdosis} produces as instructed from this file an additional
% |source-tei.xml| as follows:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p xml:lang="ar-Latn" type="transliterated"
subtype="arabtex">'inna 'abI kAna mina 
<app>
  <lem>'l-muqAtilaTi</lem>
  <rdg>'l-muqAtilIna</rdg>
</app>wa-kAnat 'ummI min `u.zamA'i buyUti
'l-zamAzimaTi.</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% At the same time, \pkg{arabluatex} is instructed to produce on its
% own from the same |source.tex| an additional |source_out.tex| in
% which all |arabtex| strings found within \cs{begin}|{arabexport}|
% \dots\ \cs{end}|{arabexport}| (see \vref{lst:arabluatex-ekd},
% ll.~9--19) are replaced with full-vocalized Arabic Unicode
% script. Finally, compiling this latter file produces the following
% |sample-arabic_out-tei.xml| an extract of which follows:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false,escapeinside=++]{xml}
<p xml:lang="arb">+\txarb{إِنَّ أَبِي كَانَ مِنَ}+ 
<app>
  <lem>+\txarb{ٱلْمُقَاتِلَةِ}+</lem>
  <rdg>+\txarb{ٱلْمُقَاتِلِينَ}+</rdg>
</app>+\txarb{وَكَانَتْ أُمِّي مِنْ عُظَمَآءِ بُيُوتِ}+
+\txarb{ٱلزَّمَازِمَةِ.}+</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% The reader will find the full |arabic-sample.tex| source file with
% instructions in \vref{sec:arabic-sample}, and is invited to refer to
% the documentation of the \pkg{arabluatex} package for more
% information on the way to use its Arabic environments and built-in
% functions dedicated to export |arabtex| ASCII strings to
% Unicode.\footcite{arabluatex}
%
% \section{Divisions of the Body}
% \label{sec:body-divisions}
% The features that are described in this section call for one general
% remark.  \pkg{ekdosis} is designed to figure out where any \LaTeX\
% command that is converted to a \texttt{TEI} opening element allowed
% to nest recursively, such as |<div>|, |<lg>| and the like, is to be
% closed, even though there is no explicit indication of the point
% where the closure occurs. Thoroughly scanning \LaTeX\ source files
% with \textsf{Lua} functions which involve complex string matching
% and recursions was required, as \LaTeX\ \enquote*{open} commands
% such as \cs{chapter} or \cs{section} only act as milestones,
% contrary to \texttt{TEI} elements.
% 
% \danger It must be noted that the two styles described hereinafter
% are mutually exclusive. \texttt{TEI xml} forbids that both be
% combined within a single |<body>| element.\footnote{See
% \url{https://tei-c.org/release/doc/tei-p5-doc/en/html/DS.html\#DSDIV}.}
% As a result, \pkg{ekdosis} will disregard whichever one is not
% selected.
% \vskip\baselineskip
%
% \subsection{\LaTeX\ Standard Divisions}
% \label{sec:latex-divs}
% \pkg{ekdosis} can use the \LaTeX\ standard textual divisions, such
% as \cs{book}, \cs{chapter}, \cs{section} and the like.
%
% \danger However, to have these divisions properly translated into
% \texttt{TEI} numbered |<div>| elements, the |divs| general option
% must be set to |latex| explicitly\---viz. |divs=latex|\---as
% described above \vpageref{ref:divs-opt}.
%
% \danger As the \env{alignment} environment that is provided by
% \pkg{ekdosis} places all aligned texts within \texttt{TEI xml}
% un-numbered |<div>| elements and \LaTeX\ textual divisions are
% converted into numbered |<div|\textsubscript{\emph{n}}|>| elements,
% inserting such divisions in texts to be aligned will result in an
% invalid \texttt{TEI xml} output. Instead, un-numbered divisions
% through \cs{ekddiv} must be used as described below in
% \vref{sec:ekddiv}.
%
% Once |divs| has been set to |latex|, \pkg{ekdosis} converts
% \cs{book}, \cs{part}, \cs{chapter}, \cs{section}, \cs{subsection}
% and \cs{subsubsection} into corresponding \texttt{TEI}
% \enquote*{numbered} |<div|\textsubscript{\emph{n}}|>| elements,
% where $1\leq n\leq 6$.
%
% \paragraph{Adjusting the Levels of Textual Subdivisions}
% \DescribeMacro{\MkBodyDivs}
% \cs{MkBodyDivs}\marg{div1}\marg{div2}\marg{div3}\allowbreak\marg{div4}\marg{div5}\marg{div6}
% takes six mandatory arguments. This command can be used in the
% preamble or at any point of the document to make the number of the
% first-level subdivision of the edition text, viz.\ |<div1>|, match
% to any \LaTeX\ command other than \cs{book}. For example, if
% \cs{section} be the highest-level sectional command used, then
% \cs{MkBodyDivs}|{section}{subsection}{subsubsection}{}{}|\allowbreak|{}|
% will have \cs{section}, \cs{subsection} and \cs{subsubsection}
% converted into |<div1>|, |<div2>| and |<div3>| respectively.
%
% \paragraph{Inserting Variants in Headings}
% Variant readings can be inserted in headings. In this case, the
% optional argument of the \LaTeX\ sectional command must naturally be
% used to prevent variants from going into headers, footers or the
% table of contents, like so:\footnote{On the use of \texttt{egomute}
% (l.~13), see above \vref{it:egomute}.}---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
% Preamble:
\usepackage[teiexport=tidy, divs=latex]{ekdosis}
\MkBodyDivs{chapter}{section}{}{}{}{}

% Document:
\chapter[Ἱπποκράτους ἐπιδημιῶν βιβλίον δεύτερον]{Ἱπποκράτους ἐπιδημιῶν
  \app{
    \lem[wit={I,R,H}]{βιβλίον δεύτερον}
    \rdg[wit=V]{λόγος β’}}}

\section[Τμῆμα πρῶτον]{
  \app{
    \lem[resp=egomute, type=emendation, nosep,
     post=suppleui]{\supplied{Τμῆμα πρῶτον}}
   }}
Ἄνθρακες θερινοὶ ἐν Κραννῶνι· [...]
\end{minted}
% \iffalse
%</example>
% \fi
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<div1 type="chapter">
  <head>Ἱπποκράτους ἐπιδημιῶν 
  <app>
    <lem wit="#I #R #H">βιβλίον δεύτερον</lem>
    <rdg wit="#V">λόγος β’</rdg>
  </app></head>
  <div2 type="section">
    <head>
      <app>
        <lem><supplied resp="#ego" type="emendation">Τμῆμα
         πρῶτον</supplied></lem>
      </app>
    </head>
    <p>Ἄνθρακες θερινοὶ ἐν Κραννῶνι· [...]</p>
  </div2>
</div1>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Using \texttt{TEI} Un-numbered Divisions}
% \label{sec:ekddiv}
% \danger As already described \vpageref{ref:divs-opt}, the
% un-numbered style of division is the one that is set by default. It
% is congruous to the general option |divs=ekdosis|.
%
% This style provides a flexible mechanism in which format and
% presentation are separated from content. It is designed to meet the
% requirements of classical and literary texts the divisions of which
% may depend on many different received traditions.
%
% \DescribeMacro{\ekddiv} \cs{ekddiv}\marg{key-value arguments} is the
% unique sectional command provided by \pkg{ekdosis}. This command
% converts the divisions into un-numbered \texttt{TEI} |<div>|
% elements allowed to nest recursively and takes one mandatory
% argument in which the following |key-value| arguments are
% accepted:---\\
% \DescribeOption{type} |type|$=$\meta{name}
% \hfill\tcboxverb{Default: none}\\
% |type| corresponds to the \texttt{TEI} class |att.typed| and can be
% used to classify the element in which it is found in any
% way. Suitable values here can be |book|, |chapter|, |section| and
% the like.\\
% \DescribeOption{n} |n|$=$\meta{value} \hfill
% \tcboxverb{Default: none}\\
% |n| is meant to provide a number or any kind of label for the
% division and does not have to be unique in the document.\\
% \DescribeOption{head} |head|$=$\meta{name}
% \hfill\tcboxverb{Default: none}\\
% |head| holds the title of the division and may further contain
% variant readings.\\
% \DescribeOption{barehead} |barehead|$=$\meta{name}
% \hfill\tcboxverb{Default: none}\\
% |barehead| is supposed to be used to prevent unwanted commands from
% going into such places as headers, footers and the table of
% contents.\\
% \DescribeOption{depth} |depth|$=$\meta{n} where $1\leq n\leq 9$
% \hfill\tcboxverb{Default: 1}\\
% As \texttt{TEI} un-numbered divisions are simply |<div>| elements
% allowed to nest recursively to indicate their hierarchic depth and
% \cs{ekddiv} is an \enquote*{open} \LaTeX\ command, |n| is needed to
% indicate the depth of the division within the hierarchy, the largest
% being |1| and the smallest being |9|.\\
% \DescribeOption{toc}
% |toc|$=$\verb+book|part|chapter|section|subsection|subsubsection|paragraph|+\\
% |subparagraph|\hfill\tcboxverb{Default: not set}\\
% If |toc| be set, the title of the division goes into the table of
% contents at the hierarchic level that is specified as value.
%
% \paragraph{Formatting the Titles}
% \DescribeMacro{\FormatDiv} By design, \pkg{ekdosis} does
% not format the titles. Instead, depending on what is needed for the
% edition text, \cs{FormatDiv}\marg{n}\marg{code
% before}\marg{code after} is provided to lay out the titles of any
% hierarchic depth of division. This command takes three mandatory
% arguments as follows: \meta{n}, which is the number referring to the
% particular depth of division to be formatted and some \LaTeX\
% commands to go before and after the title itself. The following
% example illustrates how the titles of the largest division can be
% printed horizontally centered in a larger size:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\FormatDiv{1}{\begin{center}\Large}{\end{center}}
\end{minted}
% \iffalse
%</example>
% \fi
%
% To elaborate on the example provided above in \vref{sec:latex-divs},
% here follows how the first three hierarchical levels could be
% formatted as un-numbered divisions:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
% Preamble:
\FormatDiv{1}{\begin{center}\Large}{\end{center}}
\FormatDiv{2}{\begin{center}\large}{\end{center}}
\FormatDiv{3}{\bfseries}{.}

% Document:
\begin{ekdosis}
  \ekddiv{
    head={Ἱπποκράτους ἐπιδημιῶν
      \app{
        \lem[wit={I,R,H}]{βιβλίον δεύτερον}
        \rdg[wit=V]{λόγος β’}}},
    type=book,
    depth=1,
    n=II
  }

  \ekddiv{
    head={\app{
        \lem[resp=egomute, post=suppleui,
        type=emendation]{\supplied{Τμῆμα πρῶτον}}
        \rdg[wit=codd, alt=om.]{}}},
    type=section,
    depth=2,
    n=II.1
  }

  \ekddiv{head=1, type=paragraph, depth=3, n=II.1.1}
  Ἄνθρακες θερινοὶ ἐν Κραννῶνι· [...]
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% PDF output:---
% \medskip
%
% \begingroup
% \needspace{7\baselineskip}
% \resetlinenumber
% \FormatDiv{1}{\begin{center}\Large}{\end{center}}
% \FormatDiv{2}{\begin{center}\large}{\end{center}}
% \FormatDiv{3}{\bfseries}{.}
% \begin{alignment}[flush,
%   tcols=1,
%   texts=hippocrates[xml:lang="grc"],
%   apparatus=hippocrates]
%   \AtBeginEnvironment{hippocrates}{\selectlanguage{greek}}
%   \begin{hippocrates}
%       \ekddiv{
%         head={Ἱπποκράτους ἐπιδημιῶν
%           \app{
%           \lem[wit={hI,hR,hH}]{βιβλίον δεύτερον}
%           \rdg[wit=hV]{λόγος β’}}},
%         type=book,
%         depth=1,
%         n=II}
% 
%         \ekddiv{
%         head={\app{
%           \lem[resp=egomute, post=suppleui,
%             type=emendation]{\supplied{Τμῆμα πρῶτον}}
%           \rdg[wit=hcodd, alt=om.]{}}},
%         type=section,
%         depth=2,
%         n=II.1
%       }
% 
%       \ekddiv{head=1, type=paragraph, depth=3, n=II.1.1} Ἄνθρακες
%       θερινοὶ ἐν Κραννῶνι· [...]
%     \end{hippocrates}
% \end{alignment}
% \endgroup
% 
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<div xml:id="div-hippocrates_1" xml:lang="grc">
  <div type="book" n="II">
    <head>Ἱπποκράτους ἐπιδημιῶν 
    <app>
      <lem wit="#I #R #H">βιβλίον δεύτερον</lem>
      <rdg wit="#V">λόγος β’</rdg>
    </app></head>
    <div type="section" n="II.1">
      <head>
        <app>
          <lem resp="#ego" type="emendation">
            <supplied>Τμῆμα πρῶτον</supplied>
          </lem>
          <rdg wit="#V #I #R #H" />
        </app>
      </head>
      <div type="paragraph" n="II.1.1">
        <head>1</head>
        <p>Ἄνθρακες θερινοὶ ἐν Κραννῶνι· [...]</p>
      </div>
    </div>
  </div>
</div>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \section{The Tricks of the Trade}
% \label{sec:tricks-of-trade}
% As the |.tex| source file is compiled, \pkg{ekdosis} has to compute
% a tremendous amount of data. Most of this work is performed by
% \textsf{Lua} functions. An edition text narrowed down to a single
% page needs to be compiled at least three times. On the first run,
% the apparatus criticus does not show. Instead, \pkg{ekdosis}
% produces an auxiliary file named \cs{jobname}|.ekd| in which all the
% entries of the apparatus criticus are collected. Then, on the second
% run a test is performed on this auxiliary file to determine whether
% there are entries\---and if so, which ones\---to be printed on the
% current page. At the same time, references to the line numbers are
% updated if necessary. Finally, on the third run, the apparatus
% criticus is printed.
%
% Of course, every change made to the input may similarly require
% \hologo{LuaLaTeX} to be run three more times to get everything to
% the right place with the right numbers.
%
% \subsection{The Oscillating Problem}
% \label{sec:oscillating-problem}
% In some instances, notably when on a given page entries are very
% abundant in number, specifically when the edition text is getting
% close to the bottom of the page, \pkg{ekdosis} may oscillate
% indefinitely between different sets of page decisions without being
% able to settle down. The condition may be typically illustrated as
% follows: after Lua\LaTeX\ has been run, an entry is attached to the
% last line of the page. As said above, this entry does not show
% yet. But when it does, should it result in an additional line being
% printed in the apparatus criticus, the last line of the edition
% text\---the one the entry was previously attached to\---goes to the
% next page. As a result, this entry also moves to the next page with
% the line it belongs to. This point is literally critical, because
% unless a \cs{pagebreak} is inserted just here so as to keep the
% contentious line on the next page, \pkg{ekdosis} enters a vicious
% circle from which it cannot escape, not to mention that right
% entries with right line numbers cannot come on pages that follow a
% wrong page either.
%
% An alert reader may have guessed that inserting a \cs{pagebreak} is
% a good way to get out of the vicious circle. And surely, if only a
% few pages be at stake, this is the way to go. However,
% \cs{pagebreak} commands should only be inserted when the whole
% edition text is ready for any substantial change in the preceding
% pages may result in pages that break just after they begin.
%
% \paragraph{Conditional page breaks}
% \DescribeMacro{\ekdpb} \cs{ekdpb}\oarg{page no}\marg{line no}
% \newfeature[v1.2]\\
% One way to avoid this inconvenience is to use \cs{ekdpb} instead of
% the standard \cs{pagebreak} command provided by \LaTeX\ to insert
% conditional page breaks. \cs{ekdpb} takes as mandatory argument the
% line number, as it is printed in the margin, where the page break
% should take place. An optional argument allows to further specify
% the page number where the page break should occur. The value that is
% expected is the page number as it is printed\===e.g.\ an Arabic,
% Roman or alphanumeric number. If the specified conditions be not
% met, then the page break is not triggered.
%
% \paragraph{Using \texttt{maxentries}}
% Another way\---should the edition text fall into the vicious circle
% too often\---is to limit the number of entries per page that a given
% layer of apparatus criticus may accept as described above
% \vpageref{ref:maxentries}. As a result, \pkg{ekdosis} will take care
% of inserting automatic breakpoints between pages whenever the number
% of entries on a given page reaches the value set as |maxentries|.
%
% |maxentries| must not be too small: otherwise offensive to look at
% vertical spaces may come between the edition text and the apparatus
% criticus. Conversely, |maxentries| must not be too big: otherwise,
% should entries overflow on a given page, the edition text and the
% apparatus criticus may clash again. As said above, a couple of
% clashes can be managed with a couple of manually inserted page
% breaks. But if there be too many of them, it is a good indication
% that the selected value of |maxentries| is too high.
%
% Complex edition texts do have a magic number. An advisable way to
% figure it out would be to start from a sample of only a few pages,
% selected as evidence for the complexity of the whole. As only a few
% pages would need to be compiled, the magic number should emerge
% quite rapidly.
%
% \paragraph{Adding and Removing Entries}
% \DescribeMacro{\addentries} \cs{addentries}\oarg{layer}\marg{n}
% \newfeature[v1.1]\\
% If |maxentries| be set for a given layer of critical notes,
% \cs{addentries}\oarg{layer}\marg{n}, where \meta{n} is an integer,
% can be used to add \meta{n} to\---or remove it from if \meta{n} be
% negative\---the number of accepted entries on the current
% page. \cs{addentries} operates on the default layer of notes, but
% any other declared layer can be specified in the optional argument
% of the command.
%
% \danger Of course, \cs{addentries} must be issued before the
% number of entries on a given page has reached the value set as
% |maxentries|.
%
% Once a sensible value for |maxentries| has been found,
% \cs{addentries} can further be used with a positive integer to allow
% for more entries and more lines on some pages so that offending
% vertical spaces are decreased. Conversely, \cs{addentries} with a
% negative integer will remove entries on pages where there are too
% many of them and \pkg{ekdosis} still oscillates between different
% sets of page decisions.
%
% \subsection{Variae Quaestiones}
% \label{sec:variae-quaestiones}
% This section is about issues that are not strictly speaking part of
% the documentation of \pkg{ekdosis} but may nevertheless
% circumstantially arise.
%
% \paragraph{Superfluous Dots}
% \phts\label{sec:superfluous-dots} As said above
% \vpageref{ref:ending-dot}, it is customary in some editions to have
% a full stop printed at the end of the apparatus
% criticus. \pkg{ekdosis} provides specific commands to achieve this
% in a straightforward way, such as \cs{SetEndApparatus} and the
% |ehook| optional argument of \cs{SetApparatus} and
% \cs{DeclareApparatus}.\footnote{See above
% \vpagerefrange{ref:setendapparatus}{sec:declaring-layers}.} However,
% if the last word of the apparatus criticus on a given page be an
% abbreviation followed by a dot, such a setting will have two dots
% printed at the end of the apparatus instead of one. The solution is
% to define a command to have a dot printed only if not followed by a
% dot, and append this command to the abbreviated form of the word,
% like so:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
% Preamble:
\usepackage{xspace}
\usepackage{ekdosis}

\makeatletter
\newcommand{\ekddot}{%
  \ltx@ifnextchar{.}{\xspace}{.\xspace}}
\makeatother

\DeclareApparatus{default}[ehook=.]
\DeclareScholar{Erm}{Erm\ekddot}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \begin{remarks}
% \item Line~2: The \pkg{xspace} package is needed for \cs{xspace} is
%   used by the \cs{ekddot} command that is defined at l.~6.
% \item Line~7: \cs{ltx@ifnextchar} is part of the \pkg{ltxcmds}
%   package which is loaded by \pkg{ekdosis}. As this command uses a
%   private control sequence, it must be found within
%   \cs{makeatletter} \dots\ \cs{makeatother}.
% \item Line~10: \cs{ekddot} will only work with multiple-layer
%   apparatus criticus. Therefore, \cs{DeclareAppa{\allowbreak}ratus}
%   must be used even if only one layer of critical notes be needed.
% \end{remarks}
%
% \paragraph{Backup of Essential Files}
% Each time the |.tex| source file is compiled, \pkg{ekdosis} reads
% the |.aux| corresponding \LaTeX\ auxiliary file and its own |.ekd|
% auxiliary file so as to process labels and collect entries of the
% apparatus criticus. If for whatever reason\---e.g.\ some unknown
% command has been inserted\---the compilation be frozen and so must
% be aborted, it may happen that most of the edition text has to be
% reconstructed page after page. For large and complex editions, this
% makes advisable to have current versions of those files backed up
% each time a new compilation begins, which can be achieved by
% inserting the following lines before the line that loads the
% document class:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\RequirePackage{verbatimcopy}
\IfFileExists{\jobname.aux}{%
  \OldVerbatimCopy{\jobname.aux}{\jobname.aux.bak}}{}
\IfFileExists{\jobname.ekd}{%
  \OldVerbatimCopy{\jobname.ekd}{\jobname.ekd.bak}}{}
\documentclass{book}
\end{minted}
% \iffalse
%</example>
% \fi
%
% This way, both |.aux| and |.ekd| files can be recovered from
% |.aux.bak| and |.ekd.bak| just after the compilation has been
% aborted. Should this be needed, one must proceed carefully as
% follows:---
% \begin{enumerate}
% \item Just after the compilation has been aborted, move both
%   |aux.bak| and |ekd.bak| files to a safe place.
% \item Remove or correct the offending command or lines that broke
%   the compilation and make sure that the issue is solved.
% \item Restore the |.aux| and |.ekd| files from |aux.bak| and
% |.ekd.bak| and resume work where it was left off.
% \end{enumerate}
%
% \section{\texttt{TEI xml} Output}
% \label{sec:teixml-output}
% Several examples of \texttt{TEI xml} output have been provided
% hitherto. Before proceeding, the reader is invited to return to
% every one of them. In this respect, it may be of interest to review
% carefully the excerpt of Caesar's \emph{Gallic War} of which the
% \LaTeX\ source file and its corresponding \texttt{TEI xml} output
% are printed in full below in \vref{sec:caesar-gw-6-1-13}. Once
% \pkg{ekdosis} has been instructed to convert the edition text into
% \texttt{TEI xml} (l.~11), the preamble of this file shows how to set
% languages and fonts to be used in the document (ll.~2--6), format
% the titles (l.~16) and lay out the alignment of an edition text
% associated with two translations (ll.~18--25) in modern
% languages. Furthermore, it shows how information related to each
% language (Latin, English and French) is to be found in two different
% places, namely for \texttt{TEI xml} output (ll.~21--3) and for PDF
% output through \LaTeX\ (ll.~27--9). Finally, it provides examples of
% declaring witnesses, hands and shorthands (ll.~31--60). As to the
% document itself, it shows how to lay out a conspectus siglorum in a
% table (ll.~64--80), before giving detailed examples of how the
% edition text is entered (ll.~85--101) and sectional commands
% provided by \pkg{ekdosis} are used (ll.~86, 103 and
% 110).\footnote{The PDF output is available as
% \href{samples/Caesar_BG-6-13-1.pdf}{a separate file}.}
%
% \subsection{Requesting \texttt{TEI xml} Output}
% \label{sec:request-tei-output}
% \texttt{TEI xml} output is requested by means of the |teiexport|
% global option as described above
% \vpageref{ref:teiexport-option}. Once instructed to output
% \texttt{TEI}, \pkg{ekdosis} converts and exports in sequence the
% contents of \env{ekdosis} environments (see above
% \vref{sec:single-text-editing}). As regards the contents of
% \env{alignment} environments (see above \vref{sec:alignment-basic}),
% \pkg{ekdosis} first collates the contents of the environments that
% have been declared as values of the |texts| optional argument of
% \env{alignment} or \cs{SetAlignment},\footnote{See above
% \vref{sec:multiple-alignment}.} then places each of the
% corresponding \texttt{TEI xml} outputs within distinct |<div>|
% elements named after the declared environments themselves. For
% example, to return to Caesar's text, the Latin edition text is found
% between a \cs{begin}|{latin}| \dots\ \cs{end}|{latin}| environment
% (see the |.tex| source file, \vref{sec:caesar-gw-tex}, ll.~85--101)
% which is declared at l.~21. Then, the corresponding \texttt{xml}
% output is found within a |<div>| element, the |xml:id| of which has
% been given by \pkg{ekdosis} the value |div-latin_1| (see
% \vref{sec:caesar-gw-tei}, ll.~176--200).
%
% \paragraph{\texttt{TEI} File Name} \DescribeMacro{\SetTEIFilename}
% \cs{SetTEIFilename}\marg{basename} is a preamble-only command. It
% can be used to set the base name of the \texttt{TEI xml} output
% file, to which the suffix |.xml| is appended. By default, the base
% name is \cs{jobname}|-tei|.
%
% \subsection{General Principles}
% \label{sec:totei-general-principles}
% \paragraph{Validation of the \texttt{TEI xml} Structure}
% The reference tool that the author relies on is that provided by the
% \emph{\texttt{TEI} by Example Project}.\footnote{\cite{TBE}.
% The \texttt{TEI} validator is here:
% \url{http://teibyexample.com/xquery/TBEvalidator.xq}.} As for
% \pkg{ekdosis}, it is designed to produce on request, in addition to
% an edition in print, a \texttt{TEI xml}-compliant output file. That
% said, one must keep in mind that the \LaTeX\ packages that are part
% of {\TeX}Live can be counted in thousands, and the commands they
% provide in tens of thousands. There may even be grounds in asserting
% that the possibilities offered by \TeX\ and \LaTeX\ quite exceed
% what can be afforded by \texttt{TEI xml}. On another hand, many
% \LaTeX\ commands make no sense in \texttt{TEI}. Therefore, a
% sensible choice is to keep them out of the environments the contents
% of which are to be translated into \texttt{xml} elements, as will be
% illustrated by the following.
% 
% Converting a \LaTeX\ document into \texttt{TEI xml} can be quite an
% intricate business. In many cases, however, \LaTeX\ strings are
% found within environments or groups that are easy to convert into
% \texttt{TEI} equivalents: unless instructed otherwise, whether such
% groups are delimited by opening and closing braces or by explicit
% \cs{begin} \dots\ \cs{end} commands, \pkg{ekdosis} translates them
% into |xml| so that for example \cs{emph}|{word}| and
% \cs{begin}|{quote}| \meta{quoted words} \cs{end}|{quote}| become
% |<emph>| \meta{word} |</emph>| and |<quote>| \meta{quoted words}
% |</quote>| respectively.
%
% But \LaTeX\ does not place everything into groups or
% environments. To take here but a few examples, sectional divisions
% are marked in \LaTeX\ with \enquote{open} commands such as
% \cs{chapter} or \cs{section} with no clear indication where the
% closure of divisions occurs, contrary to \texttt{TEI xml} markup
% with numbered or un-numbered |<div>| elements allowed to nest
% recursively. As regards running paragraphs of text, the situation is
% even worse than in the latter case, as the following simple example
% shows:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
\begin{document}
\begin{ekdosis}
  ...

  ... These are the final words of some section in the body text.

  \section{New Section}

  Here is how some new section begins...

  ... Final words.
  \section{Other Section}
  Opening words of the section...
  
  ... Final words
  
  \section{Other Section}
  Opening words...
  
  ... Final words.
\end{ekdosis}
\end{document}
\end{minted}
% \iffalse
%</example>
% \fi
%
% Obviously, construing this \LaTeX\ source file into \texttt{TEI xml}
% is a fairly complex task. For example, line~6 only closes a
% paragraph for line~7 opens a division (hence |</p><div1>|), line~8
% only opens a paragraph just after the heading of the section (hence
% |</head><p>|) while line~14 both closes the foregoing paragraph and
% opens a new one (hence |</p><p>|), contrary to line~16 which both
% closes a paragraph and a sectional division (hence |</p></div1>|),
% not to mention lines~20--1, where notwithstanding the absence of
% blank line or any other indication,
% |</p></div1></body></text></TEI>| is needed.
%
% \pkg{ekdosis} has been designed to implement this task through
% \textsf{Lua} functions which involve string matching (both forward
% and reverse matching) and recursions.
%
% \paragraph{\texttt{TEI xml} Export Settings}
% \label{ref:setteixmlexport}
% \DescribeMacro{\SetTEIxmlExport} \cs{SetTEIxmlExport}\marg{csv list
% of options} can be used in the preamble or at any point of the
% document, except inside environments set to receive an apparatus
% criticus, namely the \env{ekdosis} environment or any other similar
% environment declared by means of the \env{alignment} environment or
% \cs{SetAlignment}.\footnote{See above
% \vref{sec:multiple-alignment}.}  At the time of writing, there is
% only one option, as follows:---\\
% \DescribeOption{autopar} |autopar|$=$\verb+true|false+
% \hfill\tcboxverb{Default: true}\\
% The algorithm described above applies for edition texts composed in
% running paragraphs or lines of poetry, but it may fail to produce a
% valid \texttt{TEI xml} output with other arrangements, such as
% performance texts or transcriptions of speech for which the
% \texttt{TEI} Guidelines define specific rules.  |autopar=false|
% instructs \pkg{ekdosis} to ignore blank lines in the |.tex| source
% file as markers for paragraph boundaries. As a result, each
% paragraph of the edition text must be found within an environment
% associated with the \texttt{xml} element |<p>|, such as \env{ekdpar}
% or any other environment declared as such by means of \cs{EnvtoTEI}
% described below in \vref{sec:new-cmds-envs}. A typical use case of
% |autopar=false| is provided below in
% \vref{sec:specific-tei-modules}.
%
% \DescribeEnv{ekdpar} \cs{begin}|{ekdpar}| \dots\ \cs{end}|{ekdpar}|
% is a simple environment that does nothing but insert \cs{par}
% primitives. It can be used to instruct \pkg{ekdosis} to place
% paragraphs within |<p>| elements when |autopar| has been set to
% |false| by means of \cs{SetTEIxmlExport} described above.
%
% \paragraph{The \texttt{xml:id} Attribute}
% As a general rule, the |xml:id| global attribute must be unique for
% the element that bears the attribute. Furthermore, it must begin
% with a letter or an underscore and contain no characters other that
% letters, digits, hyphens, underscores and full stops. \pkg{ekdosis}
% issues a warning when it finds that any \meta{unique id} of
% \meta{unique label} expected in the first argument of
% \cs{DeclareWitness}, \cs{DeclareHand}, \cs{DeclareSource} or
% \cs{DeclareScholar} is not unique or breaks the rules just
% described, but does not prevent the |.tex| source file from
% compiling. Instead, it prints the string |<??>| in place of the
% expected formatted siglum so that the error in the |.tex| source
% file can be easily spotted and corrected.
%
% \danger As the \meta{unique id} declared with \cs{DeclareShorthand}
% is not to be exported in the \texttt{TEI xml} output file,
% \pkg{ekdosis} checks neither its uniqueness nor its validness.
%
% \danger It must be noted that \LaTeX\ labels that are provided in
% commands such as \cs{label}, \cs{cite} and the like must also be
% unique in the document. As \LaTeX\ will issue warnings if duplicates
% be found, \cs{ekdosis} does not check their uniqueness but will
% issue warnings if such labels contain invalid strings.
%
% \subsection{Routine \LaTeX\ Commands and Environments}
% \label{sec:routine-cmds}
% The list of \LaTeX\ commands known by \pkg{ekdosis} at the time of
% writing follows. To this list must be added the \LaTeX\ standard
% commands that are used for sectional divisions as described above in
% \vref{sec:latex-divs} and most of the commands provided by the
% \pkg{arabluatex} and \pkg{icite}\footcite{icite} packages. Standard
% citation commands are also supported as will be described below in
% \vref{sec:citation-cmds}:---
% 
% \begin{xltabular}{0.825\linewidth}{XX}
%     \toprule
%     \LaTeX\ command & \texttt{TEI xml} element\\
%     \midrule\endhead
%     \cs{textsuperscript}|{}| & |<hi rend="sup"></hi>| \\
%     \cs{textsubscript}|{}| & |<hi rend="sub"></hi>| \\
%     \cs{textbf}|{}| & |<hi rend="bold"></hi>| \\
%     \cs{textit}|{}| & |<hi rend="italic"></hi>| \\
%     \cs{textsc}|{}| & |<hi rend="smallcaps"></hi>| \\
%     \cs{textsf}|{}| & |<hi rend="sf"></hi>| \\
%     \cs{footnote}|{}| & |<note place="bottom"></note>| \\
%     \cs{marginpar}|{}| & |<note place="margin"></note>| \\
%     \cs{enquote}\meta{*}|{}| & |<quote></quote>| \\
%     \cs{label}|{label}| & |<anchor xml:id="label"/>| \\
%     \cs{linelabel}|{label}| & |<anchor xml:id="label"/>| \\
%     \cs{ref}|{label}| & |<ptr ="#label"/>| \\
%     \cs{pageref}|{label}| & |<ptr ="#label"/>| \\
%     \cs{vref}|{label}| & |<ptr ="#label"/>| \\
%     \cs{vpageref}|{label}| & |<ptr ="#label"/>| \\
%     \cs{pagebreak}\meta{\oarg{1-4}} & no output \\
%     \cs{mbox}\marg{text} &  \meta{text} \\
%     \midrule
%     \multicolumn{2}{c}{From the \pkg{extdash}\footcite{extdash}
%     package:}\\
%     \cs{---} or \cs{===} & --- \\
%     \cs{--} or \cs{==} & -- \\
%     \cs{-/} or \cs{=/} & ‐ \\
%     \bottomrule
% \end{xltabular}
%
% As for environments:---
% 
% \begin{xltabular}{0.825\linewidth}{XX}
%     \toprule
%     \LaTeX\ environment & \texttt{TEI xml} element\\
%     \midrule\endhead
%     |flushright| & |<p rend="align(right)"></p>| \\
%     |flushleft| & |<p rend="align(left)"></p>| \\
%     |center| & |<p rend="align(center)"></p>| \\
%     |quotation| & |<quote></quote>| \\
%     |quoting| & |<quote></quote>| \\
%     |verse| & |<lg></lg>| \\
%     \bottomrule
% \end{xltabular}
%
% Regarding other, very frequently used commands or environments, some
% do not need to be inserted in the translation tables: as already
% said above, \pkg{ekdosis} converts by default the original names of
% these into \texttt{xml} elements. For instance, \cs{emph}|{}| and
% \cs{begin}|{quote}| \dots\ \cs{end}|{quote}| will result in
% |<emph></emph>| and |<quote></quote>| respectively.
%
% For the same simple reason, should one wish to have words within a
% \texttt{TEI xml} element that does not have any \LaTeX\ equivalent,
% all is needed is to define an inoperative \LaTeX\ command named
% after the \texttt{TEI} element, like so:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
% Preamble:
\newcommand{\mentioned}[1]{#1}

% Document:

Our usage corresponds to the \mentioned{aggregate} of many
mathematical writings and to the sense of \mentioned{class} found in
older logical writings.
\end{minted}
% \iffalse
%</example>
% \fi
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>Our usage corresponds to the <mentioned>aggregate</mentioned> of
many mathematical writings and to the sense of
<mentioned>class</mentioned> found in older logical writings.</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% Of course, it is also possible to have the \enquote{mentioned} words
% printed in a different font family:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\newcommand{\mentioned}[1]{\textsf{#1}}
\end{minted}
% \iffalse
%</example>
% \fi
%
% This command will print them in a sans serif font family, with the
% exact same \texttt{TEI xml} output as above.
%
% \subsection{Processing New Commands or Environments}
% \label{sec:new-cmds-envs}
% The following three commands are provided to instruct \pkg{ekdosis}
% how to convert unknown or unusual \hologo{(La)TeX} commands or
% environments into \texttt{TEI xml} equivalents.
%
% \DescribeMacro{\TeXtoTEI} \cs{TeXtoTEI}\marg{csname}\marg{TEI
% element}\oarg{TEI attribute(s)}\\
% \cs{TeXtoTEI} takes two mandatory arguments and one optional
% argument, namely: the control sequence name to be converted, the
% \texttt{TEI} element it is to be converted into and any additional
% \texttt{xml} attributes to be appended to the opening \texttt{TEI}
% element. For example, the \cs{sidenote} command that is provided by
% the \pkg{sidenotes} package can be processed like so:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
% Preamble:
\TeXtoTEI{sidenote}{note}[place="margin"]

% Document:
\begin{ekdosis}
  \begin{ekdverse}
    The self-same moment I could pray;\sidenote{The spell begins to
      break}\footnote{The turning point of the poem...}
  \end{ekdverse}
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<lg>
  <l>The self-same moment I could pray;
  <note place="margin">The spell begins to break</note>
  <note place="bottom">The turning point of the
  poem...</note></l>
</lg>
\end{minted}
% \iffalse
%</example>
% \fi
%
% Even more subtly, provided that the code |#STC| points to some more
% information identifying the agency concerned:\footnote{At the time
% of writing, \enquote*{sources} can be declared with
% \cs{DeclareSource} as described above
% \vpageref{ref:declare-source}. Then the unique identifier used in
% the first argument of this command can point to the list of
% references inserted by \pkg{ekdosis} in the back matter section of
% the \texttt{TEI} output file. See below
% \vref{sec:references-cited-works} for more information on how to do
% this. Scholars can also be referred to as individuals by means of
% the \cs{DeclareScholar} command. See above
% \vpageref{ref:declare-source}.}---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
% Preamble:
\usepackage{sidenotes}
\usepackage[teiexport=tidy]{ekdosis}

\TeXtoTEI{sidenote}{note}[place="margin"]

\newcommand{\STCsnote}[1]{\sidenote{#1}}
\TeXtoTEI{STCsnote}{note}[place="margin" resp="#STC"]

% Document:
\begin{ekdosis}
  \begin{ekdverse}
    The self-same moment I could pray;\STCsnote{The spell begins to
      break}\footnote{The turning point of the poem...}
  \end{ekdverse}
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<lg>
  <l>The self-same moment I could pray;
  <note place="margin" resp="#STC">The spell begins to
  break</note>
  <note place="bottom">The turning point of the
  poem...</note></l>
</lg>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \DescribeMacro{\EnvtoTEI} \DescribeMacro{\EnvtoTEI*}
% \cs{EnvtoTEI}\meta{*}\marg{env name}\marg{TEI element}\oarg{TEI
% attribute(s)}\\
% \cs{EnvtoTEI} instructs \pkg{ekdosis} how to convert \LaTeX\
% environments into \texttt{TEI xml} equivalents. It takes two
% mandatory arguments and one optional argument, namely the name of
% the \LaTeX\ environment to be converted, the \texttt{TEI} element it
% is to be converted into and any additional attributes to be appended
% to the \texttt{TEI} opening element. \cs{EnvtoTEI*} is restricted to
% \texttt{TEI} elements that must never appear within |<p>| elements,
% such as |<p>| itself, |<div>|, |<lg>| and the like. The following
% example illustrates how \cs{EnvtoTEI} can be used conjointly with
% \pkg{babel} to convey information about the languages used from
% \LaTeX\ to \texttt{TEI}:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
% Preamble:
% Use babel and babeltags:
\usepackage[greek.ancient, english]{babel}
\babeltags{ancientgreek = greek}

\EnvtoTEI{ancientgreek}{p}[xml:lang="grc"]

% Document:
\begin{ekdosis}
  \begin{ancientgreek}
    περὶ πολλοῦ ἂν ποιησαίμην, ὦ ἄνδρες, τὸ τοιούτους ὑμᾶς ἐμοὶ
    δικαστὰς περὶ τούτου τοῦ πράγματος γενέσθαι, οἷοίπερ ἂν ὑμῖν
    αὐτοῖς εἴητε τοιαῦτα πεπονθότες...
  \end{ancientgreek}
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p xml:lang="grc">περὶ πολλοῦ ἂν ποιησαίμην, ὦ ἄνδρες, τὸ
τοιούτους ὑμᾶς ἐμοὶ δικαστὰς περὶ τούτου τοῦ πράγματος
γενέσθαι, οἷοίπερ ἂν ὑμῖν αὐτοῖς εἴητε τοιαῦτα πεπονθότες...</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \DescribeMacro{\TeXtoTEIPat}
% \phts\label{ref:textoteipat}
% \cs{TeXtoTEIPat}\marg{\TeX\ pattern}\marg{TEI pattern}\\
% Finally, this more flexible\---and more delicate to
% handle\---command uses pattern matching to instruct \pkg{ekdosis}
% how to convert \hologo{(La)TeX} commands into \texttt{TEI}
% equivalents. In the first mandatory argument, strings to be captured
% are marked in sequence with numbers prefixed by |#|, like so: |#1|,
% |#2|, |#3| and so forth. Then, in the second mandatory argument, the
% strings captured are inserted where each of them is expected in
% the \texttt{TEI} element.
%
% \danger If the entire string to be captured be enclosed in square or
% curly brackets, it is advisable to use |@b|\texttt{\emph{n}} (for
% curly brackets) or |@s|\texttt{\emph{n}} (for square brackets)
% instead of |#|\texttt{\emph{n}}, where \texttt{\emph{n}} is the
% number that is expected in the sequence. This will prevent any
% brackets that may be found in the captured string from being
% interpreted.
%
% \danger Strings must be entered exactly as \pkg{ekdosis} will find
% them as the |.tex| source file is compiled. Specifically,
% \emph{control sequences}, namely the coded commands immediately
% preceded by `\verb+\+' are always found followed by a space. For
% instance, |\emph{}| will be seen and processed by \pkg{ekdosis} as
% \verb*|\emph {}|.
%
% The following example illustrates how \pkg{ekdosis} can be
% instructed to process the
% \cs{textcolor}\allowbreak\marg{color}\marg{text} command:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos]{latex}
\TeXtoTEIPat{\textcolor␣{#1}@b2}{<hi rend="#1">@b2</hi>}

Sample text with a \textcolor{red}{word} in red.
\end{minted}
% \iffalse
%</example>
% \fi
% 
% \begin{remarks}
% \item[\textsc{Rem.}]  As can be seen from l.~1, it is safe to use
%   |#1| for the first string for color names are naturally formed of
%   letters without braces. However, |@b2| is preferable to capture
%   the whole second argument of \cs{textcolor} for it may contain
%   words within braces.
% \end{remarks}
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<p>Sample text with a 
<hi rend="red">word</hi>in red.</p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Inserting Code in the \texttt{TEI xml} Ouput File}
% \label{sec:inserting-code-tei}
% It may be needed to insert code in the \texttt{TEI xml} output file
% only, for example when clear enough information is written in the
% apparatus criticus by means of such optional arguments as |pre|,
% |post|, |prewit| or |postwit| that are not processed for \texttt{TEI
% xml} ouput.\footnote{See above \vref{sec:single-text-editing}.}
%
% \needspace{2\baselineskip}
% \DescribeMacro{\teidirect} \newfeature[v1.3] \cs{teidirect}\oarg{xml
% attributes}\marg{xml element}\marg{code}\\
% Two mandatory arguments are expected by \cs{teidirect}, namely the
% \texttt{TEI xml} element followed by the contents to be found in the
% ouput file between the opening and closing tags. Additionally,
% attribute-value pairs to be found inside the start-tag of the
% element can be specified in the optional argument of the command. An
% example follows:
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos]{latex}
% Preamble:
\DeclareWitness{GalE1.M}{Gal.E1(M)}{\emph{Monacencis Gr.}
  231}[origDate=s. XVI]
\DeclareWitness{GalE1.Q}{Gal.E1(Q)}{\emph{Parisinus Gr.}
  2174}[origDate=s. XIV]
  \DeclareShorthand{GalE1.M.Q}{Gal.E1(MQ)}{GalE1.M,GalE1.Q}

% Document:
ἐν \app{
    \lem[wit=codd]{καύμασιν}
    \rdg[wit=GalE1.M.Q, postwit=\unskip(23.16)]{καύματι}
    \teidirect{note}{p. 23, l. 16 Wenkebach}}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \begin{remarks}
% \item |GalE1.M.Q| (l.~11) has been defined as a shorthand to denote
%   the agreement of two otherwise defined manuscripts by means of
%   \cs{DeclareWitness}: |GalE1.M| and |GalE1.Q|. (See ll.~2--6.)
% \item The |postwit| optional argument has been used to further
%   specify the location where this variant reading can be found in
%   the critical edition of Galen's Commentary on Hippocrates'
%   \emph{Epidemics}, Book~1 (l.~11). But as the effect of |postwit|
%   is limited to the PDF output, \cs{teidirect} has been used to
%   convey this item of information to the \texttt{TEI xml} ouput file
%   (l.~12).
% \end{remarks}
%
% PDF output:---
% \medskip
%
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%     \begin{ancientgreek}
% ἐν \app{
%     \lem[wit=hcodd]{καύμασιν}
%     \rdg[wit=hGalE1.M.Q, postwit=\unskip(23.16)]{καύματι}
%     \teidirect{note}{p. 23, l. 16 Wenkebach}}
%     \end{ancientgreek}
%   \end{specimen}
% \end{alignment}
%
% \texttt{TEI xml} output:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos]{xml}
<p xml:lang="grc">ἐν 
<app>
  <lem wit="#V #I #R #H">καύμασιν</lem>
  <rdg wit="#GalE1.#M #GalE1.Q">καύματι</rdg>
  <note>p. 23, l. 16 Wenkebach</note>
</app></p>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Specific \texttt{TEI} Modules}
% \label{sec:specific-tei-modules}
% The following example illustrates how \pkg{ekdosis} can be adapted
% in a straightforward way to modules provided by the \texttt{TEI} for
% encoding specific texts such as transcriptions of
% speech.\footnote{See
% \url{https://tei-c.org/release/doc/tei-p5-doc/en/html/TS.html}.} The
% technique applied below uses \cs{EnvtoTEI} conjointly with
% \cs{SetTEIxmlExport}|{autopar=|\allowbreak|false}| described above
% \vpageref{ref:setteixmlexport}:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
% Preamble:
\newenvironment{speech}{\par}{\par}
\newcommand{\speaker}[1]{\textbf{#1}\par}
\EnvtoTEI{speech}{sp}

\SetTEIxmlExport{autopar=false}

% Document:
\begin{ekdosis}
  \begin{speech}
    \speaker{Σωκράτης}
    \begin{ekdpar}
      κατέβην χθὲς εἰς Πειραιᾶ μετὰ Γλαύκωνος τοῦ Ἀρίστωνος
      προσευξόμενός τε τῇ θεῷ καὶ ἅμα τὴν ἑορτὴν βουλόμενος θεάσασθαι
      τίνα τρόπον ποιήσουσιν ἅτε νῦν πρῶτον ἄγοντες. καλὴ μὲν οὖν μοι
      καὶ ἡ τῶν ἐπιχωρίων πομπὴ ἔδοξεν εἶναι, οὐ μέντοι ἧττον ἐφαίνετο
      πρέπειν ἣν οἱ Θρᾷκες ἔπεμπον.
    \end{ekdpar}
  \end{speech}
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \begin{remarks}
% \item Lines~2--3 define a basic environment meant to contain
% individual speeches and a command to hold the name of the
% speaker. This name is printed in bold face and followed by a new
% paragraph in the PDF output.
% \item Line~4 instructs \pkg{ekdosis} to convert \env{speech} \LaTeX\
%   environments into |<sp>| \texttt{TEI xml} elements.
% \item Line~6 disables the |autopar| algorithm that \pkg{ekdosis}
%   provides by default for running paragraphs of text. As a
%   consequence, \env{ekdpar} is used to mark the paragraphs.
% \end{remarks}
% 
% PDF output:---
% \medskip
%
% \needspace{7\baselineskip}
% \SetTEIxmlExport{autopar=false}
% \begingroup
% \newenvironment{speech}{\par\selectlanguage{greek}}{\par}
% \newcommand{\speaker}[1]{\textbf{#1}\par}
% \EnvtoTEI{speech}{sp}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%  \begin{speech}
%    \speaker{Σωκράτης}
%    \begin{ekdpar}
%      κατέβην χθὲς εἰς Πειραιᾶ μετὰ Γλαύκωνος τοῦ Ἀρίστωνος
%      προσευξόμενός τε τῇ θεῷ καὶ ἅμα τὴν ἑορτὴν βουλόμενος θεάσασθαι
%      τίνα τρόπον ποιήσουσιν ἅτε νῦν πρῶτον ἄγοντες. καλὴ μὲν οὖν μοι
%      καὶ ἡ τῶν ἐπιχωρίων πομπὴ ἔδοξεν εἶναι, οὐ μέντοι ἧττον ἐφαίνετο
%      πρέπειν ἣν οἱ Θρᾷκες ἔπεμπον.
%    \end{ekdpar}
%  \end{speech}     
%   \end{specimen}
% \end{alignment}
% \endgroup
% \SetTEIxmlExport{autopar=true}
%
% \texttt{TEI xml} output:---
% 
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<sp>
  <speaker>Σωκράτης</speaker>
  <p>κατέβην χθὲς εἰς Πειραιᾶ μετὰ Γλαύκωνος τοῦ Ἀρίστωνος
  προσευξόμενός τε τῇ θεῷ καὶ ἅμα τὴν ἑορτὴν βουλόμενος
  θεάσασθαι τίνα τρόπον ποιήσουσιν ἅτε νῦν πρῶτον ἄγοντες.
  καλὴ μὲν οὖν μοι καὶ ἡ τῶν ἐπιχωρίων πομπὴ ἔδοξεν εἶναι, οὐ
  μέντοι ἧττον ἐφαίνετο πρέπειν ἣν οἱ Θρᾷκες ἔπεμπον.</p>
</sp>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{References to Cited Works}
% \label{sec:references-cited-works}
% A full example of what is technically called a \emph{Conspectus
% Siglorum} can be found above in \vref{sec:print-witnesses}. Such a
% list of manuscript sigla should be found immediately before the
% edition text. Traditionally, this section is followed by a list of
% other sources used to establish the text, so that the edited text is
% in the end established both from manuscript evidence (the
% \enquote{witnesses}) and other works based on a scholarly approach
% of the text (the \enquote{sources}) which are called in Latin
% \emph{Editiones uel Studia}. As a consequence of this classification
% as \enquote{witness} or \enquote{source}, the former must go within
% the |<listWit>| element of the \texttt{TEI} header, whereas the
% latter is to be found within the |<listBibl>| element.
%
% \DescribeMacro{\AddxmlBibResource}
% \cs{AddxmlBibResource}\marg{basename or name.xml} is a preamble-only
% command. If a base name (either suffixed with |.xml| or not) for a
% \texttt{TEI xml}-compliant bibliographical database be provided,
% \pkg{ekdosis} will use it and insert formatted data in the back
% matter section of its own \texttt{TEI xml} output file, as
% |<biblStruct>| elements within a |listBibl| section.
%
% As an example, the following Bib\hologo{(La)TeX} entry and its
% \texttt{TEI} equivalent are provided:\footnote{\label{fn:zotero}To
% the author's knowledge, \textsf{Zotero}
% (\url{https://www.zotero.org}) provides excellent \texttt{TEI xml}
% output from Bib\hologo{(La)TeX} input files.}---
%
% \iffalse
%<*example>
% \fi
\begin{minted}{bibtex}
@Book{Drak,
  title = {Punicorum Libri Septemdecim},
  author = {Silius Italicus, Tiberius Catius},
  editor = {Drakenborch, Arnold},
  date = {1717},
  publisher = {Trajecti ad Rhenum},
  location = {Utrecht}
}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \iffalse
%<*example>
% \fi
\begin{minted}{xml}
<?xml version="1.0" encoding="UTF-8"?>
<listBibl xmlns="http://www.tei-c.org/ns/1.0">
  <biblStruct type="book" xml:id="Drak">
    <monogr>
      <title level="m">Punicorum libri septemdecim</title>
      <author>
        <forename>Tiberius Catius</forename>
        <surname>Silius Italicus</surname>
      </author>
      <editor>
        <forename>Arnold</forename>
        <surname>Drakenborch</surname>
      </editor>
      <imprint>
        <pubPlace>Utrecht</pubPlace>
        <publisher>Trajecti ad Rhenum</publisher>
        <date>1717</date>
      </imprint>
    </monogr>
  </biblStruct>
</listBibl>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \danger As can be seen, the same string |Drak| is used as a label in
% the Bib\hologo{(La)TeX} file (l.~1) and an |xml:id| in the
% \texttt{TEI} file (l.~3). This same label must be used again in the
% preamble of the |.tex| source file to declare Arnold Drakenborch as a
% source,\footnote{See above \vpageref{ref:declare-source}.} like
% so:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
% Use 'bibl.xml' as a TEI xml bibliographical database:
\AddxmlBibResource{bibdata.xml}

% Declare A. Drakenborch as source:
\DeclareSource{Drak}{\emph{Drakenborch}}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \phts\label{ref:ekdverse-ex}
% Finally, an extract of Silius Italicus' \emph{Punica}, Book~9,
% ll.~30-2 follows (|.tex| source file, PDF output and \texttt{TEI}
% output files):---
%
% \iffalse
%<*example>
% \fi
\begin{minted}{latex}
% Preamble:
\usepackage[style=oxnotes]{biblatex}
\addbibresource{bibdata.bib}

\usepackage[teiexport=tidy]{ekdosis}

% basename of the .xml bibliographical database:
\AddxmlBibResource{bibdata.xml}

% Witnesses:
\DeclareWitness{L}{L}{Laurentianus, plut, XXXVII, cod. 16}[
                      origDate=s. XV]
% Other witnesses [...]

% Sources:
\DeclareSource{Drak}{\emph{Drakenborch}}
% Alternatively, use BibLaTeX for the rendition:
% \DeclareSource{Drak}{\citename{Drak}{editor}}
% Other sources [...]

% Document:
\begin{ekdosis}
  \begin{ekdverse}
    Sed uos, quorum oculos atque ora humentia uidi,\\
    uertere cum consul terga et remeare iuberet,\\
    \app{
      \lem[source=Drak, type=emendation]{ne morem}
      \rdg[wit={L, F}]{me morem}
      \rdg[wit={O, V}]{memorem}
    } et pugnae signum exspectate petendae:\\
  \end{ekdverse}
\end{ekdosis}
\end{minted}
% \iffalse
%</example>
% \fi
%
% PDF output:---
% \medskip
%
% \needspace{7\baselineskip}
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
% \resetlinenumber\resetvlinenumber[30]
% \setlength{\vrightskip}{-1.5in}
%   \begin{specimen}
%     \begin{ekdverse}
%       Sed uos, quorum oculos atque ora humentia uidi,\\
%       uertere cum consul terga et remeare iuberet,\\
%       \app{
%         \lem[source=sDrak, type=emendation]{ne morem}
%         \rdg[wit={sL, sF}]{me morem}
%         \rdg[wit={sO, sV}]{memorem}
%       } et pugnae signum exspectate petendae:\\
%     \end{ekdverse}
%   \end{specimen}
% \end{alignment}
%
% \texttt{TEI xml} output file produced by \pkg{ekdosis} (narrowed
% down to the |<text>| element):---
%
% \iffalse
%<*example>
% \fi
\begin{minted}{xml}
<text>
  <body>
    <lg>
      <l>Sed uos, quorum oculos atque ora humentia uidi,</l>
      <l>uertere cum consul terga et remeare iuberet,</l>
      <l>
      <app>
        <lem source="#Drak" type="emendation">ne morem</lem>
        <rdg wit="#L #F">me morem</rdg>
        <rdg wit="#O #V">memorem</rdg>
      </app>et pugnae signum exspectate petendae:</l>
    </lg>
  </body>
  <back>
    <listBibl>
      <biblStruct type="book" xml:id="Drak">
        <monogr>
          <title level="m">Punicorum libri septemdecim</title>
          <author>
            <forename>Tiberius Catius</forename>
            <surname>Silius Italicus</surname>
          </author>
          <editor>
            <forename>Arnold</forename>
            <surname>Drakenborch</surname>
          </editor>
          <imprint>
            <pubPlace>Utrecht</pubPlace>
            <publisher>Trajecti ad Rhenum</publisher>
            <date>1717</date>
          </imprint>
        </monogr>
      </biblStruct>
    </listBibl>
  </back>
</text>
\end{minted}
% \iffalse
%</example>
% \fi
%
% \subsection{Citation Commands}
% \label{sec:citation-cmds}
% \pkg{ekdosis} can also convert into \texttt{TEI xml} references to
% cited works. Depending on the optional arguments used in the
% citation command, references will be converted into |<ptr>| or
% |<ref>| elements with the appropriate identifier supplied by means
% of the |target| attribute.
%
% Of course, for this mechanism to work, Bib\TeX\ or Bib\LaTeX\ must
% be used and connected to some |.bib| bibliographical database
% file. Additionally, this |.bib| file must have been converted into a
% \texttt{TEI xml}-compliant file where all the Bib\hologo{(La)TeX}
% entries that are used in the document are found within
% |<biblStruct>| elements.\footnote{See above n.~\vref{fn:zotero} for
% information on how to do this.} Finally, this |.xml| bibliographical
% database must have been connected to the |.tex| source file by means
% of \cs{AddxmlBibResource} described above in
% \vref{sec:references-cited-works}.
%
% As an example, the following |sample.bib| file is used:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{bibtex}
@Book{ReynoldsWilson1991,
  author =	 {Reynolds, L. D. and Wilson, N. G},
  title =	 {Scribes and Scholars},
  year =	 {1991},
  subtitle =	 {A Guide to the Translation of Greek and Latin
                  Literature},
  edition =	 {3},
  publisher =	 {Clarendon Press},
  location =	 {Oxford}
}
\end{minted}
% \iffalse
%</example>
% \fi
%
% It has been converted into |sample.xml| as follows:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<?xml version="1.0" encoding="UTF-8"?>
<listBibl xmlns="http://www.tei-c.org/ns/1.0">
  <biblStruct type="book" xml:id="ReynoldsWilson1991">
    <monogr>
      <title level="m">Scribes and Scholars</title>
      <author>
        <forename>L. D.</forename>
        <surname>Reynolds</surname>
      </author>
      <author>
        <forename>N. G.</forename>
        <surname>Wilson</surname>
      </author>
      <edition>3</edition>
      <imprint>
        <pubPlace>Oxford</pubPlace>
        <publisher>Clarendon Press</publisher>
        <date>1991</date>
      </imprint>
    </monogr>
  </biblStruct>
</listBibl>
\end{minted}
% \iffalse
%</example>
% \fi
%
% Once both files have been prepared, inserting references and
% exporting them into the \texttt{TEI xml} output file can be achieved
% in a straightforward way. (The full |sample.tex| is provided
% below.)---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
\documentclass{article}

\usepackage[teiexport=tidy]{ekdosis}
\AddxmlBibResource{sample.xml}

\usepackage[style=oxnotes]{biblatex}
\addbibresource{sample.bib}

\begin{document}
\begin{ekdosis}
  On textual criticism, see \cite[207--241]{ReynoldsWilson1991}.
\end{ekdosis}
\end{document}
\end{minted}
% \iffalse
%</example>
% \fi
%
% PDF output:---
% \medskip
%
% \needspace{7\baselineskip}
% \resetlinenumber
% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
%   \begin{specimen}
%   On textual criticism, see \cite[207--241]{ReynoldsWilson1991}.
%   \end{specimen}
% \end{alignment}
%
% \medskip
% \texttt{TEI xml} output narrowed down to the contents of the |<text>|
% element:---
%
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{xml}
<text>
  <body>
    <p>On textual criticism, see 
    <ref target="#ReynoldsWilson1991">207--241</ref>.</p>
  </body>
  <back>
    <listBibl>
      <biblStruct type="book" xml:id="ReynoldsWilson1991">
        <monogr>
          <title level="m">Scribes and Scholars</title>
          <author>
            <forename>L. D.</forename>
            <surname>Reynolds</surname>
          </author>
          <author>
            <forename>N. G.</forename>
            <surname>Wilson</surname>
          </author>
          <edition>3</edition>
          <imprint>
            <pubPlace>Oxford</pubPlace>
            <publisher>Clarendon Press</publisher>
            <date>1991</date>
          </imprint>
        </monogr>
      </biblStruct>
    </listBibl>
  </back>
</text>
\end{minted}
% \iffalse
%</example>
% \fi
%
% At the time of writing, the following citation commands are
% converted into \texttt{TEI xml} by \pkg{ekdosis}:---
% \begin{enumerate}
% \item
% \cs{icite}\oarg{prenote}\oarg{postnote}\marg{key}\footnote{From the
% \pkg{icite} package. \cs{icite} can be used in place of almost any
% standard citation command. See \cite{icite}.}
% \item \cs{cite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{Cite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{cite*}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{parencite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{Parencite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{parencite*}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{footcite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{footcitetext}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{textcite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{Textcite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{smartcite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{Smartcite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{autocite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{Autocite}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{autocite*}\oarg{prenote}\oarg{postnote}\marg{key}
% \item \cs{Autocite*}\oarg{prenote}\oarg{postnote}\marg{key}
% \end{enumerate}
%
% The next release of \pkg{ekdosis} will include all citation commands
% with the exception of so-called \enquote{qualified citation lists}.
% 
% \section{Future Work}
% \label{sec:future-work}
% A short, un-commented list of what is planned in the versions of
% \pkg{ekdosis} to come follows:---
% \begin{enumerate}
% \item Very short-term (weeks):---
%   \begin{enumerate}
%   \item Text structure: milestone elements.
%   \item Marginal edition texts: It may happen that the marginalia of
%     manuscripts contain texts worth editing in addition to and along
%     the main text to which they are linked by reference signs.
%   \item Headers and footers: \cs{ekddiv} will provide top and bottom
%     marks to be used in headers and footers.
%   \end{enumerate}
% \item Short-term (months):---
%   \begin{enumerate}
%   \item Poetry: \pkg{ekdosis} is now able to load and use the
%     facilities provided by the \pkg{verse} package. Refined options
%     will be added, such as metrical analysis.  Arabic poetry through
%     the environments and commands provided by the \pkg{arabluatex}
%     package will also be supported. Other packages will also be
%     considered for inclusion, such as \pkg{poetry} or
%     \pkg{teubner}. In the end, \pkg{ekdosis} will provide a way for
%     the typesetting of poetry which will allow for more flexibility
%     and compatibility with \texttt{TEI xml}.
%   \item Correspondence and alignment, segmentation: The functions
%     are being tested at the time of writing and will be included in
%     \pkg{ekdosis}.
%   \end{enumerate}
% \item Medium-term: Indexing, commands and environments for specific
%   modules of the \texttt{TEI}.
% \end{enumerate}
% 
% \begin{comment}
%   \section{Correspondence and Alignment}
% \end{comment}
% \label{sec:correspondence-alignment}
%
% \label{ref:segmentation}
% 
% \section{GNU Free Documentation License}
% \label{sec:fdl}
% \textbf{Version 1.3, 3 November 2008}
% 
% \begin{center}
%   Version 1.3, 3 November 2008
%   
%   Copyright \copyright{} 2000, 2001, 2002, 2007, 2008 Free
%   Software Foundation, Inc.
%   
%   \bigskip
%   
%   \url{https://fsf.org/}
%   
%   \bigskip
%   
%   Everyone is permitted to copy and distribute verbatim copies
%   of this license document, but changing it is not allowed.
% \end{center}
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\bf\large Preamble}
% \end{center}
% 
% The purpose of this License is to make a manual, textbook, or other
% functional and useful document \enquote{free} in the sense of
% freedom: to assure everyone the effective freedom to copy and
% redistribute it, with or without modifying it, either commercially
% or noncommercially.  Secondarily, this License preserves for the
% author and publisher a way to get credit for their work, while not
% being considered responsible for modifications made by others.
% 
% This License is a kind of \enquote{copyleft}, which means that
% derivative works of the document must themselves be free in the same
% sense.  It complements the GNU General Public License, which is a
% copyleft license designed for free software.
% 
% We have designed this License in order to use it for manuals for
% free software, because free software needs free documentation: a
% free program should come with manuals providing the same freedoms
% that the software does.  But this License is not limited to software
% manuals; it can be used for any textual work, regardless of subject
% matter or whether it is published as a printed book.  We recommend
% this License principally for works whose purpose is instruction or
% reference.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 1. APPLICABILITY AND DEFINITIONS\par}
% \end{center}
% 
% This License applies to any manual or other work, in any medium,
% that contains a notice placed by the copyright holder saying it can
% be distributed under the terms of this License.  Such a notice
% grants a world-wide, royalty-free license, unlimited in duration, to
% use that work under the conditions stated herein.  The
% \enquote{\textbf{Document}}, below, refers to any such manual or
% work.  Any member of the public is a licensee, and is addressed as
% \enquote{\textbf{you}}.  You accept the license if you copy, modify
% or distribute the work in a way requiring permission under copyright
% law.
% 
% A \enquote{\textbf{Modified Version}} of the Document means any work
% containing the Document or a portion of it, either copied verbatim,
% or with modifications and/or translated into another language.
% 
% A \enquote{\textbf{Secondary Section}} is a named appendix or a
% front-matter section of the Document that deals exclusively with the
% relationship of the publishers or authors of the Document to the
% Document's overall subject (or to related matters) and contains
% nothing that could fall directly within that overall subject.
% (Thus, if the Document is in part a textbook of mathematics, a
% Secondary Section may not explain any mathematics.)  The
% relationship could be a matter of historical connection with the
% subject or with related matters, or of legal, commercial,
% philosophical, ethical or political position regarding them.
% 
% The \enquote{\textbf{Invariant Sections}} are certain Secondary
% Sections whose titles are designated, as being those of Invariant
% Sections, in the notice that says that the Document is released
% under this License.  If a section does not fit the above definition
% of Secondary then it is not allowed to be designated as Invariant.
% The Document may contain zero Invariant Sections.  If the Document
% does not identify any Invariant Sections then there are none.
% 
% The \enquote{\textbf{Cover Texts}} are certain short passages of
% text that are listed, as Front-Cover Texts or Back-Cover Texts, in
% the notice that says that the Document is released under this
% License.  A Front-Cover Text may be at most 5 words, and a
% Back-Cover Text may be at most 25 words.
% 
% A \enquote{\textbf{Transparent}} copy of the Document means a
% machine-readable copy, represented in a format whose specification
% is available to the general public, that is suitable for revising
% the document straightforwardly with generic text editors or (for
% images composed of pixels) generic paint programs or (for drawings)
% some widely available drawing editor, and that is suitable for input
% to text formatters or for automatic translation to a variety of
% formats suitable for input to text formatters.  A copy made in an
% otherwise Transparent file format whose markup, or absence of
% markup, has been arranged to thwart or discourage subsequent
% modification by readers is not Transparent.  An image format is not
% Transparent if used for any substantial amount of text.  A copy that
% is not \enquote{Transparent} is called \enquote{\textbf{Opaque}}.
% 
% Examples of suitable formats for Transparent copies include plain
% ASCII without markup, Texinfo input format, LaTeX input format, SGML
% or XML using a publicly available DTD, and standard-conforming
% simple HTML, PostScript or PDF designed for human modification.
% Examples of transparent image formats include PNG, XCF and JPG.
% Opaque formats include proprietary formats that can be read and
% edited only by proprietary word processors, SGML or XML for which
% the DTD and/or processing tools are not generally available, and the
% machine-generated HTML, PostScript or PDF produced by some word
% processors for output purposes only.
% 
% The \enquote{\textbf{Title Page}} means, for a printed book, the
% title page itself, plus such following pages as are needed to hold,
% legibly, the material this License requires to appear in the title
% page.  For works in formats which do not have any title page as
% such, \enquote{Title Page} means the text near the most prominent
% appearance of the work's title, preceding the beginning of the body
% of the text.
% 
% The \enquote{\textbf{publisher}} means any person or entity that
% distributes copies of the Document to the public.
% 
% A section \enquote{\textbf{Entitled XYZ}} means a named subunit of
% the Document whose title either is precisely XYZ or contains XYZ in
% parentheses following text that translates XYZ in another language.
% (Here XYZ stands for a specific section name mentioned below, such
% as \enquote{\textbf{Acknowledgements}},
% \enquote{\textbf{Dedications}}, \enquote{\textbf{Endorsements}}, or
% \enquote{\textbf{History}}.)  To \enquote{\textbf{Preserve the
% Title}} of such a section when you modify the Document means that it
% remains a section \enquote{Entitled XYZ} according to this
% definition.
% 
% The Document may include Warranty Disclaimers next to the notice
% which states that this License applies to the Document.  These
% Warranty Disclaimers are considered to be included by reference in
% this License, but only as regards disclaiming warranties: any other
% implication that these Warranty Disclaimers may have is void and has
% no effect on the meaning of this License.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 2. VERBATIM COPYING\par}
% \end{center}
% 
% You may copy and distribute the Document in any medium, either
% commercially or noncommercially, provided that this License, the
% copyright notices, and the license notice saying this License
% applies to the Document are reproduced in all copies, and that you
% add no other conditions whatsoever to those of this License.  You
% may not use technical measures to obstruct or control the reading or
% further copying of the copies you make or distribute.  However, you
% may accept compensation in exchange for copies.  If you distribute a
% large enough number of copies you must also follow the conditions in
% section~3.
% 
% You may also lend copies, under the same conditions stated above,
% and you may publicly display copies.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 3. COPYING IN QUANTITY\par}
% \end{center}
% 
% If you publish printed copies (or copies in media that commonly have
% printed covers) of the Document, numbering more than 100, and the
% Document's license notice requires Cover Texts, you must enclose the
% copies in covers that carry, clearly and legibly, all these Cover
% Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
% the back cover.  Both covers must also clearly and legibly identify
% you as the publisher of these copies.  The front cover must present
% the full title with all words of the title equally prominent and
% visible.  You may add other material on the covers in addition.
% Copying with changes limited to the covers, as long as they preserve
% the title of the Document and satisfy these conditions, can be
% treated as verbatim copying in other respects.
% 
% If the required texts for either cover are too voluminous to fit
% legibly, you should put the first ones listed (as many as fit
% reasonably) on the actual cover, and continue the rest onto adjacent
% pages.
% 
% If you publish or distribute Opaque copies of the Document numbering
% more than 100, you must either include a machine-readable
% Transparent copy along with each Opaque copy, or state in or with
% each Opaque copy a computer-network location from which the general
% network-using public has access to download using public-standard
% network protocols a complete Transparent copy of the Document, free
% of added material.  If you use the latter option, you must take
% reasonably prudent steps, when you begin distribution of Opaque
% copies in quantity, to ensure that this Transparent copy will remain
% thus accessible at the stated location until at least one year after
% the last time you distribute an Opaque copy (directly or through
% your agents or retailers) of that edition to the public.
% 
% It is requested, but not required, that you contact the authors of
% the Document well before redistributing any large number of copies,
% to give them a chance to provide you with an updated version of the
% Document.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 4. MODIFICATIONS\par}
% \end{center}
% 
% You may copy and distribute a Modified Version of the Document under
% the conditions of sections 2 and 3 above, provided that you release
% the Modified Version under precisely this License, with the Modified
% Version filling the role of the Document, thus licensing
% distribution and modification of the Modified Version to whoever
% possesses a copy of it.  In addition, you must do these things in
% the Modified Version:
% 
% \begin{itemize}
% \item[A.]  Use in the Title Page (and on the covers, if any) a title
%   distinct from that of the Document, and from those of previous
%   versions (which should, if there were any, be listed in the
%   History section of the Document).  You may use the same title as a
%   previous version if the original publisher of that version gives
%   permission.
%    
%  \item[B.]  List on the Title Page, as authors, one or more persons
%    or entities responsible for authorship of the modifications in
%    the Modified Version, together with at least five of the
%    principal authors of the Document (all of its principal authors,
%    if it has fewer than five), unless they release you from this
%    requirement.
%    
%  \item[C.]  State on the Title page the name of the publisher of the
%    Modified Version, as the publisher.
%    
%  \item[D.]  Preserve all the copyright notices of the Document.
%    
%  \item[E.]  Add an appropriate copyright notice for your
%    modifications adjacent to the other copyright notices.
%    
%  \item[F.]  Include, immediately after the copyright notices, a
%    license notice giving the public permission to use the Modified
%    Version under the terms of this License, in the form shown in the
%    Addendum below.
%    
%  \item[G.]  Preserve in that license notice the full lists of
%    Invariant Sections and required Cover Texts given in the
%    Document's license notice.
%    
%  \item[H.]  Include an unaltered copy of this License.
%    
%  \item[I.]  Preserve the section Entitled \enquote{History},
%    Preserve its Title, and add to it an item stating at least the
%    title, year, new authors, and publisher of the Modified Version
%    as given on the Title Page.  If there is no section Entitled
%    \enquote{History} in the Document, create one stating the title,
%    year, authors, and publisher of the Document as given on its
%    Title Page, then add an item describing the Modified Version as
%    stated in the previous sentence.
%    
%  \item[J.]  Preserve the network location, if any, given in the
%    Document for public access to a Transparent copy of the Document,
%    and likewise the network locations given in the Document for
%    previous versions it was based on.  These may be placed in the
%    \enquote{History} section.  You may omit a network location for a
%    work that was published at least four years before the Document
%    itself, or if the original publisher of the version it refers to
%    gives permission.
%    
%  \item[K.]  For any section Entitled \enquote{Acknowledgements} or
%    \enquote{Dedications}, Preserve the Title of the section, and
%    preserve in the section all the substance and tone of each of the
%    contributor acknowledgements and/or dedications given therein.
%    
%  \item[L.]  Preserve all the Invariant Sections of the Document,
%    unaltered in their text and in their titles.  Section numbers or
%    the equivalent are not considered part of the section titles.
%    
%  \item[M.]  Delete any section Entitled \enquote{Endorsements}.
%    Such a section may not be included in the Modified Version.
%    
%  \item[N.]  Do not retitle any existing section to be Entitled
%    \enquote{Endorsements} or to conflict in title with any Invariant
%    Section.
%    
%  \item[O.]  Preserve any Warranty Disclaimers.
% \end{itemize}
% 
% If the Modified Version includes new front-matter sections or
% appendices that qualify as Secondary Sections and contain no
% material copied from the Document, you may at your option designate
% some or all of these sections as invariant.  To do this, add their
% titles to the list of Invariant Sections in the Modified Version's
% license notice.  These titles must be distinct from any other
% section titles.
% 
% You may add a section Entitled \enquote{Endorsements}, provided it
% contains nothing but endorsements of your Modified Version by
% various parties---for example, statements of peer review or that the
% text has been approved by an organization as the authoritative
% definition of a standard.
% 
% You may add a passage of up to five words as a Front-Cover Text, and
% a passage of up to 25 words as a Back-Cover Text, to the end of the
% list of Cover Texts in the Modified Version.  Only one passage of
% Front-Cover Text and one of Back-Cover Text may be added by (or
% through arrangements made by) any one entity.  If the Document
% already includes a cover text for the same cover, previously added
% by you or by arrangement made by the same entity you are acting on
% behalf of, you may not add another; but you may replace the old one,
% on explicit permission from the previous publisher that added the
% old one.
% 
% The author(s) and publisher(s) of the Document do not by this
% License give permission to use their names for publicity for or to
% assert or imply endorsement of any Modified Version.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 5. COMBINING DOCUMENTS\par}
% \end{center}
% 
% You may combine the Document with other documents released under
% this License, under the terms defined in section~4 above for
% modified versions, provided that you include in the combination all
% of the Invariant Sections of all of the original documents,
% unmodified, and list them all as Invariant Sections of your combined
% work in its license notice, and that you preserve all their Warranty
% Disclaimers.
% 
% The combined work need only contain one copy of this License, and
% multiple identical Invariant Sections may be replaced with a single
% copy.  If there are multiple Invariant Sections with the same name
% but different contents, make the title of each such section unique
% by adding at the end of it, in parentheses, the name of the original
% author or publisher of that section if known, or else a unique
% number.  Make the same adjustment to the section titles in the list
% of Invariant Sections in the license notice of the combined work.
% 
% In the combination, you must combine any sections Entitled
% \enquote{History} in the various original documents, forming one
% section Entitled \enquote{History}; likewise combine any sections
% Entitled \enquote{Acknowledgements}, and any sections Entitled
% \enquote{Dedications}.  You must delete all sections Entitled
% \enquote{Endorsements}.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 6. COLLECTIONS OF DOCUMENTS\par}
% \end{center}
% 
% You may make a collection consisting of the Document and other
% documents released under this License, and replace the individual
% copies of this License in the various documents with a single copy
% that is included in the collection, provided that you follow the
% rules of this License for verbatim copying of each of the documents
% in all other respects.
% 
% You may extract a single document from such a collection, and
% distribute it individually under this License, provided you insert a
% copy of this License into the extracted document, and follow this
% License in all other respects regarding verbatim copying of that
% document.
% 
% \needspace{3\baselineskip}
% \begin{center}
% {\large\bf 7. AGGREGATION WITH INDEPENDENT WORKS\par}
% \end{center}
% 
% A compilation of the Document or its derivatives with other separate
% and independent documents or works, in or on a volume of a storage
% or distribution medium, is called an \enquote{aggregate} if the
% copyright resulting from the compilation is not used to limit the
% legal rights of the compilation's users beyond what the individual
% works permit.  When the Document is included in an aggregate, this
% License does not apply to the other works in the aggregate which are
% not themselves derivative works of the Document.
% 
% If the Cover Text requirement of section~3 is applicable to these
% copies of the Document, then if the Document is less than one half
% of the entire aggregate, the Document's Cover Texts may be placed on
% covers that bracket the Document within the aggregate, or the
% electronic equivalent of covers if the Document is in electronic
% form.  Otherwise they must appear on printed covers that bracket the
% whole aggregate.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 8. TRANSLATION\par}
% \end{center}
% 
% Translation is considered a kind of modification, so you may
% distribute translations of the Document under the terms of
% section~4.  Replacing Invariant Sections with translations requires
% special permission from their copyright holders, but you may include
% translations of some or all Invariant Sections in addition to the
% original versions of these Invariant Sections.  You may include a
% translation of this License, and all the license notices in the
% Document, and any Warranty Disclaimers, provided that you also
% include the original English version of this License and the
% original versions of those notices and disclaimers.  In case of a
% disagreement between the translation and the original version of
% this License or a notice or disclaimer, the original version will
% prevail.
% 
% If a section in the Document is Entitled \enquote{Acknowledgements},
% \enquote{Dedications}, or \enquote{History}, the requirement
% (section~4) to Preserve its Title (section~1) will typically require
% changing the actual title.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 9. TERMINATION\par}
% \end{center}
% 
% You may not copy, modify, sublicense, or distribute the Document
% except as expressly provided under this License.  Any attempt
% otherwise to copy, modify, sublicense, or distribute it is void, and
% will automatically terminate your rights under this License.
% 
% However, if you cease all violation of this License, then your
% license from a particular copyright holder is reinstated (a)
% provisionally, unless and until the copyright holder explicitly and
% finally terminates your license, and (b) permanently, if the
% copyright holder fails to notify you of the violation by some
% reasonable means prior to 60 days after the cessation.
% 
% Moreover, your license from a particular copyright holder is
% reinstated permanently if the copyright holder notifies you of the
% violation by some reasonable means, this is the first time you have
% received notice of violation of this License (for any work) from
% that copyright holder, and you cure the violation prior to 30 days
% after your receipt of the notice.
% 
% Termination of your rights under this section does not terminate the
% licenses of parties who have received copies or rights from you
% under this License.  If your rights have been terminated and not
% permanently reinstated, receipt of a copy of some or all of the same
% material does not give you any rights to use it.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 10. FUTURE REVISIONS OF THIS LICENSE\par}
% \end{center}
% 
% The Free Software Foundation may publish new, revised versions of
% the GNU Free Documentation License from time to time.  Such new
% versions will be similar in spirit to the present version, but may
% differ in detail to address new problems or concerns.  See
% \url{https://www.gnu.org/licenses/}.
% 
% Each version of the License is given a distinguishing version
% number.  If the Document specifies that a particular numbered
% version of this License \enquote{or any later version} applies to
% it, you have the option of following the terms and conditions either
% of that specified version or of any later version that has been
% published (not as a draft) by the Free Software Foundation.  If the
% Document does not specify a version number of this License, you may
% choose any version ever published (not as a draft) by the Free
% Software Foundation.  If the Document specifies that a proxy can
% decide which future versions of this License can be used, that
% proxy's public statement of acceptance of a version permanently
% authorizes you to choose that version for the Document.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf 11. RELICENSING\par}
% \end{center}
% 
% \enquote{Massive Multiauthor Collaboration Site} (or \enquote{MMC
% Site}) means any World Wide Web server that publishes copyrightable
% works and also provides prominent facilities for anybody to edit
% those works.  A public wiki that anybody can edit is an example of
% such a server.  A \enquote{Massive Multiauthor Collaboration} (or
% \enquote{MMC}) contained in the site means any set of copyrightable
% works thus published on the MMC site.
% 
% \enquote{CC-BY-SA} means the Creative Commons Attribution-Share
% Alike 3.0 license published by Creative Commons Corporation, a
% not-for-profit corporation with a principal place of business in San
% Francisco, California, as well as future copyleft versions of that
% license published by that same organization.
% 
% \enquote{Incorporate} means to publish or republish a Document, in
% whole or in part, as part of another Document.
% 
% An MMC is \enquote{eligible for relicensing} if it is licensed under
% this License, and if all works that were first published under this
% License somewhere other than this MMC, and subsequently incorporated
% in whole or in part into the MMC, (1) had no cover texts or
% invariant sections, and (2) were thus incorporated prior to November
% 1, 2008.
% 
% The operator of an MMC Site may republish an MMC contained in the
% site under CC-BY-SA on the same site at any time before August 1,
% 2009, provided the MMC is eligible for relicensing.
% 
% \needspace{3\baselineskip}
% \begin{center}
%   {\large\bf ADDENDUM: How to use this License for your documents\par}
% \end{center}
% 
% To use this License in a document you have written, include a copy
% of the License in the document and put the following copyright and
% license notices just after the title page:
% 
% \bigskip
% \begin{quote}
%   Copyright \copyright{} YEAR YOUR NAME.  Permission is granted to
%   copy, distribute and/or modify this document under the terms of
%   the GNU Free Documentation License, Version 1.3 or any later
%   version published by the Free Software Foundation; with no
%   Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
%   A copy of the license is included in the section entitled
%   \enquote{GNU Free Documentation License}.
% \end{quote}
% \bigskip
%     
% If you have Invariant Sections, Front-Cover Texts and Back-Cover
% Texts, replace the \enquote{with \dots\ Texts.}\ line with this:
% 
% \bigskip
% \begin{quote}
%   with the Invariant Sections being LIST THEIR TITLES, with the
%   Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
% \end{quote}
% \bigskip
%     
% If you have Invariant Sections without Cover Texts, or some other
% combination of the three, merge those two alternatives to suit the
% situation.
% 
% If your document contains nontrivial examples of program code, we
% recommend releasing these examples in parallel under your choice of
% free software license, such as the GNU General Public License,
% to permit their use in free software.
%
% \section{References}
% \label{sec:references}
% \printbibliography[heading=none]
%
% \section{Sample: C. J. Caesar, \emph{Gallic War},
%           VI, XIII.1}
% \label{sec:caesar-gw-6-1-13}
% \subsection{\texttt{.tex} Source File}
% \label{sec:caesar-gw-tex}
% \inputminted[linenos=true]{latex}{samples/Caesar_BG-6-13-1.tex}
% \subsection{\texttt{TEI xml} Output}
% \label{sec:caesar-gw-tei}
% \inputminted[linenos=true]{xml}{samples/Caesar_BG-6-13-1-tei.xml}
% 
% \section{Arabic Sample File}
% \label{sec:arabic-sample}
% |arabic-sample.tex|:---
% \iffalse
%<*example>
% \fi
\begin{minted}[linenos=false]{latex}
% Instructions:
% 1. Compile this file three times.
%    - Open arabic-sample.pdf and arabic-sample-tei.xml and see the
%      result.
% 2. Compile arabic-sample_out.tex three times.
%    - Open arabic-sample_out.pdf and arabic-sample-out-tei.xml and
%      see the result.
%
\documentclass{article}

% The following three lines are only needed by the
% 'arabic-sample_out.tex' that arabluatex is instructed to produce:
\usepackage{babel}
\babelprovide[onchar=fonts]{arabic}
\babelfont[*arabic]{rm}{Amiri}

% instruct ekdosis to output TEI xml (arabic-sample-tei.xml):
\usepackage[teiexport=tidy]{ekdosis}

% instruct arabluatex to output sample-arabic_out.tex with Unicode
% Arabic strings in place of arabtex ASCII scheme:
\usepackage[fullvoc,export]{arabluatex}

\begin{document}

\begin{arabexport} % export arabtex strings to Unicode Arabic
  \begin{ekdosis}
    \begin{arab}
      'inna 'abI kAna mina 
      \app{
        \lem{'l-muqAtilaTi}
        \rdg{'l-muqAtilIna}
      }
      wa-kAnat 'ummI min `u.zamA'i buyUti 'l-zamAzimaTi.
    \end{arab}
  \end{ekdosis}
\end{arabexport}
\end{document}
\end{minted}
% \iffalse
%</example>
% \fi
%
% \StopEventually{}
% 
% \section{Implementation}
% \label{sec:implementation}
% 
% \iffalse
%<*package>
% \fi
% 
% \pkg{ekdosis} relies on Lua functions and tables. Read the
% |.lua| files that accompany \pkg{ekdosis} for more
% information.
%    \begin{macrocode}
\RequirePackage{iftex}
%    \end{macrocode}
% Of course, \pkg{ekdosis} requires {\LuaLaTeX}. Issue an error
% if the document is processed with another engine.
%    \begin{macrocode}
\RequireLuaTeX
%    \end{macrocode}
% Set global options:---
%    \begin{macrocode}
\RequirePackage{expkv-opt}
\RequirePackage{expkv-def}
\newif\if@pkg@float
\newif\if@pkg@footins
\newif\if@pkg@ekddivs
\newif\if@parnotesroman
\newif\if@pkg@parnotes
\newif\iftei@export
\newif\if@pkg@poetry@verse
\ekvdefinekeys{ekdosis}{
  choice layout = {float = {\@pkg@floattrue},
    footins = {\@pkg@floatfalse\@pkg@footinstrue}},
  initial layout = float,
  unknown-choice layout = \PackageError{ekdosis}{unknown
    layout=#1}{`layout' must be either `float' or `footins'.},
  choice divs = {ekdosis = {\@pkg@ekddivstrue},
    latex = {\@pkg@ekddivsfalse
      \AtBeginDocument{\luadirect{ekdosis.setekddivsfalse()}}}},
  initial divs = ekdosis,
  unknown-choice divs = \PackageError{ekdosis}{unknown divs=#1}{`divs'
    must be either `ekdosis' or `latex'.},
  choice poetry = {verse = {\@pkg@poetry@versetrue}},
  unknown-choice poetry = \PackageError{ekdosis}{unknown
    poetry=#1}{`poetry' must be `verse' for now.},
  choice parnotes = {false = {},
    true = {\@pkg@parnotestrue},
    roman = {\@pkg@parnotestrue\@parnotesromantrue}},
  default parnotes = true,
  unknown-choice parnotes = \PackageError{ekdosis}{unknown
    parnotes=#1}{`parnotes' must be either `true', or `false' or
    `roman'.},
  choice teiexport = {false = {},
    true = {\tei@exporttrue
      \AtBeginDocument{\luadirect{ekdosis.openteistream()}}%
      \AtEndDocument{\luadirect{ekdosis.closeteistream()}}},
    tidy = {\tei@exporttrue
      \AtBeginDocument{\luadirect{ekdosis.openteistream()}}%
      \AtEndDocument{\luadirect{ekdosis.closeteistream("tidy")}}}},
  default teiexport = true,
  unknown-choice teiexport = \PackageError{ekdosis}{unknown
    teiexport=#1}{`teiexport' must be either `true', `false' or
    `tidy'.}
}
\ekvoProcessLocalOptions{ekdosis}
\newif\ifekd@memoir@loaded
\@ifclassloaded{memoir}{%
  \ekd@memoir@loadedtrue\@pkg@poetry@versetrue}{}
%    \end{macrocode}
% \paragraph{Required Packages} \label{ref:ekdrequirements} In
% addition to \pkg{iftex}, \pkg{expkv-opt} and \pkg{expkv-def}, a list
% of the packages that are required by \pkg{ekdosis} follows:---
%    \begin{macrocode}
% \RequirePackage{iftex} % already loaded above
% \RequirePackage{expkv-opt} % already loaded above
% \RequirePackage{expkv-def} % already loaded above
\RequirePackage{luacode}
\RequirePackage{paracol}
\RequirePackage{etoolbox}
\RequirePackage{lineno}
\if@pkg@float
  \RequirePackage{trivfloat}
\fi
\RequirePackage{refcount}
\RequirePackage{zref-user}
\RequirePackage{zref-abspage}
\RequirePackage{ltxcmds}
\RequirePackage{pdftexcmds}
\RequirePackage{ifoddpage}
\if@pkg@poetry@verse
  \RequirePackage{verse}
\fi
\if@pkg@parnotes
  \RequirePackage{parnotes}
\fi
%    \end{macrocode}
% \paragraph{Lua} Here begins the real work: load |ekdosis.lua|:---
%    \begin{macrocode}
\luadirect{dofile(kpse.find_file("ekdosis.lua"))}
%    \end{macrocode}
%    \begin{macrocode}
\AtEndDocument{
  \luadirect{ekdosis.closestream()}
}
%    \end{macrocode}
% \begin{macro}{\SetHooks} \cs{SetHooks} is used to set
%   hooks meant to be shared by all declared apparatuses, such as the
%   font size, the format of numerals, \emph{\&c.} This command can be
%   used in the preamble or at any point of the document.
%   \changes{v1.2}{2021/04/02}{general hooks: new option
%   \texttt{lemmastyle}}
%   \changes{v1.2}{2021/04/02}{general hooks: new option
%   \texttt{readingstyle}}
%    \begin{macrocode}
\ekvdefinekeys{ekd@hooks}{
  store appfontsize = \ekd@appfontsize,
  store refnumstyle = \ekd@refnumstyle,
  store postrefnum = \ekd@postrefnum,
  store lemmastyle = \ekd@lemmastyle,
  store readingstyle = \ekd@readingstyle,
  code initialrule = \def\ekd@initial@rule{#1\NLS},
  default initialrule = \rule{0.4\columnwidth}{0.4pt},
  noval noinitialrule = \undef\ekd@initial@rule,
  initial appfontsize = \footnotesize,
  initial refnumstyle = \bfseries,
  initial postrefnum = ~,
  initial lemmastyle = {},
  initial readingstyle = {}
}
\NewDocumentCommand{\SetHooks}{m}{\ekvset{ekd@hooks}{#1}}
%    \end{macrocode}
% \end{macro}
% Build and process the list of witnesses and hands:---
%    \begin{macrocode}
\ekvdefinekeys{ekd@witness}{
  store settlement = \settlement@value,
  store institution = \institution@value,
  store repository = \repository@value,
  store collection = \collection@value,
  store idno = \idno@value,
  store msName = \msName@value,
  store origDate = \origDate@value,
  store locus = \locus@value
}
%    \end{macrocode}
% \begin{macro}{\DeclareWitness} \cs{DeclareWitness} is a
%   preamble-only command. It takes three mandatory arguments and one
%   optional argument. It is meant to collect data related to
%   witnesses to be used in the edition text. Data are stored in |Lua|
%   tables and are used to encode the |<listWit>| part of the |TEI|
%   header as well as the Conspectus Siglorum in the edition in print.
%    \begin{macrocode}
\NewDocumentCommand{\DeclareWitness}{m m m O{}}{%
  \bgroup
  \ekvset{ekd@witness}{#4}
    \luadirect{ekdosis.newwitness(
      \luastringN{#1},
      \luastringN{#2},
      \luastringN{#3},
      \luastringO{\settlement@value},
      \luastringO{\institution@value},
      \luastringO{\repository@value},
      \luastringO{\collection@value},
      \luastringO{\idno@value},
      \luastringO{\msName@value},
      \luastringO{\origDate@value},
      \luastringO{\locus@value})}
    \egroup
  }
\@onlypreamble\DeclareWitness
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\DeclareHand} As \cs{DeclareWitness}, \cs{DeclareHand}
% is a preamble-only command meant to collect data and store them in
% |Lua| tables. It takes three mandatory arguments and one optional
% argument. The second argument is used to connect the hand to a
% declared witness it is related to. Then the table in which this
% witness is recorded can be fed with new data.
%    \begin{macrocode}
\NewDocumentCommand{\DeclareHand}{m m m +O{}}{
  \luadirect{ekdosis.newhand(\luastringN{#1},
    \luastringN{#2},
    \luastringN{#3},
    \luastringN{#4})}
}
\@onlypreamble\DeclareHand
%    \end{macrocode}
% \end{macro}
% Build and process the list of scholars:---
%    \begin{macrocode}
\ekvdefinekeys{ekd@scholar}{
  store rawname = \rawname@value,
  store forename = \forename@value,
  store surname = \surname@value,
  store addname = \addname@value,
  store note = \note@value
}
%    \end{macrocode}
% \begin{macro}{\DeclareScholar}
% \changes{v1.1}{2020/11/04}{nows builds a list of persons}
% \cs{DeclareScholar} is used to build a list of persons within the
% |<listPerson>| element. It takes two mandatory arguments to specify
% consecutively a unique identifier and the rendition to be used in
% the apparatus criticus in print, and one optional argument used to
% collect the name parts components and further items of information
% from |key-value| \enquote*{named} arguments.
%    \begin{macrocode}
\NewDocumentCommand{\DeclareScholar}{m m O{}}{%
  \bgroup
  \ekvset{ekd@scholar}{#3}
    \luadirect{ekdosis.newscholar(
      \luastringN{#1},
      \luastringN{#2},
      \luastringO{\rawname@value},
      \luastringO{\forename@value},
      \luastringO{\surname@value},
      \luastringO{\addname@value},
      \luastringO{\note@value})}
    \egroup
  }
\@onlypreamble\DeclareScholar
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\DeclareSource}
% \changes{v1.1}{2020/11/04}{new command added}There is also a table in
% which are collected data related to sources to be used in the
% apparatus criticus. \cs{DeclareSource} is a preamble-only 
% command and takes two mandatory arguments: a unique id and a
% shorthand (preferably a Bib\hologo{(La)TeX} label) to be used in
% the apparatus criticus which can be extracted from a bibliographic
% database.
%    \begin{macrocode}
\NewDocumentCommand{\DeclareSource}{m m}{
  \luadirect{ekdosis.newsource(\luastringN{#1},
    \luastringN{#2})}
}
\@onlypreamble\DeclareSource
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\DeclareShorthand} \cs{DeclareShorthand} is a
%   preamble-only command that can be used to record manuscript
%   families or any kind of shorthand to be used to refer to
%   previously declared ids, for example the shorthand |codd| can be
%   used to point to all declared witnesses. This command takes three
%   mandatory arguments: a unique id, its rendition in print and a
%   csv-list of previously declared ids.
%    \begin{macrocode}
\NewDocumentCommand{\DeclareShorthand}{m m m}{
  \luadirect{ekdosis.newshorthand(\luastringN{#1},
    \luastringN{#2},
    \luastringN{#3})}
}
\@onlypreamble\DeclareShorthand
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\getsiglum}
% \cs{getsiglum}\marg{csv list} takes a comma-separated list of
% declared ids by means of \cs{DeclareWitness}, \cs{DeclareHand},
% \cs{DeclareShorthand} or \cs{DeclareSource} and returns their
% respective renditions.
%    \begin{macrocode}
\NewDocumentCommand{\getsiglum}{m}{%
  \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\SigLine}
% \cs{Sigline}\marg{unique id} takes the unique id of any declared
% witness by means of \cs{DeclareWitness} as argument and returns a
% line ready to be inserted in a table set to print a Conspectus
% Siglorum. \cs{SigLine} returns three fields separated by the symbol
% |&| that is used in tables as follows: the siglum referring to the
% witness, the contents of the |description| field and the contents of
% the optional |origDate| field.
%    \begin{macrocode}
\NewDocumentCommand{\SigLine}{m}{%
  \luadirect{tex.sprint(ekdosis.basic_cs(\luastringN{#1}))}
}
%    \end{macrocode}
% \end{macro}
% \paragraph{\TeX\ to \texttt{TEI xml}}
% Here follow the |key-value| options to be used by \cs{SetTEIxmlExport}
% below:---
%    \begin{macrocode}
\ekvdefinekeys{tei@settings}{
  choice autopar = {true = \luadirect{ekdosis.setteiautopar("yes")},
    false = {\luadirect{ekdosis.setteiautopar("no")}}},
  initial autopar = true,
  unknown-choice autopar = \PackageError{ekdosis}{unknown
    autopar=#1}{`autopar' must be either `true' or `false'.}
}
%    \end{macrocode}
% \begin{macro}{\SetTEIxmlExport}
% \cs{SetTEIxmlExport} collects the settings to be applied
% to \texttt{TEI xml} export. For now, there is only one option. This
% command can be used at any point of the document, except inside
% environments meant to receive an apparatus criticus.
%    \begin{macrocode}
\NewDocumentCommand{\SetTEIxmlExport}{m}{
  \unless\ifekd@state\ekvset{tei@settings}{#1}\fi
}
%    \end{macrocode}
% \end{macro}
% The following three commands can be used to instruct \pkg{ekdosis}
% how to convert unknown or unusual \hologo{(La)TeX} commands into
% \texttt{TEI xml} equivalents.
% \begin{macro}{\TeXtoTEI}
% \cs{TeXtoTEI}\marg{csname}\marg{TEI element}\oarg{TEI attribute(s)}
% takes two mandatory arguments and one optional argument, namely: the
% control sequence name to be converted, the \texttt{TEI} element it
% is to be converted into and any additional \texttt{xml} attributes
% to be appended to the opening \texttt{TEI} element:---
%    \begin{macrocode}
\NewDocumentCommand{\TeXtoTEI}{m m O{}}{%
  \luadirect{ekdosis.newcmdtotag(\luastringN{#1},
    \luastringN{#2},
    \luastringN{#3})}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\teidirect}
% \changes{v1.3}{2021/05/07}{direct insertion of elements in the
% \texttt{TEI xml} file}
% \cs{teidirect}\oarg{xml attributes}\marg{xml element}\marg{code}
% does nothing in \LaTeX. Its only use is to insert elements in the
% \texttt{TEI xml} output file.
%    \begin{macrocode}
\NewDocumentCommand{\teidirect}{O{}mm}{\ignorespaces}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\EnvtoTEI}
% \begin{macro}{\EnvtoTEI*}
% \cs{EnvtoTEI}\meta{*}\marg{env name}\marg{TEI element}\oarg{TEI
% attribute(s)} instructs how to convert \LaTeX{} environments into
% \texttt{TEI xml} equivalents. It takes two mandatory arguments and
% one optional argument, namely the name of the \LaTeX{} environment
% to be converted, the \texttt{TEI} element it is to be converted into
% and any additional attributes to be appended to the \texttt{TEI}
% opening element. \cs{EnvtoTEI*} is restricted to \texttt{TEI}
% elements that must never appear within |<p>| elements, such as
% |<div>|, |<lg>| and the like.
%    \begin{macrocode}
\NewDocumentCommand{\EnvtoTEI}{s m m O{}}{%
  \IfBooleanTF{#1}{%
  \luadirect{ekdosis.newenvtotag(\luastringN{#2},
    \luastringN{#3},
    \luastringN{#4},
    "yes")}
  }{%
  \luadirect{ekdosis.newenvtotag(\luastringN{#2},
    \luastringN{#3},
    \luastringN{#4})}
  }
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\TeXtoTEIPat}
% \changes{v1.1}{2020/11/04}{renamed, formerly \cs{TeXtoTEIPatt}}
% Finally, the more flexible\---and more delicate to
% handle\---\cs{TeXtoTEIPat}\marg{\TeX\
% pattern}\allowbreak\marg{\texttt{TEI} pattern} uses pattern matching
% to instruct \pkg{ekdosis} how to convert \hologo{(La)TeX} commands
% into \texttt{TEI} equivalents.
%    \begin{macrocode}
\NewDocumentCommand{\TeXtoTEIPat}{m m}{%
  \luadirect{ekdosis.newpatttotag(\luastringN{#1}, \luastringN{#2})}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\SetTEIFilename} \cs{SetTEIFilename}\marg{basename} is
%   a preamble-only command. It is used to set the base name of the
%   |TEI xml| output file, to which the suffix |.xml| is appended. By
%   default, the base name is |\jobname-tei|:---
%    \begin{macrocode}
\NewDocumentCommand{\SetTEIFileName}{m}{
  \luadirect{ekdosis.setteifilename(\luastringN{#1})}
}
\@onlypreamble\SetTEIFileName
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\AddxmlBibResource} This is a preamble-only command.
%   If a base name (either suffixed with |.xml| or not) for a
%   \texttt{TEI xml}-compliant bibliographical database file be
%   provided with \cs{AddxmlBibResource}\marg{basename or name.xml},
%   \pkg{ekdosis} will use it and insert formatted data in the back
%   matter section of its own \texttt{TEI xml} output file, as
%   |<biblStruct>| elements within a |<listBibl>| section.
%    \begin{macrocode}
\NewDocumentCommand{\AddxmlBibResource}{m}{
  \luadirect{ekdosis.addxmlbibresource(\luastringN{#1})}
}
\@onlypreamble\AddxmlBibResource
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ekd@test@lang}
% \cs{ekd@test@lang} is used internally by \pkg{ekdosis}. This command
% returns \cs{ekd@lang@pkgtrue} if either \pkg{babel} or
% \pkg{polyglossia} be used so that \cs{languagename} can be inserted
% when and where needed in the apparatus criticus.
%    \begin{macrocode}
\newif\ifekd@lang@pkg
\NewDocumentCommand{\ekd@test@lang}{}{%
  \ltx@ifpackageloaded{babel}{\ekd@lang@pkgtrue}{}%
  \ltx@ifpackageloaded{polyglossia}{\ekd@lang@pkgtrue}{}%
}
%    \end{macrocode}
% \end{macro}
% \paragraph{Multiple-layer apparatuses}
% \pkg{ekdosis} must know if an entry is to be processed in a single-
% or multiple-layer context:---
%    \begin{macrocode}
\newif\ifekd@mapps
%    \end{macrocode}
% Now the key-value options can be defined:---
%    \begin{macrocode}
\ekvdefinekeys{ekd@newapp}{
  choice direction = {LR = \def\direction@val{LR},
                      RL = \def\direction@val{RL}},
  unknown-choice direction = \PackageError{ekdosis}{unknown
    direction=#1}{`direction' must be either `LR' or `RL'.},
  store rule = \rule@val,
  nmeta norule = {rule=none},
  code delim = \def\delim@val{\unexpanded{#1}},
  store sep = \sep@val,
  store bhook = \bhook@val,
  store ehook = \ehook@val,
  store maxentries = \limit@val,
  store lang = \lang@val,
  store notelang = \notelang@val,
  initial direction = LR,
  initial delim = {},
  initial ehook = {\csname ekd@end@apparatus\endcsname}
}
%    \end{macrocode}
% \begin{macro}{\DeclareApparatus}
% \cs{DeclareApparatus}\marg{apparatus name}\oarg{options} is a
% preamble-only command. As a mandatory argument, it takes the name of
% the new layer of notes to be inserted in the apparatus block. Then,
% the following seven key-value options can be used to lay out the
% layer: \verb+direction=LR|RL+, |rule|, |delim| (the delimiter between
% entries), |sep| (the separator between lemma part and readings or
% notes), |bhook| (\LaTeX{} code inserted as the layer begins),
% |ehook| (\LaTeX{} code inserted as the layer ends), |maxentries|
% (if set and |maxentries >= 10|, the number of entries at which a
% \cs{pagebreak} is issued):---
%    \begin{macrocode}
\NewDocumentCommand{\DeclareApparatus}{m O{}}{
  \newbool{subsq@unit@#1}
  \booltrue{subsq@unit@#1}
  \unless\ifekd@mapps\global\ekd@mappstrue\fi
  \bgroup
  \ekvset{ekd@newapp}{#2}
  \luadirect{ekdosis.newapparatus(
    \luastringN{#1},
    \luastring{\direction@val},
    \luastringO{\rule@val},
    \luastringO{\delim@val},
    \luastringO{\sep@val},
    \luastringO{\bhook@val},
    \luastringO{\ehook@val},
    \luastringO{\limit@val},
    \luastringO{\lang@val},
    \luastringO{\notelang@val}
    )}
  \egroup
}
\@onlypreamble\DeclareApparatus
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\addentries}
% \changes{v1.1}{2020/11/04}{modifies the number of accepted entries
% on the current page.}
% If |maxentries| be set for a given layer of critical notes,
% \cs{addentries}\oarg{layer}\marg{n}, where \meta{n} is an integer,
% can be used to add \meta{n} to\---or remove it from if \meta{n} be
% negative\---the number of accepted entries on the current
% page. \cs{addentries} operates on the default layer of notes, but
% any other declared layer can be specified in the optional argument
% of the command.
%    \begin{macrocode}
\NewDocumentCommand{\addentries}{O{\ekdan@type} m}{%
  \luadirect{ekdosis.addto_bagunits(\luastringO{#1}, \luastringN{#2})}%
  \ignorespaces
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ekdpb}
% \changes{v1.2}{2021/04/02}{conditional page breaks}
% \cs{ekdpk}\oarg{page no}\marg{line no} is used to insert conditional
% page breaks by specifying that the page break should occur only on a
% given line and optionally a given page. If the specified conditions
% are met then this command triggers \cs{pagebreak}.
%    \begin{macrocode}
\NewDocumentCommand{\ekdpb}{o m}{%
  \def\@tmpoarg{#1}%
  \def\@tmpmarg{#2}%
  \luadirect{ekdosis.dolnlab(\luastringN{#2})}%
  \linelabel{\luadirect{tex.sprint(ekdosis.getlnlab())}}%
  \def\tmp@ln{%
    \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}}}%
  \def\tmp@pg{%
    \getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}}}%
  \IfNoValueTF{#1}
  {\ifnum
    \pdf@strcmp{\@tmpmarg}{\tmp@ln} = 0
    \pagebreak
    \fi}
  {\ifnum
    \pdf@strcmp{\@tmpoarg}{\tmp@pg} = 0
    \ifnum
    \pdf@strcmp{\@tmpmarg}{\tmp@ln} = 0
    \pagebreak
    \fi
    \fi
  }\ignorespaces
}
%    \end{macrocode}
% \end{macro}
% Apparatus-related settings and functions. Some booleans to check if
% an apparatus should be inserted and what is the current environment.
%    \begin{macrocode}
\newbool{do@app}
\newif\ifekd@state
\newif\ifekd@isinapp
\newif\ifekd@isinlem
\newif\ifekd@appinapp
%    \end{macrocode}
% The next boolean is shared with \pkg{arabluatex}. \cs{LRnum} is used
% internally to ensure that numerals referring to line spans are
% displayed in the right order.
%    \begin{macrocode}
\providebool{al@rlmode}
\@ifpackageloaded{arabluatex}{}{%
  \def\setRL{\booltrue{al@rlmode}\pardir TRT\textdir TRT}
  \def\setLR{\boolfalse{al@rlmode}\pardir TLT \textdir TLT}
}
\protected\def\LRnum#1{\bgroup\textdir TLT#1\egroup}
%    \end{macrocode}
% Set counter referring to line numbers and make it global. 
%    \begin{macrocode}
\newcounter{ekd@lab}
\globalcounter{ekd@lab}
%    \end{macrocode}
% This command inserts words in the apparatus criticus without
% checking if both |ekd@isinapp| and |ekd@state| are set to |true|.
%    \begin{macrocode}
\NewDocumentCommand{\unconditional@appin}{o m}{%
  \IfNoValueTF{#1}
  {\luadirect{ekdosis.appin(\luastringO{#2})}}
  {\luadirect{ekdosis.appin(\luastringO{#2}, \luastringO{#1})}}%
}
%    \end{macrocode}
% \begin{macro}{\blfootnote} \cs{blfootnote}\marg{footnote} is used
% internally to insert the apparatus in the footnote block should the
% global optional argument |layout| be set to |footins|. Therefore, it
% is not documented.
%    \begin{macrocode}
\def\blfootnote{\gdef\@thefnmark{\relax}\@footnotetext}
 % \def\blfootnote{\gdef\@thefnmark{}\@blfootnotetext}
\long\def\@blfootnotetext#1{\insert\footins{%
    \reset@font\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
    \protected@edef\@currentlabel{%
       \csname p@footnote\endcsname\@thefnmark
    }%
    \color@begingroup
      \@makeblfntext{%
        \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
    \color@endgroup}}%
\newcommand\@makeblfntext[1]{%
    \parindent 1em%
    \noindent
    \hb@xt@0em{\hss\@makefnmark}#1}
%    \end{macrocode}
% \end{macro}
% \paragraph{Single-layer apparatus} The following commands are for
% general settings. All of them can be used in the preamble or at any
% point of the document.  The keys to be used follow:---
%    \begin{macrocode}
\newif\ifrtl@app
\edef\ekdsep{] }
\ekvdefinekeys{default@app}{
  choice direction = {LR = \rtl@appfalse,
    RL = \rtl@apptrue},
  unknown-choice direction = \PackageError{ekdosis}{unknown
    direction=#1}{`direction' must be either `LR' or `RL'.},
  code sep = \edef\ekdsep{#1},
  store bhook = \ekd@begin@apparatus,
  initial bhook = {},
  store ehook = \ekd@end@apparatus,
  initial ehook = {},
  store delim = \ekd@unit@delim,
  initial delim = {},
  store rule = \ekd@default@rule,
  initial rule = \rule{0.4\columnwidth}{0.4pt},
  noval norule = \def\ekd@default@rule{\mbox{}},
  store lang = \ekd@singleapp@lang,
  initial lang = \ltx@ifpackageloaded{babel}{\languagename}{}%
                 \ltx@ifpackageloaded{polyglossia}{\languagename}{},
  store notelang = \ekd@singleapp@note@lang,
  initial notelang = \ltx@ifpackageloaded{babel}{\languagename}{}%
                 \ltx@ifpackageloaded{polyglossia}{\languagename}{}
}
%    \end{macrocode}
% \begin{macro}{\SetApparatus}
% All settings can also be defined as |key-value| options within the
% argument of \cs{SetApparatus}:---
%    \begin{macrocode}
\NewDocumentCommand{\SetApparatus}{m}{
  \ekvset{default@app}{#1}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\SetLTRapp}
% \begin{macro}{\SetRTLapp}
% \cs{SetLTRapp} and \cs{SetRTLapp} are two argument-less commands to
% set the direction of single-layer apparatus criticus, either LTR or
% RTL:---
%    \begin{macrocode}
\NewDocumentCommand{\SetRTLapp}{}{\rtl@apptrue}
\NewDocumentCommand{\SetLTRapp}{}{\rtl@appfalse}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\SetSeparator}
% \cs{SetSeparator}\marg{separator} allows to change the separator
% between lemma texts and variant readings, which is by default
% a closing square bracket followed by a space (\verb*+] +):---
%    \begin{macrocode}
\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\SetBeginApparatus}
%   \cs{SetBeginApparatus}\marg{characters} can be used to append
%   characters at the beginning of the apparatus block. By default,
%   nothing is appended:---
%    \begin{macrocode}
\NewDocumentCommand{\SetBeginApparatus}{m}{\edef\ekd@begin@apparatus{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\SetEndApparatus}
% \cs{SetEndApparatus}\marg{characters} can be used to append
% characters at the end of the apparatus block\---such as a period,
% as it is customary in some editions. By default, nothing is
% appended:---
%    \begin{macrocode}
\NewDocumentCommand{\SetEndApparatus}{m}{\edef\ekd@end@apparatus{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\SetUnitDelimiter}
% \cs{SetUnitDelimiter}\marg{delimiter} can be used to set the
% delimiter between entries in the apparatus criticus. By default,
% there is no delimiter except a simple space. \cs{SetUnitDelimiter}
% can be used to insert a broad space (with |\hskip| for instance, as
% in the OCT series) or the divider-sign (‖, as in the Budé series):---
%    \begin{macrocode}
\NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\SetApparatusLanguage}
% \changes{v1.2}{2021/04/02}{defines an alternate language to be
% applied in apparatus entries}
% \cs{SetApparatusLang}\marg{languagename} can be used when
% it is needed to apply in the apparatus criticus a language
% different from the one that is selected in the edition text.
%    \begin{macrocode}
\NewDocumentCommand{\SetApparatusLanguage}{m}{%
  \def\ekd@singleapp@lang{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\SetApparatusNoteLanguage}
% \changes{v1.3}{2021/05/07}{defines an alternate language to be
% applied in note apparatus entries}
% \cs{SetApparatusNoteLang}\marg{languagename} can be used when
% it is needed to apply in entries introduced by the \cs{note} command
% a language different from the one that is selected in the edition
% text.
%    \begin{macrocode}
\NewDocumentCommand{\SetApparatusNoteLanguage}{m}{%
  \def\ekd@singleapp@note@lang{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\footnoteruletrue}
% \begin{macro}{\footnoterulefalse}
% As \pkg{ekdosis} takes care of drawing a rule separating the main
% text from the apparatus block as well as layers of notes from each
% other inside this block, it may not be desirable to have
% the standard \LaTeX{} \enquote{footnoterule} printed on every page
% of the edition text. \cs{footnoterulefalse} removes it while
% \cs{footnoteruletrue} leaves it untouched. The latter is set by
% default.
%    \begin{macrocode}
\newif\iffootnoterule
\footnoteruletrue
\let\dflt@footnoterule\footnoterule
\let\dflt@pcol@footnoterule\pcol@footnoterule
\renewcommand\footnoterule{%
  \iffootnoterule
  \dflt@footnoterule%
  \fi
}
\renewcommand\pcol@footnoterule{%
  \iffootnoterule
  \dflt@pcol@footnoterule%
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\SetDefaultRule}
%   By default, \pkg{ekdosis} draws separating rules the definition of
%   which is |\rule{0.4\columnwid|\allowbreak|th}{0.4pt}|. This can be
%   changed in the preamble or at any point of the document with
%   \cs{SetDefaultRule}\marg{\allowbreak{}rule definition}. Leaving
%   this argument empty as in \cs{SetDefaultRule}|{}| removes the
%   rule.
%    \begin{macrocode}
\NewDocumentCommand{\SetDefaultRule}{m}{%
  \def\@tempa{#1}
  \ifx\@tempa\empty\def\ekd@default@rule{\mbox{}}%
  \else%
  \def\ekd@default@rule{#1}%
  \fi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\NLS}
% \cs{NLS} was previously adapted from a snippet written by Heiko
% Oberdiek. It is used by \pkg{ekdosis} internally to prevent page
% breaks between separating rules and subsequent notes. Therefore, it
% is not documented.
%    \begin{macrocode}
\newcommand*{\NLS}{%
  \nobreak\@normalcr\relax
  % \par
  % \nobreak
  % \vspace{-\parskip}%
  % \leavevmode
  % \noindent
  % \ignorespaces
}
%    \end{macrocode}
% \end{macro}
% This boolean is used to test if a given entry is to be preceded by a
% numeral referring to the line of the edition text.
%    \begin{macrocode}
\newif\ifsubsq@unit
\subsq@unittrue
%    \end{macrocode}
% \cs{add@@apparatus} inserts the apparatus block on a given page
% either in the footnote floating block or in a float of its own,
% depending on the value set in the |layout| global option. As some
% commands need to know whether they are called from inside the
% apparatus criticus, a conditional is first defined.
%    \begin{macrocode}
\if@pkg@float
\trivfloat{ekdapparatus}
\fi
\newif\ifekd@inside@app
\def\add@@apparatus{%
  \if@pkg@parnotes\parnotes\else\fi
  \if@pkg@footins
  \bgroup
    \unless\ifekd@mapps
      \ifrtl@app\pardir TRT\leavevmode\textdir TRT\else
        \pardir TLT\leavevmode\textdir TLT\fi
    \fi
  \blfootnote{%
    \if@pkg@parnotes
    \if@parnotesroman
    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi
    \parnoteclear\else\fi
    \ekd@inside@apptrue
    \ekd@appfontsize
    \ifekd@mapps
      \ifdefined\ekd@initial@rule
        \ekd@initial@rule
      \fi
    \fi
    \apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi
    \ekd@inside@appfalse
    \if@pkg@parnotes\parnotes\parnotereset\else\fi
  }%
  \egroup
  \fi
  \if@pkg@float
  \begin{ekdapparatus}[!b]
    \unless\ifekd@mapps
      \ifrtl@app\pardir TRT\leavevmode\textdir TRT\else
        \pardir TLT\leavevmode\textdir TLT\fi
    \fi
    \if@pkg@parnotes
    \if@parnotesroman
    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi
    \parnoteclear\else\fi
    \ekd@inside@apptrue
    \ekd@appfontsize
    \ifekd@mapps
      \ifdefined\ekd@initial@rule
        \ekd@initial@rule
      \fi
    \fi
    \apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi
    \ekd@inside@appfalse
    \if@pkg@parnotes\parnotes\parnotereset\else\fi
  \end{ekdapparatus}
  \fi
}
%    \end{macrocode}
% Before inserting any new entry, \cs{add@apparatus} calls
% \cs{test@apparatus} to decide whether a new apparatus block must be
% created on a given page.
%    \begin{macrocode}
\def\add@apparatus{%
  \test@apparatus%
  \ifbool{do@app}{\subsq@unitfalse\add@@apparatus}{}%
}
%    \end{macrocode}
% \cs{append@app} inserts a bare (sub)entry in the apparatus...
%    \begin{macrocode}
\NewDocumentCommand{\append@app}{o +m}{%
  \ifekd@isinapp%
    \ifekd@state%
    \IfNoValueTF{#1}%
      {\luadirect{ekdosis.appin(\luastringO{#2})}}%
      {\luadirect{ekdosis.appin(\luastringO{#2}, \luastringO{#1})}}%
    \fi%
  \fi}
%    \end{macrocode}
% while \cs{append@ln@app} inserts a (sub)entry possibly preceded by a
% line number.
%    \begin{macrocode}
\NewDocumentCommand{\append@ln@app}{o +m}{%
  \IfNoValueTF{#1}
  {\luadirect{tex.sprint(ekdosis.mdvappend(\luastringO{#2}))}}
  {\luadirect{tex.sprint(ekdosis.mdvappend(\luastringO{#2},
      \luastringO{#1}))}}}
%    \end{macrocode}
% \paragraph{Lineation settings}
% \begin{macro}{\outerlinenumbers}
% \begin{macro}{\innerlinenumbers}
% \pkg{ekdosis} does not use the \enquote{pagewise} numbering mode
% that is provided by \pkg{lineno}. Therefore,
% \cs{outerlinenumbers} and \cs{innerlinenumbers} are defined in
% addition to \cs{rightlinenum{\allowbreak}bers} and
% \cs{leftlinenumbers}.
%    \begin{macrocode}
\def\outerlinenumbers{%
  \def\makeLineNumberRunning{%
    \checkoddpage
    \ifoddpage
    \linenumberfont\hskip\linenumbersep\hskip\textwidth
    \hbox to\linenumberwidth{\hss\LineNumber}\hss
    \else
    \hss\linenumberfont\LineNumber\hskip\linenumbersep
    \fi
  }%
}
\def\innerlinenumbers{%
  \def\makeLineNumberRunning{%
    \checkoddpage
    \ifoddpage
    \hss\linenumberfont\LineNumber\hskip\linenumbersep
    \else
    \linenumberfont\hskip\linenumbersep\hskip\textwidth
    \hbox to\linenumberwidth{\hss\LineNumber}\hss
    \fi
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% The keys to be used for lineation settings follow. A conditional is
% defined beforehand so that \pkg{ekdosis} may know whether the
% numbering should start afresh at the top of each page.
%    \begin{macrocode}
\newif\ifekd@pagelineation
\newif\ifekd@pagevlineation
\NewDocumentCommand{\ekdatbegshihook}{}{%
  \ifekd@pagelineation\resetlinenumber\fi
}
\AddToHook{shipout/before}{\ekdatbegshihook}
\newif\ifekd@elidednumbers
\ekvdefinekeys{ekd@lineation}{
  choice lineation = {page = \ekd@pagelineationtrue,
    document = \ekd@pagelineationfalse},
  unknown-choice lineation = \PackageError{ekdosis}{unknown
    lineation=#1}{`lineation' must be either `page' or `document'.},
  choice vlineation = {page = \ekd@pagevlineationtrue,
    document = \ekd@pagevlineationfalse},
  unknown-choice vlineation = \PackageError{ekdosis}{unknown
    vlineation=#1}{`vlineation' must be either `page' or `document'.},
  code modulonum = \chardef\c@linenumbermodulo#1\relax,
  noval modulo = \modulolinenumbers,
  code vmodulo = \ifekd@memoir@loaded\linenumberfrequency{#1}
                 \else\if@pkg@poetry@verse\poemlines{#1}\fi\fi,
  initial vmodulo = 1,
  default vmodulo = 5,
  bool continuousvnum = \if@continuous@vnum,
  choice numbers = {elided = \ekd@elidednumberstrue,
    full = \ekd@elidednumbersfalse},
  unknown-choice numbers = \PackageError{ekdosis}{unknown
    numbers=#1}{`numbers' must be either `elided' or `full'.},
  initial numbers = elided,
  choice margin = {right = \rightlinenumbers,
    left = \leftlinenumbers,
    inner = \innerlinenumbers,
    outer = \outerlinenumbers},
  unknown-choice margin = \PackageError{ekdosis}{unknown
    margin=#1}{`margin' must be either `left', `right', \MessageBreak
    `inner' or `outer'},
  choice vmargin = {
    right = \if@pkg@poetry@verse\verselinenumbersright\fi,
    left = \if@pkg@poetry@verse\verselinenumbersleft\fi},
  unknown-choice vmargin = \PackageError{ekdosis}{unknown
    vmargin=#1}{`margin' must be either `left' ot `right'}
}
%    \end{macrocode}
% \begin{macro}{\SetLineation}
% Then \cs{SetLineation}\marg{options} can be used in the preamble or
% at any point of the document to set lineation preferences. Its
% argument processes the |key-value| options that are defined just
% above.
%    \begin{macrocode}
\NewDocumentCommand{\SetLineation}{m}{
  \ekvset{ekd@lineation}{#1}
}
%    \end{macrocode}
% \end{macro}
% Use |\normalfont| for line numbers:---
%    \begin{macrocode}
\renewcommand\linenumberfont{\normalfont\footnotesize}
%    \end{macrocode}
% \begin{macro}{\SetDefaultApparatus}
% By default, \pkg{ekdosis} defines one layer of critical notes which
% is called |default|. This name can be changed at any point of the
% document with \cs{SetDefaultApparatus}\marg{name}.
%    \begin{macrocode}
\ekvdefinekeys{appnote}{
   store type = \ekdan@type,
   initial type = default
 }
\NewDocumentCommand{\SetDefaultApparatus}{m}{%
  \ekvset{appnote}{type=#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\app}
% \cs{app}|[type=|\meta{type}|]|\marg{apparatus entries} takes one
% mandatory argument and accepts one optional argument. |type=| refers
% to the layer the note must go into and \meta{apparatus entries}
% contains command used to insert the entries, either \cs{lem},
% \cs{rdg} or \cs{note}\meta{*}:---
%    \begin{macrocode}
\NewDocumentCommand{\app}{O{} > { \TrimSpaces } +m}{%
  \leavevmode
  \begingroup
  \ekvset{appnote}{#1}%
  \ifekd@isinapp\ekd@appinapptrue\fi
  \ekd@isinapptrue%
  \stepcounter{ekd@lab}%
  \zlabel{ekd:\theekd@lab}%
  \luadirect{ekdosis.storeabspg(
    \luastring{\zref@extract{ekd:\theekd@lab}{abspage}})}%
  \ifekd@state\add@apparatus\fi%
  \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#2}))}%
  \ekd@isinappfalse%
  \ekd@appinappfalse
  \endgroup}
%    \end{macrocode}
% \end{macro}
% \cs{current@ref@arg} is used outside \cs{app} by \cs{note}. It takes
% two mandatory arguments: the beginning line label and the ending
% line label\---which are manually inserted---and returns the formatted
% reference to be inserted in the apparatus criticus.
%    \begin{macrocode}
\def\current@ref@arg#1#2{{%\textdir TLT%
    \unexpanded\expandafter{\ekd@refnumstyle}%
    \ifnum%
    \pdf@strcmp{\getpagerefnumber{#1}}{\getpagerefnumber{#2}}
    =
    0
    \ifnum%
    \pdf@strcmp{\getrefnumber{#1}}{\getrefnumber{#2}}
    =
    0
    %
    \ifekd@mapps%
    \ifbool{subsq@unit@\ekdan@type}{%
      \ifnum%
      \pdf@strcmp{\getrefnumber{#1}}{%
        \getrefnumber{\luadirect{tex.sprint(ekdosis.getprevnotelab())}}}
      =
      0
      \else
      \LRnum{\getrefnumber{#1}}\unexpanded\expandafter{\ekd@postrefnum}% issue the no
      \fi%
    }%
    {\LRnum{\getrefnumber{#1}}\unexpanded\expandafter{\ekd@postrefnum}}% issue the no
    \else
    \ifsubsq@unit%
    %
    \ifnum%
    \pdf@strcmp{\getrefnumber{#1}}{%
      \getrefnumber{\luadirect{tex.sprint(ekdosis.getprevnotelab())}}}
    =
    0
    \else
    \LRnum{\getrefnumber{#1}}\unexpanded\expandafter{\ekd@postrefnum}% issue the no
    \fi
    %
    \else
    \LRnum{\getrefnumber{#1}}\unexpanded\expandafter{\ekd@postrefnum}% issue the no
    \fi
    \fi
    %
    \else
    \ifekd@elidednumbers
    \luadirect{tex.sprint(ekdosis.numrange(\luastring{\getrefnumber{#1}},
      \luastring{\getrefnumber{#2}}))}%
        \unexpanded\expandafter{\ekd@postrefnum}% issue the nos
    \else
    \LRnum{\getrefnumber{#1}}--%
    \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd@postrefnum}% issue the nos
    \fi
    \fi%
    \else
    \LRnum{\getrefnumber{#1}}--%
    \LRnum{\getpagerefnumber{#2}}.%
    \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd@postrefnum}% issue pg and ln nos
    \fi%
    \ifekdn@forcenum
      \LRnum{\getrefnumber{#1}}\unexpanded\expandafter{\ekd@postrefnum}% force the no
    \fi
  }%
}
%    \end{macrocode}
% \cs{current@ref} is pretty much the same as \cs{current@reg@arg},
% but takes no argument. It is used by commands such as \cs{lem} when
% references to page and line numbers can be returned by \textsf{Lua}.
%    \begin{macrocode}
\def\current@ref{{%\textdir TLT%
    \unexpanded\expandafter{\ekd@refnumstyle}%
    \ifnum%
    \pdf@strcmp{%
      \getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      {\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}
    =
    0
    \ifnum%
    \pdf@strcmp{%
      \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      {\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}
    =
    0
    %
    \ifekd@mapps%
    \ifbool{subsq@unit@\ekdan@type}{%
      \ifnum%
      \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}}
      =
      0
    %%%begin
    \ifnum%
    \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}}
    =
    0
    \ifekd@appinapp
    \ifnum%
    \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevprevlnlab())}-b}}
    =
    0
    \else
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      \unexpanded\expandafter{\ekd@postrefnum}% issue the no
    \fi
    \fi
    \else
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      \unexpanded\expandafter{\ekd@postrefnum}% issue the no
    \fi
    %%% end
      \else
      \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
        \unexpanded\expandafter{\ekd@postrefnum}% issue the no
      \fi%
    }{\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      \unexpanded\expandafter{\ekd@postrefnum}}% issue the no
    \else
    \ifsubsq@unit%
    %
    \ifnum%
    \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}}
    =
    0
    %%%begin
    \ifnum%
    \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}}
    =
    0
    \ifekd@appinapp
    \ifnum%
    \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevprevlnlab())}-b}}
    =
    0
    \else
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      \unexpanded\expandafter{\ekd@postrefnum}% issue the no
    \fi
    \fi
    \else
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      \unexpanded\expandafter{\ekd@postrefnum}% issue the no
    \fi
    %%% end
    \else
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      \unexpanded\expandafter{\ekd@postrefnum}% issue the no
    \fi
    %
    \else
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      \unexpanded\expandafter{\ekd@postrefnum}% issue the no
    \fi
    \fi
    %
    \else
    \ifekd@elidednumbers
    \luadirect{tex.sprint(ekdosis.numrange(
      \luastring{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}},
      \luastring{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}))}%
        \unexpanded\expandafter{\ekd@postrefnum}% issue the nos
    \else
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
        \unexpanded\expandafter{\ekd@postrefnum}% issue the nos
    \fi
    \fi%
    \else
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
    \LRnum{\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}.%
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
      \unexpanded\expandafter{\ekd@postrefnum}% issue pg and ln nos
    \fi%
    \ifekdl@forcenum
    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
      \unexpanded\expandafter{\ekd@postrefnum}% force the no
    \fi
  }%
}
%    \end{macrocode}
% Define keys to be used by the optional arguments of \cs{lem} and
% \cs{rdg}:---
%    \begin{macrocode}
\newif\ifekdl@forcenum
\newif\ifekdl@nonum
\ekvdefinekeys{lem}{
  code wit = \def\ekdlr@wit{#1},
  code source = \def\ekdlr@source{#1},
  code resp = \def\ekdlr@resp{#1},
  code alt  = \def\ekdlr@alt{#1},
  code pre = \def\ekdlr@pre{#1},
  code post = \def\ekdlr@post{#1},
  code prewit = \def\ekdlr@prewit{#1},
  code postwit = \def\ekdlr@postwit{#1},
  store type = \ekdlr@type,
  store sep = \ekdl@sep,
  noval nonum = \ekdl@nonumtrue,
  noval num = \ekdl@forcenumtrue,
  bool nolem = \ifekdl@nolem,
  bool nosep = \ifekdl@nosep,
  initial sep = \ekdsep
}
\ekvdefinekeys{rdg}{
  code wit = \def\ekdlr@wit{#1},
  code source = \def\ekdlr@source{#1},
  code resp = \def\ekdlr@resp{#1},
  code alt  = \def\ekdlr@alt{#1},
  code pre = \def\ekdlr@pre{#1},
  code post = \def\ekdlr@post{#1},
  code prewit = \def\ekdlr@prewit{#1},
  code postwit = \def\ekdlr@postwit{#1},
  store type = \ekdlr@type,
  bool nordg = \ifekdr@nordg
}
%    \end{macrocode}
% \begin{macro}{\rdgGrp}
% \changes{v1.1}{2020/11/04}{new macro for grouping readings}
% \cs{rdgGrp}\oarg{option}\marg{lemma and/or readings} may be used to
% group readings so as to indicate subvariation in apparatus
% entries. This command is expected inside \cs{app}|{}|, and takes as
% argument readings to be grouped introduced by means of \cs{lem}
% and/or \cs{rdg} commands.  It further accepts |type| as an optional
% key-value argument to describe the type of grouping.
%    \begin{macrocode}
\NewDocumentCommand{\rdgGrp}{O{} > {\TrimSpaces } m}{%
  \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#2}))}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\app@lang}
% \begin{macro}{\app@note@lang}
% \cs{app@lang} is used internally by \cs{lem} and \cs{rdg} to set the
% language for apparatus entries. \cs{note} uses \cs{\app@note@lang}.
%    \begin{macrocode}
\def\app@lang{%
  \ifekd@mapps
  \luadirect{tex.sprint(ekdosis.getapplang(\luastring{\ekdan@type}))}%
  \else
  \ekd@singleapp@lang
  \fi
}
\def\app@note@lang{%
  \ifekd@mapps
  \luadirect{tex.sprint(ekdosis.getappnotelang(\luastring{\ekdan@type}))}%
  \else
  \ekd@singleapp@note@lang
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\lem}
% \cs{lem}\oarg{options}\marg{lemma text} inserts \meta{lemma text}
% both in the edition text and in the apparatus criticus by default,
% preceded by the reference to the line number or a space if it is the
% same number as the one of the previous entry. This command accepts
% the optional key-value arguments just defined above.
%    \begin{macrocode}
\NewDocumentCommand{\lem}{O{} m}{%
  \ekd@isinlemtrue%
  \luadirect{ekdosis.dolnlab(\luastringN{#2})}%
  \null
  \bgroup%
  \ekdl@forcenumfalse
  \ekdl@nonumfalse
  \ekvset{lem}{#1}%
  \ekd@test@lang
  \ifekd@mapps%
    \ifnum%
    \luadirect{tex.sprint(ekdosis.get_bagunits(\luastringO{\ekdan@type}))}
    = 1
    \boolfalse{subsq@unit@\ekdan@type}%
    \fi%
    \luadirect{ekdosis.increment_bagunits(\luastringO{\ekdan@type})}%
    \def\ekd@munit@delim{%
      \luadirect{tex.sprint(ekdosis.getappdelim(\luastringO{\ekdan@type}))}}%
    \luadirect{tex.sprint(ekdosis.limit_bagunits(\luastringO{\ekdan@type}))}%
  \fi%
  \ifekdl@nolem\edef\lem@app{%
    % \hskip .75em
    \ifekd@mapps
    \ifbool{subsq@unit@\ekdan@type}%
    {\ekd@munit@delim}{}%
    \else%
    \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
    \fi%
    \unless\ifekdl@nonum\current@ref\fi}%\hskip .25em}%
  \else%
  \ifbool{al@rlmode}{%
    \edef\lem@app{%
      % \hskip .75em
      \ifekd@mapps
      \ifbool{subsq@unit@\ekdan@type}%
      {\ekd@munit@delim}{}%
      \else%
      \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
      \fi%
      \unless\ifekdl@nonum\current@ref\fi%\hskip .25em
      \ifdefined\ekdlr@alt%
        \ifdefined\ekdlr@post%
          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
          {\textdir TRT\unexpanded\expandafter{\ekd@lemmastyle}%
            \unexpanded\expandafter{\ekdlr@alt}}%
        \ifdefined\ekdlr@pre%
          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
      \else
        \ifdefined\ekdlr@post%
          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
          {\textdir TRT\unexpanded\expandafter{\ekd@lemmastyle}%
            \unexpanded{#2}}%
        \ifdefined\ekdlr@pre%
          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
      \fi
      \ifdefined\ekdlr@postwit%
        \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
      \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
      \ifdefined\ekdlr@prewit%
        \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
      \ifekdl@nosep\else\unexpanded\expandafter{\ekdl@sep}\fi
    }%
  }%
  {%
    \edef\lem@app{%
      % \hskip .75em
      \ifekd@mapps
      \ifbool{subsq@unit@\ekdan@type}%
      {\ekd@munit@delim}{}%
      \else%
      \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
      \fi%
      \unless\ifekdl@nonum\current@ref\fi%\hskip .25em
      \ifdefined\ekdlr@alt%
        \ifdefined\ekdlr@pre%
          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
        \ifbool{ekd@lang@pkg}%
        {{\unexpanded\expandafter{\ekd@lemmastyle}%
            \noexpand\selectlanguage{\app@lang}%
            \unexpanded\expandafter{\ekdlr@alt}}}%
        {\unexpanded\expandafter{\ekd@lemmastyle}%
          \unexpanded\expandafter{\ekdlr@alt}}%
        \ifdefined\ekdlr@post%
          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
      \else
        \ifdefined\ekdlr@pre%
          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
          \ifbool{ekd@lang@pkg}%
          {{\unexpanded\expandafter{\ekd@lemmastyle}%
              \noexpand\selectlanguage{\app@lang}%
              \unexpanded{#2}}}{%
            {\unexpanded\expandafter{\ekd@lemmastyle}\unexpanded{#2}}}%
        \ifdefined\ekdlr@post%
          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
      \fi
      \ifdefined\ekdlr@prewit%
        \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
      \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
      \ifdefined\ekdlr@postwit%
        \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
      \ifekdl@nosep\else\unexpanded\expandafter{\ekdl@sep}\fi
    }%
  }%
  \fi%
  \ifekd@mapps%
  \append@ln@app[\ekdan@type]{\lem@app}%
  \else%
  \append@ln@app{\lem@app}%
  \fi%
  \egroup%
  \ekd@isinlemfalse%
  \subsq@unittrue%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\rdg}
% \cs{rdg}\oarg{options}\marg{variant reading} inserts \meta{variant
% reading} in the second part of the entry, after the lemma text and
% the separator, in the apparatus criticus. This command accepts the
% optional key-value arguments defined above.
%    \begin{macrocode}
\NewDocumentCommand{\rdg}{O{} m}{%
  \bgroup%
  \ekvset{rdg}{#1}%
  \ekd@test@lang
  % \ifekdr@nordg\append@app{}\else% do we need \append@app{} here? If
  %                               % so, keep in mind \ifekd@mapps,
  %                               like so:
  \ifekdr@nordg%
    \ifekd@mapps%
      \append@app[\ekdan@type]{}%
    \else%
    \append@app{}%
    \fi%
  \else%
  \ifbool{al@rlmode}{%
    \edef\rdg@app{%
      \ifdefined\ekdlr@alt%
        \ifdefined\ekdlr@post%
          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
          {\textdir TRT\unexpanded\expandafter{\ekd@readingstyle}%
            \unexpanded\expandafter{\ekdlr@alt}}%
        \ifdefined\ekdlr@pre%
          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
      \else
        \ifdefined\ekdlr@post%
          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
          {\textdir TRT\unexpanded\expandafter{\ekd@readingstyle}%
            \unexpanded{#2}}%
        \ifdefined\ekdlr@pre%
          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
      \fi
      \ifdefined\ekdlr@postwit%
        \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
      \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
      \ifdefined\ekdlr@prewit%
        \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
    }%
  }%
  {%
    \edef\rdg@app{%
      \ifdefined\ekdlr@alt%
        \ifdefined\ekdlr@pre%
          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
        \ifbool{ekd@lang@pkg}%
        {{\unexpanded\expandafter{\ekd@readingstyle}%
            \noexpand\selectlanguage{\app@lang}%
            \unexpanded\expandafter{\ekdlr@alt}}}%
        {\unexpanded\expandafter{\ekd@readingstyle}%
          \unexpanded\expandafter{\ekdlr@alt}}%
        \ifdefined\ekdlr@post%
          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
      \else
        \ifdefined\ekdlr@pre%
          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
          \ifbool{ekd@lang@pkg}%
          {{\unexpanded\expandafter{\ekd@readingstyle}%
              \noexpand\selectlanguage{\app@lang}\unexpanded{#2}}}{%
            {\unexpanded\expandafter{\ekd@readingstyle}\unexpanded{#2}}}%
        \ifdefined\ekdlr@post%
          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
      \fi
      \ifdefined\ekdlr@prewit%
        \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
      \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
      \ifdefined\ekdlr@postwit%
        \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
    }%
  }%
  \ifekd@mapps%
      \append@app[\ekdan@type]{\rdg@app}%
  \else%
  \append@app{\rdg@app}%
  \fi%
  \fi%
  \egroup%
}
%    \end{macrocode}
% \end{macro}
% Define keys to be used by the optional argument of \cs{note} when
% this command is found outside \cs{app}:---
%    \begin{macrocode}
\newif\ifekdn@forcenum
\ekvdefinekeys{note}{
  store type = \ekdan@type,
  store lem = \ekdn@lem,
  code labelb = \def\ekdn@labelb{#1},
  code labele = \def\ekdn@labele{#1},
  store sep = \ekdn@sep,
  bool nosep = \ifekdn@nosep,
  initial type = default,
  initial sep = \ekdsep,
  bool nonum = \ifekdn@nonum,
  noval num = \ekdn@forcenumtrue
}
%    \end{macrocode}
% \cs{note@noapp} is used internally when a \cs{note} command is found
% outside \cs{app}. This command is mostly used to insert short
% comments or references to texts quoted or cited in the edition text
% to go into additional layers of the apparatus criticus, e.g.\ the
% \emph{apparatus testium}. It accepts the optional key-value
% arguments just defined above. It must be noted that |labelb| must be
% specified; otherwise \pkg{ekdosis} will issue an error message.
%    \begin{macrocode}
\NewDocumentCommand{\note@noapp}{O{} +m}{%
  \leavevmode
  \bgroup%
  \ekvset{note}{#1}%
  \ekd@test@lang
  \stepcounter{ekd@lab}%
  \zlabel{ekd:\theekd@lab}%
  \luadirect{ekdosis.storeabspg(
    \luastring{\zref@extract{ekd:\theekd@lab}{abspage}})}%
  \ifekd@state\add@apparatus\fi%
  \ifekd@mapps%
    \ifnum%
      \luadirect{tex.sprint(ekdosis.get_bagunits(\luastringO{\ekdan@type}))}
      = 1
      \boolfalse{subsq@unit@\ekdan@type}%
    \fi%
  \luadirect{ekdosis.increment_bagunits(\luastringO{\ekdan@type})}%
    \def\ekd@munit@delim{%
      \luadirect{tex.sprint(ekdosis.getappdelim(\luastringO{\ekdan@type}))}}%
    \luadirect{tex.sprint(ekdosis.limit_bagunits(\luastringO{\ekdan@type}))}%
  \fi%  
  \ifdefined\ekdn@labelb%
    \luadirect{tex.sprint(ekdosis.setnotelab(\luastringO{\ekdn@labelb}))}%
    \ifdefined\ekdn@labele\else\def\ekdn@labele{\ekdn@labelb}\fi%
  \else\PackageError{ekdosis}{missing labelb}{`labelb' must be
    set.}\fi%
  \ifbool{al@rlmode}%
  {\edef\note@contents{%
      % \hskip .75em
      \ifekd@mapps
        \ifbool{subsq@unit@\ekdan@type}%
        {\ekd@munit@delim}{}%
      \else%
        \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
      \fi%
      \unless\ifekdn@nonum\current@ref@arg{\ekdn@labelb}{\ekdn@labele}\fi%\hskip .25em
      \ifdefined\ekdn@lem%
      {\textdir TRT\unexpanded\expandafter{\ekd@lemmastyle}%
        \unexpanded\expandafter{\ekdn@lem}}%
          \unless\ifekdn@nosep
          \unexpanded\expandafter{\ekdn@sep}\fi
          \else\fi%
            {\textdir TRT\unexpanded{#2}}}}%
  {\edef\note@contents{%
      % \hskip .75em
      \ifekd@mapps
        \ifbool{subsq@unit@\ekdan@type}%
        {\ekd@munit@delim}{}%
      \else%
        \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
      \fi%
      \unless\ifekdn@nonum\current@ref@arg{\ekdn@labelb}{\ekdn@labele}\fi%\hskip .25em
      \ifdefined\ekdn@lem
        \ifbool{ekd@lang@pkg}%
        {{\unexpanded\expandafter{\ekd@lemmastyle}%
            \noexpand\selectlanguage{\app@lang}%
              \unexpanded\expandafter{\ekdn@lem}}}%
          {\unexpanded\expandafter{\ekd@lemmastyle}%
            \unexpanded\expandafter{\ekdn@lem}}%
          \unless\ifekdn@nosep
          \unexpanded\expandafter{\ekdn@sep}\fi
          \else\fi%
          \ifbool{ekd@lang@pkg}%
          {{\noexpand\selectlanguage{\app@note@lang}\unexpanded{#2}}}{%
            {\unexpanded{#2}}}}}%
  \ifekd@mapps%
  \unconditional@appin[\ekdan@type]{\note@contents}%
  \else%
  \unconditional@appin{\note@contents}%
  \fi%
    \luadirect{ekdosis.setprevnotelab(\luastringO{\ekdn@labelb})}%
  \egroup
  \subsq@unittrue
  \ignorespaces
}
%    \end{macrocode}
% Define keys to be used by the optional argument of \cs{note} when
% this command is found inside \cs{app}:---
%    \begin{macrocode}
\ekvdefinekeys{ekd@note}{
  store pre = \pre@value,
  store post = \post@value
}
%    \end{macrocode}
% The following three commands, \cs{note@app}, \cs{ekd@note} and
% \cs{ekd@note@star} are used internally when a \cs{note} command is
% found inside \cs{app}. These commands are used to insert short
% comments after the lemma text or after any variant reading in the
% apparatus criticus. \cs{note@app} and subsequently \cs{ekd@note} and
% \cs{ekd@note@star} accept the optional key-value arguments just
% defined above.
%    \begin{macrocode}
\NewDocumentCommand{\ekd@note}{O{} m}{%
  \bgroup%
  \ekvset{ekd@note}{#1}%
  \edef\note@contents{%
    \ekvifdefinedNoVal{ekd@note}{pre}{}{%
      \unexpanded\expandafter{\pre@value}}%
    {\unexpanded{#2}}%
    \ekvifdefinedNoVal{ekd@note}{post}{}{%
      \unexpanded\expandafter{\post@value}}%
  }%
  \ifekd@mapps%
  \append@app[\ekdan@type]{\note@contents}%
  \else%
  \append@app{\note@contents}%
  \fi%
  \egroup%
}
\NewDocumentCommand{\ekd@note@star}{O{} m}{%
  \bgroup
  \ekvset{ekd@note}{#1}%
  \edef\note@contents{%
    \ekvifdefinedNoVal{ekd@note}{pre}{}{%
      \unexpanded\expandafter{\pre@value}}%
    \if@pkg@parnotes
      \unskip\noexpand\parnote{\unexpanded{#2}}%
    \else
      \unskip\noexpand\footnote{\unexpanded{#2}}%
    \fi
    \ekvifdefinedNoVal{ekd@note}{post}{}{%
      \unexpanded\expandafter{\post@value}}%
  }%
  \ifekd@mapps
    \append@app[\ekdan@type]{\note@contents}%
  \else
    \append@app{\note@contents}%
  \fi
  \egroup
}
\NewDocumentCommand{\note@app}{s O{} +m}{%
  \ifbool{al@rlmode}{%
    \IfBooleanTF{#1}{\ekd@note@star[#2]{%
          {\textdir TRT#3}}}
    {\ekd@note[#2]{{\textdir TRT#3}}}%
  }{%
    \IfBooleanTF{#1}{\ekd@note@star[#2]{#3}}
    {\ekd@note[#2]{#3}}%
  }%
}
%    \end{macrocode}
% \begin{macro}{\note}
% Finally, \cs{note} is a simple command designed to check whether
% \cs{note} itself is called inside or outside \cs{app}. Then, unless
% it is found inside \cs{lem}, it calls \cs{note@app} in the former
% case and \cs{note@noapp} in the latter case:---
%    \begin{macrocode}
\NewDocumentCommand{\note}{s O{} +m}{%
  \ifekd@state%
    \ifekd@isinapp%
      \ifekd@isinlem%
        \note@noapp[#2]{#3}%
      \else%
        \IfBooleanTF{#1}{\note@app*[#2]{#3}}{\note@app[#2]{#3}}%
      \fi%
    \else%
      \note@noapp[#2]{#3}%
      \fi%
  \fi%
}
%    \end{macrocode}
% \end{macro}
% \paragraph{Emendations and Conjectures}
% Here follows the |key-value| options to be used by
% \cs{SetCritSymbols} below:---
%    \begin{macrocode}
\ekvdefinekeys{ekd@corr}{
  store suppbegin = \suppb@value,
  store suppend = \suppe@value,
  store delbegin = \delb@value,
  store delend = \dele@value,
  store sicbegin = \sicb@value,
  store sicend = \sice@value,
  store gapmark = \gapm@value,
  initial suppbegin = \ifbool{al@rlmode}{>}{<},
  initial suppend = \ifbool{al@rlmode}{<}{>},
  initial delbegin = \ifbool{al@rlmode}{\}}{\{},
  initial delend = \ifbool{al@rlmode}{\{}{\}},
  initial sicbegin = \dag,
  initial sicend = \dag,
  initial gapmark = ***
}
%    \end{macrocode}
% \begin{macro}{\supplied}
% \changes{v1.1}{2020/11/04}{new macro for editorial additions}
% \cs{supplied}\marg{text} takes as mandatory argument the text added
% or supplied by conjecture.
%    \begin{macrocode}
\NewDocumentCommand{\supplied}{m}{%
  \ifekd@inside@app
  #1%
  \else
  \suppb@value #1\suppe@value
  \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\surplus}
% \changes{v1.1}{2020/11/04}{new macro for editorial deletions}
% \cs{surplus}\marg{text} takes as mandatory argument the text
% considered by the editor to be inauthentic, but nevertheless
% retained between braces in the edition text as it is transmitted by
% all witnesses.
%    \begin{macrocode}
\NewDocumentCommand{\surplus}{m}{%
  \ifekd@inside@app
  #1%
  \else
  \delb@value #1\dele@value
  \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\sic}
% \changes{v1.1}{2020/11/04}{new macro for text deemed to be not
% understandable}
% \cs{sic}\marg{text} takes as mandatory argument the text deemed by
% the editor to be readable but not understandable. \cs{sic} insert
% \meta{text} between cruces while \cs{sic*} prints only one crux
% before \meta{text}.
%    \begin{macrocode}
\NewDocumentCommand{\sic}{s m}{%
  \ifekd@inside@app
  #2%
  \else
  \IfBooleanTF{#1}
    {\sicb@value #2}
    {\sicb@value #2\sice@value}%
  \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\gap}
% \changes{v1.1}{2020/11/04}{new macro for lacunae}
% \cs{gap}\marg{options} indicates that some amount of text has fallen
% away from the entire tradition. It takes as mandatory argument a
% comma-separated list of options that can be used to further specify
% the reason for omission, the unit of measurement, the quantity and
% extent.
%    \begin{macrocode}
\NewDocumentCommand{\gap}{m}{%
  \gapm@value
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\SetCritSymbols}
% \changes{v1.1}{2020/11/04}{new macro to set the symbols to be
% used to mark the corrections} \cs{SetCritSymbols}\marg{csv list of
% options} is used to change the symbols that \pkg{ekdosis} uses by
% default for representing emendations, lacunae, omissions, gaps and
% editorial deletions.
%    \begin{macrocode}
\NewDocumentCommand{\SetCritSymbols}{m}{
  \ekvset{ekd@corr}{#1}
}
%    \end{macrocode}
% \end{macro}
% \cs{apparatus} is used internally by \pkg{ekdosis} to print the
% apparatus at the bottom of pages. Therefore, it is not documented,
% but this may change in the future for it will be possible to have
% apparatuses printed at other places.
%    \begin{macrocode}
\NewDocumentCommand{\apparatus}{}{%
  \luadirect{tex.sprint(ekdosis.appout())}}
%    \end{macrocode}
% The following two commands call \textsf{Lua} functions to check
% whether an apparatus should be printed on a given page and to store
% the current column id.
%    \begin{macrocode}
\NewDocumentCommand{\test@apparatus}{}{%
  \luadirect{tex.sprint(ekdosis.testapparatus())}}
\NewDocumentCommand{\ekd@storecol}{}{%
  \luadirect{ekdosis.storecurcol(\luastring{\thecolumn})}%
}
%    \end{macrocode}
% Start and stop |ekdosis|:
%    \begin{macrocode}
\NewDocumentCommand{\EkdosisOn}{}{%
  \ekd@statetrue}
\NewDocumentCommand{\EkdosisOff}{}{%
  \ekd@statefalse%
}
%    \end{macrocode}
% Neutralize unwanted commands provided by \pkg{lineno} within the
% \env{ekdosis} environment:---
%    \begin{macrocode}
\def\ekd@setlineno{%
  \let\setpagewiselinenumbers\relax%
  \let\pagewiselinenumbers\relax%
  \let\endpagewiselinenumbers\relax%
  \let\runningpagewiselinenumbers\relax%
  \let\realpagewiselinenumbers\relax%
}
%    \end{macrocode}
% \begin{environment}{ekdosis}
% Finally comes the \env{ekdosis} environment meant to receive the
% edition text equipped with an apparatus criticus. This environment
% collects its contents and delivers it to \textsf{Lua} functions if a
% \texttt{TEI xml} output file be desired.
%    \begin{macrocode}
\NewDocumentEnvironment{ekdosis}{+b}{%
  \ekd@setlineno%
  \runninglinenumbers
    \EkdosisOn#1}{%
    \EkdosisOff
  \endrunninglinenumbers%
  \iftei@export
  \luadirect{ekdosis.exporttei(\luastringN{\par #1\par })}\fi}
%    \end{macrocode}
% \end{environment}
% \paragraph{Alignment} What follows is to arrange texts in parallel
% columns either on single pages or on facing pages.
%
% Define keys to be used by the \env{alignment} environment:---
%    \begin{macrocode}
\ekvdefinekeys{ekd@align}{
  store tcols = \tcols@num,
  store lcols = \lcols@num,
  store texts = \texts@value,
  store apparatus = \apparatus@value,
  bool paired = \ifekd@paired,
  choice lineation = {page = \ekd@pagelineationtrue,
                      document = \ekd@pagelineationfalse},
  unknown-choice lineation = \PackageError{ekdosis}{unknown
    lineation=#1}{`lineation' must be either `page' or `document'.},
  choice segmentation = {auto = \def\segmentation@val{auto},
                         noauto = \def\segmentation@val{noauto}},
  unknown-choice segmentation = \PackageError{ekdosis}{unknown
    segmentation=#1}{`segmentation' must be either `auto' or
    `noauto'.},
  bool flush = \ifekd@flushapp,
  initial tcols = 2,
  initial lcols = 1,
  initial texts = edition;translation,
  initial apparatus = edition,
  default segmentation = auto
}
%    \end{macrocode}
% \begin{macro}{\SetAlignment}
% \cs{SetAlignment}\marg{settings} can be used either in the
% preamble or at any point of the document to set or modify the
% keys-value settings just defined above.
%    \begin{macrocode}
\NewDocumentCommand{\SetAlignment}{m}{
  \ekvset{ekd@align}{#1}
}
%    \end{macrocode}
% \end{macro}
% Patch \pkg{paracol} to insert a hook in \cs{pcol@nextpage}. This
% hook is used to reset line numbers on new pages.
%    \begin{macrocode}
\patchcmd{\pcol@nextpage}{%
  \endgroup}{%
  \ifekd@pagelineation\resetlinenumber\fi
  \endgroup}{}{}
%    \end{macrocode}
% \cs{EkdosisColStart} and \cs{EkdosisColStop} initialize columns
% meant to receive edition texts. These commands are used internally
% by \pkg{ekdosis}.
%    \begin{macrocode}
\NewDocumentCommand{\EkdosisColStart}{}{%
  \ekd@setlineno%
  \runninglinenumbers
  \ekd@storecol%
  \stepcounter{ekd@lab}%
  \zlabel{ekd:\theekd@lab}%
  \luadirect{%
    ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}},
    "pg_i")}%
  \ifekd@pagelineation
    \luadirect{tex.sprint(ekdosis.checkresetlineno())}
  \fi
}
\NewDocumentCommand{\EkdosisColStop}{}{%
  \stepcounter{ekd@lab}%
  \zlabel{ekd:\theekd@lab}%
  \luadirect{%
    ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}},
    "pg_ii")}%
  \endrunninglinenumbers%
}
%    \end{macrocode}
% \begin{environment}{alignment}
% \cs{begin}|{alignment}|\oarg{options}\dots\cs{end}|{alignment}| can
% be used as it is provided to typeset a standard critical edition
% text on the left-hand pages accompanied with a translation on the
% right-hand pages. To that effect, it provides by default two new
% environments, \env{edition} and \env{translation}, to be used to
% typeset both texts. (Either whole texts or texts entered by
% paragraphs alternately.) The optional argument of \env{alignment}
% accepts the exact same key-value options as \cs{SetAlignment}
% described above. One may contrast these options with those accepted
% by \cs{SetAlignment} as \enquote{local settings}.
%    \begin{macrocode}
\NewDocumentEnvironment{alignment}{O{}}
{%
  \ekvset{ekd@align}{#1}%
  \luadirect{ekdosis.mkenvdata(
    \luastring{\texts@value},
    "texts"
    )}
  \ifekd@flushapp
    \luadirect{ekdosis.newalignment("set")}
  \fi
  \luadirect{ekdosis.mkenvdata(
    \luastring{\apparatus@value}, "apparatus"
    )}
  \setrunninglinenumbers
  \luadirect{tex.sprint(ekdosis.mkenv())}
  \ifekd@paired
  \begin{paracol}[\lcols@num]{\tcols@num}
  \else
  \begin{paracol}[\lcols@num]*{\tcols@num}
  \fi
  }
  {\end{paracol}
  \iftei@export\luadirect{ekdosis.export_coldata_totei()}\fi
  \ifekd@flushapp
    \luadirect{ekdosis.newalignment("reset")}
  \fi
  \luadirect{ekdosis.flushenvdata()}
  \luadirect{ekdosis.flushcolnums()}
  }
%    \end{macrocode}
% \end{environment}
% \paragraph{Headers and Footers}
%    \begin{macrocode}
\NewDocumentCommand{\ekd@storemark}{m}{%
  \stepcounter{ekd@lab}%
  \zlabel{ekd:\theekd@lab}%
  \luadirect{ekdosis.storehfmark(
    \luastring{\zref@extract{ekd:\theekd@lab}{abspage}},
    \luastringN{#1})}%
}
\NewDocumentCommand{\ekdmark}{}{%
  \luadirect{tex.sprint(ekdosis.gethfmark(\luastring{\thepage}))}%
}
%    \end{macrocode}
% \paragraph{Divisions of the Body}
% \pkg{ekdosis} can convert \cs{book}, \cs{part}, \cs{chapter},
% \cs{section}, \cs{subsec{\allowbreak}tion} and \cs{subsubsection}
% into corresponding \texttt{TEI} \enquote*{numbered}
% |<div|\textsubscript{\emph{n}}|>| elements, where $1\leq n\leq 6$.
% \begin{macro}{\MkBodyDivs}
% \cs{MkBodyDivs} is used to let \pkg{ekdosis} know which sectional
% commands are actually being used in an edition text. This command
% takes six mandatory arguments. For example, if \cs{section} and
% \cs{subsection} are the only sectional commands being used,
% |\MkBodyDivs{section}{subsection}{}{}{}{}| will have \cs{section}
% and \cs{subsection} converted into |<div1>| and |<div2>|
% respectively.
%    \begin{macrocode}
\NewDocumentCommand{\MkBodyDivs}{mmmmmm}{
  \luadirect{ekdosis.mkdivdepths(
    \luastringN{#1},
    \luastringN{#2},
    \luastringN{#3},
    \luastringN{#4},
    \luastringN{#5},
    \luastringN{#6}
    )
  }
}
%    \end{macrocode}
% \end{macro}
% Divisions specific to \pkg{ekdosis}. Define keys to be used by
% \cs{ekddiv}:---
%    \begin{macrocode}
\ekvdefinekeys{ekd@div}{
  code type = \def\type@value{#1},
  code n = \def\n@value{#1},
  code head = \def\head@value{#1},
  code barehead = \def\barehead@value{#1},
  store depth = \depth@value,
  code mark = \ekd@storemark{#1},
  choice toc = {book = \def\toc@value{book},
                part = \def\toc@value{part},
                chapter = \def\toc@value{chapter},
                section = \def\toc@value{section},
                subsection = \def\toc@value{subsection},
                subsubsection = \def\toc@value{subsubsection},
                paragraph = \def\toc@value{paragraph},
                subparagraph = \def\toc@value{subparagraph}},
  unknown-choice toc = \PackageError{ekdosis}{unknown toc=#1}{`toc'
    must be either `book', `part', `chapter', `section', `subsection',
    \MessageBreak `subsubsection', `paragraph' or `subparagraph'.},
  initial depth = 1
}
%    \end{macrocode}
% \begin{macro}{\FormatDiv}
% \cs{FormatDiv}\marg{n}\marg{code before}\marg{code
% after} is used to lay out the heading of the title. It takes three
% mandatory arguments: \emph{n}, namely the number referring to the
% particular depth of the division, and then some \LaTeX{} formatting
% commands to go before and after the heading itself:---
%    \begin{macrocode}
\NewDocumentCommand{\FormatDiv}{m m m}{
  \luadirect{ekdosis.fmtdiv(\luastring{#1},
    \luastringN{#2},
    \luastringN{#3})}
}
%    \end{macrocode}
% \end{macro}
% \cs{ekd@getfmtdiv} gets the formatting commands that have been
% stored by \cs{FormatDiv}.
%    \begin{macrocode}
\NewDocumentCommand{\ekd@getfmtdiv}{m m}{%
  \luadirect{tex.sprint(ekdosis.getfmtdiv(\luastringO{#1},
    \luastringN{#2}))}%
}
%    \end{macrocode}
% \begin{macro}{\ekddiv}
% \cs{ekddiv}\marg{key-value arguments} is the standard command
% provided by \pkg{ekdosis} to meet the requirements of classical and
% literary texts the divisions of which depend on many different
% received traditions. It takes one mandatory argument in which the
% key-value arguments defined above are accepted, and converts the
% divisions into \texttt{TEI} \enquote*{un-numbered} |<div>|
% elements.
%    \begin{macrocode}
\NewDocumentCommand{\ekddiv}{m}{
  \begingroup
  \ekvset{ekd@div}{#1}%
  \ifdefined\head@value
    \bgroup
      \ekd@getfmtdiv{\depth@value}{b}%
      \head@value
      \ekd@getfmtdiv{\depth@value}{e}%
    \egroup
      \ifdefined\toc@value
        \ltx@ifpackageloaded{hyperref}{\phantomsection}{}%
          \ifdefined\barehead@value
            \addcontentsline{toc}{\toc@value}{\barehead@value}%
          \else
            \addcontentsline{toc}{\toc@value}{\head@value}%
          \fi
      \fi
  \fi
  \endgroup
}
%    \end{macrocode}
% \end{macro}
% \paragraph{Poetry Settings}
% \begin{environment}{ekdverse}
%   \env{ekdverse} provides an implementation of poetry lines. It is
%   set to use either the \pkg{lineno} or the \pkg{verse} package
%   depending on the value that is passed to the global option
%   |poetry|.
% \begin{macro}{\test@vpnum}
% \cs{test@vpnum} is used internally when |ekdosis| needs to know
% whether two subsequent lines are printed on the same page or not.
%    \begin{macrocode}
\newif\ifekd@test@vpnum
\newcounter{ekd@vpnum}
\globalcounter{ekd@vpnum}
\NewDocumentCommand{\test@vpnum}{}{%
  \ifekd@test@vpnum
    \edef\@tempa{\theekd@vpnum}%
    \stepcounter{ekd@vpnum}%
    \label{vpnum:\theekd@vpnum}%
    \ifnum
      \pdf@strcmp{\getpagerefnumber{vpnum:\@tempa}}%
        {\getpagerefnumber{vpnum:\theekd@vpnum}}
        = 0
      \else
        \resetvlinenumber
    \fi
  \else
  \label{vpnum:\theekd@vpnum}%
  \global\ekd@test@vpnumtrue
  \fi
}
%    \end{macrocode}
% \end{macro}
% A small patch is applied to the \pkg{verse} package, then
% \env{ekdverse} is defined:---
%    \begin{macrocode}
\if@pkg@poetry@verse
\patchcmd{\start@vsline}{%
  \ifaltindent}{%
  \ifekd@pagevlineation\test@vpnum\fi
  \ifaltindent}{}{}
\ekvdefinekeys{ekd@verse}{
  dimen width = \vwidth@val,
  initial width = \linewidth,
  code type = \def\type@value{#1},
}
\ifekd@memoir@loaded
  \linenumberfont{\normalfont\footnotesize}
\else
  \verselinenumfont{\normalfont\footnotesize}
\fi
\setcounter{poemline}{1}
\NewDocumentEnvironment{ekdverse}{!O{}}{%
  \ekvset{ekd@verse}{#1}%
  \if@continuous@vnum\setverselinenums{\thelinenumber}{0}\fi
  \nolinenumbers
  \let\linelabel\label
  \ifekd@memoir@loaded
    \refstepcounter{verse}%
  \else
    \stepcounter{verse@envctr}%
  \fi
  \addtocounter{poemline}{-1}\refstepcounter{poemline}%
  \setcounter{vslineno}{1}%
  \let\\=\@vscentercr
  \list{}{\itemsep \z@
          \itemindent  -\vindent%
          \listparindent\itemindent
          \parsep       \stanzaskip
          \setlength{\itemsep}{0pt}%
          \setlength{\topsep}{0pt}%
          \setlength{\partopsep}{0pt}%
          \ifdim\vwidth@val < \linewidth
            \rightmargin        \z@
            \setlength{\leftmargin}{\linewidth}%
            \addtolength{\leftmargin}{-\vwidth@val}%
            \addtolength{\leftmargin}{-0.5\leftmargin}%
          \else
            \rightmargin        \leftmargin
          \fi
          \addtolength{\leftmargin}{\vindent}}%
  \item[]\ifekd@pagevlineation\test@vpnum\fi%
}
{\endlist
  \if@continuous@vnum\resetlinenumber[\thepoemline]\fi}
%    \end{macrocode}
% Finally, this is the standard \env{verse} environment:---
%    \begin{macrocode}
\else
\newlength{\ekdverseindentlength}
\setlength{\ekdverseindentlength}{\parindent}
\NewDocumentEnvironment{ekdverse}{!O{\ekdverseindentlength}}{
  \begin{list}{}{%
      \setlength{\leftmargin}{#1}
      \setlength{\itemsep}{0pt}
      \setlength{\topsep}{0pt}
      \setlength{\partopsep}{0pt}
    }
  \item[]
  }{\end{list}}
\fi
%    \end{macrocode}
% \end{environment}
% \begin{macro}{\resetvlinenumber}
% \changes{v1.2}{2021/04/02}{resets line numbers in poetry environments}
% This command is the equivalent of \cs{resetlinenumber} for lines of
% poetry. It takes an integer as optional argument, which is |1| by
% default.
%    \begin{macrocode}
\NewDocumentCommand{\resetvlinenumber}{O{1}}{%
  \if@pkg@poetry@verse
  \setverselinenums{#1}{0}%
  \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{environment}{ekdstanza}
%   \changes{v1.2}{2021/04/02}{new environment for stanzas}
%   \env{ekdstanza} is needed when lines are grouped into stanzas,
%   which can be further named by means of the |type| optional
%   argument:---
%    \begin{macrocode}
\ekvdefinekeys{ekd@stanza}{
  code type = \def\type@value{#1}
}
\NewDocumentEnvironment{ekdstanza}{!O{}}{%
  \leavevmode\unskip
  \ekvset{ekd@stanza}{#1}%
  \ignorespaces
}{}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{ekdpar}
%   When |autopar| is set to |false| by means of \cs{SetTEIxmlExport},
%   \env{ekdpar}\---or any other environment set to be inserted within
%   |<p>| elements\---must be used so that \pkg{ekdosis} can be
%   informed of paragraph boundaries.
%    \begin{macrocode}
\NewDocumentEnvironment{ekdpar}{}{\par}{\par}
%    \end{macrocode}
% \end{environment}
% \paragraph{Configuration File} Finally, if a configuration file
% named |\jobname-ekd.cfg| can be found, this file is read and its
% contents loaded into the document preamble. This provides a
% convenient way to gather all the settings related to the critical
% edition in a separate file.
%    \begin{macrocode}
\IfFileExists{\jobname-ekd.cfg}{\input{\jobname-ekd.cfg}}{}
%    \end{macrocode}
% \iffalse
%</package>
% \fi
% 
% \Finale
% \iffalse
%<*lua>
% \fi
% \begin{comment}
% \begin{ekdlua}
-- `'
-- This table will hold the functions:
ekdosis = {}

-- lpeg equivalent for string.gsub()
local function gsub(s, patt, repl)
  patt = lpeg.P(patt)
  patt = lpeg.Cs((patt / repl + 1)^0)
  return lpeg.match(patt, s)
end

-- some basic patterns:
local letters = lpeg.R("az", "AZ")
local ascii = lpeg.R("az", "AZ", "@@")
local dblbkslash = lpeg.Cs("\\")
local bsqbrackets = lpeg.Cs{ "[" * ((1 - lpeg.S"[]") + lpeg.V(1))^0 * "]" }
local bcbraces = lpeg.Cs{ "{" * ((1 - lpeg.S"{}") + lpeg.V(1))^0 * "}" }
local spce = lpeg.Cs(" ")
local spcenc = lpeg.P(" ")
local cmdstar = lpeg.Cs(spce * lpeg.P("*"))
local bsqbracketsii = lpeg.Cs(bsqbrackets^-2)
local bcbracesii = lpeg.Cs(bcbraces^-2)
local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1)
local rawcmd = lpeg.Cs(dblbkslash * ascii^1)
local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash)
local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1)
local app = lpeg.Cs("app")
local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg"))
local note = lpeg.Cs("note")
local inlem = lpeg.Cs{ "<lem" * ((1 - (lpeg.P"<lem" + lpeg.P"</lem>")) + lpeg.V(1))^0 * "</lem>" }
local lnbrk = lpeg.Cs("\\\\")
local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1 * spcenc^-1)
local poemlinebreak = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P("&gt;") * bsqbrackets^-1 * spcenc^-1)
local linegroup = lpeg.Cs{ "<lg" * ((1 - lpeg.S"<>") + lpeg.V(1))^0 * ">" }
local bclinegroup = lpeg.Cs(linegroup + lpeg.P("</lg>"))
local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1) -- not used
local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter")
			    + lpeg.P("section") + lpeg.P("subsection")
			    + lpeg.P("subsubsection"))
local par =  lpeg.P(lpeg.P("\\par") * spce^0)
local parb = lpeg.P(lpeg.P("\\p@rb") * spce^0)
local para = lpeg.P(lpeg.P("\\p@ra") * spce^0)
local labelrefcmds = lpeg.Cs(lpeg.P("label")
			       + lpeg.P("linelabel")
			       + lpeg.P("lineref")
			       + lpeg.P("ref")
			       + lpeg.P("pageref")
			       + lpeg.P("vref")
			       + lpeg.P("vpageref"))
local citecmds = lpeg.Cs(lpeg.P("icite")
			    + lpeg.P("cite")
			    + lpeg.P("Cite")
			    + lpeg.P("cite *")
			    + lpeg.P("parencite")
			    + lpeg.P("Parencite")
			    + lpeg.P("parencite *")
			    + lpeg.P("footcite")
			    + lpeg.P("footcitetext")
			    + lpeg.P("textcite")
			    + lpeg.P("Textcite")
			    + lpeg.P("smartcite")
			    + lpeg.P("Smartcite")
			    + lpeg.P("autocite")
			    + lpeg.P("Autocite")
			    + lpeg.P("autocite *")
			    + lpeg.P("Autocite *")
)
--
-- Bind to local variables
local next = next

-- General
local xmlids = {}
table.insert(xmlids, {xmlid = "scholars"} )

local function xmlidfound(element)
   for i = 1,#xmlids do
      if xmlids[i].xmlid == element then
	 return true
      end
   end
   return false
end

local function checkxmlid(str)
   if string.find(str, "^[0-9]")
      or string.find(str, "[%{%}%[%]%(%):; ]")
   then
      return false
   else
      return true
   end
end

-- Witnesses
local listWit = {}
-- Persons/Scholars
local listPerson = {}

local idsRend = {}
local shorthands = {}

local function isfound(table, value)
   for i = 1,#table do
      if table[i] == value then
	 return true
      end
   end
   return false
end

local function isintable(table, value)
   for i = 1,#table do
      if table[i].a == value then
	 return true
      end
   end
   return false
end

local function get_a_index(id, table)
   local idfound = nil
   for i = 1,#table
   do
      if table[i].a == id then
	 idfound = i
	 break
      end
   end
   return idfound
end

local function getindex(id, table)
   local idfound = nil
   for i = 1,#table
   do
      if table[i].xmlid == id then
	 idfound = i
	 break
      end
   end
   return idfound
end

function ekdosis.newwitness(id,
			    siglum,
			    description,
			    Settlement,
			    Institution,
			    Repository,
			    Collection,
			    Idno,
			    MsName,
			    OrigDate,
			    Locus)
   if xmlidfound(id)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
      	 ..id..
      	 "\" already exists as an xml:id. "
      	 ..
      	 "Please pick another id.}}")
   elseif not checkxmlid(id)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
      	 ..id..
      	 "\" is not a valid xml:id. \\MessageBreak "
      	 ..
      	 "Please pick another id.}}")
   else
      table.insert(xmlids, {xmlid = id})
      table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
      table.insert(idsRend, {xmlid = id, abbr = siglum})
      table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
      table.insert(listWit, {xmlid = id,
			     abbr = siglum,
			     detailsDesc = description,
			     msIdentifier = {
				settlement = Settlement,
				institution = Institution,
				repository = Repository,
				collection = Collection,
				idno = Idno,
				msName = MsName}
                             })
      local indexwit = getindex(id, listWit)
      if OrigDate ~= "" then
	 listWit[indexwit].history = {}
	 listWit[indexwit].history.origin = {origDate = OrigDate}
      end
      if Locus ~= "" then
	 listWit[indexwit].msContents = {}
	 listWit[indexwit].msContents.msItem = {locus = Locus}
      end
   end
   return true
end

function ekdosis.newhand(id, witid, siglum, description)
   if xmlidfound(id) or not xmlidfound(witid)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
      	 ..id..
      	 "\" already exists as an xml:id. "
      	 ..
      	 "Please pick another id.}}")
   elseif not checkxmlid(id)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
      	 ..id..
      	 "\" is not a valid xml:id. \\MessageBreak "
      	 ..
      	 "Please pick another id.}}")
   else
      table.insert(xmlids, {xmlid = id})
      table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
      table.insert(idsRend, {xmlid = id, abbr = siglum})
      table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
      local indexwit = getindex(witid, listWit)
      -- listWit[indexwit].handDesc = {xmlid = id, abbr = siglum, handNote = description}
      if listWit[indexwit].handDesc == nil
      then
	 listWit[indexwit].handDesc = {}
      else
      end
      table.insert(listWit[indexwit].handDesc,
		   {xmlid = id, abbr = siglum, detailsDesc = description})
   end
   return true
end

function ekdosis.newshorthand(id, rend, xmlids)
   if isintable(shorthands, id)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
      	 ..id..
      	 "\" already exists as a shorthand. "
      	 ..
      	 "Please pick another shorthand.}}")
   else
      table.insert(shorthands, { a = id, b = rend, c = xmlids })
      table.sort(shorthands, function(a ,b) return(#a.a > #b.a) end)
      table.insert(idsRend, {xmlid = id, abbr = rend})
      table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
   end
   return true
end

function ekdosis.newscholar(id,
			    siglum,
			    rawname,
			    Forename,
			    Surname,
			    AddName,
			    Note)
   if xmlidfound(id)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
      	 ..id..
      	 "\" already exists as an xml:id. "
      	 ..
      	 "Please pick another id.}}")
   elseif not checkxmlid(id)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
      	 ..id..
      	 "\" is not a valid xml:id. \\MessageBreak "
      	 ..
      	 "Please pick another id.}}")
   else
      table.insert(xmlids, {xmlid = id})
      table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
      table.insert(idsRend, {xmlid = id, abbr = siglum})
      table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
      if rawname ~= ""
      then
	 table.insert(listPerson, {xmlid = id,
				   abbr = siglum,
				   note = Note,
				   persName = {
				      name = rawname}
	 })
      else
	 table.insert(listPerson, {xmlid = id,
				   abbr = siglum,
				   note = Note,
				   persName = {
				      forename = Forename,
				      surname = Surname,
				      addName = AddName}
	 })
      end
   end
   return true
end

local xmlbibresource = nil

function ekdosis.addxmlbibresource(str)
   if string.find(str, "%.xml$")
   then
      xmlbibresource = str
   else
      xmlbibresource = str..".xml"
   end
   return true
end

function ekdosis.newsource(id, siglum)
   if xmlidfound(id)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
	    ..id..
	    "\" already exists as an xml:id. " 
	    ..
	    "Please pick another id.}}")
   elseif not checkxmlid(id)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
      	 ..id..
      	 "\" is not a valid xml:id. \\MessageBreak "
      	 ..
      	 "Please pick another id.}}")
   else
      table.insert(xmlids, {xmlid = id})
      table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
      table.insert(idsRend, {xmlid = id, abbr = siglum})
      table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
   end
   return true
end

function ekdosis.getsiglum(str, opt)
   str = str..","
   str = string.gsub(str, "%s-(%,)", "%1")
   ctrl = str
   if opt == "tei" then
      for i = 1,#shorthands do
	 str = string.gsub(str, shorthands[i].a, shorthands[i].c)
      end
      for i = 1,#idsRend do
	 str  = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)",
			    "%1#"..idsRend[i].xmlid.."%2")
	 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
      end
      str = string.gsub(str, "%,(%s-)([%#])", " %2")
      str = string.gsub(str, "%,$", "")
   else
      for i = 1,#idsRend do
	 str  = string.gsub(str, idsRend[i].xmlid.."%,", idsRend[i].abbr)
	 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
      end
   end
   -- if string.find(ctrl, "[A-Za-z0-9]")
   if string.find(ctrl, "%S")
   then
      return "<??>"
   else
      return str
   end
end

-- begin totei functions

local cmdtotags = {
   {a="textsuperscript", b="hi", c=" rend=\"sup\""},
   {a="textsubscript", b="hi", c=" rend=\"sub\""},
   {a="LRfootnote", b="note", c=" place=\"bottom\""},
   {a="RLfootnote", b="note", c=" place=\"bottom\""},
   {a="enquote *", b="quote", c=""},
   {a="marginpar", b="note", c=" place=\"margin\""},
   {a="footnote", b="note", c=" place=\"bottom\""},
   {a="enquote", b="quote", c=""},
   {a="txtrans", b="s", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
   {a="textbf", b="hi", c=" rend=\"bold\""},
   {a="textit", b="hi", c=" rend=\"italic\""},
   {a="textsc", b="hi", c=" rend=\"smallcaps\""},
   {a="textsf", b="hi", c=" rend=\"sf\""},
   {a="arbup", b="hi", c=" rend=\"sup\""},
   {a="txarb", b="s", c=" xml:lang=\"arb\""},
   {a="arb", b="foreign",
    c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
}

local texpatttotags = {
   {a="\\addentries%s+%[(.-)%]{(.-)}", b=""},
   {a="\\addentries%s+{(.-)}", b=""},
   {a="\\setverselinenums%s+{(.-)}{(.-)}", b=""},
   {a="\\resetvlinenumber%s+%[(.-)%]", b=""},
   {a="\\resetvlinenumber%s+", b=""},
   {a="\\resetlinenumber%s+%[(.-)%]", b=""},
   {a="\\resetlinenumber%s+", b=""},
   {a="\\indentpattern%s+{(.-)}", b=""},
   {a="\\settowidth%s+{(.-)}{(.-)}", b=""},
   {a="\\poemlines%s+{(.-)}", b=""},
   {a="\\pagebreak%s+%[[1-4]%]", b=""},
   {a="\\pagebreak%s+", b=""},
   {a="\\teidirect%s+(%b[]){(.-)}(%b{})", b="<%2 ekd@os%1ekd@cs>ekd@ob%3ekd@cb</%2>"},
   {a="\\teidirect%s+{(.-)}(%b{})", b="<%1>ekd@ob%2ekd@cb</%1>"},
   {a="\\altrfont%s+", b=""},
   {a="\\mbox%s+(%b{})", b="ekd@ob%1ekd@cb"},
   {a="\\LR%s+(%b{})", b="ekd@ob%1ekd@cb"},
   {a="\\RL%s+(%b{})", b="ekd@ob%1ekd@cb"},
   {a="\\%=%=%=%s?", b="—"},
   {a="\\%-%-%-%s?", b="—"},
   {a="\\%=%=%s?", b="–"},
   {a="\\%-%-%s?", b="–"},
   {a="\\%=%/%s?", b="‐"},
   {a="\\%-%/%s?", b="‐"},
   {a="\\vin%s+", b=""},
   {a="\\uc%s+(%b{})", b="ekd@ob%1ekd@cb"}
}

local envtotags = {
   {a="flushright", b="p", c=" rend=\"align(right)\""},
   {a="flushleft", b="p", c=" rend=\"align(left)\""},
   {a="quotation", b="quote", c=""},
   {a="txarabtr", b="p", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
   {a="quoting", b="quote", c=""},
   {a="ekdpar", b="p", c=""},
   {a="txarab", b="p", c=" xml:lang=\"arb\""},
   {a="center", b="p", c=" rend=\"align(center)\""},
   {a="arab", b="p",
    c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
}

local close_p = {
   "p",
   "lg"
}

local forbid_xmlid = true

function ekdosis.newcmdtotag(cmd, tag, attr)
   if forbid_xmlid
   then
      attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here
   else
   end
   if isintable(cmdtotags, cmd)
   then
      local index = get_a_index(cmd, cmdtotags)
      table.remove(cmdtotags, index)
      table.insert(cmdtotags, {a = cmd, b = tag, c = " "..attr})
      table.sort(cmdtotags, function(a ,b) return(#a.a > #b.a) end)
   else
      table.insert(cmdtotags, {a = cmd, b = tag, c = " "..attr})
      table.sort(cmdtotags, function(a ,b) return(#a.a > #b.a) end)
   end
   return true
end

function ekdosis.newpatttotag(pat, repl)
   pat = string.gsub(pat, "([%[%]])", "%%%1")
   pat = string.gsub(pat, "%@b[1-9]", "(%%b{})")
   pat = string.gsub(pat, "%@s[1-9]", "(%%b[])")
   pat = string.gsub(pat, "%#[1-9]", "(.-)")
   repl = string.gsub(repl, "%#([1-9])", "%%%1")
   repl = string.gsub(repl, "%@b([1-9])", "ekd@ob%%%1ekd@cb")
   repl = string.gsub(repl, "%@s([1-9])", "ekd@os%%%1ekd@cs")
   if isintable(texpatttotags, pat)
   then
      local index = get_a_index(pat, texpatttotags)
      table.remove(texpatttotags, index)
      table.insert(texpatttotags, { a = pat, b = repl })
      table.sort(texpatttotags, function(a ,b) return(#a.a > #b.a) end)
   else
      table.insert(texpatttotags, { a = pat, b = repl })
      table.sort(texpatttotags, function(a ,b) return(#a.a > #b.a) end)
   end
   return true
end

function ekdosis.newenvtotag(env, tag, attr, closep)
   if forbid_xmlid
   then
      attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here
   else
   end
   if isintable(envtotags, env)
   then
      local index = get_a_index(env, envtotags)
      table.remove(envtotags, index)
      table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep})
      table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end)
   else
      table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep})
      table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end)
   end
   return true
end

-- Get values of attributes
local function get_attr_value(str, attr)
   str = str..","
   str = string.gsub(str, "%b{}", function(body)
			body = string.gsub(body, attr, attr.."@ekd")
			return string.format("%s", body)
   end)
   local attrval = string.match(str, "%f[%w]"..attr.."%s?%=%s?%b{}")
      or string.match(str, "%f[%w]"..attr.."%s?%=%s?.-%,")
      or ""
   attrval = string.gsub(attrval, attr.."%s?%=%s?(%b{})", function(bbraces)
			    bbraces = string.sub(bbraces, 2, -2)
			    return string.format("%s", bbraces)
   end)
   attrval = string.gsub(attrval, attr.."%s?%=%s?(.-)%s?%,", "%1")
   str = string.gsub(str, attr.."@ekd", attr)
   return attrval
end

local function xml_entities(str)
   str = string.gsub(str, "%<", "&lt;")
   str = string.gsub(str, "%>", "&gt;")
   return str
end

local function note_totei(str)
   str = gsub(str,
	      dblbkslash *
		 note *
		 spcenc^-1 *
		 bsqbrackets *
		 bcbraces *
		 spcenc^-1,
	      function(bkslash, cmd, opt, arg)
		 opt = string.sub(opt, 2, -2)
		 arg = string.sub(arg, 2, -2)
		 teitype = get_attr_value(opt, "type")
		 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
		 right = get_attr_value(opt, "labelb")
		 left = get_attr_value(opt, "labele")
		 if right == ""
		 then
		    return string.format("<%s>%s</%s>", cmd, arg, cmd)
		 else
		    if left ~= ""
		    then
		       return string.format(
			  "<%s%s target=\"#range(right(%s),left(%s))\">%s</%s><anchor xml:id=\"%s\"/>",
			  cmd, teitype, right, left, arg, cmd, right)
		    elseif left == ""
		    then
		       return string.format(
			  "<%s%s target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>",
			  cmd, teitype, right, arg, cmd, right)
		    end
		 end
   end)
   return str
end

local function remove_extra_anchors(str)
   str = string.gsub(str, "(</note>)(<anchor.->)(<note.->)", function(enote, anchor, bnote)
   			local id_one = string.gsub(anchor, "(%<anchor )(.-)(/%>)", "%2")
   			id_one = string.sub(get_attr_value(id_one, "xml:id"), 2, -2)
   			local id_two = string.match(bnote, "target%=.-right%((.-)%)")
   			id_two = string.gsub(id_two, ".-right%((.-)%)", "%1")
   			if id_one == id_two
   			then
   			   return string.format("%s%s", enote, bnote)
   			else
   			   return string.format("%s%s%s", enote, anchor, bnote)
   			end
   end)
   return str
end

local function app_totei(str)
   str = gsub(str,
	      dblbkslash *
		 app *
		 spcenc^-1 *
		 bsqbrackets *
		 bcbraces *
		 spcenc^-1,
	      function(bkslash, cmd, opt, arg)
		 opt = string.sub(opt, 2, -2)
		 arg = string.sub(arg, 2, -2)
		 opt = get_attr_value(opt, "type")
		 if opt ~= "" then opt = " type=\""..opt.."\"" else end
		 return app_totei(string.format("<%s%s>%s</%s>",
						cmd, opt, arg, cmd))
   end)
   return str
end

local function rdgGrp_totei(str)
   str = gsub(str,
	      dblbkslash *
		 lpeg.Cs("rdgGrp") *
		 spcenc^-1 *
		 bsqbrackets *
		 bcbraces *
		 spcenc^-1,
	      function(bkslash, cmd, opt, arg)
		 opt = string.sub(opt, 2, -2)
		 arg = string.sub(arg, 2, -2)
		 teitype = get_attr_value(opt, "type")
		 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
		 if opt == ""
		 then
		    return rdgGrp_totei(string.format("<%s>%s</%s>",
						       cmd, arg, cmd))
		 else
		    return rdgGrp_totei(string.format("<%s%s>%s</%s>",
						       cmd, teitype, arg, cmd))
		 end
   end)
   return str
end

local function lem_rdg_totei(str)
   str = gsub(str,
	      spcenc^-1 *
		 dblbkslash *
		 lemrdg *
		 spcenc^-1 *
		 bsqbrackets *
		 bcbraces *
		 spcenc^-1,
	      function(bkslash, cmd, opt, arg)
		 opt = string.sub(opt, 2, -2)
		 arg = string.sub(arg, 2, -2)
		 -- opt = get_attr_value(opt, "wit")
		 --
		 teiwit = get_attr_value(opt, "wit")
		 if teiwit ~= "" then teiwit = " wit=\""..ekdosis.getsiglum(teiwit, "tei").."\"" else end
		 teisource = get_attr_value(opt, "source")
		 if teisource ~= "" then teisource = " source=\""..ekdosis.getsiglum(teisource, "tei").."\"" else end
		 teiresp = get_attr_value(opt, "resp")
		 if teiresp ~= "" then teiresp = " resp=\""..ekdosis.getsiglum(teiresp, "tei").."\"" else end
		 teitype = get_attr_value(opt, "type")
		 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
		 --
		 if opt == ""
		 then
		    return lem_rdg_totei(string.format("<%s>%s</%s>",
						       cmd, arg, cmd))
		 else
		    -- opt = ekdosis.getsiglum(opt, "tei")
		    return lem_rdg_totei(string.format("<%s%s%s%s%s>%s</%s>",
						       cmd, teiwit, teisource, teiresp, teitype, arg, cmd))
		 end
   end)
   str = gsub(str, spcenc^-0 * dblbkslash * lemrdg * spcenc^-1 * bcbraces * spcenc^-1,
	      function(bkslash, cmd, arg)
		 arg = string.sub(arg, 2, -2)
		 return lem_rdg_totei(string.format("<%s>%s</%s>", cmd, arg, cmd))
   end)
   return str
end

local function relocate_notes(str)
   str = gsub(str, inlem, function(arg)
		 local notes = {}
		 for i in string.gmatch(arg, "%<note.->.-%<%/note%>")
		 do
		    table.insert(notes, i)
		 end
		 allnotes = table.concat(notes)
		 arg = string.gsub(arg, "%<note.->.-%<%/note%>", "")
		 return string.format("%s%s", arg, allnotes)
   end)
   return str
end

local function linestotei(str)
   if not string.find(str, "^%s?<lg")
   then
      str = "\n<l>"..str
   end
   str = gsub(str, poemline * spcenc^0 * bclinegroup, "</l>\n%2")
   str = gsub(str, linegroup * -(spcenc^0 * bclinegroup), "%1\n<l>")
   str = gsub(str, lpeg.Cs("</lg>") * -(spcenc^0 * (bclinegroup + -1)), "%1\n<l>")
   -- str = gsub(str, poemline * spcenc^-1 * -1, "</l>\n")
   str = gsub(str, poemlinebreak, "<lb/> ")
   -- str = gsub(str, poemline * spcenc^-1 * lpeg.Cs("<lg"), "</l>%2")
   -- str = gsub(str, lpeg.Cs("</lg>") * spcenc^1 * -lpeg.P("<l"), "%1\n<l>")
   str = gsub(str, poemline, "</l>\n<l>")
   return str
end

local function stanzatotei(str)
   str = string.gsub(str, "\\begin%s?%{ekdstanza%}(%b[])(.-)\\end%s?%{ekdstanza%}", function(opt, arg)
			arg = string.gsub(arg, "\\par%s?", "")
			opt = string.sub(opt, 2, -2)
			teitype = get_attr_value(opt, "type")
			if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
			if opt == ""
			then
			   return string.format("<lg>%s</lg>", arg)
			else
			   return string.format("<lg%s>%s</lg>", teitype, arg)
			end
   end)
   str = string.gsub(str, "\\begin%s?%{ekdstanza%}(.-)\\end%s?%{ekdstanza%}", function(arg)
			arg = string.gsub(arg, "\\par%s?", "")
			return string.format("<lg>%s</lg>", arg)
   end)
   return str
end

-- better use lpeg: look into this later
local function versetotei(str)
   str = string.gsub(str, "\\begin%s?%{ekdverse%}(%b[])(.-)\\end%s?%{ekdverse%}", function(opt, arg)
			arg = string.gsub(arg, "\\par%s?", "")
			arg = string.gsub(arg, "\\begin%s?%{patverse%*?%}", "")
			arg = string.gsub(arg, "\\end%s?%{patverse%*?%}", "")
			arg = string.gsub(arg, "\\indentpattern%s?%b{}", "")
			opt = string.sub(opt, 2, -2)
			teitype = get_attr_value(opt, "type")
			if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
			if opt == ""
			then
			   return "\\p@rb "..linestotei(string.format("<lg>%s</lg>", arg)).."\\p@ra "
			else
			   return "\\p@rb "..linestotei(string.format("<lg%s>%s</lg>", teitype, arg)).."\\p@ra "
			end
   end)
   str = string.gsub(str, "\\begin%s?%{ekdverse%}(.-)\\end%s?%{ekdverse%}", function(arg)
			arg = string.gsub(arg, "\\par%s?", "")
			return "\\p@rb "..linestotei(string.format("<lg>%s</lg>", arg)).."\\p@ra "
   end)
   str = string.gsub(str, "\\begin%s?%{verse%}%b[](.-)\\end%s?%{verse%}", function(arg)
			arg = string.gsub(arg, "\\par%s?", "")
			return "\\p@rb "..linestotei(string.format("<lg>%s</lg>", arg)).."\\p@ra "
   end)
   str = string.gsub(str, "\\begin%s?%{verse%}(.-)\\end%s?%{verse%}", function(arg)
			arg = string.gsub(arg, "\\par%s?", "")
			return "\\p@rb "..linestotei(string.format("<lg>%s</lg>", arg)).."\\p@ra "
   end)
   return str
end

local function envtotei(str)
   for i = 1,#envtotags
   do
      if envtotags[i].b ~= ""
      then
	 if isfound(close_p, envtotags[i].b) or envtotags[i].d == "yes"
	 then
	    str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
			  * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
			  * bsqbracketsii * bcbracesii * spcenc^-1,
		       "\\p@rb <"..envtotags[i].b..envtotags[i].c..">")
	    str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
			  * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
		       "</"..envtotags[i].b..">\\p@ra ")
	 else
	    str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
			  * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
			  * bsqbracketsii * bcbracesii * spcenc^-1,
		       "<"..envtotags[i].b..envtotags[i].c..">")
	    str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
			  * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
		       "</"..envtotags[i].b..">")
	 end
      else
	 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
		       * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
		       * bsqbracketsii * bcbracesii * spcenc^-1,
		    "")
	 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
		       * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
		    "")
      end
   end
   str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
		 * lpeg.Cs(ascii^1) * lpeg.P("}") * bsqbracketsii
		 * bcbracesii * spcenc^-1,
	      "<%1>")
   str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
		 * lpeg.Cs(ascii^1) * lpeg.P("}") * bsqbracketsii
		 * bcbracesii,
	      "</%1>")
   return str
end

local function texpatttotei(str)
   for i = 1,#texpatttotags do
      str = string.gsub(str, texpatttotags[i].a, texpatttotags[i].b)
      str = string.gsub(str, "ekd@ob%{", "")
      str = string.gsub(str, "%}ekd@cb", "")
      str = string.gsub(str, "ekd@os%[", "")
      str = string.gsub(str, "%]ekd@cs", "")
   end
   return str
end

local function icitetotei(str)
   str = gsub(str, lpeg.P("\\")
		 * citecmds
		 * spcenc^-1
		 * bsqbrackets
		 * bsqbrackets
		 * bcbraces
		 * (bsqbrackets + bcbraces)^-1,
	      function(cmd, pre, post, body, opt)
		 pre = string.sub(pre, 2, -2)
		 post = string.sub(post, 2, -2)
		 body = string.sub(body, 2, -2)
		 if not checkxmlid(body)
		 then
		    tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
				 ..body..
				 "\" is not a valid xml:id. \\MessageBreak "
				 ..
				 "Please pick another id.}}")
		 else
		 end
		 return string.format("%s <ref target=\"#%s\">%s</ref>", pre, body, post)
   end)
   str = gsub(str, lpeg.P("\\")
		 * citecmds
		 * spcenc^-1
		 * bsqbrackets
		 * bcbraces
		 * (bsqbrackets + bcbraces)^-1,
	      function(cmd, post, body, opt)
		 post = string.sub(post, 2, -2)
		 body = string.sub(body, 2, -2)
		 if not checkxmlid(body)
		 then
		    tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
				 ..body..
				 "\" is not a valid xml:id. \\MessageBreak "
				 ..
				 "Please pick another id.}}")
		 else
		 end
		 return string.format("<ref target=\"#%s\">%s</ref>", body, post)
   end)
   str = gsub(str, lpeg.P("\\")
		 * citecmds
		 * spcenc^-1
		 * bcbraces
		 * (bsqbrackets + bcbraces)^-1,
	      function(cmd, body, opt)
		 body = string.sub(body, 2, -2)
		 if not checkxmlid(body)
		 then
		    tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
				 ..body..
				 "\" is not a valid xml:id. \\MessageBreak "
				 ..
				 "Please pick another id.}}")
		 else
		 end
		 return string.format("<ptr target=\"#%s\"/>", body)
   end)
   return str
end

local function cmdtotei(str)
   for i = 1,#cmdtotags
   do
      str = gsub(str, lpeg.P("\\") * lpeg.Cs(cmdtotags[i].a) * spcenc^-1 * bsqbrackets * -bcbraces, "\\%1%2{}")
      str = gsub(str, lpeg.P("\\") * lpeg.Cs(cmdtotags[i].a) * spcenc^-1 * -(bsqbrackets + bcbraces), "\\%1[]{}")
      str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?%*?(%b{})", "%1[]%2")
      str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?%*?(%b[])(%b{})",
			function(cmd, arg, body)
			   body = string.sub(body, 2, -2)
			   arg = string.sub(arg, 2, -2)
			   arg = string.gsub(arg, "(%b{})", function(braces)
						braces = string.sub(braces, 2, -2)
						return string.format("\"%s\"", braces)
			   end)
			   body = cmdtotei(body)
			   -- return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s</"..cmdtotags[i].b..">", arg, body)
			   if cmdtotags[i].b ~= ""
			   then
			      return string.format("<"..cmdtotags[i].b..cmdtotags[i].c..">%s</" ..
						   cmdtotags[i].b..">", body)
			   else
			      return ""
			   end
      end)
   end
   -- temporarily:
   str = string.gsub(str, "\\(getsiglum)%s?(%b{})",
		     function(cmd, body)
			body = string.sub(body, 2, -2)
			teisiglum = ekdosis.getsiglum(body, "tei")
 			printsiglum = ekdosis.getsiglum(body)
 			-- body = cmdtotei(body)
			return string.format("<ref target=\"%s\">%s</ref>",
					     teisiglum, printsiglum)
   end)
   str = string.gsub(str, "\\(gap)%s?(%b{})",
		     function(cmd, body)
			body = string.sub(body, 2, -2)
			teireason = get_attr_value(body, "reason")
			if teireason ~= "" then teireason = " reason=\""..teireason.."\"" else end
			teiunit = get_attr_value(body, "unit")
			if teiunit ~= "" then teiunit = " unit=\""..teiunit.."\"" else end
			teiquantity = get_attr_value(body, "quantity")
			if teiquantity ~= "" then teiquantity = " quantity=\""..teiquantity.."\"" else end
			teiextent = get_attr_value(body, "extent")
			if teiextent ~= "" then teiextent = " extent=\""..teiextent.."\"" else end
			return string.format("<gap%s%s%s%s/>", teireason, teiunit, teiquantity, teiextent)
   end)
   str = gsub(str, lpeg.P("\\") * labelrefcmds * spcenc^-1 * bcbraces,
	      function(cmd, body)
		 body = string.sub(body, 2, -2)
		 if not checkxmlid(body)
		 then
		    tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
				 ..body..
				 "\" is not a valid xml:id. \\MessageBreak "
				 ..
				 "Please pick another id.}}")
		 else
		 end
		 if string.find(cmd, "label")
		 then
		    return string.format("<anchor xml:id=\"%s\"/>", body)
		 else
		    return string.format("<ptr target=\"#%s\"/>", body)
		 end
   end)
   str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})",
		     function(cmd, opt, body)
			body = string.sub(body, 2, -2)
			body = cmdtotei(body)
			return string.format("<%s>%s</%s>", cmd, body, cmd)
   end)
   str = string.gsub(str, "\\(%a+)%s?%*?(%b{})",
		     function(cmd, body)
			body = string.sub(body, 2, -2)
			body = cmdtotei(body)
			return string.format("<%s>%s</%s>", cmd, body, cmd)
   end)
   str = string.gsub(str, "(%s)(%>)", "%2")
   return str
end

local teiautopar = true

function ekdosis.setteiautopar(choice)
   if choice == "yes"
   then
      teiautopar = true
   else
      teiautopar = false
   end
   return true
end

local function partotei(str)
   if teiautopar
   then
      str = gsub(str, lpeg.P(lpeg.P("\\par") * spcenc^1)^1, "\\par ")
      str = gsub(str, ((para + parb) * par^-1)^2, "\\p@r ")
      str = string.gsub(str, "\\p@ra%s+", "<p>")
      str = string.gsub(str, "\\p@rb%s+", "</p>")
      str = string.gsub(str, "\\p@r%s+", "")   
      str = string.gsub(str, "%s?\\par%s?", "<p>", 1)
      str = string.gsub(str, "(%<p%>)(%s-)(%<%/?div%d?)", "%3")
      str = string.gsub(str, "%s?\\par%s?", "</p><p>")
      str = string.gsub(str, "<p>%s?</p>", "")
      str = string.gsub(str, "(%<p%>)%s?(%</div%>)$", "%2")
      str = string.gsub(str, "(%<p%>)%s?$", "")
      str = string.gsub(str, "(<p>)%s?(<div.->)", "%2%1")
   else
      str = gsub(str, par + para + parb, "")
   end
   return str
end

local function self_close_tags(str)
   str = gsub(str, lpeg.P("<" * -lpeg.S("/"))
		 * lpeg.Cs(letters^1)
		 * lpeg.Cs((1 - lpeg.S"<>")^0)
		 * lpeg.P(">")
		 * lpeg.P("</")
		 * lpeg.Cs(letters^1)
		 * lpeg.P(">"), function(ftag, arg, ltag)
		    if ftag == ltag
		    then
		       return string.format("<%s%s/>", ftag, arg)
		    else
		    end
   end)
   return str
end

--headers and footers
local hfmarks = {}

function ekdosis.storehfmark(page, mk)
   table.insert(hfmarks, {a = page, mark = mk})
   return true
end

function ekdosis.gethfmark(page)
   local indexpage = get_a_index(page, hfmarks)
   if hfmarks[indexpage] ~= nil
   then
      return hfmarks[indexpage].mark
   else
      return "nil"
   end
end

local divdepth = {
   book = 1,
   part = 2,
   chapter = 3,
   section = 4,
   subsection = 5,
   subsubsection = 6
}

function ekdosis.mkdivdepths(...)
   divdepth = {}
   local num = 1
   for _, y in ipairs{...}
   do
      if y == "book" or "part" or "chapter"
	 or "section" or "subsection" or "subsubsection"
      then
	 divdepth[y] = num
	 num = num + 1
      else
      end
   end
   return true
end

-- LaTeX side: format the divisions
local fmtdiv = {}

function ekdosis.fmtdiv(n, fmtb, fmte)
   if isintable(fmtdiv, n)
   then
      local index = get_a_index(n, fmtdiv)
      table.remove(fmtdiv, index)
   else
   end
   table.insert(fmtdiv, { a = n, formatb = fmtb, formate = fmte} )
   return true
end

function ekdosis.getfmtdiv(n, pos)
   local index = get_a_index(n, fmtdiv)
   if index ~= nil
   then
      if pos == "b"
      then
	 return fmtdiv[index].formatb
      elseif pos == "e"
      then
	 return fmtdiv[index].formate
      end
   else
      return ""
   end
end

local ekddivs = true

function ekdosis.setekddivsfalse()
   ekddivs = false
end

local function ekddivs_totei(str)
   str = gsub(str, dblbkslash * lpeg.Cs("ekddiv") * spce^-1 * bcbraces,
	      function(bkslash, cmd, space, arg)
		 if ekddivs
		 then
		    arg = string.sub(arg, 2, -2)
		    teitype = get_attr_value(arg, "type")
		    tein = get_attr_value(arg, "n")
		    teihead = get_attr_value(arg, "head")
		    teidepth = get_attr_value(arg, "depth")
		    if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
		    if tein ~= "" then tein = " n=\""..tein.."\"" else end
		    if teidepth ~= ""
		    then
		       teidepth = " depth=\""..teidepth.."\""
		    else
		       teidepth = " depth=\"1\""
		    end
		    return string.format("\\p@rb <div%s%s%s><head>%s</head>\\p@ra ",
					 teitype, tein, teidepth, teihead)
		 else
		    return ""
		 end
   end)
   return str
end

local function section_totei(str)
   str = gsub(str, dblbkslash * sections * spce^-1 * bcbraces, "%1%2%3[]%4")
   str = gsub(str, dblbkslash * sections * spce^-1 * bsqbrackets * bcbraces,
	      function(bkslash, secname, space, opt, arg)
		 if ekddivs
		 then
		    return ""
		 else
		    ctr = divdepth[secname]
		    arg = string.sub(arg, 2, -2)
		    return string.format("\\p@rb <div%s type=\"%s\"><head>%s</head>\\p@ra ",
					 ctr, secname, arg)
		 end
   end)
   return str
end

local used_ndivs = {}

local function close_ekddivs_at_end(str)
   local isdiv = false
   if string.find(str, "</div>$")
   then
      isdiv = true
      str = string.gsub(str, "(.*)(</div>)$", "%1")
   else
   end
   -- collect used depth numbers
   for i in string.gmatch(str, "<div .-depth%=\"%d\".->")
   do
      i = string.match(i, "depth=\"%d\"")
      i = string.match(i, "%d")
      if isintable(used_ndivs, i)
      then
      else
	 table.insert(used_ndivs, {a = i} )
      end
   end
   if next(used_ndivs) ~= nil
   then
      table.sort(used_ndivs, function(a ,b) return(#a.a > #b.a) end)
   else
   end
   local firstdiv = string.match(str, "<div .-depth%=\"%d\".->") or ""
   firstdiv = string.match(firstdiv, "depth%=\"%d\"") or ""
   firstdiv = string.match(firstdiv, "%d") or ""
   local lastdiv = string.match(string.reverse(str), ">.-\"%d\"%=htped.- vid<") or ""
   lastdiv = string.match(lastdiv, "\"%d\"%=htped") or ""
   lastdiv = string.match(lastdiv, "%d") or ""
   local firstdivindex = get_a_index(firstdiv, used_ndivs)
   local lastdivindex = get_a_index(lastdiv, used_ndivs)
   firstdivindex = tonumber(firstdivindex)
   lastdivindex = tonumber(lastdivindex)
   local closedivs = ""
   if isintable(used_ndivs, firstdiv)
   then
      while lastdivindex >= firstdivindex
      do
	 closedivs = closedivs.."</div>"
	 lastdivindex = lastdivindex - 1
      end
   end
   if isdiv
   then
      return str..closedivs.."</div>"
   else
      return str..closedivs
   end
end

local function close_ndivs_at_end(str)
   local isdiv = false
   if string.find(str, "</div>$")
   then
      isdiv = true
      str = string.gsub(str, "(.*)(</div>)$", "%1")
   else
   end
   -- collect used div numbers
   for i in string.gmatch(str, "<div[1-6]")
   do
      i = string.match(i, "[1-6]")
      if isintable(used_ndivs, i)
      then
      else
   	 table.insert(used_ndivs, {a = i} )
      end
   end
   if next(used_ndivs) ~= nil
   then
      table.sort(used_ndivs, function(a ,b) return(#a.a > #b.a) end)
   else
   end
   local firstdiv = string.match(str, "<div[1-6]") or ""
   firstdiv = string.match(firstdiv, "[1-6]") or ""
   local lastdiv = string.match(string.reverse(str), "[1-6]vid<") or ""
   lastdiv = string.match(lastdiv, "[1-6]") or ""
   local firstdivindex = get_a_index(firstdiv, used_ndivs)
   local lastdivindex = get_a_index(lastdiv, used_ndivs)
   firstdivindex = tonumber(firstdivindex)
   lastdivindex = tonumber(lastdivindex)
   local closedivs = ""
   if isintable(used_ndivs, firstdiv)
   then
      while lastdivindex >= firstdivindex
      do
	 closedivs = closedivs.."</div"..used_ndivs[lastdivindex].a..">"
	 lastdivindex = lastdivindex - 1
      end
   end
   if isdiv
   then
      return str..closedivs.."</div>"
   else
      return str..closedivs
   end
end

local function close_ekddivs_in_between(str)
   local maxdepth = 1
   for i in string.gmatch(str, "<div.-depth=\"(%d)\".->", "%1")
   do
      if tonumber(i) > tonumber(maxdepth)
      then
	 maxdepth = i
      else
      end
   end
   for ndivi = 1, maxdepth
   do
      str = string.gsub(str, "(<div [^%>]-[Dd]epth%=\")("..ndivi..")(\".->)(.-)(<div [^%>]-depth%=\")(%d)(\".->)",
			function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
			   local firstdiv = ndivi
			   local lastdiv = ndivii
			   local firstdivindex = get_a_index(firstdiv, used_ndivs)
			   local lastdivindex = get_a_index(lastdiv, used_ndivs)
			   firstdivindex = tonumber(firstdivindex)
			   lastdivindex = tonumber(lastdivindex)
			   local closedivs = ""
			   if firstdivindex >= lastdivindex
			   then
			      while firstdivindex >= lastdivindex
			      do
				 closedivs = closedivs.."</div>"
				 firstdivindex = firstdivindex - 1
			      end
			   end
			   bdivii = string.gsub(bdivii, "depth", "Depth")
			   return string.format("%s%s%s%s%s%s%s%s",
						bdivi, ndivi, edivi, between,
						closedivs, bdivii, ndivii, edivii)
      end)
   end
   return str
end

local function clean_ekddivs(str)
   str = string.gsub(str, "(<div.-)(%s[Dd]epth%=\"%d\")(.->)", "%1%3")
   used_ndivs = {}
   return str
end

local function close_ndivs_in_between(str)
   for ndivi = 1, 6
   do
      str = string.gsub(str, "(<[Dd]iv)("..ndivi..")(.->)(.-)(<div)([1-6])(.->)",
			function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
			   local firstdiv = ndivi
			   local lastdiv = ndivii
			   local firstdivindex = get_a_index(firstdiv, used_ndivs)
			   local lastdivindex = get_a_index(lastdiv, used_ndivs)
			   firstdivindex = tonumber(firstdivindex)
			   lastdivindex = tonumber(lastdivindex)
			   local closedivs = ""
			   if firstdivindex >= lastdivindex
			   then
			      while firstdivindex >= lastdivindex
			      do
			   	 closedivs = closedivs.."</div"..used_ndivs[firstdivindex].a..">"
			   	 firstdivindex = firstdivindex - 1
			      end
			   end
			   bdivii = string.gsub(bdivii, "div", "Div")
			   return string.format("%s%s%s%s%s%s%s%s",
						bdivi, ndivi, edivi, between,
						closedivs, bdivii, ndivii, edivii)
   end)
   end
   return str
end

local function clean_latexdivs(str)
   str = string.gsub(str, "(<Div)([1-6])(.->)", "<div%2%3")
   used_ndivs = {}
   return str
end

local function textotei(str)
   str = xml_entities(str)
   str = texpatttotei(str)
   str = note_totei(str)
   str = remove_extra_anchors(str)
   str = app_totei(str)
   str = rdgGrp_totei(str)
   str = lem_rdg_totei(str)
   str = relocate_notes(str)
   str = stanzatotei(str)
   str = versetotei(str)
   str = envtotei(str)
   str = ekddivs_totei(str)
   str = section_totei(str)
   str = icitetotei(str)
   str = cmdtotei(str)
   str = self_close_tags(str)
   str = partotei(str)
   if ekddivs
   then
      str = close_ekddivs_at_end(str)
      str = close_ekddivs_in_between(str)
      str = close_ekddivs_in_between(str)
      str = clean_ekddivs(str)
   else
      str = close_ndivs_at_end(str)
      str = close_ndivs_in_between(str)
      str = close_ndivs_in_between(str)
      str = clean_latexdivs(str)
   end
   return str
end

local teifilename = tex.jobname.."-tei"

function ekdosis.setteifilename(str)
   teifilename = str
   return true
end

function ekdosis.openteistream()
   local f = io.open(teifilename.."_tmp.xml", "a+")
   f:write('<?xml version="1.0" encoding="utf-8"?>', "\n")
   f:write("<TEI xmlns=\"http://www.tei-c.org/ns/1.0\">", "\n")
   f:write("<teiHeader>", "\n")
   f:write("<fileDesc>", "\n")
   f:write("<titleStmt>", "\n")
   f:write("<title><!-- Title --></title>", "\n")
   f:write("<respStmt>", "\n")
   f:write("<resp><!-- Edited by --></resp>", "\n")
   f:write("<name><!-- Name --></name>", "\n")
   f:write("</respStmt>", "\n")
   f:write("</titleStmt>", "\n")
   f:write("<publicationStmt>", "\n")
   f:write("<distributor><!-- Distributor name  --></distributor>", "\n")
   f:write("</publicationStmt>", "\n")
   f:write("<sourceDesc>", "\n")
   if next(listWit) == nil and next(listPerson) == nil
   then
      f:write("<p>No source, born digital</p>", "\n")
   else
      if next(listWit) ~= nil
      then
	 f:write("<listWit>", "\n")
	 for i = 1,#listWit do
	    f:write('<witness xml:id=\"', listWit[i].xmlid, "\">", "\n")
	    f:write('<abbr type="siglum">', textotei(listWit[i].abbr), "</abbr>", "\n")
	    f:write(textotei(listWit[i].detailsDesc), "\n")
	    f:write("<msDesc>", "\n")
	    if listWit[i].msIdentifier.settlement == ""
	       and listWit[i].msIdentifier.institution == ""
	       and listWit[i].msIdentifier.repository == ""
	       and listWit[i].msIdentifier.collection == ""
	       and listWit[i].msIdentifier.idno == ""
	       and listWit[i].msIdentifier.msName == ""
	    then
	       f:write("<msIdentifier/>", "\n")
	    else
	       f:write("<msIdentifier>", "\n")
	       if listWit[i].msIdentifier.settlement ~= "" then
		  f:write("<settlement>", textotei(listWit[i].msIdentifier.settlement), "</settlement>", "\n")
	 else end
	       if listWit[i].msIdentifier.institution ~= "" then
		  f:write("<institution>", textotei(listWit[i].msIdentifier.institution), "</institution>", "\n")
	 else end
	       if listWit[i].msIdentifier.repository ~= "" then
		  f:write("<repository>", textotei(listWit[i].msIdentifier.repository), "</repository>", "\n")
	 else end
	       if listWit[i].msIdentifier.collection ~= "" then
		  f:write("<collection>", textotei(listWit[i].msIdentifier.collection), "</collection>", "\n")
	 else end
	       if listWit[i].msIdentifier.idno ~= "" then
		  f:write("<idno>", textotei(listWit[i].msIdentifier.idno), "</idno>", "\n")
	 else end
	       if listWit[i].msIdentifier.msName ~= "" then
		  f:write("<msName>", textotei(listWit[i].msIdentifier.msName), "</msName>", "\n")
	 else end
	       f:write("</msIdentifier>", "\n")
	    end
	    if listWit[i].handDesc ~= nil then
	       f:write("<physDesc>", "\n")
	       f:write("<handDesc hands=\"", #listWit[i].handDesc, "\">", "\n")
	       local j = 1
	       while listWit[i].handDesc[j]
	       do
		  f:write("<handNote xml:id=\"", listWit[i].handDesc[j].xmlid, "\">", "\n")
		  f:write('<abbr type="siglum">', textotei(listWit[i].handDesc[j].abbr), "</abbr>", "\n")
		  f:write("<p>", textotei(listWit[i].handDesc[j].detailsDesc), "</p>", "\n")
		  f:write("</handNote>", "\n")
		  j = j + 1
	       end
	       f:write("</handDesc>", "\n")
	       f:write("</physDesc>", "\n")
	    else end
	    if listWit[i].msContents ~= nil then
	       f:write("<msContents>", "\n")
	       f:write("<msItem>", "\n")
	       f:write("<locus>", textotei(listWit[i].msContents.msItem.locus), "</locus>", "\n")
	       f:write("</msItem>", "\n")
	       f:write("</msContents>", "\n")
	    end
	    if listWit[i].history ~= nil then
	       f:write("<history>", "\n")
	       f:write("<origin>", "\n")
	       f:write("<origDate>", textotei(listWit[i].history.origin.origDate), "</origDate>", "\n")
	       f:write("</origin>", "\n")
	       f:write("</history>", "\n")
	    end
	    f:write("</msDesc>", "\n")
	    f:write("</witness>", "\n")
	 end
	 f:write("</listWit>", "\n")
      end
      if next(listPerson) ~= nil
      then
	 f:write("<listPerson xml:id=\"scholars\">", "\n")
	 for i = 1,#listPerson do
	    f:write('<person xml:id=\"', listPerson[i].xmlid, "\">", "\n")
	    f:write('<persName>', "\n")
	    f:write('<abbr type="siglum">', textotei(listPerson[i].abbr), "</abbr>", "\n")
	    if listPerson[i].persName.name ~= nil
	    then
	       f:write(textotei(listPerson[i].persName.name))
	    else
	       if listPerson[i].persName.forename ~= ""
	       then
		  f:write("<forename>", textotei(listPerson[i].persName.forename), "</forename>", "\n")
	       else
		  f:write("<forename><!-- forename --></forename>", "\n")
	       end
	       if textotei(listPerson[i].persName.surname) ~= ""
	       then
		  f:write("<surname>", textotei(listPerson[i].persName.surname), "</surname>", "\n")
	       else
		  f:write("<surname><!-- surname --></surname>", "\n")
	       end
	       if textotei(listPerson[i].persName.addName) ~= ""
	       then
		  f:write("<addName>", textotei(listPerson[i].persName.addName), "</addName>", "\n")
	       end
	    end
	    if listPerson[i].note ~= ""
	    then
	       f:write("<note>", textotei(listPerson[i].note), "</note>", "\n")
	    end
	    f:write('</persName>', "\n")      
	    f:write('</person>', "\n")      
	 end
	 f:write("</listPerson>", "\n")
      end
   end
   f:write("</sourceDesc>", "\n")
   f:write("</fileDesc>", "\n")
   f:write("<encodingDesc>", "\n")
   f:write('<variantEncoding method="parallel-segmentation" location="internal"/>', "\n")
   f:write("</encodingDesc>", "\n")
   f:write("</teiHeader>", "\n")
   f:write("<text>", "\n")
   f:write("<body>", "\n")
   f:close()
   return true
end

local tidy = nil

local function cleanup_tei()
   local f = assert(io.open(teifilename.."_tmp.xml", "r"))
   t = f:read("*a")
   t = string.gsub(t, "%<p%>%s?%</p%>", "")
   t = string.gsub(t, "^\n", "")
   f:close()
   local fw = assert(io.open(teifilename.."_tmp.xml", "w"))
   fw:write(t)
   fw:close()
   return true
end

function ekdosis.closeteistream(opt)
   local f = io.open(teifilename.."_tmp.xml", "a+")
   f:write("\n", "</body>", "\n")
   if xmlbibresource ~= nil then
      bibf = assert(io.open(xmlbibresource, "r"))
      t = bibf:read("*a")
      t = string.gsub(t, "%s+corresp%=%b\"\"", "")
      t = string.gsub(t, "\n\n", "\n")
      f:write("<back>", "\n")
      f:write("<listBibl>", "\n")
      for i in string.gmatch(t, "<biblStruct.->.-</biblStruct>")
      do
	 f:write(i, "\n")
      end
      f:write("</listBibl>", "\n")
      f:write("</back>", "\n")
      bibf:close()
   else
   end
   f:write("</text>", "\n")
   f:write("</TEI>", "\n")
   f:close()
   cleanup_tei()
   os.remove(teifilename..".xml")
   os.rename(teifilename.."_tmp.xml", teifilename..".xml")
   if opt == "tidy" then
      os.execute("tidy -qmi -xml --output-xml yes "..teifilename..".xml")
   else
   end
   return true
end

function ekdosis.exporttei(str)
   local f = io.open(teifilename.."_tmp.xml", "a+")
   -- f:write("\n<p>")
   str = textotei(str)
   f:write(str)
   f:close()
   return true
end
-- end totei functions

-- begin basic TeX Conspectus siglorum
function ekdosis.basic_cs(msid)
   local indexwit = getindex(msid, listWit)
   siglum = listWit[indexwit].abbr
   -- if listWit[indexwit].detailsDesc == ""
   -- then
   -- name = listWit[indexwit].msIdentifier.msName
   -- else
   --    name = listWit[indexwit].msIdentifier.msName
   -- 	 .."\\thinspace\\newline\\bgroup\\footnotesize{}"..
   -- 	 listWit[indexwit].detailsDesc
   -- 	 .."\\egroup{}"
   -- end
   name = listWit[indexwit].detailsDesc
   if listWit[indexwit].history ~= nil
      and
      listWit[indexwit].history.origin ~= nil
   then
      date = listWit[indexwit].history.origin.origDate
   else
      date = ""
   end
   if listWit[indexwit].msContents ~= nil
      and
      listWit[indexwit].msContents.msItem ~= nil
   then
      locus = listWit[indexwit].msContents.msItem.locus
   else
      locus = ""
   end
   return siglum.."&"..name.." "..locus.."&"..date
end
-- end basic TeX Conspectus siglorum

function ekdosis.removesp(str)
   str = gsub(str, cmd * cmdargs * spcenc^-1, "%1%2")
   return str
end

function ekdosis.closestream()
   os.remove(tex.jobname..".ekd")
   os.rename(tex.jobname.."_tmp.ekd", tex.jobname..".ekd")
   return true
end

local cur_abs_pg = 0
local pg_i = nil
local pg_ii = nil
local prevcol = nil
local curcol = "x"

local check_resetlineno = {}

function ekdosis.update_abspg(n) -- not used
   cur_abs_pg = n
   return true
end

function ekdosis.storeabspg(n, pg)
   if pg == "pg_i" then
      pg_i = n
   elseif pg == "pg_ii" then
      pg_ii = n
      table.insert(check_resetlineno, curcol.."-"..pg_ii)
   end
   cur_abs_pg = n
   return true
end

function ekdosis.checkresetlineno()
   if isfound(check_resetlineno, curcol.."-"..pg_i)
   then
      return ""
   else
      return "\\resetlinenumber"
   end
end

--
-- Build environments to be aligned
--

local cur_alignment = "-"
local cur_alignment_patt = "%-"
local cur_alignment_cnt = 1

local newalignment = false
function ekdosis.newalignment(str)
   if str == "set"
   then
      newalignment = true
      cur_alignment = "-"..cur_alignment_cnt.."-"
      cur_alignment_patt = "%-"..cur_alignment_cnt.."%-"
      cur_alignment_cnt = cur_alignment_cnt + 1
   elseif str == "reset"
   then
      newalignment = false
      cur_alignment = "-"
      cur_alignment_patt = "%-"
   end
   return true
end

local aligned_texts = {}
local texts_w_apparatus = {}
local coldata_totei = {}

local function sanitize_envdata(str)  -- look for a better way to achieve this
   str = string.gsub(str, "(%a+)%s+(%b[])", "%1%2")
   str = string.gsub(str, "(%a+)(%b[])%s+", "%1%2")
   str = string.gsub(str, "%s+(%a+)(%b[])", "%1%2")
   str = gsub(str, lpeg.Cs(letters^1)
		 * spcenc^-1
		 * -bsqbrackets
		 * lpeg.Cs(";"), "%1[]%2")
   str = string.gsub(str, "%s+(%a+)(%b[])", "%1%2")
   return str
end

function ekdosis.mkenvdata(str, opt)
   if not string.find(str, "%;", -1) then str = str .. ";" else end
   --   str = str ..";"
   --   str = string.gsub(str, "%s+", "")
   local fieldstart = 1
   local col = 0
   if opt == "texts" then
      str = sanitize_envdata(str)
      repeat
	 local _s, nexti = string.find(str, "%b[]%s-%;", fieldstart)
	 local namediv = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%1")
	 local attr = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%2")
	 attr = string.sub(attr, 2, -2)
	 if forbid_xmlid
	 then
	    attr = string.gsub(attr, "xml:id", "n") -- xml:id is not allowed here
	 else
	 end
	 table.insert(aligned_texts, { text = namediv,
				       attribute = attr,
				       column = col })
	 table.insert(coldata_totei, { environment = namediv,
				       data = {} })
	 col = col + 1
	 fieldstart = nexti + 1
      until fieldstart > string.len(str)
      return aligned_texts
   elseif opt == "apparatus" then
      repeat
	 local nexti = string.find(str, "%;", fieldstart)
	 table.insert(texts_w_apparatus, string.sub(str, fieldstart, nexti-1))
	 fieldstart = nexti +1
      until fieldstart > string.len(str)
      return texts_w_apparatus
   end
end

-- Reminder: the following two variables are already set above
-- local prevcol = nil
-- local curcol = "x"

function ekdosis.storecurcol(n)
      curcol = n
   return true
end

function ekdosis.flushcolnums()
   prevcol = nil
   curcol = "x"
   return true
end

function ekdosis.flushenvdata()
   aligned_texts = {}
   texts_w_apparatus = {}
   coldata_totei = {}
   return true
end

function ekdosis.storecoldata(nthcol, chunk)
   local tindex = tonumber(nthcol) + 1
   table.insert(coldata_totei[tindex].data, chunk)
   return true
end

local environment_div = {}

local function build_envdiv(str)
   if not environment_div[str]
   then
      environment_div[str] = 1
   else
      environment_div[str] = environment_div[str] + 1
   end
   local div = "div-"..str.."_"..environment_div[str]
   if xmlidfound(div)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
		   ..div..
		   "\" already exists as an xml:id. " 
		   ..
		   "ekdosis has generated some random id.}}")
      return "div-"..math.random(1000,9999)
   elseif not checkxmlid(div)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
      	 ..div..
      	 "\" is not a valid xml:id. \\MessageBreak "
      	 ..
      	 "Please pick another id.}}")
   else
      table.insert(xmlids, {xmlid = div})
      table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
      return div
   end
end

function ekdosis.mkenv()
   local environments = {}
   for i = 1,#aligned_texts
   do
      if isfound(texts_w_apparatus, aligned_texts[i].text)
      then
	 table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{+b}"
			 .."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}"
			 .."\\par"
			 .."\\EkdosisColStart"
			 .."\\EkdosisOn#1"
		         .."}{\\EkdosisOff"
			 .."\\EkdosisColStop"
		         .."\\end{nthcolumn}"
			 .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
			 .. aligned_texts[i].column
			 ..", \\luastringN{\\par#1\\par})}\\fi"
			 .."}")
	 table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{+b}"
			 .."{\\begin{nthcolumn*}{".. aligned_texts[i].column.."}[]"
			 .."\\par"
			 .."\\EkdosisColStart"
			 .."\\EkdosisOn#1"
		         .."}{\\EkdosisOff"
			 .."\\EkdosisColStop"
		         .."\\end{nthcolumn*}"
			 .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
			 .. aligned_texts[i].column
			 ..", \\luastringN{\\par#1\\par})}\\fi"
			 .."}")
      else
	 table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{+b}"
			 .."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}"
			 .."\\par"
			 .."#1"
		         .."}{\\end{nthcolumn}"
			 .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
			 .. aligned_texts[i].column
			 ..", \\luastringN{\\par#1\\par})}\\fi"
			 .."}")
	 table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{+b}"
			 .."{\\begin{nthcolumn*}{"..aligned_texts[i].column.."}[]"
			 .."\\par"
			 .."#1"
			 .."}{"
		         .."\\end{nthcolumn*}"
			 .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
			 .. aligned_texts[i].column
			 ..", \\luastringN{\\par#1\\par})}\\fi"
			 .."}")
      end
      forbid_xmlid = false
      if aligned_texts[i].attribute ~= ""
      then
	 ekdosis.newenvtotag(aligned_texts[i].text, "div",
			     "xml:id=\""
				..build_envdiv(aligned_texts[i].text)
				.."\" "
				..aligned_texts[i].attribute)
      else
	 ekdosis.newenvtotag(aligned_texts[i].text, "div",
			     "xml:id=\""
				..build_envdiv(aligned_texts[i].text)
				.."\"")
      end
      forbid_xmlid = true
   end
   str = table.concat(environments)
   return str
end

function ekdosis.export_coldata_totei()
   for i = 1,#coldata_totei
   do
      ekdosis.exporttei("\\begin{".. coldata_totei[i].environment .."}"
			   .. table.concat(coldata_totei[i].data)
			.. "\\end{".. coldata_totei[i].environment .."}")
   end
end

-- handle multiple layers in apparatuses
--
local apparatuses = {}
local bagunits = {}

function ekdosis.newapparatus(teitype,
			      appdir,
			      apprule,
			      appdelim,
			      appsep,
			      appbhook,
			      appehook,
			      applimit,
			      applang,
			      appnotelang)
   if isintable(apparatuses, teitype)
   then
      tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
		   ..teitype..
		   "\" already exists.}}")
   else
      table.insert(apparatuses, {a = teitype,
				 direction = appdir,
				 rule = apprule,
				 delim = appdelim,
				 sep = appsep,
				 bhook = appbhook,
				 ehook = appehook,
				 limit = applimit,
				 lang = applang,
				 notelang = appnotelang})
   end
   bagunits[teitype] = 1
   return true
end

function ekdosis.getapplang(teitype)
   i = get_a_index(teitype, apparatuses)
   if apparatuses[i].lang ~= ""
   then
      return apparatuses[i].lang
   else
      return "\\languagename"
   end
end

function ekdosis.getappnotelang(teitype)
   i = get_a_index(teitype, apparatuses)
   if apparatuses[i].notelang ~= ""
   then
      return apparatuses[i].notelang
   else
      return "\\languagename"
   end
end

function ekdosis.getappdelim(str)
   for i = 1,#apparatuses
   do
      if apparatuses[i].a == str then
	 delimfound = apparatuses[i].delim
	 break
      end
   end
   return delimfound
end

function ekdosis.get_bagunits(teitype)
   return bagunits[teitype]
end

local function getapplimit(teitype)
   for i = 1,#apparatuses
   do
      if apparatuses[i].a == teitype then
	 limitfound = apparatuses[i].limit
	 break
      end
   end
   if tonumber(limitfound) ~= nil
   then
      if tonumber(limitfound) < 10
      then
	 return 0
      else
	 return limitfound
      end
   else
      return 0
   end
end

function ekdosis.limit_bagunits(teitype)
   local limit = tonumber(getapplimit(teitype))
   if limit >= 10 and bagunits[teitype] > limit
   then
      bagunits[teitype] = 2
      return "\\pagebreak"
   else
      return ""
   end
end

function ekdosis.addto_bagunits(teitype, n)
   if tonumber(getapplimit(teitype)) ~= 0
   then
      n = tonumber(n)
      bagunits[teitype] = bagunits[teitype] - n
   end
end

function ekdosis.increment_bagunits(teitype)
   bagunits[teitype] = (bagunits[teitype] or 0) + 1
end

local function reset_bagunits()
   for i = 1,#apparatuses
   do
      bagunits[apparatuses[i].a] = 1
   end
end

function ekdosis.appin(str, teitype)
   local f = io.open(tex.jobname.."_tmp.ekd", "a+")
   if next(apparatuses) == nil
   then
      f:write("<", cur_abs_pg, cur_alignment, curcol, "-0>", str, "</",
	      cur_abs_pg, cur_alignment, curcol, "-0>\n")
   else
      for i = 1,#apparatuses
      do
	 if apparatuses[i].a == teitype then
	    appno = i
	    break
	 end
      end
      f:write("<", cur_abs_pg, cur_alignment, curcol, "-",
	      appno, ">", str, "</", cur_abs_pg, cur_alignment, curcol, "-", appno, ">\n")
   end
   f:close()
   return true
end

function ekdosis.appout()
   local file = io.open(tex.jobname..".ekd", "r")
   if file ~= nil then io.close(file)
      f = assert(io.open(tex.jobname..".ekd", "r"))
      t = f:read("*a")
      local output = {}
      if next(apparatuses) == nil then
	 -- table.insert(output, "BEGIN")
	 table.insert(output, "\\csname ekd@default@rule\\endcsname\\NLS")
	 table.insert(output, "\\csname ekd@begin@apparatus\\endcsname\\ignorespaces")
--	 table.insert(output, "\\noindent ")
	 for i in string.gmatch(t,
				"<"..cur_abs_pg
				   ..cur_alignment_patt
				   ..curcol.."%-0>.-</"
				   ..cur_abs_pg
				   ..cur_alignment_patt
				   ..curcol.."%-0>")
	 do
	    table.insert(output, i)
	 end
	 -- table.insert(output, "END")
      else
	 local appinserted = false
	 local n = 1
	 while apparatuses[n]
	 do
	    if string.match(t, "<"..cur_abs_pg
			       ..cur_alignment_patt
			       ..curcol.."%-"..n..">.-</"
			       ..cur_abs_pg
			       ..cur_alignment_patt
			       ..curcol.."%-"..n..">")
	    then
	       -- table.insert(output, "BEGIN")
	       table.insert(output, "\\bgroup{}")
	       if apparatuses[n].direction == "LR"
	       then
		  table.insert(output, "\\pardir TLT\\leavevmode\\textdir TLT{}")
	       elseif apparatuses[n].direction == "RL"
	       then
		  table.insert(output, "\\pardir TRT\\leavevmode\\textdir TRT{}")
	       end
	       if apparatuses[n].rule == "none"
	       then
		  if n > 1
		  then
		     if appinserted
		     then
			table.insert(output, "\\NLS{}")
		     end
		  else
		     table.insert(output, "\\noindent ")
		  end
	       elseif apparatuses[n].rule ~= ""
	       then
		  if n > 1
		  then
		     if appinserted
		     then
			table.insert(output, "\\NLS{}" .. apparatuses[n].rule .. "\\NLS{}")
		     else
			table.insert(output, apparatuses[n].rule .. "\\NLS{}")
		     end
		  else
--		     table.insert(output, "\\noindent ")
		     table.insert(output, apparatuses[n].rule .. "\\NLS{}")
		  end
	       else
		  if n > 1
		  then
		     if appinserted
		     then
			table.insert(output, "\\NLS\\csname ekd@default@rule\\endcsname\\NLS{}")
		     else
			table.insert(output, "\\csname ekd@default@rule\\endcsname\\NLS{}")
		     end
		  else
--		     table.insert(output, "\\noindent ")
		     table.insert(output, "\\csname ekd@default@rule\\endcsname\\NLS{}")
		  end
	       end
	       if apparatuses[n].sep ~= ""
	       then
		  table.insert(output, "\\edef\\ekdsep{" .. apparatuses[n].sep .. "}")
	       else
	       end
	       if apparatuses[n].bhook ~= ""
	       then
		  table.insert(output, apparatuses[n].bhook)
	       else
		  table.insert(output, "\\relax")
	       end
	       for i in string.gmatch(t,
				      "<"..cur_abs_pg
					 ..cur_alignment_patt
					 ..curcol.."%-"..n..">.-</"
					 ..cur_abs_pg
					 ..cur_alignment_patt
					 ..curcol.."%-"..n..">")
	       do
		  table.insert(output, i)
		  appinserted = true
	       end
	       if apparatuses[n].ehook ~= ""
	       then
		  table.insert(output, apparatuses[n].ehook)
	       else
	       end
	       table.insert(output, "\\egroup{}")
	       -- table.insert(output, "END")
	    end
	    n = n + 1
	 end
      end
      f:close()
      str = table.concat(output)
      str = string.gsub(str, "</"..cur_abs_pg..cur_alignment_patt..curcol.."%-[0-9]>", "")
      str = string.gsub(str, "<"..cur_abs_pg..cur_alignment_patt..curcol.."%-[0-9]>", " ")
      return str
   else
   end
end

function ekdosis.appin_out(str, nl)
   local f = io.open(tex.jobname.."_tmp.ekd", "a+")
   if nl == "yes" then
      f:write(str, "\n")
   else
      f:write(str)
   end
   f:close()
   return true
end

local curcol_curabspg = {}

function ekdosis.testapparatus()
   if isfound(curcol_curabspg, curcol.."-"..cur_abs_pg)
   then
      if newalignment
      then
	 if next(apparatuses) ~= nil then
	    reset_bagunits()
	 end
	 newalignment = false
	 return "\\booltrue{do@app}"
      else
	 return "\\boolfalse{do@app}"
      end
   else
      table.insert(curcol_curabspg, curcol.."-"..cur_abs_pg)
      if next(apparatuses) ~= nil then
	 reset_bagunits()
      end
      newalignment = false
      return "\\booltrue{do@app}"
   end
end

local function get_ln_prefix(x, y)
   for index = 1, string.len(x)
   do
      if string.sub(x, index, index) ~= string.sub(y, index, index)
      then
	 return string.sub(x, 1, index - 1)
      end
   end
end

function ekdosis.numrange(x, y)
  xstr = tostring(x)
  ystr = tostring(y)
  if x == y -- which will never apply
  then
     return "\\LRnum{" .. xstr .. "}"
  elseif string.len(xstr) ~= string.len(ystr)
  then
     return "\\LRnum{" .. xstr .. "}--\\LRnum{" .. ystr .. "}"
  else
    common = get_ln_prefix(xstr, ystr)
    if string.len(common) == 0
    then
       return "\\LRnum{" .. xstr .. "}--\\LRnum{" .. ystr .. "}"
    elseif string.sub(xstr, -2, -2) == "1"
    then
       return "\\LRnum{"
	  .. string.sub(common, 1, -2)
	  .. string.sub(xstr, string.len(common), -1)
	  .. "}--\\LRnum{"
	  .. string.sub(ystr, string.len(common), -1)
	  .. "}"
    else
       return "\\LRnum{"
	  .. string.sub(common, 1, -1)
	  .. string.sub(xstr, string.len(common) + 1, -1)
	  .. "}--\\LRnum{"
	  .. string.sub(ystr, string.len(common) + 1, -1)
	  .. "}"
    end
  end
end

local lnlabs = {}
local lnlab_salt = 0
local current_lnlab = nil
local prev_lnlab = nil
local prev_prev_lnlab = nil
local notelabs = {}
local current_notelab = nil
local prev_notelab = nil
local current_lemma = nil
local salt = 0

local function mdvisintable(table, value)
   for _, v in pairs(table) do
      if v == value then return true end
   end
   return false
end

function ekdosis.dolnlab(str)
   if prev_lnlab ~= nil then prev_prev_lnlab = prev_lnlab end
   prev_lnlab = current_lnlab
   current_lemma = str
   i = md5.sumhexa(str)
   if not mdvisintable(lnlabs, i) then
      table.insert(lnlabs, i)
   else
      i = i..salt
      table.insert(lnlabs, i)
      salt = salt + 1
   end
   current_lnlab = i
   return true
end

function ekdosis.getlnlab()
   return current_lnlab
end

function ekdosis.getprevlnlab()
   return prev_lnlab
end

function ekdosis.getprevprevlnlab()
   return prev_prev_lnlab
end

function ekdosis.setnotelab(str)
   current_notelab = str
   if isfound(notelabs, current_notelab)
   then
      return ""
   else
      table.insert(notelabs, current_notelab)
      return "\\linelabel{" .. current_notelab .. "}"
   end
end

function ekdosis.getnotelab()
   return current_notelab
end

function ekdosis.setprevnotelab(str)
   prev_notelab = str
   return true
end

function ekdosis.getprevnotelab()
   return prev_notelab
end

local cmdstorm = lpeg.P(lpeg.P("note")
			   + lpeg.P("linelabel")
			   + lpeg.P("index"))

local function remove_from_app(str)
   str = gsub(str, dblbkslash * cmdstorm * cmdargs, "")
   return str
end

function ekdosis.mdvappend(str, teitype)
   if teitype == nil
   then
   return "\\linelabel{" .. current_lnlab .. "-b}\\wordboundary{}"
      ..
      current_lemma
      ..
      "\\linelabel{" .. current_lnlab .. "-e}"
      ..
      "\\csname append@app\\endcsname{"
      .. remove_from_app(str) .. "}"
   else
   return "\\linelabel{" .. current_lnlab .. "-b}\\wordboundary{}"
      ..
      current_lemma
      ..
      "\\linelabel{" .. current_lnlab .. "-e}"
      ..
      "\\csname append@app\\endcsname" .. "[" .. teitype ..  "]{"
      .. remove_from_app(str) .. "}"
   end
end

% \end{ekdlua}
% \end{comment}
% \iffalse
%</lua>
% \fi
% 
\endinput