summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/ledmac/ledpar.dtx
blob: 0b12bf384d8d366990966196e82dae70b0363079 (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
% \iffalse meta-comment
%
% ledpar.dtx
% Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net 
% Maintainer:Maïeul Rouquette maieul at maieul dot net
% Copyright 2004, 2005 Peter R. Wilson
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any 
% later version.
% The latest version of the license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2003/06/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% This work consists of the files listed in the README file.
%
%
%<*driver>
\documentclass[twoside]{ltxdoc}
\usepackage{url}
  \usepackage[draft=false,
              plainpages=false,
              pdfpagelabels,
              bookmarksnumbered,
%              hyperindex=true
              hyperindex=false
             ]{hyperref}
\providecommand{\phantomsection}{} % just in case hyperref is not used
\usepackage{graphicx}
\makeatletter
  \@mparswitchfalse
\makeatother
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%%\OnlyDescription
\renewcommand{\MakeUppercase}[1]{#1}
\pagestyle{headings}
\setcounter{StandardModuleDepth}{1}
\setcounter{IndexColumns}{2}
\begin{document}
  \raggedbottom
  \DocInput{ledpar.dtx}
\end{document}
%</driver>
%
% \fi
%
% \CheckSum{4247}
%
% \makeatletter
% \newcommand*{\DescribeIt}{\leavevmode\@bsphack\begingroup\MakePrivateLetters
%  \Describe@It}
% \newcommand*{\Describe@It}[1]{\endgroup
%   \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
%   \SpecialItIndex{#1}\@esphack\ignorespaces}
% \newcommand*{\SpecialItIndex}[1]{\@bsphack
%   \index{#1\actualchar{\protect\ttfamily#1}\encapchar usage}\@esphack}
%     
% \DoNotIndex{\@,\@@par,\@beginparpenalty,\@empty}
% \DoNotIndex{\@flushglue,\@input}
% \DoNotIndex{\@makefnmark,\@makeother,\@maketitle}
% \DoNotIndex{\@namedef,\@ne,\@spaces,\@tempa}
% \DoNotIndex{\@tempb,\@tempswafalse,\@tempswatrue}
% \DoNotIndex{\@thanks,\@thefnmark,\@topnum}
% \DoNotIndex{\@@,\@elt,\@forloop,\@fortmp,\@gtempa,\@totalleftmargin}
% \DoNotIndex{\",\/,\@ifundefined,\@nil,\@verbatim,\@vobeyspaces}
% \DoNotIndex{\|,\~,\ ,\active,\advance,\aftergroup,\begingroup,\bgroup}
% \DoNotIndex{\mathcal,\csname,\def,\documentstyle,\dospecials,\edef}
% \DoNotIndex{\egroup}
% \DoNotIndex{\else,\endcsname,\endgroup,\endinput,\endtrivlist}
% \DoNotIndex{\expandafter,\fi,\fnsymbol,\futurelet,\gdef,\global}
% \DoNotIndex{\hbox,\hss,\if,\if@inlabel,\if@tempswa,\if@twocolumn}
% \DoNotIndex{\ifcase}
% \DoNotIndex{\ifcat,\iffalse,\ifx,\ignorespaces,\index,\input,\item}
% \DoNotIndex{\jobname,\kern,\leavevmode,\leftskip,\let,\llap,\lower}
% \DoNotIndex{\m@ne,\next,\newpage,\nobreak,\noexpand,\nonfrenchspacing}
% \DoNotIndex{\obeylines,\or,\protect,\raggedleft,\rightskip,\rm,\sc}
% \DoNotIndex{\setbox,\setcounter,\small,\space,\string,\strut}
% \DoNotIndex{\strutbox}
% \DoNotIndex{\thefootnote,\thispagestyle,\topmargin,\trivlist,\tt}
% \DoNotIndex{\twocolumn,\typeout,\vss,\vtop,\xdef,\z@}
% \DoNotIndex{\,,\@bsphack,\@esphack,\@noligs,\@vobeyspaces,\@xverbatim}
% \DoNotIndex{\`,\catcode,\end,\escapechar,\frenchspacing,\glossary}
% \DoNotIndex{\hangindent,\hfil,\hfill,\hskip,\hspace,\ht,\it,\langle}
% \DoNotIndex{\leaders,\long,\makelabel,\marginpar,\markboth,\mathcode}
% \DoNotIndex{\mathsurround,\mbox,\newcount,\newdimen,\newskip}
% \DoNotIndex{\nopagebreak}
% \DoNotIndex{\parfillskip,\parindent,\parskip,\penalty,\raise,\rangle}
% \DoNotIndex{\section,\setlength,\TeX,\topsep,\underline,\unskip,\verb}
% \DoNotIndex{\vskip,\vspace,\widetilde,\\,\%,\@date,\@defpar}
% \DoNotIndex{\[,\{,\},\]}
% \DoNotIndex{\count@,\ifnum,\loop,\today,\uppercase,\uccode}
% \DoNotIndex{\baselineskip,\begin,\tw@}
% \DoNotIndex{\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k,\l,\m,\n,\o,\p,\q}
% \DoNotIndex{\r,\s,\t,\u,\v,\w,\x,\y,\z,\A,\B,\C,\D,\E,\F,\G,\H}
% \DoNotIndex{\I,\J,\K,\L,\M,\N,\O,\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z}
% \DoNotIndex{\1,\2,\3,\4,\5,\6,\7,\8,\9,\0}
% \DoNotIndex{\!,\#,\$,\&,\',\(,\),\+,\.,\:,\;,\<,\=,\>,\?,\_}
% \DoNotIndex{\discretionary,\immediate,\makeatletter,\makeatother}
% \DoNotIndex{\meaning,\newenvironment,\par,\relax,\renewenvironment}
% \DoNotIndex{\repeat,\scriptsize,\selectfont,\the,\undefined}
% \DoNotIndex{\arabic,\do,\makeindex,\null,\number,\show,\write,\@ehc}
% \DoNotIndex{\@author,\@ehc,\@ifstar,\@sanitize,\@title,\everypar}
% \DoNotIndex{\if@minipage,\if@restonecol,\ifeof,\ifmmode}
% \DoNotIndex{\lccode,\newtoks,\onecolumn,\openin,\p@,\SelfDocumenting}
% \DoNotIndex{\settowidth,\@resetonecoltrue,\@resetonecolfalse,\bf}
% \DoNotIndex{\clearpage,\closein,\lowercase,\@inlabelfalse}
% \DoNotIndex{\selectfont,\mathcode,\newmathalphabet,\rmdefault}
% \DoNotIndex{\bfdefault}
% \DoNotIndex{\newcommand,\renewcommand,\providecommand}
% \DoNotIndex{\ ,\to}
%
% \newcommand{\dtxfilename}{\texttt{ledpar.dtx}}
% \def\fileversion{v0.1} \def\filedate{2004/12/10}
% \def\fileversion{v0.2} \def\filedate{2005/01/01}
% \def\fileversion{v0.3} \def\filedate{2005/03/24}
% \def\fileversion{v0.3a} \def\filedate{2005/03/30}
% \def\fileversion{v0.3b} \def\filedate{2005/04/08}
% \def\fileversion{v0.3c} \def\filedate{2011/06/16}
%
% \changes{v0.1}{2004/12/10}{First public release}
% \changes{v0.2}{2005/01/01}{Fix babel problems}
% \changes{v0.3}{2005/03/24}{Reorganize for ledarab}
% \changes{v0.3a}{2005/03/30}{Minor \cs{linenummargin} fix}
% \changes{v0.3b}{2005/04/08}{Improved parallel page balancing}
% \changes{v0.3c}{2011/06/16}{Compatibilty with Polyglossia}

% \hyphenation{man-u-script man-u-scripts}
%
% \newcommand{\Lpack}[1]{\textsf{#1}}
% \newcommand{\Lclass}[1]{\textsf{#1}}
% \newcommand{\file}[1]{\texttt{#1}}
% \newcommand{\ledpar}{ledpar}
% \newcommand{\ledmac}{ledmac}
% \newcommand{\Ledmac}{\Lpack{\ledmac}}
% \newcommand{\Ledpar}{\Lpack{\ledpar}}
% \newcommand{\edmac}{\texttt{EDMAC}}
% \newcommand{\tabmac}{\texttt{TABMAC}}
% \newcommand{\edstanza}{\texttt{EDSTANZA}}
% \newcommand{\PWcomment}[1]{}
% \newenvironment{PW}{\itshape}{}
% \renewenvironment{PW}{\sffamily}{}
% \newcommand{\texbook}{\textit{TeXbook}}
% \newcommand{\thetexbook}{\textit{The TeXbook}}
%
% ^^A PW added following as the definitions are at some unknown elsewhere
% \newcommand{\egstart}{}
% \newcommand{\egmid}{}
% \newcommand{\egend}{}
%
% \renewcommand{\egstart}{%
%    \par
%    \begingroup
%    \centering
%    \begin{minipage}{0.45\textwidth}}
% \renewcommand{\egmid}{%
%    \end{minipage}\hfill\begin{minipage}{0.45\textwidth}}
% \renewcommand{\egend}{%
%    \end{minipage}\par\endgroup}
%
% \title{Parallel typesetting for critical editions: \\
%       the \Lpack{\ledpar} package\thanks{This file (\dtxfilename)
% has version number \fileversion, last revised \filedate.}}
% \author{%
% Peter Wilson \\
% Herries Press\thanks{\texttt{herries dot press at earthlink dot net}}\\
% Ma\"ieul Rouquette\thanks{\texttt{maieul at maieul dot net}}}
%
% \date{}
%
%
% \maketitle
%
%
% \begin{abstract}
% The \Ledmac{} package, which is based on the \PlainTeX\ set of
% \edmac\ macros, has been used for some time for typesetting critical 
% editions. The \Ledpar{} package is an extension to \Ledmac{}
% which enables texts and their critical apparatus to be typeset in 
% parallel, either in two columns or on pairs of facing pages.
% \end{abstract}
%
% \tableofcontents
%
% \listoffigures
%
%
% \section{Introduction}
%
%    The \edmac{} macros \cite{EDMACTUG} for typesetting critical editions 
% of texts
% have been available for use with TeX for some years. Since \edmac{}
% became available there had been a small but constant demand for a
% version of \edmac{} that could be used with LaTeX. The \Ledmac{}
% package was introduced in 2003 in an attempt to satisfy that request.
% 
%    Some critical editions contain texts in more than one form, such as
% a set of verses in one language and their translations in another. In
% such cases there is a desire to be able to typeset the two texts, together
% with any critical apparatus, in parallel. The \Ledpar{} package
% is an extension to \Ledmac{} that enables two texts and their
% apparatus to be set in parallel, either in two columns or on pairs of
% facing pages.
%
%    The package has to try and coerce \TeX{} into paths it was not designed
% for. Use of the package, therefore, may produce some surprising results.
%
% This manual contains a general description of how to use 
% \Ledpar{} starting in section~\ref{howto};
% the complete source code for the package,
% with extensive documentation (in sections~\ref{overview}
% through \ref{end}); 
% and an Index to the source code. As \Ledpar{} is an adjunct to \Ledmac{}
% I assume that you have read the \Ledmac{} manual. Also \Ledpar{} requires
% \Ledmac{} to be used, preferably at least version 0.6 (2004/12/10).
% You do not need to  read the source code for this package in order to 
% use it but doing so may help to answer any questions you might have.
% On a first reading,
% I suggest that you should skip anything after the general documentation in
% sections~\ref{howto} until~\ref{overview}, 
% unless you are particularly interested in the innards of \Ledpar.
%
%
% \section{The \Lpack{\ledpar} package}\label{howto}
%
% A file may mix \emph{numbered} and \emph{unnumbered} text.
% Numbered text is printed with marginal line numbers and can include
% footnotes and endnotes that are referenced to those line numbers:
% this is how you'll want to print the text that you're editing.
% Unnumbered text is not printed with line numbers, and you can't
% use \Ledmac's note commands with it: this is appropriate for
% introductions and other material added by the editor around the
% edited text.
%
% The \Ledpar{} package lets you typeset two \emph{numbered} texts in
% parallel. This can be done either as setting the `Leftside' and `Rightside'
% texts in two columns or on facing pages.
% In the paired pages case footnotes are placed at the bottom of the page
% on which they are called out --- that is, footnotes belonging to the left
% are set at the foot of a left (even numbered) page, and those for right
% texts are at the bottom of the relevant right (odd numbered) page. However,
% in the columnar case, all footnotes are set at the bottom left of the 
% page on which they are called out --- they are not set below the 
% relevant column. 
% The line numbering schemes need not be the same for the two texts.
%
% \subsection{General}
%
% \Ledmac{} essentially puts each chunk of numbered text 
% (the text within a \cs{pstart} \ldots \cs{pend}) into a box and then 
% following the \cs{pend} extracts the text line by line from the box 
% to number and print it. More precisely, the text is first put into the
% the box as though it was being typeset as normal onto a page and
% any notes are stored without being typeset. Then each typeset line 
% is extracted from the box and any notes for that line are recalled.
% The line, with any notes, is then output for printing, possibly with
% a line number attached. Effectively, all the text is typeset and then
% afterwards all the notes are typeset.
% 
%
% \Ledpar{} similarly puts the left and right chunks into boxes but can't 
% immediately output the text after a \cs{pend} --- it has to wait until
% after both the left and right texts have been collected before it can 
% start processing. This means that several boxes are required and possibly
% TeX has to store a lot of text in its memory; both the number of potential
% boxes and memory are limited. If TeX's memory is overfilled the recourse is
% to reduce the amount of text stored before printing.
%
% \DescribeMacro{\maxchunks}
% It is possible to have multiple chunks in the left and right texts before
% printing them. The macro \cs{maxchunks}\marg{num} specifies the maximum
% number of chunks within the left or right texts. This is initially set as: \\
% \verb?\maxchunks{10}? \\
% meaning that there can be up to 10 chunks in the left text and up to 
% 10 chunks in 
% the right text, requiring a total of 20 boxes. If you need more chunks
% then you can increase \cs{maxchunks}.
%
% TeX has a limited number of boxes; if you get an error
% message along the lines of `no room for a new box', then decrease
% the number. A chunk also requires a counter so you may get a message
% along the lines `no room for a new count', which may be resolved by reducing
% \cs{maxchunks}.
%
%    On the other hand, if you get a \Ledmac{} error message along the
% lines: `Too many \cs{pstart} without printing. Some text will be lost.'
% then you will have to either increase \cs{maxchunks} or use the
% parallel printing commands (\cs{Columns} or \cs{Pages}) more frequently.
%
% When typesetting verse using \cs{syntax}, each line is treated as a chunk,
% so be warned that if you are setting parallel verses you might have to 
% increase \cs{maxchunks} much more than it appears at first sight.
%
%    In general, \Ledmac{} is a TeX resource hog, and \Ledpar{} only 
% makes things worse in this respect.
%
% \section{Parallel columns}\label{columns}
%
% \DescribeEnv{pairs}
% Numbered text that is to be set in columns must be within a \verb?pairs?
% environment. Within the environment the text for the lefthand and righthand
% columns is placed within the \verb?Leftside? and \verb?Rightside? 
% environments, respectively; these are described in more detail below
% in section~\ref{leftright}.
%
% \DescribeMacro{\Columns}
% The command \cs{Columns} typesets the texts in the previous pair of
% \verb?Leftside? and \verb?Rightside? environments. 
% The general scheme for parallel columns looks like this:
% \begin{verbatim}
% \begin{pairs}
% \begin{Leftside} ... \end{Leftside}
% \begin{Rightside} ... \end{Rightside}
% \Columns
% \begin{Leftside} ... \end{Leftside}
% ...
% \Columns
% \end{pairs}
% \end{verbatim}
%
% There is no required pagebreak before or after the columns.
%
% \DescribeMacro{\Lcolwidth}
% \DescribeMacro{\Rcolwidth}
% The lengths \cs{Lcolwidth} and \cs{Rcolwidth} are the widths of the left
% and right columns, respectively. By default, these are: \\
% \verb?\setlength{\Lcolwidth}{0.45\textwidth}? \\
% \verb?\setlength{\Rcolwidth}{0.45\textwidth}? \\
% They may be adjusted if one text tends to be `bulkier' than the other.
%
% \DescribeMacro{\columnrulewidth}
% \DescribeMacro{\columnseparator}
% The macro \cs{columnseparator} is called between each left/right pair
% of lines. By default it inserts a vertical rule of width 
% \cs{columnrulewidth}. As this is initially defined to be 0pt the rule
% is invisible. For a visible rule between the columns you could try: \\
% \verb?\setlength{\columnrulewidth}{0.4pt}? \\
% You can also modify \cs{columnseparator} if you want more control.
%
%
% \section{Facing pages}\label{pages}
%
% \DescribeEnv{pages}
% Numbered text that is to be set on facing pages must be within a \verb?pages?
% environment. Within the environment the text for the lefthand and righthand
% pages is placed within the \verb?Leftside? and \verb?Rightside? 
% environments, respectively.
%
% \DescribeMacro{\Pages}
% The command \cs{Pages} typesets the texts in the previous pair of
% \verb?Leftside? and \verb?Rightside? environments. 
% The general scheme for parallel pages looks like this:
% \begin{verbatim}
% \begin{pages}
% \begin{Leftside} ... \end{Leftside}
% \begin{Rightside} ... \end{Rightside}
% \Pages
% \begin{Leftside} ... \end{Leftside}
% ...
% \Pages
% \end{pages}
% \end{verbatim}
% The \verb?Leftside? text is set on lefthand (even numbered) pages and
% the \verb?Rightside? text is set on righthand (odd numbered) pages.
% Each \cs{Pages} command starts a new even numbered page. After parallel
% typesetting is finished, a new page is started.
% 
% \DescribeMacro{\Lcolwidth}
% \DescribeMacro{\Rcolwidth}
% Within the \verb?pages? environment the lengths \cs{Lcolwidth} and 
% \cs{Rcolwidth} are the widths of the left
% and right pages, respectively. By default, these are set to the normal
% textwidth for the document, but can be changed within the environment if
% necessary.
%
% \DescribeMacro{\goalfraction}
% When doing parallel pages \Ledpar{} has to guess where TeX is going to 
% put pagebreaks and hopefully get there first in order to put the pair of
% texts on their proper pages. When it thinks that the fraction 
% \cs{goalfraction} of a page has been filled, it finishes that page and 
% starts on the other side's text. The definition is: \\
% \verb?\newcommand*{\goalfraction}{0.9}? \\
% If you think you can get more on a page, increase this. On the other hand,
% if some left text overflows onto an odd numbered page or some right text
% onto an even page, try reducing it, for instance by: \\
% \verb?\renewcommand*{\goalfraction}{0.8}?
%
% \section{Left and right texts}\label{leftright}
%
% Parallel texts are divided into Leftside and Rightside. The form of the
% contents of these two are independent of whether they will be set 
% in columns or pages.
%
% \DescribeEnv{Leftside}
% \DescribeEnv{Rightside}
% The left text is put within the \verb?Leftside? environment and the 
% right text likewise in the \verb?Rightside? environment. The number of 
% \verb?Leftside? and \verb?Rightside? environments must be the same.
%
% Within these environments you can designate the line numbering scheme(s)
% to be used. 
% \DescribeMacro{\firstlinenum}
% \DescribeMacro{\linenumincrement}
% \DescribeMacro{\firstsublinenum}
% \DescribeMacro{\sublinenumincrement}
% The \Ledmac{} package originally used counters for specifying the 
% numbering scheme; now both \Ledmac\footnote{when used with \Lpack{ledpatch}
% v0.2 or greater.} and
% the \Ledpar{} package use macros instead. Following 
% \cs{firstlinenum}\marg{num} the first line number will be \meta{num}, and
% following \cs{linenumincrement}\marg{num} only every \meta{num}th
% line will have a printed number. Using these macros inside the
% \verb?Leftside? and \verb?Rightside? environments gives you independent 
% control over the left and right numbering schemes. The \cs{firstsublinenum}
% and \cs{sublinenumincrement} macros correspondingly set the numbering
% scheme for sublines.
%
% \DescribeMacro{\pstart}
% \DescribeMacro{\pend}
% In a serial (non-parallel) mode, each numbered paragraph, or chunk, 
% is contained
% between the \cs{pstart} and \cs{pend} macros, and the paragraph is output
% when the \cs{pend} macro occurs. The situation is somewhat different
% with parallel typesetting as the left text (contained within \cs{pstart}
% and \cs{pend} groups within the \verb?Leftside? environment) has to be
% set in parallel with the right text (contained within its own \cs{pstart}
% and \cs{pend} groups within the corresponding \verb?Rightside? environment)
% the \cs{pend} macros cannot immediately initiate any typesetting ---
% this has to be controlled by the \cs{Columns} or \cs{Pages} macros.
% Several chunks may be specified within a \verb?Leftside? or 
% \verb?Rightside? environment.
% A multi-chunk text then looks like:
% \begin{verbatim}
% \begin{...side}
%   % \beginnumbering
%   \pstart first chunk \pend
%   \pstart  second chunk \pend
%   ...
%   \pstart  last chunk \pend
%   % \endnumbering
% \end{...side}
% \end{verbatim}
% Numbering, via \cs{beginnumbering} and \cs{endnumbering}, may extend
% across several \verb?Leftside? or \verb?Rightside? environments. 
% Remember, though,
% that the Left/Right sides are effectively independent of each other.
%
% Generally speaking, controls like \cs{firstlinenum} or \cs{linenummargin}
% apply to sequential and left texts. To effect right texts only they have 
% to be within a \verb?Rightside? environment. 

% If you are using the 
% \Lpack{babel} package with different languages 
% (via, say, \cs{selectlanguage}) for the left and right texts it is 
% particularly important to select the appropriate language within the
% \verb?Leftside? and \verb?Rightside? environments. The initial language
% selected for the right text is the \Lpack{babel} package's default. Also,
% it is the \emph{last} \cs{selectlanguage} in a side that controls the
% language used in any notes for that side when they get printed. If
% you are using multilingual notes then it is probably safest to explicitly
% specify the language(s) for each note rather than relying on the language
% selection for the side. The right side language is also
% applied to the right side line numbers.
%
% Corresponding left and right sides must have the same number of
% paragraph chunks --- if there are four on the left there must be four
% on the right, even if some are empty. The start of each pair of left and
% right chunks are aligned horizontally on the page. The ends may
% come at different positions --- if one chunk is shorter than the other
% then blank lines are output on the shorter side until the end of the longer
% chunk is reached. 
% 
% \section{Numbering text lines}
%
% \DescribeMacro{\beginnumbering}
% \DescribeMacro{\endnumbering}
% Each section of numbered text must be preceded by
% \cs{beginnumbering} and followed by \cs{endnumbering}, like: \\
% \cs{beginnumbering} \\
% \meta{text} \\
% \cs{endnumbering} \\
% These have to be separately specified within \verb?Leftside? and
% \verb?Rightside? environments.
%
% The \cs{beginnumbering} macro resets the line number to zero,
% reads an auxiliary file called \meta{jobname}.\file{nn} (where
% \meta{jobname} is the name of the main input file for this job,
% and \file{nn} is 1 for the first numbered section, 2 for
% the second section, and so on), and then creates a new version of
% this auxiliary file to collect information during this run. 
% Separate auxiliary files are maintained for right hand texts and
% these are named \meta{jobname}.\file{nnR}, using the `R' to distinguish
% them from the left hand and serial (non-parallel) texts.
%
% \DescribeMacro{\memorydump}
% The command \cs{memorydump} effectively performs an \cs{endumbering}
% immediately followed by a \cs{beginnumbering} while not restarting the
% numbering sequence. This has the effect of clearing TeX's memory of previous
% texts and any associated notes, allowing
% longer apparent streams of parallel texts. The command should be applied
% to both left and right texts, and after making sure that all previous
% notes have been output. For example, along the lines of:
% \begin{verbatim}
% \begin{Leftside}
%   \beginnumbering
%   ...
% \end{Leftside}
% \begin{Rightside}
%   \beginnumbering
%   ...
% \end{Rightside}
% \Pages
% \begin{Leftside}
%   \memorydump
%   ...
% \end{Leftside}
% \begin{Rightside}
%   \memorydump
%   ...
% \end{verbatim}
%
% \DescribeMacro{\Rlineflag}
% The value of \cs{Rlineflag} is appended to the line numbers of the
% right texts. Its default definition is: \\
% \verb?\newcommand*{\Rlineflag}{R}? \\
% This may be useful for parallel columns but for parallel pages it might
% be more appropriate to redefine it as: \\
% \verb?\renewcommand*{\Rlineflag}{}?.
%
% \DescribeMacro{\printlinesR}
% \DescribeMacro{\ledsavedprintlines}
% The \cs{printlines} macro is ordinarily used to print the line number 
% references for critical footnotes. For footnotes from right side texts 
% a special version is supplied, called \cs{printlinesR}, which incorporates
% \cs{Rlineflag}. (The macro \cs{ledsavedprintlines} is a copy of the original
% \cs{printlines}, just in case \ldots). As provided, the package makes no
% use of \cs{printlinesR} but you may find it useful. For example, if you only
% use the B footnote series in righthand texts then you may wish to flag
% any line numbers in those footnotes with the value of \cs{Rlineflag}. You
% could do this by putting the following code in your preamble:
% \begin{verbatim}
% \let\oldBfootfmt\Bfootfmt
% \renewcommand{\Bfootfmt}[3]{%
%   \let\printlines\printlinesR
%   \oldBfootfmt{#1}{#2}{#3}}
% \end{verbatim}
% 
% \section{Verse}
%
% If you are typesetting verse with \Ledmac{} you can use the \cs{stanza}
% construct, and you can also use this in right or left parallel texts.
% In this case each verse line is a chunk which has two implications.
% (1) you can unexpectedly exceed the \cs{maxchunks} limit or the overall
% limit on the number of boxes, and (2) left and right verse lines are
% matched, which may not be desirable if one side requires more print lines
% for verse lines than the other does.
%
% \DescribeEnv{astanza}
% \Ledpar{} provides an \verb?astanza? environment which you can use instead
% of \cs{stanza} (simply replace \verb?\stanza? by \verb?\begin{astanza}? and
% add \verb?\end{astanza}? after the ending \verb?\&?). Within the 
% \verb?astanza? environment each verse line is treated as a paragraph, 
% so there must be no blank lines in the environment otherwise there will
% be some extraneous vertical spacing.
%
%    If you get an error message along the lines of `Missing number, 
% treated as zero \cs{sza@0@}' it is because you have forgotten to use
% \cs{setstanzaindents} to set the stanza indents.
%
% \DescribeMacro{\skipnumbering}
% The command \cs{skipnumbering} when inserted in a line of parallel text
% causes the numbering of that particular line to be skipped. This can
% useful if you are putting some kind of marker (even if it is only a 
% blank line) between stanzas. Remember, parallel texts must be numbered
% and this provides a way to slip in an `unnumbered' line.
%
%    The \verb?astanza? environment forms a chunk but you may want to
% have more than one stanza within the chunk. Here are a couple of ways of 
% doing that with a blank line between each internal stanza, and with
% each stanza numbered. First some preliminary definitions:
% \begin{verbatim}
% \newcommand*{\stanzanum}[2][\stanzaindentbase]{%
%   \hskip -#1\llap{\textbf{#2}}\hskip #1\ignorespaces}
% \newcommand{\interstanza}{\par\mbox{}\skipnumbering}
% \end{verbatim}
% And now for two stanzas in one. In this first example the line numbering
% repeats for each stanza.
% \begin{verbatim}
% \setstanzaindents{1,0,1,0,1,0,1,0,1,0,1}
% \begin{pairs}
% \begin{Leftside}
%   \firstlinenum{2}
%   \linenumincrement{1}
%   \beginnumbering
%   \begin{astanza}
%     \stanzanum{1} First in first stanza &
%                   Second in first stanza &
%                   Second in first stanza &
%                   Third in first stanza &
%                   Fourth in first stanza &
%     \interstanza
%     \setline{2}\stanzanum{2} First in second stanza &
%                   Second in second stanza &
%                   Second in second stanza &
%                   Third in second stanza &
%                   Fourth in second stanza \&
%   \end{astanza}
%   ...
% \end{verbatim}
% And here is a slightly different way of doing the same thing, but with
% the line numbering being continuous.
% \begin{verbatim}
% \setstanzaindents{1,0,1,0,1,0,0,1,0,1,0,1}
% \begin{pairs}
% \begin{Leftside}
%   \firstlinenum{2}
%   \linenumincrement{1}
%   \beginnumbering
%   \begin{astanza}
%     \stanzanum{1} First in first stanza &
%                   Second in first stanza &
%                   Second in first stanza &
%                   Third in first stanza &
%                   Fourth in first stanza &
%     \strut &
%     \stanzanum{2}\advanceline{-1} First in second stanza &
%                   Second in second stanza &
%                   Second in second stanza &
%                   Third in second stanza &
%                   Fourth in second stanza \&
%   \end{astanza}
%   ...
% \end{verbatim}
%
%
%
% \StopEventually{}
%
% \clearpage
% \section{Implementation overview}\label{overview}
%
%    TeX is designed to process a single stream of text, which may include
% footnotes, tables, and so on. It just keeps converting its input into
% a stream typeset pages. It was not designed for typesetting two texts
% in parallel, where it has to alternate from one to the other. Further,
% TeX essentially processes its input one paragraph at a time --- it is
% very difficult to get at the `internals' of a paragraph such as the
% individual lines in case you want to number them or put some mark at the
% start or end of the lines.
%
%    \Ledmac{} solves the problem of line numbering by putting the paragraph
% in typeset form into a box, and then extracting the lines one by one 
% from the box for TeX to put them onto the page with the appropriate page
% breaks. Most of the \Ledmac{} code is concerned with handling this box
% and its contents.
%
%    \Ledpar's solution to the problem of parallel texts is to put the two
% texts into separate boxes, and then appropriately extract the pairs of
% lines from the boxes. This involves duplicating 
% much of the original box code for an extra right text box. The other, 
% smaller,
% part of the code is concerned with coordinating the line extractions from
% the boxes.
%
%    The package code is presented in roughly in the same order as in \Ledmac.
%
% \section{Preliminaries}
% \label{preliminaries}\relax
%
% Announce the name and version of the package, which is 
% targetted for LaTeX2e. The package also requires the \Ledmac{}
% package, preferably at least version 0.6 (2004/12/10).
%
%    \begin{macrocode}
%<*code>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ledpar}[2011/06/16 v0.3c ledmac extension for parallel texts]

%    \end{macrocode}
%
%  As noted above,much of the code is a duplication of the original
% \Ledmac{} code to handle the extra box(es) for the right hand side text,
% and sometimes for the left hand side as well. In order to distinguish
% I use `R' or `L' in the names of macros for the right and left code.
% The specifics of `L' and `R' are normally hidden from the user by
% letting the \verb?Leftside? and \verb?Rightside? environments set things
% up appropriately.
%
% \begin{macro}{\ifl@dpairing}
% \begin{macro}{\ifl@dpaging}
% \begin{macro}{\ifledRcol}
% \cs{ifl@dpairing} is set TRUE if we are processing parallel texts and
% \cs{ifl@dpaging} is also set TRUE if we are doing parallel pages.
% \cs{ifledRcol} is set TRUE if we are doing the right hand text.
% \cs{ifl@dpairing} is defined in \Lpack{ledmac}.
% \changes{v0.3}{2005/02/24}{Moved \cs{ifl@dpairing} to ledmac}
%    \begin{macrocode}
  \l@dpairingfalse
\newif\ifl@dpaging
  \l@dpagingfalse
\newif\ifledRcol
  \ledRcolfalse
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Lcolwidth}
% \begin{macro}{\Rcolwidth}
% The widths of the left and right parallel columns (or pages).
%    \begin{macrocode}
\newdimen\Lcolwidth
  \Lcolwidth=0.45\textwidth
\newdimen\Rcolwidth
  \Rcolwidth=0.45\textwidth

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Messages}
%
% All the error and warning messages are collected here as macros.
%
% \begin{macro}{\led@err@TooManyPstarts}
%     \begin{macrocode}
\newcommand*{\led@err@TooManyPstarts}{%
  \ledmac@error{Too many \string\pstart\space without printing.
                Some text will be lost}{\@ehc}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@err@BadLeftRightPstarts}
%     \begin{macrocode}
\newcommand*{\led@err@BadLeftRightPstarts}[2]{%
  \ledmac@error{The numbers of left (#1) and right (#2)
                \string\pstart s do not match}{\@ehc}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@err@LeftOnRightPage}
% \begin{macro}{\led@err@RightOnLeftPage}
%     \begin{macrocode}
\newcommand*{\led@err@LeftOnRightPage}{%
  \ledmac@error{The left page has ended on a right page}{\@ehc}}
\newcommand*{\led@err@RightOnLeftPage}{%
  \ledmac@error{The right page has ended on a left page}{\@ehc}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \section{Sectioning commands}
%
% \begin{macro}{\section@numR}
% This is the right side equivalent of \cs{section@num}.
% 
% Each section will read and write an associated `line-list
% file', containing information used to do the numbering. Normally
% the file will be called \meta{jobname}\file{.nn}, where \file{nn} is the
% section number. However, for right side texts the file is called
% \meta{jobname}\file{.nnR}. The \cs{extensionchars} applies to the
% right side files just as it does to the normal files.
%    \begin{macrocode}
\newcount\section@numR
  \section@numR=\z@
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifnumberingR}
% The \cs{ifnumberingR} flag is
% set to \verb"true" if we're within a right text numbered section.
%    \begin{macrocode}
\newif\ifnumberingR
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifpst@rtedL}
% \begin{macro}{\ifpst@rtedR}
% \cs{ifpst@rtedL} is set FALSE at the start of left side numbering, and
% similarly for \cs{ifpst@rtedR}. 
% \cs{ifpst@rtedL} is defined in \Lpack{ledmac}.
% \changes{v0.3}{2005/02/24}{Moved \cs{ifpst@rtedL} to ledmac}
%    \begin{macrocode}
  \pst@rtedLfalse
\newif\ifpst@rtedR
  \pst@rtedRfalse

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\beginnumbering}
% For parallel processing the original \cs{beginnumbering} is extended
% to zero \cs{l@dnumpstartsL} --- the number of chunks to be processed.
% It also sets \cs{ifpst@rtedL} to FALSE.
%    \begin{macrocode}
\providecommand*{\beginnumbering}{%
  \ifnumbering
    \led@err@NumberingStarted
    \endnumbering
  \fi
  \global\l@dnumpstartsL \z@
  \global\pst@rtedLfalse
  \global\numberingtrue
  \global\advance\section@num \@ne
  \initnumbering@reg
  \message{Section \the\section@num}%
  \line@list@stuff{\jobname.\extensionchars\the\section@num}%
  \l@dend@stuff}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\beginnumberingR}
% This is the right text equivalent of \cs{beginnumbering}, and begins 
% a section of numbered text.
%    \begin{macrocode}
\newcommand*{\beginnumberingR}{%
  \ifnumberingR
    \led@err@NumberingStarted
    \endnumberingR
  \fi
  \global\l@dnumpstartsR \z@
  \global\pst@rtedRfalse
  \global\numberingRtrue
  \global\advance\section@numR \@ne
  \global\absline@numR \z@
  \global\line@numR \z@
  \global\subline@numR \z@
  \global\@lock \z@
  \global\sub@lock \z@
  \global\sublines@false
  \global\let\next@page@numR=\relax
  \global\let\sub@change=\relax
  \message{Section \the\section@numR R }%
  \line@list@stuffR{\jobname.\extensionchars\the\section@numR R}%
  \l@dend@stuff}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endnumbering}
% This is the left text version of the regular \cs{endnumbering} and must 
% follow the last text for a left text numbered section. 
% It sets \cs{ifpst@rtedL} to FALSE. It is fully defined in \Lpack{ledmac}.
% \end{macro}
%
% \begin{macro}{\endnumberingR}
% This is the right text equivalent of \cs{endnumbering} and must follow the 
% last text for a right text numbered section.
%    \begin{macrocode}
\def\endnumberingR{%
  \ifnumberingR
    \global\numberingRfalse
    \normal@pars
    \ifl@dpairing
      \global\pst@rtedRfalse
    \else
      \ifx\insertlines@listR\empty\else
        \global\noteschanged@true
      \fi
      \ifx\line@listR\empty\else
        \global\noteschanged@true
      \fi
    \fi
    \ifnoteschanged@
      \led@mess@NotesChanged
    \fi
  \else
    \led@err@NumberingNotStarted
  \fi}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\pausenumberingR}
% \begin{macro}{\resumenumberingR}
% These are the right text equivalents of \cs{pausenumbering} and
% \cs{resumenumbering}.
%    \begin{macrocode}
\newcommand*{\pausenumberingR}{%
  \endnumberingR\global\numberingRtrue}
\newcommand*{\resumenumberingR}{%
  \ifnumberingR
     \global\pst@rtedRtrue
     \global\advance\section@numR \@ne
     \led@mess@SectionContinued{\the\section@numR R}%
     \line@list@stuffR{\jobname.\extensionchars\the\section@numR R}%
     \l@dend@stuff
  \else
    \led@err@numberingShouldHaveStarted
     \endnumberingR
     \beginnumberingR
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memorydumpL}
% \begin{macro}{\memorydumpR}
% \cs{memorydump} is a shorthand for \cs{pausenumbering}\cs{resumenumbering}.
% This will clear the memorised stuff for the previous chunks while
% keeping the numbering going.
%    \begin{macrocode}
\newcommand*{\memorydumpL}{%
  \endnumbering
  \numberingtrue
  \global\pst@rtedLtrue
  \global\advance\section@num \@ne
     \led@mess@SectionContinued{\the\section@num}%
  \line@list@stuff{\jobname.\extensionchars\the\section@num}%
  \l@dend@stuff}
\newcommand*{\memorydumpR}{%
  \endnumberingR
  \numberingRtrue
  \global\pst@rtedRtrue
  \global\advance\section@numR \@ne
     \led@mess@SectionContinued{\the\section@numR R}%
  \line@list@stuffR{\jobname.\extensionchars\the\section@numR R}%
  \l@dend@stuff}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \section{Line counting}
% \label{lineation}\relax
%
% \subsection{Choosing the system of lineation}
%
% Sometimes you want line numbers that start at $1$ at the top of each
% page; other times you want line numbers that start at $1$ at the start
% of each section and increase regardless of page breaks.
% \Ledpar{} lets you choose different schemes for the left and right texts.
%
% \begin{macro}{\ifbypage@R}
% \begin{macro}{\bypage@Rtrue}
% \begin{macro}{\bypage@Rfalse}
% The \cs{ifbypage@R} flag specifies the current lineation
% system for right texts: \verb"false" for line-of-section, \verb"true" 
% for line-of-page.
% \Ledpar{} will use the line-of-section system unless instructed otherwise.
%    \begin{macrocode}
\newif\ifbypage@R
  \bypage@Rfalse
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lineationR}
% \cs{lineationR}\marg{word} is the macro used to select the 
% lineation system for right texts.
% Its argument is a string: either \texttt{page} or \texttt{section}.
%    \begin{macrocode}
\newcommand*{\lineationR}[1]{{%
  \ifnumberingR
    \led@err@LineationInNumbered
  \else
    \def\@tempa{#1}\def\@tempb{page}%
    \ifx\@tempa\@tempb
        \global\bypage@Rtrue
    \else
       \def\@tempb{section}%
       \ifx\@tempa\@tempb
           \global\bypage@Rfalse
       \else
         \led@warn@BadLineation
       \fi
    \fi
  \fi}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\linenummargin}
% \begin{macro}{\line@marginR}
% You call \cs{linenummargin}\marg{word} to specify which margin you want your
% right text's line numbers in; it takes one argument, a string.
% You can put the line numbers in the same margin on every page using
% \texttt{left} or \texttt{right}; or you can use \texttt{inner} or
% \texttt{outer} to get them in the inner or outer margins.
% You can change this within a numbered section, but the
% change may not take effect just when you'd like; if it's done between
% paragraphs nothing surprising should happen.
%
% For right texts the selection is recorded in the count \cs{line@marginR},
% otherwise in the count \cs{line@margin}:
% $0$ for left, $1$ for right, $2$ for outer, and $3$ for inner.
% \changes{v0.3a}{2005/03/30}{Don't just set \cs{line@marginR} in \cs{linenummargin}}
%    \begin{macrocode}
\newcount\line@marginR
\renewcommand*{\linenummargin}[1]{{%
  \l@dgetline@margin{#1}%
  \ifnum\@l@dtempcntb>\m@ne
    \ifledRcol
      \global\line@marginR=\@l@dtempcntb
    \else
      \global\line@margin=\@l@dtempcntb
    \fi
  \fi}}
%    \end{macrocode}
% By default put right text numbers at the right.
%    \begin{macrocode}
\line@marginR=\@ne

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

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\firstlinenum}
% \begin{macro}{\linenumincrement}
% \begin{macro}{\firstsublinenum}
% \begin{macro}{\sublinenumincrement}
% These are the user's macros for changing (sub) line numbers. They are
% defined in \Lpack{ledmac} v0.7, but just in case 
% I have started by \cs{provide}ing them.
%    \begin{macrocode}
\providecommand*{\firstlinenum}{}
\providecommand*{\linenumincrement}{}
\providecommand*{\firstsublinenum}{}
\providecommand*{\sublinenumincrement}{}
\renewcommand*{\firstlinenum}[1]{%
  \ifledRcol \setcounter{firstlinenumR}{#1}%
  \else      \setcounter{firstlinenum}{#1}%
  \fi}
\renewcommand*{\linenumincrement}[1]{%
  \ifledRcol \setcounter{linenumincrementR}{#1}%
  \else      \setcounter{linenumincrement}{#1}%
  \fi}
\renewcommand*{\firstsublinenum}[1]{%
  \ifledRcol \setcounter{firstsublinenumR}{#1}%
  \else      \setcounter{firstsublinenum}{#1}%
  \fi}
\renewcommand*{\sublinenumincrement}[1]{%
  \ifledRcol \setcounter{sublinenumincrementR}{#1}%
  \else      \setcounter{sublinenumincrement}{#1}%
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Rlineflag}
% This is appended to the line numbers of right text.
%    \begin{macrocode}
\newcommand*{\Rlineflag}{R}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\linenumrepR}
% \begin{macro}{\sublinenumrepR}
% \cs{linenumrepR}\marg{ctr} typesets the right line number \meta{ctr}, and
% similarly \cs{sublinenumrepR} for subline numbers.
% \changes{v0.3}{2005/02/10}{Added \cs{linenumrepR} and \cs{sublinenumrepR}}
%    \begin{macrocode}
\newcommand*{\linenumrepR}[1]{\@arabic{#1}}
\newcommand*{\sublinenumrepR}[1]{\@arabic{#1}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\leftlinenumR}
% \begin{macro}{\rightlinenumR}
% \begin{macro}{\l@dlinenumR}
% \cs{leftlinenumR} and \cs{rightlinenumR} are the macros that are
% called to print the right text's marginal line numbers. Much of the
% code for these is common and is maintained in \cs{l@dlinenumR}.
% \changes{v0.3}{2005/02/10}{Simplified \cs{leftlinenumR} and 
%                \cs{rightlinenumR} by introducing \cs{l@dlinenumR}}
%    \begin{macrocode}
\newcommand*{\leftlinenumR}{%
  \l@dlinenumR
  \kern\linenumsep}
\newcommand*{\rightlinenumR}{%
  \kern\linenumsep 
  \l@dlinenumR}
\newcommand*{\l@dlinenumR}{%
  \numlabfont\linenumrepR{\line@numR}\Rlineflag%
  \ifsublines@
    \ifnum\subline@num>\z@
      \unskip\fullstop\sublinenumrepR{\subline@numR}%
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Line-number counters and lists}
%
% We need another set of counters and lists for the right text, 
% corresponding to those in \Lpack{ledmac} for regualr or left text.
%
% \begin{macro}{\line@numR}
% \begin{macro}{\subline@numR}
% \begin{macro}{\absline@numR}
% The count \cs{line@numR} stores the line number that's used in
% the right text's marginal line numbering and in notes. 
% The count \cs{subline@numR} stores
% a sub-line number that qualifies \cs{line@numR}. 
% The count \cs{absline@numR} stores the
% absolute number of lines since the start
% of the right text section: that is, the number we've actually printed, 
% no matter what numbers we attached to them. 
%
%    \begin{macrocode}
\newcount\line@numR
\newcount\subline@numR
\newcount\absline@numR

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\line@listR}
% \begin{macro}{\insertlines@listR}
% \begin{macro}{\actionlines@listR}
% \begin{macro}{\actions@listR}
% Now we can define the list macros that will be created from the
% line-list file.  They are directly analagous to the left text ones.
% The full list of action codes and their meanings is given in the \Ledmac{}
% manual.
%
% Here are the commands to create these lists:
%
%    \begin{macrocode}
\list@create{\line@listR}
\list@create{\insertlines@listR}
\list@create{\actionlines@listR}
\list@create{\actions@listR}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\linesinpar@listL}
% \begin{macro}{\linesinpar@listR}
% \begin{macro}{\maxlinesinpar@list}
% In order to synchonise left and right chunks in parallel processing
% we need to know how many lines are in each left and right text chunk,
% and the maximum of these for each pair of chunks.
%    \begin{macrocode}
\list@create{\linesinpar@listL}
\list@create{\linesinpar@listR}
\list@create{\maxlinesinpar@list}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\page@numR}
% The right text page number.
%    \begin{macrocode}
\newcount\page@numR

%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Reading the line-list file}
%
%
% \begin{macro}{\read@linelist}
% \cs{read@linelist}\marg{file} is the control sequence
% that's called by \cs{beginnumbering}
% (via \cs{line@list@stuff}) to open and process a
% line-list file; its argument is the name of the file.
% \phantomsection\label{readlinelist}
%    \begin{macrocode}
\renewcommand*{\read@linelist}[1]{%
%    \end{macrocode}
% We do do different things depending whether or not we are processing 
% right text
%    \begin{macrocode}
  \ifledRcol
    \list@clear{\line@listR}%
    \list@clear{\insertlines@listR}%
    \list@clear{\actionlines@listR}%
    \list@clear{\actions@listR}%
    \list@clear{\linesinpar@listR}%
    \list@clear{\linesonpage@listR}
  \else
    \list@clearing@reg
    \list@clear{\linesinpar@listL}%
    \list@clear{\linesonpage@listL}%
  \fi
%    \end{macrocode}
%
% Make sure that the \cs{maxlinesinpar@list} is empty (otherwise things
% will be thrown out of kilter if there is any old stuff still hanging
% in there).
%    \begin{macrocode}
  \list@clear{\maxlinesinpar@list}
%    \end{macrocode}
% Now get the file and interpret it.
%    \begin{macrocode}
  \get@linelistfile{#1}%
  \endgroup
%    \end{macrocode}
%
% When the reading is done, we're all through with the
% line-list file. All the information we needed
% from it will now be encoded in our list macros.
% Finally, we
% initialize the \cs{next@actionline} and \cs{next@action} macros,
% which specify where and what the next action to be taken is.
%    \begin{macrocode}
  \ifledRcol
    \global\page@numR=\m@ne
    \ifx\actionlines@listR\empty
      \gdef\next@actionlineR{1000000}%
    \else
      \gl@p\actionlines@listR\to\next@actionlineR
      \gl@p\actions@listR\to\next@actionR
    \fi
  \else
    \global\page@num=\m@ne
    \ifx\actionlines@list\empty
      \gdef\next@actionline{1000000}%
    \else
      \gl@p\actionlines@list\to\next@actionline
      \gl@p\actions@list\to\next@action
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
% This version of \cs{read@linelist} creates list macros
% containing data for the entire section, so they could get rather
% large. The \cs{memorydump} macro is available if you run into
% macro memory limitations.
%
% \subsection{Commands within the line-list file}
%
% This section defines the commands that can appear within a
% line-list file, except for \cs{@lab} which is in a
% later section among the cross-referencing commands it is
% associated with.
%
% The macros with \verb"action" in their names contain all the code
% that modifies the action-code list.
%
% \begin{macro}{\@l}
% \cs{@l} does everything related to the start of a
% new line of numbered text. Exactly what it does depends
% on whether right text is being processed.
%
%    \begin{macrocode}
\renewcommand{\@l}[2]{% 
  \fix@page{#1}%
  \ifledRcol
    \ifx\l@dchset@num\relax \else
      \advance\absline@numR \@ne
      \set@line@action
      \let\l@dchset@num=\relax
      \advance\absline@numR \m@ne
      \advance\line@numR \m@ne%  % do we need this??
    \fi
    \advance\absline@numR \@ne
%    \end{macrocode}
% Increment the absolute line-number, and perform
% deferred actions relating to page starts and sub-lines.
%    \begin{macrocode}
    \ifx\next@page@numR\relax \else
      \page@action
      \let\next@page@numR=\relax
    \fi
    \ifx\sub@change\relax \else
      \ifnum\sub@change>\z@
        \sublines@true
      \else
        \sublines@false
      \fi
      \sub@action
      \let\sub@change=\relax
    \fi
%    \end{macrocode}
%
% Fix the lock counters, if necessary. A value of $1$ is advanced to
% $2$; $3$ advances to $0$; other values are unchanged.
%    \begin{macrocode}
         \ifcase\@lock
            \or
               \@lock \tw@
            \or \or
               \@lock \z@
         \fi
         \ifcase\sub@lock
            \or
               \sub@lock \tw@
            \or \or
               \sub@lock \z@
         \fi
%    \end{macrocode}
%
% Now advance the visible line number, unless it's been locked.
%    \begin{macrocode}
  \ifsublines@
    \ifnum\sub@lock<\tw@
      \advance\subline@numR \@ne
    \fi
  \else
    \ifnum\@lock<\tw@
      \advance\line@numR \@ne \subline@numR \z@
    \fi
  \fi
  \else
%    \end{macrocode}
% And when we are not in right text
%    \begin{macrocode}
    \@l@reg
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\last@page@numR}
% \begin{macro}{\fix@page}
% We have to adjust \cs{fix@page} to handle parallel texts.
%
%    \begin{macrocode}
\newcount\last@page@numR
  \last@page@numR=-10000
\renewcommand*{\fix@page}[1]{%
  \ifledRcol
    \ifnum #1=\last@page@numR
    \else
      \ifbypage@R
        \line@numR \z@ \subline@numR \z@
      \fi
      \page@numR=#1\relax
      \last@page@numR=#1\relax
      \def\next@page@numR{#1}%
    \fi
  \else
    \ifnum #1=\last@page@num
    \else
      \ifbypage@
        \line@num \z@ \subline@num \z@
      \fi
      \page@num=#1\relax
      \last@page@num=#1\relax
      \def\next@page@num{#1}%
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@adv}
% The \cs{@adv}\marg{num} macro advances
% the current visible line number by the amount specified as
% its argument. This is used to implement \cs{advanceline}.
%    \begin{macrocode}
\renewcommand*{\@adv}[1]{%
  \ifsublines@
    \ifledRcol
      \advance\subline@numR by #1\relax
      \ifnum\subline@numR<\z@
        \led@warn@BadAdvancelineSubline
        \subline@numR \z@
      \fi
    \else
      \advance\subline@num by #1\relax
      \ifnum\subline@num<\z@
        \led@warn@BadAdvancelineSubline
        \subline@num \z@
      \fi
    \fi
  \else
    \ifledRcol
      \advance\line@numR by #1\relax
      \ifnum\line@numR<\z@
        \led@warn@BadAdvancelineLine
        \line@numR \z@
      \fi
    \else
      \advance\line@num by #1\relax
      \ifnum\line@num<\z@
        \led@warn@BadAdvancelineLine
        \line@num \z@
      \fi
    \fi
  \fi
  \set@line@action}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@set}
% The \cs{@set}\marg{num} macro sets
% the current visible line number to the value specified as
% its argument.  This is used to implement \cs{setline}.
%    \begin{macrocode}
\renewcommand*{\@set}[1]{%
  \ifledRcol
    \ifsublines@
      \subline@numR=#1\relax 
    \else
      \line@numR=#1\relax 
    \fi
    \set@line@action
  \else
    \ifsublines@
      \subline@num=#1\relax 
    \else
      \line@num=#1\relax 
    \fi
    \set@line@action
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@d@set}
% \begin{macro}{\l@dchset@num}
% The \cs{l@d@set}\marg{num} macro sets
% the line number for the next \verb?\pstart...? to the value specified as
% its argument.  This is used to implement \cs{setlinenum}.
%
% \verb?\l@dchset@num? is a flag to the \verb?\@l? macro. If it is not
% \verb?\relax? then a linenumber change is to be done.
%    \begin{macrocode}
\renewcommand*{\l@d@set}[1]{%
  \ifledRcol
    \line@numR=#1\relax
    \advance\line@numR \@ne
    \def\l@dchset@num{#1}
  \else
    \line@num=#1\relax
    \advance\line@num \@ne
    \def\l@dchset@num{#1}
  \fi}
\let\l@dchset@num\relax

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\page@action}
% \cs{page@action}
% adds an entry to the action-code list to change the page number.
%    \begin{macrocode}
\renewcommand*{\page@action}{%
  \ifledRcol
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR
    \xright@appenditem{\next@page@numR}\to\actions@listR
  \else
    \xright@appenditem{\the\absline@num}\to\actionlines@list
    \xright@appenditem{\next@page@num}\to\actions@list
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\set@line@action}
% \cs{set@line@action} adds an entry to the action-code
% list to change the visible line number.
%    \begin{macrocode}
\renewcommand*{\set@line@action}{%
  \ifledRcol
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR
    \ifsublines@
       \@l@dtempcnta=-\subline@numR
    \else
       \@l@dtempcnta=-\line@numR
    \fi
    \advance\@l@dtempcnta by -5000\relax
    \xright@appenditem{\the\@l@dtempcnta}\to\actions@listR
  \else
    \xright@appenditem{\the\absline@num}\to\actionlines@list
    \ifsublines@
       \@l@dtempcnta=-\subline@num
    \else
       \@l@dtempcnta=-\line@num
    \fi
    \advance\@l@dtempcnta by -5000\relax
    \xright@appenditem{\the\@l@dtempcnta}\to\actions@list
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\sub@action}
% \cs{sub@action}
% adds an entry to the action-code list to turn sub-lineation on or
% off, according to the current value of the \cs{ifsublines@} flag.
%    \begin{macrocode}
\renewcommand*{\sub@action}{%
  \ifledRcol
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR
    \ifsublines@
      \xright@appenditem{-1001}\to\actions@listR
    \else
      \xright@appenditem{-1002}\to\actions@listR
    \fi
  \else
    \xright@appenditem{\the\absline@num}\to\actionlines@list
    \ifsublines@
      \xright@appenditem{-1001}\to\actions@list
    \else
      \xright@appenditem{-1002}\to\actions@list
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\do@lockon}
% \cs{lock@on}
% adds an entry to the action-code list to turn line number
% locking on. The current setting of the sub-lineation flag tells us
% whether this applies to line numbers or sub-line numbers.
%    \begin{macrocode}
\renewcommand*{\do@lockon}{%
  \ifx\next\lock@off
     \global\let\lock@off=\skip@lockoff
  \else
    \ifledRcol
       \xright@appenditem{\the\absline@numR}\to\actionlines@listR
       \ifsublines@
         \xright@appenditem{-1005}\to\actions@listR
         \ifcase\sub@lock
           \sub@lock \@ne
         \else
           \sub@lock \z@
         \fi
       \else
         \xright@appenditem{-1003}\to\actions@listR
         \ifcase\@lock
           \@lock \@ne
         \else
           \@lock \z@
         \fi
       \fi
    \else
       \xright@appenditem{\the\absline@num}\to\actionlines@list
       \ifsublines@
         \xright@appenditem{-1005}\to\actions@list
         \ifcase\sub@lock
           \sub@lock \@ne
         \else
           \sub@lock \z@
         \fi
       \else
         \xright@appenditem{-1003}\to\actions@list
         \ifcase\@lock
           \@lock \@ne
         \else
           \@lock \z@
         \fi
       \fi
    \fi  
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lock@off}
% \begin{macro}{\do@lockoff}
% \begin{macro}{\skip@lockoff}
% \cs{lock@off} adds an entry to the action-code list
% to turn line number locking off.
%    \begin{macrocode}
\renewcommand*{\do@lockoff}{%
  \ifledRcol
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR
    \ifsublines@
      \xright@appenditem{-1006}\to\actions@listR
      \ifnum\sub@lock=\tw@
        \sub@lock \thr@@
      \else
        \sub@lock \z@
      \fi
    \else
      \xright@appenditem{-1004}\to\actions@listR
      \ifnum\@lock=\tw@
        \@lock \thr@@
      \else
        \@lock \z@
      \fi
    \fi
  \else
    \xright@appenditem{\the\absline@num}\to\actionlines@list
    \ifsublines@
      \xright@appenditem{-1006}\to\actions@list
      \ifnum\sub@lock=\tw@
        \sub@lock \thr@@
      \else
        \sub@lock \z@
      \fi
    \else
      \xright@appenditem{-1004}\to\actions@list
      \ifnum\@lock=\tw@
        \@lock \thr@@
      \else
        \@lock \z@
      \fi
    \fi
  \fi}
\global\let\lock@off=\do@lockoff

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\n@num}
% This macro implements the \cs{skipnumbering} command. It uses a new
% action code, namely 1007.
%    \begin{macrocode}
\providecommand*{\n@num}{}
\renewcommand*{\n@num}{%
  \ifledRcol
    \xright@appenditem{\the\absline@numR}\to\actionlines@listR
    \xright@appenditem{-1007}\to\actions@listR
  \else
    \n@num@reg
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ref}
% \begin{macro}{\insert@countR}
% \cs{@ref}
% marks the start of a passage, for creation of a footnote reference.
% It takes two arguments:
% \begin{itemize}\addtolength{\itemsep}{-1ex}
% \item \verb"#1", the number of entries to add to \cs{insertlines@list}
% for this reference. \SpecialMainIndex{\insert@count}
% This value for right text, here and within \cs{edtext},
% which computes it and writes it to the line-list file,
% will be stored in the count \cs{insert@countR}.
%    \begin{macrocode}
\newcount\insert@countR
%    \end{macrocode}
%
% \item \verb"#2", a sequence of other line-list-file commands, executed to
% determine the ending line-number. (This may also include other
% \cs{@ref} commands, corresponding to uses of \cs{edtext}
% within the first argument of another instance of \cs{edtext}.)
% \end{itemize}
%
% The first thing \cs{@ref} itself does is to add the specified number
% of items to the \cs{insertlines@list} list.
%    \begin{macrocode}
\renewcommand*{\@ref}[2]{%
  \ifledRcol
    \global\insert@countR=#1\relax
    \loop\ifnum\insert@countR>\z@
      \xright@appenditem{\the\absline@numR}\to\insertlines@listR
      \global\advance\insert@countR \m@ne
    \repeat
%    \end{macrocode}
%
% Next, process the second argument to determine the page
% and line numbers for the end of this lemma.
% We temporarily equate \cs{@ref} to a different macro that just executes
% its argument, so that nested \cs{@ref} commands are just skipped
% this time. Some other macros need to be temporarily redefined to
% suppress their action.
%    \begin{macrocode}
  \begingroup
    \let\@ref=\dummy@ref
    \let\page@action=\relax
    \let\sub@action=\relax
    \let\set@line@action=\relax
    \let\@lab=\relax
    #2
    \global\endpage@num=\page@numR
    \global\endline@num=\line@numR
    \global\endsubline@num=\subline@numR
  \endgroup
%    \end{macrocode}
%
% Now store all the information about the location of the lemma's
% start and end in \cs{line@list}.
%    \begin{macrocode}
    \xright@appenditem%
      {\the\page@numR|\the\line@numR|%
       \ifsublines@ \the\subline@numR \else 0\fi|%
       \the\endpage@num|\the\endline@num|%
       \ifsublines@ \the\endsubline@num \else 0\fi}\to\line@listR
%    \end{macrocode}
%
% Finally, execute the second argument of \cs{@ref} again,
% to perform for real all the commands within it.
%    \begin{macrocode}
  #2
  \else
%    \end{macrocode}
% And when not in right text
%    \begin{macrocode}
    \@ref@reg{#1}{#2}%
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@pend}
% \begin{macro}{\@pendR}
% \cs{@pend}\marg{num} adds its argument to the \cs{linesinpar@listL}
% list, and analagously for \cs{@pendR}. We start off with a 
% \cs{providecommand} just in case an older version of \Ledmac{} is being
% used which does not define these macros.
%    \begin{macrocode}
\providecommand*{\@pend}[1]{}
\renewcommand*{\@pend}[1]{%
  \xright@appenditem{#1}\to\linesinpar@listL}
\providecommand*{\@pendR}[1]{}
\renewcommand*{\@pendR}[1]{%
  \xright@appenditem{#1}\to\linesinpar@listR}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@lopL}
% \begin{macro}{\@lopR}
% \cs{@lopL}\marg{num} adds its argument to the \cs{linesonpage@listL}
% list, and analagously for \cs{@lopR}. We start off with a 
% \cs{providecommand} just in case an older version of \Ledmac{} is being
% used which does not define these macros.
%    \begin{macrocode}
\providecommand*{\@lopL}[1]{}
\renewcommand*{\@lopL}[1]{%
  \xright@appenditem{#1}\to\linesonpage@listL}
\providecommand*{\@lopR}[1]{}
\renewcommand*{\@lopR}[1]{%
  \xright@appenditem{#1}\to\linesonpage@listR}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Writing to the line-list file}
%
% We've now defined all the counters, lists, and commands involved in
% reading the line-list file at the start of a section. Now we'll
% cover the commands that \Ledmac{} uses within the text of a
% section to write commands out to the line-list.
%
% \begin{macro}{\linenum@outR}
% The file for right texts will be opened on output stream \cs{linenum@outR}.
%    \begin{macrocode}
\newwrite\linenum@outR
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\iffirst@linenum@out@R}
% \begin{macro}{\first@linenum@out@Rtrue}
% \begin{macro}{\first@linenum@out@Rfalse}
% Once any file is opened on this stream, we keep it open forever, or
% else switch to another file that we keep open.
%    \begin{macrocode}
\newif\iffirst@linenum@out@R
  \first@linenum@out@Rtrue
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\line@list@stuffR}
% This is the right text version of the \cs{line@list@stuff}\marg{file} 
% macro. It is called by \cs{beginnumberingR} and performs
% all the line-list operations needed at the start of a section.
% Its argument is the name of the line-list file.
%    \begin{macrocode}
\newcommand*{\line@list@stuffR}[1]{%
  \read@linelist{#1}%
  \iffirst@linenum@out@R
     \immediate\closeout\linenum@outR
     \global\first@linenum@out@Rfalse
     \immediate\openout\linenum@outR=#1
  \else
     \closeout\linenum@outR
     \openout\linenum@outR=#1
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\new@lineR}
% The \cs{new@lineR} macro sends the \cs{@l} command to the right text
% line-list file, to mark the start of a new text line.
%    \begin{macrocode}
\newcommand*{\new@lineR}{%
  \write\linenum@outR{\string\@l[\the\c@page][\thepage]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\flag@start}
% \begin{macro}{\flag@end}
% We enclose a lemma marked by \cs{edtext} in
% \cs{flag@start} and \cs{flag@end}: these send the \cs{@ref}
% command to the line-list file.
% \changes{v0.3}{2005/02/04}{Removed extraneous spaces from\cs{flag@end}}
%    \begin{macrocode}
\renewcommand*{\flag@start}{%
  \ifledRcol
    \edef\next{\write\linenum@outR{%
                  \string\@ref[\the\insert@countR][}}%
    \next
  \else
    \edef\next{\write\linenum@out{%
                  \string\@ref[\the\insert@count][}}%
    \next
  \fi}
\renewcommand*{\flag@end}{%
  \ifledRcol
    \write\linenum@outR{]}%
  \else
    \write\linenum@out{]}%
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\startsub}
% \begin{macro}{\endsub}
% \cs{startsub} and \cs{endsub}
% turn sub-lineation on and off, by writing
% appropriate instructions to the line-list file.
%    \begin{macrocode}
\renewcommand*{\startsub}{\dimen0\lastskip
  \ifdim\dimen0>0pt \unskip \fi
  \ifledRcol \write\linenum@outR{\string\sub@on}%
  \else      \write\linenum@out{\string\sub@on}%
  \fi
  \ifdim\dimen0>0pt \hskip\dimen0 \fi}
\def\endsub{\dimen0\lastskip
  \ifdim\dimen0>0pt \unskip \fi
  \ifledRcol \write\linenum@outR{\string\sub@off}%
  \else      \write\linenum@out{\string\sub@off}%
  \fi
  \ifdim\dimen0>0pt \hskip\dimen0 \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\advanceline}
% You can use \cs{advanceline}\marg{num}
% in running text to advance the current visible
% line-number by a specified value, positive or negative.
%    \begin{macrocode}
\renewcommand*{\advanceline}[1]{%
  \ifledRcol \write\linenum@outR{\string\@adv[#1]}%
  \else      \write\linenum@out{\string\@adv[#1]}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setline}
% You can use \cs{setline}\marg{num}
% in running text (i.e., within \verb?\pstart...\pend?) to set the 
% current visible
% line-number to a specified positive value.
%    \begin{macrocode}
\renewcommand*{\setline}[1]{%
  \ifnum#1<\z@
    \led@warn@BadSetline
  \else
    \ifledRcol \write\linenum@outR{\string\@set[#1]}%
    \else      \write\linenum@out{\string\@set[#1]}%
    \fi
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setlinenum}
% You can use \cs{setlinenum}\marg{num}
% before a \verb?\pstart? to set the visible line-number to a specified 
% positive value. It writes a \verb?\l@d@set? command to the line-list file.
%    \begin{macrocode}
\renewcommand*{\setlinenum}[1]{%
  \ifnum#1<\z@
    \led@warn@BadSetlinenum
  \else
    \ifledRcol \write\linenum@outR{\string\l@d@set[#1]}
    \else      \write\linenum@out{\string\l@d@set[#1]} \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\startlock}
% \begin{macro}{\endlock}
% You can use \cs{startlock} or \cs{endlock}
% in running text to start or end line number locking at
% the current line. They decide whether line numbers or sub-line numbers
% are affected, depending on the current state of the sub-lineation flags.
%    \begin{macrocode}
\renewcommand*{\startlock}{%
  \ifledRcol \write\linenum@outR{\string\lock@on}%
  \else      \write\linenum@out{\string\lock@on}%
  \fi}
\def\endlock{%
  \ifledRcol \write\linenum@outR{\string\lock@off}%
  \else      \write\linenum@out{\string\lock@off}%
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\skipnumbering}
% In numbered text, \cs{skipnumbering} in a line will suspend the 
% numbering for that particular line. That is, line numbers are unchanged and
% no line number will be printed.
%    \begin{macrocode}
\renewcommand*{\skipnumbering}{%
  \ifledRcol \write\linenum@outR{\string\n@num}%
             \advanceline{-1}%
  \else      
    \skipnumbering@reg
  \fi}

%    \end{macrocode}
% \end{macro}
%
%
% \section{Marking text for notes}
% \label{text}\relax
%
% The \cs{edtext} (or \cs{critext}) macro is used to create all 
% footnotes and endnotes,
% as well as to print the portion of the main text to which a given note
% or notes is keyed. The idea is to have that lemma appear only once in
% the \file{.tex} file: all instances of it in the main text and in the
% notes are copied from that one appearance.
%
% \cs{critext} requires two arguments. At any point within numbered
% text, you use it by saying:
% \begin{verbatim}
%     \critext{#1}#2/
% \end{verbatim}
% Similarly \cs{edtext} requires the same two arguments
% but you use it by saying:
% \begin{verbatim}
%     \edtext{#1}{#2}
% \end{verbatim}
% 
%
% \begin{macro}{\critext}
% Now we begin \cs{critext} itself. 
%
% We slightly modify the original to make accomodation for when right text is 
% being processed.
%
%    \begin{macrocode}
\long\def\critext#1#2/{\leavevmode
  \begingroup
    \no@expands
    \xdef\@tag{#1}%
    \set@line
    \ifledRcol \global\insert@countR \z@ 
    \else      \global\insert@count \z@ \fi
    \ignorespaces #2\relax
    \flag@start
  \endgroup
  \showlemma{#1}%
  \ifx\end@lemmas\empty \else
    \gl@p\end@lemmas\to\x@lemma
    \x@lemma
    \global\let\x@lemma=\relax
  \fi
  \flag@end}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\edtext}
% And similarly for \cs{edtext}.
%    \begin{macrocode}
\renewcommand{\edtext}[2]{\leavevmode
  \begingroup
    \no@expands
    \xdef\@tag{#1}%
    \set@line
    \ifledRcol \global\insert@countR \z@ 
    \else      \global\insert@count \z@ \fi
    \ignorespaces #2\relax
    \flag@start
  \endgroup
  \showlemma{#1}%
  \ifx\end@lemmas\empty \else
    \gl@p\end@lemmas\to\x@lemma
    \x@lemma
    \global\let\x@lemma=\relax
  \fi
  \flag@end}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\set@line}
% The \cs{set@line} macro
% is called by \cs{edtext} to put the line-reference field and
% font specifier for the current block of text into \cs{l@d@nums}.
%    \begin{macrocode}
\renewcommand*{\set@line}{%
  \ifledRcol
    \ifx\line@listR\empty
      \global\noteschanged@true
      \xdef\l@d@nums{000|000|000|000|000|000|\edfont@info}%
    \else
      \gl@p\line@listR\to\@tempb
      \xdef\l@d@nums{\@tempb|\edfont@info}%
      \global\let\@tempb=\undefined
    \fi
  \else
    \ifx\line@list\empty
      \global\noteschanged@true
      \xdef\l@d@nums{000|000|000|000|000|000|\edfont@info}%
    \else
      \gl@p\line@list\to\@tempb
      \xdef\l@d@nums{\@tempb|\edfont@info}%
      \global\let\@tempb=\undefined
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \section{Parallel environments}
%
% The initial set up for parallel processing is deceptively simple.
%
%
% \begin{environment}{pairs}
% \begin{environment}{pages}
% The \verb?pairs? environment is for parallel columns and the \verb?pages?
% environment for parallel pages.
%    \begin{macrocode}
\newenvironment{pairs}{%
  \l@dpairingtrue
  \l@dpagingfalse
}{%
  \l@dpairingfalse
}
%    \end{macrocode}
% The \verb?pages? environment additionally sets the `column' widths to the
% \cs{textwidth} (as known at the time the package is called).
%    \begin{macrocode}
\newenvironment{pages}{%
  \l@dpairingtrue
  \l@dpagingtrue
  \setlength{\Lcolwidth}{\textwidth}%
  \setlength{\Rcolwidth}{\textwidth}%
}{%
  \l@dpairingfalse
  \l@dpagingfalse
}

%    \end{macrocode}
% \end{environment}
% \end{environment}
%
% \begin{environment}{Leftside}
% Within the \verb?pairs? and \verb?pages? environments the left and
% right hand texts are within \verb?Leftside? and \verb?Rightside?
% environments, respectively. The \verb?Leftside? environment is simple, 
% indicating that right text is not within its purview and using some 
% particular macros.
% \changes{v0.3}{2005/02/10}{Added hooks into Leftside environment}
%    \begin{macrocode}
\newenvironment{Leftside}{%
  \ledRcolfalse
  \let\pstart\pstartL
  \let\pend\pendL
  \let\memorydump\memorydumpL
  \Leftsidehook
}{\Leftsidehookend}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\Leftsidehook}
% \begin{macro}{\Leftsidehookend}
% \begin{macro}{\Rightsidehook}
% \begin{macro}{\Rightsidehookend}
% Hooks into the start and end of the \texttt{Leftside} and \texttt{Rightside}
% environments. These are initially empty.
% \changes{v0.3}{2005/02/10}{Added \cs{Leftsidehook}, \cs{Leftsidehookend},
%                            \cs{Rightsidehook} and \cs{Rightsidehookend}}
%    \begin{macrocode}
\newcommand*{\Leftsidehook}{}
\newcommand*{\Leftsidehookend}{}
\newcommand*{\Rightsidehook}{}
\newcommand*{\Rightsidehookend}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{environment}{Rightside}
% The \verb?Rightside? environment is only slightly more complicated
% than the \verb?Leftside?.
% Apart from indicating that right text is being provided it 
% ensures that the right right text code will be used.
%    \begin{macrocode}
\newenvironment{Rightside}{%
  \ledRcoltrue
  \let\beginnumbering\beginnumberingR
  \let\endnumbering\endnumberingR
  \let\pausenumbering\pausenumberingR
  \let\resumenumbering\resumenumberingR
  \let\memorydump\memorydumpR
  \let\pstart\pstartR
  \let\pend\pendR
  \let\lineation\lineationR
  \Rightsidehook
}{%
  \ledRcolfalse
  \Rightsidehookend
}

%    \end{macrocode}
% \end{environment}
%
%
%
% \section{Paragraph decomposition and reassembly}
% \label{paragraph}\relax
%
% In order to be able to count the lines of text and affix line
% numbers, we add an extra stage of processing for each paragraph.
% We send the paragraph into a box
% register, rather than straight onto the vertical list, and when
% the paragraph ends we
% slice the paragraph into its component lines; to each line we
% add any notes or line numbers, add a command to write to the
% line-list, and then at last send the line to the vertical list.
% This section contains all the code for this processing.
%
% \subsection{Boxes, counters, {\tt\protect\bslash pstart}
% and {\tt\protect\bslash pend}}
%
% \begin{macro}{\num@linesR}
% \begin{macro}{\one@lineR}
% \begin{macro}{\par@lineR}
% Here are numbers and flags that are used internally in the course
% of the paragraph decomposition.
%
% When we first form the paragraph, it goes into a box register,
% \cs{l@dLcolrawbox} or \cs{l@dRcolrawbox} for right text, instead of onto the 
% current vertical list.
% The \cs{ifnumberedpar@} flag will be \verb"true" while a paragraph is
% being processed in that way.
% \cs{num@lines(R)} will store the number of lines in the paragraph
% when it's complete. When we chop it up into lines, each line
% in turn goes into the
% \cs{one@line} or \cs{one@lineR} register, and \cs{par@line(R)} 
% will be the number
% of that line within the paragraph.
%    \begin{macrocode}
\newcount\num@linesR
\newbox\one@lineR
\newcount\par@lineR
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pstartL}
% \begin{macro}{\pstartR}
% \cs{pstart} starts the paragraph by
% clearing the \cs{inserts@list} list and other
% relevant variables, and then arranges for the
% subsequent text to go into the appropriate box. 
% \cs{pstart} needs to appear at the start of
% every paragraph that's to be numbered.
%
% Beware: everything that occurs between \cs{pstart} and \cs{pend}
% is happening within a group; definitions must be global if you want
% them to survive past the end of the paragraph.
%
% We have to have specific left and right \cs{pstart} when parallel processing;
% among other things because of potential changes in the linewidth.
% 
%    \begin{macrocode}
\newcommand*{\pstartL}{\ifnumbering \else
    \led@err@PstartNotNumbered
    \beginnumbering
  \fi
  \ifnumberedpar@
    \led@err@PstartInPstart
    \pend
  \fi
%    \end{macrocode}
% If this is the first \cs{pstart} in a numbered section, clear any inserts
% and set \cs{ifpst@rtedL} to FALSE.
%    \begin{macrocode}
  \ifpst@rtedL\else
    \list@clear{\inserts@list}%
    \global\let\next@insert=\empty
     \global\pst@rtedLtrue
  \fi
  \begingroup\normal@pars
%    \end{macrocode}
% When parallel processing we check that we haven't exceeded
% the maximum number of chunks. In any event we grab a box for the
% forthcoming text.
%    \begin{macrocode}
  \global\advance\l@dnumpstartsL \@ne
  \ifnum\l@dnumpstartsL>\l@dc@maxchunks
    \led@err@TooManyPstarts
    \global\l@dnumpstartsL=\l@dc@maxchunks
  \fi
  \global\setnamebox{l@dLcolrawbox\the\l@dnumpstartsL}=\vbox\bgroup%
                     \hsize=\Lcolwidth
  \numberedpar@true}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\pstartR}{\ifnumberingR \else
    \led@err@PstartNotNumbered
    \beginnumberingR
  \fi
  \ifnumberedpar@
    \led@err@PstartInPstart
    \pendR
  \fi
  \ifpst@rtedR\else
    \list@clear{\inserts@listR}%
    \global\let\next@insertR=\empty
    \global\pst@rtedRtrue
  \fi
  \begingroup\normal@pars
  \global\advance\l@dnumpstartsR \@ne
  \ifnum\l@dnumpstartsR>\l@dc@maxchunks
    \led@err@TooManyPstarts
    \global\l@dnumpstartsR=\l@dc@maxchunks
  \fi
  \global\setnamebox{l@dRcolrawbox\the\l@dnumpstartsR}=\vbox\bgroup%
                     \hsize=\Rcolwidth
  \numberedpar@true}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\pendL}
% \cs{pend} must be used to end a numbered paragraph. Again we need 
% a version 
% that knows about left parallel texts.
%
%    \begin{macrocode}
\newcommand*{\pendL}{\ifnumbering \else
    \led@err@PendNotNumbered
  \fi
  \ifnumberedpar@ \else
    \led@err@PendNoPstart
  \fi
%    \end{macrocode}
% We set all the usual interline penalties to zero and then immediately
% call \cs{endgraf} to end the paragraph; this ensures that there'll
% be no large interline penalties to prevent us from slicing the
% paragraph into pieces. These penalties revert to the values
% that you set when the group for the \cs{vbox} ends. 
%    \begin{macrocode}
  \l@dzeropenalties
  \endgraf\global\num@lines=\prevgraf\egroup
  \global\par@line=0
%    \end{macrocode}
% End the group that was begun in the \cs{pstart}.
%    \begin{macrocode}
  \endgroup
  \ignorespaces}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pendR}
% The version of \cs{pend} needed for right texts.
%
%    \begin{macrocode}
\newcommand*{\pendR}{\ifnumberingR \else
    \led@err@PendNotNumbered
  \fi
  \ifnumberedpar@ \else
    \led@err@PendNoPstart
  \fi
  \l@dzeropenalties
  \endgraf\global\num@linesR=\prevgraf\egroup
  \global\par@lineR=0
  \endgroup
  \ignorespaces}

%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Processing one line}
%
% For parallel texts we have to be able to process left and right lines
% independently. For sequential text we happily use the 
% original \cs{do@line}. Otherwise \ldots
%
% \begin{macro}{\l@dleftbox}
% \begin{macro}{\l@drightbox}
% A line of left text will be put in the box \cs{l@dleftbox}, and analagously
% for a line of right text.
%    \begin{macrocode}
\newbox\l@dleftbox
\newbox\l@drightbox

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\countLline}
% \begin{macro}{\countRline}
% We need to know the number of lines processed.
%    \begin{macrocode}
\newcount\countLline
  \countLline \z@
\newcount\countRline
  \countRline \z@

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@donereallinesL}
% \begin{macro}{\@donetotallinesL}
% \begin{macro}{\@donereallinesR}
% \begin{macro}{\@donetotallinesR}
% We need to know the number of `real' lines output (i.e., those that
% have been input by the user), and the total lines output (which includes
% any blank lines output for synchronisation).
%    \begin{macrocode}
\newcount\@donereallinesL
\newcount\@donetotallinesL
\newcount\@donereallinesR
\newcount\@donetotallinesR

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\do@lineL}
% The \cs{do@lineL} macro is called to 
% do all the processing for a single line of left text.
% \changes{v0.3}{2005/02/10}{Added \cs{do@lineLhook} to \cs{do@lineL}}
% \changes{v0.3}{2005/02/10}{Simplified \cs{do@lineL} by using macros for 
%                            some common code}
%    \begin{macrocode}
\newcommand*{\do@lineL}{%
  \advance\countLline \@ne
%    \end{macrocode}
% If the current \cs{l@dLcolrawbox} box is not empty it contains
% the remaining unprocessed lines of the chunk, so
% pull one line off the top.
% \cs{vbadness} must be cranked up to
% suppress \verb"Underfull vbox" errors from
% \cs{vsplit}; \cs{splittopskip} will be inserted at the top of
% \cs{one@line}, so we zero it. (This skip will appear in the final
% vertical list, just before every \cs{baselineskip}.)
%    \begin{macrocode}
  \ifvbox\namebox{l@dLcolrawbox\the\l@dpscL}%
    {\vbadness=10000 \splittopskip=0pt
%    \end{macrocode}
% Insert the \cs{do@lineLhook} and 
% null the \cs{...d@ta}, which may later hold line numbers, here. 
% They will get defined within \cs{affixline@num}. Similarly for
% \cs{l@dcsnotetext} for the text of a sidenote.
%    \begin{macrocode}
    \do@lineLhook
    \l@demptyd@ta
%    \end{macrocode}
%
%    \begin{macrocode}
    \global\setbox\one@line=\vsplit\namebox{l@dLcolrawbox\the\l@dpscL}
                             to\baselineskip}%
%    \end{macrocode}
%
% \cs{one@line} comes out of \cs{vsplit} as a \verb"vbox";
% we now convert it to an \verb"hbox".
%    \begin{macrocode}
   \unvbox\one@line \global\setbox\one@line=\lastbox
%    \end{macrocode}
%
% Calculate the line and page number for this line.
%    \begin{macrocode}
   \getline@num
%    \end{macrocode}
% Now we'll put the line into a box of the apropriate width, with a line 
% number attached if necessary.
%    \begin{macrocode}
   \setbox\l@dleftbox
   \hb@xt@ \Lcolwidth{%
%    \end{macrocode}
% Add line numbers, inserts, sidenotes, etc.
%    \begin{macrocode}
     \affixline@num
     \l@dld@ta
     \add@inserts
     \affixside@note
%    \end{macrocode}
% Now stick everything into a set of boxes. 
%    \begin{macrocode}
     \l@dlsn@te% left side note
  {\ledllfill\hb@xt@ \wd\one@line{\new@line\unhbox\one@line}\ledrlfill\l@drd@ta
     \l@drsn@te% right side note
  }}%
%    \end{macrocode}
% Penalties get stripped off by this slicing process; the following
% macro puts them back in as the last stepandthen we increment the
% number of `real' (text),and total lines done.
%    \begin{macrocode}
    \add@penaltiesL
    \global\advance\@donereallinesL\@ne
    \global\advance\@donetotallinesL\@ne
%    \end{macrocode}
% Otherwise, the curent \cs{l@dLcolrawbox} has been emptied, so just 
% generate an empty box and increment the total lines.
%    \begin{macrocode}
  \else
    \setbox\l@dleftbox \hb@xt@ \Lcolwidth{\hspace*{\Lcolwidth}}%
    \global\advance\@donetotallinesL\@ne
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\do@lineLhook}
% \begin{macro}{\do@lineRhook}
% Hooks, initially empty, into the respective \cs{do@line(L/R)} macros.
% \changes{v0.3}{2005/02/10}{Added \cs{do@lineLhook} and \cs{do@lineRhook}}
%    \begin{macrocode}
\newcommand*{\do@lineLhook}{}
\newcommand*{\do@lineRhook}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\do@lineR}
% The \cs{do@lineR} macro is called to 
% do all the processing for a single line of right text.
% \changes{v0.3}{2005/02/10}{Changed \cs{do@lineR} similarly to \cs{do@lineL}}
%    \begin{macrocode}
\newcommand*{\do@lineR}{%
  \advance\countRline \@ne
  \ifvbox\namebox{l@dRcolrawbox\the\l@dpscR}%
   {\vbadness=10000 \splittopskip=0pt
    \do@lineRhook
    \l@demptyd@ta
    \global\setbox\one@lineR=\vsplit\namebox{l@dRcolrawbox\the\l@dpscR}
                             to\baselineskip}%
   \unvbox\one@lineR \global\setbox\one@lineR=\lastbox
   \getline@numR
   \setbox\l@drightbox
   \hb@xt@ \Rcolwidth{%
     \affixline@numR
     \l@dld@ta
     \add@insertsR
     \affixside@noteR
     \l@dlsn@te% left side note
  {\ledllfill\hb@xt@ \wd\one@lineR{\new@lineR\unhbox\one@lineR}\ledrlfill\l@drd@ta
     \l@drsn@te% right side note
  }}%
    \add@penaltiesR
    \global\advance\@donereallinesR \@ne
    \global\advance\@donetotallinesR \@ne
  \else
    \setbox\l@drightbox \hb@xt@ \Rcolwidth{\hspace*{\Rcolwidth}}
    \global\advance\@donetotallinesR \@ne
  \fi}

%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Line and page number computation}
%
% \begin{macro}{\getline@numR}
% The \cs{getline@numR} macro
% determines the page and line numbers for the right text line we're about to
% send to the vertical list.
%    \begin{macrocode}
\newcommand*{\getline@numR}{%
  \global\advance\absline@numR \@ne
  \do@actionsR
  \do@ballastR
  \ifsublines@
     \ifnum\sub@lock<\tw@
       \global\advance\subline@numR \@ne
     \fi
  \else
     \ifnum\@lock<\tw@
       \global\advance\line@numR \@ne
       \global\subline@numR=\z@
     \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\do@ballastR}
% \phantomsection\label{do@ballastR}\relax
% The real work in the line macros above is done in \cs{do@actions}, but
% before we plunge into that, let's get \cs{do@ballastR} out of the
% way.  
%    \begin{macrocode}
\newcommand*{\do@ballastR}{\global\ballast@count=\z@
  \begingroup
    \advance\absline@numR \@ne
    \ifnum\next@actionlineR=\absline@numR
      \ifnum\next@actionR>-1001
        \global\advance\ballast@count by -\c@ballast
       \fi
     \fi
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\do@actionsR}
% \begin{macro}{\do@actions@nextR}
%
% The \cs{do@actionsR} macro
% looks at the list of actions to take at particular right text absolute line
% numbers, and does everything that's specified for the current line.
%
% It may call itself recursively and we use tail recursion, via
% \cs{do@actions@nextR} for this.
% \changes{v0.3}{2005/02/24}{Used \cs{do@actions@fixedcode} in \cs{do@actionsR}}
%    \begin{macrocode}
\newcommand*{\do@actionsR}{%
  \global\let\do@actions@nextR=\relax
  \@l@dtempcntb=\absline@numR
  \ifnum\@l@dtempcntb<\next@actionlineR\else
    \ifnum\next@actionR>-1001
       \global\page@numR=\next@actionR
       \ifbypage@R
         \global\line@numR=\z@ \global\subline@numR=\z@
       \fi
    \else
       \ifnum\next@actionR<-4999
          \@l@dtempcnta=-\next@actionR
          \advance\@l@dtempcnta by -5001
          \ifsublines@
             \global\subline@numR=\@l@dtempcnta
          \else
             \global\line@numR=\@l@dtempcnta
          \fi
       \else
          \@l@dtempcnta=-\next@actionR
          \advance\@l@dtempcnta by -1000
          \do@actions@fixedcode
       \fi
    \fi
    \ifx\actionlines@listR\empty
         \gdef\next@actionlineR{1000000}%
    \else
         \gl@p\actionlines@listR\to\next@actionlineR
         \gl@p\actions@listR\to\next@actionR
         \global\let\do@actions@nextR=\do@actionsR
    \fi
  \fi
  \do@actions@nextR}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Line number printing}
%
%
% \begin{macro}{\affixline@numR}
% \cs{affixline@numR} is the right text version of the 
% \cs{affixline@num} macro.
% \changes{v0.3}{2005/02/24}{Changed \cs{affixline@numR} to match new ledmac}
%    \begin{macrocode}
\newcommand*{\affixline@numR}{%
\ifl@dskipnumber
  \global\l@dskipnumberfalse
\else
  \ifsublines@
    \@l@dtempcntb=\subline@numR
    \ifnum\subline@numR>\c@firstsublinenumR
      \@l@dtempcnta=\subline@numR
      \advance\@l@dtempcnta by-\c@firstsublinenumR
      \divide\@l@dtempcnta by\c@sublinenumincrementR
      \multiply\@l@dtempcnta by\c@sublinenumincrementR
      \advance\@l@dtempcnta by\c@firstsublinenumR
    \else
      \@l@dtempcnta=\c@firstsublinenumR
    \fi
    \ch@cksub@l@ck
  \else
    \@l@dtempcntb=\line@numR
    \ifx\linenumberlist\empty
      \ifnum\line@numR>\c@firstlinenumR
         \@l@dtempcnta=\line@numR
         \advance\@l@dtempcnta by-\c@firstlinenumR
         \divide\@l@dtempcnta by\c@linenumincrementR
         \multiply\@l@dtempcnta by\c@linenumincrementR
         \advance\@l@dtempcnta by\c@firstlinenumR
      \else
         \@l@dtempcnta=\c@firstlinenumR
      \fi
    \else
      \@l@dtempcnta=\line@numR
      \edef\rem@inder{,\linenumberlist,\number\line@numR,}%
        \edef\sc@n@list{\def\noexpand\sc@n@list
        ####1,\number\@l@dtempcnta,####2|{\def\noexpand\rem@inder{####2}}}%
        \sc@n@list\expandafter\sc@n@list\rem@inder|%
          \ifx\rem@inder\empty\advance\@l@dtempcnta\@ne\fi
    \fi
    \ch@ck@l@ck
  \fi
  \ifnum\@l@dtempcnta=\@l@dtempcntb
 \if@twocolumn
    \if@firstcolumn
      \gdef\l@dld@ta{\llap{{\leftlinenumR}}}%
    \else
      \gdef\l@drd@ta{\rlap{{\rightlinenumR}}}%
    \fi
 \else
    \@l@dtempcntb=\line@marginR
    \ifnum\@l@dtempcntb>\@ne
      \advance\@l@dtempcntb by\page@numR
    \fi
    \ifodd\@l@dtempcntb
      \gdef\l@drd@ta{\rlap{{\rightlinenumR}}}%
    \else
      \gdef\l@dld@ta{\llap{{\leftlinenumR}}}%
    \fi
 \fi
  \else
%%    #1%
  \fi
  \f@x@l@cks
\fi}

%    \end{macrocode}
% \end{macro}
%
% \subsection{Add insertions to the vertical list}
%
% \begin{macro}{\inserts@listR}
% \cs{inserts@listR} is the list macro that contains the inserts that
% we save up for one right text paragraph.
%
%    \begin{macrocode}
\list@create{\inserts@listR}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\add@insertsR}
% \begin{macro}{\add@inserts@nextR}
% The right text version.
%    \begin{macrocode}
\newcommand*{\add@insertsR}{%
  \global\let\add@inserts@nextR=\relax
  \ifx\inserts@listR\empty \else
    \ifx\next@insertR\empty
      \ifx\insertlines@listR\empty
        \global\noteschanged@true
        \gdef\next@insertR{100000}%
      \else
        \gl@p\insertlines@listR\to\next@insertR
      \fi
    \fi
    \ifnum\next@insertR=\absline@numR
      \gl@p\inserts@listR\to\@insertR
      \@insertR
      \global\let\@insertR=\undefined
      \global\let\next@insertR=\empty
      \global\let\add@inserts@nextR=\add@insertsR
    \fi
  \fi
  \add@inserts@nextR}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Penalties}
%
% \begin{macro}{\add@penaltiesL}
% \begin{macro}{\add@penaltiesR}
% \cs{add@penaltiesL} is
% the last macro used by \cs{do@lineL}. It adds up the club,
% widow, and interline penalties, and puts a single penalty
% of the appropriate size
% back into the paragraph; these penalties get
% removed by the \cs{vsplit} operation. \cs{displaywidowpenalty} and
% \cs{brokenpenalty} are not restored, since we have no easy way to
% find out where we should insert them.
%
% \phantomsection\label{add@penalties}
% In the code below, which is a virtual copy of the original
% \cs{add@penalties}, \cs{num@lines} is the number of lines in the whole
% paragraph, and \cs{par@line} is the line we're working on at the
% moment.  The count \cs{@l@dtempcnta} is used to calculate and
% accumulate the penalty; it is initially set to the value of
% \cs{ballast@count}, which has been worked out in \cs{do@ballast}.
% Finally, the penalty is
% checked to see that it doesn't go below $-10000$.
% \begin{verbatim}
% \newcommand*{\add@penaltiesR}{\@l@dtempcnta=\ballast@count
%   \ifnum\num@linesR>\@ne
%     \global\advance\par@lineR \@ne
%     \ifnum\par@lineR=\@ne
%       \advance\@l@dtempcnta by \clubpenalty
%     \fi
%     \@l@dtempcntb=\par@lineR \advance\@l@dtempcntb \@ne
%     \ifnum\@l@dtempcntb=\num@linesR
%       \advance\@l@dtempcnta by \widowpenalty
%     \fi
%     \ifnum\par@lineR<\num@linesR
%       \advance\@l@dtempcnta by \interlinepenalty
%     \fi
%   \fi
%     \ifnum\@l@dtempcnta=\z@
%       \relax
%     \else
%       \ifnum\@l@dtempcnta>-10000
%         \penalty\@l@dtempcnta
%       \else
%         \penalty -10000
%       \fi
%     \fi}
% \end{verbatim}
% This is for a single chunk. However, as we are probably dealing 
% with several chunks at a time, the above is nor really relevant. I think
% that it is likely with parallel text that there is no real need to add
% back any penalties; even if there was, they would have to match across the
% left and right lines. So, I end up with the following.
%
%    \begin{macrocode}
\newcommand*{\add@penaltiesL}{}
\newcommand*{\add@penaltiesR}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Printing leftover notes}
%
% \begin{macro}{\flush@notesR}
% The \cs{flush@notesR}
% macro is called after the entire right text has been sliced up
% and sent on to the vertical list.
%    \begin{macrocode}
\newcommand*{\flush@notesR}{%
  \@xloop
    \ifx\inserts@listR\empty \else
      \gl@p\inserts@listR\to\@insertR
      \@insertR
      \global\let\@insertR=\undefined
  \repeat}

%    \end{macrocode}
% \end{macro}
%
%
% \section{Footnotes}
% \label{footnotes}\relax
%
% \subsection{Outer-level footnote commands}
% \begin{macro}{\Afootnote}
% The outer-level footnote commands will look familiar: they're
% just called \cs{Afootnote}, \cs{Bfootnote}, etc., instead of
% plain \cs{footnote}. What they do, however, is quite different,
% since they have to operate in conjunction with \cs{edtext} when
% numbering is in effect.
%
% If we're within a line-numbered paragraph, then, we tack this note onto
% the \cs{inserts@list} list, and increment the deferred-page-bottom-note
% counter.
%    \begin{macrocode}
\renewcommand*{\Afootnote}[1]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vAfootnote{A}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vAfootnote{A}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
      \global\advance\insert@count \@ne
    \fi
%    \end{macrocode}
%
% Within free text, there's no need to put off making the insertion
% for this note. No line numbers are available, so this isn't generally
% that useful; but you might want to use it to get around some
% limitation of \Ledmac.
%    \begin{macrocode}
  \else
    \vAfootnote{A}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Bfootnote}
% \begin{macro}{\Cfootnote}
% \begin{macro}{\Dfootnote}
% \begin{macro}{\Efootnote}
% We need similar commands for the other footnote series.
%    \begin{macrocode}
\renewcommand*{\Bfootnote}[1]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vBfootnote{B}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vBfootnote{B}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
      \global\advance\insert@count \@ne
    \fi
  \else
    \vBfootnote{B}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand*{\Cfootnote}[1]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vCfootnote{C}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vCfootnote{C}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
      \global\advance\insert@count \@ne
    \fi
  \else
    \vCfootnote{C}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand*{\Dfootnote}[1]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vDfootnote{D}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vDfootnote{D}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
      \global\advance\insert@count \@ne
    \fi
  \else
    \vDfootnote{D}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand*{\Efootnote}[1]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vEfootnote{E}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vEfootnote{E}%
                     {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
      \global\advance\insert@count \@ne
    \fi
  \else
    \vEfootnote{E}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\mpAfootnote}
% \begin{macro}{\mpBfootnote}
% \begin{macro}{\mpCfootnote}
% \begin{macro}{\mpDfootnote}
% \begin{macro}{\mpEfootnote}
% For footnotes in minipages and the like, we need a similar series of commands.
%    \begin{macrocode}
\renewcommand*{\mpAfootnote}[1]{%
  \ifnumberedpar@
  \ifledRcol
    \xright@appenditem{\noexpand\mpvAfootnote{A}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
    \global\advance\insert@countR \@ne
  \else
    \xright@appenditem{\noexpand\mpvAfootnote{A}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
    \global\advance\insert@count \@ne
  \fi
  \else
    \mpvAfootnote{A}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand*{\mpBfootnote}[1]{%
  \ifnumberedpar@
  \ifledRcol
    \xright@appenditem{\noexpand\mpvBfootnote{B}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
    \global\advance\insert@countR \@ne
  \else
    \xright@appenditem{\noexpand\mpvBfootnote{B}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
    \global\advance\insert@count \@ne
  \fi
  \else
    \mpvBfootnote{B}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand*{\mpCfootnote}[1]{%
  \ifnumberedpar@
  \ifledRcol
    \xright@appenditem{\noexpand\mpvCfootnote{C}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
    \global\advance\insert@countR \@ne
  \else
    \xright@appenditem{\noexpand\mpvCfootnote{C}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
    \global\advance\insert@count \@ne
  \fi
  \else
    \mpvCfootnote{C}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand*{\mpDfootnote}[1]{%
  \ifnumberedpar@
  \ifledRcol
    \xright@appenditem{\noexpand\mpvDfootnote{D}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
    \global\advance\insert@countR \@ne
  \else
    \xright@appenditem{\noexpand\mpvDfootnote{D}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
    \global\advance\insert@count \@ne
  \fi
  \else
    \mpvDfootnote{D}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand*{\mpEfootnote}[1]{%
  \ifnumberedpar@
  \ifledRcol
    \xright@appenditem{\noexpand\mpvEfootnote{E}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@listR
    \global\advance\insert@countR \@ne
  \else
    \xright@appenditem{\noexpand\mpvEfootnote{E}%
                   {{\l@d@nums}{\@tag}{#1}}}\to\inserts@list
    \global\advance\insert@count \@ne
  \fi
  \else
    \mpvEfootnote{E}{{0|0|0|0|0|0|0}{}{#1}}%
  \fi\ignorespaces}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Normal footnote formatting} \label{sec:nfootformat}
%
% The \cs{printlines} macro prints the line
% numbers for a note---which, in the
% general case, is a rather complicated task.
% The seven parameters of the
% argument are the line numbers as stored in \cs{l@d@nums}, in the
% form described on page \pageref{linenumbers}: the starting
% page, line, and sub-line numbers, followed by the ending page,
% line, and sub-line numbers, and then the font specifier for
% the lemma.
%
%
% \begin{macro}{\printlinesR}
% \begin{macro}{\ledsavedprintlines}
% This is the right text version of \cs{printlines} and takes account
% of \cs{Rlineflag}. Just in case, \cs{ledsavedprintlines} is a copy
% of the original \cs{printlines}.
% 
% Just a reminder of the arguments: \\
% \verb?\printlinesR    #1      |  #2  |   #3    |    #4    |  #5  |  #6     |   #7? \\
% \verb?\printlinesR start-page | line | subline | end-page | line | subline | font ? 
% \changes{v0.3}{2005/02/10}{Simplified \cs{printlinesR} by using 
%                            \cs{setprintlines}}
%    \begin{macrocode}
\def\printlinesR#1|#2|#3|#4|#5|#6|#7|{\begingroup
  \setprintlines{#1}{#2}{#3}{#4}{#5}{#6}%
  \ifl@d@pnum #1\fullstop\fi
  \ifledplinenum \linenumr@p{#2}\Rlineflag\else \symplinenum\fi
  \ifl@d@ssub \fullstop \sublinenumr@p{#3}\fi
  \ifl@d@dash \endashchar\fi
  \ifl@d@pnum #4\fullstop\fi
  \ifl@d@elin \linenumr@p{#5}\Rlineflag\fi
  \ifl@d@esl \ifl@d@elin \fullstop\fi \sublinenumr@p{#6}\fi
\endgroup}

\let\ledsavedprintlines\printlines

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \section{Cross referencing}
% \label{xref}\relax
%
%
% \begin{macro}{\labelref@listR}
% Set up a new list, \cs{labelref@listR}, to hold the page, line and
% sub-line numbers for each label in right text.
%    \begin{macrocode}
\list@create{\labelref@listR}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\edlabel}
% The \cs{edlabel} command first writes a \cs{@lab} macro to
% the \cs{linenum@out} file.  It then checks to see that the
% \cs{labelref@list} actually has something in it (if not, it
% creates a dummy entry), and pops the next value for the current
% label, storing it in \cs{label@refs}. Finally it defines the
% label to be \cs{empty} so that any future check will turn up
% the fact that it has been used.
%    \begin{macrocode}
\renewcommand*{\edlabel}[1]{\@bsphack
  \ifledRcol
    \write\linenum@outR{\string\@lab}%
    \ifx\labelref@listR\empty
      \xdef\label@refs{\zz@@@}%
    \else
      \gl@p\labelref@listR\to\label@refs
    \fi
    \protected@write\@auxout{}%
      {\string\l@dmake@labelsR\space\thepage|\label@refs|{#1}}%
  \else
    \write\linenum@out{\string\@lab}%
    \ifx\labelref@list\empty
      \xdef\label@refs{\zz@@@}%
    \else
      \gl@p\labelref@list\to\label@refs
    \fi
  \fi
  \protected@write\@auxout{}%
    {\string\l@dmake@labels\space\thepage|\label@refs|{#1}}%
  \@esphack}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dmake@labelsR}
% This is the right text version of \cs{l@dmake@labels}, taking account
% of \cs{Rlineflag}.
%
%    \begin{macrocode}
\def\l@dmake@labelsR#1|#2|#3|#4{%
  \expandafter\ifx\csname the@label#4\endcsname \relax\else
    \led@warn@DuplicateLabel{#4}%
  \fi
  \expandafter\gdef\csname the@label#4\endcsname{#1|#2\Rlineflag|#3}%
  \ignorespaces}
\AtBeginDocument{%
  \def\l@dmake@labelsR#1|#2|#3|#4{}%
}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@lab}
% The \cs{@lab} command, which appears in the \cs{linenum@out} file,
% appends the current values of page, line and sub-line to the
% \cs{labelref@list}. These values are defined by the earlier
% \cs{@page}, \cs{@l}, and the \cs{sub@on} and \cs{sub@off} commands
% appearing in the \cs{linenum@out} file.
%
%    \begin{macrocode}
\renewcommand*{\@lab}{%
  \ifledRcol
    \xright@appenditem{\linenumr@p{\line@numR}|%
      \ifsublines@ \sublinenumr@p{\subline@numR}\else 0\fi}%
      \to\labelref@listR
  \else
    \xright@appenditem{\linenumr@p{\line@num}|%
      \ifsublines@ \sublinenumr@p{\subline@num}\else 0\fi}%
      \to\labelref@list
  \fi}

%    \end{macrocode}
% \end{macro}
%
%
% \section{Side notes}
%
%    Regular \verb?\marginpar?s do not work inside numbered text --- they
% don't produce any note but do put an extra unnumbered blank line into
% the text.
% \begin{macro}{\sidenote@marginR}
% \begin{macro}{\sidenotemargin}
% Specifies which margin sidenotes can be in.
%    \begin{macrocode}
\newcount\sidenote@marginR
\renewcommand*{\sidenotemargin}[1]{{%
  \l@dgetsidenote@margin{#1}%
  \ifnum\@l@dtempcntb>\m@ne
    \ifledRcol
      \global\sidenote@marginR=\@l@dtempcntb 
    \else
      \global\sidenote@margin=\@l@dtempcntb 
    \fi
  \fi}}
\sidenotemargin{right}
\global\sidenote@margin=\@ne

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dlsnote}
% \begin{macro}{\l@drsnote}
% \begin{macro}{\l@dcsnote}
% The `footnotes' for left, right, and moveable sidenotes. The whole 
% scheme is reminiscent of the critical footnotes code.
%    \begin{macrocode}
\renewcommand*{\l@dlsnote}[1]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vl@dlsnote{{\l@d@nums}{\@tag}{#1}}}%
                         \to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vl@dlsnote{{\l@d@nums}{\@tag}{#1}}}%
                         \to\inserts@list
      \global\advance\insert@count \@ne
    \fi
  \fi\ignorespaces}
\renewcommand*{\l@drsnote}[1]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vl@drsnote{{\l@d@nums}{\@tag}{#1}}}%
                         \to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vl@drsnote{{\l@d@nums}{\@tag}{#1}}}%
                         \to\inserts@list
      \global\advance\insert@count \@ne
    \fi
  \fi\ignorespaces}
\renewcommand*{\l@dcsnote}[1]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vl@dcsnote{{\l@d@nums}{\@tag}{#1}}}%
                         \to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vl@dcsnote{{\l@d@nums}{\@tag}{#1}}}%
                         \to\inserts@list
      \global\advance\insert@count \@ne
    \fi
  \fi\ignorespaces}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\affixside@noteR}
% The right text version of \cs{affixside@note}.
%    \begin{macrocode}
\newcommand*{\affixside@noteR}{%
  \gdef\@templ@d{}%
  \ifx\@templ@d\l@dcsnotetext \else
    \if@twocolumn
      \if@firstcolumn
        \setl@dlp@rbox{}{}{\l@dcsnotetext}%
      \else
        \setl@drp@rbox{}{}{\l@dcsnotetext}%
      \fi
    \else
      \@l@dtempcntb=\sidenote@marginR
      \ifnum\@l@dtempcntb>\@ne
        \ifl@dpaging
          \advance\@l@dtempcntb by\@ne
        \else
          \advance\@l@dtempcntb by\page@num
        \fi
      \fi
      \ifodd\@l@dtempcntb
        \setl@drp@rbox{}{}{\l@dcsnotetext}%
      \else
        \setl@dlp@rbox{}{}{\l@dcsnotetext}%
      \fi
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
%
%
% \section{Familiar footnotes}
%
%
% \begin{macro}{\l@dbfnote}
% \verb?\l@dbfnote? adds the footnote to the insert list, and
% \verb?\vl@dbfnote? calls the original \verb?\@footnotetext?.
%    \begin{macrocode}
\renewcommand{\l@dbfnote}[1]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vl@dbfnote{{#1}}{\@thefnmark}}%
                         \to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vl@dbfnote{{#1}}{\@thefnmark}}%
                         \to\inserts@list
      \global\advance\insert@count \@ne
    \fi
  \fi\ignorespaces}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\normalbfnoteX}
% \changes{v0.3}{2005/02/04}{Removed extraneous spaces from \cs{normalbfnoteX}}
%    \begin{macrocode}
\renewcommand{\normalbfnoteX}[2]{%
  \ifnumberedpar@
    \ifledRcol
      \xright@appenditem{\noexpand\vbfnoteX{#1}{#2}{\@nameuse{thefootnote#1}}}%
                         \to\inserts@listR
      \global\advance\insert@countR \@ne
    \else
      \xright@appenditem{\noexpand\vbfnoteX{#1}{#2}{\@nameuse{thefootnote#1}}}%
                         \to\inserts@list
      \global\advance\insert@count \@ne
    \fi
  \fi\ignorespaces}

%    \end{macrocode}
% \end{macro}
%
%
% \section{Verse}
%
% Before we can define the main stanza macros we need to be able to save 
% and reset
% the category code for \&. To save the current value we use
% \verb+\next+ from the \verb+\loop+ macro.
%    \begin{macrocode}
  \chardef\next=\catcode`\&
  \catcode`\&=\active

%    \end{macrocode}
%
%
% \begin{environment}{astanza}
% This is roughly an environmental form of \cs{stanza}, which treats
% its stanza-like contents as a single chunk.
%
%    \begin{macrocode}
\newenvironment{astanza}{%
  \startstanzahook
  \catcode`\&\active
  \global\stanza@count\@ne
  \ifnum\usenamecount{sza@0@}=\z@
    \let\stanza@hang\relax
    \let\endlock\relax
  \else
%%%    \interlinepenalty\@M % this screws things up, but I don't know why
    \rightskip\z@ plus 1fil\relax
  \fi
  \ifnum\usenamecount{szp@0@}=\z@
    \let\sza@penalty\relax
  \fi 
  \def&{%
    \endlock\mbox{}%
    \sza@penalty
    \global\advance\stanza@count\@ne
    \@astanza@line}%
  \def\&{%
    \endlock\mbox{}
    \pend
    \endstanzaextra}%
  \pstart
  \@astanza@line
}{}

%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\@astanza@line}
% This gets put at the start of each line in the environment. It sets up
% the paragraph style --- each line is treated as a paragraph.
%    \begin{macrocode}
\newcommand*{\@astanza@line}{%
  \parindent=\csname sza@\number\stanza@count @\endcsname\stanzaindentbase
  \par
  \stanza@hang%\mbox{}%
  \ignorespaces}

%    \end{macrocode}
% \end{macro}
%
% Lastly reset the modified category codes.
%    \begin{macrocode}
  \catcode`\&=\next

%    \end{macrocode}
%
% \section{Naming macros}
%
%    The LaTeX kernel provides \cs{@namedef} and \cs{@namuse} for defining
% and using macros that may have non-letters in their names. We need
% something similar here as we are going to need and use some numbered
% boxes and counters.
%
% \begin{macro}{\newnamebox}
% \begin{macro}{\setnamebox}
% \begin{macro}{\unhnamebox}
% \begin{macro}{\unvnamebox}
% \begin{macro}{\namebox}
% A set of macros for creating and using `named'boxes; the macros are called 
% after the regular box macros, but including the string `name'.
%    \begin{macrocode}
\providecommand*{\newnamebox}[1]{%
  \expandafter\newbox\csname #1\endcsname}
\providecommand*{\setnamebox}[1]{%
  \expandafter\setbox\csname #1\endcsname}
\providecommand*{\unhnamebox}[1]{%
  \expandafter\unhbox\csname #1\endcsname}
\providecommand*{\unvnamebox}[1]{%
  \expandafter\unvbox\csname #1\endcsname}
\providecommand*{\namebox}[1]{%
                     \csname #1\endcsname}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\newnamecount}
% \begin{macro}{\usenamecount}
% Macros for creating and using `named' counts.
%    \begin{macrocode}
\providecommand*{\newnamecount}[1]{%
  \expandafter\newcount\csname #1\endcsname}
\providecommand*{\usenamecount}[1]{%
                       \csname #1\endcsname}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{Counts and boxes for parallel texts}
%
%    In sequential text, each chunk (that enclosed by \cs{pstart} \ldots
% \cs{pend}) is put into a box called \cs{raw@text} and then immediately
% printed, resulting in the box being emptied and ready for the next chunk. 
% For parallel processing multiple boxes are needed as printing is delayed.
% We also need extra counters for various things.
%
% \begin{macro}{\maxchunks}
% \begin{macro}{\l@dc@maxchunks}
% The maximum number of chunk pairs before printing has to be called for.
% The default is 10 chunk pairs.
%    \begin{macrocode}
\newcount\l@dc@maxchunks
\newcommand{\maxchunks}[1]{\l@dc@maxchunks=#1}
  \maxchunks{10}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dnumpstartsL}
% \begin{macro}{\l@dnumpstartsR}
% The numbers of left and right chunks. \cs{l@dnumpstartsL} is defined
% in \Lpack{ledmac}.
% \changes{v0.3}{2005/02/24}{Moved \cs{l@dnumpstartsL} to ledmac}
%    \begin{macrocode}
\newcount\l@dnumpstartsR

%    \end{macrocode}
% \end{macro}
% \end{macro}
% 
% \begin{macro}{\l@pscL}
% \begin{macro}{\l@pscR}
% A couple of scratch counts for use in left and right texts, respectively.
%    \begin{macrocode}
\newcount\l@dpscL
\newcount\l@dpscR

%    \end{macrocode}
% \end{macro}
% \end{macro}
% 
% \begin{macro}{\l@dsetuprawboxes}
% This macro creates \cs{maxchunks} pairs of boxes for left and right
% chunks. The boxes are called \cs{l@dLcolrawbox1}, \cs{l@dLcolrawbox2}, etc.
%    \begin{macrocode}
\newcommand*{\l@dsetuprawboxes}{%
  \@l@dtempcntb=\l@dc@maxchunks
  \loop\ifnum\@l@dtempcntb>\z@
    \newnamebox{l@dLcolrawbox\the\@l@dtempcntb}
    \newnamebox{l@dRcolrawbox\the\@l@dtempcntb}
    \advance\@l@dtempcntb \m@ne
  \repeat}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dsetupmaxlinecounts}
% \begin{macro}{\l@dzeromaxlinecounts}
% To be able to synchronise left and right texts we need
% to know the maximum number of text lines there are in each pair of chunks.
% \cs{l@dsetupmaxlinecounts} creates \cs{maxchunks} new counts
% called \cs{l@dmaxlinesinpar1}, etc., and
% \cs{l@dzeromaxlinecounts} zeroes all of them.
%    \begin{macrocode}
\newcommand*{\l@dsetupmaxlinecounts}{%
  \@l@dtempcntb=\l@dc@maxchunks
  \loop\ifnum\@l@dtempcntb>\z@
    \newnamecount{l@dmaxlinesinpar\the\@l@dtempcntb}
    \advance\@l@dtempcntb \m@ne
  \repeat}
\newcommand*{\l@dzeromaxlinecounts}{%
  \begingroup
  \@l@dtempcntb=\l@dc@maxchunks
  \loop\ifnum\@l@dtempcntb>\z@
    \global\usenamecount{l@dmaxlinesinpar\the\@l@dtempcntb}=\z@
    \advance\@l@dtempcntb \m@ne
  \repeat
  \endgroup}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% Make sure that all these are set up. This has to be done after the
% user has had an opportunity to change \cs{maxchunks}.
%    \begin{macrocode}
\AtBeginDocument{%
  \l@dsetuprawboxes
  \l@dsetupmaxlinecounts
  \l@dzeromaxlinecounts
  \l@dnumpstartsL=\z@
  \l@dnumpstartsR=\z@
  \l@dpscL=\z@
  \l@dpscR=\z@}

%    \end{macrocode}
%
% \section{Fixing babel}
%
%    With parallel texts there is the possibility that the two sides
% might use different languages via \verb?babel?. On the other hand,
% \verb?babel? might not be called at all (even though it might be already
% built into the format).
% \changes{v0.2}{2004/12/20}{Added section of babel related code}
%
%    With the normal sequential text each line is initially typeset
% in the current language environment, and then it is output at which
% time its attachments are typeset (in the same language environment.
% In the parallel case lines are typeset in their current language but
% an attachment might be typeset outside the language environment
% of its line if the left and right side languages are different.
% To counter this, we have to make sure that the correct language is
% used at the proper times.
%
% \begin{macro}{\ifl@dusedbabel}
% \begin{macro}{\l@dusedbabelfalse}
% \begin{macro}{\l@dusedbabeltrue}
% A flag for checking if \verb?babel? has been used as a package.
%    \begin{macrocode}
\newif\ifl@dusedbabel
  \l@dusedbabelfalse
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifl@dsamelang}
% \begin{macro}{\l@dsamelangfalse}
% \begin{macro}{\l@dsamelangtrue}
% A flag for checking if the same \verb?babel? language has been used 
% for both the left and right texts.
%    \begin{macrocode}
\newif\ifl@dsamelang
  \l@dsamelangtrue
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dchecklang}
% I'm going to use \cs{theledlanguageL} and \cs{theledlanguageR} to hold
% the names of the languages used for the left and right texts. This macro
% sets \cs{ifl@dsamelang} TRUE if they are the same, otherwise it
% sets it FALSE.
%    \begin{macrocode}
\newcommand*{\l@dchecklang}{%
  \l@dsamelangfalse
  \edef\@tempa{\theledlanguageL}\edef\@temp{\theledlanguageR}%
  \ifx\@tempa\@tempb
    \l@dsamelangtrue
  \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dbbl@set@language}
% In \verb?babel? the macro \cs{bbl@set@language}\marg{lang} does the work when
% the language \meta{lang} is changed via \cs{selectlanguage}. 
% Unfortunately for me, if it is given
% an argument in the form of a control sequence it strips off the \verb?\?
% character rather than expanding the command. I need a version that accepts
% an argument in the form \cs{lang} without it stripping the \verb?\?.
%    \begin{macrocode}
\newcommand*{\l@dbbl@set@language}[1]{%
  \edef\languagename{#1}%
  \select@language{\languagename}%
  \if@filesw
    \protected@write\@auxout{}{\string\select@language{\languagename}}%
    \addtocontents{toc}{\string\select@language{\languagename}}%
    \addtocontents{lof}{\string\select@language{\languagename}}%
    \addtocontents{lot}{\string\select@language{\languagename}}%
  \fi}

%    \end{macrocode}
% \end{macro}
%
% The rest of the setup has to be postponed until the end of the preamble
% when we know if \verb?babel? has been used or not. However, for now assume
% that it has not been used.
%
% \begin{macro}{\selectlanguage}
% \begin{macro}{\l@duselanguage}
% \begin{macro}{\theledlanguageL}
% \begin{macro}{\theledlanguageR}
% \cs{selectlanguage} is a \verb?babel? command. \cs{theledlanguageL} and
% \cs{theledlanguageR} are the names of the languages of the left and right
% texts. \cs{l@duselanguage} is similar to \cs{selectlanguage}.
%    \begin{macrocode}
\providecommand{\selectlanguage}[1]{}
\newcommand*{\l@duselanguage}[1]{}
\gdef\theledlanguageL{}
\gdef\theledlanguageR{}

%    \end{macrocode}
%
% Now do the \verb?babel? fix or \verb?polyglossia?, if necessary.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifundefined{xpg@main@language}{% 
    \@ifundefined{bbl@main@language}{% 
%    \end{macrocode}
%  Either \verb?babel? has not been used or it has been used with no
% specified language. 
%    \begin{macrocode}
    \l@dusedbabelfalse
    \renewcommand*{\selectlanguage}[1]{}}{%
%    \end{macrocode}
% Here we deal with the case where babel has been used. \cs{selectlanguage}
% has to be redefined to use our version of \cs{bbl@set@language} and to
% store the left or right language.
%    \begin{macrocode}
    \l@dusedbabeltrue
    \let\l@doldselectlanguage\selectlanguage
    \let\l@doldbbl@set@language\bbl@set@language
    \let\bbl@set@language\l@dbbl@set@language
    \renewcommand{\selectlanguage}[1]{%
      \l@doldselectlanguage{#1}%
      \ifledRcol \gdef\theledlanguageR{#1}%
      \else      \gdef\theledlanguageL{#1}%
      \fi}
%    \end{macrocode}
% \cs{l@duselanguage} simply calls the original \cs{selectlanguage} so
% that \cs{theledlanguageL} and \cs{theledlanguageR} are unaltered.
%    \begin{macrocode}
    \renewcommand*{\l@duselanguage}[1]{%
      \l@doldselectlanguage{#1}}
%    \end{macrocode}
% Lastly, initialise the left and right languages to the current \verb?babel?
% one.
%    \begin{macrocode}
    \gdef\theledlanguageL{\bbl@main@language}%
    \gdef\theledlanguageR{\bbl@main@language}%
    }%
   }
%    \end{macrocode}
% If on Polyglossia
% \begin{macrocode}
  {    \apptocmd{\xpg@set@language}{%
        \ifledRcol \gdef\theledlanguageR{#1}%
        \else      \gdef\theledlanguageL{#1}%
        \fi}%
      \let\l@duselanguage\xpg@set@language
      \gdef\theledlanguageL{\xpg@main@language}%
      \gdef\theledlanguageR{\xpg@main@language}%
% \end{macrocode}
% That's it.
%    \begin{macrocode}
}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \section{Parallel columns}
%
% \begin{macro}{\Columns}
% The \cs{Columns} command results in the previous Left and
% Right texts being typeset in matching columns. There should
% be equal numbers of chunks in the left and right texts.
%
%    \begin{macrocode}
\newcommand*{\Columns}{%
  \ifnum\l@dnumpstartsL=\l@dnumpstartsR\else
    \led@err@BadLeftRightPstarts{\the\l@dnumpstartsL}{\the\l@dnumpstartsR}%
  \fi
%    \end{macrocode}
% Start a group and zero counters, etc.
%    \begin{macrocode}
  \begingroup
    \l@dzeropenalties
    \endgraf\global\num@lines=\prevgraf
            \global\num@linesR=\prevgraf
    \global\par@line=\z@
    \global\par@lineR=\z@
    \global\l@dpscL=\z@
    \global\l@dpscR=\z@
%    \end{macrocode}
% Check if there are chunks to be processed, and process them
% two by two (left and right pairs).
%    \begin{macrocode}
    \check@pstarts
    \loop\if@pstarts
%    \end{macrocode}
% Increment \cs{l@dpscL} and \cs{l@dpscR} which here count
% the numbers of left and right chunks.
%    \begin{macrocode}
      \global\advance\l@dpscL \@ne
      \global\advance\l@dpscR \@ne
%    \end{macrocode}
% Check if there is text yet to be processed in at least one of
% the two current chunks, and also whether the left and right languages 
% are the same
% \changes{v0.2}{2004/12/20}{Added \cs{l@dchecklang} and \cs{l@duselanguage}
%                to \cs{Columns}}
%    \begin{macrocode}
      \checkraw@text
      \l@dchecklang
{        \loop\ifaraw@text
%    \end{macrocode}
% Grab the next pair of left and right text lines and output them, swapping
% languages if they differ
%    \begin{macrocode}
          \ifl@dsamelang
            \do@lineL
            \do@lineR
          \else
            \l@duselanguage{\theledlanguageL}%
            \do@lineL
            \l@duselanguage{\theledlanguageR}%
            \do@lineR
          \fi
          \hb@xt@ \hsize{%
            \unhbox\l@dleftbox
            \hfill \columnseparator \hfill
            \unhbox\l@drightbox
          }%
          \checkraw@text
        \repeat}
%    \end{macrocode}
% Having completed a pair of chunks, write the number of lines
% in each chunk to the respective section files.
%    \begin{macrocode}
      \@writelinesinparL
      \@writelinesinparR
      \check@pstarts
    \repeat
%    \end{macrocode}
% Having output all chunks, make sure all notes have been output,
% then zero counts ready for the next set of texts.
%    \begin{macrocode}
    \flush@notes
    \flush@notesR
  \endgroup
%    \end{macrocode}
%    \begin{macrocode}
  \global\l@dpscL=\z@
  \global\l@dpscR=\z@
  \global\l@dnumpstartsL=\z@
  \global\l@dnumpstartsR=\z@
  \ignorespaces}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\columnseparator}
% \begin{macro}{\columnrulewidth}
% The separator between line pairs in parallel columns is in the form
% of a vertical rule extending a little below the baseline and with a height
% slightly greater than the \cs{baselineskip}. The width of the rule
% is \cs{columnrulewidth} (initially 0pt so the rule is invisible).
%    \begin{macrocode}
\newcommand*{\columnseparator}{%
  \smash{\rule[-0.2\baselineskip]{\columnrulewidth}{1.05\baselineskip}}}
\newdimen\columnrulewidth
  \columnrulewidth=\z@

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@pstarts}
% \begin{macro}{\@pstartstrue}
% \begin{macro}{\@pstartsfalse}
% \begin{macro}{\check@pstarts}
% \cs{check@pstarts} returns \cs{@pstartstrue} if there are any unprocessed
%  chunks.
%    \begin{macrocode}
\newif\if@pstarts
\newcommand*{\check@pstarts}{%
  \@pstartsfalse
  \ifnum\l@dnumpstartsL>\l@dpscL
    \@pstartstrue
  \else
    \ifnum\l@dnumpstartsR>\l@dpscR
      \@pstartstrue
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifaraw@text}
% \begin{macro}{\araw@texttrue}
% \begin{macro}{\araw@textfalse}
% \begin{macro}{\checkraw@text}
% \cs{checkraw@text} checks whether the current Left or Right box is
% void or not. If one or other is not void it sets \cs{araw@texttrue},
% otherwise both are void and it sets \cs{araw@textfalse}.
%    \begin{macrocode} 
\newif\ifaraw@text
  \araw@textfalse
\newcommand*{\checkraw@text}{%
  \araw@textfalse
  \ifvbox\namebox{l@dLcolrawbox\the\l@dpscL}
    \araw@texttrue
  \else  
    \ifvbox\namebox{l@dRcolrawbox\the\l@dpscR}
      \araw@texttrue
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% 
% 
% \begin{macro}{\@writelinesinparL}
% \begin{macro}{\@writelinesinparR}
% These write the number of text lines in a chunk to the section files,
% and then afterwards zero the counter.
%    \begin{macrocode}
\newcommand*{\@writelinesinparL}{%
  \edef\next{%
    \write\linenum@out{\string\@pend[\the\@donereallinesL]}}%
  \next
  \global\@donereallinesL \z@}
\newcommand*{\@writelinesinparR}{%
  \edef\next{%
    \write\linenum@outR{\string\@pendR[\the\@donereallinesR]}}%
  \next
  \global\@donereallinesR \z@}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{Parallel pages}
%
% This is considerably more complicated than parallel columns.
%
% \begin{macro}{\numpagelinesL}
% \begin{macro}{\numpagelinesR}
% \begin{macro}{\l@dminpagelines}
% Counts for the number of lines on a left or right page, and the smaller
% of the number of lines on a pair of facing pages.
%    \begin{macrocode}
\newcount\numpagelinesL
\newcount\numpagelinesR
\newcount\l@dminpagelines

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\Pages}
% The \cs{Pages} command results in the previous Left and
% Right texts being typeset on matching facing pages. There should
% be equal numbers of chunks in the left and right texts.
%
%    \begin{macrocode}
\newcommand*{\Pages}{%
  \typeout{}
  \typeout{*************************** PAGES ***************************}
  \ifnum\l@dnumpstartsL=\l@dnumpstartsR\else
    \led@err@BadLeftRightPstarts{\the\l@dnumpstartsL}{\the\l@dnumpstartsR}%
  \fi
%    \end{macrocode}
% Get onto an empty even (left) page, then initialise counters, etc.
%    \begin{macrocode}
  \cleartol@devenpage
  \begingroup
    \l@dzeropenalties
    \endgraf\global\num@lines=\prevgraf
            \global\num@linesR=\prevgraf
    \global\par@line=\z@
    \global\par@lineR=\z@
    \global\l@dpscL=\z@
    \global\l@dpscR=\z@
    \writtenlinesLfalse
    \writtenlinesRfalse
%    \end{macrocode}
% Check if there are chunks to be processed.
%    \begin{macrocode}
    \check@pstarts
    \loop\if@pstarts
%    \end{macrocode}
% Loop over the number of chunks, incrementing the chunk counts 
% (\cs{l@dpscL}
% and \cs{l@dpscR} are chunk (box) counts.)
%    \begin{macrocode}
      \global\advance\l@dpscL \@ne
      \global\advance\l@dpscR \@ne
%    \end{macrocode}
% Calculate the maximum number of real text lines in the chunk pair,
% storing the result in the relevant \cs{l@dmaxlinesinpar}.
%    \begin{macrocode}
      \getlinesfromparlistL
      \getlinesfromparlistR
      \l@dcalc@maxoftwo{\@cs@linesinparL}{\@cs@linesinparR}%
          {\usenamecount{l@dmaxlinesinpar\the\l@dpscL}}%
      \check@pstarts
    \repeat
%    \end{macrocode}
% Zero the counts again, ready for the next bit.
%    \begin{macrocode}
    \global\l@dpscL=\z@
    \global\l@dpscR=\z@
%    \end{macrocode}
% Get the number of lines on the first pair of pages and store
% the minumum in \cs{l@dminpagelines}.
%    \begin{macrocode}
    \getlinesfrompagelistL
    \getlinesfrompagelistR
    \l@dcalc@minoftwo{\@cs@linesonpageL}{\@cs@linesonpageR}%
        {\l@dminpagelines}%
%    \end{macrocode}
% Now we start processing the left and right chunks (\cs{l@dpscL} and
% \cs{l@dpscR} count the left and right chunks), starting with the first pair.
%    \begin{macrocode}
    \check@pstarts
    \if@pstarts
%    \end{macrocode}
% Increment the chunk counts to get the first pair.
%    \begin{macrocode}
      \global\advance\l@dpscL \@ne
      \global\advance\l@dpscR \@ne
%    \end{macrocode}
% We haven't processed any lines from these chunks yet, so zero the
% respective line counts.
%    \begin{macrocode}
      \global\@donereallinesL=\z@
      \global\@donetotallinesL=\z@
      \global\@donereallinesR=\z@
      \global\@donetotallinesR=\z@
%    \end{macrocode}
% Start a loop over the boxes (chunks).
%    \begin{macrocode}
      \checkraw@text
%    \end{macrocode}
%    \begin{macrocode}
%      \begingroup
{        \loop\ifaraw@text
%    \end{macrocode}
% See if there is more that can be done for the left page and set up the 
% left language.
% \changes{v0.2}{2004/12/20}{Added \cs{l@duselanguage} to \cs{Pages}}
%    \begin{macrocode}
          \checkpageL
          \l@duselanguage{\theledlanguageL}%
%%%          \begingroup
{            \loop\ifl@dsamepage
%    \end{macrocode}
% Process the next (left) text line, adding it to the page.
% \changes{v0.3}{2005/02/10}{Added \cs{ledstrutL} to \cs{Pages}}
%    \begin{macrocode}
              \do@lineL
              \advance\numpagelinesL \@ne
              \hb@xt@ \hsize{\ledstrutL\unhbox\l@dleftbox}%
%    \end{macrocode}
% Perhaps we have to move to the next (left) box. Check if we have got all
% we can onto the page. If not, repeat for the next line.
%    \begin{macrocode}
              \get@nextboxL
              \checkpageL
            \repeat
%    \end{macrocode}
% That (left) page has been filled. Output the number of real lines 
% on the page --- if the page break is because the page has been 
% filled with lines, use the actual number, otherwise the page has been
% ended early in order to synchronise with the facing page so use an
% impossibly large number.
%    \begin{macrocode}
            \ifl@dpagefull
%    \end{macrocode}
%    \begin{macrocode}
              \@writelinesonpageL{\the\numpagelinesL}%
            \else
              \@writelinesonpageL{1000}%
            \fi
%    \end{macrocode}
% Zero the left page lines count and clear the page to get onto the facing
% (odd, right) page.
%    \begin{macrocode}
            \numpagelinesL \z@
            \clearl@dleftpage }%
%    \end{macrocode}
% Now do the same for the right text.
% \changes{v0.3}{2005/02/10}{Added \cs{ledstrutR} to \cs{Pages}}
%    \begin{macrocode}
          \checkpageR
          \l@duselanguage{\theledlanguageR}%
{            \loop\ifl@dsamepage
              \do@lineR
              \advance\numpagelinesR \@ne
              \hb@xt@ \hsize{\ledstrutR\unhbox\l@drightbox}%
              \get@nextboxR
              \checkpageR
            \repeat
            \ifl@dpagefull
              \@writelinesonpageR{\the\numpagelinesR}%
            \else
              \@writelinesonpageR{1000}%
            \fi
            \numpagelinesR=\z@
%    \end{macrocode}
% The page is full, so move onto the next (left, odd) page and repeat left 
% text processing.
%    \begin{macrocode}
            \clearl@drightpage}
%    \end{macrocode}
% More to do? If there is we have to get the number of lines for the next
% pair of pages before starting to output them.
% \changes{v0.3b}{2005/04/08}{Added \cs{l@dminpagelines} calculation
%                             for succeeding page pairs}
%    \begin{macrocode}
          \checkraw@text
          \ifaraw@text
            \getlinesfrompagelistL
            \getlinesfrompagelistR
            \l@dcalc@minoftwo{\@cs@linesonpageL}{\@cs@linesonpageR}%
                             {\l@dminpagelines}%
          \fi
        \repeat}
%    \end{macrocode}
% We have now output the text from all the chunks.
%    \begin{macrocode}
    \fi
%    \end{macrocode}
% Make sure that there are no inserts hanging around.
%    \begin{macrocode}
    \flush@notes
    \flush@notesR
  \endgroup
%    \end{macrocode}
% Zero counts ready for the next set of left/right text chunks.
%    \begin{macrocode}
  \global\l@dpscL=\z@
  \global\l@dpscR=\z@
  \global\l@dnumpstartsL=\z@
  \global\l@dnumpstartsR=\z@
  \ignorespaces}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ledstrutL}
% \begin{macro}{\ledstrutR}
% Struts inserted into leftand right text lines.
% \changes{v0.3}{2005/02/10}{Added \cs{ledtrutL} and \cs{ledstrutR}}
%    \begin{macrocode}
\newcommand*{\ledstrutL}{\strut}
\newcommand*{\ledstrutR}{\strut}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\cleartoevenpage}
% \begin{macro}{\cleartol@devenpage}
% \begin{macro}{\clearl@dleftpage}
% \begin{macro}{\clearl@drightpage}
% \cs{cleartoevenpage}, which is defined in the memoir class, 
% is like \cs{clear(double)page} except that we 
% end up on an even page.
% \cs{cleartol@devenpage} is similar except that it first checks to see
% if it is already on an empty page.
% \cs{clearl@dleftpage} and \cs{clearl@drightpage} get us onto
% an odd and even page, respectively, checking that we end up on
% the immediately next page.
%    \begin{macrocode}
\providecommand{\cleartoevenpage}[1][\@empty]{%
  \clearpage
  \ifodd\c@page\hbox{}#1\clearpage\fi}
\newcommand*{\cleartol@devenpage}{%
  \ifdim\pagetotal<\topskip%  on an empty page
  \else
    \clearpage
  \fi
  \ifodd\c@page\hbox{}\clearpage\fi}
\newcommand*{\clearl@dleftpage}{%
  \clearpage
  \ifodd\c@page\else
    \led@err@LeftOnRightPage
    \hbox{}%
    \cleardoublepage
  \fi}
\newcommand*{\clearl@drightpage}{%
  \clearpage
  \ifodd\c@page
    \led@err@RightOnLeftPage
    \hbox{}%
    \cleartoevenpage
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\getlinesfromparlistL}
% \begin{macro}{\@cs@linesinparL}
% \begin{macro}{\getlinesfromparlistR}
% \begin{macro}{\@cs@linesinparR}
% \cs{getlinesfromparlistL} gets the next entry from the 
% \cs{linesinpar@listL} and puts it into \cs{@cs@linesinparL}; if the
% list is empty, it sets \cs{@cs@linesinparL} to 0. Similarly
% for \cs{getlinesfromparlistR}.
%    \begin{macrocode}
\newcommand*{\getlinesfromparlistL}{%
  \ifx\linesinpar@listL\empty
    \gdef\@cs@linesinparL{0}%
  \else
    \gl@p\linesinpar@listL\to\@cs@linesinparL
  \fi}
\newcommand*{\getlinesfromparlistR}{%
  \ifx\linesinpar@listR\empty
    \gdef\@cs@linesinparR{0}%
  \else
    \gl@p\linesinpar@listR\to\@cs@linesinparR
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\getlinesfrompagelistL}
% \begin{macro}{\@cs@linesonpageL}
% \begin{macro}{\getlinesfrompagelistR}
% \begin{macro}{\@cs@linesonpageR}
% \cs{getlinesfrompagelistL} gets the next entry from the 
% \cs{linesonpage@listL} and puts it into \cs{@cs@linesonpageL}; if the
% list is empty, it sets \cs{@cs@linesonpageL} to 1000. Similarly
% for \cs{getlinesfrompagelistR}.
%    \begin{macrocode}
\newcommand*{\getlinesfrompagelistL}{%
  \ifx\linesonpage@listL\empty
    \gdef\@cs@linesonpageL{1000}%
  \else
    \gl@p\linesonpage@listL\to\@cs@linesonpageL
  \fi}
\newcommand*{\getlinesfrompagelistR}{%
  \ifx\linesonpage@listR\empty
    \gdef\@cs@linesonpageR{1000}%
  \else
    \gl@p\linesonpage@listR\to\@cs@linesonpageR
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@writelinesonpageL}
% \begin{macro}{\@writelinesonpageR}
% These macros output the number of lines on a page to the section file
% in the form of \cs{@lopL} or \cs{@lopR} macros.
%    \begin{macrocode}
\newcommand*{\@writelinesonpageL}[1]{%
  \edef\next{\write\linenum@out{\string\@lopL{#1}}}%
  \next}
\newcommand*{\@writelinesonpageR}[1]{%
  \edef\next{\write\linenum@outR{\string\@lopR{#1}}}%
  \next}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\l@dcalc@maxoftwo}
% \begin{macro}{\l@dcalc@minoftwo}
% \cs{l@dcalc@maxoftwo}\marg{num}\marg{num}\marg{count} sets \meta{count}
% to the maximum of the two \meta{num}.
%
% Similarly 
% \cs{l@dcalc@minoftwo}\marg{num}\marg{num}\marg{count} sets \meta{count}
% to the minimum of the two \meta{num}.
%
%    \begin{macrocode}
\newcommand*{\l@dcalc@maxoftwo}[3]{%
  \ifnum #2>#1\relax
    #3=#2\relax
  \else
    #3=#1\relax
  \fi}
\newcommand*{\l@dcalc@minoftwo}[3]{%
  \ifnum #2<#1\relax
    #3=#2\relax
  \else
    #3=#1\relax
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifl@dsamepage}
% \begin{macro}{\l@dsamepagetrue}
% \begin{macro}{\l@dsamepagefalse}
% \begin{macro}{\ifl@dpagefull}
% \begin{macro}{\l@dpagefulltrue}
% \begin{macro}{\l@dpagefullfalse}
% \begin{macro}{\checkpageL}
% \begin{macro}{\checkpageR}
% \cs{checkpageL} tests if the space and lines already taken on the page by
% text and footnotes is less than the constraints. If so, then 
% \cs{ifl@dpagefull} is set FALSE and \cs{ifl@dsamepage} is set TRUE. 
% If the page is spatially full
% then \cs{ifl@dpagefull} is set TRUE and \cs{ifl@dsamepage} is set FALSE.
% If it is not spatially full but the maximum number of lines have been
% output then both \cs{ifl@dpagefull} and \cs{ifl@dsamepage}
% are set FALSE.
%
%    \begin{macrocode}
\newif\ifl@dsamepage
  \l@dsamepagetrue
\newif\ifl@dpagefull
\newcommand*{\checkpageL}{%
  \l@dpagefulltrue
  \l@dsamepagetrue
  \check@goal
  \ifdim\pagetotal<\ledthegoal
    \ifnum\numpagelinesL<\l@dminpagelines
    \else
      \l@dsamepagefalse
      \l@dpagefullfalse
    \fi
  \else
    \l@dsamepagefalse
    \l@dpagefulltrue
  \fi}
\newcommand*{\checkpageR}{%
  \l@dpagefulltrue
  \l@dsamepagetrue
  \check@goal
  \ifdim\pagetotal<\ledthegoal
    \ifnum\numpagelinesR<\l@dminpagelines
    \else
      \l@dsamepagefalse
      \l@dpagefullfalse
    \fi
  \else
    \l@dsamepagefalse
    \l@dpagefulltrue
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ledthegoal}
% \begin{macro}{\goalfraction}
% \begin{macro}{\check@goal}
% \cs{ledthegoal} is the amount of space allowed to taken by text and 
% footnotes on a page before a forced pagebreak. This can be controlled via
% \cs{goalfraction}. \cs{ledthegoal} is calculated via \cs{check@goal}.
%    \begin{macrocode}
\newdimen\ledthegoal
\newcommand*{\goalfraction}{0.9}
\newcommand*{\check@goal}{%
  \ledthegoal=\goalfraction\pagegoal}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\ifwrittenlinesL}
% \begin{macro}{\ifwrittenlinesL}
% Booleans for whether line data has been written to the section file.
%    \begin{macrocode}
\newif\ifwrittenlinesL
\newif\ifwrittenlinesR

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\get@nextboxL}
% \begin{macro}{\get@nextboxR}
% If the current box is not empty (i.e., still contains some lines) 
% nothing is done. Otherwise if and only if a synchronisation point is 
% reached the next box is started.
%
%    \begin{macrocode}
\newcommand*{\get@nextboxL}{%
  \ifvbox\namebox{l@dLcolrawbox\the\l@dpscL}% box is not empty
%    \end{macrocode}
% The current box is not empty; do nothing.
%    \begin{macrocode}
  \else%                                      box is empty
%    \end{macrocode}
% The box is empty; check if enough lines (real and blank) have been
% output.
%    \begin{macrocode}
    \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscL}>\@donetotallinesL
    \else
%    \end{macrocode}
% Sufficient lines have been output.
%    \begin{macrocode}
      \ifwrittenlinesL 
      \else
%    \end{macrocode}
% Write out the number of lines done, and set the boolean so this is only
% done once.
%    \begin{macrocode}
        \@writelinesinparL
        \writtenlinesLtrue
      \fi
      \ifnum\l@dnumpstartsL>\l@dpscL
%    \end{macrocode}
% There are still unprocessed boxes. Recalculate the maximum number of
% lines needed, and move onto the next box (by incrementing \cs{l@dpscL}).
%    \begin{macrocode}
        \writtenlinesLfalse
        \l@dcalc@maxoftwo{\the\usenamecount{l@dmaxlinesinpar\the\l@dpscL}}%
                         {\the\@donetotallinesL}%
                         {\usenamecount{l@dmaxlinesinpar\the\l@dpscL}}%
        \global\@donetotallinesL \z@
        \global\advance\l@dpscL \@ne
      \fi
    \fi
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\get@nextboxR}{%
  \ifvbox\namebox{l@dRcolrawbox\the\l@dpscR}% box is not empty
  \else%                                      box is empty
    \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscR}>\@donetotallinesR
    \else
      \ifwrittenlinesR 
      \else
        \@writelinesinparR
        \writtenlinesRtrue
      \fi
      \ifnum\l@dnumpstartsR>\l@dpscR
        \writtenlinesRfalse
        \l@dcalc@maxoftwo{\the\usenamecount{l@dmaxlinesinpar\the\l@dpscR}}%
                         {\the\@donetotallinesR}%
                         {\usenamecount{l@dmaxlinesinpar\the\l@dpscR}}%
        \global\@donetotallinesR \z@
        \global\advance\l@dpscR \@ne
      \fi
    \fi
  \fi}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{The End}\label{end}
%
% This is the end of the package code. But before we finish, enable
% a patch file (if there is one) to be read.
%
%    \begin{macrocode}
\InputIfFileExists{ledparpatch.sty}

%</code>
%    \end{macrocode}
%
% \newpage
% \appendix
%
% \section{Examples}\label{examples}
%
% This section presents some sample documents. 
%
%
%    The figures are from processed versions of the files. Having latexed
% a file I used DVIPS to get Encapsulated PostScript, then the epstopdf
% script to get a PDF version as well, for example: \\
% \begin{verbatim}
% > latex villon
% > latex villon
% > latex villon
% > dvips -E -o villon.eps villon  % produces villon.eps
% > epstopdf villon.eps            % produces villon.pdf
% \end{verbatim}
%
% For a multipage example, DVIPS has an option to output a range of pages (-p
% for the first and -l (letter l) for the last).
% For instance, to output a single page, say page 2:\\
% \begin{verbatim}
% > latex djd17nov
% > latex djd17nov
% > latex djd17nov
% > dvips -E -p2 -l2 -o djd17novL.eps djd17nov  % produces djd17novL.eps
% > epstopdf djd17novL.eps                      % produces djd17novL.pdf
% \end{verbatim}
%
%      For those who aren't fascinated by LaTeX code, I show the all the
% typeset results first, then the code that produced them. 
% 
%
% \cleardoublepage
%
% \begin{figure}[p]
% \centering
% \includegraphics{villon}
% \caption{Output from \file{villon.tex}.}
% \label{villon-out}
% \end{figure}
%
% \begin{figure}[p]
% \centering
% \includegraphics{djd17novL}
% \caption{Left page output from \file{djd17nov.tex}.}
% \label{djdL-out}
% \end{figure}
%
% \begin{figure}[p]
% \centering
% \includegraphics{djd17novR}
% \caption{Right page output from \file{djd17nov.tex}.}
% \label{djdR-out}
% \end{figure}
%
% \begin{figure}[p]
% \centering
% \includegraphics{djdpoems1}
% \caption{First left page output from \file{djdpoems.tex}.}
% \label{djdp1-out}
% \end{figure}
%
% \begin{figure}[p]
% \centering
% \includegraphics{djdpoems2}
% \caption{First right page output from \file{djdpoems.tex}.}
% \label{djdp2-out}
% \end{figure}
%
% \begin{figure}[p]
% \centering
% \includegraphics{djdpoems3}
% \caption{Second left page output from \file{djdpoems.tex}.}
% \label{djdp3-out}
% \end{figure}
%
% \begin{figure}[p]
% \centering
% \includegraphics{djdpoems4}
% \caption{Second right page output from \file{djdpoems.tex}.}
% \label{djdp4-out}
% \end{figure}
%
%
%
% \clearpage
%
% \subsection{Parallel column example}\label{example:villon}
%
% This made-up example, \file{villon.tex}, is included to show 
% parallel columns and how they can be interspersed in regular text.
% The verses are set using the \cs{stanza} construct, where each 
% verse line is a chunk.
% The code is given below and the result is shown in Figure~\ref{villon-out}.
%
% \medskip
% \hrule
% \medskip
%    \begin{macrocode}
%<*villon>
%%% villon.tex Example parallel columns
\documentclass{article}
\addtolength{\textheight}{-10\baselineskip}
\usepackage{ledmac,ledpar}
%% Use r instead of R to flag right text line numbers
\renewcommand{\Rlineflag}{r}
%% Use the flag in the notes
\let\oldBfootfmt\Bfootfmt
\renewcommand{\Bfootfmt}[3]{%
  \let\printlines\printlinesR
  \oldBfootfmt{#1}{#2}{#3}}
\begin{document}

I thought that limericks were peculiarly English, but this appears not
to be the case. As with most limericks this one is by Anonymous.

\vspace*{\baselineskip}

\begin{pairs}
%% no indentation
\setstanzaindents{0,0,0,0,0,0,0,0,0}
%% no number flag
\renewcommand{\Rlineflag}{}
%% draw a rule and widen the columns
\setlength{\columnrulewidth}{0.4pt}
\setlength{\Lcolwidth}{0.46\textwidth}
\setlength{\Rcolwidth}{\Lcolwidth}

\begin{Leftside}
%% set left text line numbering sequence
\firstlinenum{2}
\linenumincrement{2}
\linenummargin{left}
\beginnumbering
\stanza
Il y avait un jeune homme de Dijon, &
Qui n'avait que peu de religion. &
Il dit: `Quant \`{a} moi, &
Je d\'{e}teste tous les trois, &
Le P\`{e}re, et le Fils, et le Pigeon.' \&
\endnumbering
\end{Leftside}

\begin{Rightside}
%% different right text line numbering sequence
\firstlinenum{1}
\linenumincrement{2}
\linenummargin{right}
\beginnumbering
\stanza
There was a young man of Dijon, &
Who had only a little religion, &
He said: `As for me, & 
I detest all the three, &
The Father, the Son, and the Pigeon.' \&
\endnumbering
\end{Rightside}

\Columns
\end{pairs}

\vspace*{\baselineskip}

    The following is verse \textsc{lxxiii} of Fran\c{c}ois Villon's 
\textit{Le Testament} (The Testament), composed in 1461.

%% Allow for hanging indentation for long lines
\setstanzaindents{1,0,0,0,0,0,0,0,0}
%% Columns wider than the default
\setlength{\Lcolwidth}{0.46\textwidth}
\setlength{\Rcolwidth}{\Lcolwidth}
\vspace*{\baselineskip}

\begin{pairs}
\begin{Leftside}
\firstlinenum{2}
\linenumincrement{2}
\linenummargin{left}
\beginnumbering
\stanza
Dieu mercy et Tacque Thibault, &
Qui tant d'eaue froid m'a fait boire, &
Mis en bas lieu, non pas en hault, &
Mengier d'angoisse maints \edtext{poire}{\lemma{poire d'angoisse}%
  \Afootnote{This has a triple meaning: literally it is the fruit of the 
  choke pear,
  figuratively it means `bitter fruit', and it also refers to a torture
  instrument.}}, &
Enferr\'{e} \ldots Quant j'en ay memoire, &
Je Prie pour luy \edtext{\textit{et reliqua}}{\Afootnote{and so on}}, &
Que Dieu luy doint, et voire, voire! &
Ce que je pense \ldots \textit{et cetera}. \&
\endnumbering
\end{Leftside}

\begin{Rightside}
\firstlinenum{2}
\linenumincrement{2}
\linenummargin{right}
\beginnumbering
\stanza
Thanks to God --- and to \edtext{Tacque Thibaud}{%
  \Bfootnote{A favourite of Jean, Duc de Berry and loathed for his exactions
  and debauchery. Villon uses his name as an insulting nickname for
  Thibaud d'Auxigny, the Bishop of Orl\'{e}ans.}}  &
Who made me drink so much \edtext{cold water}{%
  \Bfootnote{Can either refer to the normal prison diet of bread and 
   water or to a common medieval torture which involved forced drinking 
   of cold water.}}, &
Put me underground instead of higher up &
And made me eat such bitter fruit, &
In chains \ldots When I think of this, &
I pray for him---\textit{et reliqua;} &
May God grant him (yes, by God) &
What I think \ldots \textit{et cetera}. \&
\endnumbering
\end{Rightside}

\Columns
\end{pairs}

\vspace*{\baselineskip}

    The translation and notes are by Anthony Bonner, 
\textit{The Complete Works of Fran\c{c}ois Villon}, published by 
Bantam Books in 1960.

\end{document}

%</villon>
%    \end{macrocode}
%
%
% \subsection{Example parallel facing pages} \label{example:djd17nov}
%
% This example, illustrated in Figures~\ref{djdL-out} and~\ref{djdR-out},
% was provided in November 2004 by Dirk-Jan Dekker\index{Dekker, Dirk-Jan}
% of the Department of Medieval History at Radboud University, Nijmegen.
%
% \medskip
% \hrule
% \medskip
%
%    \begin{macrocode}
%<*djd17nov>
%%% This is djd17nov.tex, a sample critical text edition
%%% written in LaTeX2e with the ledmac and ledpar packages.
%%% (c) 2003--2004 by Dr. Dirk-Jan Dekker,
%%% Radboud University, Nijmegen (The Netherlands)
%%% (PRW) Modified slightly by PRW to fit the ledpar manual

\documentclass[10pt, letterpaper, twoside]{article}
\usepackage[latin,english]{babel}
\usepackage{makeidx}
\usepackage{ledmac,ledpar}
\lineation{section}
\linenummargin{inner}
\sidenotemargin{outer}

\makeindex

\renewcommand{\notenumfont}{\footnotesize}
\newcommand{\notetextfont}{\footnotesize}

%\let\Afootnoterule=\relax
\let\Bfootnoterule=\relax
\let\Cfootnoterule=\relax

\addtolength{\skip\Afootins}{1.5mm}
%\addtolength{\skip\Bfootins}{1.5mm}
%\addtolength{\skip\Cfootins}{1.5mm}

\makeatletter

\renewcommand*{\para@vfootnote}[2]{%
  \insert\csname #1footins\endcsname
  \bgroup
    \notefontsetup
    \interlinepenalty=\interfootnotelinepenalty
    \floatingpenalty=\@MM
    \splittopskip=\ht\strutbox \splitmaxdepth=\dp\strutbox
    \leftskip=\z@skip \rightskip=\z@skip
    \l@dparsefootspec #2\ledplinenumtrue%                  new from here
    \ifnum\@nameuse{previous@#1@number}=\l@dparsedstartline\relax
      \ledplinenumfalse
     \fi
     \ifnum\previous@page=\l@dparsedstartpage\relax
     \else \ledplinenumtrue \fi
     \ifnum\l@dparsedstartline=\l@dparsedendline\relax
     \else \ledplinenumtrue \fi
     \expandafter\xdef\csname previous@#1@number\endcsname{\l@dparsedstartline}%
     \xdef\previous@page{\l@dparsedstartpage}%            to here
     \setbox0=\vbox{\hsize=\maxdimen
       \noindent\csname #1footfmt\endcsname#2}%
      \setbox0=\hbox{\unvxh0}%
      \dp0=0pt
      \ht0=\csname #1footfudgefactor\endcsname\wd0
      \box0
      \penalty0
  \egroup
}

\newcommand*{\previous@A@number}{-1}
\newcommand*{\previous@B@number}{-1}
\newcommand*{\previous@C@number}{-1}
\newcommand*{\previous@page}{-1}

\newcommand{\abb}[1]{#1%
        \let\rbracket\nobrak\relax}
\newcommand{\nobrak}{\textnormal{}}
\newcommand{\morenoexpands}{%
        \let\abb=0%
}

\newcommand{\Aparafootfmt}[3]{%
  \ledsetnormalparstuff
  \scriptsize
  \notenumfont\printlines#1|\enspace
%  \lemmafont#1|#2\enskip
  \notetextfont
  #3\penalty-10\hskip 1em plus 4em minus.4em\relax}
        
\newcommand{\Bparafootfmt}[3]{%
  \ledsetnormalparstuff
  \scriptsize
  \notenumfont\printlines#1|%
  \ifledplinenum
  	\enspace
  \else
  	{\hskip 0em plus 0em minus .3em}%
  \fi
  \select@lemmafont#1|#2\rbracket\enskip
  \notetextfont
  #3\penalty-10\hskip 1em plus 4em minus.4em\relax }
       
\newcommand{\Cparafootfmt}[3]{%
  \ledsetnormalparstuff
  \scriptsize
  \notenumfont\printlines#1|\enspace
%  \lemmafont#1|#2\enskip
  \notetextfont
  #3\penalty-10\hskip 1em plus 4em minus.4em\relax}

\makeatother

\footparagraph{A}
\footparagraph{B}
\footparagraph{C}

\let\Afootfmt=\Aparafootfmt
\let\Bfootfmt=\Bparafootfmt
\let\Cfootfmt=\Cparafootfmt

\renewcommand*{\Rlineflag}{}

\emergencystretch40pt

\author{Guillelmus de Berchen}
\title{Chronicon Geldriae}
\date{}
\hyphenation{archi-epi-sco-po Huns-dis-brug li-be-ra No-vi-ma-gen-si}
\begin{document}
\begin{pages}
\begin{Leftside}
\beginnumbering\pstart
\selectlanguage{latin}
\section{De ecclesia S. Stephani Novimagensi}

\noindent\setline{1}
Nobilis itaque comes Otto\protect\edindex{Otto II of Guelders} 
imperio et dominio Novimagensi sibi, ut praefertur, impignoratis 
et commissis 
\edtext{proinde}{\Bfootnote{primum D}} praeesse cupiens, anno 
\textsc{liiii} superius descripto, mense 
Iu\edtext{}{\Afootnote{p.\ 227~R}}nio, una cum iudice, scabinis ceterisque 
civibus civitatis Novimagensis, pro ipsius et inhabitantium in ea 
necessitate,\edtext{}{\Afootnote{p.\ 97~N}} commodo et utilitate, 
ut \edtext{ecclesia eius}{\Bfootnote{ecclesia D: eius eius H}} parochialis 
\edtext{\abb{extra civitatem}}{\Bfootnote{\textit{om.}~H}} sita 
destrueretur et \edtext{infra}{\Bfootnote{intra D}} muros 
\edtext{transfer\edtext{}{\Afootnote{p.\ 129~D}}retur}%
{\Bfootnote{transferreretur NH}} 
ac de novo construeretur, 
\edtext{a reverendo patre domino 
Conrado\protect\edindex{Conrad of Hochstaden} de 
\edtext{Hofsteden}{\Bfootnote{Hoffstede D: Hoffsteden H}}, archiepiscopo 
\edtext{Coloniensi}{\Bfootnote{Colononiensi H}}, licentiam}%
{\Cfootnote{William is confusing two charters that are five years 
apart. Permission from St.\ Apostles' Church in Cologne had been 
obtained as early as 1249. Cf.\ 
Sloet\protect\index{Sloet van de Beele, L.A.J.W.}, 
\textit{Oorkondenboek} nr.\ 707 (14 November 1249): 
``\ldots{}nos devotionis tue precibus annuentes, ut ipsam ecclesiam 
faciens demoliri transferas in locum alium competentem, tibi 
auctoritate presentium indulgemus\ldots''}}, et a venerabilibus 
\edtext{dominis}{\Bfootnote{viris H}} decano et capitulo sanctorum 
Apostolorum\protect\edindex{St. Apostles' (Cologne)} 
\edtext{Coloniensi}{\Bfootnote{Coloniae H}}, ipsius ecclesiae ab 
antiquo veris et pacificis patronis, consensum, citra tamen 
praeiudicium, damnum aut gravamen \edtext{iurium}{\Bfootnote{virium D}} 
et bonorum eorundem, impetravit.
\pend

\pstart
\edtext{Et exinde \edtext{liberum}{\Bfootnote{librum H}} 
locum eiusdem civitatis 
\edtext{qui}{\Bfootnote{quae D}} dicitur 
\edtext{Hundisburg}{\Bfootnote{Hundisburch D: Hundisbrug HMN: 
Hunsdisbrug R}}\protect\edindex{Hundisburg}, 
de praelibati Wilhelmi\protect\edindex{William II of Holland} Romanorum 
\edtext{regis}{\Bfootnote{imperatoris D}}, ipsius fundi 
do\edtext{}{\Afootnote{f.\ 72v~M}}mini, consensu, ad aedificandum 
\edtext{\abb{et consecrandum}}{\Bfootnote{\textit{om.}\ H}} 
ecclesi\edtext{}{\Afootnote{p.\ 228~R}}am et coemeterium, 
\edtext{eisdem}{\Bfootnote{eiusdem D}} decano et capitulo de expresso 
eiusdem civitatis assensu libera contradiderunt voluntate, obligantes 
se ipsi \edtext{comes}{\Bfootnote{comites D}} et civitas 
\edtext{\abb{dictis}}{\Bfootnote{\textit{om.}\ H}} decano et capitulo, 
quod in recompensationem illius areae infra castrum et portam, quae 
fuit dos ecclesiae, in qua plebanus habitare solebat---quae 
\edtext{tunc}{\Bfootnote{nunc H}} per novum fossatum civitatis est 
destructa---aliam aream competentem et ecclesiae novae, 
\edtext{ut praefertur, aedificandae}{%
\lemma{\abb{ut\ldots aedificandae}}\Bfootnote{\textit{om.}\ H}} satis 
\edtext{contiguam}{\Bfootnote{contiguum M}}, ipsi plebano darent et 
assignarent.}{\Cfootnote{Cf.\ Sloet, \textit{Oorkondenboek} nr.\ 762 
(June 1254)}} Et desuper 
\edtext{\abb{apud}}{\Bfootnote{\textit{om.}\ H}} dictam ecclesiam 
sanctorum Apostolorum \edtext{est}{\Bfootnote{et H}} 
\edtext{littera}{\Bfootnote{litteram H}} sigillis ipsorum 
Ottonis\edtext{}{\Afootnote{p.\ 130~D}} comitis et civitatis 
\edtext{Novimagensis}{\Bfootnote{Novimagii D}} 
\edtext{sigillata}{\Bfootnote{sigillis communita H}}.
\pend

\pstart
 // One additional line to show synchronization. //
\pend
\endnumbering
\end{Leftside}

\begin{Rightside}
\sidenotemargin{right}\selectlanguage{english}
\beginnumbering
\pstart
\addtocounter{section}{-1}%
\leavevmode\section{St.\ Stephen's Church in Nijmegen}

\noindent\setline{1}%
After the noble count Otto had taken in pledge the power over 
Nijmegen,\footnote{In 1247 William II\protect\index{William II of Holland} 
(1227--1256) count of Holland needed money to fight his way to 
Aachen\protect\index{Aachen} to be crowned King of the Holy Roman 
Empire. He gave the town of Nijmegen in pledge to Otto 
II\protect\index{Otto II of Guelders} (1229--1271) count of Guelders.} 
like I have written above, he wanted to protect the town. So in June 
1254\ledsidenote{1254} he and the judge, the sheriffs and other 
citizens of Nijmegen obtained permission to demolish the parish 
church that lay outside the town walls,\footnote{Since the early 
seventh century old St.\ Stephen's church had been located close 
to the castle, at today's 
Kelfkensbos\protect\index{Kelfkensbos (Nijmegen)} square. 
Traces of the church and the presbytery were found during excavations 
in 1998--1999.} to move it inside the walls and to rebuild it new. 
This operation was necessary and useful both for Otto himself and 
for the inhabitants of the town. The reverend father Conrad of 
Hochstaden, archbishop of 
Cologne,\footnote{Conrad of Hochstaden ({\textdagger} 1261) was 
archbishop of Cologne in 1238--1261. Nijmegen belonged to the 
archdiocese of Cologne until 1559.} gave his permission. So did the 
reverend dean and canons of the chapter of St.\ 
Apostles'\protect\index{St. Apostles' (Cologne)} in Cologne, who had 
long\footnote{They probably became the patrons when the chapter was 
established in the early eleventh century. About the church and the 
chapter, see Gottfried Stracke\protect\index{Stracke, G.}, 
\textit{K\"{o}ln:\ St.\ Aposteln}, Stadtspuren -- Denkm\"{a}ler in 
K\"{o}ln, vol.\ 19, K\"{o}ln: J.\,P.\ Bachem, 1992.} been the true 
and benevolent patrons of the church---but they did not allow Otto 
to do anything without their knowledge, nor to infringe their rights, 
nor to damage their property.
\pend

\pstart 
And so the count and the town voluntarily gave an open space in town 
called Hundisburg, which was owned by the aforementioned king William, 
to the dean and chapter of St.\ Apostles' in order to build and 
consecrate a church and graveyard. King William approved and the 
town of Nijmegen explicitly expressed its assent. A new ditch was dug 
on property of the church near the castle and the 
harbour,\footnote{Nowadays, the exact location of the medieval 
ditch---and of two Roman ones---can be seen in the pavement of 
Kelfkensbos\protect\index{Kelfkensbos (Nijmegen)} square.} causing 
the demolition of the presbytery. In compensation, the count and 
citizens committed themselves to giving the parish priest another 
suitable space close enough to the new church that was about to be 
built. A letter about these transactions, with the seals of count 
Otto and the town of Nijmegen, is kept at St.\ Apostles' 
church.\footnote{The original letter is lost. A 15th century 
transcription of it is kept at the Historisches Archiv der 
Stadt K\"{o}ln (HAStK).}
\pend

\pstart 
// One additional line to show synchronization. //
\pend
\endnumbering
\end{Rightside}
\Pages
\end{pages}

%%%%%%%%%%%%%%%%%%%%%%%%%%%
\printindex
\end{document}
%%%%%%%%%%%%%%%%%%

%</djd17nov>
%    \end{macrocode}
%
% \medskip
% \hrule
%
% \subsection{Example poetry on parallel facing pages} \label{example:djdpoems}
%
% This example, illustrated in Figures~\ref{djdp1-out} to~\ref{djdp4-out},
% was originally provided in November 2004 by 
% Dirk-Jan Dekker\index{Dekker, Dirk-Jan} for an earlier version of \Ledpar.
% I have updated it, and also extended it to show the difference between
% the \cs{stanza} command and the \verb?astanza? environment. \cs{stanza}
% is used for the first pair of pages and \verb?astanza? for the second
% pair. Note the
% definition of \cs{endstanzaextra} to give a short line after each stanza.
%
% \medskip
% \hrule
% \medskip
%
%    \begin{macrocode}
%<*djdpoems>
%%% djdpoems.tex  example parallel verses on facing pages
\documentclass{article}
\usepackage{ledmac,ledpar}
\addtolength{\textheight}{-15\baselineskip}

\maxchunks{24} % default value = 10
\setstanzaindents{6,0,1,0,1}

\newcommand{\longdash}{---------}

\footparagraph{A} % for left pages
\footparagraph{B} % for right pages
\firstlinenum{1}
\linenumincrement{1}

\let\oldBfootfmt\Bfootfmt
\renewcommand{\Bfootfmt}[3]{%
   \let\printlines\printlinesR
   \oldBfootfmt{#1}{#2}{#3}}
   
\begin{document}

\newcommand{\interstanza}{\pstart\centering\longdash\skipnumbering\pend}

\begin{pages}
\begin{Leftside}
\def\endstanzaextra{\interstanza}
\beginnumbering

\stanza
Arma gravi numero violentaque bella parabam &
 edere, materi\={a} conveniente modis. &
Par erat inferior versus---risisse Cupido &
 dicitur atque unum surripuisse pedem. \&

\stanza
``Quis tibi, saeve puer, dedit hoc in carmina iuris? &
 Pieridum vates, non tua turba \edtext{sumus}{\Afootnote{note lost}}. &
Quid si praeripiat flavae V\u{e}nus arma Minervae, &
 ventilet accensas flava Minerva faces? \&

\stanza
Quis probet in silvis Cererem regnare iugosis, &
 lege pharetratae Virginis arva coli? &
Crinibus insignem quis \edtext{acuta}{\Afootnote{acut\={a} (abl.\ abs.)}} 
cuspide Phoebum &
 instruat, Aoniam Marte movente lyram? \&
\endnumbering
\end{Leftside}

\begin{Rightside}
\def\endstanzaextra{\interstanza}
\beginnumbering
\firstlinenum{1}
\linenumincrement{1}
\setstanzaindents{6,0,1,0,1,0}

\stanza
I was preparing to sing of weapons and violent wars, &
in heavy numbers, with the subject matter suited to the verse measure. &
The even lines were as long as the odd ones, but Cupid laughed, &
they said, and he stole away one foot.\footnote{I.e., the even lines, 
which were hexameters (with six feet) became pentameters 
(with five feet).} \&

\stanza
``O cruel boy, who gave you the right over poetry? &
We poets belong to the Pierides,\footnote{Muses} we are not your folk. &
\edlabel{beginparadox}What if Venus should seize away the arms of 
Minerva with the golden hair, &
 if Minerva with the golden hair should fan alight the kindled torch 
of love? \&
 
\stanza
Who would approve of Ceres\footnote{Ceres was the Roman goddess of 
the harvest.} reigning on the woodland ridges, &
 and of land tilled under the law of the Maid with the 
quiver\footnote{By `\textit{Virgo}' (`Virgin') Ovid means Diana, the 
Roman goddess of the hunt.}? &
Who would provide Phoebus with his beautiful hair with a sharp-pointed 
spear, &
 while Mars stirs the \edtext{Aonian}{\Bfootnote{Mount Parnassus, 
where the Muses live, is located in Aonia.}} 
lyre?\edlabel{endparadox}\footnote{Lines 
\xlineref{beginparadox}--\xlineref{endparadox} show some paradoxical 
situations that would occur if the gods didn't stay with their own 
business.} \&
\endnumbering
\end{Rightside}

\Pages
\end{pages}

\begin{pages}
\begin{Leftside}
\def\endstanzaextra{\interstanza}
\beginnumbering

\begin{astanza}
Arma gravi numero violentaque bella parabam &
 edere, materi\={a} conveniente modis. &
Par erat inferior versus---risisse Cupido &
 dicitur atque unum surripuisse pedem. \&
\end{astanza}

\begin{astanza}
``Quis tibi, saeve puer, dedit hoc in carmina iuris? &
 Pieridum vates, non tua turba \edtext{sumus}{\Afootnote{note lost}}. &
Quid si praeripiat flavae V\u{e}nus arma Minervae, &
 ventilet accensas flava Minerva faces? \&
\end{astanza}

\begin{astanza}
Quis probet in silvis Cererem regnare iugosis, &
 lege pharetratae Virginis arva coli? &
Crinibus insignem quis \edtext{acuta}{\Afootnote{acut\={a} (abl.\ abs.)}} 
cuspide Phoebum &
 instruat, Aoniam Marte movente lyram? \&
\end{astanza}

\endnumbering
\end{Leftside}

\begin{Rightside}
\def\endstanzaextra{\interstanza}
\beginnumbering
\firstlinenum{1}
\linenumincrement{1}
\setstanzaindents{6,0,1,0,1,0}

\begin{astanza}
I was preparing to sing of weapons and violent wars, &
in heavy numbers, with the subject matter suited to the verse measure. &
The even lines were as long as the odd ones, but Cupid laughed, &
they said, and he stole away one foot.\footnote{I.e., the even lines, 
which were hexameters (with six feet) became pentameters 
(with five feet).} \&
\end{astanza}

\begin{astanza}
``O cruel boy, who gave you the right over poetry? &
We poets belong to the Pierides,\footnote{Muses} we are not your folk. &
\edlabel{beginparadox}What if Venus should seize away the arms of 
Minerva with the golden hair, &
 if Minerva with the golden hair should fan alight the kindled torch 
of love? \&
\end{astanza}
 
\begin{astanza}
Who would approve of Ceres\footnote{Ceres was the Roman goddess of the 
harvest.} reigning on the woodland ridges, &
 and of land tilled under the law of the Maid with the 
quiver\footnote{By `\textit{Virgo}' (`Virgin') Ovid means Diana, 
the Roman goddess of the hunt.}? &
Who would provide Phoebus with his beautiful hair with a sharp-pointed 
spear, &
 while Mars stirs the \edtext{Aonian}{\Bfootnote{Mount Parnassus, where 
the Muses live, is located in Aonia.}} 
lyre?\edlabel{endparadox}\footnote{Lines 
\xlineref{beginparadox}--\xlineref{endparadox} show some paradoxical 
situations that would occur if the gods didn't stay with their 
own business.} \&
\end{astanza}

\endnumbering
\end{Rightside}

\Pages
\end{pages}

\end{document}

%</djdpoems>
%    \end{macrocode}
%
% \medskip
% \hrule
%
% \clearpage
%
% \bibliographystyle{alpha}
% \begin{thebibliography}{WWW99}
% \addcontentsline{toc}{section}{References}
% \bibitem[LW90]{EDMACTUG}
% John Lavagnino and Dominik Wujastyk.
% \newblock `An overview of \edmac: a \textsc{Plain} TeX format for
%            critical editions'.
% \newblock \emph{TUGboat}, \textbf{11}, 4, pp. 623--643, November 1990.
% \newblock (Code available from CTAN in
%            \texttt{macros/plain/contrib/edmac})
%
%
% \bibitem[Wil02]{MEMOIR}
% Peter Wilson.
% \newblock \emph{The \Lpack{memoir} class for configurable typesetting}.
% \newblock November 2002.
% \newblock (Available from CTAN in
%            \texttt{macros/latex/contrib/memoir})
%
% \bibitem[Wil04]{LEDMAC}
% Peter Wilson.
% \newblock \emph{\Lpack{ledmac} A presumptuous attempt to port
%            \Lpack{EDMAC},\Lpack{TABMAC} and \Lpack{EDSTANZA} to
%             LaTeX}.
% \newblock December 2004.
% \newblock (Available from CTAN in
%            \texttt{macros/latex/contrib/ledmac})
%
% \end{thebibliography}
%
% \Finale
% \section*{}
% \addcontentsline{toc}{section}{Index}
% \PrintIndex
%
% \section*{}
% \addcontentsline{toc}{section}{Change History}
% \PrintChanges
% \endinput
\endinput

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