summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/custom-bib/merlin.mbs
blob: e60196263ebb52c91b69a7bf856773f51c77cd5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
%\iffalse         THIS IS A META COMMENT -*- TeX -*- -*- DTX -*-
% File: merlin.mbs
%% Copyright 1994-2011 Patrick W Daly
% Max-Planck-Institut f\"ur Sonnensystemforschung
% Max-Planck-Str. 2
% D-37191 Katlenburg-Lindau
% Germany
% E-mail: daly@mps.mpg.de
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
% It is part of the custom-bib collection,
%   a contribution to the LaTeX2e system.
%====================================================================
%       Master  Bibliography  Style
%    for customizing bibliographic style files (.bst)
%    with the help of     docstrip.tex
%    and the auxiliary program     makebst.tex
%--------------------------------------------------------------------
%   (See version and date in the \ProvidesFile command below)
%--------------------------------------------------------------------
%    This file supports numerical and author-year citation styles
%        for natbib, harvard, astronom, authordate, apalike
%    It also supports languages other than English
%--------------------------------------------------------------------
%    This file is self-documenting: simply LaTeX it!
%  (Alternatively, extract documentation driver with option `driver')
%====================================================================
%
%<*!tail>
% (The following notice appears in bst files generated from this file)
 % ===============================================================
 % IMPORTANT NOTICE:
 % This bibliographic style (bst) file has been generated from one or
 % more master bibliographic style (mbs) files, listed above.
 %
 % This generated file can be redistributed and/or modified under the terms
 % of the LaTeX Project Public License Distributed from CTAN
 % archives in directory macros/latex/base/lppl.txt; either
 % version 1 of the License, or any later version.
 % ===============================================================
 % Name and version information of the main mbs file:
%\fi
 % \ProvidesFile{merlin.mbs}[2011/11/18 4.33 (PWD, AO, DPC)]
%\iffalse
%</!tail>
%<*a&!a>
% The following ensures that the driver part is not seen by makebst
% The driver part must not contain any \end other than \end{document} !
\ifx\endoptions\undefined\let\tempx=\relax\else
  \long\def\tempx#1\end#2{}\fi\tempx
%</a&!a>
%<*driver>
   \NeedsTeXFormat{LaTeX2e}%
   \documentclass[a4paper,10pt,twoside]{article}%
   \usepackage{doc}%
   \raggedbottom
   \CodelineNumbered
   \RecordChanges
 %  Comment out next line to print coding
   \OnlyDescription
   \setlength{\oddsidemargin}{0.5\paperwidth}
   \addtolength{\oddsidemargin}{-0.5\textwidth}
   \addtolength{\oddsidemargin}{-1in}
   \setlength{\evensidemargin}{\oddsidemargin}

\begin{document}
   \DocInput{merlin.mbs}
\end{document}
%</driver>
%                   END OF META COMMENT   \fi
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \CheckSum{517}
% \setcounter{StandardModuleDepth}{1}
% \setcounter{IndexColumns}{2}
% \setlength{\IndexMin}{10cm}
%
% \changes{1.0}{1993 Aug 16}{Initial version}
% \changes{2.0}{1994 Jan 31}{Add multilingual capabilities}
% \changes{2.1--2.5}{1995 May 2}{Changes to \texttt{babel.mbs} parallel 1.3--1.7
%    in \texttt{genbst.mbs}}
% \changes{1.3(2.1)}{1994 Jul 1}{Change documentation to \LaTeXe}
% \changes{1.3(2.1)a}{1994 Sep 1}{Alter wording of article title capitalization
%          choice}
% \changes{1.4(2.2)}{1994 Sep 5}{Add full author name possibilities}
% \changes{1.4(2.2)}{1994 Sep 5}{Fix up some punctuations}
% \changes{1.4(2.2)a}{1994 Sep 7}{Add possibility to put titles in quotes}
% \changes{1.5(2.3)}{1994 Sep 15}{Accommodate new \texttt{harvard.sty}}
% \changes{1.5(2.3)}{1994 Sep 15}{Add full names for \texttt{natbib} v5.3}
% \changes{1.5(2.3)a}{1994 Oct 11}{Add option so year can contain any text}
% \changes{1.5(2.3)b}{1995 Jan 18}{Allow edited by to be in parentheses}
% \changes{1.5(2.3)b}{1995 Jan 18}{Allow (year) to have no punctuation
%     following}
% \changes{1.5(2.3)c}{1995 Jan 20}{Journal volume numbers with more choice}
% \changes{1.6(2.4)}{1995 Feb 2}{Date with no punctuation preceding it}
% \changes{1.6(2.4)}{1995 Feb 2}{Editor names can be reversed like authors'}
% \changes{1.6(2.4)}{1995 Feb 2}{Can abbreviate `edited by' to `ed(s).'}
% \changes{1.6(2.4)}{1995 Feb 2}{Released version}
% \changes{1.7(2.5)}{1995 Feb 9}{Add \texttt{seq-key} option}
% \changes{3.0}{1995 Mar 15}{Becomes \texttt{merlin.mbs}, with language
%      support in additional files}
% \changes{3.0}{1995 Feb 27}{Allow full author names to be reversed}
% \changes{3.0}{1995 Mar 1}{Add \texttt{isbn} field option}
% \changes{3.0}{1995 Mar 3}{Citation names can be bold or small caps}
% \changes{3.0}{1995 Mar 8}{Colon and space may follow year}
% \changes{3.0}{1995 Mar 15}{Names can be reversed, dotless intials}
% \changes{3.0}{1995 Mar 17}{Volume, number can be followed by semi-colon}
% \changes{3.0}{1995 Mar 20}{Allow word editor or ed to be in parentheses}
% \changes{3.0}{1995 Mar 20}{Abbreviated journal names can have dots removed}
% \changes{3.1}{1995 May 4}{Fix `edited by' so it is not abbreviated
%         automatically with `editor'}
% \changes{3.1}{1995 May 6}{Re-do head/tail options to allow easy update of
%         older \texttt{.dbj} files}
% \changes{3.2}{1995 May 19}{Minimum number of authors can be up to 6, not  5}
% \changes{3.2}{1995 May 19}{Allow date as part of journal spec., for medical
%         journals}
% \changes{3.2}{1995 May 19}{Suppress `pages' and `pp'}
% \changes{3.2}{1995 May 19}{Allow date to be `1994 Jul', with or without dot}
% \changes{3.2}{1995 Jun 7}{Authors as Jones C.T.}
% \changes{3.2}{1995 Jun 16}{Sort without \emph{von} part}
% \changes{3.2}{1995 Jul 31}{Release as version 3.2}
% \changes{3.3}{1995 Aug 7}{Extra labels put in braces so they are treated
%     as one unit by natbib}
% \changes{3.3}{1995 Aug 7}{Publisher's address can precede name}
% \changes{3.3}{1995 Sep 4}{Add full authors only if different from short list}
% \changes{3.4}{1995 Sep 5}{Add number of references as argument to
%      \texttt{thebibliography} environment}
% \changes{3.4}{1995 Sep 28}{Fix placement of \texttt{bolden} in
%      \texttt{format.vol.num.pages}}
% \changes{3.4}{1995 Sep 28}{Add possibility of date between volume and pages}
% \changes{3.4}{1995 Sep 28}{Word `and' can be in normal font in citations}
% \changes{3.5}{1995 Oct 4}{Tech Reports to have titles like books}
% \changes{3.5}{1995 Oct 9}{Delimit \texttt{\char`\\harvardyearright} properly}
% \changes{3.5}{1995 Oct 9}{Add option to sort by year (numerical only)}
% \changes{3.5}{1995 Oct 12}{Allow multiple journal-name files}
% \changes{3.5}{1995 Oct 16}{Allow months in dates even for author-year}
% \changes{3.5}{1995 Oct 24}{Fix sorting bug for limited number of authors}
% \changes{3.5}{1995 Oct 30}{Add \texttt{named} format for author--year cites}
% \changes{3.6}{1995 Nov 2}{Blocks can be separated by semi-colons}
% \changes{3.6}{1995 Nov 23}{Journal names in normal font}
% \changes{3.6}{1995 Nov 23}{Volume subnumber added to pages}
% \changes{3.6}{1995 Nov 24}{Book pages in parentheses}
% \changes{3.6}{1995 Dec 7}{Put Jr at end for AGU author style}
% \changes{3.6}{1995 Dec 7}{Put `and' in same font in list and citation}
% \changes{3.6}{1996 Jan 30}{Allow `et al' to be in normal font}
% \changes{3.6a}{1996 Feb 1}{Fix bugs with \texttt{xand} option}
% \changes{3.7}{1996 Feb 2}{Fix small caps with NFSS}
% \changes{3.7}{1996 Feb 5}{Fix clash of \texttt{emphasize} and
%      \texttt{purify\$}}
% \changes{3.8}{1996 Feb 29}{Add \texttt{alpha}-type style}
% \changes{3.8}{1996 Mar 1}{Style alpha is never unsorted}
% \changes{3.8}{1996 Mar 12}{Allow blanks between blocks}
% \changes{3.8}{1996 Mar 12}{Publisher in parentheses}
% \changes{3.8}{1996 Mar 15}{Allow author-year to be sorted by year}
% \changes{3.8}{1996 Mar 16}{Cited `and' resets only one attribute}
% \changes{3.8}{1996 Mar 19}{Allow date to be between volume and number}
% \changes{3.81}{1996 Jun 17}{Add \texttt{\char`\\natexlab} for \texttt{natbib} 6.3}
% \changes{3.81}{1996 Jun 19}{Fix coding for adding `page' to journals}
% \changes{3.81}{1996 Jun 19}{Add `volume' to journals}
% \changes{3.81}{1996 Jun 19}{Remove word `in'}
% \changes{3.81}{1996 Jun 19}{Place publisher before chapter/pages}
% \changes{3.81}{1996 Jun 25}{Allow period after date}
% \changes{3.81}{1996 Jun 26}{Commas between blocks, except for article titles
%         where period comes}
% \changes{3.81}{1996 Sep 12}{Allow comma before date}
% \changes{3.81}{1996 Sep 13}{Reorganize incollection organization and
%             publisher}
% \changes{3.81}{1996 Sep 13}{Allow edition to come before publisher}
% \changes{3.81}{1996 Sep 16}{Allow author--year to be in citation order}
% \changes{3.81}{1996 Sep 16}{Publisher, address, date can all be in
%            parentheses}
% \changes{3.81}{1996 Sep 18}{Remove extraneous hyphen before
%           \texttt{\char`\\getans}}
% \changes{3.82}{1996 Nov 15}{Allow pages at end before notes}
% \changes{3.82}{1996 Nov 15}{Fix bug with quoted titles when title missing}
% \changes{3.82}{1996 Dec 16}{Fix bug that put comma before publisher in
%           parentheses}
% \changes{3.82}{1996 Dec 16}{Allow AGU author style with full names}
% \changes{3.83}{1997 Feb 5}{Allow dash for repeated authors, periods
%   before notes}
% \changes{3.83}{1997 Apr 25}{Change case of first note word if mid-sentence}
% \changes{3.84}{1997 Sep 16}{Option to break long page numbers}
% \changes{3.84}{1997 Oct 20}{Option for titles in guillemets}
% \changes{3.84}{1997 Oct 20}{Option to use underlining for emphasis}
% \changes{3.84}{1997 Oct 30}{Reorganize options for year in journal spec}
% \changes{3.84}{1997 Oct 30}{Multiple options in menu}
% \changes{3.85}{1998 Feb 10}{Fonts for names: can exclude first names,
% use-defined font allowed, improved coding for `and' and `et~al.'}
% \changes{3.86}{1998 Feb 25}{Use \texttt{format.date} consistently in place
%   of \texttt{year} alone}
% \changes{3.86}{1998 Feb 25}{Suppress ISBN number when certain crossrefs
%    are present}
% \changes{3.86}{1998 Feb 25}{Add option for comma between year and pages}
% \changes{3.86}{1998 Apr 20}{Bug with minimum 6 authors corrected}
% \changes{3.87}{1998 Jul 23}{Add \texttt{url} field for all styles}
% \changes{3.87}{1998 Jul 23}{Suppress months in numerical mode}
% \changes{3.87}{1998 Jul 23}{Author limitation now 99}
% \changes{3.87}{1998 Jul 23}{Add \texttt{annote} field and annotation}
% \changes{3.87}{1998 Aug 17}{Add \texttt{issn} field}
% \changes{3.87}{1998 Aug 17}{Correct spelling of `guillimet'}
% \changes{3.87}{1998 Aug 17}{Make \textsl{et~al.} a variable \texttt{bbl.etal}}
% \changes{3.87}{1998 Aug 17}{Add \texttt{language} field}
% \changes{3.87h}{1998 Oct 16}{Add html output possibilities}
% \changes{3.88}{1998 Nov 27}{Option to suppress edition conversion in English}
% \changes{3.88}{1998 Dec 2}{Conf. booktitles are upright if book titles are}
% \changes{3.88}{1998 Dec 2}{Various extra options for book pages,
%         inproceedings, mainly for MPG Jahrbuch}
% \changes{3.88}{1998 Jan 13}{For html, newblock just adds period, no new line}
% \changes{3.88}{1999 Feb 1}{Do edition suppression properly}
% \changes{3.88}{1999 Feb 26}{Fix font handling of names}
% \changes{3.88}{1999 Feb 26}{Test for multipages for word `page(s)' in journals}
% \changes{3.89}{1999 May 12}{Missing years may be left blank, not just ????}
% \changes{3.89}{1999 May 12}{When key replaces author, leave year blank}
% \changes{3.89d1}{1999 Jul 20}{AO: %Arthur Ogawa (ogawa@teleport.com)
%      Add new entries: collaboration, eid, eprint, numpages, per option
%      \texttt{revdata}}
% \changes{3.89d1}{1999 Jul 20}{AO: Add reference component tags (\texttt{bibinfo}
%      and friends)}
% \changes{4.00}{1999 Sept 17}{PWD: incorporate AO's changes with moderations}
% \changes{4.00}{2000 Jan 21}{PWD: add \texttt{archive} field}
% \changes{4.01}{2000 May 4}{PWD: Fix improper \texttt{change.case\$} and
%     \texttt{bibinfo.check} ordering}
% \changes{4.02}{2000 June 27}{Fix bug with `in' with articles}
% \changes{4.03}{2002 Jan 14}{PWD: add \texttt{seq-yrr} for reversed year ordering}
% \changes{4.03}{2002 Jan 14}{PWD: add \texttt{thtit-x} to suppress thesis titles}
% \changes{4.03}{2002 Jan 14}{PWD: add line to define \texttt{natexlab} in aux file for harvard}
% \changes{4.03}{2002 Jan 14}{PWD: bug fix when both \texttt{pp-last} and \texttt{dt-jnl} given}
% \changes{4.04}{2002 Sep 13}{PWD: add support for Slovene/Slovenian language}
% \changes{4.05}{2002 Oct 21}{PWD: bug fix in \texttt{inproceedings} with
%         \texttt{pp-last} and \texttt{dt-beg}}
% \changes{4.06}{2003 Apr 2}{PWD: add \texttt{nmd-2} and \texttt{nmd-3} for use with \texttt{nmdash}}
% \changes{4.10}{2003 May 28}{PWD: add DOI}
% \changes{4.10}{2003 June 3}{PWD: use \texttt{\protect\bslash providecommand}
%    instead of \TeX\ commands, but provide \texttt{noprov} option to undo it.}
% \changes{4.10}{2003 June 3}{PWD: make \texttt{eid} available not just for Rev\TeX}
% \changes{4.10}{2003 June 11}{PWD: add \texttt{pg-pre} for total book pages location}
% \changes{4.11}{2003 June 23}{PWD: fix DOI to have no space after colon}
% \changes{4.11}{2003 June 23}{PWD: add options \texttt{ser-vol} and \texttt{ser-ed}}
% \changes{4.11a}{2003 Aug 19}{PWD: fix bug with \texttt{ser-ed} option}
% \changes{4.12}{2003 Sep 8}{PWD: rename \texttt{noprov} to \texttt{plntx} for Plain \TeX\ compatibility}
% \changes{4.12a}{2003 Nov 6}{PWD: fix bug in which comma separators go on wrong side; change was
%                             originally made in \texttt{makebst} but not in \texttt{merlin}}
% \changes{4.13}{2004 Feb 9}{PWD: fix some bugs in \texttt{inbook} and \texttt{incollection}}
% \changes{4.13}{2004 Feb 9}{PWD: add option \texttt{nm-rvcx}}
% \changes{4.13}{2004 Feb 9}{PWD: add option \texttt{tit-col} for colon after titles}
% \changes{4.14}{2005 Oct 17}{PWD: add option \texttt{nm-rvvc}, spaceless initials with comma}
% \changes{4.14}{2005 Oct 17}{PWD: add option \texttt{etal-xc} to suppress comma before et al.}
% \changes{4.15}{2006 Jan 4}{PWD: add option \texttt{pres} for conference talks, presentations}
% \changes{4.16}{2006 Feb 15}{PWD: fix bug in \texttt{proceedings} that suppress number/series at times}
% \changes{4.20}{2007 Apr 23}{PWD: add option to allow more than one author in cites before et al.}
% \changes{4.20}{2007 Apr 24}{PWD: allow variable number of authors before truncating citation}
% \changes{4.21}{2007 May 2}{PWD: reprogram \texttt{remove.dots} to retain dot accent}
% \changes{4.22}{2007 Oct 10}{PWD: add code provided by Joseph Wright for 2-digit extra labels}
% \changes{4.30}{2008 Aug 25}{PWD: fix bug in ordering with \texttt{seq-key} and truncated author lists}
% \changes{4.30}{2008 Aug 25}{PWD: allow up to 6 authors with \texttt{mcite}}
% \changes{4.30}{2008 Aug 27}{PWD: Fix bug for \texttt{nm-rvvc}, thanks to Ted Pavlic}
% \changes{4.30}{2008 Aug 27}{PWD: Remove bibinfo encapsulation for DOI, treat like URL}
% \changes{4.30}{2008 Aug 27}{PWD: Add option \texttt{url-doi} to make URL out of the DOI}
% \changes{4.30}{2008 Oct 4}{PWD: Add option \texttt{xintls} to sort on surname only without initials}
% \changes{4.31}{2011 Jan 10}{PWD: let the pre-date punctuation options \texttt{yr-com} etc. work with \texttt{harnm} too}
% \changes{4.32}{2011 Mar 28}{PWD: Fix bug with \texttt{numser} in \texttt{proceedings}}
% \changes{4.33}{2011 May 13}{PWD: Fix bug with \texttt{remove.dots} by declaring string \texttt{z}}
% \changes{4.33}{2011 Nov 18}{PWD: Fix bug so that \texttt{pub-xc} works without \texttt{ay} too}
%
% \pagestyle{myheadings}
% \markboth{P. W. Daly}{A General Master Bibliography Style}
%
% \title{{\bfseries A Master Bibliographic Style File}\\
%      for numerical, author--year, multilingual applications}
%
% \author{Patrick W. Daly}
%
% \GetFileInfo{merlin.mbs}
% \date{This paper describes file \texttt{\filename},\\
%  version \fileversion{} from \filedate
%   \thanks{Work on \texttt{custom-bib}~4.00 was supported by the
%          American Physical Society}}
%
% \maketitle
%
% \MakeShortVerb{\|}
%
% \parskip=1ex \parindent=0pt
%
% \newcommand{\btx}{{\sc Bib}\TeX}
% \newcommand{\dtx}{\textsf{docstrip}}
%
% \section{Introduction}
% A problem facing users of \btx{} is that there is no standard for
% formatting lists of references. Publishers and journals insist
% on completely arbitrary placement of commas, colons, and ordering of
% entries. Furthermore, author--year styles of citations are supported by
% certain special \LaTeX{} packages, but each for only a very limited
% number of bibliographic styles. Finally, most such style files are for
% English only, and any adaptations to other languages must duplicate the
% entire spectrum of such files.
%
% All of these obstacles are in principle easily overcome by simply
% reprogramming \btx{} by means of an appropriate \emph{bibliographic style
% file} (extension \texttt{.bst}). \btx{} is in fact extremely flexible;
% unfortunately its programming language is very low-level, permitting only
% the most basic of hacks for the normal user.
%
% The solution to this is a \emph{generic} or \emph{master bibliographic
% style file} (extension \texttt{.mbs}) containing \dtx{} options for
% alternative coding. By selecting the desired options, one can customize a
% \texttt{.bst} file to one's needs.
%
% This file, \texttt{\filename}, is my latest version of a general-purpose
% \texttt{.mbs} file to meet as many bibliographic needs as possible.
% It was originally assembled from Oren Patashnik's standard files {\tt
% plain.bst} and \texttt{unsrt.bst}, plus his non-standard file {\tt
% apalike.bst}, a very basic author--year citation style.
% It has since evolved extensively as I have added features found in
% available \texttt{.bst} files, and those demanded by publishers or
% suggested to me by many user/contributors.
%
% To produce a customized bibliographic style (\texttt{.bst}) file from this
% master file, simply \TeX{} or \LaTeX{} the `program' \texttt{makebst.tex}.
% When asked for the name of the master file, answer with
% \begin{quote}\tt\filename\end{quote}
% and then reply to the questions in the following menus. The last question
% is whether you want to generate the \texttt{.bst} file right away.
%
% More details on this process and on the options available are to be found
% in the rest of this article.
%
% \section{History of this File}
%
% Since the first release of this generic file, in November 1993, under the
% name \texttt{genbst.mbs}, I have received innumerable
% suggestions for additions, most of which I have tried to include. Often
% this has resulted in reorganizing the coding, and adding new functions.
% The resulting \texttt{.bst} files are now quite different from those of
% Patashnik, although the underlying ideas are the same.
%
% A second version was released shortly afterwards that paralleled the first
% one except that it included support for languages other than English.
% That file was named \texttt{babel.mbs}, following the \texttt{babel}
% system of Johannes Braams. Although I always viewed it as version 2 of
% \texttt{genbst.mbs}, all additions to the one were also included in the
% other. This of course was tedious and prone to error. I looked forward to
% the day when \texttt{babel.mbs} would become the only supported version.
% The reason I was reluctant to do that before was that the overhead per
% language was fairly high, and I dreaded to think how large the file would
% become when 20 or 30 languages were added.
%
% I then found a way to put the language definitions into separate files,
% one per language. This means that new languages do not burden the basic
% file, and that users need only keep those support files that might
% interest him or her. New ones may also be made up locally by hacking an
% existing language definition file. (The file \texttt{english.mbs} is
% supplied only for this purpose.)
%
% For this reason, \texttt{\filename} was released as version~3 of
% \texttt{genbst.mbs} and \texttt{babel.mbs}. In spite of the new name, it
% should be regarded as their direct successor. Needless to say, this means
% that the earlier two \texttt{.mbs} files will no longer be maintained.
%
% To include language support, all explicit English words like
% \textsl{editor} and \textsl{chapter} have been replaced by functions
% whose definitions may be altered in the resulting \texttt{.bst} file
% (less desirable method) or which may be redefined by an external
% language definition file (preferred method).  Alternatively, one can select
% the pseudo-language named \texttt{babel} which inserts \LaTeX{} commands
% for the explicit words, the definitions of which must be
% contained in a file called {\tt babelbst.tex}. Only the languages English
% and \texttt{babel} are included internally to \texttt{\filename}; all
% others are contained in external language definition files.
%
% Another new feature is the possibility of including a file containing
% prestored shorthand designations for certain journal names. Such a file
% is provided for physics journals, but others could be made up using this
% one as a model. See Section~\ref{sec:jnames}.
%
% To take advantage of these external files, one must use
% \texttt{makebst} version~3; \texttt{\filename} may still be used with
% earlier versions, but without the external files.
%
% Version~4 arose out of a project by David Carlisle who created a variant
% of \texttt{\filename} for REV\TeX\ and the American Physical Society with
% the help of Mark Doyle of the APS. The main purpose was to add extra
% fields (see page~\pageref{sec:revtex}) that were needed. Subsequently
% Arthur Ogawa revised the code considerably, making it more rational,
% fixing some bugs and adding some extra features.
%
% I was then asked to incorporate all these changes into the official
% version of \texttt{\filename}. This required much debugging, since the
% Ogawa's rationalization upset several of the delicate interplays between
% various options. The result is version~4.0, the work on which has been
% supported by the American Physical Society.
%
% Version~4.0 contains the REV\TeX\ extra fields and the
% Carlisle-Doyle-Ogawa rewrites. An additional feature that derived from
% Carlisle's work on REV\TeX\ is the tagging of the text entries in the
% bibliography. This means the volume number is given as
% |\bibinfo{volume}{5}|. Normally only the number 5 is printed, but another
% program could use this to reconstruct the original database entries.
%
% Arthur Ogawa also added some features to \texttt{makebst} to provide a more
% verbose protocol. As a result, version~4 of \texttt{\filename} can only be
% used with version~4 of \texttt{makebst}. Older versions of \texttt{\filename}
% will still function with the newer \texttt{makebst}. Also, \texttt{.dbj}
% files created with older versions should still produce the same results with
% \texttt{\filename}~4.
%
% \def\temp{merlin.mbs}\ifx\temp\filename
% This file is now named after the legendary magician in the hope that it
% can produce wonders by incanting the right magic formulas. However, one
% should bear in mind that even Merlin was not omnipotent. It would be too
% much to hope that all bibliographic wishes will be fulfilled quickly and
% easily, but we shall try as best we can. Watch the wizardry at work!
% \fi
%
% \section{About Master Bibliographic Style Files}
%
% For details about how master bibliography style files are to be
% constructed, see the documentation on \texttt{makebst}. Here only a
% rough overview is given.
%
% \subsection{The \dtx{} Program}
% The \dtx{} program, written by Frank Mittelbach, is now a fundamental
% part of the \LaTeXe{} installation. Its original purpose is to remove
% comment lines from documented files, but has the secondary function of
% selecting alternative lines of coding.
%
% A master \btx{} bibliographic style file is one that, when processed by
% \dtx{} with selected options, produces a regular \btx{} \texttt{.bst}
% file with the desired features.
%
% In this sense, \dtx{} functions something like a C preprocessor. In fact,
% Oren Patashnik's original \texttt{.bst} files were all produced from a single
% source file by means of the preprocessor. The advantage of \dtx{} is that
% it is portable to all installations with \TeX.
%
% \subsection{The \dtx{} Batch Job}
%
% The \dtx{} program can be run either interactively, where the user must
% answer questions via the keyboard, or by means of a batch job where all
% the inputs are prepared in a file beforehand. For producing a \btx{}
% style file from a master file, the batch job method is the only feasible
% one, simply because of the large number of options available. (There is
% another reason for employing a batch job: the interactive method adds an
% |\endinput| command at the end, something that \btx{} will protest
% about.)
%
% The batch job files in general do not have any particular extension but I
% use \texttt{.dbj} for \emph{\dtx{} batch job}. These files are useful
% because they document the options used to produce the \texttt{.bst} file,
% and they may be edited to experiment with alternative options.
%
% \subsection{The \texttt{makebst} Program}
%
% It is possible to make up a batch job file by hand using the option
% information listed in Section~\ref{sec:options}, but my accompanying
% program \texttt{makebst} simplifies the task considerably. It reads menu
% information in the master file itself in order to present the user with
% an interactive list of choices, translating the answers into appropriate
% options that are then written to a batch job file.
%
% To run it, simply process \texttt{makebst.tex} with \TeX\ or \LaTeX, and
% answer the questions. The first of these is whether you want some
% instructions or not, and the second is the name of the \texttt{.mbs} that
% you want to use. The next query is about the name of the desired
% \texttt{.bst} file (which will also be the root name of the batch job).
% After that, all further questions come from menu information in the
% master file.
%
% At the very end, \texttt{makebst} asks if it should run the batch job for
% you. Isn't that a fine service?
%
% \section{Multilingual Adaptation}
% The original \texttt{.bst} files from Oren Patashnik contain explicit
% English words that are output into the final text. Since \LaTeX{} is
% increasingly being used for other languages, and since the official
% version since December 1991 also uses macros in place of explicit words,
% it seems appropriate for \btx{} to follow suit.
%
% In this master bibliographic style file {\tt\filename}, all explicit
% words have been replaced by functions: e.g., the word \textsl{editor} has
% become the function \texttt{bbl.editor}. Depending on the language option
% chosen, this function is defined to be the text {\tt"editor"},
% {\tt"Redakteur"}, or {\tt"redacteur"}, for English, German, and French,
% respectively.
%
% There is another special `language' called \texttt{babel} that instead inserts
% the text |"\bbleditor{}"|; the definitions of these \LaTeX{} commands
% must be in a separate file named \texttt{babelbst.tex} that is read in at
% the start of the bibliography.
%
% Only English and \texttt{babel} are supported directly in
% \texttt{\filename}; all other language definitions are contained in
% separate definition files, e.g., \texttt{french.mbs}, \texttt{german.mbs}.
%
% The language selection is made during the \texttt{makebst} run, which
% asks for the name of the language definition file as the first menu item. If
% either English or \texttt{babel} is wanted, reply with the default, which
% is \texttt{\filename} itself; otherwise give the name of the desired
% language file.
%
% \begin{quote}\slshape
%   \textbf{Note:} the language definition files can only be used with
%   \texttt{makebst} version~3 or later, and
%
%   with an external definition file, the \dtx{} run requires two passes
%   through \texttt{\filename}, doubling the processing time.
% \end{quote}
%
% Apart from the language adaptation of the whole bibliography, there is also
% the possibility of switching languages for individual references, so as to
% hyphenate the title properly. This is done with the \texttt{language} field
% and the \verb!\setlanguage! command.
%
% \subsection{Adding a New Language Definition File}
%
% To create a new language definition file, simply take one of the existing
% ones, like \texttt{english.mbs}, and replace the explicit English words
% with their translations. There are, however, a number of points that can
% complicate this procedure.
%
% \begin{enumerate}
% \item
%   Do not forget to change the documentation in the file, especially
%   version number, date, author.
%
% \item
%   There are option menus that need to be translated too. It might also be
%   desirable to add or remove options. In most cases, the options in the
%   language files involve possible abbreviations, like
%   \begin{quote}
%      \verb!\mes{^^JABBREVIATE WORD `PAGES':}!\\
%      \verb!\optdef{*}{}{`Page(s)'}{(no abbreviation)}!\\
%      \verb!\optdef{a}{pp}{`Page' abbreviated}{as p. or pp.}!\\
%      \verb!\getans!
%   \end{quote}
%
%   In this example, the option \texttt{pp} appears later in the definition
%   \begin{quote}
%      \verb!FUNCTION {bbl.pages}!\\
%      \verb+%<!pp>{ "pages" }+\\
%      \verb!%<pp>{ "pp." }!
%   \end{quote}
%   This a \emph{local} option, that only affects the coding in the definition
%   file. It is possible to add more local options.
%
% \item
%   However, all options, whether activated by the main file or by the
%   definition file, apply to both. In other words, there really is no such
%   thing as a local option. In the above example, \texttt{pp} is only
%   local because it is never used in \texttt{\filename}.
%
% \item
%   Add the name of the language as an option, with
%   \begin{quote}
%      \verb!\mes{^^JOptions for ENGLISH}!\\
%      \verb!\wr{\spsp\spsp english,\pc: English language}!
%   \end{quote}
%   (This is how options are added without |\optdef| and |\getans|.) The
%   main file just might recognize it in order to take some
%   language-specific action. The least it should do is add a comment at
%   the start of the \texttt{.bst} file stating for which language it is to
%   be used.
%
% \item
%   There could be some problems with edition numbers due to language
%   dependent ways of treating ordinal numbers (1st, 2nd, 3rd in English;
%   1$^{\mbox{\scriptsize re}}$, 2$^{\mbox{\scriptsize e}}$,
%   3$^{\mbox{\scriptsize e}}$ in French; 1., 2., 3., in German). Some
%   accommodation already exists for the oddball language English, and
%   further hacking may be needed for others.
%
% \item
%   If there should be any need for a double-quote character in
%   the translations (German needs it for umlauts) then there is trouble
%   because the \btx{} strings do not allow it. Instead, use the command
%   |\qq|, as in the German word |F\qq{u}nfte| for {\sl F\"unfte} (fifth).
%   It is then vital to add the option \texttt{umlaut} with
%   \begin{quote}
%      \verb!\wr{\spsp\spsp umlaut,\pc: Activate umlaut command}!
%   \end{quote}
%
% Bernd Raichle points out that |\^^b| can be used in place of |\"|
% within \btx{} code. One can thus replace |F\qq{u}nfte| with |F\^^b unfte|
% and do away with the \texttt{umlaut} option.
%
% \end{enumerate}
%
% \subsection{Changing \texttt{babelbst.tex} for a New Language}
%
% Alternatively, a new language can be added by
% modifying the file \texttt{babelbst.tex} and selecting the language {\tt
% babel} for the \texttt{.bst} file. If this is the only language to be used,
% then just change the English words in the definitions.
%
% However, some form of switching would be more desirable. With \TeX\
% version 3, there is a |\language| parameter to control the hyphenation
% patterns, and this could be used to select the correct language. For
% example, if language 0 is English and language 1 German, then put the
% English version of \texttt{babelbst.tex} into \texttt{englbst.tex} and the
% German
% version in \texttt{germbst.tex}. Then \texttt{babelbst.tex} could contain:
% \begin{quote}\begin{verbatim}
% \ifcase\language \input{englbst} \or \input{germbst}
%   \else \input{englbst} \fi
% \end{verbatim}
% \end{quote}
%
% This is of course installation dependent.
%
% \subsection{Extracting the Sample \texttt{babelbst.tex} File}
%
% A sample \texttt{babelbst.tex} (for English) is contained in this master
% file.  Extract it with \dtx{} and the option \texttt{bblbst}. It may be
% edited (and possibly renamed) for other languages as needed.
%
% \subsection{Problem with Edition Numbers}
% Something to note here is the ordinal numbers for editions. \btx{}
% demands that the field \texttt{edition} be given in the database as a word
% \textsl{First}, \textsl{Second}, etc., or as \textsl{1st}, \textsl{2nd},
% etc. This is bad policy
% because it is language dependent. So what I do is to test for the words
% \textsl{first} through \textsl{fifth} (case independently) and replace them
% with language-dependent equivalents. If the {\tt<ord>} option is selected,
% these equivalents are ordinal numbers for that language. Any other words
% cannot be interpreted and must be printed as is.
%
% However, if the \texttt{edition} is given as a number, with or without
% following letters, then the numbers 1 through 5 are replaced by their
% words; any higher numbers just have the ordinal ending (\textsl{th}
% in English) added to them.
%
% These numbers are only used with the word \textsl{edition} or
% its equivalent in other languages, so the translators need
% to provide only the one gender, e.g., feminine for both German and
% French.
%
%
% \section{Prestoring Names of Journals}\label{sec:jnames}
%
% The standard \texttt{.bst} files contain the names of some 20 journals
% in the field of computing, stored as macros for easy reference within the
% database \texttt{.bib} files. For example, the \textsl{Journal of
% Computer and System Sciences} can be referred to as \texttt{jcss}.
% With the option \texttt{jabr} (for journal abbreviation) this same
% shorthand produces \textsl{J.~Comput. Syst. Sci.}.
%
% Some \texttt{.bst} files for physics journals include additional journal
% names, and it is conceivable that other faculties might wish to prepare
% their own such lists, with each name present in a full or abbreviated
% form. Such an external file can now be added with \texttt{\filename} and
% \texttt{makebst} version~3.
%
% As a model, I supply a file \texttt{physjour.mbs} with the names of
% physics journals which I have taken from other \texttt{.bst} files.
% I also have a file \texttt{geojour.mbs} with the names of geophysics
% journals, and a contributed file \texttt{photjour.mbs} containing names of
% optics journals.
%
% In fact, version~3.5 can even include multiple journal-name files.
% Thus one can decide whether to include both, one, or none of the above
% files.
%
% \section{HTML Output}
% There is an option \texttt{html} to create a \texttt{.bst} file producing
% hypertext (HTML) output instead of the regular \LaTeX\ code. This is still
% experimental. The resulting \btx\ output will still be a file with extension
% \texttt{.bbl} and will contain the \LaTeX\ special characters, like |\"a| for
% \"a. One must go over the output to convert such characters to the HTML
% equivalents, and to remove curly braces. Only then can it be renamed
% \texttt{.html}.
%
% Three possible lists are offered:
% \begin{itemize}
% \item a simple paragraph for each entry,
% \item a numbered list,
% \item a description list with the key as the label.
% \end{itemize}
%
% \section{Updating Older \texttt{.dbj} Files}\label{sec:update}
% If you have existing \texttt{.dbj} files for generating \texttt{.bst}
% files from the older version \texttt{genbst.mbs}, these may be run with
% \texttt{\filename} by simply changing the name of the source
% \texttt{.mbs} file. For example, where the older \texttt{.dbj} file contains
% the line
% \begin{quote}
% |\generateFile{mystyle.bst}{f}{\from{genbst.mbs}{%|
% \end{quote}
% edit the file so that \texttt{genbst.mbs} is replaced by
% \texttt{\filename}. The resulting \texttt{mystyle.bst} file will then be
% an updated version of the older one, containing all the same features.
%
% Version~4 of \texttt{\filename} can only be used with version~4 of
% \texttt{makebst}, whereas older versions of \texttt{\filename} will still
% function with the newer \texttt{makebst}. Also, \texttt{.dbj} files created
% with older versions should still produce the same results with
% \texttt{\filename}~4, albeit with different coding.
%
% \section{Acknowledgements}
% I wish to thank all the people who have taken the trouble to send me
% suggestions or special requests. Admittedly, it has been out of
% self-interest on their part, since they had bibliographic needs to be
% met. And I have often questioned the need for many of their demands. Yet,
% that is part of the bibliographic jungle that I am trying to eliminate.
% If I thought that bibliographies were arbitrarily formatted before I
% started this project, I have more than sufficient confirmation since
% then. The fault lies not with the poor contributors, but with the
% publishers who cannot agree on a decent standard.
%
% I want to thank Frank Mittelbach, not only for creating \dtx{}
% in the first place, but also for sending me his bibliographic requirements,
% and for suggesting an improvement to \texttt{makebst}.
%
% David Carlisle has added the REV\TeX\ fields and |\bibinfo| tagging in a
% special variant of \texttt{\filename}; Arthur Ogawa then incorporated
% them into the main file, and overhauled much of the coding to make it
% more legible and rational.
%
% I especially wish to thank Mark Doyle and the American Physical
% Society for supporting the work on \texttt{custom-bib}~4.0.
%
% And finally, all of us must thank Oren Patashnik for providing \btx;
% without its flexibility and programmability (in spite of the complexity
% of the language) the master bibliographic styles would not be possible at
% all.
%
% \section{The Options}\label{sec:options}
% Here I present a list of all the \dtx{} options that are
% available in this file {\tt\filename}.
% The normal user can skip this section since he will probably make use
% of the menus via \texttt{makebst}. These are described in
% Section~\ref{sec:menu}. The menus provide much more informative prompts
% than the heavily abbreviated option names listed here. In other words,
% the options described in this section are meant for internal (programmer)
% usage, while the normal interface for the user is the menus.
%
% I have tried to avoid
% conflicts with mutually exclusive options by always letting one dominate if
% more than one has been specified. Such options have the same prefix, such
% as \texttt{nm-rev} and \texttt{nm-init}.
% If one uses \texttt{makebst} to produce the
% \dtx{} batch job, then it is impossible to give mutually
% exclusive options unless one edits the batch file oneself afterwards.
% (Anything is possible with computer freaks!)
%
% Most mutually exclusive options have the same prefix before the hyphen.
%
% \newenvironment{opt}{%
% \begin{list}{}{\labelwidth2cm \leftmargin2.5cm \labelsep1em \rightmargin0pt
%  \def\makelabel##1{\ttfamily##1 \hfill}}}{\end{list}}
% \textbf{Citation style:} whether or not a numerical or author--year system
% is to be used.
% \begin{opt}
% \item[--] default is numerical, standard \LaTeX, as for {\tt
%           plain.bst}.\\
%           |\bibitem{key}...|
% \item[cite] special for listing entire databases; the cite key is used
%             as the label so it may be listed.\\
%             |\bibitem[key]{key}...|
% \item[ay] for author--year style of citations. Various forms of |\bibitem|
%           are provided under this option, to support different types
%           of \LaTeX{} styles for interfacing with the author--year system.
% \item[alph] for \texttt{alpha.bst} style of citations; essentially numerical
%           but an abbreviation of the author names plus year is used as
%           the label. First three letters of single author, or first letters
%           of first three authors.
% \item[alf-1] with \texttt{alph}, uses first three letters of first author's
%           name, regardless of how many authors.
% \item[alf-f] with \texttt{alph}, uses first author's whole name.
% \end{opt}
%
% For numerical style, one can select the HTML option, to output a
% hypertext file instead of a \LaTeX\ one.
%
% \begin{opt}
% \item[--] normal \LaTeX\ output;
% \item[html] for HTML output, one reference per paragraph
% \item[htlist] (with \texttt{html}) outputs to a numbered list;
% \item[htdes] (with \texttt{html}) outputs description list, with the key.
% \end{opt}
%
% If \texttt{ay} has been selected, then the type of author--year interface
% is selectable. Some of these, like \texttt{natbib} and \texttt{harvard}
% exist in two versions because of updates in these systems.
% \begin{opt}
% \item[--] default is the system I invented for my \texttt{natbib.sty}.\\
%            |\bibitem[author(year)]{key}...|
% \item[nat] for extended format of \texttt{natbib.sty} version 5.3\\
%            |\bibitem[author(year)full author]{key}...|
% \item[alk] for the \texttt{apalike.sty} of Oren Patashnik and related
%            systems\\
%            |\bibitem[author, year]{key}...|
% \item[har] for the Harvard family of styles (with \texttt{harvard.sty}).\\
%            |\harvarditem[short]{long}{year}{key}...|
% \item[harnm] for the extended Harvard family, containing some extra commands
%            used by \LaTeXe\ version 2.0.3 of \texttt{harvard.sty}
% \item[ast] for astronomy family of styles (with \texttt{astron.sty}).\\
%            |\bibitem[\protect\astroncite{author}{year}]{key}...|
% \item[cay] for the Chicago family of styles (with \texttt{chicago.sty}).\\
%            |\bibitem[\protect\citeauthoryear{long}{short}{year}]{key}...|
% \item[nmd] for the `named' variant of Chicago (with \texttt{named.sty}).\\
%            |\bibitem[\protect\citeauthoryear{author}{year}]{key}...|
% \item[cn] for the ``author--date'' group of styles (with {\tt
%            authordate1-4.sty})\\
%            |\bibitem[\protect\citename{author, }year]{key}...|
% \end{opt}
%
% \textbf{Sequence:} the order in which the references are listed.
% \begin{opt}
% \item[--]      default is alphabetical by all authors, date, title
% \item[seq-yr]  order by year (ascending), authors, title
% \item[seq-yrr]  order by year (descending), authors, title
% \item[seq-no]  sequence by citation order
% \item[seq-lab] (author--year) by label, date, title (means that Daly
%                precedes Daly and Williams, precedes Daly et al.)
% \item[seq-labc] (author--year) like \texttt{seq-lab} but the Daly et al.'s
%                come in citation order
% \item[seq-key] (author--year) like \texttt{seq-lab} except that for
%                identical authors and year, the cite keyword is used
%                instead of the title or cite order
% \item[xintls] (use with \texttt{seq-} options) to sort on surname only
%                without the initials or first names
% \item[vonx]    ignore \emph{von} part of name when ordering (default is
%                to consider \emph{von} as part of the whole surname)
% \end{opt}
% Note on the \texttt{seq-lab} option and it variants: it orders the list of
% references by \emph{label}, which is what the |\cite| command prints. The
% ordering rules are:
% \begin{enumerate}
%   \item the first author, with name or initials (so P.~Daly is different from
%   E.~Daly)
%   \item by number of co-authors: single author, double author, multiple
%   authors
%   \item by year
%   \item by co-authors
%   \item by title
% \end{enumerate}
% Variations are: with \texttt{seq-key}, the last item becomes the \btx\ citation
% keyword; with \texttt{seq-labc}, the co-author is still used for two-author
% papers, but not for multiple authors, and the final criterion is the order of
% citation in the document. These references will have identical labels (First
% \emph{et~al}, year) and are distinguished by additional letters, which are
% assigned in the order in which the first citations are made. The list of
% references conforms to this order.
%
% With \texttt{xintls} as well, first names or initials are
%  ignored for sorting, so all Daly's are mixed together.
%
% \textbf{Language selection:} the translations of certain explicit words.
% \begin{opt}
% \item[--]      default is English, for \textsl{and}, \textsl{chapter},
%                  \textsl{editor}, etc.;
% \item[babel]     replace words with \LaTeX{} commands that are defined
%                  in the file \texttt{babelbst.tex};
% \item[lang]     adds the \texttt{language} field for switching language
%                 for one reference only by means of the \verb!\setlanguage!
%                 command in \texttt{babel}.
% \end{opt}
%
% If one of the external language definition files is used, then the name of
% its language should be in the list of active options. Many other language
% names are already included as options in this main file simply for the
% purpose of adding a comment at the start of the \texttt{.bst} file.
%
% The \texttt{language} field is intended to allow the hyphenation patterns
% to be switched temporarily so that titles can be set in the original
% language.
%
% \textbf{Annotation:}
% annotations are added either by means of the \texttt{annote} field, or
% with a \texttt{.tex} file of the same name as the citation key.
% \begin{opt}
% \item[--]   no annotations
% \item[annote] annotations enabled, with \texttt{annote} field.
% \end{opt}
%
% \textbf{Presentations:}
% add a non-standard type to handle talks (presentations). This is similar to the
% \texttt{inproceedings} but without \texttt{booktitle} and with the presenting
% author in bold face. This author is specified by the \texttt{key} entry, which
% is that author's position in the author list (1, 2, \dots). The type of presentation
% (oral or poster) is specified by the entry \texttt{type}. The date without year is given
% in \texttt{month}, which must be present.
% \begin{opt}
% \item[--]  no presentations
% \item[pres] include a \texttt{presentation} type
% \item[pres-bf] (with \texttt{pres}) to put speaker in bold face
% \item[pres-it] (with \texttt{pres}) to put speaker in italics
% \item[pres-sc] (with \texttt{pres}) to put speaker in small caps
% \end{opt}
% Without any of the extra font options, the speaker's name is not highlighted.
%
% \textbf{Missing names:}
% If the author and/or editor is missing, the standard \texttt{.bst} files
% use the \texttt{key} field in place of the names for purposes of ordering the
% entries.
%
% For author--year styles, the \texttt{key} field is even inserted in the
% reference list and in the label in place of the authors. Optionally, one can
% suppress the year in this case, which causes \texttt{natbib} (version~7)
% to print only that key text as a code designation for the work.
%
% \begin{opt}
% \item[--] year is inserted in the labels when \texttt{key} replaces authors
% \item[keyxyr] year is left blank in this case
% \end{opt}
%
% \textbf{Names formatting:} how initials and surnames are to be combined.
% \begin{opt}
% \item[--]       default is full names, given names first
% \item[nm-revf]  full names, surname first
% \item[nm-init]  initials plus surname
% \item[nm-rev]   surname plus initials
% \item[nm-rev1]  surname plus initials (1st name only) then initials
%                 plus surname
% \item[nm-revv1] same as \texttt{nm-rev1} but with full names
% \item[nm-rv]    as \texttt{nm-rev}, but initials without dots
% \item[nm-rvvc]  as \texttt{nm-rev}, but initials without spaces
% \item[nm-rvv]   as \texttt{nm-rev}, but initials without spaces or comma
% \item[nm-rvx]   as \texttt{nm-rev}, but initials without dots or spaces
% \item[nm-rvcx]  as \texttt{nm-rvx}, but with comma after surname
% \item[ed-rev]   editors' names in collections are reversed the same as authors'
% \item[ed-au]    editors are formatted with same routine as authors; this
%                 is an alias for \texttt{ed-rev}, which is kept only for
%                 compatibility
% \item[aunm-semi] a semi-colon is placed between author names instead of
%                  a comma
% \item[aunm-sl]  a slash is placed between author names instead of a comma
% \item[nmdash]   repeated author/editor names replaced by dash
% \item[nmd-2]    with \texttt{nmdash}, uses 2 em dashes
% \item[nmd-3]    with \texttt{nmdash}, uses 3 em dashes
% \item[jnrlab]   include the junior part of name in citations (normally
%                 appears only in reference listing)
% \item[jnrlst]   with one of the \texttt{nm-rev} type options, puts the
%                 junior part last, after the (reversed) first name
% \end{opt}
%
% \textbf{Number of names in bibliography:} normally all names listed (in reference list)
% \begin{opt}
% \item[nmlm]     limit number of names
% \item[x1...x90]  (with \texttt{nmlm}) maximum number of names to appear;
%                  for over 9, give the tens and units separately, as
%                  \texttt{x20,x5} for 25
% \item[m1...m90]  (with \texttt{nmlm}) minimum number before \textsl{et al.}
%                   written;
%                 no check for consistency is taken; one \texttt{x} and
%                 one \texttt{m} number must be given, and {\tt x}$\le${\tt m}
% \end{opt}
%
% \textbf{Number of names in citation:} before \textsl{et al.}
%
% The default is to cite one or two names at most, but for three or more, to
% cite only one name with \textsl{et~ al.}
% \begin{opt}
% \item[mcite] to change the default
% \item[mct-1...mct-6] (with \texttt{mcite}) number of names preceding \textsl{et~al.}
% \item[mct-x2...mct-x6] (with \texttt{mcite}) max number of authors without truncating
% \end{opt}
% The default is equivalent to \texttt{mct-1} and \texttt{mct-x2}.
%
% \textbf{Names font:} in the reference list
% \begin{opt}
% \item[--]       default is names in normal typeface
% \item[nmft]     names are in some special font
% \item[nmfted]   editors' names in collections also get special fonts
% \item[nmft-sc]  names in small caps
% \item[nmft-it]  names in italics
% \item[nmft-bf]  names in bold
% \item[nmft-def]  names in user defined font |\bibnamefont{}|.
% \item[nmand-rm] `and' in normal font, not same as authors'.
% \item[fnm-rm]   (with \texttt{nmft}) first names are in regular font
% \item[fnm-def]  (with \texttt{nmft}) first names are in user defined
%                 font |\bibfnamefont{}|.
% \item[--]       first names are in same font as the surnames.
% \end{opt}
%
% \textbf{Citation font:} what is written by the |\cite| command
% \begin{opt}
% \item[--]       default is no special font
% \item[lab-it]   cited names in italics
% \item[lab-sc]   cited names in small caps
% \item[lab-bf]   cited names in bold face
% \item[lab-def]  cited names in user defined font |\bibnamefont{}|.
% \item[and-rm]   word `and' in cited names in normal font
% \item[xlab-it]  extra label (letter after year) in italics
% \end{opt}
%
% \textbf{Block punctuation:} between logical sections (not mutually
% exclusive)
% \begin{opt}
% \item[--]       default is period after each logical section, including end
% \item[blk-com]  use commas, except at very end (changes \textsl{In} to
%                     \textsl{in})
% \item[blk-tit]  like \texttt{blk-com} except period follows titles of
%                      articles and books
% \item[blk-tita] like \texttt{blk-com} except period follows article title
% \item[tit-col] with \texttt{blk-tit} or \texttt{blk-tita}, for colon instead of period
% \item[com-semi] with \texttt{blk-com}, uses semi-colon instead of comma
% \item[com-blank] with \texttt{blk-com}, uses blanks instead of comma
% \item[in-col]   puts a colon after \textsl{In} or \textsl{in} for edited works
% \item[in-it]    puts word \textsl{in} in italics (may be used with
%                   \texttt{in-col})
% \item[in-x]     suppresses the word \textsl{in} for edited works
% \item[fin-bare] no punctuation at the very end
% \item[au-col] puts a colon after the author/editor block
% \item[blknt]  puts period before note
% \end{opt}
%
% \textbf{Date:} if missing
%
% \begin{opt}
% \item[--] Missing date replaced by ???? (author--year)
% \item[blkyear] Missing date left blank, even in label.
% \end{opt}
%
% \textbf{Date:} position and enclosure
%
% \begin{opt}
% \item[--]       default is date at end, before notes; for author--year,
%                   date consists only of year, no month
% \item[dt-jnl]   date at end as for default, except for journal articles
%                   where it follows the journal name as part of specification
% \item[dt-end]   date goes after any notes
% \item[dt-beg]   date goes after authors' names
% \item[yr-par]   date in parentheses ()
% \item[yr-brk]   date in brackets []
% \item[yr-com]   date preceded by comma and space
% \item[yr-col]   date preceded by colon and space
% \item[yr-per]   date preceded by period and space
% \item[yr-blk]   date preceded by space
% \item[dtrev]    date as year month instead of month year
% \item[dtbf]     date bold face
% \item[aymth]    include month even for author-year
% \item[xmth]     suppress month for numerical mode
% \item[yrp-x]    suppresses punctuation following month, year when date
%                 is just after authors
% \item[yrp-col]  adds colon and space after date when just after authors
% \item[yrp-semi] adds semi-colon and space after date when just after authors
% \item[yrp-per]  adds period and space after date
% \item[yrpp-xsp] removes blank following year punctuation
% \item[note-yr]  permits text (like ``in press'') in the \texttt{year} field
% \end{opt}
%
% \textbf{Article in journal:} style of title, volume, pages
% \begin{opt}
% \item[--]       default is: Title. \textit{Journal}, vol(num):p1--p2
% \item[injnl]    adds word \textsl{in} before journal name, same style as
%                 for incollections
% \item[volp-sp]  as above, but with a space, vol(num):~p1--p2
% \item[volp-semi] semi-colon instead of colon:   vol(num);~p1--p2
% \item[volp-com] comma and space instead of colon:   vol(num),~p1--p2
% \item[volp-blk] only space instead of colon:   vol(num)~p1--p2
% \item[vol-bf]   volume in bold
% \item[vol-it]   volume in italics
% \item[vol-2bf]  volume and number bold
% \item[vnum-x]   no number for journals, only volume
% \item[vnum-sp]  space between, as vol (num)
% \item[vnum-cm]  replace vol(num) with vol, num
% \item[vnum-nr]  replace vol(num) with vol, no. num
% \item[vnum-h]   replace vol(num) with vol, \#num
% \item[vnum-b]   replace vol(num) with vol num
% \item[jdt-v]    year in parentheses attached to volume: vol(year) num
% \item[jdt-vs]   as above, with space: vol (year) num
% \item[jdt-p]    year precedes pages: vol(num), (year) p1--p2
% \item[jdt-pc]   as above, with comma: vol(num), (year), p1--p2
% \item[jpg-1]    only starting page given
% \item[pgsep-c]  page numbers over 10,000 have comma
% \item[pgsep-s]  page numbers over 10\,000 have space
% \item[pgsep-p]  page numbers over 10.000 have period
% \item[jwdpg]    include `page' or `pp' for articles
% \item[jwdvol]   include `volume' or `vol' for articles
% \item[jnm-x]    no punctuation after journal name
% \item[tit-it]   article title in italics
% \item[tit-qq]   article title in quotes
% \item[bt-rm]    booktitle in upright font, not italic (this will be issued
%                 with \texttt{btit-rm} normally; separate options allow for
%                 more control if wanted
% \item[bt-qq]    booktitle of incollection and inproceedings in quotes
% \item[qt-s]     (with \texttt{tit-qq}) single instead of double quotes
% \item[qt-g]     (with \texttt{tit-qq}) guillemets instead of quotes
% \item[qx]       (with \texttt{tit-qq}) comma outside quotes
% \item[jtit-x]   no article title (applies only to journals and
%                 collections)
% \item[atit-u]   article title capitalized as in entry, default is
%                 sentence capitalization (first word and words following
%                 colons)
% \item[jxper]    abbreviated journal names have periods removed, as
%                 `Phys Rev'
% \item[jttl-rm]  name of journal not in italics
% \item[pp-last]  pages appear at end, before any notes
% \end{opt}
%
% \textbf{Number and series:} for collections and inproceedings
%
% This is a confusing issue. The standard wants to print something like
% ``number 123 in Collected Works'', and issues a warning if there is a number
% without a series. However, for many such works, there is an identification
% number for the collection, such as ESA~SP-123. Giving this as the number
% without a series results in ``number ESA~SP-123'' and a warning. Setting the
% series to this code number produces desired results, but is illogical.
%
% Another problem is that this code number should often should appear just
% before the publisher name,
% whereas the standard places it elsewhere.
%
% \begin{opt}
% \item[--]  default, number must have series, \textsl{number} is printed
% \item[num-xser] default behaviour if both number and series present, but if
%      only number is there, it is printed without the word \textsl{number} and
%      without a warning
% \item[numser]  moves the number/series to just before the publisher/organization
% \item[ser-vol] for a book in a series with volume number, appears as ``\textit{Series-Name}, vol.~23''
%       rather than ``vol.~23 of \textit{Series-Name}''
% \item[ser-ed] for incollection, inproceedings, the series and volume appear between
%       the booktitle and the editors
% \end{opt}
%
%
% \textbf{Thesis title:} formatted like a book or article
% \begin{opt}
% \item[--]       default is like a book title
% \item[thtit-a]  titles of PhD and Master theses formatted like articles
% \item[thtit-x]  no thesis title
% \end{opt}
%
% \textbf{Technical Report title:} formatted like book or article
% \begin{opt}
% \item[--]       default is like an article title
% \item[trtit-b]  titles of technical reports formatted like books
% \item[trnum-it] \textsl{technical report} and number italic
% \end{opt}
%
% \textbf{Books:}  title font style, pages, and address location
% \begin{opt}
% \item[--]       default is italicized
% \item[btit-rm]  book title plain
% \item[bkpg-par] pages in books places in parentheses
% \item[bkpg-x]   pages in books bare without word \textsl{pages}
% \item[add-pub]  publisher's address before name, colon separated
% \item[pub-par]  publisher and address in parentheses
% \item[pub-date] publisher with address and date in parentheses
% \item[pub-xc]   with \texttt{pub-date}, suppresses comma before date
% \item[pub-xpar] with \texttt{pub-date} to suppress parentheses
% \item[pre-pub]  publisher placed before chapter and page information
% \item[pre-edn]  edition before publisher
% \item[pg-bk]    add number of pages for books and booklets
% \item[pg-pre]   with \texttt{pg-bk}, total pages comes before publisher
% \end{opt}
%
% \textbf{Abbreviations:} of various words, default is no abbreviations
% \begin{opt}
% \item[pp]       abbreviate \textsl{page(s)} as \textsl{p.} and \textsl{pp.}
% \item[ppx]      no word \textsl{page(s)} or abbreviation
% \item[ed]       abbreviate \textsl{editor(s)} as \textsl{ed.} and
%                     \textsl{eds.}
% \item[ednx]     abbreviates \textsl{edition} as \textsl{ed.} instead
%                     of \textsl{edn.}
% \item[abr]      abbreviate \textsl{volume}, \textsl{edition},
%                     \textsl{technical report}, etc.
% \item[mth-bare] months abbreviated without dots
% \item[jabr]     abbreviate names of prestored journals
% \item[ord]      write edition numbers as 1st, 2nd, instead as words.
% \item[xedn]     suppress conversion of editions (for English) to avoid
%                 overflowing some \btx\ installations
% \end{opt}
%
% \textbf{Editor:} alternative for \emph{in edited} book, inbook, or proceedings.
% \begin{opt}
% \item[--]       ``in \emph{names}, editors, \emph{title}''
% \item[edpar]    ``in \emph{names} (editors), \emph{title}''
% \item[edparc]   ``in \emph{names}, (editors) \emph{title}''
% \item[edparxc]  ``in \emph{names} (editors) \emph{title}''
% \item[bkedcap]  capitalizes ``Editor''
% \end{opt}
%
% \textbf{Editor:} alternative for \emph{in edited} incollection or inproceedings.
% If none of these are selected, they are treated the same as an edited book.
% \begin{opt}
% \item[--]       ``in \emph{names}, editors, \emph{title}''
% \item[edby]     ``in \emph{title}, edited by \emph{names}''
% \item[edby-par] ``in \emph{title} (edited by \emph{names})''
% \item[edby-parc] ``in \emph{title}, (edited by \emph{names})''
% \item[edcap]    (with \texttt{edby-par}) capitalizes ``Edited by'' or
%                    ``Editor''
% \item[edbyx]    (with \texttt{edby} or \texttt{edby-par}) replaces text
%                 \textsl{edited by} by \textsl{editor(s)} before the names,
% \item[edbyw]    same as \texttt{edbyx} but with word \textsl{editor} only in
%                  parentheses
% \item[edbyy]    (with \texttt{edby} or \texttt{edby-par}) replaces text
%                 \textsl{edited by} by \textsl{editor(s)} after the names,
%                 as ``in \emph{title}, \emph{names}, editors''.
% \end{opt}
%
% \textbf{ISBN, ISSN numbers:} include or not
% \begin{opt}
% \item[--]       default is no ISBN number, ignore this field,
% \item[isbn]     include an ISBN number as optional entry for books, booklets,
%                 incollections, inproceedings
% \item[issn]     include an ISSN number for periodicals
% \end{opt}
%
% \textbf{URL address:} include or not, and how
% \begin{opt}
% \item[--]       ignore URL field,
% \item[url]      process URL field (needs one of next options too),
% \item[url-blk]  (with \texttt{url}) URL text as regular blocked item,
% \item[url-nt]   URL text treated as a note
% \item[url-nl]   URL text added as new line below reference (Harvard style)
% \end{opt}
%
% \textbf{DOI number:} include or not
% \begin{opt}
% \item[--]       default is not to include the Digital Object Identifier
% \item[doi]      include the DOI number
% \item[agu-doi]  (with \texttt{doi}) place DOI number AGU style, as part of page designation
% \item[url-doi]  (with \texttt{url} options) write DOI as a URL
% \end{opt}
% With the \texttt{url-doi} option, the DOI is formatted to be a URL, i.e. as
%  |//dx.doi.org/|\emph{doi}; if there is a URL entry as well, it is ignored.
%  If this option is given without the \texttt{url} options, it behaves like
%  \texttt{doi}.
%
% The \texttt{agu-doi} option is for the special usage of the American Geophysical Society.
%
% \textbf{REV\TeX\ data fields:} for use with \texttt{revtex.bst}.
% \begin{opt}
% \item[--]      Do not include extra fields for REV\TeX
% \item[revdata] Include fields \texttt{collaboration}, \texttt{eid},
%                  \texttt{numpages} for REV\TeX.
% \end{opt}
%
% \textbf{Eprint field:} used by REV\TeX\ but can be used on its own.
% \begin{opt}
% \item[--]      Do not include \texttt{eprint} and \texttt{archive} fields
% \item[eprint]  Include \texttt{eprint} and \texttt{archive} fields.
% \end{opt}
%
% \textbf{Reference component tagging:} apply structure to the |\bibitem| contents.
% \begin{opt}
% \item[--]      no tagging.
% \item[bibinfo] apply tags like |\bibinfo|, and |\eprint| to the fields of data
%                in the content of the |\bibitem| statement.
% \end{opt}
%
% \textbf{Emphasis:} defines what `italicized' really means
% \begin{opt}
% \item[--]       default is |\em| (can switch between |\it|
%                 and |\rm|
% \item[em-it]    use |\it| instead (always italic)
% \item[em-x]     no emphasis
% \item[em-ul]    underline for emphasis (with or without \texttt{ulem})
% \end{opt}
%
% \textbf{Special punctuation:}
% \begin{opt}
% \item[amper]    use \& in place of \textsl{and}
% \item[varand]   use command |\BIBand| in place of \textsl{and}
% \item[and-xcom] no comma before last \textsl{and} of an author list
%                   (citations and references)
% \item[and-com]  add comma before \textsl{and} even for two authors (in list of
%                  references)
% \item[and-com-ed] the same as \texttt{and-com} but for editors in
%                   collections
% \item[xand]    no \textsl{and} in an author list (references)
% \item[etal-it]  \textsl{et al.} in italics
% \item[etal-rm]  \textsl{et al.} in roman even if authors in different font
% \item[etal-xc]  no comma before \textit{et al.}
% \end{opt}
%
% \textbf{Font commands:}
% \begin{opt}
% \item[--]     use Plain \TeX\ (also \LaTeX~2.09) font commands
% \item[nfss]   use |\textbf|, |\textit|, |\emph| in place of |\bf|, |\it|,
%                and |\em|; only works then with \LaTeXe
% \end{opt}
%
% \textbf{Plain \TeX\ compatibility:}
% \begin{opt}
% \item[--]    use \LaTeXe\ commands for testing, redefining commands
% \item[plntx] use \TeX\ for maximum compatibility
% \end{opt}
%
%
% \section{The Menu Information}\label{sec:menu}
% Here I describe the options and menu information for this particular
% master file \texttt{\filename}. To construct a \dtx{} driver file
% to generate a desired \texttt{.bst} file, simply process \texttt{makebst.tex}
% with \TeX\ or \LaTeX, and give
% \begin{quote}\tt\filename\end{quote}
% when prompted for the name of the master file. Then answer the questions
% in the menus that follow. The menu information is extracted from here.
%
% All the menu information is nested between \dtx{} guard options
% |%<*options>| \dots\ |%</options>|, and the last command is
% |\endoptions|. The rest of the file is nested between
% \begin{quote}
%   |%<*!options&!driver&!bblbst>| \dots\ |</!options&!driver&!bblbst>|
% \end{quote}
% in order to exclude it if \dtx{} is used to
% extract the menu information, the documentation driver, or the
% \texttt{babelbst.tex} file.
%
% The main coding is divided into two sections, the \emph{head} and
% \emph{tail}; in between come any external language or journal name
% support files. The head part is marked with the \dtx{} guard option
% |<!tail>| and the tail with |<!head>|. This roundabout means of doing
% things makes it possible to process \texttt{\filename} with \texttt{.dbj}
% files that were generated for the older \texttt{genbst.mbs} file by
% simply changing the name of the source file as shown in
% Section~\ref{sec:update}. If both \texttt{head} and \texttt{tail} (and
% \texttt{exlang}) options are omitted, as they are in the older
% \texttt{.dbj} files, \texttt{\filename} is processed completely in one
% pass. To include external files, two passes are needed, one for each
% part, with the external file(s) coming in between.
%
% Note too that if the internal language commands are taken (i.e., if
% \texttt{exlang} option is not given) then the default language is
% English, which is tested for as |<!babel>|. This too permits the simple
% update of older \texttt{.dbj}, at least for English.
%
% \subsection*{Selecting Language}
% Explicit words in the bibliography style, such as \textsl{and},
%      \textsl{editor}, etc.,
% are represented by functions \texttt{bbl.and}, \texttt{bbl.editor}, and so on.
% By default these functions translate to the normal English text, but
% other languages are also possible.
%
% The definitions of these functions for other languages are contained in
% external files. At this point, we can make use of features in
% \texttt{makebst} (version~3.0 or later) to ask for the name of such a
% definition file, and store it in |\cfile|. If no external file is
% specified, then the internal definitions are taken, for which there are
% two possibilities: English or \LaTeX{} commands (Babel).
%
% The commands |\MBswitch|, |\mes|, |\MBaskfile|, |\wr|, |\pc|, |\spsp| are
% defined in \texttt{makebst.tex}.
%
% If |\MBswitch| does not exist, then the version of \texttt{makebst}
% cannot support external files.
%
%    \begin{macrocode}
%<*options>
\expandafter\ifx\csname beginoptiongroup\endcsname\relax
 \mes{^^J******************^^J%
        !!!!!! VERSION CLASH !!!!!!!!!^^J%
        This mbs file requires makebst version 4.0 or more^^J%
        You must update makebst to run it with this mbs file^^J%
        No docstrip batch file can be produced on this run^^J%
         ******************}
 \let\temp\endinput\else\let\temp\relax\fi\temp

\newif\ifnumerical
\newif\ifmytemp
\mes{<<< For more information about the meanings of^^J%
     <<< the various options, see the section on ^^J%
     <<< Menu Information in the .mbs file documentation.}

\umes{EXTERNAL FILES:}
\expandafter\ifx\csname MBswitch\endcsname\relax
 \mes{^^J**************^^J%
        Makebst version is less than 3.0^^J%
        Cannot add external file for language definition^^J%
        **************}
 \umes{No included files.}%
 \def\cfile{}\def\jfile{}%
\else
 \MBaskfile{^^JName of language definition file}(\mroot.\mext)i\cfile
 \edef\ctemp{\mroot.\mext}
 \ifx\ctemp\cfile\def\cfile{}\fi
 \umes{Name of language file: \string\cfile=\cfile.}%
%    \end{macrocode}
%
% A second type of external file that can be added is one containing names
% of journals that are to be prestored into the \texttt{.bst} file.
% Several file names are allowed here, with the root names separated by
% commas, and with the common extension added at the end. To assist later
% parsing of the names, an additional comma is added before the extension.
%
% Note that in this case |\MBaskfile| treats the file(s) as output, i.e.,
% it does not check if the file(s) actually exist.
%
% The macro |\Mgetnext| allows the root names to be extracted from the
% list of file names.
%    \begin{macrocode}
 \def\jfile{}
 \ask{\yn}{^^JInclude file(s) for extra journal names? (NO)}
 \mytempfalse
 \if!\yn!\else\if\yn n\else\if\yn N\else\mytemptrue\fi\fi\fi
 \ifmytemp
  \MBaskfile{^^JFile to include}(physjour,geojour,photjour.mbs)o\jfile
  \edef\jfile{\froot,.\fext}
  \umes{Name of included files: \string\jfile=\jfile.}%
 \else
  \umes{No included files.}%
 \fi
\fi%MBswitch
\def\Mgetnext#1,#2.#3??{\def\froot{#1}\def\Mrest{#2}\def\fext{#3}}
%    \end{macrocode}
%
% If no external files are specified, then both |\cfile| and |\jfile| are
% empty. In this case, do \emph{not} set the options \texttt{head} and
% \texttt{tail}, which control the \dtx{} passes through
% \texttt{filename}. Now only one pass is made.
%
% If there is an external definition file, or if an external list of
% journal names, then some extra text must be
% written to fit in with that already written by \texttt{makebst}. This is
% explained in that documentation. The |\MBswitch| command turns the curly
% braces |{..}| into normal characters, and the parentheses |(..)| take on
% their grouping functionality. This permits unbalances braces to be
% written to the output file.
%
%    \begin{macrocode}
\if!\cfile\jfile!\else
 \begingroup\MBswitch
  \wr(\spsp head,\string\MBopta})
  \if!\cfile!\else
   \wr(\string\from{\cfile}{\string\MBopta})
  \fi
  \if!\jfile!\else
   \let\jxfile\jfile
   \loop
%    \end{macrocode}
%
% Parse the list of journal name files, adding a new |\from| for each one.
%
%    \begin{macrocode}
    \expandafter\Mgetnext\jxfile??
    \wr(\string\from{\froot.\fext}{\string\MBopta})
    \edef\jxfile(\Mrest.\fext)
    \if!\Mrest!\def\Mtst(1)\else\def\Mtst()\fi
   \if!\Mtst!
   \repeat
  \fi
  \wr(\string\from{\mroot.\mext}{tail,\string\MBopta}})
  \wr(\string\def\string\MBopta{\pc)
 \endgroup
\fi
%    \end{macrocode}
%
% Ask whether
% explicit English words wanted or \LaTeX{} commands whose definitions are
% to be found in the file \texttt{babelbst.tex}.
%
%    \begin{macrocode}
\beginoptiongroup{INTERNAL LANGUAGE SUPPORT
 (if no external language file)}%
 {\if!\cfile!\relax*\fi}%
\optdef{*}{}{English}{words used explicitly}
\optdef{b}{babel}{Babel}
    {(words replaced by commands defined in babelbst.tex)}
\getans
\endoptiongroup
\if!\cfile!\relax\else
\wr{\spsp\spsp exlang,\pc: External language file}
\fi
%    \end{macrocode}
%
% \subsection*{Author--year or numerical}
% The first question is whether a numerical or author--year citation style
% is to be used. If the latter, the supporting system is my {\tt
% natbib.sty}, which expects |\bibitem| to have an optional argument
% containing the short form of the authors, plus year in parentheses.
% E.g.,
% \begin{quote}
% |\bibitem[Daly et al.(1990)]{key}...|
% \end{quote}
% There is now a newer version of \texttt{natbib.sty} (v5.3) that
% supports an optional full author list too, as
% \begin{quote}
% |\bibitem[Daly et al.(1990)Daly, Keppler, and Williams]{key}...|
% \end{quote}
% Other systems are also supported, such as the Harvard family of
% bibliography styles (with \texttt{harvard.sty}), which have entries in the
% form
% \begin{quote}
% |\harvarditem[Daly et al.]{Daly, Keppler,|\\
% |       and Williams}{1990}{key}...|
% \end{quote}
% or the astronomy family (with \texttt{astron.sty}) with entries like
% \begin{quote}
% |\bibitem[\protect\astroncite{Daly et al.}{1990}]{key}...|
% \end{quote}
% or the Chicago family (with \texttt{chicago.sty}) with entries like
% \begin{quote}
% |\bibitem[\protect\citeautheryear{Daly, Keppler, and|\\
% |      Williams}{Daly et al.}{1990}]{key}...|
% \end{quote}
% or the `named' variant of Chicago (with \texttt{named.sty}) with entries like
% \begin{quote}
% |\bibitem[\protect\citeauthoryear{Daly et al.}{1990}]{key}...|
% \end{quote}
% or the so-called ``author--date'' group (with \texttt{authordate1-4.sty})
% with entries of the form
% \begin{quote}
% |\bibitem[\protect\citename{Daly et al.}1990]{key}...|
% \end{quote}
% Finally, there is the \texttt{apalike} format of Oren Patashnik, for use
% with \texttt{apalike.sty} that has entries of the form
% \begin{quote}
% |\bibitem[Daly et al., 1990]{key}...|
% \end{quote}
%
% In addition to numerical or author--year citation styles, there is also a
% \texttt{cite} style available in which the label is the same as the cite
% key. This is for listing entire contents of databases with the cite key
% visible.
%
% A flag |\ifnumerical| is established because some of the following menu
% features depend on which system is to be used.
%
% The \texttt{alph} option produces labels as in \texttt{alpha.bst}; options
% \texttt{alf-1} and \texttt{alf-f} modify these. Standard is: first three
% letters of the single author (Dal90 for Daly, 1990) and first letters of
% first three authors (DK90 for Daly and Kopka, 1990). Alternatives are first
% three letters of the first author, no matter how many authors there are, and
% full name of first author.
%    \begin{macrocode}
\beginoptiongroup{STYLE OF CITATIONS:}{}
\optdef{*}{}{Numerical}{as in standard LaTeX}
\optdef{a}{ay}{Author-year}{with some non-standard interface}
\optdef{b}{alph}{Alpha style, Jon90 or JWB90}{for single or multiple authors}
\optdef{o}{alph,alf-1}{Alpha style, Jon90}{even for multiple authors}
\optdef{f}{alph,alf-f}{Alpha style, Jones90}{(full name of first author)}
\optdef{c}{cite}{Cite key}{(special for listing contents of bib file)}
\getans
\endoptiongroup
\if\ans a\numericalfalse\else\numericaltrue\fi
\if\ans b\mytempfalse   \else\mytemptrue   \fi
\beginoptiongroup{HTML OUTPUT
 (if non author-year citations)}
 {\ifnumerical*\fi}
\optdef{*}{}{Normal LaTeX}{output}
\optdef{h}{html}{Hypertext}{output, in HTML code, in paragraphs}
\optdef{n}{html,htlist}{Hypertext list}{with sequence numbers}
\optdef{k}{html,htdes}{Hypertext with keys}{for viewing databases}
\getans
\endoptiongroup
\beginoptiongroup{AUTHOR--YEAR SUPPORT SYSTEM
 (if author-year citations)}
 {\ifnumerical\else*\fi}
\optdef{*}{nat}{Natbib}{for use with natbib v5.3 or later}
\optdef{o}{}{Older Natbib}{without full authors citations}
\optdef{l}{alk}{Apalike}{for use with apalike.sty}
\optdef{h}{har}{Harvard}{system with harvard.sty}
\optdef{a}{ast}{Astronomy}{system with astron.sty}
\optdef{c}{cay}{Chicago}{system with chicago.sty}
\optdef{n}{nmd}{Named}{system with named.sty}
\optdef{d}{cn}{Author-date}{system with authordate1-4.sty}
\getans
%    \end{macrocode}
% The \texttt{harvard} family has been extended for \LaTeXe, and the new
% \texttt{.bst} files allow the word \textsl{and} and the brackets around years
% to be variable with commands. These features may be added too.
% The URL field used to be exclusively part of Harvard, but now exists
% independently of it too.
%
%    \begin{macrocode}
\beginoptiongroup{HARVARD EXTENSIONS INCLUDED
 (if Harvard support selected)}
 {\if\ans h*\fi}%
\optdef{*}{harnm}{With Harvard extensions}{for LaTeX2e version of harvard.sty}
\optdef{n}{}{Older Harvard}{style, for LaTeX 2.09}
\getans
\endoptiongroup
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Language switching}
% A \texttt{language} field can be present to specify the original language of
% the reference; with \verb!\setlanguge!, the hyphenation patterns are set for
% setting the title in that language.
%    \begin{macrocode}
\beginoptiongroup{LANGUAGE FIELD}{}
\optdef{*}{}{No language field}{}
\optdef{l}{lang}{Add language field}{to switch hyphenation patterns temporarily}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Annotations}
% Annotations to a reference are additional information not normally printed
% out in the list of references. They are used for listing databases.
% The coding here was offered by Soren Dayton.
%    \begin{macrocode}
\beginoptiongroup{ANNOTATIONS:}{}
\optdef{*}{}{No annotations}{will be recognized}
\optdef{a}{annote}{Annotations}{in annote field or in .tex file of citekey name}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Presentations}
% Presentations are talks at meetings, oral or poster, that are not otherwise
% published. The author making the presentation is indicated with the \texttt{key}
% entry, which is the speaker's number within the author list. The font used
% to highlight the speaker is either bold or italics, depending on the secondary
% option, otherwise not highlighted.
%    \begin{macrocode}
\beginoptiongroup{PRESENTATIONS:}{}
\optdef{*}{}{Do not add presentation type}{for conference talks}
\optdef{p}{pres}{Add presentation, speaker not highlighted}{}
\optdef{b}{pres,pres-bf}{Presentation, speaker bold face}{}
\optdef{i}{pres,pres-it}{Presentaion, speaker italic}{}
\optdef{c}{pres,pres-sc}{Presentaion, speaker in small caps}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Ordering of the listed references}
%   Choices here depend on citation style. The default in both cases is
% alphabetical order of all authors. For numerical style, one may also
% choose an unsorted order, which means the order is the same as the original
% citations. This corresponds to \texttt{unsrt.bst}. Order of citation is
% also offered for author--year for \texttt{natbib}-type styles that can
% also be used for numerical listings.
%
% Another possibility is to order first by year, then authors. This too only
% makes sense for numerical citations. However, it is offered for author--year
% in the event that a \texttt{natbib}-type style is used for numerical
% listings.
%
% For the alpha style, the ordering is by label only, so no option is
% offered here (|\ifnumerical| is \meta{true} and |\ifmytemp| is \meta{false}).
%
% For author--year, the second choice is by label. (The label is the
% optional |\bibitem| argument, and is what is printed in place of the
% |\cite| command.) With this option, all the papers with the same first
% author are ordered so that the one-author papers come first, followed by
% the two-author papers, followed by the multiple-author papers. This is a
% more sensible system for author--year citations, and is demanded by some
% journals (like JGR).
%
% One problem that can arise here is when two or more references have the
% same set of authors and year; normally they are then ordered by the
% title, ignoring initial words like \textsl{the} and \textsl{a}, with the
% letters a, b,
% c, \dots, added to the year. This can mean that a set of references with
% a natural sequence will be put into a different order. An alternative is
% to order them by the citation keyword instead of by title. This of course
% assumes that the keywords in this case reflect that natural sequence.
%    \begin{macrocode}
\let\ans\relax
\beginoptiongroup{ORDERING OF REFERENCES
 (if non-author/year and non-alph)}
 {\ifnumerical\ifmytemp*\fi\fi}%
\optdef{*}{}{Alphabetical}{by all authors}
\optdef{c}{seq-no}{Citation order}{(unsorted, like unsrt.bst)}
\optdef{d}{seq-yr}{Year ordered}{and then by authors}
\optdef{r}{seq-yrr}{Reverse year ordered}{and then by authors}
\getans
\endoptiongroup
%
\beginoptiongroup{ORDERING OF REFERENCES
 (if author-year citations)}
 {\ifnumerical\else*\fi}%
\optdef{*}{}{Alphabetical}{by all authors}
\optdef{l}{seq-lab}{By label}%
   {(Jones before Jones and James before Jones et al)}
\optdef{m}{seq-labc}{By label and cite order}%
   {(like above but all Jones et al ordered as cited)}
\optdef{k}{seq-key}{By label and cite key}{instead of label and title, as above}
\optdef{d}{seq-yr}{Year ordered}{and then by authors (for publication lists)}
\optdef{r}{seq-yrr}{Reverse year ordered}{and then by authors (most recent first)}
\optdef{c}{seq-no}{Citation order}{(unsorted, only meaningful for numericals)}
\getans
\endoptiongroup
%    \end{macrocode}
% The standard \btx\ styles consider the \emph{von} part of the name to be a
% fixed part of the surname. European usage tends to alphabetize ignoring these
% honorifics.
%    \begin{macrocode}
\beginoptiongroup{ORDER ON VON PART
 (if not citation order)}
 {\if\ans c\else*\fi}%
\optdef{*}{}{Sort on von part}{(de la Maire before Defoe)}
\optdef{x}{vonx}{Sort without von part}{(de la Maire after Mahone)}
\getans
\endoptiongroup
%    \end{macrocode}
%
% Sorting normally treats authors with the same surname but different initials
% or first name separately; but a strict ordering by cite label would lump all
% Smiths together.
%    \begin{macrocode}
\beginoptiongroup{IGNORE FIRST NAMES (if author-year citations)}
  {\ifnumerical\else*\fi}%
\optdef{*}{}{Respect first names}{or initials, treat as different authors}
\optdef{x}{xintls}{Sort on surname only}{and treat all Smiths as one}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Formatting author names}
% The default is that the full names of the authors are listed, given names
% first, unabbreviated. Of course, if only the initials have been given in
% the \texttt{.bib} file, then that is all that can appear in the list. Other
% possibilities are to use initials (even if full names in the \texttt{.bib}
% file) either before or after the surnames. A specialty of the journals of
% the American Geophysical Union is to have only the first name with
% reversed initials.
%
% If the reference is part of a larger work with editors, then the editor
% names appear later in the reference text, usually as ``edited by \dots''
% or as ``\emph{names} (editors)''. In these cases, the editor names are
% not usually reversed (surname first) even if the authors' names are.
% An option is provided to format such editor names exactly as the authors'.
%    \begin{macrocode}
\beginoptiongroup{AUTHOR NAMES:}{}
\optdef{*}{ed-au}{Full, surname last}{(John Frederick Smith)}
\optdef{f}{nm-revf}{Full, surname first}{(Smith, John Frederick)}
\optdef{i}{nm-init,ed-au}{Initials + surname}{(J. F. Smith)}
\optdef{r}{nm-rev}{Surname + initials}{(Smith, J. F.)}
\optdef{s}{nm-rv}{Surname + dotless initials}{(Smith J F)}
\optdef{w}{nm-rvvc}{Surname + comma + spaceless initials}{(Smith, J.F.)}
\optdef{x}{nm-rvx}{Surname + pure initials}{(Smith JF)}
\optdef{y}{nm-rvcx}{Surname + comma + pure initials}{(Smith, JF)}
\optdef{z}{nm-rvv}{Surname + spaceless initials}{(Smith J.F.)}
\optdef{a}{nm-rev1}{Only first name reversed, initials}%
   {(AGU style: Smith, J. F., H. K. Jones)}
\optdef{b}{nm-revv1}{First name reversed, with full names}%
   {(Smith, John Fred, Harry Kab Jones)}
\getans
\endoptiongroup
\mytempfalse
\if\ans f\mytemptrue\fi
\if\ans r\mytemptrue\fi
\if\ans s\mytemptrue\fi
\if\ans x\mytemptrue\fi
\if\ans y\mytemptrue\fi
\if\ans a\mytemptrue\fi
\if\ans b\mytemptrue\fi
\beginoptiongroup{EDITOR NAMES IN COLLECTIONS
 (if author names reversed)}
 {\ifmytemp*\fi}
\if\ans r
\optdef{*}{}{Editor names NOT reversed}{as edited by J. J. Smith}
\fi
\if\ans s
\optdef{*}{}{Editor names NOT reversed}{as edited by J J Smith}
\fi
\if\ans a
\optdef{*}{}{Editor names NOT reversed}{as edited by J. J. Smith}
\fi
\if\ans x
\optdef{*}{}{Editor names NOT reversed}{as edited by JJ Smith}
\fi
\if\ans f
\optdef{*}{}{Editor names NOT reversed}{as edited by John James Smith}
\fi
\if\ans y
\optdef{*}{}{Editor names NOT reversed}{as edited by J.J. Smith}
\fi
\if\ans b
\optdef{*}{}{Editor names NOT reversed}{as edited by John James Smith}
\fi
\optdef{r}{ed-rev}{Editor names reversed}{just like authors'}
\getans
\beginoptiongroup{POSITION OF JUNIOR
  (if author names reversed)}
  {}
\optdef{*}{jnrlst}{Junior comes last}{as Smith, John, Jr.}
\optdef{m}{}{Junior between}{as Smith, Jr., John}
\getans
\endoptiongroup
\endoptiongroup

\beginoptiongroup{JUNIOR PART IN THE CITATION
 (if author-year citations)}
 {\ifnumerical\else*\fi}%
\optdef{*}{}{No `junior' part in the citations}{but in the ref listing}
\optdef{j}{jnrlab}{`Junior' in citations}{as well as in ref listing}
\getans
\endoptiongroup

\beginoptiongroup{PUNCTUATION BETWEEN AUTHOR NAMES:}{}
\optdef{*}{}{Author names separated by commas}{}
\optdef{s}{aunm-semi}{Names separated by semi-colon}{}
\optdef{h}{aunm-sl}{Names separated by slash}{/}
\getans
\endoptiongroup

\beginoptiongroup{ADJACENT REFERENCES WITH REPEATED NAMES:}{}
\optdef{*}{}{Author/editor names always present}{}
\optdef{d}{nmdash}{Repeated author/editor names replaced by dash}{}
\optdef{2}{nmdash,nmd-2}{Repeated author/editor names replaced by 2 dashes}{}
\optdef{3}{nmdash,nmd-3}{Repeated author/editor names replaced by 3 dashes}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Number of authors}
% Normally the complete list of authors as given in the \texttt{.bib} file is
% presented in the reference list. However, some journals prefer to limit
% them to a maximum. If there are more than this maximum number of author
% names, then a minimum number plus \textsl{et al.} are listed.
%
% Because no test for consistency of the numbers is carried out in the
% \texttt{.bst} file itself (it might be possible, but I found it too complex),
% this is done here.
%    \begin{macrocode}
\beginoptiongroup{NUMBER OF AUTHORS IN BIBLIOGRAPHY:}{}
\optdef{*}{}{All authors}{included in listing}
\optdef{l}{nmlm}{Limited authors}{(et al replaces missing names)}
\getans
\endoptiongroup
\if\ans l
\loop
  \ask{\num}{Maximum number of authors (1-99)}
  \ifnum\num>99\relax
  \mes{*** Must be between 1 and 99}
\repeat
\def\parsenum#1#2{\if#2\relax\wr{\spsp\spsp x#1,\pc: Maximum of #1\space authors}
  \else\wr{\spsp\spsp x#10,x#2,\pc: Maximum of #1#2\space authors}\fi}
\expandafter\parsenum\num\relax
\mes{\spsp You have selected maximum \num\space authors}
\edef\numx{\num}
\loop
  \ask{\num}{Minimum number (before et al given) (1-\numx)}
  \ifnum\num>\numx
  \mes{*** Must be between 1 and \numx}
\repeat
\def\parsenum#1#2{\if#2\relax\wr{\spsp\spsp m#1,\pc: Minimum of #1\space authors}
  \else\wr{\spsp\spsp m#10,m#2,\pc: Minimum of #1#2\space authors}\fi}
\expandafter\parsenum\num\relax
\mes{\spsp You have selected minimum \num\space authors}
\fi

%    \end{macrocode}
%
% Something that I finally add after being asked many times, is to allow for
% more than one name in the citation before inserting \textsl{et~al.}
% to allow more than 2 authors before truncating
%    \begin{macrocode}
\beginoptiongroup{AUTHORS IN CITATIONS:}{}
\optdef{*}{}{One author et al}{for three or more authors}
\optdef{m}{mcite}{Some other truncation scheme}{}
\getans
\endoptiongroup
\mytempfalse
\if\ans m\mytemptrue\fi
\beginoptiongroup{MAX AUTHORS BEFORE ET AL:
 (if regular cite not selected)}
 {\ifmytemp*\fi}%
\optdef{*}{mct-1}{One et al}{}
\optdef{2}{mct-2}{One, Two et al}{}
\optdef{3}{mct-3}{One, Two, Three et al}{}
\optdef{4}{mct-4}{One, Two, Three, Four et al}{}
\optdef{5}{mct-5}{One, Two, Three, Four, Five et al}{}
\optdef{6}{mct-6}{One, Two, Three, Four, Five, Six et al}{}
\getans
\endoptiongroup
\beginoptiongroup{MAX AUTHORS WITHOUT ET AL:
 (if regular cite not selected)}
 {\ifmytemp*\fi}%
\optdef{*}{mct-x2}{Two authors without truncating}{}
\optdef{3}{mct-x3}{Three authors}{without truncating}
\optdef{4}{mct-x4}{Four authors}{without truncating}
\optdef{5}{mct-x5}{Five authors}{without truncating}
\optdef{6}{mct-x6}{Six authors}{without truncating}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Typeface of names}
% The author names in the list of references normally appear in the current
% typeface. This may be changed to small caps, bold, or italics.
%
% Alternatively, the surnames only can be formatted, with the first names in the
% regular font. One can also specify that the words `and' and `et~al.'\ should be
% in the regular font, or that `et~al.'\ be italic.
%
% Another possibility is that the names be put into a command |\bibnamefont{..}|,
% which must be defined in the \LaTeX\ document. By default, this command does
% not format its argument. There is also a |\bibfnamefont| command for the first
% names, to be user-defined.
%
% Editor names in a collection or in a book will not normally have these
% fonts applied to them; this may be additionally selected.
%
%    \begin{macrocode}
\beginoptiongroup{TYPEFACE FOR AUTHORS IN LIST OF REFERENCES:}{}
\optdef{*}{}{Normal font for author names}{}
\optdef{s}{nmft,nmft-sc}{Small caps authors}{(\string\sc)}
\optdef{i}{nmft,nmft-it}{Italic authors}{(\string\it\space or \string\em)}
\optdef{b}{nmft,nmft-bf}{Bold authors}{(\string\bf)}
\optdef{u}{nmft,nmft-def}{User defined author font}{(\string\bibnamefont)}
\getans
\endoptiongroup
\mytempfalse
\if\ans i\mytemptrue\fi
\if\ans s\mytemptrue\fi
\if\ans b\mytemptrue\fi
\if\ans u\mytemptrue\fi
\beginoptiongroup{FONT FOR FIRST NAMES
 (if non-default font for authors)}
 {\ifmytemp*\fi}%
\optdef{*}{}{First names same font as surnames}{}
\optdef{r}{fnm-rm}{First names in normal font}{}
\optdef{u}{fnm-def}{First names in user defined font}{(\string\bibfnamefont)}
\getans
\beginoptiongroup{EDITOR NAMES IN INCOLLECTION ETC:}{}
\optdef{*}{}{Editors incollection normal font}{}
\optdef{a}{nmfted}{Editors incollection like authors}{font}
\getans
\endoptiongroup

\beginoptiongroup{FONT FOR `AND' IN LIST:}{}
\optdef{*}{}{`And' in author font}{(JONES AND JAMES)}
\optdef{r}{nmand-rm}{`And' in normal font}{(JONES and JAMES)}
\getans
\endoptiongroup
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Names in Citation label}
% This applies to author--year style only. The label is the text written
% by the |\cite| command, and for author--year style, this is something like
% `Daly et al.\ (1990b)'. One may select italics for the authors and for the
% extra label attached to the year. The year always remains plain.
%
% This parallels the font selection for the names in the list of references
% except that there no choice for the first names, since only surnames
% are used in the labels. A user-defined |\citefontname| may also
% be selected, but this \emph{must} be defined by the user since there
% will be no default definition for it.
%
% If a font is selected for the cited authors, then the word `and' may be
% optionally put in the normal font.
%
% It is not possible to select the type of brackets for the year, since
% this is determined by the \LaTeX{} style option that manages the
% author--year citations. This is not standard \LaTeX, so that there are a
% number of private style files for achieving this.
%    \begin{macrocode}
\beginoptiongroup{FONT OF CITATION LABELS IN TEXT
 (if author-year citations)}
 {\ifnumerical\else*\fi}%
\optdef{*}{}{Cited authors plain}{as result of \string\cite\space command}
\optdef{i}{lab,lab-it}{Cited authors italic}{}
\optdef{s}{lab,lab-sc}{Cited authors small caps}{}
\optdef{b}{lab,lab-bf}{Cited authors bold}{}
\optdef{u}{lab,lab-def}{User defined citation font}{(\string\citenamefont)}
\getans

\mytempfalse
\if\ans i\mytemptrue\fi
\if\ans s\mytemptrue\fi
\if\ans b\mytemptrue\fi
\if\ans u\mytemptrue\fi
\beginoptiongroup{FONT FOR `AND' IN CITATIONS
 (if non-default font for citation lables)}
 {\ifmytemp*\fi}%
\optdef{*}{}{Cited `and' in author font}{}
\optdef{r}{and-rm}{Cited `and' in normal font}{}
\getans
\endoptiongroup
\beginoptiongroup{FONT OF EXTRA LABEL
 (The extra letter on the year)}{}
\optdef{*}{}{Extra label plain}{}
\optdef{i}{xlab-it}{Extra label italic}{}
\getans
\endoptiongroup
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Label for missing author names}
%
% If the author and/or editor is missing, the standard \texttt{.bst} files
% use the \texttt{key} field in place of the names for purposes of ordering the
% entries.
%
% For author--year styles, the \texttt{key} field is even inserted in the
% reference list and in the label in place of the authors. Optionally, one can
% suppress the year in this case, which causes \texttt{natbib} (version~7)
% to print only that key text as a code designation for the work. Thus if
% \texttt{KEY = "CS1-345"} and there are no authors, then |\citep| produces
% (CS1-345) and |\citet| simply CS1-345. That is, they behave like
% |\citeauthor|. If \texttt{natbib} did not recognize the blank year, one would
% get (CS1-345, ) and CS1-345 (). (Earlier versions of \texttt{natbib} crash on
% a blank year.)
%    \begin{macrocode}
\beginoptiongroup{LABEL WHEN AUTHORS MISSING
 (if author-year citations)}
 {\ifnumerical\else*\fi}%
\optdef{*}{keyxyr}{Year blank when KEY replaces missing author}{(for natbib 7.0)}
\optdef{y}{}{Year included when KEY replaces missing author}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Missing date}
% A missing date can be set to ???? or simply left blank. In the latter case,
% \texttt{natbib} version~7 will print only the authors without any year
% punctuation or brackets.
%
%    \begin{macrocode}
\beginoptiongroup{MISSING DATE
 (if author-year citations)}
 {\ifnumerical\else*\fi}%
\optdef{*}{}{Missing date set to ????}{in label and text}
\optdef{b}{blkyear}{Missing date left blank}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Position of date}
% This applies to author--year style only. It makes sense to put the date
% immediately after the author list, since the two items (author and year)
% are the identifiers of the reference. Default position is at the
% end of the references, before any notes. It is also possible to place
% it even after the notes.
%
% Medical journals have a system where the date is part of the journal
% specification, as Lancet 1994;45(2):34--40. Otherwise the date appears at
% the end.
%    \begin{macrocode}
\beginoptiongroup{DATE POSITION:}{}
\optdef{*}{}{Date at end}{}
\optdef{b}{dt-beg}{Date after authors}{}
\optdef{j}{dt-jnl}{Date part of journal spec.}{(as 1994;45:34-40) else at end}
\optdef{e}{dt-end}{Date at very end}{after any notes}
\getans
\endoptiongroup
\if\ans b\mytemptrue\else\if\ans j\mytemptrue\else\mytempfalse\fi\fi
%    \end{macrocode}
%
% \subsection*{Format of date}
% The year may be enclosed in parentheses, brackets, or preceded by a
% colon. If none of these are selected, the date (month plus year) appears.
% For author--year, the date normally consists only of the year, no month,
% but this may be overridden.
%
% If the date comes just after the authors, then one might want special
% punctuation following it, like a colon, or space only. The latter is
% probably desirable if the date is brackets or parentheses.
%
% The date can even be put into bold face.
%    \begin{macrocode}
\beginoptiongroup{DATE FORMAT
 (if non author-year citations)}
 {\ifnumerical*\fi}%
\optdef{*}{}{Plain month and year}{without any brackets}
\optdef{p}{yr-par}{Date in parentheses}{as (May 1993)}
\optdef{b}{yr-brk}{Date in brackets}{as [May 1993]}
\optdef{c}{yr-col}{Date preceded by colon}{as `: May 1993'}
\optdef{d}{yr-per}{Date preceded by period}{as `. May 1993'}
\optdef{m}{yr-com}{Date preceded by comma}{as `, May 1993'}
\optdef{s}{yr-blk}{Date preceded by space}{only, as ` May 1993'}
\getans
\beginoptiongroup{SUPPRESS MONTH:}{}
\optdef{*}{}{Date is month and year}{}
\optdef{x}{xmth}{Date is year only}{}
\getans
\endoptiongroup
\beginoptiongroup{REVERSED DATE
 (if including month)}
 {\if\ans x\else*\fi}%
\optdef{*}{}{Date as month year}{}
\optdef{r}{dtrev}{Date as year month}{}
\getans
\endoptiongroup
\endoptiongroup

\beginoptiongroup{DATE FORMAT
 (if author-year citations)}
 {\ifnumerical\else*\fi}%
\optdef{*}{}{Year plain}{without any brackets}
\optdef{p}{yr-par}{Year in parentheses}{as (1993)}
\optdef{b}{yr-brk}{Year in brackets}{as [1993]}
\optdef{c}{yr-col}{Year preceded by colon}{as `: 1993'}
\optdef{d}{yr-per}{Year preceded by period}{as `. 1993'}
\optdef{m}{yr-com}{Date preceded by comma}{as `, 1993'}
\optdef{s}{yr-blk}{Year preceded by space}{only, as ` 1993'}
\getans
\beginoptiongroup{INCLUDE MONTHS:}{}
\optdef{*}{}{Date is year only}{without the month}
\optdef{m}{aymth}{Include month in date}{}
\getans
\endoptiongroup
\beginoptiongroup{REVERSED DATE
 (if including month)}
 {\if\ans m*\fi}%
\optdef{*}{}{Date as month year}{}
\optdef{r}{dtrev}{Date as year month}{}
\getans
\endoptiongroup
\endoptiongroup

\beginoptiongroup{DATE PUNCTUATION
 (if date not at end)}
 {\ifmytemp*\fi}%
\optdef{*}{}{Date with standard block punctuation}{(comma or period)}
\optdef{c}{yrp-col}{Colon after date}{as 1994:}
\optdef{s}{yrp-semi}{Semi-colon after date}{as 1994;}
\optdef{p}{yrp-per}{Period after date}{even when blocks use commas}
\optdef{x}{yrp-x}{No punct. after date}{}
\getans
\beginoptiongroup{BLANK AFTER DATE:}{}
\optdef{*}{}{Space after date}{and punctuation}
\optdef{x}{yrpp-xsp}{No space after date}{as 1994:45}
\getans
\endoptiongroup
\endoptiongroup
\beginoptiongroup{DATE FONT:}{}
\optdef{*}{}{Date in normal font}{}
\optdef{b}{dtbf}{Date in bold face}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% Normally in author--year citations, the \texttt{year} entry is truncated
% to the last 4 characters, which should be the 4 digits of the year. Some
% users have requested the possibility of suppressing this truncation so
% that they may put text in the \texttt{year} field, such as ``in press.''
% Another use for it is when years are given as ``1968--72''. Actually,
% I have no idea why the year should be truncated at all.
%    \begin{macrocode}
\beginoptiongroup{TRUNCATE YEAR
 (if author-year citations)}
 {\ifnumerical\else*\fi}%
\optdef{*}{note-yr}{Year text full}{as 1990--1993 or `in press'}
\optdef{t}{}{Year truncated}{to last 4 digits}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Article title in journal}
% The title of an article in a journal or in a collection (a book, or
% conference proceedings) may appear plain, in italics, within single
% or double quotes or even in guillemets. The last is best with T1 coding; a
% poor man's version for OT1 is provided; \LaTeXe\ is required in both cases.
%
% Furthermore, it may have sentence capitalization (first
% word and word following colon) or be capitalized as in the \texttt{.bib} file
% entry. That is why it is recommended to capitalize the entry text as it
% should appear when fully capitalized, putting words that are always
% capitalized in braces. Example:
% \begin{quote}
% |TITLE="The Results of the {Giotto} Mission"|
% \end{quote}
% which produces either ``The results of the Giotto mission'' or ``The
% Results of the Giotto Mission'', depending on option.
%
% Additionally, the article titles may be fully suppressed.
%    \begin{macrocode}
\beginoptiongroup{TITLE OF ARTICLE:}{}
\optdef{*}{}{Title plain}{with no special font}
\optdef{i}{tit-it}{Title italic}{(\string\em)}
\optdef{q}{tit-qq,qt-s}{Title and punctuation in single quotes}{(`Title,' ..)}
\optdef{d}{tit-qq}{Title and punctuation in double quotes}{(``Title,'' ..)}
\optdef{g}{tit-qq,qt-g}{Title and punctuation in guillemets}{(<<Title,>> ..)}
\optdef{x}{tit-qq,qt-s,qx}{Title in single quotes}{(`Title', ..)}
\optdef{y}{tit-qq,qx}{Title in double quotes}{(``Title'', ..)}
\optdef{z}{tit-qq,qt-g,qx}{Title in guillemets}{(<<Title>>, ..)}
\getans
\endoptiongroup
\mytempfalse
\if\ans q\mytemptrue\fi
\if\ans d\mytemptrue\fi
\if\ans g\mytemptrue\fi
\if\ans x\mytemptrue\fi
\if\ans y\mytemptrue\fi
\if\ans z\mytemptrue\fi
\beginoptiongroup{COLLECTION/PROCEEDINGS TITLES
 (if quoted title)}
 {\ifmytemp*\fi}%
\optdef{*}{bt-qq}{Quote collection and proceedings titles}{too}
\optdef{x}{}{Collection and proceedings titles not in quotes}{}
\getans
\endoptiongroup
\beginoptiongroup{CAPITALIZATION OF ARTICLE TITLE:}{}
\optdef{*}{}{Sentence style}{(capitalize first word and those in braces)}
\optdef{t}{atit-u}{Title style}{(just as in bib entry)}
\getans
\endoptiongroup

\beginoptiongroup{ARTICLE TITLE PRESENT:}{}
\optdef{*}{}{Article title present}{in journals and proceedings}
\optdef{x}{jtit-x}{No article title}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Journal names}
% Abbreviated journal names normally contain periods; the periods may be
% removed with this option. In fact, only letters, numbers, and spacing are
% retained.
%    \begin{macrocode}
\beginoptiongroup{JOURNAL NAMES:}{}
\optdef{*}{}{Periods in journal names}{are retained, as `Phys. Rev.'}
\optdef{x}{jxper}{Dotless journal names}{as `Phys Rev'}
\getans
\endoptiongroup
%    \end{macrocode}
% Journal name is normally printed in italics; can be left in normal font.
%    \begin{macrocode}
\beginoptiongroup{JOURNAL NAME FONT:}{}
\optdef{*}{}{Journal name italics}{}
\optdef{r}{jttl-rm}{Journal name normal}{font}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Title of Theses and Technical Reports}
% The title of a these (PhD or Master's) is normally treated the same
% as that of a book. Optionally, it may be formatted like that of
% an article.
%
% The title of a technical report is normally treated the same as that
% of an article. Optionally, it may be formatted like that of a book.
%
%    \begin{macrocode}
\beginoptiongroup{THESIS TITLE:}{}
\optdef{*}{}{Thesis titles like books}{}
\optdef{a}{thtit-a}{Thesis title like article}{}
\optdef{x}{thtit-x}{No thesis title}{}
\getans
\endoptiongroup

\beginoptiongroup{TECHNICAL REPORT TITLE:}{}
\optdef{*}{}{Tech. report title like articles}{}
\optdef{b}{trtit-b}{Tech. report title like books}{}
\getans
\endoptiongroup

\beginoptiongroup{TECHNICAL REPORT NUMBER:}{}
\optdef{*}{}{Tech. report and number plain}{as `Tech. Rep. 123'}
\optdef{i}{trnum-it}{Tech. report and number italic}%
      {as `{\string\it\space Tech. Rep. 123'}}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Journal reference}
% Great diversity of opinion exists as to how a journal reference is to be
% formatted. It consists of a volume, possibly a number, and page limits.
% The number is really only necessary if the page numbers within one volume
% start at 1 for each physical `number'. Since journals are often bound
% together in one volume later, it makes more sense to number the pages
% continuously through the whole volume.
%
% I am only aware of one journal that used to reset the pagination for each
% `number', in which case the number was part of the page designation.
% I had erroneously provided an option \texttt{vnum-pg} to achieve this, but I
% now realize that instead, for this one journal, the database entries must
% contain \texttt{pages="(2)33--2(55)"}. This option has been removed at
% version 3.84.
%
% A number of styles for journal specifications are
% \begin{quote}
%   \begin{tabular}{l@{\qquad}l}
% 21(2):33--55             & 21, no.\ 2: 33--55\\
% \textbf{21}(2):33--55    & \textbf{21}, \#2, 33--55\\
% \textit{21}(2), 33--55   & \textit{21} (2); 33--55 \\
% 21(2) (1995) 33--55      & 21(1995), 33-55\\
% 21(2) 33--55             & vol.~21 (2), pp.~33--55
%   \end{tabular}
% \end{quote}
%
% Here both start and stop page numbers have been given; often only the
% start page is wanted.
%
% It is also possible to include the year as part of the journal specification,
% in which case the year is always in parentheses, attached snugly or with space
% to the volume, or preceding the pages.
%
%    \begin{macrocode}
\beginoptiongroup{JOURNAL VOLUME:}{}
\optdef{*}{}{Volume plain}{as vol(num)}
\optdef{i}{vol-it}{Volume italic}{as {\string\em\space vol}(num)}
\optdef{b}{vol-bf}{Volume bold}{as {\string\bf\space vol}(num)}
\optdef{d}{vol-2bf}{Volume and number bold}{as {\string\bf\space vol(num)}}
\getans
\endoptiongroup
%    \end{macrocode}
%
% The form of the `number' is also given: in parentheses, with `no.',
% with \#, or omitted. The \texttt{vnum-b} option is meant to be used
% with \texttt{jdt-v} and \texttt{jdt-vs} but could be used alone.
%    \begin{macrocode}
\beginoptiongroup{JOURNAL VOL AND NUMBER:}{}
\optdef{*}{}{Journal vol(num)}{as 34(2)}
\optdef{s}{vnum-sp}{Journal vol (num)}{as 34 (2)}
\optdef{c}{vnum-cm}{Journal vol, num}{as 34, 2}
\optdef{n}{vnum-nr}{Journal vol, no. num}{as 34, no. 2}
\optdef{h}{vnum-h}{Journal vol, \string\# number}{as 34, \string\#2}
\optdef{b}{vnum-b}{Journal vol number}{as 34 2}
\optdef{x}{vnum-x}{Journal vol, without number}{as 34}
\getans
\endoptiongroup

\beginoptiongroup{VOLUME PUNCTUATION:}{}
\optdef{*}{}{Volume with colon}{as vol(num):ppp}
\optdef{s}{volp-sp}{Volume with colon and space}{as vol(num): ppp}
\optdef{h}{volp-semi}{Volume with semi-colon}{as vol(num); ppp}
\optdef{c}{volp-com}{Volume with comma}{as vol(num), ppp}
\optdef{b}{volp-blk}{Volume with blank}{as vol(num) ppp}
\getans
\endoptiongroup

\beginoptiongroup{YEAR IN JOURNAL SPECIFICATION:}{}
\optdef{*}{}{Journal year like others}{as given by date position}
\optdef{v}{jdt-v}{Journal vol(year)}{as 34(1995)}
\optdef{s}{jdt-vs}{Journal vol (year)}{as 34 (1995)}
\optdef{p}{jdt-p}{Year with pages}{as 34(2), (1995) 1345--1387}
\optdef{c}{jdt-pc}{Year, comma, pages}{as 34(2), (1995), 1345--1387}
\getans
\endoptiongroup

\beginoptiongroup{PAGE NUMBERS:}{}
\optdef{*}{}{Start and stop page numbers}{given}
\optdef{f}{jpg-1}{Only start page number}{}
\getans
\endoptiongroup

\beginoptiongroup{LARGE PAGE NUMBERS:}{}
\optdef{*}{}{No separators for large page numbers}{}
\optdef{c}{pgsep-c}{Comma inserted over 9999}{as 11,234}
\optdef{s}{pgsep-s}{Thin space inserted over 9999}{as 11 234}
\optdef{p}{pgsep-p}{Period inserted over 9999}{as 11.234}
\getans
\endoptiongroup

\beginoptiongroup{WORD `PAGE' IN ARTICLES:}{}
\optdef{*}{}{Article pages numbers only}{as 234-256}
\optdef{p}{jwdpg}{Include `page' in articles}{as pp. 234--256}
\getans
\endoptiongroup
%    \end{macrocode}
%
% Some journals want page numbers at the end, even for books, proceedings, as
% well as for journals.
%    \begin{macrocode}
\beginoptiongroup{POSITION OF PAGES:}{}
\optdef{*}{}{Pages given mid text}{as is normal}
\optdef{e}{pp-last}{Pages at end}{but before any notes}
\getans
\endoptiongroup

\beginoptiongroup{WORD `VOLUME' IN ARTICLES:}{}
\optdef{*}{}{Article volume as number only}{as 21}
\optdef{p}{jwdvol}{Include `volume' in articles}{as vol. 21}
\getans
\endoptiongroup
%    \end{macrocode}
%
% Fiddle with the format and location of the number/series for collections and
% inproceedings.
%    \begin{macrocode}
\beginoptiongroup{NUMBER AND SERIES FOR COLLECTIONS:}{}
\optdef{*}{num-xser}{Allows number without series}{and suppresses word "number"}
\optdef{s}{}{Standard BibTeX}{as: "number 123 in Total Works"; error if number and no series}
\getans
\endoptiongroup

\beginoptiongroup{POSITION OF NUMBER AND SERIES:}{}
\optdef{*}{}{After chapter and pages}{as in standard BibTeX}
\optdef{t}{numser}{Just before publisher}{or organization}
\getans
\endoptiongroup
%    \end{macrocode}
%
% Fiddle with the format and location of series and volume with books and collections.
%    \begin{macrocode}
\beginoptiongroup{VOLUME AND SERIES FOR BOOKS/COLLECTIONS:}{}
\optdef{*}{}{Vol. 23 of Series}{as in standard BibTeX}
\optdef{s}{ser-vol}{Series, vol. 23}{}
\getans
\endoptiongroup

\beginoptiongroup{POSITION OF VOLUME AND SERIES FOR INCOLLECTIONS:}{}
\optdef{*}{}{Series and volume after the editors}{}
\optdef{e}{ser-ed}{Series and volume after booktitle}{and before editors}
\getans
\endoptiongroup
%    \end{macrocode}
%
% It is possible to decide whether the journal name should be
% separated from the following specifications with a blank or comma.
%    \begin{macrocode}
\beginoptiongroup{JOURNAL NAME PUNCTUATION:}{}
\optdef{*}{}{Comma after journal}{name}
\optdef{x}{jnm-x}{Space after journal}{name}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Books}
% The title of a book (as opposed to an article in a book or journal) is
% normally italicized. This may be set to the regular font.
%
% The page numbers in books may be set in parentheses, as (pp.\ 345--350).
%    \begin{macrocode}
\beginoptiongroup{BOOK TITLE:}{}
\optdef{*}{}{Book title italic}{(\string\em)}
\optdef{p}{btit-rm,bt-rm}{Book title plain}{(no font command)}
\getans
\endoptiongroup

\beginoptiongroup{PAGES IN BOOKS:}{}
\optdef{*}{}{Pages in book plain}{as pp. 50-55}
\optdef{p}{bkpg-par}{Pages in book in parentheses}{as (pp. 50-55)}
\optdef{x}{bkpg-x}{Pages in book bare}{as 50-55}
\getans
\endoptiongroup
\beginoptiongroup{TOTAL PAGES OF A BOOK:}{}
\optdef{*}{}{Total book pages not printed}{}
\optdef{p}{pg-bk}{For book: 345 pages}{or pp.}
\optdef{a}{pg-bk,pg-pre}{Total book pages before publisher}{}
\getans
\endoptiongroup
%    \end{macrocode}
% Some psychology journals wish to have the publisher's address preceding
% the name, separated by colon, as
% \begin{quote}New York: Wiley and Sons\end{quote}
%
% Some journals (e.g.\ Nature) put publisher in parentheses with date,
% as (Wiley and Sons, New York, 1983). These normally put the date in
% parentheses at the end anyway, so this is a merging of the two sets of
% parentheses.
%    \begin{macrocode}
\beginoptiongroup{PUBLISHER ADDRESS:}{}
\optdef{*}{}{Publisher, address}{as Harcourt, New York}
\optdef{a}{add-pub}{Address: Publisher}{as New York: Harcourt}
\getans
\endoptiongroup

\beginoptiongroup{PUBLISHER IN PARENTHESES:}{}
\optdef{*}{}{Publisher as normal block}{without parentheses}
\optdef{p}{pub-par}{Publisher in parentheses}{}
\optdef{d}{pub-date}{Publisher and date in parentheses}{(Oxford, 1994)}
\optdef{c}{pub-date,pub-xc}{Publisher and date in parentheses, no comma}{(Oxford 1994)}
\optdef{f}{pub-date,pub-xpar}{Publisher and date without parentheses}{Oxford, 1994}
\optdef{k}{pub-date,pub-xpar,pub-xc}{Publisher and date, no parentheses, no comma}{Oxford 1994}
\getans
\endoptiongroup

\beginoptiongroup{PUBLISHER POSITION:}{}
\optdef{*}{}{Publisher after chapter, pages}{}
\optdef{p}{pre-pub}{Publisher before chapter, pages}{}
\optdef{e}{pre-edn}{Publisher after edition}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{ISBN, ISSN, DOI numbers}
% Books normally possess an ISBN number. This may be included as an
% optional entry for \texttt{book}, \texttt{inbook}, \texttt{booklet},
% \texttt{incollection}, \texttt{proceedings}, \texttt{inproceedings}.
% However, it should be suppressed for \texttt{inbook} etc.\ when
% there is a crossref to another book with the ISBN number.
%
% Periodicals contain an ISSN number. Add this to \texttt{article}, or
% course, but also to \texttt{inproceedings} and \texttt{proceedings}, since
% they are sometimes printed in a periodical.
%
% Journal articles that appear online are given a DOI number, something more
% robust than a URL that can change as machines are upgraded.
% The American Geophysical Union (AGU) uses the DOI as part of the
% page number substitution for electronic journals, placing the number
% where the pages would normally appear.
%    \begin{macrocode}
\beginoptiongroup{ISBN NUMBER:}{}
\optdef{*}{isbn}{Include ISBN}{for books, booklets, etc.}
\optdef{x}{}{No ISBN}{}
\getans
\endoptiongroup

\beginoptiongroup{ISSN NUMBER:}{}
\optdef{*}{issn}{Include ISSN}{for periodicals}
\optdef{x}{}{No ISSN}{}
\getans
\endoptiongroup

\beginoptiongroup{DOI NUMBER:}{}
\optdef{*}{doi}{Include DOI}{as "doi: number"}
\optdef{u}{url-doi}{Format DOI as URL //dx.doi.org/doi}{(must give url options!)}
\optdef{a}{agu-doi,doi}{Insert DOI AGU style}{as part of page number}
\optdef{x}{}{No DOI}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Editor of book without author}
%
% This is normally
% \begin{quote}
%  J. K. James, editor
% \end{quote}
% but may also be
% \begin{quote}
%  J. K. James, (editor)\\
%  J. K. James (editor),
% \end{quote}
% Alternatively, the word \textsl{editor} may be capitalized and/or
% abbreviated.
%
%    \begin{macrocode}
\beginoptiongroup{`EDITOR' AFTER NAMES (EDITED BOOKS WITHOUT AUTHORS):}{}
\optdef{*}{}{Word `editor' after name}{}
\optdef{a}{edpar}{`Name (editor),'}{in parentheses, after name, comma after}
\optdef{b}{edpar,bkedcap}{`Name (Editor),'}{as above, editor upper case}
\optdef{c}{edparc}{`Name, (editor)'}{in parentheses, after name, comma between}
\optdef{d}{edparc,bkedcap}{`Name, (Editor)'}{as above, editor upper case}
\optdef{e}{edparxc}{`Name (editor)'}{in parentheses, after name, no commas}
\optdef{f}{edparxc,bkedcap}{`Name (Editor)'}{as above, editor upper case}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Edited by}
% For an article within an edited collection, the normal form is
% \begin{quote}
% In J. K. James, editor, \emph{Title of Collection} \dots
% \end{quote}
% Alternative forms are
% \begin{quote}
% In J. K. James (editor), \emph{Title} \dots\\
% In \emph{Title}, edited by J. K. James \dots\\
% In \emph{Title} (Edited by J. K. James) \dots
% \end{quote}
% If none of the \texttt{edby} variations is used, then the same system is
% used as for edited books, i.e. \texttt{edpar} applies.
%    \begin{macrocode}
\beginoptiongroup{EDITOR IN COLLECTIONS:}{}
\optdef{*}{}{Same as for edited book}{(names before booktitle)}
\optdef{b}{edby}{In booktitle, edited by .. }{(where .. is names)}
\optdef{p}{edby-par}{In booktitle (edited by ..)}{}
\optdef{c}{edby-parc}{In booktitle, (edited by ..)}{}
\optdef{e}{edby,edbyx}{In booktitle, editor ..}{}
\optdef{f}{edby,edbyw}{In booktitle, (editor) ..}{}
\optdef{k}{edby-par,edbyx}{In booktitle (editor..)}{}
\optdef{g}{edby-parc,edbyx}{In booktitle, (editor..)}{}
\optdef{j}{edby,edbyy}{In booktitle, .., editor}{}
\optdef{m}{edby-par,edbyy}{In booktitle (.., editor)}{}
\getans
\endoptiongroup
\mytempfalse
\if\ans p\mytemptrue\fi
\if\ans k\mytemptrue\fi
\if\ans c\mytemptrue\fi
\if\ans f\mytemptrue\fi
\beginoptiongroup{CAPITALIZE `EDITOR' OR `EDITED BY'
 (if editor capitalizable)}
 {\ifmytemp*\fi}%
\optdef{*}{}{`(editor,..)' or `(edited by..)'}{in lower case}
\optdef{c}{edcap}{`(Editor,..)' or `(Edited by..)'}{in upper case}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Block punctuation}
% Blocks are logical sections of the reference specification, such as the
% author block, the journal block, editor block, etc. These are normally
% separated by periods, but alternatively a comma may be used. Another
% choice is to use commas except after titles where a period is given.
%
% \LaTeX\ offers an \texttt{openbib} option, which means that the blocks
% are not only new sentences, but new lines as well. This can only
% function when the default option here is taken, for then the command
% |\newblock| is placed between the blocks. This command is normally
% defined to do nothing, but \LaTeX\ redefines it to issue a new line
% when open bibliographies are wanted.
%    \begin{macrocode}
\beginoptiongroup{PUNCTUATION BETWEEN SECTIONS (BLOCKS):}{}
\optdef{*}{}{\string\newblock\space after blocks}
   {(periods or new lines with openbib option)}
\optdef{c}{blk-com}{Comma between blocks}{}
\optdef{s}{blk-com,com-semi}{Semi-colon between blocks}{}
\optdef{b}{blk-com,com-blank}{Blanks between blocks}{}
\optdef{t}{blk-tit}{Period after titles of articles, books, etc}{else commas}
\optdef{u}{blk-tit,tit-col}{Colon after titles of articles, books, etc}{else commas}
\optdef{a}{blk-tita}{Period after titles of articles}{else commas}
\optdef{d}{blk-tita,tit-col}{Colon after titles of articles}{else commas}
\getans
\endoptiongroup
\mytempfalse
\if\ans c\mytemptrue\fi
\if\ans s\mytemptrue\fi
\if\ans b\mytemptrue\fi
\if\ans t\mytemptrue\fi
\if\ans a\mytemptrue\fi
\beginoptiongroup{PUNCTUATION BEFORE NOTES
 (if not using \string\newblock)}
 {\ifmytemp*\fi}%
\optdef{*}{}{Notes have regular punctuation}{like all other blocks}
\optdef{p}{blknt}{Notes preceded by period}{}
\getans
\endoptiongroup
\beginoptiongroup{PUNCTUATION AFTER AUTHORS:}{}
\optdef{*}{}{Author block normal}{with regular block punctuation}
\optdef{c}{au-col}{Author block with colon}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{\textsl{In} with colon}
% When referring to works in a collection, one begins the block describing
% that collection with \textsl{In}. Optionally, one may add a colon.
%    \begin{macrocode}
\beginoptiongroup{PUNCTUATION AFTER `IN':}{}
\optdef{*}{}{Space after `in'}{for incollection or inproceedings}
\optdef{c}{in-col}{Colon after `in'}{(as `In: ...')}
\optdef{i}{in-it}{Italic `in'}{and space}
\optdef{d}{in-col,in-it}{Italic `in' and colon}{}
\optdef{x}{in-x}{No word `in'}{for edited works}
\getans
\endoptiongroup
\beginoptiongroup{`IN' WITH JOURNAL NAMES
 (if using 'in' with collections)}
 {\if\ans x\else*\fi}
\optdef{*}{}{No `in' before journal name}{}
\optdef{i}{injnl}{Add `in' before journal name}{in style for incollection}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Final punctuation}
% The punctuation at the end of the reference is normally a period. This
% may be suppressed.
%    \begin{macrocode}
\beginoptiongroup{FINAL PUNCTUATION:}{}
\optdef{*}{}{Period at very end}{of the listed reference}
\optdef{x}{fin-bare}{No period at end}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Abbreviations}
% A number of words may be abbreviated: pages, editors, volume, chapter,
% and so on. The first two may be independently set to abbreviation, the
% rest with a single option.
%
% Additionally, the edition numbers may be
% output as words (first, second, etc.) or as numbers (1st, 2nd, etc.).
% (Recall that the input in the \texttt{.bib} file is always as English
% words.)
%    \begin{macrocode}
\beginoptiongroup{ABBREVIATE WORD `PAGES'
 (if not using external language file)}
 {\if!\cfile!\relax*\fi}%
\optdef{*}{}{`Page(s)'}{(no abbreviation)}
\optdef{a}{pp}{`Page' abbreviated}{as p. or pp.}
\optdef{x}{ppx}{`Page' omitted}{}
\getans
\beginoptiongroup{ABBREVIATE WORD `EDITORS':}{}
\optdef{*}{}{`Editor(s)'}{(no abbreviation)}
\optdef{a}{ed}{`Editor' abbreviated}{as ed. or eds.}
\getans
\endoptiongroup

\beginoptiongroup{OTHER ABBREVIATIONS:}{}
\optdef{*}{}{No abbreviations}{of volume, edition, chapter, etc}
\optdef{a}{abr}{Abbreviations}{of such words}
\getans
\endoptiongroup
\beginoptiongroup{ABBREVIATION FOR `EDITION'
 (if abbreviating words)}
 {\if\ans a*\fi}%
\optdef{*}{}{`Edition' abbreviated as `edn'}{}
\optdef{a}{ednx}{`Edition' abbreviated as `ed'}{}
\getans
\beginoptiongroup{MONTHS WITH DOTS:}{}
\optdef{*}{}{Months with dots}{as Jan.}
\optdef{x}{mth-bare}{Months without dots}{as Feb Mar}
\getans
\endoptiongroup
\endoptiongroup
\beginoptiongroup{EDITION NUMBERS:}{}
\optdef{*}{xedn}{Editions as in database}{saving much processing memory}
\optdef{w}{}{Write out editions}{as first, second, third, etc}
\optdef{n}{ord}{Numerical editions}{as 1st, 2nd, 3rd, etc}
\getans
\endoptiongroup
\endoptiongroup
%    \end{macrocode}
%
% The above choices about abbreviations are made only if the internal
% languages are taken (English or \texttt{babel}). For an external language
% definition file, these choices, along with possible other ones, are made
% in the external file, which is read in at this point.
%    \begin{macrocode}
\umes{Reading external language file \string\cfile=\cfile}%
\if!\cfile!\relax\else
 \input\cfile
\fi
%    \end{macrocode}
%
% This file contains the standard set of stored journal names present in
% the basic bibliography style files. If other files containing journal
% names are to be included, they may only contain the options \texttt{jabr}
% or \texttt{jaa} since these options are selected here. No option
% menus from the journal-name files will be read in.
%    \begin{macrocode}
\beginoptiongroup{STORED JOURNAL NAMES:}{}
\optdef{*}{}{Full journal names}{for prestored journals}
\optdef{a}{jabr}{Abbreviated journal names}{}
\optdef{s}{jabr,jaa}{Abbreviated with astronomy shorthands}{like ApJ and AJ}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Variations on \textsl{and}}
% It is possible to replace the word \textsl{and} with an ampersand \&, and to
% specify whether a comma is to precede \textsl{and} in a list of more than two
% names.
%
% A variable \textsl{and} may be provided for with the command |\BIBand|
% in place of the word. In this case, the command must be defined in the
% document file or some other package called. (This is intended for situations
% where an ampersand is wanted in parenthetical citations, but the word in
% textual ones.)
%
%    \begin{macrocode}
\beginoptiongroup{AMPERSAND:}{}
\optdef{*}{}{Use word `and'}{in author lists}
\optdef{a}{amper}{Use ampersand}{in place of `and'}
\optdef{v}{varand}{Use \string\BIBand}{in place of `and'}
\getans
\endoptiongroup

\beginoptiongroup{COMMA BEFORE `AND':}{}
\optdef{*}{}{Comma before `and'}{as `Tom, Dick, and Harry'}
\optdef{n}{and-xcom}{No comma before `and'}{as `Tom, Dick and Harry'}
\optdef{c}{and-com}{Comma even with 2 authors}{as `Tom, and Harry'}
\getans
\endoptiongroup
\beginoptiongroup{COMMA BEFORE `AND' EVEN FOR COLLECTION EDITORS
 (if using comma before `and' with authors)}
 {\if\ans c*\fi}%
\optdef{*}{and-com-ed}{Comma with 2 editors}{in collections}
\optdef{x}{}{Two editors without comma}{as `Tom and Harry'}
\getans
\endoptiongroup
\beginoptiongroup{NO `AND' IN REFERENCE LIST:}{}
\optdef{*}{}{With `and'}{before last author in reference list}
\optdef{x}{xand}{No `and'}{as `Tom, Dick, Harry'}
\getans
\endoptiongroup

\beginoptiongroup{COMMA BEFORE `ET AL':}{}
\optdef{*}{}{Comma before `et al'}{in reference list}
\optdef{x}{etal-xc}{No comma before `et al'}{}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Font of \textsl{et al}}
% One can chose that \textsl{et~al.}\ be put into italics.
% Or, if the authors are in a different font from the regular one, the
% \textsl{et~al.}\ can still be Roman.
%    \begin{macrocode}
\beginoptiongroup{FONT OF `ET AL':}{}
\optdef{*}{}{Plain et al}{}
\optdef{i}{etal-it}{Italic et al}{}
\optdef{r}{etal-rm}{Roman et al}{even when authors something else}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Additional Data Fields}\label{sec:revtex}
% \changes{3.89d1}{1999 July 20}{AO: add the revdata option group}
% The American Physical Society's REV\TeX\ package contains \btx\ support
% with a \texttt{bst} file generated from a variant of
% \texttt{\filename}. The extra fields are also available here.
% \begin{itemize}
% \item \textbf{collaboration}: A collaboration name associated with a
% reference.
% \item \textbf{eprint}: The e-print citation for the reference (Los Alamos
% or otherwise). E-print numbers can be turned into hyperlinks to the
% online article. The output is\\
%    \hspace*{2em}|\eprint{|\textit{eprint-spec}|}|
% \item \textbf{archive}: is an optional argument for |\eprint|, as\\
%    \hspace*{2em}|\eprint[|\textit{archive-des}|]{|\textit{eprint-spec}|}|\\
% The \textit{archive-des} is some code such as \texttt{arXiv} that is
% translated to a base URL by a class or package file. The default definition
% of |\eprint| ignores \textit{archive-des} and prints \textit{eprint-spec}
% as a URL.
% \item \textbf{url}: A URL associated with the reference. Can be turned
% into a hyperlink.
% \end{itemize}
%
% A collaboration appears as part of the author list and the other two
% appear at the end of the citaton. The URL field can be selected
% independently of this option.
%
% In addition there are new fields for journals like Phys.\ Rev.~D that
% no longer use page numbers.
% \begin{itemize}
% \item \textbf{eid}: Electronic article identifier.
% \item \textbf{numpages}: Number of pages in an article. For use in
% conjunction with the \textbf{eid} field when page counts are
% desired. Deprecated when submitting to Phys.\ Rev.
%
% The \texttt{eprint} (with \texttt{archive}) and \texttt{url} fields may be
% included independently of the other REV\TeX\ fields.
%
% The \texttt{eid} field is now always included, although it is optional for
% the bibliography entries. This electronic identifier is a replacement for the
% page number in electronic journals: it is the sequence number in the printed
% volume. If present, it will be used in place of the page number.
%
% \end{itemize}
%
%    \begin{macrocode}
\beginoptiongroup{ADDITIONAL REVTeX DATA FIELDS:}{}
\optdef{*}{}{No additional fields}{for REVTeX}
\optdef{r}{revdata,eprint,url,url-blk}{Include REVTeX data fields}
 {collaboration, eid, eprint, archive, numpages, url}
\getans
\mytemptrue
\if\ans r\mytempfalse\fi
\beginoptiongroup{E-PRINT DATA FIELD:
(without REVTeX fields)}
{\ifmytemp*\fi}
\optdef{*}{}{Do not include eprint field}{}
\optdef{e}{eprint}{Include eprint and archive fields}{for electronic publications}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{URL address}
% For electronic documents with an Internet address, add a URL entry.
% Harvard already has this, but here it is done for all styles.
% The URL text will be set with the \verb!\url! command in the \texttt{url}
% package by Donald Arseneau. This package must be loaded for the command
% to work right. It allows line breaks at punctuations. Otherwise,
% \verb!\texttt! is used instead, with no line breaks. The URL text is preceded
% by \verb!\urlprefix! which defaults to ``URL '' but may be redefined by the
% user to be whatever s/he wants. The final space must be included.
%
% Note: selecting the REV\TeX\ fields automatically includes this, so the
% offer only is made if REV\TeX\ has been rejected.
%
%    \begin{macrocode}
\beginoptiongroup{URL ADDRESS:
(without REVTeX fields)}{\ifmytemp*\fi}
\optdef{*}{}{No URL}{for electronic (Internet) documents}
\optdef{u}{url,url-blk}{Include URL}{as regular item block}
\optdef{n}{url,url-nt}{URL as note}{}
\optdef{l}{url,url-nl}{URL on new line}{after rest of reference}
\getans
\endoptiongroup
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Reference Component Tagging}
% \changes{3.89d1}{1999 July 20}{AO: add the bibinfo option group}
% If reference component tagging is enabled, we
% apply tags like |\bibinfo| and |\eprint| to the fields of data
% in the content of the |\bibitem| statement. We also ensure that
% these commands have a default meaning within the scope of the |thebibliography|
% environment. The default definitions simply print the field and ignore the
% tag. However, other programs or packages might make use of the tag
% information to separate authors from title, for example.
%
%    \begin{macrocode}
\beginoptiongroup{REFERENCE COMPONENT TAGS:}{}
\optdef{*}{}{No reference component tags}
 {in the \string\bibitem\space entries}
\optdef{b}{bibinfo}{Reference component tags}
 {like \string\bibinfo\space in the content of \string\bibitem}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Define emphasis}
% In everything that been mentioned so far, italicization should be
% understood to mean `emphasize' in the \LaTeX{} sense. This means that the
% command |\em| is used. This is not the same as |\it|, which is always
% italics. Rather, with |\em|, the font style switches between |\rm| and
% |\it| depending on the context. Here one may choose to true italics, or
% to switch off italics altogether.
%    \begin{macrocode}
\beginoptiongroup{EMPHASIS:
 (affects all so-called italics)}{}
\optdef{*}{}{Use emphasis}{ie, \string\em, allows font switching}
\optdef{i}{em-it}{Use true italics}{ie, \string\it, absolute italics}
\optdef{x}{em-x}{No italics}{at all}
\optdef{u}{em-ul}{Underlining}{in place of italics, best with ulem package}
\getans
\endoptiongroup
%    \end{macrocode}
%
% \subsection*{Plain \TeX\ compatibility}
% Bold face, italics, and emphasis are made with the \LaTeXe\ commands,
% which makes them incompatible with the obsolete \LaTeX2.09, and with
% Plain \TeX. There are also some extra testing for existing commands
% that best work with \LaTeXe\ syntax.
%
% If the bibliography style file is to be fully compatible with Plain \TeX,
% do not select the option \texttt{nfss} but do take \texttt{plntx}.
%    \begin{macrocode}
\beginoptiongroup{COMPATIBILITY WITH PLAIN TEX:}{}
\optdef{*}{nfss}{Use LaTeX commands}{which may not work with Plain TeX}
\optdef{t}{plntx}{Use only Plain TeX}{commands for fonts and testing}
\getans
\endoptiongroup
%    \end{macrocode}
%
% Terminate the options list. If a language definition file has been called,
% then we have a closing brace too many, so add another dummy opening brace.
%    \begin{macrocode}
\if!\cfile\jfile!\else
\begingroup\MBswitch
\wr(,{\pc)
\endgroup
\fi

\endoptions
%</options>
%    \end{macrocode}
% \StopEventually{\PrintChanges}
%
% \section{The Bibliographic Coding}
%
%    \begin{macrocode}
%<*!options&!driver&!bblbst>
%<*!tail>
 %   For use with BibTeX version 0.99a or later
 %-------------------------------------------------------------------
%<*(!nmft&(nmft-it|nmft-sc|nmft-bf|nmft-def))|(!lab&(lab-it|lab-bf|lab-sc|lab-def))>
 %  WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
 %  The input dbj file contains one of the options
%<nmft-it|nmft-sc|nmft-bf|nmft-def> %        nmft-it, nmft-bf, nmft-sc, or nmft-def
%<lab-it|lab-sc|lab-bf|lab-def> %        lab-it, lab-bf, lab-sc, or lab-def
 %  without the corresponding general option(s):
%<nmft-it|nmft-sc|nmft-bf|nmft-def> %              nmft
%<lab-it|lab-sc|lab-bf|lab-def> %              lab
 %  (You may be using an older dbj with a newer version of merlin.mbs)
 %  Please edit your dbj file to add the general option(s) and reprocess.
 %
%</(!nmft&(nmft-it|nmft-sc|nmft-bf|nmft-def))|(!lab&(lab-it|lab-bf|lab-sc|lab-def))>
%<*!exlang>
%<!babel> % This bibliography style file is intended for texts in ENGLISH
%<*babel>
 % This bibliography style file requires a file named  babelbst.tex
 %   containing the definitions of word commands like \bbleditor, etc.
%</babel>
%</!exlang>
%<*exlang>
 % This bibliography style file is intended for texts in
%<bahasa> %   BAHASA
%<brazilian> %   BRAZILIAN
%<catalan> %   CATALAN
%<croatian> %   CROATIAN
%<czech> %   CZECH
%<danish> %   DANISH
%<dansk> %   DANSK
%<dutch> %   DUTCH
%<english> %   ENGLISH
%<esperanto> %   ESPERANTO
%<finnish> %   FINNISH
%<french> %   FRENCH
%<galacian> %   GALACIAN
%<german> %   GERMAN
%<hungarian> %   HUNGARIAN
%<italian> %   ITALIAN
%<norwegian> %   NORWEGIAN
%<norsk> %   NORWEGIAN
%<polski> %   POLISH
%<polish> %   POLISH
%<portuguese> %   PORTUGUESE
%<romanian> %   ROMANIAN
%<russian> %   RUSSIAN
%<slovak> %   SLOVAK
%<slovenian> %   SLOVENIAN
%<slovene> %   SLOVENIAN
%<spanish> %   SPANISH
%<swedish> %   SWEDISH
%<turkish> %   TURKISH
%</exlang>
%<*!html>
%<*ay>
 % This is an author-year citation style bibliography. As such, it is
 % non-standard LaTeX, and requires a special package file to function properly.
 % Such a package is    natbib.sty   by Patrick W. Daly
%<*alk>
 % or:                  apalike.sty  by Oren Patashnik
 % The form of the \bibitem entries is
 %   \bibitem[Jones et al., 1990]{key}...
%</alk>
%<*!(har|ast|alk|cay|nmd|cn)>
 % The form of the \bibitem entries is
 %   \bibitem[Jones et al.(1990)]{key}...
%<nat> %   \bibitem[Jones et al.(1990)Jones, Baker, and Smith]{key}...
 % The essential feature is that the label (the part in brackets) consists
 % of the author names, as they should appear in the citation, with the year
 % in parentheses following. There must be no space before the opening
 % parenthesis!
%<nat> % With natbib v5.3, a full list of authors may also follow the year.
 % In natbib.sty, it is possible to define the type of enclosures that is
 % really wanted (brackets or parentheses), but in either case, there must
 % be parentheses in the label.
 % The \cite command functions as follows:
 %   \citet{key} ==>>                Jones et al. (1990)
%<nat> %   \citet*{key} ==>>               Jones, Baker, and Smith (1990)
 %   \citep{key} ==>>                (Jones et al., 1990)
%<nat> %   \citep*{key} ==>>               (Jones, Baker, and Smith, 1990)
 %   \citep[chap. 2]{key} ==>>       (Jones et al., 1990, chap. 2)
 %   \citep[e.g.][]{key} ==>>        (e.g. Jones et al., 1990)
 %   \citep[e.g.][p. 32]{key} ==>>   (e.g. Jones et al., 1990, p. 32)
 %   \citeauthor{key} ==>>           Jones et al.
%<nat> %   \citeauthor*{key} ==>>          Jones, Baker, and Smith
 %   \citeyear{key} ==>>             1990
%</!(har|ast|alk|cay|nmd|cn)>
%<*har>
 % or:                  harvard.sty  by Peter Williams and Thorsten Schnier
%<harnm> % (needs natbib v5.3  or  harvard v2.0.3)
 % The form of the bibitem entries is
 %   \harvarditem[Jones et al.]{Jones, Baker, and Smith}{1990}{key}...
%</har>
%<*cay>
 % or:                  chicago.sty
 % The form of the bibitem entries is
 %   \bibitem[\protect\citeauthoryear{Jones, Baker, and Smith}
 %        {Jones et al.}{1990}{key}...
%</cay>
%<*nmd>
 % or:                  named.sty
 % The form of the bibitem entries is
 %   \bibitem[\protect\citeauthoryear{Jones et al.}{1990}]{key}...
%</nmd>
%<*ast>
 % or:                  astron.sty
 % The form of the bibitem entries is
 %   \bibitem[\protect\astroncite{Jones et al.}{1990}]{key}...
%</ast>
%<*cn>
 % or:                  authordate1-4.sty
 % The form of the bibitem entries is
 %   \bibitem[\protect\citename{Jones et al.}1990]{key}...
%</cn>
%</ay>
%<*!ay>
%<*!alph&!cite>
 % This is a numerical citation style, and as such is standard LaTeX.
%</!alph&!cite>
%<*alph>
 % This is a labelled citation style similar to the standard alpha.bst,
 %   where labels are of the form Dal90 or DBK89.
%</alph>
%<*cite&!alph>
 % This is a special pseudo-numerical bibliography style, intended to be
 %   used to list all the entries in a bib database
%</cite&!alph>
 % It requires no extra package to interface to the main text.
 % The form of the \bibitem entries is
%<!alph&!cite> %   \bibitem{key}...
%<alph> %   \bibitem[label]{key}...
%<!alph&cite> %   \bibitem[key]{key}...
%<*!cite|alph>
 % Usage of \cite is as follows:
%<*!alph&!cite>
 %   \cite{key} ==>>          [#]
 %   \cite[chap. 2]{key} ==>> [#, chap. 2]
 % where # is a number determined by the ordering in the reference list.
%</!alph&!cite>
%<*alph>
 %   \cite{key} ==>>          [label]
 %   \cite[chap. 2]{key} ==>> [label, chap. 2]
 % The order in the reference list is by label.
%</alph>
%<*seq-no&!alph>
 % The order in the reference list is that by which the works were originally
 %   cited in the text, or that in the database.
%</seq-no&!alph>
%<*!seq-no&!alph>
 % The order in the reference list is alphabetical by authors.
%</!seq-no&!alph>
%</!cite|alph>
%</!ay>
%</!html>
%<*html>
 % This bibliographic style file produces HTML output instead of LaTeX.
 % The LaTeX special characters are not translated, so that the output
 % (which has the .bbl ending still) will have to be further massaged,
 % and renamed with .html or .htm. The title and heading may also need
 % to be revised.
 %
%<htlist&!htdes> % The output is a numbered list.
%<htdes> % The output is an unnumbered list with the keys printed
%<htdes> % before each entry.
%<!htlist&!htdes> % The output is lists each entry as one paragraph.
%</html>
 %---------------------------------------------------------------------

%    \end{macrocode}
%
% \begin{macro}{`ENTRY'}
% \changes{1.5(2.3)}{1994 Sep 16}{Add URL entry type for \texttt{harnm} option}
%  The new \texttt{harvard.sty} of \LaTeXe{} includes an entry URL, or
%  rather it is included in the new \texttt{.bst} files for it. Add it
%  here too, but only for option \texttt{harnm}.
%
% \changes{3.0}{1995 Mar 1}{Add optional entries \texttt{isbn}}
% Books normally have an ISBN number.
% This entry is (optionally) included, modelled after that in
% \texttt{xbtxbst.doc}.
% \changes{3.89d1}{1999 July 20}{AO: add the \texttt{revdata} data}
%
%    \begin{macrocode}
ENTRY
  { address
%<annote>    annote
%<eprint>    archive
    author
    booktitle
    chapter
%<revdata>    collaboration
%<doi|url-doi>    doi
    edition
    editor
    eid
%<eprint>    eprint
    howpublished
    institution
%<isbn>    isbn
%<issn>    issn
    journal
    key
%<lang>    language
    month
    note
    number
%<revdata>    numpages
    organization
    pages
    publisher
    school
    series
    title
    type
%<url|harnm|revdata>    url
    volume
    year
  }
  {}
%<!ay&!alph>  { label }
%<!ay&alph>  { label extra.label sort.label }
%<ay>  { label extra.label sort.label short.list }
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
INTEGERS { output.state before.all mid.sentence after.sentence after.block }
%    \end{macrocode}
%
% \begin{macro}{`init.state.consts'}
%    \begin{macrocode}
FUNCTION {init.state.consts}
{ #0 'before.all :=
  #1 'mid.sentence :=
  #2 'after.sentence :=
  #3 'after.block :=
}
%    \end{macrocode}
% \end{macro}
%
% |s| and |t| are general-purpose scratch registers whose value does not persist
% past the end of a function. They also do not appear to be used to communicate
% between functions or to be clobbered within a sub-function call. Hopefully.
%    \begin{macrocode}
STRINGS { s t}
%    \end{macrocode}
%
% \begin{macro}{`output.nonnull'}
%    \begin{macrocode}
FUNCTION {output.nonnull}
{ 's :=
  output.state mid.sentence =
%<!blk-com|(!com-semi&!com-blank)>    { ", " * write$ }
%<blk-com&com-semi>    { "; " * write$ }
%<blk-com&!com-semi&com-blank>    { " " * write$ }
    { output.state after.block =
        { add.period$ write$
          newline$
%<!html>          "\newblock " write$
        }
        { output.state before.all =
            'write$
            { add.period$ " " * write$ }
          if$
        }
      if$
      mid.sentence 'output.state :=
    }
  if$
  s
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`output'}
%    \begin{macrocode}
FUNCTION {output}
{ duplicate$ empty$
    'pop$
    'output.nonnull
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`output.check'}
%    \begin{macrocode}
FUNCTION {output.check}
{ 't :=
  duplicate$ empty$
    { pop$ "empty " t * " in " * cite$ * warning$ }
    'output.nonnull
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`fin.entry'}
% \changes{3.87}{1998 Jul 23}{Add annotation}
% \changes{3.89d1}{1999 July 20}{AO: make ``babel compatible''}
% I have often been asked to add an annotation function. This suggestion is
% from Soren Dayton; it inputs a file with the same name as the cite key, or
% uses the text in the \texttt{annote} field. It will only work with \LaTeXe.
%    \begin{macrocode}
FUNCTION {fin.entry}
%<*!fin-bare>
{ add.period$
  write$
%</!fin-bare>
%<*fin-bare>
{ duplicate$ empty$
    'pop$
    'write$
  if$
%</fin-bare>
%<html&htdes>  "</dd>" write$
%<html&!htdes&htlist>  "</li>" write$
%<html&!htdes&!htlist>  "</p>" write$
  newline$
%<*annote>
%<*!html>
  annote missing$
    { "\bibAnnoteFile{" cite$ * "}" * write$ newline$ }
    { "\bibAnnote{" cite$ * "}{" * annote * "}" * write$ newline$
    }
  if$
%</!html>
%<*html>
  "<blockquote><strong>Key:</strong> "
  cite$ * write$
  annote missing$
    { newline$ }
    { "<br><strong>Annotation:</strong>" write$ newline$
      annote write$ newline$
    }
  if$
  "</blockquote>" write$ newline$
%</html>
%</annote>
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`new.block'}
%    \begin{macrocode}
FUNCTION {new.block}
{ output.state before.all =
    'skip$
    { after.block 'output.state := }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`new.sentence'}
%    \begin{macrocode}
FUNCTION {new.sentence}
{ output.state after.block =
    'skip$
    { output.state before.all =
        'skip$
        { after.sentence 'output.state := }
      if$
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`add.blank'}
% \changes{1.5(2.3)b}{1995 Jan 10}{Add function}
% When text is printed with \texttt{output} or
% \texttt{output.check}, the \texttt{output.state} is set such that
% a comma will precede the next output text. For special effects, we want to
% suppress this comma, inserting a blank instead. Hence the
% \texttt{output.state} is changed to \texttt{before.all}, meaning no
% punctuation is to be inserted.
%    \begin{macrocode}
FUNCTION {add.blank}
{  " " * before.all 'output.state :=
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`add.colon'}
% \changes{3.4}{1995 Sep 28}{Add macro}
% \changes{3.83}{1997 Feb 5}{Simplify: just tack on colon}
%    \begin{macrocode}
%<*au-col|tit-col>
FUNCTION {add.colon}
{ duplicate$ empty$
    'skip$
    { ":" * add.blank }
  if$
}

%</au-col|tit-col>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`no.blank.or.punct'}
% \changes{3.2}{1995 May 19}{Add function}
% \changes{3.2}{1995 May 30}{Present only for option \texttt{yrpp-xsp}}
% Another frill is to suppresss both blanks and punctuation. The |\hspace|
% permits a line break at this point.
%    \begin{macrocode}
%<*yrpp-xsp>
FUNCTION {no.blank.or.punct}
%<*!html>
{  "\hspace{0pt}" * before.all 'output.state :=
}
%</!html>
%<html>{  before.all 'output.state := }

%</yrpp-xsp>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`date.block'}
% \changes{3.0}{1995 Mar 9}{Add function}
% \changes{3.81}{1996 Jun 25}{Add option \texttt{yrp-per}}
% The \texttt{date.block} function is used for special punctuating effects
% after the date.
%    \begin{macrocode}
FUNCTION {date.block}
{
%<*!yrp-x>
%<yrp-col>  ":" *
%<*!yrp-col>
%<yrp-semi>  ";" *
%<*!yrp-semi>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&!yrp-per>  skip$
%<(blk-com|blk-tit|blk-tita)&yrp-per>  new.sentence
%</!yrp-semi>
%</!yrp-col>
%</!yrp-x>
%<*yrp-x|yrp-col|yrp-semi>
%<!yrpp-xsp>  add.blank
%<yrpp-xsp>  no.blank.or.punct
%</yrp-x|yrp-col|yrp-semi>
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`not'}
%    \begin{macrocode}
FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`and'}
%    \begin{macrocode}
FUNCTION {and}
{   'skip$
    { pop$ #0 }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`or'}
%    \begin{macrocode}
FUNCTION {or}
{   { pop$ #1 }
    'skip$
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`non.stop'}
% \changes{1.4(2.2)a}{1994 Sep 8}{Add to test if last character
%   is punctuation: . ! ?}
% This function (my invention) tests if the last character in the string
% on the stack is \texttt{. ! ?} by using \texttt{add.period\$}. It is to
% be used for conditional italic correction or adding commas.
%    \begin{macrocode}
%<*!tit-it&tit-qq>
FUNCTION {non.stop}
{ duplicate$
   "}" * add.period$
   #-1 #1 substring$ "." =
}

%</!tit-it&tit-qq>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`remove.dots'}
% \changes{4.00}{1999 Oct 8}{Add macro}
% \changes{4.21}{2007 May 2}{Retain dot accent}
% \changes{4.33}{2011 May 13}{Add string declaration for \texttt{z}}
% This macro removes any periods from the string on the stack. To be used
% for undotting journal names, months, and juniors. Previously
% \texttt{purify\$} was used for this, but that removes more than just
% dots.
%
% May 2007, Joseph A. Wright (Morning Star, UK) contributed a revision to allow
% the dot accent |\.| to be retained.
%    \begin{macrocode}
%<*nm-rv|nm-rvx|nm-rvcx|mth-bare|jxper>
STRINGS {z}

FUNCTION {remove.dots}
{ 'z :=
   ""
   { z empty$ not }
   { z #1 #2 substring$
     duplicate$ "\." =
       { z #3 global.max$ substring$ 'z :=  * }
       { pop$
         z #1 #1 substring$
         z #2 global.max$ substring$ 'z :=
         duplicate$ "." = 'pop$
           { * }
         if$
       }
     if$
   }
   while$
}
%</nm-rv|nm-rvx|nm-rvcx|mth-bare|jxper>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`new.block.checka'}
%    \begin{macrocode}
%<*!ay>
FUNCTION {new.block.checka}
{ empty$
    'skip$
    'new.block
  if$
}
%</!ay>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`new.block.checkb'}
%    \begin{macrocode}
FUNCTION {new.block.checkb}
{ empty$
  swap$ empty$
  and
    'skip$
    'new.block
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`new.sentence.checka'}
%    \begin{macrocode}
%<*!ay>
FUNCTION {new.sentence.checka}
{ empty$
    'skip$
    'new.sentence
  if$
}
%</!ay>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`new.sentence.checkb'}
%    \begin{macrocode}
%<*!ay>
FUNCTION {new.sentence.checkb}
{ empty$
  swap$ empty$
  and
    'skip$
    'new.sentence
  if$
}
%</!ay>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`field.or.null'}
%    \begin{macrocode}
FUNCTION {field.or.null}
{ duplicate$ empty$
    { pop$ "" }
    'skip$
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`emphasize'}
% Emphasis can be either italic or the alternating font. The font command
% may be NFSS or regular \LaTeX~2.09 declarations.
%\changes{1.3(2.1)}{1994 Jul 1}{Add \texttt{nfss} option}
%\changes{3.84}{1997 Oct 20}{Add \texttt{em-ul} option}
%    \begin{macrocode}
FUNCTION {emphasize}
%<*!em-x>
{ duplicate$ empty$
    { pop$ "" }
%<html>    { "<i>" swap$ * "</i>" * }
%<*!html>
%<em-ul>    { "\uline{" swap$ * "}" * }
%<*!em-ul>
%<*!nfss>
%<!em-it>    { "{\em " swap$ * "\/}" * }
%<em-it>    { "{\it " swap$ * "\/}" * }
%</!nfss>
%<*nfss>
%<!em-it>    { "\emph{" swap$ * "}" * }
%<em-it>    { "\textit{" swap$ * "}" * }
%</nfss>
%</!em-ul>
%</!html>
  if$
}
%</!em-x>
%<em-x>{ skip$ }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`bolden'}
% The bold font command may be NFSS or the regular \LaTeX~2.09 declaration.
%\changes{1.3(2.1)}{1994 Jul 1}{Add \texttt{nfss} option}
%    \begin{macrocode}
%<*nmft-bf|vol-bf|vol-2bf|lab-bf|dtbf|pres-bf>
FUNCTION {bolden}
{ duplicate$ empty$
    { pop$ "" }
%<html>    { "<b>" swap$ * "</b>" * }
%<*!html>
%<!nfss>    { "{\bf " swap$ * "}" * }
%<nfss>    { "\textbf{" swap$ * "}" * }
%</!html>
  if$
}
%</nmft-bf|vol-bf|vol-2bf|lab-bf|dtbf|pres-bf>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`scaps'}
% To put text into small caps.
%\changes{3.0}{1995 Mar 3}{Add function}
%    \begin{macrocode}
%<*lab-sc|nmft-sc|pres-sc>
FUNCTION {scaps}
{ duplicate$ empty$
    { pop$ "" }
%<html>    { skip$ }
%<*!html>
%<!nfss>    { "{\sc " swap$ * "}" * }
%<nfss>    { "\textsc{" swap$ * "}" * }
%</!html>
  if$
}
%</lab-sc|nmft-sc|pres-sc>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`roman.list'}
% \changes{3.4}{1995 Sep 28}{Add function}
% \changes{3.85}{1998 Feb 6}{Remove function}
% \begin{macro}{`roman.cite'}
% \changes{3.8}{1996 Mar 16}{Add function}
% \changes{3.85}{1998 Feb 6}{Remove function}
% \end{macro}
% \end{macro}
%
% \begin{macro}{`bib.name.font'}
% \changes{3.85}{1998 Feb 6}{Add macro}
% \begin{macro}{`bib.fname.font'}
% \changes{3.85}{1998 Feb 6}{Add macro}
% \begin{macro}{`cite.name.font'}
% \changes{3.85}{1998 Feb 6}{Add macro}
% Define functions for formatting the author/editor names, one for the
% surnames (\texttt{bib.name.font}) and one for the first names
% (\texttt{bib.fname.font}). These could be identical, or the latter is
% deactivated if first names are not to be formatted, only the last names.
%
% For citations, we have \texttt{cite.name.font}. Here only surnames appear.
%
% It is also possible to have a user-defined font command for each, which the
% user must define in his work. These are |\bibnamefont{}| and |\bibfnamefont{}|,
% and some defaults are provided that simply repeat the arguments. Two commands
% are needed if \texttt{nmft-def} and \texttt{fnm-def} are both given.
%
% If neither \texttt{fnm-def} nor \texttt{fnm-rm} are given, then the first names
% are formatted the same as the surnames.
%    \begin{macrocode}
%<*nmft>
FUNCTION {bib.name.font}
%<nmft-it>{ emphasize }
%<!nmft-it&nmft-bf>{ bolden }
%<!nmft-it&!nmft-bf&nmft-sc>{ scaps }
%<*!nmft-it&!nmft-bf&!nmft-sc&nmft-def>
{ duplicate$ empty$
  { pop$ "" }
%<!html>  { "\bibnamefont{" swap$ * "}" * }
%<html>  { skip$ }
  if$
}
%</!nmft-it&!nmft-bf&!nmft-sc&nmft-def>
FUNCTION {bib.fname.font}
%<!fnm-rm&!fnm-def>{ bib.name.font }
%<fnm-rm>{ skip$ }
%<*!fnm-rm&fnm-def>
{ duplicate$ empty$
  { pop$ "" }
%<!html>  { "\bibfnamefont{" swap$ * "}" * }
%<html>  { skip$ }
  if$
}
%</!fnm-rm&fnm-def>
%</nmft>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*lab>
FUNCTION {cite.name.font}
%<lab-it>{ emphasize }
%<!lab-it&lab-bf>{ bolden }
%<!lab-it&!lab-bf&lab-sc>{ scaps }
%<*!lab-it&!lab-bf&!lab-sc&lab-def>
{ duplicate$ empty$
  { pop$ "" }
%<!html>  { "\citenamefont{" swap$ * "}" * }
%<html>  { skip$ }
  if$
}
%</!lab-it&!lab-bf&!lab-sc&lab-def>
%</lab>
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{`tie.or.space.prefix'}
% \changes{3.89d1}{1999 July 20}{AO: replace \texttt{tie.or.space.connect} with
%   more flexible function}
% The function \texttt{tie.or.space.prefix} determines whether
% the top item on the stack requires a tie character and
% slips that (or a space character if not) ahead of it.
% At this point a font switch or other function can be applied to
% the top item on the stack, and the appropriate space found
% just ahead of it on the stack.
%
% The sequence \texttt{tie.or.space.prefix} \texttt{*} \texttt{*} is a common idiom
% for joining the top two stack objects with a tie or space
% depending on the length of the top object.
%
% Another idiom is to apply \texttt{tie.or.space.prefix}, apply a font switch,
% and then swap and join. In this case the tie or space follows the object.
%    \begin{macrocode}
FUNCTION {tie.or.space.prefix}
{ duplicate$ text.length$ #3 <
    { "~" }
    { " " }
  if$
  swap$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`capitalize'}
% \changes{3.0}{1995 Mar 7}{Add capitalizing function}
% Capitalizing is easy for regular languages, but for \texttt{babel},
% some trickery stuff is needed; definitions of |\capitalize| and
% |\Capitalize| are written to the \texttt{.bbl} file.
%    \begin{macrocode}

FUNCTION {capitalize}
%<!babel>{ "u" change.case$ "t" change.case$ }
%<babel>{ "\capitalize" swap$ * }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`space.word'}
% \changes{2.0}{1994 Jan 31}{Add function to space out words; necessary
%          for the multilingual functions.}
% The function \texttt{space.word} adds a space before and after the word or
% words currently on the stack. This was added for the \texttt{bbl.}$nnn$
% functions, that contain only a word without spacing, but replace explicit
% text in the originals that were spaced out. Its seems more flexible to
% define the word functions to be without spacing.
%    \begin{macrocode}
FUNCTION {space.word}
{ " " swap$ * " " * }
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
 % Here are the language-specific definitions for explicit words.
 % Each function has a name bbl.xxx where xxx is the English word.
%    \end{macrocode}
%
%    \begin{macrocode}
%<*!exlang>
%    \end{macrocode}
%
% \begin{macro}{`bbl.xxx'}
% \changes{2.0}{1994 Jan 31}{Replace all explicit words with functions
%     of the form \texttt{bbl.xxx}.}
% \changes{3.6}{1996 Jan 15}{Add option \texttt{varand}}
% \changes{3.83}{1997 Feb 25}{Add option \texttt{ednx}}
% \changes{3.83}{1997 Jun 9}{Make \texttt{\char`\\BIBand} protected}
% \changes{3.87}{1998 Aug 17}{Add \texttt{bbl.etal}}
% \changes{3.89d1}{1999 July 20}{AO: add \texttt{bbl.eidpp}}
% These are the default English words. There is no default language
% option: one of \texttt{english} or \texttt{babel} must be given.
%    \begin{macrocode}
%<*!babel>
 % The language selected here is ENGLISH
FUNCTION {bbl.and}
%<!varand|html>{ "and"}
%<varand&!html>{ "\protect\BIBand{}"}

FUNCTION {bbl.etal}
{ "et~al." }

FUNCTION {bbl.editors}
%<!ed>{ "editors" }
%<ed>{ "eds." }

FUNCTION {bbl.editor}
%<!ed>{ "editor" }
%<ed>{ "ed." }

FUNCTION {bbl.edby}
{ "edited by" }

FUNCTION {bbl.edition}
%<!abr>{ "edition" }
%<abr&!ednx>{ "edn." }
%<abr&ednx>{ "ed." }

FUNCTION {bbl.volume}
%<!abr>{ "volume" }
%<abr>{ "vol." }

FUNCTION {bbl.of}
{ "of" }

FUNCTION {bbl.number}
%<!abr>{ "number" }
%<abr>{ "no." }

FUNCTION {bbl.nr}
{ "no." }

FUNCTION {bbl.in}
{ "in" }

FUNCTION {bbl.pages}
%<!pp&!ppx>{ "pages" }
%<pp>{ "pp." }
%<!pp&ppx>{ "" }

FUNCTION {bbl.page}
%<!pp&!ppx>{ "page" }
%<pp>{ "p." }
%<!pp&ppx>{ "" }

%<*revdata>
FUNCTION {bbl.eidpp}
{ "pages" }

%</revdata>
FUNCTION {bbl.chapter}
%<!abr>{ "chapter" }
%<abr>{ "chap." }

FUNCTION {bbl.techrep}
%<!abr>{ "Technical Report" }
%<abr>{ "Tech. Rep." }

FUNCTION {bbl.mthesis}
{ "Master's thesis" }

FUNCTION {bbl.phdthesis}
{ "Ph.D. thesis" }

%<*!xedn>
FUNCTION {bbl.first}
%<!ord>{ "First" }
%<ord>{ "1st" }

FUNCTION {bbl.second}
%<!ord>{ "Second" }
%<ord>{ "2nd" }

FUNCTION {bbl.third}
%<!ord>{ "Third" }
%<ord>{ "3rd" }

FUNCTION {bbl.fourth}
%<!ord>{ "Fourth" }
%<ord>{ "4th" }

FUNCTION {bbl.fifth}
%<!ord>{ "Fifth" }
%<ord>{ "5th" }

FUNCTION {bbl.st}
{ "st" }

FUNCTION {bbl.nd}
{ "nd" }

FUNCTION {bbl.rd}
{ "rd" }

FUNCTION {bbl.th}
{ "th" }

%</!xedn>
%<*!abr>
MACRO {jan} {"January"}

MACRO {feb} {"February"}

MACRO {mar} {"March"}

MACRO {apr} {"April"}

MACRO {may} {"May"}

MACRO {jun} {"June"}

MACRO {jul} {"July"}

MACRO {aug} {"August"}

MACRO {sep} {"September"}

MACRO {oct} {"October"}

MACRO {nov} {"November"}

MACRO {dec} {"December"}

%</!abr>
%<*abr>
MACRO {jan} {"Jan."}

MACRO {feb} {"Feb."}

MACRO {mar} {"Mar."}

MACRO {apr} {"Apr."}

MACRO {may} {"May"}

MACRO {jun} {"Jun."}

MACRO {jul} {"Jul."}

MACRO {aug} {"Aug."}

MACRO {sep} {"Sep."}

MACRO {oct} {"Oct."}

MACRO {nov} {"Nov."}

MACRO {dec} {"Dec."}

%</abr>
%</!babel>
%    \end{macrocode}
%
% Here are the definitions for \texttt{babel} option, i.e., explicit
% translations are not used, but rather only \LaTeX{} macros that must be
% defined in the file \texttt{babelbst.tex}. This could allow automatic
% language selection.
%    \begin{macrocode}
%<*babel>
 % The BABEL language selection is made here; definitions in babelbst.tex.
FUNCTION {bbl.and}
{ "\bbland{}"}

FUNCTION {bbl.etal}
{ "\bbletal{}"}

FUNCTION {bbl.editors}
%<!ed>{ "\bbleditors{}" }
%<ed>{ "\bbleds{}" }

FUNCTION {bbl.editor}
%<!ed>{ "\bbleditor{}" }
%<ed>{ "\bbled{}" }

FUNCTION {bbl.edby}
{ "\bbledby{}" }

FUNCTION {bbl.edition}
%<!abr>{ "\bbledition{}" }
%<abr>{ "\bbledn{}" }

FUNCTION {bbl.volume}
%<!abr>{ "\bblvolume{}" }
%<abr>{ "\bblvol{}" }

FUNCTION {bbl.of}
{ "\bblof{}" }

FUNCTION {bbl.number}
%<!abr>{ "\bblnumber{}" }
%<abr>{ "\bblno{}" }

FUNCTION {bbl.nr}
{ "\bblno{}" }

FUNCTION {bbl.in}
{ "\bblin{}" }

FUNCTION {bbl.pages}
%<!pp&!ppx>{ "\bblpages{}" }
%<pp>{ "\bblpp{}" }
%<!pp&ppx>{ "" }

FUNCTION {bbl.page}
%<!pp&!ppx>{ "\bblpage{}" }
%<pp>{ "\bblp{}" }
%<!pp&ppx>{ "" }

FUNCTION {bbl.chapter}
%<!abr>{ "\bblchapter{}" }
%<abr>{ "\bblchap{}" }

FUNCTION {bbl.techrep}
%<!abr>{ "\bbltechreport{}" }
%<abr>{ "\bbltechrep{}" }

FUNCTION {bbl.mthesis}
{ "\bblmthesis{}" }

FUNCTION {bbl.phdthesis}
{ "\bblphdthesis{}" }

%<*revdata>
FUNCTION {bbl.eidpp}
{ "\bbleidpp{}" }

%</revdata>
%<*!xedn>
FUNCTION {bbl.first}
%<!ord>{ "\bblfirst{}" }
%<ord>{ "\bblfirsto{}" }

FUNCTION {bbl.second}
%<!ord>{ "\bblsecond{}" }
%<ord>{ "\bblsecondo{}" }

FUNCTION {bbl.third}
%<!ord>{ "\bblthird{}" }
%<ord>{ "\bblthirdo{}" }

FUNCTION {bbl.fourth}
%<!ord>{ "\bblfourth{}" }
%<ord>{ "\bblfourtho{}" }

FUNCTION {bbl.fifth}
%<!ord>{ "\bblfifth{}" }
%<ord>{ "\bblfiftho{}" }

FUNCTION {bbl.st}
{ "\bblst{}" }

FUNCTION {bbl.nd}
{ "\bblnd{}" }

FUNCTION {bbl.rd}
{ "\bblrd{}" }

FUNCTION {bbl.th}
{ "\bblth{}" }

%</!xedn>
MACRO {jan} {"\bbljan{}"}

MACRO {feb} {"\bblfeb{}"}

MACRO {mar} {"\bblmar{}"}

MACRO {apr} {"\bblapr{}"}

MACRO {may} {"\bblmay{}"}

MACRO {jun} {"\bbljun{}"}

MACRO {jul} {"\bbljul{}"}

MACRO {aug} {"\bblaug{}"}

MACRO {sep} {"\bblsep{}"}

MACRO {oct} {"\bbloct{}"}

MACRO {nov} {"\bblnov{}"}

MACRO {dec} {"\bbldec{}"}

%</babel>
%    \end{macrocode}
%
% \begin{macro}{`eng.ord'}
% \changes{2.0}{1994 Jan 31}{Add function to format English ordinals.}
% This function adds English endings for ordinals 1, 2, 3. However, if
% the second last digit is 1, then the ending is `th' for all last digits.
% So far, all other languages included do not have this problem, and it is
% sufficient to add the \textsl{th} equivalent. This might change with further
% languages.
%
% This function must be included with \texttt{babel} too, since that includes
% English. This means that the language definition files must also provide
% for |\bblst|, |\bblnd|, and |\bblrd|, setting them all equal to |\bblth|.
%
%    \begin{macrocode}
%<*(english|!exlang)&!xedn>
FUNCTION {eng.ord}
{ duplicate$ "1" swap$ *
  #-2 #1 substring$ "1" =
     { bbl.th * }
     { duplicate$ #-1 #1 substring$
       duplicate$ "1" =
         { pop$ bbl.st * }
         { duplicate$ "2" =
             { pop$ bbl.nd * }
             { "3" =
                 { bbl.rd * }
                 { bbl.th * }
               if$
             }
           if$
          }
       if$
     }
   if$
}

%</(english|!exlang)&!xedn>
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</!exlang>
%    \end{macrocode}
%
%    \begin{macrocode}
%</!tail>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*!head>
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%<*!jabr>
MACRO {acmcs} {"ACM Computing Surveys"}

MACRO {acta} {"Acta Informatica"}

MACRO {cacm} {"Communications of the ACM"}

MACRO {ibmjrd} {"IBM Journal of Research and Development"}

MACRO {ibmsj} {"IBM Systems Journal"}

MACRO {ieeese} {"IEEE Transactions on Software Engineering"}

MACRO {ieeetc} {"IEEE Transactions on Computers"}

MACRO {ieeetcad}
 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}

MACRO {ipl} {"Information Processing Letters"}

MACRO {jacm} {"Journal of the ACM"}

MACRO {jcss} {"Journal of Computer and System Sciences"}

MACRO {scp} {"Science of Computer Programming"}

MACRO {sicomp} {"SIAM Journal on Computing"}

MACRO {tocs} {"ACM Transactions on Computer Systems"}

MACRO {tods} {"ACM Transactions on Database Systems"}

MACRO {tog} {"ACM Transactions on Graphics"}

MACRO {toms} {"ACM Transactions on Mathematical Software"}

MACRO {toois} {"ACM Transactions on Office Information Systems"}

MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}

MACRO {tcs} {"Theoretical Computer Science"}
%</!jabr>
%    \end{macrocode}
%
% \changes{4.00}{1999 Oct 8}{Revise journal abbreviations}
% Journal abbreviations have been revised from the original Patashnik
% ones with help of Conrado Badenas and the IUA recommendations.
%    \begin{macrocode}
%<*jabr>
MACRO {acmcs} {"ACM Comput. Surv."}

MACRO {acta} {"Acta Inf."}

MACRO {cacm} {"Commun. ACM"}

MACRO {ibmjrd} {"IBM J. Res. Dev."}

MACRO {ibmsj} {"IBM Syst.~J."}

MACRO {ieeese} {"IEEE Trans. Software Eng."}

MACRO {ieeetc} {"IEEE Trans. Comput."}

MACRO {ieeetcad}
 {"IEEE Trans. Comput. Aid. Des."}

MACRO {ipl} {"Inf. Process. Lett."}

MACRO {jacm} {"J.~ACM"}

MACRO {jcss} {"J.~Comput. Syst. Sci."}

MACRO {scp} {"Sci. Comput. Program."}

MACRO {sicomp} {"SIAM J. Comput."}

MACRO {tocs} {"ACM Trans. Comput. Syst."}

MACRO {tods} {"ACM Trans. Database Syst."}

MACRO {tog} {"ACM Trans. Graphic."}

MACRO {toms} {"ACM Trans. Math. Software"}

MACRO {toois} {"ACM Trans. Office Inf. Syst."}

MACRO {toplas} {"ACM Trans. Progr. Lang. Syst."}

MACRO {tcs} {"Theor. Comput. Sci."}

%</jabr>
%    \end{macrocode}
%
% \begin{macro}{`bibinfo.check'}
% \changes{3.89d1}{1999 July 20}{AO:
%   add functions \texttt{bibinfo.check}, \texttt{bibinfo.warn},
%   and \texttt{format.eprint}}
%   Define functions that encapsulate the argument
% in a \TeX\ macro that allows for further processing when the
% bibliography is processed, or allows for a separate computer
% program to parse the |\bibitem| contents.
%
% The following table summarizes how each of the \btx{} entries
% is accessed for output; these are the points where
% the \texttt{format.bibinfo} or \texttt{bibinfo.check} functions
% are called.
% \subsubsection*{Trapped via \texttt{format.bibinfo}}
% \begin{description}
% \item[  \texttt{author}        ]\texttt{format.names}
% \item[  \texttt{collaboration} ]\texttt{format.authors}
% \item[  \texttt{editor}        ]\texttt{format.editors} (\texttt{book}, \texttt{inbook}, \texttt{proceedings}), \texttt{format.names.ed} (\texttt{format.in.ed.booktitle})
% \item[  \texttt{eid}           ]\texttt{format.journal.eid} (\texttt{format.vol.num.pages}, article) checks the output from \texttt{format.journal.pages}
% \item[  \texttt{isbn}          ]\texttt{format.isbn}
% \item[  \texttt{issn}          ]\texttt{format.issn}
% \item[  \texttt{journal}       ]\texttt{format.article.crossref}, article
% \item[  \texttt{numpages}      ]\texttt{format.journal.eid}
% \item[  \texttt{organization}  ]\texttt{format.organization.address} (\texttt{inproceedings}, \texttt{proceedings}), \texttt{manual}
% \item[  \texttt{pages}         ]\texttt{format.book}.pages (\texttt{book}, \texttt{booklet}), \texttt{format.pages} (\texttt{format.journal.pages}, \texttt{format.chapter.pages}, \texttt{article}, \texttt{inbook}, \texttt{incollection}, \texttt{inproceedings})
% \item[  \texttt{publisher}     ]\texttt{format.publisher.address} (like \texttt{output.check}, \texttt{inproceedings}, \texttt{proceedings})
% \item[  \texttt{title}         ]\texttt{format.title}, \texttt{format.btitle}, \texttt{misc}, \texttt{presort}, \texttt{bib.sort.order}
% \item[  \texttt{volume}        ]\texttt{format.bvolume}, \texttt{format.vol.num.pages}, \texttt{format.book.crossref}
% \item[  \texttt{year}          ]in optional argument of \texttt{\char`\\bibitem}, \texttt{format.date} (as part of date), \texttt{format.year}, \texttt{format.org.or.pub}
% \item[  \texttt{booktitle}     ]\texttt{format.in.ed.booktitle} (\texttt{incollection}, \texttt{inproceedings}), \texttt{format.incoll.inproc.crossref}
% \item[  \texttt{howpublished}  ]\texttt{booklet}, \texttt{misc}
% \item[  \texttt{edition}       ]\texttt{convert.edition.format.edition}
% \item[  \texttt{institution}   ]\texttt{techreport}
% \item[  \texttt{school}        ]\texttt{mastersthesis}, \texttt{phdthesis}
% \item[  \texttt{address}       ]\texttt{format.org.or.pub}, \texttt{booklet}, \texttt{manual}, \texttt{mastersthesis}, \texttt{phdthesis}, \texttt{techreport}
% \item[  \texttt{chapter}       ]\texttt{format.chapter.pages}
% \item[  \texttt{number}        ]\texttt{format.number.series}, \texttt{format.vol.num.pages}, \texttt{format.tr.number}
% \item[  \texttt{series}        ]\texttt{format.bvolume}, \texttt{format.number.series}, \texttt{format.book.crossref}
% \item[  \texttt{type}          ]\texttt{format.chapter.pages}, \texttt{format.thesis.type}, \texttt{format.tr.number}
% \item[  \texttt{month}         ]\texttt{format.date}
% \item[  \texttt{note}          ]\texttt{format.note}
% \item[  \texttt{annote}        ]\texttt{fin.entry}
% \end{description}
%
% \subsubsection*{Encapsulated via \texttt{\char`\\url}}
% \begin{description}
% \item[  \texttt{url}           ]\texttt{format.url} (\texttt{\char`\\harvardurl}, \texttt{\char`\\url}), \texttt{format.url} (\texttt{\char`\\url}), \texttt{format.note} (\texttt{\char`\\url})
% \end{description}
%
% \subsubsection*{Encapsulated via \texttt{\char`\\doi}}
% \begin{description}
% \item[  \texttt{doi}           ]\texttt{format.doi} (\texttt{\char`\\doi})
% \end{description}
%
% \subsubsection*{Encapsulated via \texttt{\char`\\eprint}}
% \begin{description}
% \item[  \texttt{eprint}        ]\texttt{format.eprint}
% \item[  \texttt{archive}       ]\texttt{format.eprint}
% \end{description}
%
% \subsubsection*{Not encapsulated:}
% \begin{description}
% \item[  \texttt{key}           ]cite key
% \item[  \texttt{language}      ]operand of \texttt{\char`\\selectlanguage}
% \end{description}
%
% \subsubsection*{\texttt{bibinfo} tag, but not a \btx{} field}
% \begin{description}
% \item[  \texttt{date}          ]\texttt{format.date}
% \end{description}
%
% Provides robust access to fields, checking against \texttt{missing\$}
% and \texttt{empty\$}. A \dtx{} option allows giving
% a warning if either is the case.
%
% If not, it encapsulates the argument in a \TeX\ macro |\bibinfo|.
% The encapsulation is enabled by the \texttt{bibinfo} \dtx{} option:
% if turned off, it simply pops the unneeded object.
%
% \texttt{field} \texttt{string} \texttt{->} \texttt{encapsulated-field}
%
% \texttt{empty} \texttt{string} \texttt{->} \texttt{empty}
% Side effect: warning.
%    \begin{macrocode}
FUNCTION {bibinfo.check}
{ swap$
  duplicate$ missing$
    {
%<bibinfo.warning>      swap$ "missing " swap$ * " in " * cite$ * warning$ pop$
%<!bibinfo.warning>      pop$ pop$
      ""
    }
    { duplicate$ empty$
        {
%<bibinfo.warning>          swap$ "empty " swap$ * " in " * cite$ * warning$
%<!bibinfo.warning>          swap$ pop$
        }
        { swap$
%<bibinfo>          "\bibinfo{" swap$ * "}{" * swap$ * "}" *
%<!bibinfo>          pop$
        }
      if$
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`bibinfo.warn'}
% Replaces \texttt{output.check}
% with \texttt{bibinfo.warn} followed by \texttt{output}.
%
% \texttt{field} \texttt{string} \texttt{->} \texttt{encapsulated-field}
%
% \texttt{empty} \texttt{string} \texttt{->} \texttt{empty}
%
% Side effect: warning if the field is empty.
% Note: if the \dtx{} option \texttt{bibinfo} is not in effect,
% then no encapsulation is done.
%    \begin{macrocode}
FUNCTION {bibinfo.warn}
{ swap$
  duplicate$ missing$
    {
      swap$ "missing " swap$ * " in " * cite$ * warning$ pop$
      ""
    }
    { duplicate$ empty$
        {
          swap$ "empty " swap$ * " in " * cite$ * warning$
        }
        { swap$
%<bibinfo>          "\bibinfo{" swap$ * "}{" * swap$ * "}" *
%<!bibinfo>          pop$
        }
      if$
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.eprint'}
% \changes{4.00}{2000 Jan 21}{Add optional archive field}
% The access function for the \texttt{eprint} field.
%
% If the \texttt{bibinfo} \dtx{} option is selected, then this function
% encapsulates the argument in a \TeX\ macro |\eprint|.
%
% \texttt{->} \texttt{encapsulated-URL}
%    \begin{macrocode}
%<*eprint>
FUNCTION {format.eprint}
{ eprint duplicate$ empty$
    'skip$
    { "\eprint"
      archive empty$
        'skip$
        { "[" * archive * "]" * }
      if$
      "{" * swap$ * "}" *
    }
  if$
}
%</eprint>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`write.url'}
% \changes{1.5(2.3)}{1994 Sep 16}{Add \texttt{write.url} for option
%   \texttt{harnm}}
% \changes{3.87}{1998 Jul 23}{Apply to non-Harvard styles}
% \changes{4.03}{2002 Jan 14}{Fix bug when both harnm and url-nl given}
% \changes{4.30}{2008 Aug 27}{Add option to put DOI as URL}
% This function taken over from \texttt{agsm.sty}, the main \texttt{harvard}
% bib style. For non-Harvard styles that want to add the URL on a new line
% after the reference, use this function too, but defined slightly
% differently.
%    \begin{macrocode}
%<*(harnm|url-nl)&!revdata>
FUNCTION {write.url}
%<*!html>
{
%<*url-doi&url>
  doi empty$
    { url }
    { "http://dx.doi.org/" doi * }
  if$
%</url-doi&url>
%<!url-doi|!url>  url
  duplicate$ empty$
    { pop$ }
%<harnm>    { "\newline\harvardurl{" swap$ * "}" * write$ newline$ }
%<!harnm&url-nl>    { "\newline\urlprefix\url{" swap$ * "}" * write$ newline$ }
  if$
}
%</!html>
%<*html>
{
%<*url-doi&url>
  doi empty$
    { url }
    { "http://dx.doi.org/" doi * }
  if$
%</url-doi&url>
%<!url-doi|!url>  url
  duplicate$ empty$
    { pop$ }
    {  duplicate$ "<br><a href=" quote$ * swap$ * quote$
      * ">" * swap$ * "</a>" *  write$ newline$ }
  if$
}
%</html>

%</(harnm|url-nl)&!revdata>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.url'}
% \changes{3.87}{1998 Jul 22}{Add function for regular URLs}
% \changes{4.30}{2008 Aug 27}{Add option to put DOI as URL}
% A non-harvard version of URL is also made for regular styles.
% This is used only if the URL text is added as a regular item to the
% reference information, blocked if necessary. Alternatives are on a new line
% (Harvard-like) or in the note.
%    \begin{macrocode}
%<*(url-blk&!harnm)|revdata>
FUNCTION {format.url}
{
%<*url-doi&url>
  doi empty$
    { url }
    { "http://dx.doi.org/" doi * }
  if$
%</url-doi&url>
%<!url-doi|!url>  url
  duplicate$ empty$
    { pop$ "" }
%<!html>    { "\urlprefix\url{" swap$ * "}" * }
%<html>    {  duplicate$ "<a href=" quote$ * swap$ * quote$
%<html>      * ">" * swap$ * "</a>" * }
  if$
}

%</(url-blk&!harnm)|revdata>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`check.speaker'}
% \changes{4.15}{2006 Jan 4}{Add \texttt{presentation}, which needs this function
%                            to highlight speaker name}
% The \texttt{presentation} type uses the \texttt{key} entry to indicate which
% author is the speaker, as the sequence number in the author list. The speaker's
% name is put into a different font, depending on the extra option. If no font
% is specified, all names are the same.
%    \begin{macrocode}
INTEGERS { nameptr namesleft numnames }

%<*pres-bf|pres-it|pres-sc>
FUNCTION {check.speaker}
{ key empty$ 'skip$
  { key nameptr int.to.str$ =
    {
%<pres-bf>      bolden
%<pres-it&!pres-bf>      emphasize
%<pres-sc&!pres-it&!pres-bf>      scaps
    }
      'skip$
    if$
  }
  if$
}

%</pres-bf|pres-it|pres-sc>
%    \end{macrocode}
% \end{macro}

% \begin{macro}{`format.names'}
% \changes{1.5(2.3)}{1994 Sep 16}{Add \texttt{harvard} command for `and' with
%    new option \texttt{harnm}}
% \changes{3.0}{1995 Feb 27}{Add option \texttt{nm-revf}}
% \changes{3.0}{1995 Mar 15}{Add option \texttt{nm-rvx}}
% \changes{3.2}{1995 Jun 7}{Add option \texttt{nm-rvv}}
% \changes{3.6}{1995 Dec 7}{Jr to go at end with \texttt{nm-rev1} (AGU style)}
% \changes{3.6}{1995 Dec 8}{Add option \texttt{nmand-rm}}
% \changes{3.6}{1996 Jan 30}{Add option \texttt{etal-rm}}
% \changes{3.7}{1996 Feb 5}{Add option \texttt{aunm-semi}}
% \changes{3.82}{1996 Dec 16}{Add option \texttt{nm-revv1} (AGU style with full
%      names)}
% \changes{3.85}{1996 Feb 6}{Recode author font; allow first names different}
% \changes{3.88}{1999 Feb 25}{Add option \texttt{aunm-sl}}
% \changes{3.89}{1999 May 20}{Reset \texttt{t}; might still be ``others''
%         from last format function}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate author name for later processing;
%         trap empty author list;
%         bring common braces to outer level for easier understanding of code.}
% \changes{4.00}{1999 Oct 7}{Add option \texttt{jnrlst} to put Jr. last}
% \changes{4.13}{2004 Feb 9}{Add option \texttt{nm-rvcx}}
% \changes{4.14}{2005 Oct 17}{Add option \texttt{nm-rvvc}}
% \changes{4.14}{2005 Oct 17}{Add option \texttt{etal-xc}}
% The \texttt{harvard} package now (version 2.0.3, for \LaTeXe) uses
% |\harvardand| in place of the word \textsl{and} so that it can be changed
% at run time. This is allowed for with the option \texttt{harnm}, which
% need not be used only with the \texttt{har} option.
% This seems like a useless feature for \texttt{.bst} files made from
% this multilanguage source. However, it is included anyway, which means
% if \texttt{harnm} option selected, one must redefine |\harvardand|
% in the document for the language being used.
%
% The location of the junior part for reversed name is not obvious. Prior
% to version 4.0, I always had it attached to the last name, as
% Smith, Jr, John, put it probably is better as Smith, John, Jr. For the
% AGU \texttt{nm-rev1} I always did it this way, probably because I had a
% good AGU example to follow. Dilemma: do I just change them all or add an
% option to do it? The option will maintain consistency with older
% versions, but this could also be considered a bug fix rather than a new
% feature. Solution: use the option, since I have found other \texttt{.bst}
% files from Beebe and Harvard that put junior between surname and first
% name.
%
% |bibinfo| is a variable used to store a string telling it whether the
% names being formatted are authors or editors, since this function is called
% for both purposes. Every call to this function must push the string onto the stack
% just before the call.
%    \begin{macrocode}
STRINGS  { bibinfo}

%    \end{macrocode}
%
% Stack note: if the names argument is a non-nil list, this function returns
% one object on the stack, the formatted list of names.
%
% \texttt{names`string} \texttt{bibinfo`string} \texttt{->} \texttt{author-list`string}
%    \begin{macrocode}
FUNCTION {format.names}
{ 'bibinfo :=
  duplicate$ empty$ 'skip$ {
  's :=
  "" 't :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr
%    \end{macrocode}
% Here is the author formatting when the names are not set in any special
% font, or when the entire name set in a single special font.
%    \begin{macrocode}
%<*!(nmft&(fnm-rm|fnm-def))>
%<*!nm-rev1&!nm-revv1>
%<nm-init>      "{f.~}{vv~}{ll}{, jj}"
%<*!nm-init>
%<nm-rev&!jnrlst>      "{vv~}{ll}{, jj}{, f.}"
%<nm-rev&jnrlst>      "{vv~}{ll}{, f.}{, jj}"
%<*!nm-rev>
%<nm-rv&!jnrlst>      "{vv~}{ll}{ jj}{ f{~}}"
%<nm-rv&jnrlst>      "{vv~}{ll}{ f{~}}{ jj}"
%<*!nm-rv>
%<nm-rvx&!jnrlst>      "{vv~}{ll}{ jj}{ f{}}"
%<nm-rvx&jnrlst>      "{vv~}{ll}{ f{}}{ jj}"
%<*!nm-rvx>
%<nm-rvcx&!jnrlst>      "{vv~}{ll}{, jj}{, f{}}"
%<nm-rvcx&jnrlst>      "{vv~}{ll}{, f{}}{, jj}"
%<*!nm-rvcx>
%<nm-rvv&!jnrlst>      "{vv~}{ll}{ jj}{ f{.}.}"
%<nm-rvv&jnrlst>      "{vv~}{ll}{ f{.}.}{ jj}"
%<*!nm-rvv>
%<nm-rvvc&!jnrlst>      "{vv~}{ll}{, jj}{, f{.}.}"
%<nm-rvvc&jnrlst>      "{vv~}{ll}{, f{.}.}{, jj}"
%<*!nm-rvvc>
%<nm-revf&!jnrlst>      "{vv~}{ll}{, jj}{, ff}"
%<nm-revf&jnrlst>      "{vv~}{ll}{, ff}{, jj}"
%<*!nm-revf>
      "{ff~}{vv~}{ll}{, jj}"
%</!nm-revf>
%</!nm-rvvc>
%</!nm-rvv>
%</!nm-rvcx>
%</!nm-rvx>
%</!nm-rv>
%</!nm-rev>
%</!nm-init>
%</!nm-rev1&!nm-revv1>
%<*nm-rev1>
      duplicate$ #1 >
        { "{f.~}{vv~}{ll}{, jj}" }
%<!jnrlst>        { "{vv~}{ll}{, jj}{, f.}" }
%<jnrlst>        { "{vv~}{ll}{, f.}{, jj}" }
      if$
%</nm-rev1>
%<*!nm-rev1&nm-revv1>
      duplicate$ #1 >
        { "{ff~}{vv~}{ll}{, jj}" }
%<!jnrlst>        { "{vv~}{ll}{, jj}{, ff}" }
%<jnrlst>        { "{vv~}{ll}{, ff}{, jj}" }
      if$
%</!nm-rev1&nm-revv1>
      format.name$
%<nm-rv|nm-rvx>      remove.dots
%<nmft&nmand-rm>      bib.name.font
%</!(nmft&(fnm-rm|fnm-def))>
%    \end{macrocode}
% Here is the author formatting when the first and last names are
% set in (possibly different) special fonts.
%
% \changes{4.00}{1999 Oct 7}{Junior part always in first name font}
% The junior part is optionally between the reversed names, or after them.
%    \begin{macrocode}
%<*nmft&(fnm-rm|fnm-def)>
%<*!nm-rev1&!nm-revv1>
%<*nm-init>
      "{f.}" format.name$ duplicate$ empty$ 'skip$
        { tie.or.space.prefix bib.fname.font swap$ * }
      if$
      s nameptr
      "{vv~}{ll}" format.name$ bib.name.font *
      s nameptr
      "{jj}" format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font ", " swap$ * }
      if$
%</nm-init>
%<*!nm-init>
%<*nm-rev>
      "{vv~}{ll}" format.name$ bib.name.font
      s nameptr
%<!jnrlst>      "{jj, }{f.}"
%<jnrlst>      "{f.}{, jj}"
      format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font ", " swap$ * }
      if$
%</nm-rev>
%<*!nm-rev>
%<*nm-rv>
      "{vv~}{ll}" format.name$ bib.name.font
      s nameptr
%<!jnrlst>      "{jj }{f{~}}"
%<jnrlst>      "{f{~}}{ jj}"
      format.name$ duplicate$ empty$ 'skip$
        { remove.dots bib.fname.font " " swap$ * }
      if$
%</nm-rv>
%<*!nm-rv>
%<*nm-rvx>
      "{vv~}{ll}" format.name$ bib.name.font
      s nameptr
%<!jnrlst>      "{jj }{f{}}"
%<jnrlst>      "{f{}}{ jj}"
      format.name$ duplicate$ empty$ 'skip$
        { remove.dots bib.fname.font " " swap$ * }
      if$
%</nm-rvx>
%<*!nm-rvx>
%<*nm-rvcx>
      "{vv~}{ll}" format.name$ bib.name.font
      s nameptr
%<!jnrlst>      "{jj, }{f{}}"
%<jnrlst>      "{f{}}{, jj}"
      format.name$ duplicate$ empty$ 'skip$
        { remove.dots bib.fname.font ", " swap$ * }
      if$
%</nm-rvcx>
%<*!nm-rvcx>
%<*nm-rvv>
      "{vv~}{ll}" format.name$ bib.name.font
      s nameptr
%<!jnrlst>      "{jj }{f{.}.}"
%<jnrlst>      "{f{.}.}{ jj}"
      format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font " " swap$ * }
      if$
%</nm-rvv>
%<*!nm-rvv>
%<*nm-rvvc>
      "{vv~}{ll}" format.name$ bib.name.font
      s nameptr
%<!jnrlst>      "{jj, }{f{.}.}"
%<jnrlst>      "{f{.}.}{, jj}"
      format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font ", " swap$ * }
      if$
%</nm-rvvc>
%<*!nm-rvvc>
%<*nm-revf>
      "{vv~}{ll}" format.name$ bib.name.font
      s nameptr
%<!jnrlst>      "{jj, }{ff}"
%<jnrlst>      "{ff}{, jj}"
      format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font ", " swap$ * }
      if$
%</nm-revf>
%<*!nm-revf>
      "{ff}" format.name$ duplicate$ empty$ 'skip$
        { tie.or.space.prefix bib.fname.font swap$ * }
      if$
      s nameptr
      "{vv~}{ll}" format.name$ bib.name.font *
      s nameptr
      "{jj}" format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font ", " swap$ * }
      if$
%</!nm-revf>
%</!nm-rvvc>
%</!nm-rvv>
%</!nm-rvcx>
%</!nm-rvx>
%</!nm-rv>
%</!nm-rev>
%</!nm-init>
%</!nm-rev1&!nm-revv1>
%<*nm-rev1>
      nameptr #1 >
        { "{f.}" format.name$ duplicate$ empty$ 'skip$
            { tie.or.space.prefix bib.fname.font swap$ * }
          if$
          s nameptr
          "{vv~}{ll}" format.name$ bib.name.font *
          s nameptr
          "{jj}" format.name$ duplicate$ empty$ 'skip$
            { bib.fname.font ", " swap$ * }
          if$
        }
        { "{vv~}{ll}" format.name$ bib.name.font
          s nameptr
%<!jnrlst>          "{jj, }{f.}"
%<jnrlst>          "{f.}{, jj}"
          format.name$ duplicate$ empty$ 'skip$
            { bib.fname.font ", " swap$ * }
          if$
        }
      if$
%</nm-rev1>
%<*!nm-rev1&nm-revv1>
      nameptr #1 >
        { "{ff}" format.name$ duplicate$ empty$ 'skip$
            { tie.or.space.prefix bib.fname.font swap$ * }
          if$
          s nameptr
          "{vv~}{ll}" format.name$ bib.name.font *
          s nameptr
          "{jj}" format.name$ duplicate$ empty$ 'skip$
            { bib.fname.font ", " swap$ * }
          if$
        }
        { "{vv~}{ll}" format.name$ bib.name.font
          s nameptr
%<!jnrlst>          "{jj, }{ff}"
%<jnrlst>          "{ff}{, jj}"
          format.name$ duplicate$ empty$ 'skip$
            { bib.fname.font ", " swap$ * }
          if$
        }
      if$
%</!nm-rev1&nm-revv1>
      *
%</nmft&(fnm-rm|fnm-def)>
      bibinfo bibinfo.check
%<*pres-bf|pres-it|pres-sc>
      type$ "presentation" =
        { check.speaker }
        'skip$
      if$
%</pres-bf|pres-it|pres-sc>
      't :=
      nameptr #1 >
        {
%<*nmlm>
%<m1>          nameptr #1
%<m2>          nameptr #2
%<m3>          nameptr #3
%<m4>          nameptr #4
%<m5>          nameptr #5
%<m6>          nameptr #6
%<m7>          nameptr #7
%<m8>          nameptr #8
%<m9>          nameptr #9
%<m0>          nameptr #0
%<m10>          #10 +
%<m20>          #20 +
%<m30>          #30 +
%<m40>          #40 +
%<m50>          #50 +
%<m60>          #60 +
%<m70>          #70 +
%<m80>          #80 +
%<m90>          #90 +
          #1 + =
%<x1>          numnames #1
%<x2>          numnames #2
%<x3>          numnames #3
%<x4>          numnames #4
%<x5>          numnames #5
%<x6>          numnames #6
%<x7>          numnames #7
%<x8>          numnames #8
%<x9>          numnames #9
%<x0>          numnames #0
%<x10>          #10 +
%<x20>          #20 +
%<x30>          #30 +
%<x40>          #40 +
%<x50>          #50 +
%<x60>          #60 +
%<x70>          #70 +
%<x80>          #80 +
%<x90>          #90 +
          > and
            { "others" 't :=
              #1 'namesleft := }
            'skip$
          if$
%</nmlm>
          namesleft #1 >
%<!aunm-semi&!aunm-sl>            { ", " * t * }
%<aunm-semi>            { "; " * t * }
%<aunm-sl&!aunm-semi>            { "/ " * t * }
            {
              s nameptr "{ll}" format.name$ duplicate$ "others" =
                { 't := }
                { pop$ }
              if$
%<(and-com|xand)&!aunm-semi&!aunm-sl>              "," *
%<(and-com|xand)&aunm-semi>              ";" *
%<(and-com|xand)&aunm-sl&!aunm-semi>              "/" *
%<*!and-xcom&!and-com&!xand>
              numnames #2 >
%<etal-xc>              t "others" = not and
%<!aunm-semi&!aunm-sl>                { "," * }
%<aunm-semi>                { ";" * }
%<aunm-sl&!aunm-semi>                { "/" * }
                'skip$
              if$
%</!and-xcom&!and-com&!xand>
              t "others" =
                {
%<nmft&!nmand-rm&!(fnm-rm|fnm-def)&(etal-it|etal-rm)>                  bib.name.font
%<*!etal-it>
%<nmft&(nmand-rm|(fnm-rm|fnm-def))&!etal-rm>                  " " * bbl.etal bib.name.font *
%<!(nmft&(nmand-rm|(fnm-rm|fnm-def)))|etal-rm>                  " " * bbl.etal *
%</!etal-it>
%<etal-it>                  " " * bbl.etal emphasize *
%<nmft&!nmand-rm&!(fnm-rm|fnm-def)&!(etal-it|etal-rm)>                  bib.name.font
                }
%<*!xand>
                {
%<*!harnm>
%<!amper>                  bbl.and
%<amper>                  "\&"
%</!harnm>
%<harnm>                  "\harvardand{}"
%<nmft&!nmand-rm&(fnm-rm|fnm-def)>                  bib.name.font
                  space.word * t *
                }
%</!xand>
%<xand>                { " " * t * }
              if$
            }
          if$
        }
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
%<*nmft&!nmand-rm&!(fnm-rm|fnm-def)>
  t "others" =
    'skip$
    { bib.name.font }
  if$
%</nmft&!nmand-rm&!(fnm-rm|fnm-def)>
  } if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.names.ed'}
% \changes{1.6(2.4)}{1995 Feb 2}{Add option \texttt{ed-rev} to allow editor
%    to be formatted just like authors'}
% \changes{3.0}{1995 Feb 27}{Option \texttt{nm-revf} to act just as default}
% \changes{3.83}{1997 Feb 25}{Add option \texttt{and-com-ed} to replace
%     \texttt{and-com} for collection editors}
% \changes{3.85}{1996 Feb 6}{Recode author font; allow first names different}
% \changes{3.88}{1999 Feb 25}{Add option \texttt{ed-au}, synonomous with
%    \texttt{ed-rev}}
% \changes{3.88}{1999 Mar 18}{Bug fix: \texttt{and-com-ed} used correctly}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate editor for later processing;
%    trap empty editor list}
% \changes{4.30}{2008 Aug 27}{Fix bug for \texttt{nm-rvvc}}
% When editors are used in place of authors to identify the work, the
% names are always formatted just like authors'. However, in collections,
% where ``edited by'' or ``\emph{names} (editors)'' are given, it is
% normal not to reverse the names, even if the authors' are. The option
% \texttt{ed-rev} sees to it that editor names are always formatted exactly
% like those of authors, being reversed if necessary.
%
% The option \texttt{ed-au} is identical to \texttt{ed-rev}, but is more
% logical. It means editors (in incollections) are formatted exactly like
% authors, with all the font, reversing, and number limitations. This is
% selected automatically with \texttt{nm-init} and \texttt{nm-} default to save
% programming memory.
%
% The option \texttt{nm-revf} in this case acts the same as the default
% when no \texttt{nm-} option given: full names with surname last. Therefore
% it is not necessary to test for it at all, since it, like the default,
% has the lowest priority: any other \texttt{nm-} option clobbers it.
%
% The options \texttt{aunm-semi} and \texttt{aunm-sl} will put a semi-colon or
% slash between editor names, just as for authors, when \texttt{ed-rev} not
% selected, in keeping with the idea that in this case both authors and editors
% are to be formatted the same.
%
% This function either dispatches to \texttt{format.names} or executes code
% which is similar. In the latter case, names are always presented first
% followed by surname (``last name''); name limit processing (\texttt{nmlm}) is not executed;
% and endgame processing differs in being qualified by \texttt{nmfted}.
%
% Stack note: if the names (second) argument is a non-nil list, this function returns
% with one object on the stack, the formatted list of names.
%
% \texttt{names`string} \texttt{bibinfo`string} \texttt{->} \texttt{author-list`string}
%    \begin{macrocode}
FUNCTION {format.names.ed}
{
%<ed-rev|ed-au>  format.names
%<*!ed-rev&!ed-au>
  'bibinfo :=
  duplicate$ empty$ 'skip$ {
  's :=
  "" 't :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr
%    \end{macrocode}
% Editor name is handled as a single object, with no separation of first and last name.
%    \begin{macrocode}
%<*!(nmft&nmfted&(fnm-rm|fnm-def))>
%<nm-init|nm-rev|nm-rev1>      "{f.~}{vv~}{ll}{, jj}"
%<*!nm-init&!nm-rev&!nm-rev1>
%<nm-revv1>      "{ff~}{vv~}{ll}{, jj}"
%<*!nm-revv1>
%<nm-rv>      "{f{~}~}{vv~}{ll}{ jj}"
%<*!nm-rv>
%<nm-rvx>      "{f{}~}{vv~}{ll}{ jj}"
%<*!nm-rvx>
%<nm-rvcx>      "{f{}~}{vv~}{ll}{ jj}"
%<*!nm-rvcx>
%<nm-rvv|nm-rvvc>      "{f{.}.~}{vv~}{ll}{ jj}"
%<*!nm-rvv&!nm-rvvc>
      "{ff~}{vv~}{ll}{, jj}"
%</!nm-rvv&!nm-rvvc>
%</!nm-rvcx>
%</!nm-rvx>
%</!nm-rv>
%</!nm-revv1>
%</!nm-init&!nm-rev&!nm-rev1>
      format.name$
%<nm-rv|nm-rvx|nm-rvcx>      remove.dots
%<nmft&nmfted&nmand-rm>    bib.name.font
%</!(nmft&nmfted&(fnm-rm|fnm-def))>
%    \end{macrocode}
% Editor first and last name handled separately.
%    \begin{macrocode}
%<*(nmft&nmfted&(fnm-rm|fnm-def))>
%<*nm-init|nm-rev|nm-rev1>
      "{f.}" format.name$ duplicate$ empty$ 'skip$
        { tie.or.space.prefix bib.fname.font swap$ * }
      if$
      s nameptr
      "{vv~}{ll}" format.name$ bib.name.font *
      s nameptr
      "{jj}" format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font ", " swap$ * }
      if$
%</nm-init|nm-rev|nm-rev1>
%<*!nm-init&!nm-rev&!nm-rev1>
%<*nm-revv1>
      "{ff}" format.name$ duplicate$ empty$ 'skip$
        { tie.or.space.prefix bib.fname.font swap$ * }
      if$
      s nameptr
      "{vv~}{ll}" format.name$ bib.name.font *
      s nameptr
      "{jj}" format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font ", " swap$ * }
      if$
%</nm-revv1>
%<*!nm-revv1>
%<*nm-rv>
      "{f{~}}" format.name$ duplicate$ empty$ 'skip$
        { tie.or.space.prefix bib.fname.font swap$ * }
      if$
      s nameptr
      "{vv~}{ll}" format.name$ bib.name.font *
      s nameptr
      "{jj}" format.name$ duplicate$ empty$ 'skip$
        { remove.dots bib.fname.font " " swap$ * }
      if$
%</nm-rv>
%<*!nm-rv>
%<*nm-rvx|nm-rvcx>
      "{f{}}" format.name$ duplicate$ empty$ 'skip$
        { tie.or.space.prefix bib.fname.font swap$ * }
      if$
      s nameptr
      "{vv~}{ll}" format.name$ bib.name.font *
      s nameptr
      "{jj}" format.name$ duplicate$ empty$ 'skip$
        { remove.dots bib.fname.font " " swap$ * }
      if$
%</nm-rvx|nm-rvcx>
%<*!nm-rvx&!nm-rvcx>
%<*nm-rvv|nm-rvvc>
      "{f{.}.}" format.name$ duplicate$ empty$ 'skip$
        { tie.or.space.prefix bib.fname.font swap$ * }
      if$
      s nameptr
      "{vv~}{ll}" format.name$ bib.name.font *
      s nameptr
      "{jj}" format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font " " swap$ * }
      if$
%</nm-rvv|nm-rvvc>
%<*!nm-rvv&!nm-rvvc>
      "{ff}" format.name$ duplicate$ empty$ 'skip$
        { tie.or.space.prefix bib.fname.font swap$ * }
      if$
      s nameptr
      "{vv~}{ll}" format.name$ bib.name.font *
      s nameptr
      "{jj}" format.name$ duplicate$ empty$ 'skip$
        { bib.fname.font ", " swap$ * }
      if$
%</!nm-rvv&!nm-rvvc>
%</!nm-rvx&!nm-rvcx>
%</!nm-rv>
%</!nm-revv1>
%</!nm-init&!nm-rev&!nm-rev1>
      *
%</(nmft&nmfted&(fnm-rm|fnm-def))>
      bibinfo bibinfo.check
      't :=
      nameptr #1 >
        {
          namesleft #1 >
%<!aunm-semi&!aunm-sl>            { ", " * t * }
%<aunm-semi>            { "; " * t * }
%<aunm-sl&!aunm-semi>            { "/ " * t * }
            {
              s nameptr "{ll}" format.name$ duplicate$ "others" =
                { 't := }
                { pop$ }
              if$
%<(and-com-ed|xand)&!aunm-semi&!aunm-sl>              "," *
%<(and-com-ed|xand)&aunm-semi>              ";" *
%<(and-com-ed|xand)&aunm-sl&!aunm-semi>              "/" *
%<*!and-xcom&!and-com-ed&!xand>
              numnames #2 >
%<etal-xc>              t "others" = not and
%<!aunm-semi&!aunm-sl>                { "," * }
%<aunm-semi>                { ";" * }
%<aunm-sl&!aunm-semi>                { "/" * }
                'skip$
              if$
%</!and-xcom&!and-com-ed&!xand>
              t "others" =
                {

%<nmft&nmfted&!nmand-rm&!(fnm-rm|fnm-def)&(etal-it|etal-rm)>                  bib.name.font
%<*!etal-it>
%<nmft&nmfted&(nmand-rm|(fnm-rm|fnm-def))&!etal-rm>                  " " * bbl.etal bib.name.font *
%<!(nmft&nmfted&(nmand-rm|(fnm-rm|fnm-def)))|etal-rm>                  " " * bbl.etal *
%</!etal-it>
%<etal-it>                  " " * bbl.etal emphasize *
%<nmft&nmfted&!nmand-rm&!(fnm-rm|fnm-def)&!(etal-it|etal-rm)>                  bib.name.font
                }
%<*!xand>
                {
%<*!harnm>
%<!amper>                  bbl.and
%<amper>                  "\&"
%</!harnm>
%<harnm>                  "\harvardand{}"
%<nmft&nmfted&!nmand-rm&(fnm-rm|fnm-def)>                  bib.name.font
                  space.word * t *
                }
%</!xand>
%<xand>                { " " * t * }
              if$
            }
          if$
        }
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
%<*nmft&nmfted&!nmand-rm&!(fnm-rm|fnm-def)>
  t "others" =
    'skip$
    { bib.name.font }
  if$
%</nmft&nmfted&!nmand-rm&!(fnm-rm|fnm-def)>
  } if$
%</!ed-rev&!ed-au>
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.key'}
%    \begin{macrocode}
%<*ay>
FUNCTION {format.key}
{ empty$
    { key field.or.null }
    { "" }
  if$
}

%</ay>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.authors'}
%
% \changes{3.89d1}{1999 July 20}{AO: Add code to emit collaboration.}
%    \begin{macrocode}
FUNCTION {format.authors}
{ author "author" format.names
%<*revdata>
    duplicate$ empty$ 'skip$
    { collaboration "collaboration" bibinfo.check
      duplicate$ empty$ 'skip$
        { " (" swap$ * ")" * }
      if$
      *
    }
  if$
%</revdata>
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`get.bbl.editor'}
% \changes{3.89d1}{1999 July 20}{AO: access function for editor text entity}
% Use this function universally when accessing the ``editor'' text entity.
%    \begin{macrocode}
FUNCTION {get.bbl.editor}
{ editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.editors'}
% \changes{3.0}{1995 Mar 20}{Add option \texttt{edpar}}
% \changes{3.83}{1997 Feb 4}{Add option \texttt{edparc}}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate editors for further processing.}
% \changes{4.00}{1999 Oct 6}{Add option \texttt{edparxc}}
% The option \texttt{edpar} puts the word `editor' in parentheses.
% In \texttt{genbst.mbs}, this occurred automatically with the option
% \texttt{ed}, to abbreviate `editor' to `ed'. In \texttt{babel.mbs},
% this was not the case, because of complications with the word functions.
% Now this possibility is added as a special option, which means there is
% some inconsistency with older \texttt{.dbj} files that called \texttt{ed}:
% the abbreviated `ed' is not put in parentheses unless \texttt{edpar} is
% also called.
%
% Note that the code here is very similar to code in \texttt{format.in.ed.booktitle};
% the two should be kept coordinated.
%    \begin{macrocode}
FUNCTION {format.editors}
{ editor "editor" format.names duplicate$ empty$ 'skip$
    {
%<!edpar&!edparxc>      "," *
      " " *
      get.bbl.editor
%<bkedcap>      capitalize
%<edpar|edparc|edparxc>   "(" swap$ * ")" *
      *
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.in.editors'}
% \changes{3.0}{1995 Mar 20}{Add option \texttt{edpar}}
% \changes{3.83}{1997 Feb 4}{Add option \texttt{edparc}}
% \changes{3.89d1}{1999 July 20}{AO: code subsumed into
%     \texttt{format.in.ed.booktitle}}
% See the note about the option \texttt{edpar} above.
%
% \end{macro}
%
% \begin{macro}{`format.book.pages'}
% \changes{3.88}{1998 Dec 2}{Add function}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate pages for further processing.}
%    \begin{macrocode}
%<*pg-bk>
FUNCTION {format.book.pages}
{ pages "pages" bibinfo.check
  duplicate$ empty$ 'skip$
    { " " * bbl.pages * }
  if$
}
%</pg-bk>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.isbn'}
% \changes{3.0}{1995 Mar 1}{Add function}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate isbn for further processing}
%    \begin{macrocode}
%<*isbn>
FUNCTION {format.isbn}
{ isbn "isbn" bibinfo.check
  duplicate$ empty$ 'skip$
    {
%<!blk-com&!blk-tit&!blk-tita>      new.block
      "ISBN " swap$ *
    }
  if$
}

%</isbn>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.issn'}
% \changes{3.87}{1998 Aug 17}{Add function}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate issn for further processing}
%    \begin{macrocode}
%<*issn>
FUNCTION {format.issn}
{ issn "issn" bibinfo.check
  duplicate$ empty$ 'skip$
    {
%<!blk-com&!blk-tit&!blk-tita>      new.block
      "ISSN " swap$ *
    }
  if$
}

%</issn>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.doi'}
% \changes{4.10}{2003 May 28}{Add function}
% \changes{4.30}{2008 Aug 27}{Remove bibinfo encapsulation for DOI}
% DOIs like URLs are encapsulated by their own commands, so need no \texttt{bibinfo.check}.
%    \begin{macrocode}
%<*doi|(url-doi&!url)>
FUNCTION {format.doi}
{ doi empty$
    { "" }
    {
%<!blk-com&!blk-tit&!blk-tita>      new.block
%<!html>      "\doi{" doi * "}" *
%<html>      "doi:" doi *
    }
  if$
}
%</doi|(url-doi&!url)>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`select.language'}
% \changes{3.87}{1998 Aug 17}{Add function}
% The \texttt{language} field code has been provided by Bernd Feige, of the
% University of Freiburg.
%    \begin{macrocode}
%<*lang>
FUNCTION {select.language}
{ duplicate$ empty$
    'pop$
    { language empty$
        'skip$
        { "{\selectlanguage{" language * "}" * swap$ * "}" * }
      if$
    }
    if$
}

%</lang>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.note'}
% \changes{3.83}{1997 Apr 25}{Add macro}
% \changes{3.83}{1997 May 26}{Fix so unmatched brace warning suppressed}
% \changes{3.87}{1998 Jul 23}{Add option \texttt{url-nt}}
% Notes should be entered as though they were a sentence on their own.
% However, if they appear mid-sentence rather than after a block or sentence,
% the first letter must be lowercase. Thus if a note begins with a proper
% noun, it must be in braces. To avoid a warning about unmatched braces
% with the \texttt{change.case\$} function, check first if the leading
% character is an opening brace.
%
% With options \texttt{url,url-nt}, the URL text is treated as a note, and
% added here. It is output directly, not prepended to the note text. This
% means, if the note is to be a new sentence, the URL text starts that
% sentence, and the regular note is added to that sentence, comma between.
% \changes{3.89d1}{1999 July 20}{AO: encapsulate note for further processing}
% \changes{4.00}{1999 Sep 14}{PWD: remove url with \texttt{revdata}}
%
%    \begin{macrocode}
FUNCTION {format.note}
{
%<*url-nt&!revdata>
  url empty$
    'skip$
%<!html>    { "\urlprefix\url{" url * "}" * output }
%<html>    { "<a href=" quote$ * url * quote$
%<html>      * ">" * url * "</a>" * output }
  if$
%</url-nt&!revdata>
 note empty$
    { "" }
    { note #1 #1 substring$
      duplicate$ "{" =
        'skip$
        { output.state mid.sentence =
          { "l" }
          { "u" }
        if$
        change.case$
        }
      if$
      note #2 global.max$ substring$ * "note" bibinfo.check
    }
  if$
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.title'}
% \changes{1.4(2.2)a}{1994 Sep 7}{Add enquote function to put titles in quotes,
%    such that punctuation is inside quotes.}
% \changes{3.8}{1996 Apr 17}{Fix bug in quoted title and \texttt{blk-com}}
% \changes{3.83}{1997 Feb 4}{Add \texttt{qx} option, for comma outside
%        quotes}
% For a quoted title, any punctuation in the title goes inside the quote.
% Otherwise, the comma or period following the title also goes inside.
% Exception is with \texttt{qx} option, in which case the comma goes
% outside, even when punctuation present; for period (\texttt{!blk-com})
% is added outside only when punctuation is absent.
%
% \changes{3.89d1}{1999 July 20}{AO: encapsulate title for further processing.}
% \changes{4.01}{2000 May 4}{Put \texttt{change.case\$} before \texttt{bibinfo.check}}
%    \begin{macrocode}
FUNCTION {format.title}
{ title
%<*!atit-u>
  duplicate$ empty$ 'skip$
    { "t" change.case$ }
  if$
%</!atit-u>
  "title" bibinfo.check
%<*tit-it|tit-qq|lang>
  duplicate$ empty$ 'skip$
    {
%<tit-it>      emphasize
%<*!tit-it&tit-qq>
      "\enquote{" swap$ *
%<*!qx>
%<*blk-com>
      non.stop
%<!com-semi&!com-blank>        { ",} " * }
%<com-semi>        { ";} " * }
%<!com-semi&com-blank>        { "} " * }
        { "} " * }
      if$
%</blk-com>
%<!blk-com>      add.period$ "}" *
%</!qx>
%<*qx>
%<*blk-com>
%<!com-semi&!com-blank>      "}, " *
%<com-semi>      "}; " *
%<!com-semi&com-blank>      "} " *
%</blk-com>
%<!blk-com>      "}" *
%</qx>
%</!tit-it&tit-qq>
%<lang>      select.language
    }
  if$
%</tit-it|tit-qq|lang>
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`end.quote.title'}
% \changes{3.82}{1996 Nov 15}{Add macro to finish off quoted titles}
% For a quoted title, the punctuation appears in the quotes. For commas
% between block, this means the inter-block punctuation is already present,
% so it must be suppressed after every \texttt{format.title output}. This
% is done by setting the \texttt{output.state} to \texttt{before.all}, but
% only if there really was a title. Call this macro every time after
% titles are output.
%    \begin{macrocode}
%<*blk-com&tit-qq>
FUNCTION {end.quote.title}
{ title empty$
    'skip$
    { before.all 'output.state := }
  if$
}
%</blk-com&tit-qq>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`end.quote.btitle'}
% \changes{3.84}{1997 Oct 31}{Add function}
% Similar to |end.quote.title| except that it is only applied if titles of
% proceedings and collections are quoted, and if
% neither \texttt{edby}, \texttt{edby-par}, nor \texttt{edby-par} are selected
% (this is the default case in the relevant menu of the \texttt{makebst.tex} run).
% These options add text after the booktitle,
% so additional punctuation need not be suppressed. Unless there is no editor!
%
% Note: this function is called after the result of \texttt{format.in.ed.booktitle}
% has been output, and attempts to predict what that output had been.
% Would it not be better to call this function while that result is still
% on the stack?
%    \begin{macrocode}
%<*bt-qq>
FUNCTION {end.quote.btitle}
{ booktitle empty$
    'skip$
%<!edby&!edby-par&!edby-parc>    { before.all 'output.state := }
%<*edby|edby-par|edby-parc>
    { editor empty$
        { before.all 'output.state := }
        'skip$
      if$
    }
%</edby|edby-par|edby-parc>
  if$
}
%</bt-qq>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`make.full.names'}
% \changes{1.1}{1993 Nov 12}{Add key labels to \texttt{calc.long.label} and
%     get {\tt'author} and {\tt'editor} in right order when author
%     missing.}
% \changes{1.4(2.2)}{1994 Sep 5}{Remove \texttt{calc.long.label} and
%     \texttt{format.long.lab.names}, replacing them with
%     \texttt{format.full.names}, \texttt{make.full.names}, and adding
%     \texttt{author.editor.key}, \texttt{author.key}, and \texttt{editor.key}}
% \changes{1.4(2.2)a}{1994 Sep 7}{Remove option \texttt{and-com} from
%     \texttt{make.full.names}}
% \changes{1.5(2.3)}{1994 Sep 15}{Add full names for \texttt{natbib} v5.3}
% \changes{3.6}{1995 Dec 8}{Suppress `and' in full list if suppressed in short}
% \changes{3.6}{1995 Dec 8}{Font of `and' in lists same as in citations}
% \changes{3.85}{1996 Feb 6}{Recode author font}
% \changes{3.89}{1999 May 20}{Fix location of \texttt{and-xcom} code}
% In versions before 2.2, there were two functions \texttt{calc.long.label}
% and \texttt{format.long.lab.names} that made up the string
% \texttt{long.label} for each entry. This contains the full author list.
% However, there was a bug in the one routine, entered by mistake when an
% earlier bug was removed, and more seriously, the string
% \texttt{long.label} was limited to \texttt{entry.max\$} characters, 100 on
% my system. Author lists were truncated.  Thus, \texttt{make.full.names}
% is used instead to enter the full list of names directly in the
% \texttt{output.bibitem} function, without an intermediate string. This
% involves changing the order of some function definitions, especially
% \texttt{output.bibitem} must come later.
% \changes{3.89}{1999 May 20}{Reset \texttt{t}; might still be ``others''
%         from last format function}
% \changes{3.98}{1999 May 28}{Fix bug with \texttt{harnm}, missing brace}
% \changes{4.20}{2007 Apr 23}{Format juniors to be same as for \texttt{format.lab.names}}
%    \begin{macrocode}
%<*har|cay|nat>
FUNCTION {format.full.names}
{'s :=
 "" 't :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr
%<!jnrlab>      "{vv~}{ll}" format.name$
%<*jnrlab>
%<!nm-rv&!nm-rvv&!nm-rvx&!nm-rvcx>      "{vv~}{ll}{, jj}" format.name$
%<nm-rv|nm-rvv|nm-rvx|nm-rvcx>      "{vv~}{ll}{ jj}" format.name$
%</jnrlab>
%<lab&and-rm>      cite.name.font
      't :=
      nameptr #1 >
        {
%<*nmlm>
%<m1>          nameptr #1
%<m2>          nameptr #2
%<m3>          nameptr #3
%<m4>          nameptr #4
%<m5>          nameptr #5
%<m6>          nameptr #6
%<m7>          nameptr #7
%<m8>          nameptr #8
%<m9>          nameptr #9
%<m0>          nameptr #0
%<m10>          #10 +
%<m20>          #20 +
%<m30>          #30 +
%<m40>          #40 +
%<m50>          #50 +
%<m60>          #60 +
%<m70>          #70 +
%<m80>          #80 +
%<m90>          #90 +
          #1 + =
%<x1>          numnames #1
%<x2>          numnames #2
%<x3>          numnames #3
%<x4>          numnames #4
%<x5>          numnames #5
%<x6>          numnames #6
%<x7>          numnames #7
%<x8>          numnames #8
%<x9>          numnames #9
%<x0>          numnames #0
%<x10>          #10 +
%<x20>          #20 +
%<x30>          #30 +
%<x40>          #40 +
%<x50>          #50 +
%<x60>          #60 +
%<x70>          #70 +
%<x80>          #80 +
%<x90>          #90 +
          > and
            { "others" 't :=
              #1 'namesleft := }
            'skip$
          if$
%</nmlm>
          namesleft #1 >
            { ", " * t * }
            {
              s nameptr "{ll}" format.name$ duplicate$ "others" =
                { 't := }
                { pop$ }
              if$
              t "others" =
                {
%<lab&!and-rm&(etal-it|etal-rm)>                  cite.name.font
%<*!etal-it>
%<lab&and-rm&!etal-rm>                  " " * bbl.etal cite.name.font *
%<!lab|!and-rm|etal-rm>                  " " * bbl.etal *
%</!etal-it>
%<etal-it>                  " " * bbl.etal emphasize *
%<lab&!and-rm&!(etal-it|etal-rm)>                  cite.name.font
                }
                {
%<*!harnm>
%<*!and-xcom>
                  numnames #2 >
                    { "," * }
                    'skip$
                  if$
%</!and-xcom>
%<!amper>                  bbl.and
%<amper>                  "\&"
%</!harnm>
%<harnm>                  "\harvardand{}"
                  space.word * t *
                }
              if$
            }
          if$
        }
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
%<*lab&!and-rm>
  t "others" =
    'skip$
    { cite.name.font }
  if$
%</lab&!and-rm>
}

FUNCTION {author.editor.key.full}
{ author empty$
    { editor empty$
        { key empty$
            { cite$ #1 #3 substring$ }
            'key
          if$
        }
        { editor format.full.names }
      if$
    }
    { author format.full.names }
  if$
}

FUNCTION {author.key.full}
{ author empty$
    { key empty$
         { cite$ #1 #3 substring$ }
          'key
      if$
    }
    { author format.full.names }
  if$
}

FUNCTION {editor.key.full}
{ editor empty$
    { key empty$
         { cite$ #1 #3 substring$ }
          'key
      if$
    }
    { editor format.full.names }
  if$
}

FUNCTION {make.full.names}
{ type$ "book" =
  type$ "inbook" =
  or
    'author.editor.key.full
    { type$ "proceedings" =
        'editor.key.full
        'author.key.full
      if$
    }
  if$
}

%</har|cay|nat>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`output.bibitem'}
%\changes{1.1}{1993 Nov 12}{Test for missing year, set to {\tt????}.}
% The \texttt{output.bibitem} function formats the |\bibitem| entries.
%\changes{1.4(2.2)}{1994 Sep 5}{Move to later location, add
%   \texttt{make.full.names} instead of inserting string \texttt{long.label}}
%\changes{1.5(2.3)}{1994 Sep 16}{Add option \texttt{nat} for full author list
%  for \texttt{natbib.sty} version~5.3}
% \changes{3.84}{1997 Nov 18}{For \texttt{nat}, put label in braces}
% A user has pointed out to me that if the label argument in square brackets
% are put into braces (within the squares) it is then resistent to any
% problems if square braces should appear within the label. Do this, but
% only for the \texttt{nat} option.
%    \begin{macrocode}
FUNCTION {output.bibitem}
{ newline$
%<*!html>
%<*ay>
%<!har&!nat>  "\bibitem[" write$
%<!har&nat>  "\bibitem[{" write$
%<har>  "\harvarditem" write$
%<nmd>  "\protect\citeauthoryear{" write$
%<ast>  "\protect\astroncite{" write$
%<cay>  "\protect\citeauthoryear{" make.full.names * "}{" * write$
%<cn>  "\protect\citename{" write$
%<!har>  label write$
%<har>  make.full.names duplicate$ label =
%<har>    'skip$
%<har>    { "[" label * "]" * write$ }
%<har>  if$
%<har>  "{" swap$ * "}{" * write$
%<har>  year duplicate$ empty$
%<cn>  ", }" year duplicate$ empty$
%<cay|nmd|ast>  "}{" year duplicate$ empty$
%<(har|cn|cay|nmd|ast)&blkyear>    { pop$ "" }
%<(har|cn|cay|nmd|ast)&!blkyear>    { pop$ "????" }
%<har|cn|cay|nmd|ast>    'skip$
%<har|cn|cay|nmd|ast>  if$
%<har>  extra.label * "}{" * write$
%<cn>  * extra.label * "]{" * write$
%<cay|nmd|ast>  * extra.label * "}]{" * write$
%<alk>  "]{" write$
%<!(har|cay|nmd|ast|alk|cn|nat)>  ")]{" write$
%<nat>  ")" make.full.names duplicate$ short.list =
%<nat>     { pop$ }
%<nat>     { * }
%<nat>   if$
%<nat>  "}]{" * write$
%</ay>
%<!ay&!(cite|alph)>  "\bibitem{" write$
%<!ay&(cite|alph)>  "\bibitem[" label * "]{" * write$
  cite$ write$
  "}" write$
  newline$
  ""
%</!html>
%<*html>
%<*htdes>
  "<dt><strong><tt>" write$
  cite$ write$
  "</tt></strong></dt>" write$ newline$
  "<dd>"
%</htdes>
%<htlist&!htdes>  "<li>"
%<!htlist&!htdes>  "<p>"
%</html>
  before.all 'output.state :=
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`if.digit'}
% \changes{3.84}{1997 Sep 16}{Add macro}
% Add \texttt{if.digit} and \texttt{n.separate} to convert large page numbers
% to a separated number.
%    \begin{macrocode}
%<*pgsep-c|pgsep-s|pgsep-p>
FUNCTION {if.digit}
{ duplicate$ "0" =
  swap$ duplicate$ "1" =
  swap$ duplicate$ "2" =
  swap$ duplicate$ "3" =
  swap$ duplicate$ "4" =
  swap$ duplicate$ "5" =
  swap$ duplicate$ "6" =
  swap$ duplicate$ "7" =
  swap$ duplicate$ "8" =
  swap$ "9" = or or or or or or or or or
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`n.separate'}
% \changes{3.84}{1997 Sep 16}{Add macro for options \texttt{pgsep-c},
%  \texttt{pgsep-s}, \texttt{pgsep-p}}
% Large page numbers are to be separated in threes, with thin space, comma
% or period. The number must be 5 digits before the separation occurs.
% No provision is made for numbers of 7 or more digits.
%    \begin{macrocode}
FUNCTION {n.separate}
{ 't :=
  ""
  #0 'numnames :=
  { t empty$ not }
  { t #-1 #1 substring$ if.digit
      { numnames #1 + 'numnames := }
      { #0 'numnames := }
    if$
    t #-1 #1 substring$ swap$ *
    t #-2 global.max$ substring$ 't :=
    numnames #5 =
      { duplicate$ #1 #2 substring$ swap$
        #3 global.max$ substring$
%<pgsep-c>        "," swap$ * *
%<pgsep-p>        "." swap$ * *
%<pgsep-s&!html>        "\," swap$ * *
%<pgsep-s&html>        " " swap$ * *
      }
      'skip$
    if$
  }
  while$
}
%</pgsep-c|pgsep-s|pgsep-p>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`n.dashify'}
%    \begin{macrocode}
FUNCTION {n.dashify}
{
%<pgsep-c|pgsep-s|pgsep-p>  n.separate
  't :=
  ""
    { t empty$ not }
    { t #1 #1 substring$ "-" =
        { t #1 #2 substring$ "--" = not
            { "--" *
              t #2 global.max$ substring$ 't :=
            }
            {   { t #1 #1 substring$ "-" = }
                { "-" *
                  t #2 global.max$ substring$ 't :=
                }
              while$
            }
          if$
        }
        { t #1 #1 substring$ *
          t #2 global.max$ substring$ 't :=
        }
      if$
    }
  while$
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`word.in'}
% \changes{2.0}{1994 Jan 31}{Function \texttt{word.in} constructed out of
%        \texttt{bbl.in} or \texttt{bbl.iin}.}
% \changes{3.0}{1995 Feb 16}{Use only \texttt{bbl.in} and capitalize it
%         as necessary; remove \texttt{bbl.iin}}
% \changes{3.81}{1996 Jun 19}{Add option \texttt{in-x} to suppress `in'}
% \changes{4.01}{2000 May 4}{Add option \texttt{in-it} to italicize `in'}
% The function \texttt{word.in} prints the word \textsl{in} for references
% that are
% contained in a larger work, or in conference proceedings. One may have a
% colon after the word with the option \texttt{in-col}. If blocks of text are
% to be separated with commas (option \texttt{blk-com}) then the word remains
% in lower case, as it is defined in \texttt{bbl.in}; but if blocks act as
% sentences, then it must be capitalized.
%    \begin{macrocode}
FUNCTION {word.in}
%<in-x>{ "" }
%<*!in-x>
%<blk-com|blk-tita>{ bbl.in
%<!blk-com&!blk-tita>{ bbl.in capitalize
%<in-col>  ":" *
%<in-it>  emphasize
  " " * }
%</!in-x>

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.date'}
% \changes{1.4(2.2)}{1994 Sep 6}{Add option \texttt{yr-per} to put period
%    before date}
% \changes{1.5(2.3)}{1994 Sep 16}{Add \texttt{harvard} bracket names to year
%    with new option \texttt{harnm}}
% \changes{1.6(2.4)}{1995 Feb 2}{Add \texttt{yr-blk} for no punctuation before
%    the date}
% \changes{3.2}{1995 May 19}{Add \texttt{dtrev} option for year month}
% \changes{3.2}{1995 May 19}{Add \texttt{mth-bare} for dotless abbreviation
%    of months}
% \changes{3.4}{1995 Sep 28}{Add \texttt{volp-dt} for date after volume}
% \changes{3.5}{1995 Oct 9}{Add brace pair after
%      \texttt{\char`\\harvardyearright}}
% \changes{3.5}{1995 Oct 16}{Add \texttt{aymth} option for months in dates}
% \changes{3.8}{1996 Mar 19}{Add \texttt{vnum-dt} option}
% \changes{3.81}{1996 Sep 12}{Add \texttt{yr-com} option}
% \changes{3.82}{1996 Dec 12}{Fix bug that left off extra label for plain year}
% \changes{3.84}{1997 Oct 30}{Replace \texttt{volp-dt} with \texttt{jdt-p}}
% \changes{3.84}{1997 Oct 30}{Replace \texttt{vnum-dt} with \texttt{jdt-vs}}
% \changes{3.84}{1997 Oct 30}{Add \texttt{jdt-v}}
% \changes{3.85}{1998 Feb 10}{Do \texttt{yr-blk} right}
% \changes{3.86}{1998 Feb 25}{Add \texttt{jdt-pc} to add comma after year}
% \changes{3.87}{1998 Jul 23}{Add \texttt{xmth} to suppress month for numericals}
% \changes{3.87}{1998 Jul 23}{For \texttt{harnm}, suppress punctuation before date}
% \changes{3.89}{1999 May 12}{Add \texttt{blkyear} option}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate the date for further processing}
% \changes{4.31}{2011 Jan 10}{Allow options for punctuation preceding date to work with harvard}
% The new \texttt{harvard.sty} allows variable brackets around the date
% in the reference list. It uses |\harvardyearleft| and |\harvardyearright|
% in the \texttt{.bst} files. Allow this with the option \texttt{harnm},
% which could actually be used without the \texttt{har} option. Note that
% this overrides the other year formatting options, except for the preceding punctuation.
%    \begin{macrocode}
%<*ay>
FUNCTION {format.date}
{ year "year" bibinfo.check duplicate$ empty$
    {
%<*!blkyear>
      "empty year in " cite$ * "; set to ????" * warning$
       pop$ "????"
%</!blkyear>
    }
    'skip$
  if$
%<*aymth>
  month "month" bibinfo.check duplicate$ empty$
    'skip$
    {
%<dtrev>      swap$
      " " * swap$
    }
  if$
  *
%<mth-bare>  remove.dots
%</aymth>
%<dtbf>  bolden
  extra.label *
%<*!harnm>
%<*yr-par|yr-brk|yr-col|yr-blk|yr-com|yr-per>
  before.all 'output.state :=
%<yr-par>  " (" swap$ * ")" *
%<!yr-par&yr-brk>  " [" swap$ * "]" *
%<!yr-par&!yr-brk&yr-col>  ": " swap$ *
%<!yr-par&!yr-brk&!yr-col&yr-com>  ", " swap$ *
%<!yr-par&!yr-brk&!yr-col&!yr-com&yr-per>  after.sentence 'output.state :=
%<!yr-par&!yr-brk&!yr-col&!yr-com&!yr-per&yr-blk>  " " swap$ *
%</yr-par|yr-brk|yr-col|yr-blk|yr-com|yr-per>
%</!harnm>
%<*harnm>
  before.all 'output.state :=
  " \harvardyearleft " swap$ * "\harvardyearright{}" *
%<yr-col>  ":" swap$ *
%<!yr-col&yr-com>  "," swap$ *
%<!yr-col&!yr-com&yr-per>  after.sentence 'output.state :=
%<!yr-col&!yr-com&!yr-per&yr-blk>  " " swap$ *
%</harnm>
}
%</ay>
%<*!ay>
FUNCTION {format.date}
{
%<!xmth>  month "month" bibinfo.check
%<xmth>  ""
  duplicate$ empty$
  year  "year"  bibinfo.check duplicate$ empty$
    { swap$ 'skip$
        { "there's a month but no year in " cite$ * warning$ }
      if$
      *
    }
    { swap$ 'skip$
        {
%<showstack> month year
%<!dtrev>          swap$
          " " * swap$
        }
      if$
      *
%<mth-bare>      remove.dots
    }
  if$
%<dtbf>  bolden
%<*yr-par|yr-brk|yr-col|yr-com|yr-per|yr-blk>
  duplicate$ empty$
    'skip$
    {
      before.all 'output.state :=
%<yr-par>    " (" swap$ * ")" *
%<!yr-par&yr-brk>    " [" swap$ * "]" *
%<!yr-par&!yr-brk&yr-col>    ": " swap$ *
%<!yr-par&!yr-brk&!yr-col&yr-com>    ", " swap$ *
%<!yr-par&!yr-brk&!yr-col&!yr-com&yr-per>    after.sentence 'output.state :=
%<!yr-par&!yr-brk&!yr-col&!yr-com&!yr-per&yr-blk>    " " swap$ *
    }
  if$
%</yr-par|yr-brk|yr-col|yr-com|yr-per|yr-blk>
}
%</!ay>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.year'}
% \changes{3.84}{1997 Oct 30}{Add function}
% For the options that put the year into the journal specifications, use a
% special formatter separate from the regular date formatter.
% The year is always in parentheses (except for appended to journal name).
% \changes{3.89d1}{1999 July 20}{AO: encapsulate year for further processing}
%    \begin{macrocode}
%<*jdt-p|jdt-pc|jdt-v|jdt-vs>
FUNCTION{format.year}
{ year "year" bibinfo.check duplicate$ empty$
    {  "empty year in " cite$ *
%<ay&!blkyear>       "; set to ????" *
       warning$
%<ay&!blkyear>       pop$ "????"
    }
    {
%<!ay&jdt-vs>  " (" swap$ * ")" *
%<!ay&!jdt-vs>  "(" swap$ * ")" *
    }
  if$
%<*ay>
  extra.label *
%<jdt-vs>  " (" swap$ * ")" *
%<!jdt-vs>  "(" swap$ * ")" *
%</ay>
}
%</jdt-p|jdt-pc|jdt-v|jdt-vs>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.btitle'}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate title for further processing.}
%    \begin{macrocode}
FUNCTION {format.btitle}
{ title "title" bibinfo.check
  duplicate$ empty$ 'skip$
    {
%<!btit-rm>      emphasize
%<lang>      select.language
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`either.or.check'}
%    \begin{macrocode}
FUNCTION {either.or.check}
{ empty$
    'pop$
    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.bvolume'}
% \changes{4.11}{2003 Jun 23}{Add \texttt{ser-vol}}
%    \begin{macrocode}
FUNCTION {format.bvolume}
{ volume empty$
    { "" }
    { bbl.volume volume tie.or.space.prefix
      "volume" bibinfo.check * *
      series "series" bibinfo.check
      duplicate$ empty$ 'pop$
%<*!ser-vol>
        { swap$ bbl.of space.word * swap$
          emphasize * }
%</!ser-vol>
%<ser-vol>        { emphasize ", " * swap$ * }
      if$
      "volume and number" number either.or.check
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.number.series'}
%    \begin{macrocode}
FUNCTION {format.number.series}
{ volume empty$
    { number empty$
        { series field.or.null }
%<*num-xser>
        { series empty$
            { number "number" bibinfo.check }
            { output.state mid.sentence =
                { bbl.number }
                { bbl.number capitalize }
              if$
              number tie.or.space.prefix "number" bibinfo.check * *
              bbl.in space.word *
              series "series" bibinfo.check *
            }
          if$
        }
%</num-xser>
%<*!num-xser>
        { output.state mid.sentence =
            { bbl.number }
            { bbl.number capitalize }
          if$
          number tie.or.space.prefix "number" bibinfo.check * *
          series empty$
            { "there's a number but no series in " cite$ * warning$ }
            { bbl.in space.word *
              series "series" bibinfo.check *
            }
          if$
        }
%</!num-xser>
      if$
    }
    { "" }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`is.num'}
% \changes{2.0}{1994 Jan 31}{Add function to test for digit.}
% \changes{3.87h}{1998 Nov 27}{Option to suppress to save wiz-functions}
% This function takes the single-character string on the stack and returns
% 1 if it is a digit, else 0.
%    \begin{macrocode}
%<*!xedn>
FUNCTION {is.num}
{ chr.to.int$
  duplicate$ "0" chr.to.int$ < not
  swap$ "9" chr.to.int$ > not and
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`extract.num'}
% \changes{2.0}{1994 Jan 31}{Add function to extract leading number from
%        a literal string.}
% \changes{3.87h}{1998 Nov 27}{Option to suppress to save wiz-functions}
% This function tests the string on the stack to see if it begins with a
% number. If so, that number is left on the stack; if the string contains
% no numbers at the start, it is left unchanged. The idea is to convert
% \textsl{1st} to \textsl{1} and leave \textsl{first} as is.
% This is used by {\tt convert.edition}.
%    \begin{macrocode}
FUNCTION {extract.num}
{ duplicate$ 't :=
  "" 's :=
  { t empty$ not }
  { t #1 #1 substring$
    t #2 global.max$ substring$ 't :=
    duplicate$ is.num
      { s swap$ * 's := }
      { pop$ "" 't := }
    if$
  }
  while$
  s empty$
    'skip$
    { pop$ s }
  if$
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`convert.edition'}
% \changes{2.0}{1994 Jan 31}{Add function to convert \texttt{edition} entry
%      text from word to a function}
% \changes{3.87h}{1998 Nov 27}{Option to suppress to save wiz-functions}
% \changes{3.89d1}{1999 July 20}{AO: change calling sequence: arg on stack}
% The function \texttt{convert.edition} takes the text in the field
% \texttt{edition} and changes it to the language-specific equivalent. As
% originally planned for \btx, this field should contain the words
% \textsl{First}, \textsl{Second}, etc. Being so explicit,
% it is not so easy to translate, nor to
% convert to \textsl{1st}, \textsl{2nd}, etc., if one wanted.
% This function carries out the translation, by changing
% \textsl{first} or \textsl{1} to \texttt{bbl.first}, and so
% on. The field is reduced to lower case to make it case insensitive. If no
% translation is found, then the original text in \texttt{edition} is used
% instead, as it stands. However, if the original is a number greater than
% the maximum for which text is provided, then \texttt{bbl.th} is added to
% it.
%    \begin{macrocode}
FUNCTION {convert.edition}
{ extract.num "l" change.case$ 's :=
  s "first" = s "1" = or
    { bbl.first 't := }
    { s "second" = s "2" = or
        { bbl.second 't := }
        { s "third" = s "3" = or
            { bbl.third 't := }
            { s "fourth" = s "4" = or
                { bbl.fourth 't := }
                { s "fifth" = s "5" = or
                    { bbl.fifth 't := }
                    { s #1 #1 substring$ is.num
%<!english&exlang>                        { s bbl.th * 't := }
%<english|!exlang>                        { s eng.ord 't := }
                        { edition 't := }
                      if$
                    }
                  if$
                }
              if$
            }
          if$
        }
      if$
    }
  if$
  t
}
%</!xedn>

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.edition'}
% \changes{2.0}{1994 Jan 31}{Add call to \texttt{convert.edition}}
% This function formats the text for the edition specification, such as
% ``Second edition''. It combines the edition number with the word
% \textsl{edition}.
% \changes{3.89d1}{1999 July 20}{AO: encapsulate edition for further processing.}
% \changes{4.01}{2000 May 4}{Put \texttt{change.case\$} before \texttt{bibinfo.check}}
%    \begin{macrocode}
FUNCTION {format.edition}
{ edition duplicate$ empty$ 'skip$
    {
%<!xedn>      convert.edition
      output.state mid.sentence =
        { "l" }
        { "t" }
      if$ change.case$
      "edition" bibinfo.check
      " " * bbl.edition *
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
INTEGERS { multiresult }
%    \end{macrocode}
%
% \begin{macro}{`multi.page.check'}
%    \begin{macrocode}
FUNCTION {multi.page.check}
{ 't :=
  #0 'multiresult :=
    { multiresult not
      t empty$ not
      and
    }
    { t #1 #1 substring$
      duplicate$ "-" =
      swap$ duplicate$ "," =
      swap$ "+" =
      or or
        { #1 'multiresult := }
        { t #2 global.max$ substring$ 't := }
      if$
    }
  while$
  multiresult
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.pages'}
% \changes{3.6}{1995 Nov 24}{Add option \texttt{bkpg-par}}
% \changes{3.88}{1998 Dec 2}{Add option \texttt{bkpg-x}}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate pages for further processing.}
% \changes{4.00}{1999 Dec 10}{Add \texttt{!ppx} test to avoid extra space}
%    \begin{macrocode}
FUNCTION {format.pages}
{ pages duplicate$ empty$ 'skip$
    { duplicate$ multi.page.check
        {
%<!bkpg-x&!ppx>          bbl.pages swap$
          n.dashify
        }
        {
%<!bkpg-x&!ppx>          bbl.page swap$
        }
      if$
%<!bkpg-x&!ppx>      tie.or.space.prefix
      "pages" bibinfo.check
%<!bkpg-x&!ppx>      * *
%<bkpg-par>     "(" swap$ * ")" *
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`first.page'}
%    \begin{macrocode}
%<*jpg-1>
FUNCTION {first.page}
{ 't :=
  ""
    {  t empty$ not t #1 #1 substring$ "-" = not and }
    { t #1 #1 substring$ *
      t #2 global.max$ substring$ 't :=
    }
  while$
}

%</jpg-1>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.journal.pages'}
% \changes{3.82}{1996 Nov 15}{Remove from \texttt{format.vol.num.pages} to
%        be a separate function}
% \changes{3.84}{1997 Oct 30}{Remove option \texttt{vnum-pg}}
% \changes{3.84}{1997 Oct 30}{Replace \texttt{volp-dt} with \texttt{jdt-p}}
%
% \changes{3.89d1}{1999 July 20}{AO: encapsulate pages for further processing.}
%
% Note: this function gets called with something on the stack.
% It may be the volume and number.
%    \begin{macrocode}
FUNCTION {format.journal.pages}
{ pages duplicate$ empty$ 'pop$
    { swap$ duplicate$ empty$
        { pop$ pop$ format.pages }
        {
%<volp-sp>          ": " *
%<*!volp-sp>
%<volp-blk>          " " *
%<*!volp-blk>
%<volp-com>          ", " *
%<*!volp-com>
%<volp-semi>          "; " *
%<!volp-semi>          ":" *
%</!volp-com>
%</!volp-blk>
%</!volp-sp>
%<!jdt-v&!jdt-vs&jdt-p>          format.year * " " *
%<!jdt-v&!jdt-vs&!jdt-p&jdt-pc>          format.year * ", " *
          swap$
%<jpg-1>          first.page
%<!jpg-1>          n.dashify
%<*jwdpg>
          pages multi.page.check
            'bbl.pages
            'bbl.page
          if$
          swap$ tie.or.space.prefix
%</jwdpg>
          "pages" bibinfo.check
%<jwdpg>          * *
          *
        }
      if$
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.journal.eid'}
%
% \changes{3.89d1}{1999 July 20}{AO: add function to emit the eid information.}
% This function is called with something on the stack (journal vol, number)
% and appends \texttt{eid} and \texttt{numpages} if those field are non-empty.
% Very similar to \texttt{format.journal.pages}.
%
% For the AGU style of including the DOI as part of the EID, the DOI number
% is appended too.
%    \begin{macrocode}
FUNCTION {format.journal.eid}
{ eid "eid" bibinfo.check
  duplicate$ empty$ 'pop$
    { swap$ duplicate$ empty$ 'skip$
      {
%<volp-sp>          ": " *
%<*!volp-sp>
%<volp-blk>          " " *
%<*!volp-blk>
%<volp-com>          ", " *
%<*!volp-com>
%<volp-semi>          "; " *
%<!volp-semi>          ":" *
%</!volp-com>
%</!volp-blk>
%</!volp-sp>
      }
      if$
      swap$ *
%<*revdata>
      numpages empty$ 'skip$
        { bbl.eidpp numpages tie.or.space.prefix
          "numpages" bibinfo.check * *
          " (" swap$ * ")" * *
        }
      if$
%</revdata>
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.vol.num.pages'}
% \changes{1.4(2.2)}{1994 Sep 6}{Add option \texttt{volp-sp} to put space
%    after colon in vol:~page.}
% \changes{1.5(2.3)c}{1995 Jan 20}{Add options \texttt{vnum-h},
%   \texttt{vnum-nr} and \texttt{vnum-x} for various formats of
%   journal vol number}
% \changes{1.7(2.5)}{1995 Feb 9}{Add options \texttt{vnum-sp} and
%     \texttt{vnum-cm}}
% \changes{3.0}{1995 Mar 17}{Add option \texttt{volp-semi}}
% \changes{3.4}{1995 Sep 28}{Put \texttt{bolden} in right place for
%    \texttt{vol-2bf} option}
% \changes{3.8}{1996 Mar 19}{Put date between volume and number}
% \changes{3.8}{1996 Mar 19}{Add possibilitity of `page' word}
% \changes{3.81}{1996 Jun 19}{Activate \texttt{jwdpg} option properly}
% \changes{3.81}{1996 Jun 19}{Add possibilitity of `volume' word}
% \changes{3.82}{1996 Nov 15}{Add option \texttt{pp-last}}
% Version 3.84, I have rationalized several options that placed the date in the
% journal specifications. It was rather chaotic before, but now it should be
% more systematic. This means some options have been removed, something that I
% do not like to do.
%
% The option \texttt{pp-last} suppresses the pages in the formatting macros, and
% sees to it that the pages are added just before any notes in those entries
% that take pages. This applies to more than just \texttt{article}, but to
% \texttt{inbook}, \texttt{incollection} as well.
%
% \changes{3.89d1}{1999 July 20}{AO: encapsulate the volume and number for
%   further processing.}
%    \begin{macrocode}
FUNCTION {format.vol.num.pages}
{ volume field.or.null
  duplicate$ empty$ 'skip$
    {
%<jwdvol>      bbl.volume swap$ tie.or.space.prefix
      "volume" bibinfo.check
%<jwdvol>      * *
    }
  if$
%<vol-bf&!vol-2bf>  bolden
%<!vol-bf&!vol-2bf&vol-it>  emphasize
%<jdt-v|jdt-vs>  format.year *
%<*!vnum-x>
  number "number" bibinfo.check duplicate$ empty$ 'skip$
    {
      swap$ duplicate$ empty$
        { "there's a number but no volume in " cite$ * warning$ }
        'skip$
      if$
      swap$
%<vnum-sp>      "~(" swap$ * ")" *
%<!vnum-sp&vnum-cm>      ", " swap$ *
%<!vnum-sp&!vnum-cm&vnum-nr>      ", " bbl.nr * number tie.or.space.prefix pop$ * swap$ *
%<!vnum-sp&!vnum-cm&!vnum-nr&vnum-h>      ", \#" swap$ *
%<!vnum-sp&!vnum-cm&!vnum-nr&!vnum-h&vnum-b>      " " swap$ *
%<!vnum-sp&!vnum-cm&!vnum-nr&!vnum-h&!vnum-b>      "(" swap$ * ")" *
    }
  if$ *
%<!vol-bf&vol-2bf>  bolden
%</!vnum-x>
%<*!pp-last>
  eid empty$
    { format.journal.pages }
    { format.journal.eid }
  if$
%</!pp-last>
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.chapter.pages'}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate series and chapter for
%   further processing.}
%    \begin{macrocode}
FUNCTION {format.chapter.pages}
{ chapter empty$
%<!pp-last>    'format.pages
%<pp-last>    { "" }
    { type empty$
        { bbl.chapter }
        { type "l" change.case$
          "type" bibinfo.check
        }
      if$
      chapter tie.or.space.prefix
      "chapter" bibinfo.check
      * *
%<*!pp-last>
      pages empty$
        'skip$
        { ", " * format.pages * }
      if$
%</!pp-last>
    }
  if$
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`bt.enquote'}
% \changes{3.84}{1997 Oct 31}{Add function}
% \changes{3.89d1}{1999 July 20}{AO: trap \texttt{empty\$} argument}
% This is to place the booktitle for proceedings and collections into quotes.
% If punctuation is to be included, then add a comma unless a stop already
% exists, or add a period under the only circumstances that
% |format.in.ed.booktitle| is followed by |new.sentence|.
%    \begin{macrocode}
%<*bt-qq>
FUNCTION {bt.enquote}
{ duplicate$ empty$ 'skip$
  { "\enquote{" swap$ *
%<*!qx>
    non.stop
      { ",} " * }
      { "}, " * }
    if$
%</!qx>
%<*qx>
    "}, " *
%</qx>
  }
  if$
}
%</bt-qq>
%    \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{`format.booktitle'}
% \changes{3.89d1}{1999 July 20}{AO: new function}
% The function \texttt{format.booktitle} pushes one object
% (the book title, suitably encapsulated) onto the stack.
% It is currently used in \texttt{format.incoll.inproc.crossref}
% and in \texttt{format.in.ed.booktitle}, and should be used whenever accessing
% the \texttt{booktitle} field for eventual output.
%
% If the book title is empty or missing, the function pushes an empty string.
%    \begin{macrocode}
FUNCTION {format.booktitle}
{
  booktitle "booktitle" bibinfo.check
%<!bt-qq&!bt-rm>  emphasize
%<bt-qq>  bt.enquote
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.in.ed.booktitle'}
% \changes{1.5(2.3)b}{1995 Jan 18}{Add option \texttt{edby-par} to put editors
%   in parentheses}
% \changes{1.6(2.4)}{1995 Feb 2}{If \texttt{ed} and \texttt{edby} given
%   together, abbreviate `edited by' to `ed(s).'}
% \changes{3.1}{1995 May 2}{Add option \texttt{edbyx} to replace `edited by'
%    by `ed(s).'}
% \changes{3.81}{1996 Jun 26}{Add option \texttt{edcap}}
% \changes{3.84}{1997 Oct 10}{Fix bug that added extra space sometimes}
% \changes{3.88}{1998 Dec 2}{Book titles may also be roman}
% \changes{3.88}{1998 Dec 2}{New options \texttt{edby-parc} and \texttt{edbyw}}
% \changes{3.89d1}{1999 July 20}{AO: rewritten; encapsulates \texttt{booktitle} and
%      \texttt{editor} for later processing}
% \changes{4.00}{1999 Sept 17}{PWD: fix up several bugs}
% Prior to version 3.81, the \textsl{Editor} or \textsl{Edited by} in
% parentheses was meant to be capitalized, but this did not work properly.
% Now the option \texttt{edcap} produces this, and default is not capitalized.
%
% Notes on \dtx{} options:
% \begin{itemize}
% \item
% The following combinations are available through the \texttt{makebst.tex} interface:
% \begin{verbatim}
% (
%  <default>
%  |edby     (      |edbyx       |edbyy|edbyw[edcap])
%  |edby-par (|edcap|edbyx[edcap]|edbyy             )
%  |edby-parc(|edcap|edbyx                          )
% )
% \end{verbatim}
% \item
% \texttt{edby}, \texttt{edby-par}, and \texttt{edby-parc} are mutually exclusive
% and, except for the default, exhaustive.
% \item
% \texttt{edbyx}, \texttt{edbyw}, and \texttt{edbyy} are mutually exclusive
% and, except for the default, exhaustive.
% \item
% \texttt{edcap} is independent of the above two groups of options.
% \item
% When parentheses need to be applied, we make sure that the respective
% \dtx{} guard expressions are mutually exclusive.
% It makes no sense for \texttt{edbyw} to be in effect if either of
% \texttt{edby-par} or \texttt{edby-parc} is in effect.
% \item
% \texttt{makebst.tex} only activates \texttt{edcap} in certain cases,
% but we do no checking here, applying it consistently to the
% ``editor'' text entity.
% \item
% The code between \texttt{<!edpar>} and \verb+<edpar\|edparc>+
% \emph{must} match the corresponding code in \texttt{format.editors}.
% This means that in the default case, formatting is controlled by
% a \dtx{} mechanism entirely different from the other cases.
% \item \texttt{ser-ed} has been added to suit AGU. Result of series plus
% volume to go between booktitle and editors; must remove \texttt{format.bvolume}
% from \texttt{incollection} and \texttt{inproceedings}.
% \end{itemize}
%
%    \begin{macrocode}
FUNCTION {format.in.ed.booktitle}
{ format.booktitle duplicate$ empty$ 'skip$
    {
%<showstack>% btitle
%<*ser-ed>
      format.bvolume duplicate$ empty$ 'pop$
        { ", " swap$ * * }
      if$
%</ser-ed>
      editor "editor" format.names.ed duplicate$ empty$ 'pop$
        {
%<*!(edby|edby-par|edby-parc)>
%<showstack>% btitle ednms
%<!edpar&!edparxc>          "," *
          " " *
          get.bbl.editor
%<bkedcap>          capitalize
%<edpar>          "(" swap$ * "), " *
%<!edpar&(edparc|edparxc)>          "(" swap$ * ") " *
%<!edpar&!(edparc|edparxc)>          ", " *
          * swap$
%<showstack>% eds btitle
%</!(edby|edby-par|edby-parc)>
%<*edby|edby-par|edby-parc>
%<showstack>% btitle ednms
%<edbyx|edbyy|edbyw>          get.bbl.editor
%<!(edbyx|edbyy|edbyw)>          bbl.edby
%<edcap>          capitalize
%<!(edby-par|edby-parc)&edbyw>          "(" swap$ * ")" *
%<showstack>% btitle ednms ed
%<(edby-par|edby)&edbyy>          swap$ "," *
          " " * swap$ *
%<showstack>% btitle ednms-ed
%<(edby-par|edby-parc)&!edbyw>          "(" swap$ * ")" *
          swap$
%<edby|edby-parc>          "," *
          " " * swap$
%</edby|edby-par|edby-parc>
%<showstack>% btitle ednms-ed (or ednms-ed btitle)
          * }
      if$
%<showstack>% btitle-ednms-ed (or ednms-ed-btitle) (or btitle)
      word.in swap$ *
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`empty.misc.check'}
%    \begin{macrocode}
%<*!ay>
FUNCTION {empty.misc.check}
{ author empty$ title empty$ howpublished empty$
  month empty$ year empty$ note empty$
  and and and and and
%<!seq-no|alph>  key empty$ not and
    { "all relevant fields are empty in " cite$ * warning$ }
    'skip$
  if$
}
%</!ay>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.thesis.type'}
%    \begin{macrocode}
FUNCTION {format.thesis.type}
{ type duplicate$ empty$
    'pop$
    { swap$ pop$
      "t" change.case$ "type" bibinfo.check
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.tr.number'}
% \changes{4.01}{2000 May 4}{Encapsulate number}
%    \begin{macrocode}
FUNCTION {format.tr.number}
{ number "number" bibinfo.check
  type duplicate$ empty$
    { pop$ bbl.techrep }
    'skip$
  if$
  "type" bibinfo.check
  swap$ duplicate$ empty$
    { pop$ "t" change.case$ }
    { tie.or.space.prefix * * }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.article.crossref'}
%\changes{1.3(2.1)}{1994 Jul 1}{Emphasize \texttt{journal} with
%   \texttt{emphasize}, not explicitly}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate journal for further processing.}
% The \texttt{journal} field was emphasized emplicitly, but it should be
% done by command.
%    \begin{macrocode}
FUNCTION {format.article.crossref}
{
%<*!ay>
  key duplicate$ empty$
    { pop$
      journal duplicate$ empty$
        { "need key or journal for " cite$ * " to crossref " * crossref * warning$ }
        { "journal" bibinfo.check emphasize word.in swap$ * }
      if$
    }
    { word.in swap$ * " " *}
  if$
%</!ay>
%<ay>  word.in
%<!html>  " \cite{" * crossref * "}" *
%<html>  " <tt>" * crossref * "</tt>" *
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.crossref.editor'}
% \changes{3.89d1}{1999 July 20}{AO: editor encapsulated for later processing}
% \changes{3.89d1}{1999 July 20}{AO: fixed typo: "etal_rm"->"etal-rm"}
%    \begin{macrocode}
%<*!ay>
FUNCTION {format.crossref.editor}
{ editor #1 "{vv~}{ll}" format.name$
%<nmft&nmfted&nmand-rm>  bib.name.font
  "editor" bibinfo.check
  editor num.names$ duplicate$
  #2 >
    { pop$
%<nmft&nmfted&!nmand-rm&(etal-it|etal-rm)>      bib.name.font
      "editor" bibinfo.check
      " " * bbl.etal
%<etal-it>      emphasize
      *
%<nmft&nmfted&!nmand-rm&!(etal-it|etal-rm)>      bib.name.font
%<nmft&nmfted&!nmand-rm&!(etal-it|etal-rm)>      "others" 't :=
    }
    { #2 <
        'skip$
        { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
            {
%<nmft&nmfted&!nmand-rm&(etal-it|etal-rm)>              bib.name.font
              "editor" bibinfo.check
              " " * bbl.etal
%<etal-it>              emphasize
              *
%<nmft&nmfted&!nmand-rm&!(etal-it|etal-rm)>              bib.name.font
%<nmft&nmfted&!nmand-rm&!(etal-it|etal-rm)>              "others" 't :=
            }
            {
%<*!harnm>
%<!amper>             bbl.and space.word
%<amper>              " \& "
%</!harnm>
%<harnm>              " \harvardand\ "
              * editor #2 "{vv~}{ll}" format.name$
%<nmft&nmfted&nmand-rm>              bib.name.font
              "editor" bibinfo.check
              *
            }
          if$
        }
      if$
    }
  if$
%<*nmft&nmfted&!nmand-rm>
  t "others" =
    'skip$
    { bib.name.font "editor" bibinfo.check }
  if$
%</nmft&nmfted&!nmand-rm>
}
%</!ay>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.book.crossref'}
%\changes{1.3(2.1)}{1994 Jul 1}{Emphasize \texttt{series} with
%   \texttt{emphasize}, not explicitly}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate volume and series for
%    further processing.}
% The \texttt{series} field was emphasized emplicitly, but it should be
% done by command.
%    \begin{macrocode}
FUNCTION {format.book.crossref}
{ volume duplicate$ empty$
    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
      pop$ word.in
    }
    { bbl.volume
%<!(blk-com|blk-tita)>      capitalize
      swap$ tie.or.space.prefix "volume" bibinfo.check * * bbl.of space.word *
    }
  if$
%<*!ay>
  editor empty$
  editor field.or.null author field.or.null =
  or
    { key empty$
        { series empty$
            { "need editor, key, or series for " cite$ * " to crossref " *
              crossref * warning$
              "" *
            }
            { series emphasize * }
          if$
        }
        { key * }
      if$
    }
    { format.crossref.editor * }
  if$
%</!ay>
%<!html>  " \cite{" * crossref * "}" *
%<html>  " <tt>" * crossref * "</tt>" *
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.incoll.inproc.crossref'}
%\changes{1.3(2.1)}{1994 Jul 1}{Emphasize \texttt{booktitle} with
%     \texttt{emphasize},  not explicitly}
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.booktitle}}
% The \texttt{booktitle} field was emphasized emplicitly, but it should be
% done by command.
%    \begin{macrocode}
FUNCTION {format.incoll.inproc.crossref}
{
%<*!ay>
  editor empty$
  editor field.or.null author field.or.null =
  or
    { key empty$
        { format.booktitle duplicate$ empty$
            { "need editor, key, or booktitle for " cite$ * " to crossref " *
              crossref * warning$
            }
            { word.in swap$ * }
          if$
        }
        { word.in key * " " *}
      if$
    }
    { word.in format.crossref.editor * " " *}
  if$
%</!ay>
%<ay>  word.in
%<!html>  " \cite{" * crossref * "}" *
%<html>  " <tt>" * crossref * "</tt>" *
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.org.or.pub'}
% \changes{3.3}{1995 Aug 7}{Add option \texttt{add-pub} which makes use
%    of this function}
% \changes{3.8}{1996 Mar 12}{Add option \texttt{pub-par} to put publisher
%    in parentheses}
% \changes{3.81}{1996 Sep 16}{Add option \texttt{pub-date} to put publisher
%    and date in parentheses together}
% \changes{3.82}{1996 Dec 16}{Add \texttt{add.blank} for \texttt{pub-par}}
% \changes{3.88}{1998 Dec 2}{Add extra label with \texttt{pub-date}}
% \changes{3.88}{1998 Dec 2}{Option \texttt{pub-nopar} to suppress parentheses
%   with \texttt{pub-date}}
% \changes{3.88}{1998 Dec 3}{Change to include organization if present}
% \changes{4.02}{2000 June 27}{Include \texttt{dtbf} option with \texttt{pub-date}}
% Psychology journals often want \textit{address}: \textit{publisher}.
%
% \textsl{Nature} wants publisher and date in parentheses, and when both
% are there, they are merged into one set.
%
% Call function \texttt{add.blank} before parentheses so suppress preceding
% punctuation, which looks strange when publisher in parentheses.
%
% MPG Jahrbuch wants publisher and year, but without parentheses. Add
% \texttt{pub-nopar} to be used with \texttt{pub-date}.
%
% Have now (3.87.h) extended this function to include the organization, if
% present. This is for \texttt{inproceedings} and \texttt{proceedings} where
% the publisher is optional, and organization too. If the publisher is missing,
% but the organization present, it is formatted like the publisher. This
% complication comes from styles that want the publisher/organization to have
% the date included, all in parentheses.
%
% This function is called by \texttt{format.publisher.address} and
% \texttt{format.organization.address}, each putting the appropriate text
% into the stack first.
% \changes{3.89d1}{1999 July 20}{AO: encapsulate address and year for
%    further processing.}
%
%    \begin{macrocode}
FUNCTION {format.org.or.pub}
{ 't :=
  ""
%<*pub-date&!ay>
  year empty$
    { "empty year in " cite$ * warning$ }
    'skip$
  if$
%</pub-date&!ay>
%<*!(pub-date&ay)>
  address empty$ t empty$ and
%<pub-date>  year empty$ and
    'skip$
    {
%</!(pub-date&ay)>
%<pub-par|(pub-date&!pub-xpar)>      add.blank "(" *
%<*add-pub>
      address "address" bibinfo.check *
      t empty$
        'skip$
%</add-pub>
%<*!add-pub>
      t empty$
        { address "address" bibinfo.check *
        }
        { t *
          address empty$
            'skip$
            { ", " * address "address" bibinfo.check * }
          if$
        }
%</!add-pub>
%<*add-pub>
        { address empty$
            'skip$
            { ": " * }
          if$
          t *
        }
%</add-pub>
      if$
%<*pub-date&!ay>
      year empty$
        'skip$
        { t empty$ address empty$ and
            'skip$
%<!pub-xc>            { ", " swap$ * * }
%<pub-xc>            { " " swap$ * * }
          if$
          year "year" bibinfo.check
%<dtbf>          bolden
          *
        }
      if$
%</pub-date&!ay>
%<*pub-date&ay>
      year duplicate$ empty$
%<*!blkyear>
        { "empty year in " cite$ * "; set to ????" * warning$
           pop$ "????" }
%</!blkyear>
%<*blkyear>
        { "empty year in " cite$ * warning$
           pop$ "" }
%</blkyear>
%<!dtbf>        { "year" bibinfo.check extra.label * }
%<dtbf>        { "year" bibinfo.check bolden extra.label * }
      if$
      t empty$ address empty$ and
        { * }
%<!pub-xc>        { ", " swap$ * * }
%<pub-xc>        { " " swap$ * * }
      if$
%</pub-date&ay>
%<pub-par|(pub-date&!pub-xpar)>      ")" *
%<*!(pub-date&ay)>
    }
  if$
%</!(pub-date&ay)>
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.publisher.address'}
% \changes{3.88}{1998 Dec 3}{Add macro; works with \texttt{format.org.or.pub}}
% \changes{3.89d1}{1999 July 20}{AO: encapsulate \texttt{publisher}
%    and \texttt{organization}}
% \changes{4.00}{1999 Oct 28}{Check with \texttt{bibinfo.warn}}
%    \begin{macrocode}
FUNCTION {format.publisher.address}
{ publisher "publisher" bibinfo.warn format.org.or.pub
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`format.organization.address'}
% \changes{3.88}{1998 Dec 3}{Add macro; works with \texttt{format.org.or.pub}}
%    \begin{macrocode}
FUNCTION {format.organization.address}
{ organization "organization" bibinfo.check format.org.or.pub
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`name.or.dash'}
% \changes{3.83}{1997 Feb 5}{Add function to replace repeated names by dash}
% \changes{4.06}{2003 Apr 2}{Add double and triple dashes}
% This function stores what is on the stack, compares it with previous value,
% and replaces it with a long dash if they are equal. What is on the stack
% should be author or editor names for the current entry.
%    \begin{macrocode}
%<*nmdash>
STRINGS {oldname}

FUNCTION {name.or.dash}
{ 's :=
   oldname empty$
     { s 'oldname := s }
     { s oldname =
%<*!au-col>
%<!nmd-2&!nmd-3>         { "---" }
%<nmd-2&!nmd-3>         { "---{}---" }
%<nmd-3>         { "---{}---{}---" }
%</!au-col>
%<*au-col>
%<!nmd-2&!nmd-3>         { "---" add.blank }
%<nmd-2&!nmd-3>         { "---{}---" add.blank }
%<nmd-3>         { "---{}---{}---" add.blank }
%</au-col>
         { s 'oldname := s }
       if$
     }
   if$
}

%</nmdash>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`article'}
% \changes{1.5(2.3)b}{1995 Jan 18}{Add option \texttt{yrp-x} to suppress
%    punctuation following date at beginning}
% \changes{3.0}{1995 Mar 8}{Add option \texttt{yrp-col} to add colon after
%    date at beginning}
% \changes{3.0}{1995 Mar 20}{Add option \texttt{jxper} to remove periods
%    from journal name}
% \changes{3.2}{1995 May 19}{Add option \texttt{dt-jnl} to make date part of
%    the journal specification, follows journal name.}
% \changes{3.4}{1995 Sep 28}{Add option \texttt{au-col}}
% \changes{3.6}{1995 Nov 23}{Add option \texttt{jttl-rm}}
% \changes{3.7}{1996 Feb 5}{Put \texttt{purify\$} before \texttt{emphasize}}
% \changes{3.81}{1996 Jun 26}{Add option \texttt{blk-tita} for article only}
% \changes{3.83}{1997 Feb 5}{Add option \texttt{blknt} for period before notes}
% \changes{3.88}{1999 Feb 25}{Add option \texttt{injnl} for `in' with journal
%              names}
%
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.journal} and
%   \texttt{format.journal.eid}; call \texttt{format.eprint}, and
%    \texttt{format.url}.}
% \changes{4.02}{2000 June 27}{Fix bug with texttt{injnl}}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
%    \begin{macrocode}
FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<*dt-beg&!jdt-p&!jdt-pc&!jdt-vs&!jdt-v>
  format.date "year" output.check
  date.block
%</dt-beg&!jdt-p&!jdt-pc&!jdt-vs&!jdt-v>
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
%<*!jtit-x>
  format.title "title" output.check
%<blk-com&tit-qq>  end.quote.title
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<*blk-tit|blk-tita>
%<!tit-col>  new.sentence
%<tit-col>  add.colon
%</blk-tit|blk-tita>
%</!jtit-x>
  crossref missing$
    {
      journal
%<jxper>      remove.dots
      "journal" bibinfo.check
%<!jttl-rm>      emphasize
%<injnl>      word.in swap$ *
      "journal" output.check
%<jnm-x>      add.blank
%<*!dt-beg&!dt-end&dt-jnl&!jdt-p&!jdt-pc&!jdt-vs&!jdt-v>
      format.date "year" output.check
      date.block
%</!dt-beg&!dt-end&dt-jnl&!jdt-p&!jdt-pc&!jdt-vs&!jdt-v>
      format.vol.num.pages output
%<doi&agu-doi>  format.doi output
%<*!dt-beg&!dt-end&!dt-jnl&!jdt-p&!jdt-pc&!jdt-vs&!jdt-v>
      format.date "year" output.check
%</!dt-beg&!dt-end&!dt-jnl&!jdt-p&!jdt-pc&!jdt-vs&!jdt-v>
    }
    { format.article.crossref output.nonnull
%<!pp-last>      format.pages output
    }
  if$
%<*pp-last>
  eid empty$
    { format.journal.pages }
    { format.journal.eid }
  if$
%</pp-last>
%<issn>  format.issn output
%<(doi|(url-doi&!url))&!agu-doi>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end&!jdt-p&!jdt-pc&!jdt-vs&!jdt-v>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end&!jdt-p&!jdt-pc&!jdt-vs&!jdt-v>
%<eprint>  format.eprint output
%<*revdata>
  format.url output
%</revdata>
  fin.entry
%<harnm|url-nl>  write.url
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`book'}
%\changes{2.0a}{1994 Aug 30}{Fix up \texttt{new.sentence} so not added with
%        \texttt{blk-com}}
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
%    \begin{macrocode}
FUNCTION {book}
{ output.bibitem
  author empty$
    { format.editors "author and editor" output.check
%<ay>      editor format.key output
%<!edpar&(edparc|edparxc)&!au-col>      add.blank
%<au-col>      add.colon
%<nmdash>      name.or.dash
    }
    { format.authors output.nonnull
%<au-col>      add.colon
%<nmdash>      name.or.dash
      crossref missing$
        { "author and editor" editor either.or.check }
        'skip$
      if$
    }
  if$
%<dt-beg&!pub-date>  format.date "year" output.check
%<dt-beg&!pub-date>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
  format.btitle "title" output.check
  crossref missing$
    { format.bvolume output
%<!blk-com&!blk-tit&!blk-tita>      new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%<!numser>      format.number.series output
%<pre-edn>      format.edition output
%<!blk-com&!blk-tit&!blk-tita>      new.sentence
%<numser>      format.number.series output
%<pg-bk&pg-pre>      format.book.pages output
      format.publisher.address output
    }
    {
%<!blk-com&!blk-tit&!blk-tita>      new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
      format.book.crossref output.nonnull
%<!dt-beg&!dt-end&pub-date>      format.date "year" output.check
    }
  if$
%<!pre-edn>  format.edition output
%<!dt-beg&!dt-end&!pub-date>  format.date "year" output.check
%<isbn>  format.isbn output
%<pg-bk&!pg-pre>  format.book.pages output
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end&!pub-date>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end&!pub-date>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`booklet'}
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
%    \begin{macrocode}
FUNCTION {booklet}
{ output.bibitem
  format.authors output
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<ay&dt-beg>  format.date "year" output.check
%<!ay&dt-beg>  format.date output
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
  format.title "title" output.check
%<blk-com&tit-qq>  end.quote.title
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
  howpublished "howpublished" bibinfo.check output
  address "address" bibinfo.check output
%<ay&!dt-beg&!dt-end>  format.date "year" output.check
%<!ay&!dt-beg&!dt-end>  format.date output
%<isbn>  format.isbn output
%<pg-bk>  format.book.pages output
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*ay&!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</ay&!dt-beg&dt-end>
%<*!ay&!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date output
%</!ay&!dt-beg&dt-end>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`inbook'}
% \changes{3.86}{1998 Feb 25}{Use \texttt{format.date} in place of
%     \texttt{year} alone}
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
% The medical journals, with option \texttt{dt-jnl}, have the date as part of
% the journal specification. For chapters in books, they want date and pages
% to appear at the end, with a space between them. (For journals, there is to be
% no space.) Suppress the chapter specification (for now).
%
% The \texttt{dt-jnl} option usually behaves as the default, except for some
% special entries, like this one.
%
% \changes{4.13}{2004 Feb 9}{Restore chap specification with \texttt{dt-jnl} option.}
% Restore the chapter specification (2004 Feb 9) after someone complained.
% There are still some bugs here. If some date punctuation is specified, say
%  with \texttt{yrp-semi} for a semi-colon after the year, this appears always,
%  even if there is no text following. But then this to be an unlikely wish anyway,
%  since such punctuation options are best suited for \texttt{dt-beg}.
%    \begin{macrocode}
FUNCTION {inbook}
{ output.bibitem
  author empty$
    { format.editors "author and editor" output.check
%<ay>      editor format.key output
%<au-col>      add.colon
%<nmdash>      name.or.dash
    }
    { format.authors output.nonnull
%<au-col>      add.colon
%<nmdash>      name.or.dash
      crossref missing$
        { "author and editor" editor either.or.check }
        'skip$
      if$
    }
  if$
%<dt-beg&!pub-date>  format.date "year" output.check
%<dt-beg&!pub-date>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
  format.btitle "title" output.check
  crossref missing$
    {
%<pre-pub&numser>      format.number.series output
%<pre-pub>      format.publisher.address output
      format.bvolume output
%<*dt-beg|dt-end|!dt-jnl|a|!a>
      format.chapter.pages "chapter and pages" output.check
%</dt-beg|dt-end|!dt-jnl|a|!a>
%<!blk-com&!blk-tit&!blk-tita>      new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%<!numser>      format.number.series output
%<pre-edn>      format.edition output
%<!blk-com&!blk-tit&!blk-tita>      new.sentence
%<!pre-pub&numser>      format.number.series output
%<!pre-pub>      format.publisher.address output
    }
    {
%<*dt-beg|dt-end|!dt-jnl|a|!a>
      format.chapter.pages "chapter and pages" output.check
%</dt-beg|dt-end|!dt-jnl|a|!a>
%<!blk-com&!blk-tit&!blk-tita>      new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
      format.book.crossref output.nonnull
%<!dt-beg&!dt-end&!dt-jnl&pub-date>      format.date "year" output.check
    }
  if$
%<!pre-edn>  format.edition output
%<!dt-beg&!dt-end&!dt-jnl&!pub-date>  format.date "year" output.check
%<*isbn>
  crossref missing$
    { format.isbn output }
    'skip$
  if$
%</isbn>
%<*(!dt-beg&!dt-end&dt-jnl)&!pub-date>
  format.date "year" output.check
  date.block
%</(!dt-beg&!dt-end&dt-jnl)&!pub-date>
%<pp-last>  format.pages "pages" output.check
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end&!pub-date>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end&!pub-date>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`incollection'}
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
%    \begin{macrocode}
% \changes{4.13}{2004 Feb 9}{Restore chap specification with \texttt{dt-jnl} option.}
FUNCTION {incollection}
{ output.bibitem
  format.authors "author" output.check
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<dt-beg&!pub-date>  format.date "year" output.check
%<dt-beg&!pub-date>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
%<*!jtit-x>
  format.title "title" output.check
%<blk-com&tit-qq>  end.quote.title
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%</!jtit-x>
  crossref missing$
    { format.in.ed.booktitle "booktitle" output.check
%<bt-qq>      end.quote.btitle
%<pre-pub&numser>      format.number.series output
%<pre-pub>      format.publisher.address output
%<!ser-ed>      format.bvolume output
%<!numser>      format.number.series output
%<pre-edn>      format.edition output
      format.chapter.pages output
%<!blk-com&!blk-tit&!blk-tita>      new.sentence
%<!pre-pub&numser>      format.number.series output
%<!pre-pub>      format.publisher.address output
%<!pre-edn>      format.edition output
%<!dt-beg&!dt-end&!dt-jnl&!pub-date>      format.date "year" output.check
%<isbn>      format.isbn output
    }
    { format.incoll.inproc.crossref output.nonnull
      format.chapter.pages output
    }
  if$
%<*(!dt-beg&!dt-end&dt-jnl)&!pub-date>
  format.date "year" output.check
  date.block
%</(!dt-beg&!dt-end&dt-jnl)&!pub-date>
%<pp-last>  format.pages "pages" output.check
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end&!pub-date>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end&!pub-date>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`inproceedings'}
% \changes{3.81}{1996 Sep 13}{Reorganize organization/publisher}
% \changes{3.85}{1998 Feb 5}{Fix extraneous page output without
%        \texttt{pp-last}}
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.05}{2002 Oct 21}{Fix bug with \texttt{pp-last} and \texttt{dt-beg}}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
%    \begin{macrocode}
FUNCTION {inproceedings}
{ output.bibitem
  format.authors "author" output.check
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<dt-beg&!pub-date>  format.date "year" output.check
%<dt-beg&!pub-date>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
%<*!jtit-x>
  format.title "title" output.check
%<blk-com&tit-qq>  end.quote.title
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%</!jtit-x>
  crossref missing$
    { format.in.ed.booktitle "booktitle" output.check
%<bt-qq>      end.quote.btitle
%<*!pre-pub>
%<!ser-ed>      format.bvolume output
%<!numser>      format.number.series output
%<(dt-beg|dt-end|!dt-jnl)&!pp-last>      format.pages output
%</!pre-pub>
%<!blk-com&!blk-tit&!blk-tita>      new.sentence
%<numser>      format.number.series output
      publisher empty$
        { format.organization.address output }
        { organization "organization" bibinfo.check output
          format.publisher.address output
        }
      if$
%<!dt-beg&!dt-end&!dt-jnl&!pub-date>      format.date "year" output.check
%<*pre-pub>
      format.bvolume output
%<!numser>      format.number.series output
%<(dt-beg|dt-end|!dt-jnl)&!pp-last>      format.pages output
%</pre-pub>
%<isbn>      format.isbn output
%<issn>      format.issn output
    }
    { format.incoll.inproc.crossref output.nonnull
%<(dt-beg|dt-end|!dt-jnl)&!pp-last>      format.pages output
    }
  if$
%<*!dt-beg&!dt-end&dt-jnl&!pp-last>
%<!pub-date>  format.date "year" output.check
%<!pub-date>  date.block
%<jdt-v|jdt-vs|jdt-p|!jdt-pc>  add.blank
  format.pages "pages" output.check
%</!dt-beg&!dt-end&dt-jnl&!pp-last>
%<pp-last>  format.pages "pages" output.check
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end&!pub-date>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end&!pub-date>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`conference'}
%    \begin{macrocode}
FUNCTION {conference} { inproceedings }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`manual'}
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
%    \begin{macrocode}
%<*ay>
FUNCTION {manual}
{ output.bibitem
  format.authors output
  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<dt-beg>  format.date "year" output.check
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
  format.btitle "title" output.check
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%<!blk-com&!blk-tit&!blk-tita>  organization address new.block.checkb
  organization "organization" bibinfo.check output
  address "address" bibinfo.check output
  format.edition output
%<!dt-beg&!dt-end>  format.date "year" output.check
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%</ay>
%<*!ay>
FUNCTION {manual}
{ output.bibitem
  author empty$
    { organization "organization" bibinfo.check
      duplicate$ empty$ 'pop$
        { output
          address "address" bibinfo.check output
        }
      if$
    }
    { format.authors output.nonnull }
  if$
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<ay&dt-beg>  format.date "year" output.check
%<!ay&dt-beg>  format.date output
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
  format.btitle "title" output.check
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
  author empty$
    { organization empty$
        {
%<!blk-com&!blk-tit&!blk-tita>          address new.block.checka
          address "address" bibinfo.check output
        }
        'skip$
      if$
    }
    {
%<!blk-com&!blk-tit&!blk-tita>      organization address new.block.checkb
      organization "organization" bibinfo.check output
      address "address" bibinfo.check output
    }
  if$
  format.edition output
%<ay&!dt-beg&!dt-end>  format.date "year" output.check
%<!ay&!dt-beg&!dt-end>  format.date output
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*ay&!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</ay&!dt-beg&dt-end>
%<*!ay&!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date output
%</!ay&!dt-beg&dt-end>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%</!ay>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`mastersthesis'}
% \changes{2.0}{1994 Feb 7}{Add \texttt{thtit-a} to format thesis titles like
%         articles instead of books.}
% \changes{3.89d1}{1999 July 20}{AO: school via \texttt{bibinfo.warn}; call
%     \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.03}{2002 Jan 14}{Add \texttt{thtit-x}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
% To format a master's thesis.
%    \begin{macrocode}
FUNCTION {mastersthesis}
{ output.bibitem
  format.authors "author" output.check
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<dt-beg>  format.date "year" output.check
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
%<*!thtit-x>
%<!thtit-a>  format.btitle
%<thtit-a>  format.title
  "title" output.check
%<thtit-a&blk-com&tit-qq>  end.quote.title
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%</!thtit-x>
  bbl.mthesis format.thesis.type output.nonnull
  school "school" bibinfo.warn output
  address "address" bibinfo.check output
%<!dt-beg&!dt-end>  format.date "year" output.check
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`misc'}
%    \begin{macrocode}
FUNCTION {misc}
{ output.bibitem
  format.authors output
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<ay&dt-beg>  format.date "year" output.check
%<!ay&dt-beg>  format.date output
%<*ay>
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
  format.title output
%<blk-com&tit-qq>  end.quote.title
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%</ay>
%<*!ay>
%<!blk-com&!blk-tit&!blk-tita>  title howpublished new.block.checkb
  format.title output
%<blk-com&tit-qq>  end.quote.title
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%<!blk-com&!blk-tit&!blk-tita>  howpublished new.block.checka
%</!ay>
  howpublished "howpublished" bibinfo.check output
%<ay&!dt-beg&!dt-end>  format.date "year" output.check
%<!ay&!dt-beg&!dt-end>  format.date output
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*ay&!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</ay&!dt-beg&dt-end>
%<*!ay&!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date output
%</!ay&!dt-beg&dt-end>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
%<!ay>  empty.misc.check
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`phdthesis'}
% \changes{2.0}{1994 Feb 7}{Add \texttt{thtit-a} to format thesis titles like
%         articles instead of books.}
% \changes{3.89d1}{1999 July 20}{AO: school via \texttt{bibinfo.warn}; call
%     \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.03}{2002 Jan 14}{Add \texttt{thtit-x}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
% To format a doctoral thesis.
%    \begin{macrocode}
FUNCTION {phdthesis}
{ output.bibitem
  format.authors "author" output.check
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<dt-beg>  format.date "year" output.check
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
%<*!thtit-x>
%<!thtit-a>  format.btitle
%<thtit-a>  format.title
  "title" output.check
%<thtit-a&blk-com&tit-qq>  end.quote.title
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%</!thtit-x>
  bbl.phdthesis format.thesis.type output.nonnull
  school "school" bibinfo.warn output
  address "address" bibinfo.check output
%<!dt-beg&!dt-end>  format.date "year" output.check
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`presentation'}
%    \begin{macrocode}
%<*pres>
FUNCTION {presentation}
{ output.bibitem
  format.authors output
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.title output
%<blk-com&tit-qq>  end.quote.title
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
  format.organization.address "organization and address" output.check
  month "month" output.check
  year "year" output.check
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
  new.sentence
  type missing$ 'skip$
  {"(" type capitalize * ")" * output}
    if$
%<*url-blk&!harnm>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm>
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%</pres>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`proceedings'}
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
% \changes{4.16}{2006 Feb 15}{For numerical, the number/series could be missing when editor there; fixed}
%    \begin{macrocode}
%<*ay>
FUNCTION {proceedings}
{ output.bibitem
  format.editors output
  editor format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<dt-beg>  format.date "year" output.check
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
  format.btitle "title" output.check
  format.bvolume output
%<!numser>  format.number.series output
%<!blk-com&!blk-tit&!blk-tita>  new.sentence
%<numser>  format.number.series output
  publisher empty$
    { format.organization.address output }
    { organization "organization" bibinfo.check output
      format.publisher.address output
    }
  if$
%<!dt-beg&!dt-end&!pub-date>  format.date "year" output.check
%<isbn>  format.isbn output
%<issn>  format.issn output
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end&!pub-date>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end&!pub-date>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%</ay>
%    \end{macrocode}
% \changes{4.32}{2011 Mar 28}{For numerical, fix bug when \texttt{numser} absent}
%    \begin{macrocode}
%<*!ay>
FUNCTION {proceedings}
{ output.bibitem
  editor empty$
    { organization "organization" bibinfo.check output
    }
    { format.editors output.nonnull }
  if$
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<dt-beg>  format.date "year" output.check
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
  format.btitle "title" output.check
  format.bvolume output
%<!numser>  format.number.series output
  editor empty$
    { publisher empty$
%<!numser>        'skip$
%<numser>        {  format.number.series output }
        {
%<!blk-com&!blk-tit&!blk-tita>          new.sentence
%<numser>          format.number.series output
          format.publisher.address output
        }
      if$
    }
    { publisher empty$
        {
%<!blk-com&!blk-tit&!blk-tita>          new.sentence
%<numser>          format.number.series output
          format.organization.address output }
        {
%<!blk-com&!blk-tit&!blk-tita>          new.sentence
%<numser>          format.number.series output
          organization "organization" bibinfo.check output
          format.publisher.address output
        }
      if$
     }
  if$
%<!dt-beg&!dt-end&!pub-date>      format.date "year" output.check
%<isbn>  format.isbn output
%<issn>  format.issn output
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%</!ay>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`techreport'}
% \changes{3.5}{1995 Oct 4}{Add option \texttt{trtit-b}}
% \changes{3.83}{1997 Feb 25}{Add option \texttt{trnum-it}}
% \changes{3.89d1}{1999 July 20}{AO: institution via \texttt{bibinfo.warn}; call
%  \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
%    \begin{macrocode}
FUNCTION {techreport}
{ output.bibitem
  format.authors "author" output.check
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<dt-beg>  format.date "year" output.check
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
%<trtit-b>  format.btitle
%<!trtit-b>  format.title
  "title" output.check
%<!trtit-b&blk-com&tit-qq>  end.quote.title
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<blk-tit&!tit-col>  new.sentence
%<blk-tit&tit-col>  add.colon
%<!trnum-it>  format.tr.number output.nonnull
%<trnum-it>  format.tr.number emphasize output.nonnull
  institution "institution" bibinfo.warn output
  address "address" bibinfo.check output
%<!dt-beg&!dt-end>  format.date "year" output.check
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note output
%<*!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date "year" output.check
%</!dt-beg&dt-end>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`unpublished'}
% \changes{3.85}{1997 Nov 25}{Fix date at normal end}
% \changes{3.89d1}{1999 July 20}{AO: call \texttt{format.eprint}, and \texttt{format.url}.}
% \changes{4.10}{2003 May 28}{Add \texttt{format.doi}}
%    \begin{macrocode}
FUNCTION {unpublished}
{ output.bibitem
  format.authors "author" output.check
%<ay>  author format.key output
%<au-col>  add.colon
%<nmdash>  name.or.dash
%<ay&dt-beg>  format.date "year" output.check
%<!ay&dt-beg>  format.date output
%<dt-beg>  date.block
%<!dt-beg&!blk-com&!blk-tit&!blk-tita>  new.block
  format.title "title" output.check
%<blk-com&tit-qq>  end.quote.title
%<ay&!dt-beg&!dt-end>  format.date "year" output.check
%<!ay&!dt-beg&!dt-end>  format.date output
%<doi|(url-doi&!url)>  format.doi output
%<*url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.url output
%</url-blk&!harnm&!revdata>
%<!blk-com&!blk-tit&!blk-tita>  new.block
%<(blk-com|blk-tit|blk-tita)&blknt>  new.sentence
  format.note "note" output.check
%<*ay&!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date output
%</ay&!dt-beg&dt-end>
%<*!ay&!dt-beg&dt-end>
%<!blk-com&!blk-tit&!blk-tita>  new.block
  format.date output
%</!ay&!dt-beg&dt-end>
%<eprint>  format.eprint output
%<revdata>  format.url output
  fin.entry
%<(harnm|url-nl)&!revdata>  write.url
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`default.type'}
%    \begin{macrocode}
FUNCTION {default.type} { misc }
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
READ
%    \end{macrocode}
%
%    \begin{macrocode}
%<*ay|alph|!seq-no>
%    \end{macrocode}
%
% \begin{macro}{`sortify'}
% \changes{3.8}{1996 Feb 29}{Do not allow unsorted alphas}
% In \texttt{btxbst.doc}/\texttt{.mbs}, the \texttt{sortify} function is
% left out for unsorted alpha-style citations. This leads to an error,
% because it is still used. So leave it in here too. \emph{In fact, do away
% with unsorted alpha style, since it is as useless as unsorted author--year
% listings.}
%    \begin{macrocode}
FUNCTION {sortify}
{ purify$
  "l" change.case$
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
INTEGERS { len }
%    \end{macrocode}
%
% \begin{macro}{`chop.word'}
%    \begin{macrocode}
FUNCTION {chop.word}
{ 's :=
  'len :=
  s #1 len substring$ =
    { s len #1 + global.max$ substring$ }
    's
  if$
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%<*!ay&alph>
%    \end{macrocode}
%
% \begin{macro}{`format.lab.names'}
% \changes{3.8}{1996 Feb 29}{Add option \texttt{alph} for \texttt{alpha.bst}
%    style of labels}
% \changes{3.84}{1997 Nov 4}{Add options \texttt{alf-1} and \texttt{alf-f}}
% \changes{3.85}{1997 Dec 1}{Add option \texttt{jnrlab}}
% \changes{3.85}{1996 Feb 6}{Recode author font}
% The function \texttt{format.lab.names} formats by author--year or the
% \texttt{alpha} style as in the original \texttt{alpha.bst}.
% Only major difference is that there should be no unsorted (\texttt{seq-no})
% versions of this. Patashnik was clearly very unhappy about accommodating
% such an animal, and in fact, his unsorted alpha style crashes \btx.
% I also provide the \texttt{vonx} option here to ignore the \textsl{von}
% part of the name.
%
%    \begin{macrocode}
INTEGERS { et.al.char.used }
%    \end{macrocode}
%
%    \begin{macrocode}
FUNCTION {initialize.et.al.char.used}
{ #0 'et.al.char.used :=
}
%    \end{macrocode}
%
%    \begin{macrocode}
EXECUTE {initialize.et.al.char.used}
%    \end{macrocode}
%
%    \begin{macrocode}
FUNCTION {format.lab.names}
{ 's :=
%<*alf-1>
%<!vonx>  s #1 "{v{}}{l{}}" format.name$
%<vonx>  s #1 "{l{}}" format.name$
  duplicate$ text.length$ #2 <
    { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
      'skip$
    if$
%</alf-1>
%<*!alf-1&alf-f>
%<!vonx>  s #1 "{vv{}}{ll}" format.name$
%<vonx>  s #1 "{ll}" format.name$
%</!alf-1&alf-f>
%<*!alf-1&!alf-f>
  s num.names$ 'numnames :=
  numnames #1 >
    { numnames #4 >
        { #3 'namesleft := }
        { numnames 'namesleft := }
      if$
      #1 'nameptr :=
      ""
        { namesleft #0 > }
        { nameptr numnames =
            { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
                { "{\etalchar{+}}" *
                  #1 'et.al.char.used :=
                }
%<!vonx>                { s nameptr "{v{}}{l{}}" format.name$ * }
%<vonx>                { s nameptr "{l{}}" format.name$ * }
              if$
            }
%<!vonx>            { s nameptr "{v{}}{l{}}" format.name$ * }
%<vonx>            { s nameptr "{l{}}" format.name$ * }
          if$
          nameptr #1 + 'nameptr :=
          namesleft #1 - 'namesleft :=
        }
      while$
      numnames #4 >
        { "{\etalchar{+}}" *
          #1 'et.al.char.used :=
        }
        'skip$
      if$
    }
%<!vonx>    { s #1 "{v{}}{l{}}" format.name$
%<vonx>    { s #1 "{l{}}" format.name$
      duplicate$ text.length$ #2 <
        { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
        'skip$
      if$
    }
  if$
%</!alf-1&!alf-f>
}
%    \end{macrocode}
%
%    \begin{macrocode}
%</!ay&alph>
%    \end{macrocode}
% \changes{3.89}{1999 May 20}{Reset \texttt{t}; might still be ``others''
%         from last format function}
% The function for the standard citation: one or two authors cited full, but for
%  more than two, only the first with \emph{et~al.} given.
%    \begin{macrocode}
%<*ay&!mcite>
FUNCTION {format.lab.names}
{ 's :=
  "" 't :=
%<!jnrlab>  s #1 "{vv~}{ll}" format.name$
%<*jnrlab>
%<!nm-rv&!nm-rvv&!nm-rvx&!nm-rvcx>  s #1 "{vv~}{ll}{, jj}" format.name$
%<nm-rv|nm-rvv|nm-rvx|nm-rvcx>  s #1 "{vv~}{ll}{ jj}" format.name$
%</jnrlab>
%<lab&and-rm>  cite.name.font
  s num.names$ duplicate$
  #2 >
    { pop$
%<lab&!and-rm&(etal-it|etal-rm)>      cite.name.font
%<*!etal-it>
%<lab&and-rm&!etal-rm>      " " * bbl.etal cite.name.font *
%<!lab|!and-rm|etal-rm>      " " * bbl.etal *
%</!etal-it>
%<etal-it>      " " * bbl.etal emphasize *
%<lab&!and-rm&!(etal-it|etal-rm)>      cite.name.font
%<lab&!and-rm>      "others" 't :=
    }
    { #2 <
        'skip$
        { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
            {
% %<lab&!and-rm&(etal-it|etal-rm)>              cite.name.font
%<*!etal-it>
%<lab&and-rm&!etal-rm>              " " * bbl.etal cite.name.font *
%<!lab|!and-rm|etal-rm>              " " * bbl.etal *
%</!etal-it>
%<etal-it>              " " * bbl.etal emphasize *
%<lab&!and-rm&!(etal-it|etal-rm)>              cite.name.font
%<lab&!and-rm>              "others" 't :=
            }
%<*!harnm>
%<*!amper>
            { bbl.and space.word * s #2 "{vv~}{ll}" format.name$
%<lab&and-rm>              cite.name.font
              * }
%</!amper>
%<*amper>
            { " \& " * s #2 "{vv~}{ll}" format.name$
%<lab&and-rm>              cite.name.font
              * }
%</amper>
%</!harnm>
%<*harnm>
            { " \harvardand{} " * s #2 "{vv~}{ll}" format.name$
%<lab&and-rm>              cite.name.font
              * }
%</harnm>
          if$
        }
      if$
    }
  if$
%<*lab&!and-rm>
  t "others" =
    'skip$
    { cite.name.font }
  if$
%</lab&!and-rm>
}

%</ay&!mcite>
%    \end{macrocode}
%
% \changes{4.20}{2007 Apr 23}{Add citations with more than one author with \emph{et~al.}}
% \changes{4.20}{2007 Apr 24}{Select number of authors before truncating}
% \changes{4.30}{2008 Aug 25}{Up to 6 authors possible in citation}
% The code for formating author--year citations with more than one author
% before \emph{et al.} or selecting a number other than two for truncating,
% is much the same as the \texttt{format.full.names} function.
%    \begin{macrocode}
%<*ay&mcite>
FUNCTION {format.lab.names}
{'s :=
 "" 't :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr
%<!jnrlab>      "{vv~}{ll}" format.name$
%<*jnrlab>
%<!nm-rv&!nm-rvv&!nm-rvx&!nm-rvcx>      "{vv~}{ll}{, jj}" format.name$
%<nm-rv|nm-rvv|nm-rvx|nm-rvcx>      "{vv~}{ll}{ jj}" format.name$
%</jnrlab>
%<lab&and-rm>      cite.name.font
      't :=
      nameptr #1 >
        {
%<mct-1>          nameptr #2 =
%<mct-2>          nameptr #3 =
%<mct-3>          nameptr #4 =
%<mct-4>          nameptr #5 =
%<mct-5>          nameptr #6 =
%<mct-6>          nameptr #7 =
%<mct-x2>          numnames #2 > and
%<mct-x3>          numnames #3 > and
%<mct-x4>          numnames #4 > and
%<mct-x5>          numnames #5 > and
%<mct-x6>          numnames #6 > and
            { "others" 't :=
              #1 'namesleft := }
            'skip$
          if$
          namesleft #1 >
            { ", " * t * }
            {
              s nameptr "{ll}" format.name$ duplicate$ "others" =
                { 't := }
                { pop$ }
              if$
              t "others" =
                {
%<lab&!and-rm&(etal-it|etal-rm)>                  cite.name.font
%<*!etal-it>
%<lab&and-rm&!etal-rm>                  " " * bbl.etal cite.name.font *
%<!lab|!and-rm|etal-rm>                  " " * bbl.etal *
%</!etal-it>
%<etal-it>                  " " * bbl.etal emphasize *
%<lab&!and-rm&!(etal-it|etal-rm)>                  cite.name.font
                }
                {
%<*!harnm>
%<*!and-xcom>
                  numnames #2 >
                    { "," * }
                    'skip$
                  if$
%</!and-xcom>
%<!amper>                  bbl.and
%<amper>                  "\&"
%</!harnm>
%<harnm>                  "\harvardand{}"
                  space.word * t *
                }
              if$
            }
          if$
        }
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
%<*lab&!and-rm>
  t "others" =
    'skip$
    { cite.name.font }
  if$
%</lab&!and-rm>
}

%</ay&mcite>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`author.key.label'}
% \begin{macro}{`author.editor.key.label'}
% \begin{macro}{`author.key.organization.label'}
% \begin{macro}{`editor.key.organization.label'}
% \begin{macro}{`editor.key.label'}
% Have to be very careful with the options \texttt{ay}, \texttt{alph}, and
% \texttt{seq-no} here. The first two are actually mutually exclusive, and
% \texttt{ay} should dominate. The \texttt{seq-no} option only applies for
% numerical (\texttt{!ay}) but not alphabetic (\texttt{alph}) selections.
% This whole block of coding dealing with labels is only included for
% author--year or alphabetic or ordered numerical.
% That is, \texttt{ay} or \texttt{alph} or \texttt{!seq-no} is true.
%    \begin{macrocode}
%<*ay|alph>
FUNCTION {author.key.label}
{ author empty$
    { key empty$
        { cite$ #1 #3 substring$ }
%<ay>        'key
%<!ay>        { key #3 text.prefix$ }
      if$
    }
    { author format.lab.names }
  if$
}

FUNCTION {author.editor.key.label}
{ author empty$
    { editor empty$
        { key empty$
            { cite$ #1 #3 substring$ }
%<ay>            'key
%<!ay>            { key #3 text.prefix$ }
          if$
        }
        { editor format.lab.names }
      if$
    }
    { author format.lab.names }
  if$
}

%</ay|alph>
%<*!ay&alph>
FUNCTION {author.key.organization.label}
{ author empty$
    { key empty$
        { organization empty$
            { cite$ #1 #3 substring$ }
            { "The " #4 organization chop.word #3 text.prefix$ }
          if$
        }
        { key #3 text.prefix$ }
      if$
    }
    { author format.lab.names }
  if$
}

FUNCTION {editor.key.organization.label}
{ editor empty$
    { key empty$
        { organization empty$
            { cite$ #1 #3 substring$ }
            { "The " #4 organization chop.word #3 text.prefix$ }
          if$
        }
        { key #3 text.prefix$ }
      if$
    }
    { editor format.lab.names }
  if$
}

%</!ay&alph>
%<*ay>
FUNCTION {editor.key.label}
{ editor empty$
    { key empty$
        { cite$ #1 #3 substring$ }
        'key
      if$
    }
    { editor format.lab.names }
  if$
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{`calc.short.authors'}
% \changes{3.3}{1995 Sep 4}{Add function to store short list of authors
%     for later test}
%    \begin{macrocode}
FUNCTION {calc.short.authors}
{ type$ "book" =
  type$ "inbook" =
  or
    'author.editor.key.label
    { type$ "proceedings" =
        'editor.key.label
        'author.key.label
      if$
    }
  if$
  'short.list :=
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`calc.label'}
% \changes{1.5(2.3)a}{1994 Oct 11}{Add option \texttt{note-yr}}
% \changes{3.0}{1995 Mar 3}{Add options \texttt{lab-bf} and \texttt{lab-sc}}
% \changes{3.3}{1995 Sep 4}{Use \texttt{calc.short.authors}}
% \changes{3.8}{1996 Feb 29}{Add \texttt{calc.label} from \texttt{alpha.bst}}
% \changes{3.89}{1999 May 12}{Add \texttt{keyxyr} option}
%    \begin{macrocode}
FUNCTION {calc.label}
{ calc.short.authors
  short.list
%<!(har|ast|cay|nmd|alk|cn)>  "("
%<har|ast|cay|nmd|alk|cn>  ", "
  *
  year duplicate$ empty$
%<keyxyr>  short.list key field.or.null = or
%<(blkyear|keyxyr)>     { pop$ "" }
%<!(blkyear|keyxyr)>     { pop$ "????" }
%<!note-yr>     { purify$ #-1 #4 substring$ }
%<note-yr>     'skip$
  if$
  *
  'label :=
}

%</ay>
%<*!ay&alph>
FUNCTION {calc.label}
{ type$ "book" =
  type$ "inbook" =
  or
    'author.editor.key.label
    { type$ "proceedings" =
        'editor.key.organization.label
        { type$ "manual" =
            'author.key.organization.label
            'author.key.label
          if$
        }
      if$
    }
  if$
  duplicate$
  year field.or.null purify$ #-1 #2 substring$
  *
  'label :=
  year field.or.null purify$ #-1 #4 substring$
  *
  sortify 'sort.label :=
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</!ay&alph>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*ay>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*har|cay|nmd|ast|cn>
%    \end{macrocode}
%
% \begin{macro}{`calc.short.label'}
% \changes{3.3}{1995 Sep 4}{Use \texttt{calc.short.authors}}
%
%    \begin{macrocode}
FUNCTION {calc.short.label}
{ calc.short.authors short.list
  'label :=
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</har|cay|nmd|ast|cn>
%    \end{macrocode}
%
%    \begin{macrocode}
%</ay>
%    \end{macrocode}
%
% \begin{macro}{`sort.format.names'}
% \changes{1.7(2.5)}{1995 Feb 9}{Make ordering of `et al' works by year
%    and authors and not just year}
% \changes{3.0}{1995 Feb 27}{Option \texttt{nm-revf} to act just as default}
% \changes{3.2}{1995 Jun 16}{Add option \texttt{vonx} so sorting ignores the
%   \emph{von} part of the name}
% \changes{3.5}{1995 Oct 24}{For limited authors, sort only on those present}
% \changes{3.5}{1995 Oct 24}{`Et al' considered author before all others}
% \changes{3.83}{1997 Feb 25}{`Et al' considered author after all others}
% \changes{4.30}{2008 Aug 25}{Improve sorting for `others', both in bib file and when truncated}
% \changes{4.30}{2008 Aug 25}{Add \texttt{seq-labc}, like \texttt{seq-lab} but cite order
%   used instead of co-authors and title/cite-key}
% \changes{4.30}{2008 Aug 27}{Fix bug for \texttt{nm-rvvc}}
%    \begin{macrocode}
FUNCTION {sort.format.names}
{ 's :=
  #1 'nameptr :=
  ""
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr
%<*xintls>
%<!vonx>      "{vv{ } }{ll{ }}"
%<vonx>      "{ll{ }}"
%</xintls>
%<*!xintls>
%<*!nm-init&!nm-rev&!nm-rev1&!nm-rv&!nm-rvx&!nm-rvcx&!nm-rvv&!nm-rvvc>
%<!vonx>      "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}"
%<vonx>      "{ll{ }}{  ff{ }}{  jj{ }}"
%</!nm-init&!nm-rev&!nm-rev1&!nm-rv&!nm-rvx&!nm-rvcx&!nm-rvv&!nm-rvvc>
%<*nm-init|nm-rev|nm-rev1|nm-rv|nm-rvx|nm-rvcx|nm-rvv|nm-rvvc>
%<!vonx>      "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}"
%<vonx>      "{ll{ }}{  f{ }}{  jj{ }}"
%</nm-init|nm-rev|nm-rev1|nm-rv|nm-rvx|nm-rvcx|nm-rvv|nm-rvvc>
%</!xintls>
      format.name$ 't :=
      nameptr #1 >
        {
%<*nmlm>
%<m1>          nameptr #1
%<m2>          nameptr #2
%<m3>          nameptr #3
%<m4>          nameptr #4
%<m5>          nameptr #5
%<m6>          nameptr #6
%<m7>          nameptr #7
%<m8>          nameptr #8
%<m9>          nameptr #9
%<m0>          nameptr #0
%<m10>          #10 +
%<m20>          #20 +
%<m30>          #30 +
%<m40>          #40 +
%<m50>          #50 +
%<m60>          #60 +
%<m70>          #70 +
%<m80>          #80 +
%<m90>          #90 +
          #1 + =
%<x1>          numnames #1
%<x2>          numnames #2
%<x3>          numnames #3
%<x4>          numnames #4
%<x5>          numnames #5
%<x6>          numnames #6
%<x7>          numnames #7
%<x8>          numnames #8
%<x9>          numnames #9
%<x0>          numnames #0
%<x10>          #10 +
%<x20>          #20 +
%<x30>          #30 +
%<x40>          #40 +
%<x50>          #50 +
%<x60>          #60 +
%<x70>          #70 +
%<x80>          #80 +
%<x90>          #90 +
          > and
            { "others" 't :=
              #1 'namesleft := }
            'skip$
          if$
%</nmlm>
          "   "  *
          namesleft #1 = t "others" = and
            { "zzzzz" 't := }
            'skip$
          if$
%<*seq-lab|seq-key|seq-labc>
          numnames #2 > nameptr #2 = and
            { "zz" * year field.or.null * "   " *
%<seq-labc>              #1 'namesleft :=
            }
%<seq-labc>            { t sortify * }
%<!seq-labc>            'skip$
          if$
%</seq-lab|seq-key|seq-labc>
%<!seq-labc>          t sortify *
        }
        { t sortify * }
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`sort.format.title'}
%    \begin{macrocode}
FUNCTION {sort.format.title}
{ 't :=
  "A " #2
    "An " #3
      "The " #4 t chop.word
    chop.word
  chop.word
  sortify
  #1 global.max$ substring$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`author.sort'}
%    \begin{macrocode}
FUNCTION {author.sort}
{ author empty$
    { key empty$
        { "to sort, need author or key in " cite$ * warning$
          ""
        }
        { key sortify }
      if$
    }
    { author sort.format.names }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`author.editor.sort'}
%    \begin{macrocode}
FUNCTION {author.editor.sort}
{ author empty$
    { editor empty$
        { key empty$
            { "to sort, need author, editor, or key in " cite$ * warning$
              ""
            }
            { key sortify }
          if$
        }
        { editor sort.format.names }
      if$
    }
    { author sort.format.names }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`negate.year'}
% \changes{4.03}{2002 Jan 14}{Add function for ordering by descending years}
% This function negates the year by substituting each digit by its
% complement. That is, 0 $\rightarrow$ 9, 1 $\rightarrow$ 8, etc. This is used
% to provide ordering by descending year (latest year first).
%    \begin{macrocode}
%<*seq-yrr&!seq-yr>
FUNCTION {negate.year}
{ year empty$
    { "99999" }
    { year #1 #1 substring$ chr.to.int$ #105 swap$ - int.to.chr$
      year #2 #1 substring$ chr.to.int$ #105 swap$ - int.to.chr$ *
      year #3 #1 substring$ chr.to.int$ #105 swap$ - int.to.chr$ *
      year #4 #1 substring$ chr.to.int$ #105 swap$ - int.to.chr$ *
    }
    if$
}
%</seq-yrr&!seq-yr>
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%<*ay>
%    \end{macrocode}
%
% \begin{macro}{`editor.sort'}
%    \begin{macrocode}
FUNCTION {editor.sort}
{ editor empty$
    { key empty$
        { "to sort, need editor or key in " cite$ * warning$
          ""
        }
        { key sortify }
      if$
    }
    { editor sort.format.names }
  if$
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%<*seq-no>
%    \end{macrocode}
%
%    \begin{macrocode}
INTEGERS { seq.num }
%    \end{macrocode}
%
% \begin{macro}{`init.seq'}
%    \begin{macrocode}
FUNCTION {init.seq}
{ #0 'seq.num :=}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
EXECUTE {init.seq}
%    \end{macrocode}
%
% \begin{macro}{`int.to.fix'}
%    \begin{macrocode}
FUNCTION {int.to.fix}
{ "000000000" swap$ int.to.str$ *
  #-1 #10 substring$
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</seq-no>
%    \end{macrocode}
%
% \begin{macro}{`presort'}
% \changes{3.81}{1996 Sep 16}{Add option \texttt{seq-no} to author--year}
% For unsorted author--year, make up the final sorting order in
% \texttt{sort.label} with the original sequence number, for unsorting later.
%    \begin{macrocode}
FUNCTION {presort}
{ calc.label
  label sortify
  "    "
  *
%<*!seq-no>
  type$ "book" =
  type$ "inbook" =
  or
    'author.editor.sort
    { type$ "proceedings" =
        'editor.sort
        'author.sort
      if$
    }
  if$
  #1 entry.max$ substring$
%</!seq-no>
%<*seq-no>
  seq.num #1 + 'seq.num :=
  seq.num  int.to.fix
%</seq-no>
  'sort.label :=
  sort.label
  *
%<seq-yr>  "    " * year field.or.null *
%<seq-yrr&!seq-yr>  "    " * negate.year field.or.null *
%<*!seq-key&!seq-labc&!seq-yr&!seq-yrr>
  "    "
  *
  title field.or.null
  sort.format.title
  *
%</!seq-key&!seq-labc&!seq-yr&!seq-yrr>
%<seq-key|seq-yr|seq-yrr>  "    " * cite$ *
  #1 entry.max$ substring$
  'sort.key$ :=
%  "For " cite$ * ", sort.key=" * sort.key$ * warning$
}

%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</ay>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*!ay>
%    \end{macrocode}
%
% \begin{macro}{`author.organization.sort'}
%    \begin{macrocode}
FUNCTION {author.organization.sort}
{ author empty$
    { organization empty$
        { key empty$
            { "to sort, need author, organization, or key in " cite$ * warning$
              ""
            }
            { key sortify }
          if$
        }
        { "The " #4 organization chop.word sortify }
      if$
    }
    { author sort.format.names }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`editor.organization.sort'}
%    \begin{macrocode}
FUNCTION {editor.organization.sort}
{ editor empty$
    { organization empty$
        { key empty$
            { "to sort, need editor, organization, or key in " cite$ * warning$
              ""
            }
            { key sortify }
          if$
        }
        { "The " #4 organization chop.word sortify }
      if$
    }
    { editor sort.format.names }
  if$
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`presort'}
%    \begin{macrocode}
FUNCTION {presort}
%<*alph>
{ calc.label
  sort.label
  "    "
  *
  type$ "book" =
%</alph>
%<!alph>{ type$ "book" =
  type$ "inbook" =
  or
    'author.editor.sort
    { type$ "proceedings" =
        'editor.organization.sort
        { type$ "manual" =
            'author.organization.sort
            'author.sort
          if$
        }
      if$
    }
  if$
%<alph>  *
  "    "
  *
%<seq-yrr>  negate.year field.or.null sortify
%<!seq-yrr>  year field.or.null sortify
%<!(seq-yr|seq-yrr)|alph>  *
  "    "
  *
%<(seq-yr|seq-yrr)&!alph>  swap$ *
  title field.or.null
  sort.format.title
  *
  #1 entry.max$ substring$
  'sort.key$ :=
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</!ay>
%    \end{macrocode}
%
%    \begin{macrocode}
ITERATE {presort}
%    \end{macrocode}
%
%    \begin{macrocode}
SORT
%    \end{macrocode}
%
%    \begin{macrocode}
%</ay|alph|!seq-no>
%    \end{macrocode}
%
% With version~6.0 of \texttt{natbib}, the author-year styles can also be
% used for numerical citations; then the \texttt{thebibliography} environment
% must have an argument indicating the length of the longest label.
% Simply count the references and add this number as the argument.
%    \begin{macrocode}
%<*ay>
%    \end{macrocode}
%
%    \begin{macrocode}
STRINGS { last.label next.extra }
%    \end{macrocode}
%
% With computer-generated articles, it is possible to have more than 26 articles
% in one year. It has finally occurred that the extra labels go beyond `z'.
% The current code now allows for `aa', \dots `az', 'ba', \dots `zz'. This
% code was provided by Joseph Wright (2007 Oct 10).
%    \begin{macrocode}
INTEGERS { last.extra.num last.extra.num.extended last.extra.num.blank number.label }
%    \end{macrocode}
%
% \begin{macro}{`initialize.extra.label.stuff'}
% \changes{4.22}{2007 Oct 10}{Add code to allow extra labels to go beyond 26}
%    \begin{macrocode}
FUNCTION {initialize.extra.label.stuff}
{ #0 int.to.chr$ 'last.label :=
  "" 'next.extra :=
  #0 'last.extra.num :=
  "a" chr.to.int$ #1 - 'last.extra.num.blank :=
  last.extra.num.blank 'last.extra.num.extended :=
  #0 'number.label :=
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`forward.pass'}
% \changes{3.4}{1995 Sep 5}{Include number of references in argument to
%     \texttt{thebibliography} environment}
% \changes{4.22}{2007 Oct 10}{Add code to allow extra labels to go beyond 26}
%    \begin{macrocode}
FUNCTION {forward.pass}
{ last.label label =
    { last.extra.num #1 + 'last.extra.num :=
      last.extra.num "z" chr.to.int$ >
       { "a" chr.to.int$ 'last.extra.num :=
         last.extra.num.extended #1 + 'last.extra.num.extended :=
       }
       'skip$
      if$
      last.extra.num.extended last.extra.num.blank >
        { last.extra.num.extended int.to.chr$
          last.extra.num int.to.chr$
          * 'extra.label := }
        { last.extra.num int.to.chr$ 'extra.label := }
      if$
    }
    { "a" chr.to.int$ 'last.extra.num :=
      "" 'extra.label :=
      label 'last.label :=
    }
  if$
  number.label #1 + 'number.label :=
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</ay>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*!ay&alph>
%    \end{macrocode}
%
%    \begin{macrocode}
STRINGS { longest.label last.sort.label next.extra }
%    \end{macrocode}
%
%    \begin{macrocode}
INTEGERS { longest.label.width last.extra.num }
%    \end{macrocode}
%
% \begin{macro}{`initialize.longest.label'}
%    \begin{macrocode}
FUNCTION {initialize.longest.label}
{ "" 'longest.label :=
  #0 int.to.chr$ 'last.sort.label :=
  "" 'next.extra :=
  #0 'longest.label.width :=
  #0 'last.extra.num :=
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{`forward.pass'}
%    \begin{macrocode}
FUNCTION {forward.pass}
{ last.sort.label sort.label =
    { last.extra.num #1 + 'last.extra.num :=
      last.extra.num int.to.chr$ 'extra.label :=
    }
    { "a" chr.to.int$ 'last.extra.num :=
      "" 'extra.label :=
      sort.label 'last.sort.label :=
    }
  if$
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</!ay&alph>
%    \end{macrocode}
%
% \begin{macro}{`reverse.pass'}
% \changes{3.3}{1995 Aug 7}{Put extra label in braces}
% The extra label is added in braces so that natbib can treat it as one unit.
% This allows extra labels to be more than one letter long. For non-NFSS
% emphasizing, this is no problem, since labels go in |{\em a}|, but for
% non-emphasizing and for NFSS, it caused troubles without the braces.
% The trouble arises with multiple citations in one |\cite| in which
% authors and years are the same, and only the extra label is given for
% the next one. Note: |\emph{a}| is more than one letter long in this sense,
% so it is not just a problem for more than 26 papers with same authors and
% year.
%
% \changes{3.81}{1996 Jun 17}{Add \texttt{\char`\\natexlab}}
% The command |\natexlab| now encloses the extra label for \texttt{natbib}
% styles. This command normally just prints its argument, but for numerical
% citation mode, it swallows its argument. This allows the extra labels to
% be suppressed for numerical citations where they are superfluous.
% The enclosing braces mentioned above must be included here to make the
% entire extra label text a single token for \texttt{natbib}.
%    \begin{macrocode}
%<*ay>
%    \end{macrocode}
%
%    \begin{macrocode}
FUNCTION {reverse.pass}
{ next.extra "b" =
    { "a" 'extra.label := }
    'skip$
  if$
  extra.label 'next.extra :=
  extra.label
%<xlab-it>  emphasize
%<*!html>
  duplicate$ empty$
    'skip$
    { "{\natexlab{" swap$ * "}}" * }
  if$
%</!html>
  'extra.label :=
%<!(har|ast|cay|nmd|cn)>  label extra.label * 'label :=
}
%    \end{macrocode}
%
%    \begin{macrocode}
%</ay>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*!ay&alph>
%    \end{macrocode}
%
%    \begin{macrocode}
FUNCTION {reverse.pass}
{ next.extra "b" =
    { "a" 'extra.label := }
    'skip$
  if$
  label extra.label * 'label :=
  label width$ longest.label.width >
    { label 'longest.label :=
      label width$ 'longest.label.width :=
    }
    'skip$
  if$
  extra.label 'next.extra :=
}
%    \end{macrocode}
%
%    \begin{macrocode}
%</!ay&alph>
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%<ay>EXECUTE {initialize.extra.label.stuff}
%<!ay&alph>EXECUTE {initialize.longest.label}
%    \end{macrocode}
%
%    \begin{macrocode}
%<*ay|alph>
ITERATE {forward.pass}
%    \end{macrocode}
%
%    \begin{macrocode}
REVERSE {reverse.pass}
%    \end{macrocode}
%
%    \begin{macrocode}
%</ay|alph>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*ay>
FUNCTION {bib.sort.order}
{ sort.label
  "    "
  *
%<seq-yrr>  negate.year field.or.null sortify
%<!seq-yrr>  year field.or.null sortify
%<(seq-yr|seq-yrr)&!(seq-lab|seq-key|seq-labc)>  swap$
  *
%<*!seq-key&!seq-labc&!seq-yr&!seq-yrr>
  "    "
  *
  title field.or.null
  sort.format.title
  *
%</!seq-key&!seq-labc&!seq-yr&!seq-yrr>
%<seq-key|seq-yr|seq-yrr>  "    " * cite$ *
  #1 entry.max$ substring$
  'sort.key$ :=
%  "For " cite$ * ", bib.sort.key=" * sort.key$ * warning$
%<har|cay|nmd|cn|ast>  calc.short.label
}
%    \end{macrocode}
%
%    \begin{macrocode}
ITERATE {bib.sort.order}
%    \end{macrocode}
%
%    \begin{macrocode}
SORT
%    \end{macrocode}
%
%    \begin{macrocode}
%</ay>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*!ay&!alph>
%    \end{macrocode}
%
%    \begin{macrocode}
STRINGS { longest.label }
%    \end{macrocode}
%
%    \begin{macrocode}
INTEGERS { number.label longest.label.width }
%    \end{macrocode}
%
%    \begin{macrocode}
FUNCTION {initialize.longest.label}
{ "" 'longest.label :=
  #1 'number.label :=
  #0 'longest.label.width :=
}
%    \end{macrocode}
%
%    \begin{macrocode}
FUNCTION {longest.label.pass}
%<*!cite>
{ number.label int.to.str$ 'label :=
  number.label #1 + 'number.label :=
%</!cite>
%<cite>{ cite$ 'label :=
  label width$ longest.label.width >
    { label 'longest.label :=
      label width$ 'longest.label.width :=
    }
    'skip$
  if$
}
%    \end{macrocode}
%
%    \begin{macrocode}
EXECUTE {initialize.longest.label}
%    \end{macrocode}
%
%    \begin{macrocode}
ITERATE {longest.label.pass}
%    \end{macrocode}
%
%    \begin{macrocode}
%</!ay&!alph>
%    \end{macrocode}
%
% \begin{macro}{`begin.bib'}
% \changes{2.0}{1994 Jan 31}{For \texttt{german}, add the definition of
%    {\tt\protect\bslash qq} to replace double-quote character.}
% \changes{2.0}{1994 Jan 31}{For \texttt{babel}, read in file
% \texttt{babelbst.tex} in \texttt{thebibliography} to define the word
%  commands.}
% \changes{3.4}{1995 Sep 5}{Add number of references as argument}
% \changes{3.89d1}{1999 July 20}{AO: provide default meanings for procedures used.}
% The function \texttt{begin.bib} writes  the initial text to the \texttt{.bbl}
% file. The most important matter here is that the \texttt{thebibliography}
% environment is invoked.
%
% Note: the French quotation marks are called `guillimets'; Adobe erroneously
% named the symbols `guillimot', which is an arctic bird. The error has so
% propagated, that it can no longer be corrected. \LaTeX\ took it over.
%    \begin{macrocode}
FUNCTION {begin.bib}
%<*!html>
%<*!ay&alph>
{ et.al.char.used
    { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
    'skip$
  if$
  preamble$ empty$
%</!ay&alph>
%<ay|!alph>{ preamble$ empty$
    'skip$
    { preamble$ write$ newline$ }
  if$
%<ay>  "\begin{thebibliography}{" number.label int.to.str$ * "}" *
%<!ay>  "\begin{thebibliography}{"  longest.label  * "}" *
  write$ newline$
%<*(!nmft&(nmft-it|nmft-sc|nmft-bf|nmft-def))|(!lab&(lab-it|lab-bf|lab-sc|lab-def))>
 "\typeout{**********************************}" write$ newline$
 "\typeout{WARNING WARNING WARNING WARNING WARNING}" write$ newline$
 "\typeout{The bst file has been generated with inconsistent options}"
   write$ newline$
 "\typeout{Read the warning message at the start of the bst file}"
   write$ newline$
 "\typeout{**********************************}" write$ newline$
%</(!nmft&(nmft-it|nmft-sc|nmft-bf|nmft-def))|(!lab&(lab-it|lab-bf|lab-sc|lab-def))>
%<*!plntx>
%<!tit-it&tit-qq&qt-s>  "\newcommand{\enquote}[1]{`#1'}"
%<!tit-it&tit-qq&!qt-s&!qt-g>  "\newcommand{\enquote}[1]{``#1''}"
%</!plntx>
%<*plntx>
%<!tit-it&tit-qq&qt-s>  "\def\enquote#1{`#1'}"
%<!tit-it&tit-qq&!qt-s&!qt-g>  "\def\enquote#1{``#1''}"
%</plntx>
%<*!tit-it&tit-qq&!qt-s&qt-g>
%<!plntx>  "\ProvideTextCommand{\guillemotleft}{OT1}{%"
%<plntx>  "\def\guillemotleft{%"
  write$ newline$
  "  \leavevmode\raise .27ex\hbox{$\scriptscriptstyle\ll$}}"
  write$ newline$
%<!plntx>  "\ProvideTextCommand{\guillemotright}{OT1}{%"
%<plntx>  "\def\guillemotright{%"
  write$ newline$
  "  \leavevmode\raise .27ex\hbox{$\scriptscriptstyle\gg$}}"
  write$ newline$
%<!plntx>  "\newcommand{\enquote}[1]{\guillemotleft#1\guillemotright}"
%<plntx>  "\def\enquote#1{\guillemotleft#1\guillemotright}"
%</!tit-it&tit-qq&!qt-s&qt-g>
%<!tit-it&tit-qq>  write$ newline$
%<umlaut>  "\let\qq=\" quote$ * write$ newline$
%<em-ul>  "\expandafter\ifx\csname uline\endcsname\relax\let\uline\underline\fi"
%<em-ul>   write$ newline$
%<*ay>
%<!plntx>  "\providecommand{\natexlab}[1]{#1}"
%<plntx>  "\expandafter\ifx\csname natexlab\endcsname\relax\def\natexlab#1{#1}\fi"
  write$ newline$
%<*har>
  "{\catcode`\|=0\catcode`\#=12\catcode`\@=11\catcode`\\=12" write$ newline$
  "|immediate|write|@auxout{\expandafter\ifx\csname natexlab\endcsname\relax\gdef\natexlab#1{#1}\fi}}"
  write$ newline$
%</har>
%</ay>
%<*nmft&nmft-def>
%<!plntx>  "\providecommand{\bibnamefont}[1]{#1}"
%<plntx>  "\expandafter\ifx\csname bibnamefont\endcsname\relax"
%<plntx>  write$ newline$
%<plntx>  "  \def\bibnamefont#1{#1}\fi"
  write$ newline$
%</nmft&nmft-def>
%<*nmft&fnm-def>
%<!plntx>  "\providecommand{\bibfnamefont}[1]{#1}"
%<plntx>  "\expandafter\ifx\csname bibfnamefont\endcsname\relax"
%<plntx>  write$ newline$
%<plntx>  "  \def\bibfnamefont#1{#1}\fi"
  write$ newline$
%</nmft&fnm-def>
%<*lab&lab-def>
%<!plntx>  "\providecommand{\citenamefont}[1]{#1}"
%<plntx>  "\expandafter\ifx\csname citenamefont\endcsname\relax"
%<plntx>  write$ newline$
%<plntx>  "  \def\citenamefont#1{#1}\fi"
  write$ newline$
%</lab&lab-def>
%<*(url&!harnm)|eprint>
%<*!plntx>
%<nfss>  "\providecommand{\url}[1]{\texttt{#1}}"
%<!nfss>  "\providecommand{\url}[1]{{\tt #1}}"
  write$ newline$
  "\providecommand{\urlprefix}{URL }"
  write$ newline$
%</!plntx>
%<*plntx>
  "\expandafter\ifx\csname url\endcsname\relax"
  write$ newline$
%<nfss>  "  \def\url#1{\texttt{#1}}\fi"
%<!nfss>  "  \def\url#1{{\tt #1}}\fi"
  write$ newline$
  "\expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi"
  write$ newline$
%</plntx>
%</(url&!harnm)|eprint>
%<*doi>
  "\expandafter\ifx\csname urlstyle\endcsname\relax"
  write$ newline$
%<*!plntx>
  "  \providecommand{\doi}[1]{doi:\discretionary{}{}{}#1}\else"
  write$ newline$
  "  \providecommand{\doi}{doi:\discretionary{}{}{}\begingroup \urlstyle{rm}\Url}\fi"
  write$ newline$
%</!plntx>
%<*plntx>
  "  \expandafter\ifx\csname doi\endcsname\relax"
  write$ newline$
  "  \def\doi#1{doi:\discretionary{}{}{}#1}\fi \else"
  write$ newline$
  "  \expandafter\ifx\csname doi\endcsname\relax"
  write$ newline$
  "  \def\doi{doi:\discretionary{}{}{}\begingroup \urlstyle{rm}\Url}\fi \fi"
  write$ newline$
%</plntx>
%</doi>
%<*lang>
%<!plntx>  "\providecommand{\selectlanguage}[1]{\relax}"
%<*plntx>
  "\expandafter\ifx\csname selectlanguage\endcsname\relax"
  write$ newline$
  "  \def\selectlanguage#1{}\fi"
%</plntx>
  write$ newline$
%</lang>
%<*!plntx>
%<*babel>
  "\input{babelbst.tex}" write$ newline$
  "\newcommand{\Capitalize}[1]{\uppercase{#1}}" write$ newline$
  "\newcommand{\capitalize}[1]{\expandafter\Capitalize#1}" write$ newline$
%</babel>
%<*annote>
  "\providecommand{\bibAnnoteFile}[1]{%"
  write$ newline$
  "  \IfFileExists{#1}{\begin{quotation}\noindent\textsc{Key:} #1\\"
  write$ newline$
  "  \textsc{Annotation:}\ \input{#1}\end{quotation}}{}}"
  write$ newline$
  "\providecommand{\bibAnnote}[2]{%"
  write$ newline$
  "  \begin{quotation}\noindent\textsc{Key:} #1\\"
  write$ newline$
  "  \textsc{Annotation:}\ #2\end{quotation}}"
  write$ newline$
%</annote>
%</!plntx>
%<*bibinfo>
%<!plntx>  "\providecommand{\bibinfo}[2]{#2}"
%<plntx>  "\expandafter\ifx\csname bibinfo\endcsname\relax\def\bibinfo#1#2{#2}\fi"
  write$ newline$
%</bibinfo>
%<*eprint>
%<!plntx>  "\providecommand{\eprint}[2][]{\url{#2}}"
%<plntx>  "\expandafter\ifx\csname eprint\endcsname\relax\def\eprint#1{\url{#1}}\fi"
  write$ newline$
%</eprint>
}
%</!html>
%<*html>
{
"<html><head><title>Bibliography Listing</title></head>" write$ newline$
"<body>" write$ newline$
"<h2>Bibliography</h2>" write$ newline$
%<htdes>"<dl>" write$ newline$
%<!htdes&htlist>"<ol>" write$ newline$
}
%</html>
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
EXECUTE {begin.bib}
%    \end{macrocode}
%
%    \begin{macrocode}
EXECUTE {init.state.consts}
%    \end{macrocode}
%
%    \begin{macrocode}
ITERATE {call.type$}
%    \end{macrocode}
%
% \begin{macro}{`end.bib'}
%    \begin{macrocode}
FUNCTION {end.bib}
{ newline$
%<!html>  "\end{thebibliography}" write$ newline$
%<html>  "</dl></body></html>" write$ newline$
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
EXECUTE {end.bib}
%    \end{macrocode}
%
%    \begin{macrocode}
%</!head>
%    \end{macrocode}
%
%    \begin{macrocode}
%</!options&!driver&!bblbst>
%    \end{macrocode}
%
% \section{The File \texttt{babelbst.tex} for English}
% The following contains the definitions for the \texttt{babel} language
% selection as they apply to English. This file may be extracted with
% \dtx{} and the option \texttt{bblbst}.
%    \begin{macrocode}
%<*bblbst>
 % This is babelbst.tex for English.
 % It should serve as a model for other languages.
 % Alternatively, store it under a different name (e.g. englbst.tex)
 % and then \input it with a command in babelbst.tex.
\def\bbland{and}                \def\bbletal{et~al.}
\def\bbleditors{editors}        \def\bbleds{eds.}
\def\bbleditor{editor}          \def\bbled{ed.}
\def\bbledby{edited by}
\def\bbledition{edition}        \def\bbledn{edn.}
\def\bblvolume{volume}          \def\bblvol{vol.}
\def\bblof{of}
\def\bblnumber{number}          \def\bblno{no.}
\def\bblin{in}
\def\bblpages{pages}            \def\bblpp{pp.}
\def\bblpage{page}              \def\bblp{p.}
\def\bbleidpp{pages}
\def\bblchapter{chapter}        \def\bblchap{chap.}
\def\bbltechreport{Technical Report}
\def\bbltechrep{Tech. Rep.}
\def\bblmthesis{Master's thesis}
\def\bblphdthesis{Ph.D. thesis}
\def\bblfirst{First}            \def\bblfirsto{1st}
\def\bblsecond{Second}          \def\bblsecondo{2nd}
\def\bblthird{Third}            \def\bblthirdo{3rd}
\def\bblfourth{Fourth}          \def\bblfourtho{4th}
\def\bblfifth{Fifth}            \def\bblfiftho{5th}
\def\bblst{st}  \def\bblnd{nd}  \def\bblrd{rd}
\def\bblth{th}
\def\bbljan{January}  \def\bblfeb{February}  \def\bblmar{March}
\def\bblapr{April}    \def\bblmay{May}       \def\bbljun{June}
\def\bbljul{July}     \def\bblaug{August}    \def\bblsep{September}
\def\bbloct{October}  \def\bblnov{November}  \def\bbldec{December}
%</bblbst>
%    \end{macrocode}
%
% \Finale