summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/bibtex/apacite/apacite.dtx
blob: 92232a403178a564f1d2ee9dcb52187d17b09202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
% \iffalse meta-comment
%
% Copyright (C) 1994-2012 Erik Meijer and any individual authors listed
% elsewhere in this file.
%
% This file is part of the `apacite' package.
% -------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any later
% version.  The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% The `apacite' package consists of the files apacite.dtx and
% apacite.ins, and the following generated files:
% apacite.sty, apacdoc.sty,  apacite.drv,
% apacite.bst, apacitex.bst, apacann.bst,  apacannx.bst,
% apa5ex.bib,  apacxmpl.tex,
% english.apc, dutch.apc,    finnish.apc,  french.apc,
% german.apc,  ngerman.apc,  greek.apc,    norsk.apc,
% spanish.apc, swedish.apc.
%
% This work has the LPPL maintenance status `maintained'
%
% The Current Maintainer of this work is Erik Meijer
%
% This file may only be distributed together with a copy of the
% source files of the apacite package, i.e., apacite.dtx and
% apacite.ins. You may however distribute the apacite package without
% the generated files.
%
% \fi
%
% \CheckSum{0}
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \iffalse
%<*dtx>
\ProvidesFile{apacite.dtx}
   [2012/02/25 v6.01 apacite dtx file]
%</dtx>
%<driver>\ProvidesFile{apacite.drv}
%<package|docpkg>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{apacite}
%<docpkg>\ProvidesPackage{apacdoc}
%<english>\ProvidesFile{english.apc}
%<dutch>\ProvidesFile{dutch.apc}
%<finnish>\ProvidesFile{finnish.apc}
%<german>\ProvidesFile{german.apc}
%<ngerman>\ProvidesFile{ngerman.apc}
%<greek>\ProvidesFile{greek.apc}
%<norsk>\ProvidesFile{norsk.apc}
%<spanish>\ProvidesFile{spanish.apc}
%<swedish>\ProvidesFile{swedish.apc}
%<xmpl>%% apacxmpl.tex
%<bibdb>%% apa5ex.bib
%<bibstyle&!annotated>%% apacite.bst
%<bibstyle&annotated>%% apacann.bst
%<xbibstyle&!annotated>%% apacitex.bst
%<xbibstyle&annotated>%% apacannx.bst
%^^A
%^^A I have to find out how I can replace the hard-coded date+version with a
%^^A command such that the value of the command is written to the file instead
%^^A of the name.
%^^A
%<driver>   [2012/02/25 v6.01 apacite documentation driver file]
%<package>   [2012/02/25 v6.01 APA citation]
%<docpkg>   [2012/02/25 v6.01 apacite documentation style]
%<english>   [2012/02/25 v6.01 apacite language file]
%<dutch>   [2012/02/25 v6.01 apacite language file]
%<finnish>   [2012/02/25 v6.01 apacite language file]
%<german>   [2012/02/25 v6.01 apacite language file]
%<ngerman>   [2012/02/25 v6.01 apacite language file]
%<greek>   [2012/02/25 v6.01 apacite language file]
%<norsk>   [2012/02/25 v6.01 apacite language file]
%<spanish>   [2012/02/25 v6.01 apacite language file]
%<swedish>   [2012/02/25 v6.01 apacite language file]
%<xmpl>%%   [2012/02/25 v6.01 LaTeX file for examples]
%<bibdb>%%   [2012/02/25 v6.01 bibliography database for examples]
%<bibstyle&!annotated>%%   [2012/02/25 v6.01 APA bibliography style]
%<*xbibstyle&!annotated>
%%   [2012/02/25 v6.01 APA bibl. style with author index info]
%</xbibstyle&!annotated>
%<bibstyle&annotated>%%   [2012/02/25 v6.01 APA annotated bibliography style]
%<*xbibstyle&annotated>
%%   [2012/02/25 v6.01 APA annotated bibl. style with author index info]
%</xbibstyle&annotated>
%
%<*install>
%^^A =============================================
%^^A    Here is the docstrip installation file
%^^A    It is written on first LaTeX run if it
%^^A    does not already exist
%^^A =============================================
\begin{filecontents*}{apacite.ins}
%%
%% This file will generate fast loadable files and documentation
%% driver files from apacite.dtx when run through LaTeX.
%%
%% Copyright (C) 1994-2012 Erik Meijer and any individual authors listed
%% elsewhere in this file.
%%
%% This file is part of the `apacite' package.
%% -------------------------------------------
%%
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any later
%% version.  The latest version of this license is in:
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
%% The `apacite' package consists of the files apacite.dtx and
%% apacite.ins, and the following generated files:
%% apacite.sty, apacdoc.sty,  apacite.drv,
%% apacite.bst, apacitex.bst, apacann.bst,  apacannx.bst,
%% apa5ex.bib,  apacxmpl.tex,
%% english.apc, dutch.apc,    finnish.apc,  french.apc,
%% german.apc,  ngerman.apc,  greek.apc,    norsk.apc,
%% spanish.apc, swedish.apc.
%%
%% This work has the LPPL maintenance status `maintained'
%%
%% The Current Maintainer of this work is Erik Meijer
%%
%% This file may only be distributed together with a copy of the
%% source files of the apacite package, i.e., apacite.dtx and
%% apacite.ins. You may however distribute the apacite package without
%% the generated files.

\input docstrip.tex
\keepsilent

\declarepreamble\mainpreamble

This is a generated file.

Copyright (C) 1994-2012 Erik Meijer and any individual authors listed
elsewhere in this file.

This file is part of the `apacite' package.
-------------------------------------------

It may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3 of this license or (at your option) any later
version.  The latest version of this license is in:

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

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

The `apacite' package consists of the files apacite.dtx and
apacite.ins, and the following generated files:
apacite.sty, apacdoc.sty,  apacite.drv,
apacite.bst, apacitex.bst, apacann.bst,  apacannx.bst,
apa5ex.bib,  apacxmpl.tex,
english.apc, dutch.apc,    finnish.apc,  french.apc,
german.apc,  ngerman.apc,  greek.apc,    norsk.apc,
spanish.apc, swedish.apc.

This work has the LPPL maintenance status `maintained'

The Current Maintainer of this work is Erik Meijer

This file may only be distributed together with a copy of the
source files of the apacite package, i.e., apacite.dtx and
apacite.ins. You may however distribute the apacite package without
the generated files.

\endpreamble

\declarepreamble\drvpreamble

This is a generated file.

Copyright (C) 1994-2012 Erik Meijer and any individual authors listed
elsewhere in this file.

This file is part of the `apacite' package.
-------------------------------------------

It may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3 of this license or (at your option) any later
version.  The latest version of this license is in:

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

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

The `apacite' package consists of the files apacite.dtx and
apacite.ins, and the following generated files:
apacite.sty, apacdoc.sty,  apacite.drv,
apacite.bst, apacitex.bst, apacann.bst,  apacannx.bst,
apa5ex.bib,  apacxmpl.tex,
english.apc, dutch.apc,    finnish.apc,  french.apc,
german.apc,  ngerman.apc,  greek.apc,    norsk.apc,
spanish.apc, swedish.apc.

This work has the LPPL maintenance status `maintained'

The Current Maintainer of this work is Erik Meijer

This file may only be distributed together with a copy of the
source files of the apacite package, i.e., apacite.dtx and
apacite.ins. You may however distribute the apacite package without
the generated files.

You are allowed to make changes to this file, in order to generate
the user's manual with your preferred settings (e.g., to choose
whether or not to include the documented source code). Please
do not change apacite.dtx for this purpose.

\endpreamble

\edef\noendinputpostamble{%
  \MetaPrefix ^^J%
  \MetaPrefix\space End of file `\outFileName'.%
}

\askonceonly
\generate{%
  \usepreamble\mainpreamble
  \file{apacite.sty}{\from{apacite.dtx}{package}}
  \file{apacdoc.sty}{\from{apacite.dtx}{docpkg}}
  \file{english.apc}{\from{apacite.dtx}{english}}
  \file{dutch.apc}{\from{apacite.dtx}{dutch}}
  \file{finnish.apc}{\from{apacite.dtx}{finnish}}
  \file{french.apc}{\from{apacite.dtx}{french}}
  \file{german.apc}{\from{apacite.dtx}{german}}
  \file{ngerman.apc}{\from{apacite.dtx}{ngerman}}
  \file{greek.apc}{\from{apacite.dtx}{greek}}
  \file{norsk.apc}{\from{apacite.dtx}{norsk}}
  \file{spanish.apc}{\from{apacite.dtx}{spanish}}
  \file{swedish.apc}{\from{apacite.dtx}{swedish}}
  \file{apacxmpl.tex}{\from{apacite.dtx}{xmpl}}
  \usepreamble\drvpreamble
  \file{apacite.drv}{\from{apacite.dtx}{driver}}
  \usepreamble\mainpreamble
  \usepostamble\noendinputpostamble
  \file{apa5ex.bib}{\from{apacite.dtx}{bibdb}}
  \file{apacite.bst}{\from{apacite.dtx}{bibstyle}}
  \file{apacitex.bst}{\from{apacite.dtx}{xbibstyle}}
  \file{apacann.bst}{\from{apacite.dtx}{bibstyle,annotated}}
  \file{apacannx.bst}{\from{apacite.dtx}{xbibstyle,annotated}}
}

\obeyspaces
\Msg{*****************************************************}
\Msg{*                                                   *}
\Msg{* To finish the installation you have to move the   *}
\Msg{* following files into a directory searched by TeX: *}
\Msg{*                                                   *}
\Msg{*     All *.apc, *.sty                              *}
\Msg{*                                                   *}
\Msg{* and to move the following files into a directory  *}
\Msg{* searched by BibTeX:                               *}
\Msg{*                                                   *}
\Msg{*     All *.bib, *.bst                              *}
\Msg{*                                                   *}
\Msg{* To produce the documentation, run the following   *}
\Msg{* script (or something similar, depending on your   *}
\Msg{* operating system):                                *}
\Msg{*                                                   *}
\Msg{*  pdflatex apacite.drv                             *}
\Msg{*  bibtex   apacite                                 *}
\Msg{*  pdflatex apacite.drv                             *}
\Msg{*  pdflatex apacite.drv                             *}
\Msg{*  pdflatex apacite.drv                             *}
\Msg{*  makeindex -o apacite.and apacite.adx             *}
\Msg{*  pdflatex apacite.drv                             *}
\Msg{*  pdflatex apacite.drv                             *}
\Msg{*                                                   *}
\Msg{* See the README file for a brief explanation and   *}
\Msg{* the file apacite.drv for how to customize the     *}
\Msg{* manual (e.g., to include the documented source    *}
\Msg{* code.                                             *}
\Msg{*                                                   *}
\Msg{* Happy TeXing!                                     *}
\Msg{*                                                   *}
\Msg{*****************************************************}

\endbatchfile
\end{filecontents*}
%</install>
%<*gobble>
\IfFileExists{apacdoc.sty}{%
    \let\finishprematurely\relax
}{%
    \typeout{**************************************************%
             ********************}%
    \typeout{*}%
    \typeout{* To extract the package, style, and support files
             of apacite,}%
    \typeout{* run TeX on apacite.ins}%
    \typeout{*}%
    \typeout{* To (re)generate the apacite documentation, first
             run TeX on}%
    \typeout{* apacite.ins and then run LaTeX on apacite.drv
             or apacite.dtx}%
    \typeout{*}%
    \typeout{**************************************************%
             ********************^^J}%
    \makeatletter
    \edef\finishprematurely{\csname @@end\endcsname}%
    \makeatother
}
\finishprematurely
%</gobble>
% \fi
%
% \DoNotIndex{\begin,\CodelineIndex,\CodelineNumbered,\def,\DisableCrossrefs}
% \DoNotIndex{\DocInput,\documentclass,\EnableCrossrefs,\end,\GetFileInfo}
% \DoNotIndex{\NeedsTeXFormat,\OnlyDescription,\RecordChanges,\usepackage}
% \DoNotIndex{\ProvidesClass,\ProvidesPackage,\ProvidesFile,\RequirePackage}
% \DoNotIndex{\LoadClass,\PassOptionsToClass,\PassOptionsToPackage}
% \DoNotIndex{\DeclareOption,\CurrentOption,\ProcessOptions,\ExecuteOptions}
% \DoNotIndex{\AtEndOfClass,\AtEndOfPackage,\AtBeginDocument,\AtEndDocument}
% \DoNotIndex{\InputIfFileExists,\IfFileExists,\ClassError,\PackageError}
% \DoNotIndex{\ClassWarning,\PackageWarning,\ClassWarningNoLine}
% \DoNotIndex{\PackageWarningNoLine,\ClassInfo,\PackageInfo,\MessageBreak}
% \DoNotIndex{\space,\protect,\DeclareRobustCommand,\CheckCommand}
% \DoNotIndex{\newcommand,\renewcommand,\providecommand,\newenvironment}
% \DoNotIndex{\renewenvironment,\newif,\newlength,\newcounter,\setlength}
% \DoNotIndex{\setcounter,\if,\ifx,\ifcase,\ifnum,\ifdim,\else,\fi}
% \DoNotIndex{\texttt,\textbf,\textrm,\textsl,\textsc,\reset@font}
% \DoNotIndex{\textup,\textit,\textmd,\textsf,\emph,\futurelet}
% \DoNotIndex{\ttfamily,\rmfamily,\sffamily,\mdseries,\bfseries,\upshape}
% \DoNotIndex{\slshape,\scshape,\itshape,\em,\LaTeX,\LaTeXe}
% \DoNotIndex{\filename,\fileversion,\filedate,\let,\makeindex}
% \DoNotIndex{\@auxout,\@for,\@gobble,\@ifnextchar,\@m,\@mkboth,\@nil}
% \DoNotIndex{\@noitemerr,\@tempa,\@tempswafalse,\@tempswatrue,\@warning}
% \DoNotIndex{\advance,\arabic,\AtBeginDocument,\bf,\bibname,\chapter}
% \DoNotIndex{\citation,\clubpenalty,\CodelineNumbered,\csname}
% \DoNotIndex{\DisableCrossrefs,\do,\edef,\else,\endcsname,\endlist}
% \DoNotIndex{\expandafter,\fi,\gdef,\global,\hbox,\hfill,\hskip,\hspace}
% \DoNotIndex{\if,\if@filesw,\if@tempswa,\ifx,\immediate,\itemindent,\labelsep}
% \DoNotIndex{\labelwidth,\lastskip,\leftmargin,\list,\mbox,\newblock}
% \DoNotIndex{\newpage,\p@enumiv,\parindent,\penalty,\refname}
% \DoNotIndex{\relax,\section,\settowidth,\sfcode,\sloppy,\small,\string}
% \DoNotIndex{\theenumiv,\thepage,\unskip,\uppercase,\usecounter,\vskip}
% \DoNotIndex{\widowpenalty,\write,\xdef,\z@,\catcode,\ifnum,\the}
% \DoNotIndex{\@empty,\@ifundefined,\@latex@warning,\@minus,\@plus,\ }
% \DoNotIndex{\document,\@namedef,\@listi,\markboth,\or,\p@}
% \DoNotIndex{\listparindent,\noexpand,\par,\parsep,\pb,\pbf,\pbfseries}
% \DoNotIndex{\pc,\pd,\pem,\pit,\pitshape,\pmdseries,\prm,\prmfamily,\psc}
% \DoNotIndex{\pscshape,\psf,\psffamily,\psl,\pslshape,\ptt,\pttfamily}
% \DoNotIndex{\pupshape,\@iden,\@firstofone,\@unexpandable@protect}
% \DoNotIndex{\if@draft,\typeout}
% \DoNotIndex{\@ifclassloaded,\@ifstar,\@onlypreamble,\@preamblecmds}
% \DoNotIndex{\addtolength,\endinput,\@bsphack,\begingroup,\@wrindex}
% \DoNotIndex{\@listctr,\bibname,\enddocument,\hfil,\ignorespaces,\item}
% \DoNotIndex{\NAT@temp,\refname,\stepcounter,\@ifpackageloaded}
% \DoNotIndex{\@gobbletwo,\index,\itemsep,\markright,\scriptsize}
% \DoNotIndex{\textsuperscript,\@undefined}
% \DoNotIndex{\@celt,\@cite@list,\@citea,\@citeb,\@compress@cite}
% \DoNotIndex{\@bsphack,\@esphack,\@h@ld,\@make@cite@list,\@ne}
% \DoNotIndex{\@sort@celt,\@tempcnta,\@tempcntb,\delimiter,\endgroup}
% \DoNotIndex{\ifcat,\m@ne,\number}
% \DoNotIndex{\@markboth,\@mkboth,\nobreak,\SK@,\SK@@citex}
% \DoNotIndex{\SK@@label,\SK@@ref,SK@def,\SK@lbibitem,\bbl@redefine}
% \DoNotIndex{\@safe@activesfalse,\@save@activestrue,\active@prefix}
%
% \DoNotIndex{\ ,\&,\{,\},\.,\!,\",\#,\%,\',\(,\),\*,\,,\-,\/}
% \DoNotIndex{\:,\;,\<,\=,\>,\?,\@,\[,\\,\],\^,\_,\`,\|,\~}
% \DoNotIndex{\@backslashchar,\@citec,\@element@,\@input@,\@nameuse}
% \DoNotIndex{\@makeschapterhead,\@restonecolfalse,\@restonecoltrue}
% \DoNotIndex{\@old@endthebibliography,\@oldbibpreamble,\@orig@@cite}
% \DoNotIndex{\@orig@@nocitemeta,\@orig@nocite}
% \DoNotIndex{\@tmp@arg,\@xp,\AA,\aa,\addcontentsline}
% \DoNotIndex{\afterassignment,\aftergroup,\alph,\ast,\b@ex}
% \DoNotIndex{\backslash,\baselineskip,\BibTeX,\bigskip,\bs}
% \DoNotIndex{\clearpage,\cmd,\cmdfour,\cmdthree,\cmdthreealt}
% \DoNotIndex{\cmdthreepre,\cmdtwo,\columnsep,\columnseprule,\count@}
% \DoNotIndex{\dag,\do@url@hyp,\EM,\ensuremath,\entryname,\envirname}
% \DoNotIndex{\evensidemargin,\fieldname,\flqq,\fname,\fontencoding}
% \DoNotIndex{\fontfamily,\footnotesize,\footskip,\frqq}
% \DoNotIndex{\g@addto@macro,\GlossaryPrologue,\headheight,\headsep}
% \DoNotIndex{\hoffset,\if@mainmatter,\ifcodeline@index,\iffalse}
% \DoNotIndex{\ifhave@multicol,\index@prologue,\IndexMin,\IndexParms}
% \DoNotIndex{\IndexPrologue,\input,\jobname,\kern,\langle,\LaTeXrtf}
% \DoNotIndex{\latextohtml,\lbrace,\LC,\ldots,\linewidth,\lower}
% \DoNotIndex{\makeatletter,\makeatother,\MakeIndex,\MakeUppercase}
% \DoNotIndex{\marginparpush,\marginparsep,\marginparwidth,\mid}
% \DoNotIndex{\mathbin,\mathchar,\mathord,\newskip,\newwrite}
% \DoNotIndex{\normalsize,\oddsidemargin,\oldBED,\oldBEd,\oldBEDS}
% \DoNotIndex{\oldbibinitial,\oldbibliteral,\oldbibskipbracenodot}
% \DoNotIndex{\oldBIn,\oldBRetrieved,\oldevensidemargin,\oldfootskip}
% \DoNotIndex{\oldheadheight,\oldheadsep,\oldhoffset,\oldlinewidth}
% \DoNotIndex{\oldmarginparpush,\oldmarginparsep,\oldmarginparwidth}
% \DoNotIndex{\oldoddsidemargin,\oldtextheight,\oldtextwidth}
% \DoNotIndex{\oldtopmargin,\oldvoffset,\onecolumn,\openout,\opt}
% \DoNotIndex{\orig@printindex,\origbibDSM,\parskip,\Perl,\pfill}
% \DoNotIndex{\pkg,\pkgoption,\protected@edef,\protected@write}
% \DoNotIndex{\quad,\raggedright,\raisebox,\rangle,\rbrace,\rm,\sc}
% \DoNotIndex{\selectfont,\simpleguillemots,\symbol,\TeX,\TeXht}
% \DoNotIndex{\textheight,\textwidth,\thinspace,\thispagestyle}
% \DoNotIndex{\thr@@,\times,\tiny,\topmargin,\triangleright}
% \DoNotIndex{\twocolumn,\undefined,\voffset,\vspace,\X,\Y}
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
%<driver>%\documentclass[twoside]{ltxdoc}
%<driver>%\documentclass[a4paper]{ltxdoc}
%<driver>%\documentclass[twoside,a4paper]{ltxdoc}
%%
\usepackage{apacdoc}[2012/02/25 v6.01]
%% The |\providecommand|s make sure we don't get an error during
%% installation.
%% Define document-specific macros that are not interesting for
%% users.
\providecommand{\SetupAPACdoc}{}%
\SetupAPACdoc
%% Document page layout.
\providecommand{\APACdocPageLayout}{}%
\APACdocPageLayout
%% Index styles for the source code documentation
\providecommand{\SetupAPACdocPrologues}{}%
\SetupAPACdocPrologues
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOADING OF PACKAGES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% The following line can be uncommented to test compatibility with TeX4ht.
%% \usepackage{tex4ht}
%%
%% The following line is used for references to internet sources.
%% It is not generally necessary for apacite, but used in the examples.
\usepackage{url}
%%
%% The following lines can be uncommented to test compatibility with
%% the mentioned other packages and test the language support of
%% apacite.
%% \usepackage[dvips,pagebackref]{hyperref}
%% \usepackage[pdftex,pagebackref]{hyperref}
%% \usepackage[english]{babel}% babel must be loaded before apacite
%% \usepackage{german}
%%
%% Loading apacite with author index option.
\usepackage[ltxemindex,bibnewpage]{apacite}[2012/02/25 v6.01]
%%
\raggedbottom
%%
%% To include the detailed explanation of the coding, comment out
%% the next line
\OnlyDescription
%%
%% To produce a command index: add the following line for one run,
%% then run  makeindex -s gind.ist apacite
%% and reprocess, with or without this line (much faster without)
%<driver>% \EnableCrossrefs\CodelineIndex
%%
%% To produce a change history: add the following line for one run,
%% then run  makeindex -s gglo.ist -o apacite.gls apacite.glo
%% and reprocess, with or without this line (faster without)
%<driver>% \RecordChanges
%%
\DisableCrossrefs %May stay; zapped by \EnableCrossrefs
\CodelineNumbered %May stay
%%
%% For getting something useful out of greek.apc in the documentation.
%%\IfFileExists{iso-8859-7.def}{%
%%  \usepackage[iso-8859-7]{inputenc}}{}
\begin{document}
  \DocInput{apacite.dtx}
\end{document}
%</driver>
% \fi
%
% ^^A (I have to find out how to get the following remark in the right
% ^^A place in the documentation.)
% ^^A The earlier version numbers have been assigned retroactively;
% ^^A originally, apacite had only release dates.
%
% \changes{v1.0}{1994/11/30}{First public version}
% \changes{v2.0}{2000/09/22}{Second packaged version, the result of
%   continuous updating over many years. Not officially released through
%   ctan because there was no update of the documentation, but this was
%   available through my homepage at the time. Many additions in terms
%   of customizability, and introduction of the author indexing
%   facilities, which were first used in my PhD thesis in 1998.}
% \changes{v2.1}{2003/03/27}{First official release since 1994. Compared
%   to 2.0, this primarily solved some important compatibility problems
%   with other packages.}
% \changes{v2.2}{2003/09/05}{Updated for the 5th edition of the APA
%   manual, up to date documentation and test document, reorganized the
%   material, and improved compatibility.}
% \changes{v3.0}{2004/07/01}{Now adds initials if necessary to
%   distinguish first authors; now adds 2nd and later authors if necessary
%   to distinguish references; now truncates author list after 6th author
%   and editor list after 1st in reference list if there are more than 6
%   authors/editors; improved sorting for reference list; improved author
%   index support; added explicit support for reporting a meta-analysis.}
% \changes{v3.1}{2005/06/01}{Introduces explicit non-English language
%   support, solves some compatibility problems.}
% \changes{v3.2}{2005/06/08}{Fix of a small but annoying bug.}
% \changes{v4.00}{2007/09/03}{Solved many compatibility issues; improved
%   and extended language support; more extensive customizability.}
% \changes{v4.05}{2009/03/01}{Some bug fixes; extended language support;
%   annotated bibliographies.}
% \changes{v6.00}{2012/02/25}{First step towards compliance with v6 of
%   the APA manual; version number now indicates which version of the APA
%   manual is implemented.}
%
% \GetFileInfo{apacite.sty}
%
% \setcounter{IndexColumns}{2}
% \setlength{\IndexMin}{10cm}
%
% ^^A Start documentation here.
%
%
% \iffalse
%<*dtx>
% \fi
\MakePercentComment
%
% User's reference manual and test of the apacite package.
% Written by Erik Meijer
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% START OF ``NORMAL'' PART OF DOCUMENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{The \pkg{apacite} package%
       \thanks{This document describes \pkg{apacite} version~\fileversion{}
       dated \filedate.}
       \vspace{0.3\baselineskip}\\
       \large Citation and reference list with \LaTeX{} and \BibTeX{}
       according to the rules of the American Psychological Association}
\author{Erik Meijer\\
        \textsf{apacite at gmail.com}
}
\date{\filedate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% If ecmr (T1) font not available:
\simpleguillemots
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{abstract}
  \noindent
  This document describes and tests the \pkg{apacite} package
  \APACversiondate{\filedate}. This is a package that can be used with
  \LaTeX{} and \BibTeX{} to generate citations and a reference list,
  formatted according to the rules of the American Psychological Association.
  Furthermore, \pkg{apacite} contains an option to (almost) automatically
  generate an author index as well. The package can be customized in many
  ways.
\end{abstract}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\tableofcontents
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The American Psychological Association (APA) is very strict about the style in
which manuscripts submitted to its journals are written and formatted. The
requirements of the APA are described in the \emph{Publication Manual of the
American Psychological Association}, the latest version of which is the 6th
edition \cite{APAManual6}. In the sequel, this is simply called the \emph{APA
manual}.

The APA manual discusses how candidate authors should write their manuscripts:
writing style, parts of a manuscript and their order, presentation of the
results in the form of tables and figures, and so forth. Candidate authors
should study this and adhere to this.

The APA manual also gives specific rules about the formatting of a manuscript.
This includes double spacing, a running head, the typographic style of section
headings, the placement of tables and figures on separate pages at the end of
the document, and so forth. \LaTeX{} users will recognize these as ``style''
elements that should be defined in a package (\fname{.sty} file) or class
(\fname{.cls} file). Their specific documents (\fname{.tex} file) should be
largely style-independent. This idea of separating content and logical
structure from specific formatting is one of the basic elements of \LaTeX{}
\cite[p.~7]{LaTeXbook}.

An implementation of the formatting rules of the APA manual for use with
\LaTeX{} is the \pkg{apa6} class by Brian Beitzel, which is a continuation of
the earlier \pkg{apa} class by Athanassios Protopapas. This handles all kinds of
issues about general document formatting, title page, section headings, figures
and tables, and so forth. Therefore, if you intend to submit a manuscript to an
APA journal, I strongly recommend using the \pkg{apa6} class.

An important part of the APA style is the way citations and the reference list
should be formatted. This takes 56 pages in the APA manual (pp.~169--224). This
part is not handled by the \pkg{apa6} class, but by the \pkg{apacite} package.
\pkg{apacite} can be used without \pkg{apa6}. The current document, for example,
does not use the \pkg{apa6} class, because I find it desirable that possible
users can study the \pkg{apacite} package and its documentation without having
to install several other classes and packages first. Therefore, the current
document uses standard \LaTeX{} as much as possible. (The \pkg{apa} class used
to require the \pkg{apacite} package, but this was dropped because there is now
also the \pkg{biblatex-apa} citation package as an alternative to
\pkg{apacite}.)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection*{Philosophy of \pkg{apacite}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The first priority of \pkg{apacite} is to implement the rules of the APA manual
with regard to citation and reference list as closely as possible. However, just
like its predecessors (culminating in Young U. Ryu's \pkg{theapa} package), and
actually expanding much beyond their realm, \pkg{apacite} offers many
possibilities for customization as well. Many details of \pkg{apacite},
particularly punctuation and some fixed texts (e.g., ``Tech.\ Rep.'') can be
changed easily by the user by redefining some commands in \LaTeX{}. Furthermore,
\pkg{apacite} also offers several proper options to change some of its settings.

Whether certain options or customizable aspects are implemented depends on two
criteria: (1) Is it possible, easy (enough), and convenient to implement them
without compromising the ability to adhere to the APA rules, and (2) Do I (EM)
consider them important or useful enough to spend time to implement them.
Actually, the decision process is the reverse of this: First, I decide whether
I find it a relevant or useful option. If not, I will not implement it. If so,
I will think about if and how I can implement it. If I have an idea for a
solution that is practically feasible, I will pursue it. If I don't see a
solution, if I think it will take me too much time, or if I think a solution
will be inconvenient to other users, then I will not pursue it.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection*{New in this version}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The current version \fileversion{} \APACversiondate{2012/02/25} fixes a
small but annoying bug in version v6.00 \APACversiondate{2012/02/14},
which only affected documents compiled with the \pkgoption{natbibapa}
option. In the rest of this document, ``the previous version'' should be
interpreted as ``the \APACversiondate{2009/03/01} version''.

The \APACversiondate{2009/03/01} version of \pkg{apacite}
implemented the rules in the 5th edition of the APA manual. The current
version aims to conform with the new (2009) 6th edition of the APA manual.
It does not completely succeed in this yet, although the instances of
incorrectly formatted cases will be rare. Most problems can be solved by
using \LaTeX{} or \BibTeX{} tricks in the \fname{.bib} file, but this
makes the \fname{.bib} file less compatible with other styles. In the
test examples in section~\ref{sec:xmpl} below, many tricks are used and
discussed. Remaining problems, omissions, and things-to-be-done can be
found in section~\ref{sec:todo}.

The changes since the \APACversiondate{2009/03/01} version are:
\begin{itemize}

\item
Changes in order to conform to the 6th edition of the APA Manual: (a) added
\fieldname{doi} field and \pkgoption{doi} and \pkg{nodoi} options; (b)
added examples (but not all yet) from the 6th edition to the bibliography
database; (c) changed formatting of reference list entry with more than
7 authors (the first 6, then dots, then the last, instead of the first 6 and
``et al.'') and correspondingly added the \cmd{\BDBL} command;
(d) added the new command \cmd{\BRetrievedFrom} for ``Retrieved from''
without date and replaced uses of \cmd{\BAvailFrom} by \cmd{\BRetrievedFrom}
(although \cmd{\BAvailFrom} is still defined).

\item
Introduced the examples \LaTeX{} file \fname{apacxmpl.tex}, which makes
it easier to test \pkg{apacite} and get insight in how nonstandard
cases can be formatted according to APA rules. (Far from finished.)

\item
Added a style command for authors in the reference list
(\cmd{\APACrefauthstyle}).

\item
Introduced the \cmd{\usespanishe} command to \fname{spanish.apc} to
support cases in which ``and'' should be ``e'' instead of ``y''.

\item
Changed some internal code so that \pkg{apacite} can now be used with
the \pkg{bibentry} package.

\item
Changed handling of ``von parts''. Corresponding to examples in
earlier editions of the APA manual, \pkg{apacite} used to format
names with von parts as ``Helmholtz, H. L. F. von'' in the reference
list and as ``Helmholtz'' in the text, but in arguably the vast
majority of situations encountered by \pkg{apacite} users, it
is more desirable to format von parts as ``de Waal, E.'' in the
reference list and as ``de Waal'' in the text. This change implies
that it is no longer necessary to include the name in an additional
pair of braces in the \fname{.bib} file, and that, with \pkg{natbib},
capitalization of the von part (at the beginning of a sentence) with
\cmd{\Citet} and its siblings now works as well. The flipside that
it is now more difficult to obtain the previous behavior.

\item
Added options to select different citation commands:
\begin{itemize}
\item[(a)]
\pkgoption{apaciteclassic} (default) defines the ``classic''
\pkg{apacite} citation commands \cmd{\cite}, \cmd{\citeA},
\cmd{\citeNP}, etc., with the angled bracket prenotes, e.g.,
|\citeA<see>[for more details]{ex1}|.
\item[(b)]
\pkgoption{natbibapa} loads \pkg{natbib} and thus defines the
\pkg{natbib} citation commands \cmd{\citet}, \cmd{\citep}, etc.,
with the double square bracket notes, e.g.,
|\citep[see][for more details]{ex1}|. \pkg{apacite}
now contains some improved compatibility code so that the
combination of \pkg{natbib} and \pkg{apacite} better follows
the APA rules. In particular, the standard \pkg{natbib} style
``(2008a,b)'' is now replaced by the APA style ``(2008a, 2008b)''
and the usage of ``and'' versus ``\&'' also satisfies the APA
rules. \pkg{apacite} defines a few additional commands that are
missing from \pkg{natbib}, but useful for \pkg{apacite} users.
In particular, \pkg{apacite} defines \cmd{\citeauthort} and
\cmd{\citeauthorp}. The former uses ``and'' and the latter uses
``\&''. \pkg{natbib}'s \cmd{\citeauthor} is configured such that
it is the same as \cmd{\citeauthort}.

Note that \pkg{natbib} also supports sorting the citations
within a citation command and has commands to capitalize the
first letter of a citation (e.g., \cmd{\Citet}), which should
be used when names with von parts such as ``de Waal'' start a
sentence.
\item[(c)]
\pkgoption{nocitation}, which does not define any citation
commands at all.
\end{itemize}

\item
Added masked citation commands and the \pkgoption{mask} and
\pkgoption{unmask} options to activate or deactivate them.
With the \pkgoption{apaciteclassic} option, the following
masked citation commands are defined:
\cmd{\maskcite},
\cmd{\maskfullcite},
\cmd{\maskshortcite},
\cmd{\maskciteNP},
\cmd{\maskfullciteNP},
\cmd{\maskshortciteNP},
\linebreak[4]\cmd{\maskciteA},
\cmd{\maskfullciteA},
\cmd{\maskshortciteA},
\cmd{\maskciteauthor},
\linebreak[4]\cmd{\maskfullciteauthor},
\cmd{\maskshortciteauthor},
\cmd{\maskciteauthorNP},
\linebreak[4]\cmd{\maskfullciteauthorNP},
\cmd{\maskshortciteauthorNP},
\cmd{\maskciteauthorA},
\cmd{\maskfullciteauthorA},
\cmd{\maskshortciteauthorA},
\cmd{\maskciteyear}, and
\linebreak[4]\cmd{\maskciteyearNP}.
They have exactly the same syntax as the corresponding commands
without ``|mask|''. With the \pkgoption{unmask} option (default),
their definitions are also identical to the non-|mask| commands.
In contrast, with the \pkgoption{mask} option, a message of the form
``\emph{(2 citations removed for masked review)}'' is printed.
The actual message is defined in \cmd{\onemaskedcitationmsg} and
\cmd{\maskedcitationsmsg}, depending on whether one or more citations
are masked.

In addition to these commands, \cmd{\masknocite} is defined, which
is the same as \cmd{\nocite} with \pkgoption{unmask} and does nothing
with \pkgoption{mask}, and \cmd{\masktext} is defined. The latter has
one mandatory argument, which is the text included in the document
when the \pkgoption{unmask} option is chosen, and one optional
argument (the default being empty), which is the text inserted when
the \pkgoption{mask} option is chosen.

Similarly, with the \pkgoption{natbibapa} option selected, the
following commands are provided:
\cmd{\masknocite},
\cmd{\maskcitep},
\cmd{\maskcitealp},
\cmd{\maskcitet},
\cmd{\maskcitealt},
\cmd{\maskciteauthor},
\cmd{\maskcitefullauthor},
\cmd{\maskciteyearpar},
\cmd{\maskciteyear},
\cmd{\maskcite},
\cmd{\maskcitetalias},
\cmd{\maskcitepalias},
\cmd{\maskCitet},
\cmd{\maskCitep},
\cmd{\maskCitealt},
\cmd{\maskCitealp},
\cmd{\maskCiteauthor},
\cmd{\maskcitenum},
\cmd{\maskciteauthort},
\cmd{\maskciteauthorp},
\cmd{\maskCitefullauthor},
\cmd{\maskCiteauthort},
\cmd{\maskCiteauthorp}, and
\cmd{\masktext}.

\item
Improved source code documentation in the \fname{.dtx} file.

\item
Some minor changes and bug fixes.

\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection*{About this document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The current document describes how to use \pkg{apacite} and largely assumes
knowledge of or access to the standard \BibTeX{} documentation, such as
\citeA{Pata88}, \citeA[Chapter~12]{KoDa04}, or \citeA[Chapters~12 and~13]{TLC2}.
Hence, this document does not always describe how to use some of the citation
commands or how to construct a bibliography database file in detail if there
is no \pkg{apacite}-specific element to it. This document comes in two
versions. The version supplied with the distribution is the user's manual.
As is customary with packages that are distributed in \fname{.dtx} form, it is
also possible to regenerate the user's manual in such a way that it includes
the documented source code of the package as well. This is currently still
in a primitive form compared to other packages, but it will be improved
with later releases. The \fname{README} file describes how the documented
source code can be included in this manual. \citeA{meijer07} contains some
simple examples in which \pkg{apacite} is compared to standard \LaTeX/\BibTeX{}
citation, as well as a description of how \pkg{apacite} works technically.

{\bfseries Note that this manual is not completely up to date.}
This is primarily the case for the specific discussion of the examples
in section~\ref{sec:xmpl}, which focus on the 5th edition of the APA
manual, but there may be some obsolete discussions or omissions elsewhere
in the document as well.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Installation, package loading, and running \BibTeX{}}
\label{sec:usage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pkg{apacite} is distributed as a \fname{.dtx} file, like
most \LaTeX{} packages. The file \fname{apacite.dtx} is supplemented by a
\fname{README} file, which gives a brief introduction and installation
instructions, the user's manual in the file \fname{apacite.pdf} (which you are
reading right now), and the installation file \fname{apacite.ins}. Strictly
speaking, only the \fname{apacite.dtx} file is necessary, because the
installation file is regenerated from it if it is not available, and the user's
manual is generated by running \LaTeX{} on \fname{apacite.dtx}. But it is
customary (and convenient for potential users) to include the other files as
well.

The \LaTeX{} packages, \BibTeX{} style files, and other files in the
distribution are generated by running \LaTeX{} on \fname{apacite.ins}.
This generates the following files:
\begin{description}
\item[\fname{apacite.sty}] The \LaTeX{} citation package. This must
  be placed in a directory where \TeX{} can find it.
\item[\fname{apacite.bst}] The \BibTeX{} reference list style. This
  must be placed in a directory where \BibTeX{} can find it.
\item[\fname{apacitex.bst}] The \BibTeX{} reference list style with
  added author index support. This must also be placed in a directory
  where \BibTeX{} can find it.
\item[\fname{apacann.bst}]
\item[\fname{apacannx.bst}] Versions of \fname{apacite.bst} and
  \fname{apacitex.bst} that generate annotated bibliographies (if the
  \fieldname{annote} and/or \fieldname{annotate} fields are provided). Again,
  these must be placed in a directory where \BibTeX{} can find it. Most
  probably, some time in the future, the four \fname{.bst} files will be
  combined in \fname{apacite.bst}, with the desired behavior induced by
  options, but this is nontrivial and currently not implemented yet.
\item[\fname{apacxmpl.tex}] \LaTeX{} file that (with the bibliography
  database) implements the examples from the APA manual.
  This can best be kept in the same directory as \fname{apacite.dtx}.
\item[\fname{apa5ex.bib}] The file with bibliographic information
  of the examples from the APA manual, this user's manual.
  This is useful for users to find out how
  certain nontrivial problems can be solved. This can best be kept
  in the same directory as \fname{apacite.dtx}.
\item[\fname{apacite.drv}] Documentation driver. Run \LaTeX{} on this
  file to regenerate the user's manual. This is the current document,
  and can also be ontained by running \LaTeX{} on \fname{apacite.dtx},
  but you can edit the file \fname{apacite.drv} to change some settings,
  e.g., choose whether or not the documented source code must be
  included in the manual or not. Please don't edit \fname{apacite.dtx}
  itself. The file \fname{apacite.drv} can best be kept
  in the same directory as \fname{apacite.dtx}.
\item[\fname{*.apc}] Language-specific modifications of \pkg{apacite}.
  See section~\ref{sec:compat-babel} for a discussion of these.
  These must be placed in a directory where \LaTeX{} can find them.
  The files that are currently supplied are \fname{english.apc},
  \fname{dutch.apc},  \fname{finnish.apc}, \fname{french.apc},
  \fname{german.apc}, \fname{ngerman.apc}, \fname{greek.apc},
  \fname{norsk.apc},  \fname{spanish.apc}, and \fname{swedish.apc}.
\item[\fname{apacdoc.sty}] A \LaTeX{} package that contains commands
  and settings used in this user's manual. This can be placed in a
  directory where \TeX{} can find it, but given that it is primarily
  useful for processing the user's manual and not intended as a
  package for wider usage, it can also be left in the same directory as
  \fname{apacite.dtx}. See section~\ref{sec:apacdoc} for a further discussion
  of this package.
\end{description}

The \fname{apacite.sty} \LaTeX{} package is loaded by putting
\mbox{}\vspace{0.7\baselineskip}\\
\cmdthreealt{usepackage}{options}{apacite}
\mbox{}\vspace{0.7\baselineskip}\\
somewhere in your document between \cmd{\documentclass} and
|\begin{document}|, or putting
\mbox{}\vspace{0.7\baselineskip}\\
\cmdthreealt{RequirePackage}{options}{apacite}
\mbox{}\vspace{0.7\baselineskip}\\
in your own personal \LaTeX{} package (say, \fname{mysettings.sty})
that is loaded by your document.

To load the \fname{apacite.bst} or \fname{apacitex.bst} bibliography style in
\BibTeX{}, put
\mbox{}\vspace{0.7\baselineskip}\\
|\bibliographystyle{apacite}|
\mbox{}\vspace{0.7\baselineskip}\\
(or |apacitex|, |apacann|, or |apacannx|) in your document
before the \cmd{\bibliography} command. The
position of the bibliography (reference list) is determined by the line
\mbox{}\vspace{0.7\baselineskip}\\
\cmdtwo{bibliography}{bibfiles}
\mbox{}\vspace{0.7\baselineskip}\\
where \opt{bibfiles} is a list of filenames with \fname{.bib} extension, which
contain the bibliographic information that is used by \BibTeX{} to construct the
reference list. Usually, the \cmd{\bibliographystyle} and \cmd{\bibliography}
are kept together (immediately follow each other) in the document, although when
you are using the \pkg{apa6} document class with \pkg{apacite} support, the
\cmd{\bibliographystyle} is defined by the class and you are not supposed to use
the \cmd{\bibliographystyle} command yourself. See the documentation of the
\pkg{apa6} documentclass for details about this.

If you use one of the author indexing options, the author index is put in
the \LaTeX{} output by the line
\begin{verbatim}
\printindex[autx]
\end{verbatim}
If you put this line in your document, but don't use one of the author
indexing options, it will be ignored. For more on author indexing, see
section~\ref{sec:autindex}.

To get all parts in the final output, the following sequence of runs should
typically be taken (when starting from scratch): (1) \LaTeX{}, (2) \BibTeX{},
(3) \LaTeX{}, (4) \LaTeX{}, and, when author indexing is on, (5) \MakeIndex{},
(6) \LaTeX{}, and (7) \LaTeX{}. The last one is to get the index in the table
of contents. If the table of contents is on a regular page, i.e., an
arabic-numbered page instead of a roman-numbered page in the front matter, it
may even be necessary to run \MakeIndex{} another time, followed by \LaTeX{}
once or twice. Occasionally, somewhere in the process, \LaTeX{} may complain
about labels that may have changed, which requires even more additional
\LaTeX{} runs at that stage. So the number of runs that are necessary to get
everything right may become large.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Package options}
\label{sec:options}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The following options are recognized by \pkg{apacite}:
\begin{description}
\item[\pkgoption{apaciteclassic}]
\item[\pkgoption{natbibapa}]
\item[\pkgoption{nocitation}] \mbox{}\\
  These three option determine which citation commands are defined in
  \pkg{apacite}. \pkgoption{apaciteclassic} defines the ``classic''
  \pkg{apacite} citation commands \cmd{\cite}, \cmd{\citeA}, \cmd{\citeNP},
  and so forth, which use angled bracket syntax for prenotes, for example,
  |\cite<see>[for more details]{ex1}|. These are the commands
  described in section~\ref{sec:cite} below. This is the default in the
  current version, but this may change in the future.

  \pkgoption{natbibapa}
  loads the \pkg{natbib} package for the citation commands. These
  commands, such as \cmd{\citet} and \cmd{\citep}, use double square
  brackets, for example, |\citep[see][for more details]{ex1}|.
  Because these commands are not defined by \pkg{apacite} but by
  \pkg{natbib}, they are not documented in this manual. See the
  \pkg{natbib} documentation for their usage. Using \pkg{natbib} has a
  few advantages over using the classic \pkg{apacite} commands:
  (i) the citation commands are robust, which means they can be used
  inside other commands, such as \cmd{\caption}, whereas the \pkg{apacite}
  commands, like the traditional \LaTeX{} \cmd{\cite} command, are
  fragile and must be \cmd{\protect}ed when used inside other commands;
  (ii) the angled brackets do not normally occur in text mode and when
  they do, they have special meaning; this may lead to incompatibilities;
  (iii) \pkg{natbib} supports sorting citations within a citation
  command, and has commands such as \cmd{\Citet} that capitalize the
  first letter of a citation; the classic \pkg{apacite} commands lack
  this functionality;
  (iv) it is easier to switch to other styles, even to numbered styles.

  When the \pkgoption{nocitation} option is requested, no citation
  commands (except for \cmd{\nocitemeta}) are defined in \pkg{apacite}.
  This may be useful if you want to use another citation package and
  want to avoid potential compatibility conflicts.

  The option \pkgoption{natbibapa} is different from
  \pkgoption{nocitation} combined with loading of \pkg{natbib} by the
  user, because \pkgoption{natbibapa} modifies \pkg{natbib}'s and
  \pkg{apacite}'s behavior in a way that better satisfies the APA
  rules and fixes some compatibility problems.

\item[\pkgoption{BCAY}] \mbox{}\\
  This is a technical option for backwards compatibility with old versions
  (pre-\APACversiondate{2003/09/05}) of \pkg{apacite}. In those versions of
  \pkg{apacite}, the \cmd{\BCAY} construction was used to pass relevant
  citation information from the \fname{.bbl} file (\BibTeX{}'s output) to
  \LaTeX{}. This was taken over from its immediate predecessor, Young U. Ryu's
  \pkg{theapa}. However, \pkg{natbib} does not recognize the \cmd{\BCAY}
  construction, but it does recognize the analogous \cmd{\citeauthoryear}
  construction, which was also used by an earlier predecessor of
  \pkg{apacite}, \pkg{newapa}. Therefore, \pkg{apacite} has reverted to
  \cmd{\citeauthoryear} as well. This makes different versions of
  \pkg{apacite} incompatible with each other, because it is not possible to
  support both constructions at the same time. This option is used to fix
  that: In the (unlikely) event that you \emph{must} use a \fname{.bbl} file
  that is generated by an old version of \pkg{apacite}, you can turn this
  option on.

\item[\pkgoption{mask}]
\item[\pkgoption{unmask}] \mbox{}\\
  Many journals use a double blind refereeing process. To conceal the
  author's identity in such a masked review, it may be necessary to
  suppress some citations, for example, to the working paper version
  of the manuscript under review. \pkg{apa6} introduced masked citation
  commands, which are now included in \pkg{apacite} as well. These
  work as ordinary citations when the \pkgoption{mask} option is not
  requested (or when the \pkgoption{unmask} option is chosen, which
  is the default) and print a message mentioning suppression of citations
  when \pkg{apacite} is loaded with the \pkgoption{mask} option.

\item[\pkgoption{index}]
\item[\pkgoption{indexpackage}]
\item[\pkgoption{noindexpackage}] \mbox{}\\
  The \pkgoption{index} option turns author indexing on. See
  section~\ref{sec:autindex} for a discussion of the author indexing facility.
  The \pkgoption{index} option should be used with the \fname{apacitex.bst}
  (or \fname{apacannx.bst})
  \BibTeX{} style, although it does not give errors with \fname{apacite.bst}
  (or \fname{apacann.bst}),
  but simply does not give author index entries, so then this option
  typically does not have any effect (and an undesirable effect if
  it does). The \pkgoption{indexpackage} and \pkgoption{noindexpackage}
  select whether the author index entries should be generated according
  to the method of the \pkg{index} package or using a more standard-\LaTeX{}
  method.

  By default, if the \pkgoption{index} option is requested, the
  \pkgoption{indexpackage} option is turned on as well, consistent with
  the behavior of previous versions of \pkg{apacite}.

\item[\pkgoption{noindex}] \mbox{}\\
  Turns author indexing off (the default). Typically used with
  \fname{apacite.bst}, but can also be used with \fname{apacitex.bst}. In the
  latter case, the author indexing commands are simply ignored. Therefore,
  \fname{apacite.bst} is actually superfluous, but because author indexing
  will be used rarely and \fname{apacitex.bst} is more likely to lead to errors
  or incompatibilities, a ``clean'' (no author indexing) version,
  \fname{apacite.bst}, is provided as well.

\item[\pkgoption{suppresscorporate}] \mbox{}\\
  Excludes corporate authors from the author index. The \cmd{\bibcorporate}
  command must be used in the \fname{.bib} file to denote a corporate author;
  see sections~\ref{subsec:fields}, \ref{subsec:labels}, and~\ref{sec:autindex}.

\item[\pkgoption{includecorporate}] \mbox{}\\
  Includes corporate authors in the author index, provided that an author index
  is requested of course.

\item[\pkgoption{stdindex}]
\item[\pkgoption{tocindex}]
\item[\pkgoption{emindex}]
\item[\pkgoption{ltxemindex}] \mbox{}\\
  These options select the style of index formatting. They all imply the
  \pkgoption{index} option. The first three of these imply the
  \pkgoption{indexpackage} option, whereas the fourth implies
  \pkgoption{noindexpackage}. See section~\ref{sec:autindex}.

\item[\pkgoption{numberedbib}] \mbox{}\\
  This option implies that the bibliography (reference list) is a numbered
  section or chapter, e.g., ``6.~References'', instead of just ``References''.

\item[\pkgoption{unnumberedbib}] \mbox{}\\
  The reverse of \pkgoption{numberedbib}: The bibliography is an unnumbered
  section or chapter. This is the default. However, it is possible that when
  using the \pkg{apa} document class, then \pkgoption{numberedbib} works
  better, because that class turns section numbering off anyway and it may be
  that \pkg{apa}'s page headings work well if the reference list is a
  \cmd{\section} and not if it is a \cmd{\section*}. I have not experimented
  with this (yet), however.

\item[\pkgoption{sectionbib}] \mbox{}\\
  With this option, the bibliography is a section and not a chapter. Mainly
  useful in combination with the \pkg{chapterbib} package. Therefore, it will
  be discussed in more detail in section~\ref{sec:compat-chapterbib}.

\item[\pkgoption{nosectionbib}] \mbox{}\\
  With this option, the bibliography is a chapter, if the \cmd{\chapter}
  command is defined. Otherwise, it is always a section. Again, see
  section~\ref{sec:compat-chapterbib}.

\item[\pkgoption{tocbib}] \mbox{}\\
  This puts the bibliography in the table of contents, even if it is
  unnumbered, provided of course that a table of contents is requested in the
  document (by \cmd{\tableofcontents}). This is the default.

\item[\pkgoption{notocbib}] \mbox{}\\
  This does not put the bibliography in the table of contents if it is an
  unnumbered section or chapter. If it's numbered, it is always in the table
  of contents.

\item[\pkgoption{bibnewpage}] \mbox{}\\
  The bibliography is started on a new page. This is required by some journal
  styles, including the APA manual. The \pkg{apa} class already contained this
  in its \pkgoption{man} option, but now it has been made available directly
  in \pkg{apacite}.

\item[\pkgoption{nobibnewpage}] \mbox{}\\
  The bibliography is not explicitly started on a new page, although if the
  bibliography is a chapter, it will be started on a new page anyway, because
  chapters are started on a new page. This is the default in \pkg{apacite} and
  thus is the only time a non-APA setting is used as default instead of an
  available APA setting. Therefore, to satisfy the APA rules, you have to
  request the \pkgoption{bibnewpage} option explicitly.

\item[\pkgoption{doi}] \mbox{}\\
  Includes doi information in the reference list; the default.

\item[\pkgoption{nodoi}] \mbox{}\\
  Suppresses doi information in the reference list.

\end{description}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{The citation commands}
\label{sec:cite}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This section describes the commands that can be used to cite a work.
Section~\ref{sec:classic} describes the commands available with the
\pkgoption{apaciteclassic} option selected. Section~\ref{sec:natbibapa}
is devoted to the citation commands with the \pkgoption{natbibapa}
command selected. Apart from differences in syntax, there are a few
important differences between these sets of commands:
\begin{itemize}
\item
The \pkgoption{apaciteclassic} commands are \emph{fragile}, like the
standard \LaTeX{} \cmd{\cite} command. This means that they cannot be
used in other commands, like \cmd{\caption}, unless they are protected
by putting \cmd{\protect} before them, for example,
\begin{verbatim}
\caption{Theoretical constructs from \protect\citeA{Jones01}}
\end{verbatim}
In contrast, the \pkg{natbib}/\pkgoption{natbibapa} commands are
\emph{robust}, so they can be used in other commands without the
need for \cmd{\protect}.
\item
The use of the angled brackets (`|<|' and `|>|') in the
\pkgoption{apaciteclassic} commands sometimes causes compatibility
problems, for example, with certain options of the \pkg{babel}
package, such as \pkgoption{spanish}.
\item
With the \pkgoption{sort} option, \pkg{natbib} sorts citations
within the same citation command in the same order as in the reference
list, as required by the APA manual (p.~178). Therefore, when
\pkg{apacite} is loaded with the \pkgoption{natbibapa} option, it
loads \pkg{natbib} with the \pkgoption{sort} option.
Sorting is not implemented in the \pkgoption{apaciteclassic} commands,
and thus the user will need to manually order the citations
alphabetically.
\item
\pkg{natbib} provides a set of commands (e.g., \cmd{\Citet}) that
capitalize the first letter of a citation. This can be used when
a citation, of which the first author's name starts with a lowercase
letter, starts a sentence (APA manual, p.~101). This behavior would
be very hard to reproduce with the \pkgoption{apaciteclassic}
commands.
\end{itemize}
Overall, I believe that the \pkg{natbibapa} option will be preferred
by most users, and I expect that I will make this the default in a
future release of \pkg{apacite}. However, because most users of
\pkg{apacite} will still be working on documents that use the
\pkgoption{apaciteclassic} commands, this is still the default in the
current version.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{The ``classic'' \pkg{apacite} citation commands}
\label{sec:classic}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This section describes the default behavior of the citation commands
that are avilable with the \pkgoption{apaciteclassic} option.
In section~\ref{sec:custom}, customization of this behavior will be
discussed. Extensive examples are given in section~\ref{sec:xmpl}
and the new examples file described there. Table~\ref{tab:basic-cite}
gives a brief impression of the usage and results of the most common
citation commands.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{table}[tp]
\begin{center}
\caption{Examples of usage of basic citation commands.}
\label{tab:basic-cite}
\begin{tabular}{@{}ll@{}}
\hline
Command & Result \\
\hline
|\cite<e.g.,>[p.~11]{Jone01,Ross87}|       &
   (e.g., Jones, 2001; Ross, 1987, p.~11) \\
|\citeA<e.g.,>[p.~11]{Jone01,Ross87}|      &
   e.g., Jones (2001); Ross (1987, p.~11) \\
|\citeauthor<e.g.,>[p.~11]{Jone01,Ross87}| &
   e.g., Jones; Ross, p.~11 \\
|\citeyear<e.g.,>[p.~11]{Jone01,Ross87}|   &
   (e.g., 2001; 1987, p.~11) \\
|\citeyearNP<e.g.,>[p.~11]{Jone01,Ross87}|   &
   e.g., 2001; 1987, p.~11 \\
|\citeNP<e.g.,>[p.~11]{Jone01,Ross87}|       &
   e.g., Jones, 2001; Ross, 1987, p.~11 \\
\hline
\end{tabular}
\end{center}
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Structure of the citation commands;
  parenthetical citations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\cite}
The traditional \LaTeX{} citation command is \cmd{\cite}, and
\pkg{apacite} reimplements this command. This command is used for
\emph{parenthetical} citations. For example,
``|\cite{Jone01}|'' results in ``(Jones, 2001)''. Here,
|Jone01| is the \emph{key} that identifies the reference; it is
defined in the \fname{.bib} file, see section~\ref{sec:bib}.
An optional postfix---text that follows the actual citation---can
be added as a standard \LaTeX{} optional argument in square brackets:
``|\cite[p.~11]{Jone01}|'' results in ``(Jones, 2001, p.~11)''.
Similarly, an optional prefix can be added between angled brackets:
``|\cite<e.g.,>{Jone01}|'' results in ``(e.g., Jones, 2001)''.
Finally, there can be both a prefix and a postfix (in that order):
``|\cite<e.g.,>[p.~11]{Jone01}|'' results in
``(e.g., Jones, 2001, p.~11)''. As usual, multiple references
can be included within the same citation:
``|\cite<e.g.,>[p.~11]{Jone01, Ross87}|'' results in
(e.g., Jones, 2001; Ross, 1987, p.~11). The citation keys of multiple
citations must be separated by commas, with optional spaces after the
commas.

By default, \pkg{apacite} follows the APA rules and includes the
citation in round parentheses, separates the author and year by a
comma, the different references by a semicolon, and the year and
the postfix by a comma, but this can all be changed by the user;
see section~\ref{sec:custom}.

\pkg{apacite} defines a large number of alternative citation
commands, but they all have this same structure:
\cmdfour{command}{prefix}{postfix}{keys}. However, the prefix, and to
a lesser extent the postfix, are most useful with the parenthetical
citation commands.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Text citations; splitting author and year; no
parentheses}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\citeA}
The \cmd{\citeA} command produces text citations:
``|\citeA{Jone01}|'' results in ``Jones (2001)'' and.
``|\citeA[p.~11]{Jone01}|'' results in ``Jones (2001, p.~11)''.
Prefixes are generally not useful for text citations (you can simply
include the prefix in the text), but supported. Multiple citations
are also supported. These are typically only useful for cases in which
the authors are the same and only the year is repeated:
``|\citeA{Jone01, Jone02}|'' results in ``Jones (2001, 2002)''.
Corresponding with the APA rules, an ``and'' before the last author
is formatted as ``and'' in text citations, whereas it is formatted
as ``\&'' in parenthetical citations:
``|\citeA{SmJo03}|'' gives ``Smith and Jones (2003)'', whereas
``|\cite{SmJo03}|'' gives ``(Smith \& Jones, 2003)''.

\DescribeMacro{\citeauthor}
If a proper citation has been given in a paragraph,\footnote{Note that
a paragraph is not a section. Nor does it need to be declared as a
\cmd{\paragraph}. A reminder for Dutch readers: ``section'' =
``paragraaf'' and ``paragraph'' = ``alinea''.}
the second reference to the source may omit the year if no ambiguity
can  arise (APA manual, p.~174). The \cmd{\citeauthor} command can
be used for such purposes:
\begin{verbatim}
\citeA{Jone01} argued that [...]. The empirical results of
\citeauthor{Jone01} supported his argument.
\end{verbatim}
gives ``Jones (2001) argued that [\ldots]. The empirical results of
Jones supported his argument.''

\DescribeMacro{\citeyear}
The \cmd{\citeyear} command gives just the year part of a text
citation. This can be used for constructions like
``|\citeauthor{Jone01}' \citeyear{Jone01} method|'', which
gives ``Jones' (2001) method''. Note that \cmd{\citeyear} inserts the
parentheses.

\DescribeMacro{\citeyearNP}
Some constructions may require even more flexibility. The
\cmd{\citeyearNP} command (NP = no parentheses) omits the
parentheses, which can be useful for a construction like
``|In \citeyearNP{Jone01},| |\citeauthor{Jone01}| |introduced|
|his method|'', which gives ``In 2001, Jones introduced his method''.

\DescribeMacro{\citeauthorNP}
As mentioned above, text citations use ``and'' between authors,
whereas parenthetical citations use ``\&''. The, \cmd{\citeauthor}
command is a text citation command and thus should not be used
in a parenthetical citation; \cmd{\citeauthorNP} is the corresponding
parenthetical command, which gives just the authors, but now with
``\&'' when applicable. Note that neither \cmd{\citeauthor} nor
\cmd{\citeauthorNP} insert parentheses. In hindsight, it would have
been more logical---following \cmd{\cite} and \cmd{\citeA}---to use
\cmd{\citeauthorA} for what is now \cmd{\citeauthor} and
\cmd{\citeauthor} for what is now \cmd{\citeauthorNP}, but
\cmd{\citeauthor} already existed as a text citation command in
\pkg{apacite}'s predecessor \pkg{theapa}, it is used as such in
some other packages (e.g., \pkg{natbib}), and I didn't realize at
the time that \pkg{apacite} would need both. Therefore, the name
\cmd{\citeauthorNP} is modeled after \cmd{\citeNP}

\DescribeMacro{\citeNP}
The \cmd{\citeNP} command is \cmd{\cite} without the parentheses.
This is useful for complex constructions like
\begin{verbatim}
\citeauthor{Jone01} (\citeyearNP{Jone01}; see also \citeNP{SmJo03})
\end{verbatim}
which gives
``Jones (2001; see also Smith \& Jones, 2003)''.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{References without citation}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\nocite}
The standard \LaTeX{} command \cmd{\nocite} is also provided by
\pkg{apacite}; \cmdtwo{nocite}{keys} includes the references
corresponding with the keys in the reference list, but does not
generate a citation in the text. Therefore, it does not allow a pre-
or postfix. However, it does allow multiple citations. Like the
standard \LaTeX{} command, |\nocite{*}| includes all references
from the \fname{.bib} file in the reference list. In general, the APA
requires (p.~174) that each reference list entry should be cited in
the text, and thus this command will rarely be used in APA style
manuscripts. One potential application is a meta-analysis based
on more than 50 works. (See \cmd{\nocitemeta} below.)

\DescribeMacro{\nocitemeta}
An exception to the one-to-one correspondence requirement between
citations and reference list is when a meta-analysis is reported.
This is a quantitative analysis with results, e.g., regression
coefficients, from published work used as data in the current work.
Studies that are included in the meta-analysis should be included
in the reference list, but do not need to be cited. They should,
however, be marked with an asterisk in the reference list. This
can be obtained by using \cmd{\nocitemeta}, which is otherwise
identical to \cmd{\nocite}: the syntax is \cmdtwo{nocitemeta}{keys}
and |\nocitemeta{*}| includes all entries from the \fname{.bib} file
in the reference list and flags all of them with an asterisk. This
is an unlikely situation, though. Because other packages, in particular
\pkg{natbib} do not define \cmd{\nocitemeta} or an analogous command,
\pkg{apacite} provides \cmd{\nocitemeta} regardless of whether the
\pkgoption{apaciteclassic}, \pkgoption{natbibapa}, or even
\pkgoption{nocitation} option is requested.

If a meta-analysis includes more than 50 studies, these should not
be included in the main reference list, but in a separate online
supplemental archive (APA manual, p.~183). \pkg{apacite} currently
does not count the number of references included in the meta-analysis,
and thus does not check whether the references should be included in
a separate online supplemental archive, it does not disable the
\cmd{\nocitemeta} command, and it does not automatically generate
the supplemental document. This is the responsibility of the user.
If there is demand for it, I might implement such a counter so that
\pkg{apacite} can give a warning at the end of the \LaTeX{} run that
there are more than 50 references included in the meta-analysis.
Presumably, in the online supplemental archive, the references are
not marked with an asterisk, so this would be an example where
\cmd{\nocite} can be useful.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Full and short author lists}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\fullcite}
\DescribeMacro{\fullciteA}
\DescribeMacro{\fullciteNP}
\DescribeMacro{\fullciteauthor}
\DescribeMacro{\fullciteauthorNP}
When citing a work with one or two authors, all authors are included
in each citation. When citing a work with six or more authors, only
the first author's name is included in the text, followed by
``et al.\hbox{}''. With three to five authors, the full list is
included the first time the work is cited, and only the first with
``et al.\hbox{}'' in subsequent citations.

\DescribeMacro{\shortcite}
\DescribeMacro{\shortciteA}
\DescribeMacro{\shortciteNP}
\DescribeMacro{\shortciteauthor}
\DescribeMacro{\shortciteauthorNP}
There are some special cases, where some of the authors and the year
are the same, but not the whole author list, in which more names are
retained on subsequent citations as well. Section~\ref{sec:xmpl}
includes some examples of complex situations and how to deal with
them. All of this is automatically handled by \pkg{apacite}.

However, occasionally one may want to use the full
author list even after a first citation, or the short author list in
the first citation. For such (rare) cases, \pkg{apacite} provides
``full'' and ``short'' versions of all citation commands that include
an author (list) in the text. Other than forcing the full or short
author list in the text, these commands are identical to the versions
without ``|full|'' or ``|short|''.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Masked citations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\maskcite}
\DescribeMacro{\maskciteA}
\DescribeMacro{\maskciteNP}
\DescribeMacro{\maskciteauthor}
\DescribeMacro{\maskciteauthorNP}
\DescribeMacro{\maskciteyear}
\DescribeMacro{\maskciteyearNP}
Many journals use a ``masked'' or double-blind review process, in
which the identities of the authors are concealed from the reviewers.
As the APA manual states (p.~226), it is the responsibility of the
authors to ensure that the content of the manuscript does not reveal
their identities. This may include suppressing citations to other
work by the authors, in particular unpublished material, such as
the working paper version of the manuscript under review. To this
end, the \pkg{apa6} class introduced ``masked'' citation commands,
which produce the desired citation for the unmasked mode, but
insert a message stating that citations have been masked in masked
mode. Because these are citation commands, they are more properly
included in \pkg{apacite}, and they now are. I am coordinating with
\pkg{apa6}'s author Brian Beitzel on this issue (and other points
of interaction between \pkg{apa6} and \pkg{apacite}).

\DescribeMacro{\maskfullcite}
\DescribeMacro{\maskfullciteA}
\DescribeMacro{\maskfullciteNP}
\DescribeMacro{\maskfullciteauthor}
\DescribeMacro{\maskfullciteauthorNP}
All the citation commands introduced in this section have a
corresponding masked version, which has the same syntax and the same
name, except that ``|mask|'' is inserted immediately after the
backslash. Thus, the masked version of \cmd{\cite} is \cmd{\maskcite},
the masked version of \cmd{\fullciteauthorNP} is
\cmd{\maskfullciteauthorNP}, and so forth.

\DescribeMacro{\maskshortcite}
\DescribeMacro{\maskshortciteA}
\DescribeMacro{\maskshortciteNP}
\DescribeMacro{\maskshortciteauthor}
\DescribeMacro{\maskshortciteauthorNP}
When \pkg{apacite} is loaded with the \pkgoption{mask} option, these
masked citation commands insert the message
``\emph{(1\ citation removed for masked review)}'', or
``\emph{(2\ citations removed for masked review)}'', and so forth,
depending on the number of citations included in the citation
command. When \pkg{apacite} is loaded with the \pkgoption{unmask}
option (the default), the masked citation commands are equivalent
to the same commands without the ``|mask|''.

\DescribeMacro{\masknocite}
\DescribeMacro{\masktext}
%% \DescribeMacro{\maskcitations}
%% \DescribeMacro{\unmaskcitations}
In addition to the masked citation commands, \pkg{apacite} also
provides \cmd{\masknocite}, although its usefulness seems even more
remote than \cmd{\nocite} itself in APA style documents. Because
\cmd{\nocite} does not insert a citation, \cmd{\masknocite} does
not remove citations in \pkgoption{mask} mode. It only prevents an
entry in the reference list. Therefore, this command does not
insert a message about removed citations in the text either. Hence,
it does nothing in \pkgoption{mask} mode. An additional command
provided by \pkg{apacite} is \cmd{\masktext}. This has one mandatory
argument, the text that is to be masked. It also has an optional
argument, which is the text to be inserted in \pkgoption{mask} mode.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Ad-hoc citation commands}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
In order to format the examples from the APA manual correctly in
section~\ref{sec:xmpl}, the \fname{apacdoc.sty} package defines the
following additional citation commands: \cmd{\DSMcite},
\cmd{\biblecite}, and \cmd{\citesong}, and obvious variations with
|full|, |short|, |A|, and |NP|. I have decided not to include these
in \fname{apacite.sty}, primarily because I find it unattractive to
introduce different types of citation commands for different types of
citations. This also makes it more difficult to use the same document
with another citation package. Perhaps I'll be able to provide,
in a future version of \pkg{apacite}, more elegant solutions to the
problems for which these commands were defined. See
section~\ref{sec:apacdoc} for a description of the \fname{apacdoc.sty}
package and some brief usage instructions.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Using \pkg{natbib} for citations}
\label{sec:natbibapa}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
With the \pkgoption{natbibapa} option, \pkg{apacite} loads \pkg{natbib}
with the options \pkgoption{longnamesfirst} and \pkgoption{sort}. The
former inserts the full author lists in the first citation and the
short author lists in subsequent citations, in the same way the
\pkgoption{apaciteclassic} commands do. The \pkgoption{sort} option
sorts the citations within the same citation command in the same order
as in the reference list, as required by the APA manual (p.~178).
In addition to loading \pkg{natbib}, \pkg{apacite} includes some
code to improve the interoperability, and it defines some additional
commands that are specific to the \pkg{natbib}-\pkg{apacite}
combination. The latter will be described below.

Because the citation commands are defined by \pkg{natbib}, this is
not the place for extensive documentation of them. See the \pkg{natbib}
documentation. However, for completeness, I provide very brief
information here. Table~\ref{tab:natbibapa} lists the commands and
a brief description.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{table}[tp]
\centering
\caption{The \pkg{natbib} citation commands.}
\label{tab:natbibapa}
\begin{tabular}{@{}ll@{}}
\hline
Command             & Description \\
\hline
\cmd{\citep}        & Parenthetical citation           \\
\cmd{\citet}        & Text citation                    \\
\cmd{\citeauthor}   & Author only (text citation)      \\
\cmd{\citeyear}     & Year only (no parentheses)       \\
\cmd{\citeyearpar}  & Year citation (with parentheses) \\
\cmd{\citealp}      & Parenthetical citation without the parentheses \\
\cmd{\citealt}      & Text citation without the parentheses          \\
\cmd{\citenum}      & Number of the reference                        \\
\cmd{\nocite}       & No citation, only reference list entry         \\
\cmd{\Citep} etc.   & Capitalized citation               \\
\cmd{\citep*} etc.  & Full author lists                  \\
\cmd{\shortcites}   & Short author lists                 \\
\cmd{\defcitealias} & Define alias (e.g., \emph{DSM-IV}) \\
\cmd{\citepalias}   & Parenthetical citation of alias    \\
\cmd{\citetalias}   & Text citation of alias             \\
\cmd{\citetext}     & Arbitrary text within citation parentheses \\
\hline
\end{tabular}
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Compared to the \pkgoption{apaciteclassic} commands,
the \pkg{natbib} commands use square brackets for both the prefix and
the postfix: ``|\command[prefix][postfix]{keys}|''. If only one
optional argument is present, it is interpreted as a postfix. A
citation with only a prefix is obtained by using both optional
arguments, but leaving the postfix empty:
``|\command[prefix][]{keys}|''. The full author list is obtained
by adding a star after the command, for example, |\citet*{key}|.
There is no separate command for the short author list, but it can
be obtained with the construction |\shortcites{key}\citet{key}|.
The first letter of the author list is capitalized with citation
commands that capitalize the first letter of the citation command,
such as \cmd{\Citet}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Filling some gaps and other additions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\citeauthorp}
\DescribeMacro{\citeauthort}
\DescribeMacro{\Citeauthorp}
\DescribeMacro{\Citeauthort}
As mentioned in section~\ref{sec:classic}, the APA requires that
``and'' between authors is ``and'' in text citations and ``\&'' in
parenthetical citations, and therefore the \pkgoption{apaciteclassic}
option defines two author-citing commands: \cmd{\citeauthor} for
text citations and \cmd{\citeauthorNP} for parenthetical citations.
However, \pkg{natbib} only provides \cmd{\citeauthor}. For
consistency with \cmd{\citep} and \cmd{\citet}, when loaded with the
\pkgoption{natbibapa} option, \pkg{apacite} defines
\cmd{\citeauthorp} for parenthetical use and \cmd{\citeauthort} for
text use, and the corresponding capitalized versions \cmd{\Citeauthorp}
and \cmd{\Citeauthort}. The default command \cmd{\citeauthor} is a
text citation command, so it's equivalent to \cmd{\citeauthort}.

%% \DescribeMacro{\citefullauthorp}
%% \DescribeMacro{\citefullauthort}
%% \DescribeMacro{\Citefullauthorp}
%% \DescribeMacro{\Citefullauthort}

\DescribeMacro{\bibstyle@apacite}
\DescribeMacro{\bibstyle@apa}
The \pkg{natbib} package is also highly customizable, and one of
the ways it allows customization is by the \cmd{\bibstyle@xxx}
commands, which typically define the desired punctuation through
\cmd{\bibpunct} and may define other customizations. These are
executed by using the command |\citestyle{xxx}|. Furthermore, when
\pkg{natbib} is loaded, it checks the bibliography style and if it
is \fname{xxx.bst}, then it tries to execute |\citestyle{xxx}| if
defined. With the \pkgoption{natbibapa} option, \pkg{apacite}
defines \cmd{\bibstyle@apacite}, and as a synonym, \cmd{\bibstyle@apa}.
Thus, the APA punctuation defaults can be obtained with
|\citestyle{apacite}| or |\citestyle{apa}|, which are executed
by \pkg{apacite}, so the user only needs to do this if the style
has been changed.

\DescribeMacro{\maskcitep}
\DescribeMacro{\maskcitet}
\DescribeMacro{\maskciteauthor}
\DescribeMacro{\maskciteyear}
\DescribeMacro{\maskciteyearpar}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Masked citations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\maskcitealp}
\DescribeMacro{\maskcitealt}
\DescribeMacro{\maskcitenum}
\DescribeMacro{\maskcitetalias}
\DescribeMacro{\maskcitepalias}
Section~\ref{sec:classic} described masked citation commands that
can be used in double-blind review processes in an effort to conceal
the identity of the authors. Because \pkg{natbib} itself does not
define such commands, \pkg{apacite} with the \pkgoption{natbibapa}
option defines a full set of \pkg{natbib}-style masked citation
commands. Again, these are identical to the un-|mask| version if
the \pkgoption{mask} option is not requested, but insert a message
about removed citations when the \pkgoption{mask} option is requested.

\DescribeMacro{\maskCitep}
\DescribeMacro{\maskCitet}
\DescribeMacro{\maskCiteauthor}
\DescribeMacro{\maskCitealp}
\DescribeMacro{\maskCitealt}
%% The |\mbox{}| is necessary to avoid errors about too many
%% unprocessed floats. This gives some ugly vertical whitespace, but
%% the only alternative would be to write some superfluous paragraphs,
%% which is equally unattractive.
\mbox{}

\DescribeMacro{\maskciteauthorp}
\DescribeMacro{\maskciteauthort}
\DescribeMacro{\maskCiteauthorp}
\DescribeMacro{\maskCiteauthort}
\DescribeMacro{\masknocite}
\DescribeMacro{\masktext}
\mbox{}

%% \DescribeMacro{\maskcite}
%% \DescribeMacro{\maskcitefullauthor}
%% \DescribeMacro{\maskCitefullauthor}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Contents of the bibliography database file}
\label{sec:bib}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The information that is used by \LaTeX/\BibTeX{} to generate
the citations and reference list must be stored by the user in one
or more files with the \fname{.bib} extension.
A detailed overview of the contents of the \fname{.bib} file is
given in \citeA[section~12.2]{KoDa04} and \citeA[section~13.2]{TLC2}.
Roughly speaking, the
\fname{.bib} file consists of a collection of \emph{entries}
of the form
\mbox{}\vspace{0.7\baselineskip}\\
\verb+@+\opt{entryname}\verb+{+\opt{contents}\verb+}+
\mbox{}\vspace{0.7\baselineskip}\\
Most entries describe a work that may be referenced, e.g., a book
or article. There are, however, two exceptions: a \entryname{preamble}
entry (with \opt{entryname} = \verb+preamble+) and a \entryname{string}
entry (with \opt{entryname} = \verb+string+). There is typically
at most one \entryname{preamble} entry. Its \opt{contents} consist of a
string---according to \BibTeX, i.e., between double quotes (\verb+"+)
or an additional pair of braces (\verb+{+ and \verb+}+). This
string, which typically consists of \LaTeX{} commands like
\verb+\newcommand{\SortNoop}[1]{}+, is literally included
in the document before the bibliography. It can therefore be used
to define commands that are used in the (other) entries of the
\fname{.bib} file and that are not standard \LaTeX{}.

A \entryname{string} entry is similar, but the contents are now not
included in the document. Instead, the string is assigned to a kind of
``variable'', the name of which may contain characters
not usually associated with variable names, like colons and
hyphens, see \citeA[p.~769]{TLC2}. An example of a
\entryname{string} entry is
\begin{verbatim}
@string{ JPSP = {Journal of Personality and Social Psychology} }
\end{verbatim}
Then, if in a later entry, the journal is
\emph{Journal of Personality and Social Psychology}, you can format this
as
\begin{verbatim}
  journal = JPSP,
\end{verbatim}
instead of the usual
\begin{verbatim}
  journal = {Journal of Personality and Social Psychology},
\end{verbatim}
This is not only convenient because it saves typing of common
long journal names (and reduces the likelihood of typos), but it can
also be used to define style-specific variations. For example, some
styles abbreviate journal names, such as
\emph{J.~Pers.\ Soc.\ Psych.}\hbox{} instead of
\emph{Journal of Personality and Social Psychology}.
You could then put the definitions of all full journal names
in one \fname{.bib} file (\fname{fulljou.bib}, say) and the definitions
of the abbreviated journal names in another (\fname{abbrjou.bib}, say).
Suppose that the information about the referenced works is stored in a
third file, say, \fname{myrefs.bib}, and that the ``NotAPA''
style rules, implemented in the \fname{notapa.bst} \BibTeX{} style file,
require the abbreviated journal names. Then you can use
\begin{verbatim}
\bibliographystyle{notapa}
\bibliography{abbrjou,myrefs}
\end{verbatim}
to obtain a reference list complying with the ``NotAPA'' rules. If
you change your mind and decide to switch to using the rules of the
APA manual, you only need to change the two lines above into
\begin{verbatim}
\bibliographystyle{apacite}
\bibliography{fulljou,myrefs}
\end{verbatim}
(and additionally load the \fname{apacite.sty} \LaTeX{} package
through \cmd{\usepackage}).

The remaining entry types are types that correspond with the
type of a referenced work, e.g., \entryname{book} or
\entryname{article}. These entry types (reference types) are
discussed in section~\ref{subsec:types} below.
Such entries have the following structure:
\mbox{}\vspace{0.7\baselineskip}\\
\verb+@+\opt{entryname}\verb+{+\opt{key}\verb+,+\\
$\mbox{}\qquad$\opt{fieldname1}\verb+ = +\opt{value1}\verb+,+\\
$\mbox{}\qquad$\opt{fieldname2}\verb+ = +\opt{value2}\verb+,+\\
$\mbox{}\qquad\qquad\vdots$\\
$\mbox{}\qquad$\opt{fieldnameN}\verb+ = +\opt{valueN}\verb+,+\\
\verb+}+
\mbox{}\vspace{0.7\baselineskip}\\
where \opt{key} corresponds to the key used in the citation
commands and matches the entry with the citation (and should
therefore be unique). The fieldnames are \verb+author+, \verb+year+,
etc., which are described in section~\ref{subsec:fields} below.
The values are strings, either defined previously by a
\entryname{string} entry or explicitly indicated as such here
by putting the relevant information between double quotes
(\verb+"+) or a pair of braces (\verb+{+ and \verb+}+).

To be able to obey the rules of the APA manual, \pkg{apacite}
provides several fields and reference types that are not
described in the standard \BibTeX{} documentation
\cite<e.g.,>[Chapter~13]{TLC2}. Furthermore,
the meaning and usage of many fields and reference types that
\emph{are} described there have been altered somewhat. Therefore,
a complete description is given here.
The symbol \LC{} will be used to indicate that the field or
reference type is also described in \citeA[Appendix~B]{LaTeXbook},
\citeA[Chapter~12]{KoDa04}, or \citeA[Chapter~13]{TLC2}, although, as
mentioned above, the specific meaning of the item may have been
changed.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Types of references}
\label{subsec:types}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
In this section, the list of reference types that are recognized by
\pkg{apacite} is given. An overview of which fields can be used for which
reference type is given in Table~\ref{tab:fieldref}. If fields are not
relevant, but you use them anyway in your \fname{.bib} file, they are ignored.
The fields and their use are described in more detail in
section~\ref{subsec:fields}, but here some specific issues will already be
mentioned.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{table}[p]
\centering
\caption{List of fields that are used by the various reference types
         (blank = not used; \X{} = used;
          \Y{} = used, but only for citations; \A{} = only used by
          \pkg{apacann} and \pkg{apacannx}).}
\label{tab:fieldref}
\small
\makebox[0pt]{% some manipulation to squeeze the table onto the page
\newlength{\oldtabcolsep}
\setlength{\oldtabcolsep}{\tabcolsep}
\setlength{\tabcolsep}{2pt}
\begin{tabular}{@{}l@{}cccccccccc@{}}
\hline
 & \multicolumn{10}{c}{Reference type}\\
   \cline{2-11}
%
% Normally, I would use the sideways environment of the rotating
% package to format this nicely, but I do not want to require
% other packages to format this document, so I choose an uglier
% solution here.
%
 & article\\
 & magazine   &      &              &            &              &
 & phdthesis
 &
 & manual\\
Field
 & newspaper  & book & incollection & techreport & intechreport & lecture
 & mastersthesis
 & unpublished
 & misc
 & literal\\
\hline
address           &  &\X&\X&\X&\X&\X&\X&\X&\X&  \\
annote            &\A&\A&\A&\A&\A&\A&\A&\A&\A&\A\\
annotate          &\A&\A&\A&\A&\A&\A&\A&\A&\A&\A\\
author            &\X&\X&\X&\X&\X&\X&\X&\X&\X&  \\
booktitle         &  &  &\X&  &\X&  &  &  &  &  \\
chair             &  &  &  &  &  &\X&  &  &  &  \\
chapter           &  &  &\X&  &  &  &  &  &  &  \\
day               &\X&  &\X&\X&\X&\X&  &\X&\X&  \\
doi               &\X&\X&\X&\X&\X&\X&\X&\X&\X&\X\\
edition           &  &\X&\X&\X&\X&  &\X&  &\X&  \\
editor            &\X&\X&\X&\X&\X&  &  &\X&\X&  \\
englishtitle      &\X&\X&\X&\X&\X&\X&\X&\X&\X&  \\
firstkey          &\Y&\Y&\Y&\Y&\Y&\Y&\Y&\Y&\Y&\Y\\
howpublished      &\X&\X&\X&\X&\X&\X&\X&\X&\X&  \\
institution       &  &  &  &\X&\X&  &  &  &  &  \\
journal           &\X&  &  &  &  &  &\X&  &  &  \\
key               &\Y&\Y&\Y&\Y&\Y&\Y&\Y&\Y&\Y&\Y\\
lastchecked       &\X&\X&\X&\X&\X&\X&\X&\X&\X&  \\
month             &\X&  &\X&\X&\X&\X&  &\X&\X&  \\
note              &\X&\X&\X&\X&\X&\X&\X&\X&\X&  \\
number            &\X&\X&  &\X&\X&  &\X&\X&\X&  \\
organization      &  &  &  &  &  &  &  &\X&  &  \\
originaladdress   &\X&\X&\X&  &\X&  &  &  &  &  \\
originalbooktitle &\X&\X&\X&  &\X&  &  &  &  &  \\
originaledition   &\X&\X&\X&  &\X&  &  &  &  &  \\
originaleditor    &\X&\X&\X&  &\X&  &  &  &  &  \\
originaljournal   &\X&\X&\X&  &\X&  &  &  &  &  \\
originalnumber    &\X&\X&\X&  &\X&  &  &  &  &  \\
originalpages     &\X&\X&\X&  &\X&  &  &  &  &  \\
originalpublisher &\X&\X&\X&  &\X&  &  &  &  &  \\
originalvolume    &\X&\X&\X&  &\X&  &  &  &  &  \\
originalyear      &\X&\X&\X&\Y&\X&\Y&\X&\Y&\Y&\Y\\
pages             &\X&  &\X&  &\X&  &\X&  &  &  \\
publisher         &  &\X&\X&  &  &  &  &  &\X&  \\
school            &  &  &  &  &  &  &\X&  &  &  \\
series            &  &  &  &  &  &  &  &  &  &  \\
symposium         &  &  &  &  &  &\X&  &  &  &  \\
text              &  &  &  &  &  &  &  &  &  &\X\\
title             &\X&\X&\X&\X&\X&\X&\X&\X&\X&  \\
translator        &\X&\X&\X&\Y&\X&\Y&\Y&\Y&\Y&\Y\\
type              &\X&\X&\X&\X&\X&\X&\X&\X&\X&  \\
url               &\X&\X&\X&\X&\X&\X&\X&\X&\X&  \\
urldate           &\X&\X&\X&\X&\X&\X&\X&\X&\X&  \\
volume            &\X&\X&\X&\X&\X&  &\X&  &\X&  \\
year              &\X&\X&\X&\X&\X&\X&\X&\X&\X&\Y\\
\hline
\end{tabular}%
\setlength{\tabcolsep}{\oldtabcolsep}
}
%
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The following entry types (reference types) are defined in \pkg{apacite}:
\begin{description}
    \item[\entryname{article}\LC] \mbox{}\\
        A journal article or comparable. If the
        ``article'' referenced to is a special issue of a journal or
        something else that has editors instead of authors, the
        \fieldname{author} field should be empty and the \fieldname{editor}
        field should be used for the editors. If the journal paginates
        by issue instead of by volume, or when you are referring to a
        whole special issue, the issue number should be given
        in the \fieldname{number} field. In all other cases (including
        referring to an article within a special issue), the
        \fieldname{number} field must not be used. The \fieldname{type}
        field can be used to denote the type of article, for example,
        ``\verb+Letter to the editor+'', or
        ``\verb+Review of the book \emph{Life in the middle}+''.

    \item[\entryname{magazine}] \mbox{}\\
        A magazine article. Unlike in early versions of \pkg{apacite},
        this is now equivalent to \entryname{article}. However, with
        an \entryname{article}, the \fieldname{month} and \fieldname{day}
        fields should generally not be used, unless there is a compelling
        reason to use them. For a magazine, the \fieldname{month}, and
        \fieldname{day} (for weeklies) fields are commonly used.

    \item[\entryname{newspaper}] \mbox{}\\
        A newspaper article. This is similar to \entryname{article} and
        \fieldname{magazine}, except that the pages are formatted a little
        different, with ``pp.~23--49'' instead of just ``23--49''.

    \item[\entryname{book}\LC] \mbox{}\\
        An entire book. The \fieldname{type} field can be used
        to denote a specific type of item (so generally not strictly
        a book), e.g., ``\verb+Brochure+''. Similarly, the
        \fieldname{number} field can be used if this is considered
        useful. (It is used in example 24 in the APA manual, see
        below.) This seems quite rare to me, however. It should
        certainly \emph{not} be used for ISBN numbers and the like.

    \item[\entryname{incollection}\LC] \mbox{}\\
        An article in a (usually edited) book, or other kind of larger
        work, except a report, for which the \entryname{intechreport}
        entry is used. The \fieldname{booktitle} field contains the
        title of the whole collection (book). The \fieldname{type}
        field is currently used to denote the type of article, as
        with the \entryname{article} reference type, although in some
        cases, it may be more naturally to let the \fieldname{type}
        field contain the type of the whole work (e.g., CD). Therefore,
        I may change this somewhat in future versions of \pkg{apacite}.

    \item[\entryname{techreport}\LC] \mbox{}\\
        A report. This may be a ``technical'' report such as published
        by universities, or a report from government organizations or
        private companies. The \fieldname{type} field can be used to
        indicate what kind of report it is, e.g.,
        ``\verb+College Board Rep.+'' or ``\verb+{DHHS} Publication+''.
        If the \fieldname{type} field is missing, the default type
        ``\verb+Tech.\ Rep.\hbox{}+'' is used. (The \verb+\hbox{}+
        ensures that \TeX{} does not view the period as the end of a
        sentence, which would insert too much space.) If no type
        description should
        be given, \verb+\bibnotype+ should be used as the contents of
        the \fieldname{type} field. The \fieldname{number} field can
        be used to give the report number. The organization that
        published the report should be given in the \fieldname{institution}
        field.

    \item[\entryname{intechreport}] \mbox{}\\
        An article in a (usually edited) report. This is more or less
        a combination of \entryname{incollection} and
        \entryname{techreport}. It uses the same fields as the former
        to describe the article itself, except \fieldname{type}, e.g.,
        \fieldname{booktitle}, which is in this case the title of the
        entire report,
        and the same fields as the latter to describe the report.
        In particular, the \fieldname{type}, \fieldname{number},
        and \fieldname{institution} fields are used for the report.

    \item[\entryname{lecture}] \mbox{}\\
        A paper presented at a meeting. According to the APA manual,
        the year and month should be given, but \pkg{apacite} also
        uses the \fieldname{day} field when available.
        The \fieldname{symposium} field can be used for the
        name of the symposium and the \fieldname{chair} field for the chair of
        the meeting. The \fieldname{howpublished} field should be used to
        indicate the occasion at which the paper was presented if the
        \fieldname{symposium} field is empty, e.g.,
        ``\texttt{Paper presented at the meeting of the American
                  Professional Society on the Abuse of Children}''.
        It can also be used to give additional information about
        the symposium if the \fieldname{symposium} field is not empty.

    \item[\entryname{phdthesis}\LC] \mbox{}\\
        A doctoral dissertation. The \fieldname{school} field is used
        to denote the university for which the thesis was written.
        The \fieldname{type} field can be used for the thesis type,
        e.g., ``\verb+PhD thesis+''. If it is empty, the default type
        is used, which is ``\verb+Unpublished doctoral dissertation+''
        or ``\verb+Doctoral dissertation+'', depending on whether
        the \fieldname{journal} field is empty or not.

        If the thesis is abstracted in \emph{Dissertation Abstracts
        International} or similar, then the \fieldname{journal},
        \fieldname{volume}, \fieldname{number}, and \fieldname{pages} fields
        can be used as with journal articles. The \fieldname{year} field
        should denote the year of the ``journal''.
        The \fieldname{originalyear} field should be used to denote the year
        of the original thesis, even if it is the same as the year of the
        abstract, provided that the original thesis is used, and not
        the abstract. Then, the \fieldname{school} field should also
        be used, and optionally the \fieldname{type} field. If only
        the abstract is used, it should presumably be treated as a
        journal article.


    \item[\entryname{mastersthesis}\LC] \mbox{}\\
        This is equivalent to the \entryname{phdthesis} type, except that
        the default ``unpublished'' and ``published'' \fieldname{type}s are
        ``\verb+Unpublished master's thesis+'' and
        ``\verb+Master's thesis+''.

    \item[\entryname{unpublished}\LC] \mbox{}\\
         For unpublished manuscripts and similarly ``obscure'' material.
         The \fieldname{howpublished} field will typically be used to
         indicate what kind of work is referred to (e.g.,
         ``\verb+Unpublished manuscript+''). The \fieldname{organization}
         field can be used to denote the organization in which the document
         was produced, e.g., ``\texttt{Johns Hopkins University, Center
         for Social Organization of Schools}''. Note that the larger
         organization should be given first and the department after that.
         The address (city and state, etc., see the discussion of the
         \fieldname{address} field in section~\ref{subsec:fields} below)
         of the organization should be given in the \fieldname{address}
         field, unless it is already mentioned in the name of the
         organization. Presumably, if the organization is
         ``\verb+University of Groningen+'', the city name ``Groningen''
         should not be given in the \fieldname{address} field, but
         the country ``The Netherlands'' should. When both the
         \fieldname{organization} and the \fieldname{address} field
         are available, \pkg{apacite} formats these as
         ``organization, address''. This is different from the
         usual ``address: publisher'' form. This behavior cannot
         explicitly be deduced from the 5th edition, nor from the
         4th edition, of the APA manual, but the 3rd edition
         \cite{APAManual3} gives an explicit example (example 53,
         p.~131): \citeA{APA-3rd-ed-ex53}.

    \item[\entryname{misc}\LC] \mbox{}\\
        For works that do not fit into the other categories, such as
        motion pictures, cassette recordings, computer software, etc.
        The \fieldname{type} field can be used to indicate the type
        of work, and \pkg{apacite} recognizes a few specific types
        that should be formatted a little differently, see the discussion
        of the \fieldname{type} field below. If the \fieldname{address}
        and \fieldname{publisher} fields are available, the address and
        publisher part is formatted as with books. The \entryname{unpublished}
        and \entryname{misc} types are very similar, but there are some
        differences. For example, \entryname{unpublished} uses the
        \entryname{organization} field and \entryname{misc} uses the
        \fieldname{publisher} field, and this part is formatted differently.
        Further, the \entryname{unpublished} type requires
        \fieldname{author}, \fieldname{editor}, \fieldname{title}, or
        \fieldname{type}, whereas with \fieldname{misc},
        \fieldname{howpublished} takes the first position if these fields
        are all empty. Finally, as briefly indicated above and discussed
        in more detail below, \entryname{misc} recognizes some special
        types in the \fieldname{type} field.

    \item[\entryname{literal}] \mbox{}\\
        If the other categories do not format the item correctly, this
        category can be used. The \fieldname{text} field is copied literally
        to the bibliography. The \fieldname{firstkey}, \fieldname{key},
        \fieldname{year}, and possibly \fieldname{originalyear} and
        \fieldname{translator} fields are necessary to get correct
        in-text citations. However, I have never needed to use this
        entry type and I think that \entryname{misc} should also
        be able to format the entry correctly. Furthermore, the
        correct placement of \entryname{literal} references in the
        reference list (alphabetizing, sorting), may be problematic.

    \item[\entryname{manual}\LC] \mbox{}\\
        This is treated as a \entryname{misc}, except that when the
        \fieldname{type} field is empty, it is assumed to be a
        \cmd{\bibcomputersoftwaremanual}. See also the description of
        the \fieldname{type} field below.

    \item[\entryname{booklet}\LC]
    \item[\entryname{inbook}\LC]
    \item[\entryname{inproceedings}\LC]
    \item[\entryname{proceedings}\LC] \mbox{}\\
        These categories are defined by all standard citation styles. They
        are, however, not needed for the examples in the APA manual. For
        compatibility, however, they are included and defined as follows:
        \entryname{booklet} = \entryname{proceedings} =
        \entryname{misc}; \entryname{inbook} = \entryname{inproceedings} =
        \entryname{incollection}. \citeA[p.~230]{KoDa04} also mention
        \entryname{conference} as being the same as \entryname{inproceedings};
        for compatibility, this is now supported in \pkg{apacite}.
\end{description}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Fields}
\label{subsec:fields}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The following fields can be used to describe a reference in the
\fname{.bib} file:
\begin{description}

    \item[\fieldname{address}\LC] \mbox{}\\%
       The address (usually the city and state or country) of the
       publisher, school, institution, or organization that published
       the item or at which the item was produced. The APA manual
       requires that the state or territory of a U.S.-city must be given
       in the official two-letter U.S. Postal Services form.

    \item[\fieldname{annote}\LC]
    \item[\fieldname{annotate}\LC] \mbox{}\\
       These are used with the \pkg{apacann} and \pkg{apacannx} bibliography
       styles to generate annotated bibliographies, see
       section~\ref{sec:annotate}. They are simply ignored without warning by
       the \pkg{apacite} and \pkg{apacitex} bibliography styles.

    \item[\fieldname{author}\LC] \mbox{}\\
       The author(s) of the work. This may also be a corporate
       author when applicable, but some specific measures must
       then be taken to prevent the corporate name from being
       interpreted as a first name and last name
       (such as ``Association, A. P.''):
\begin{verbatim}
  author = {{\bibcorporate{American Psychological Association}}},
\end{verbatim}
       It is important to surround the \cmd{\bibcorporate}\marg{Author}
       by an additional pair of braces. Otherwise, \BibTeX{} sorts
       the entry as if its name was ``Bibcorporate\marg{Author}''.
       Section~\ref{sec:xmpl} contains more examples.

       As discussed in the standard \BibTeX{} documentation,
       multiple authors must be separated by the word \verb+and+,
       and each author's name can either be given in the form
       ``\opt{firstnames}\verb+ +\opt{lastnames}'' or
       ``\opt{lastnames}\verb+, +\opt{firstnames}''. However,
       ``von'' parts and ``junior'' parts complicate issues
       a bit. See the examples and the discussion of them.

       I would generally give the full first name(s) in the \fname{.bib}
       file, even though the APA manual only requires initials,
       because other styles require full first name(s) and
       \pkg{apacite} abbreviates to initials automatically.
       I have done this only occasionally with the examples,
       because the APA manual only gives the initials.
       Therefore, I have only provided first names with a few
       examples for which I knew the authors' first names.

       Previous versions of the APA manual required that, if there
       are more than six authors, only the first six should be named
       in the reference list, followed by ``et al.'', which allowed
       one to include only the first six plus ``|and others|'' in the
       \fname{.bib} file. In the 6th edition, however, the APA changed
       this. Now, when there are up to seven authors, they should
       all be listed, but with eight or more, the first six should
       be listed, plus dots (\ldots), plus the last author. Therefore,
       ``|and others|'' should not be used anymore in the \fname{.bib}
       file. (It was already discouraged in earlier versions of the
       \pkg{apacite} documentation.) Thus, one should list all authors
       in the \fname{.bib} file.

    \item[\fieldname{booktitle}\LC] \mbox{}\\
       The title of the larger work, typically book, but sometimes
       something else, like a report, in which the referenced item
       (article) was published.

    \item[\fieldname{chair}] \mbox{}\\
       The chair(s) of a symposium or meeting. Used for lectures.
       It is formatted the same way as editors.

    \item[\fieldname{chapter}\LC] \mbox{}\\
       The chapter number if the referenced item is a chapter in
       a larger collection. Typically used if the referenced work
       is a chapter in an internet document. If the collection is
       a book, page numbers (in the \fieldname{pages} field)
       should be used instead according to the APA rules.

    \item[\fieldname{crossref}\LC] \mbox{}\\
       The \pkg{apacite} package does not recognize this field,
       because the APA manual does not discuss explicit
       cross-referencing. If the referenced work is a chapter
       (article) in an edited book, all relevant information
       should be given in the reference list as part of the
       information about the referenced chapter, not as, e.g.,
       ``In Wainrib (1992)''. If several chapters from the
       book edited by Wainrib are referenced, the same information
       about this book is given with each referenced chapter,
       and the work itself is not a separate entry in the reference
       list (unless it is explicitly referred to).

       However, the \fieldname{crossref} field
       \emph{can} be used, as part of standard \BibTeX{} usage.
       Missing fields for the referenced work are then copied from
       the cross-referenced entry, which must come \emph{after}
       the referring entry in the \fname{.bib} file. If you use
       this, remember to put the title of the book (also) in the
       \fieldname{booktitle} field, because the \fieldname{title}
       field of the referring entry is not empty (it contains
       the chapter title).

       I have not tested cross-referencing in detail, so I do not
       know whether it behaves well (i.e., complies with the implicit
       or explicit APA rules) under various circumstances.
       Therefore, I do not recommend using it without thorough
       testing.

    \item[\fieldname{day}] \mbox{}\\
       The day of the month on which the referenced item was published,
       produced, or presented. Mainly used for articles in daily or
       weekly magazines or newspapers, for lectures (although the
       APA manual only specifies the month), and electronic documents.

    \item[\fieldname{doi}] \mbox{}\\
       Digital object identifier (DOI). The 6th edition of the APA manual
       asks authors to supply this whenever available.

    \item[\fieldname{edition}\LC] \mbox{}\\
       The edition of the book or report. Traditionally, this is of the
       form ``1st'', ``2nd'', ``3rd'', etc., or ``Rev.'' for a revised edition.
       This form is still supported, but \pkg{apacite} now also supports
       the form in which only the number is given: ``1'', ``2'', etc.
       If \pkg{apacite} detects that only a number is given, it inserts
       ``\cmd{\PrintOrdinal}\marg{number}'' in the \fname{.bbl} file.
       This \LaTeX{} function converts the number again to ``1st'', etc.
       The advantage of this is that the same bibliography database can be
       used for documents in different languages: In the language-specific
       (\fname{.apc}) files supplied with \pkg{apacite},
       \cmd{\PrintOrdinal} is redefined according to the document
       language.

    \item[\fieldname{editor}\LC] \mbox{}\\
       The editor(s) of a book, report, or special issue of a journal.
       In the examples, this field is also ``misused'' for the
       producer of a television series.

    \item[\fieldname{englishtitle}] \mbox{}\\
       The English translation of the title of an item with a non-English
       title. The APA manual requires that if the referenced work has a
       non-English title, an English translation should be given as well. For
       an article in a journal with a non-English name or in a book with a
       non-English title, the journal name or book title should not be
       translated or put in this field, only the title of the referenced work
       itself must be translated. Because, as of version
       \APACversiondate{2005/06/01}, \pkg{apacite} contains some support of
       other languages for the main document (see
       section~\ref{sec:compat-babel}), this field needs rethinking, which
       will be deferred to a future version (but, as always, suggestions
       are welcome).

    \item[\fieldname{firstkey}] \mbox{}\\
       The \fieldname{firstkey} field, if not empty, is used as
       ``author'' for the first citation to an item. Subsequent citations
       then use the \fieldname{key} field. This can be used if there is
       no author or editor field that can be used for citations, or in
       certain cases with corporate authors, where the citation in the
       text uses an abbreviation of the author's name for second and
       subsequent citations, where the abbreviation is introduced in the
       first citation. It can also be used to ``trick'' the system
       in difficult cases. See also \fieldname{key}.

    \item[\fieldname{howpublished}\LC] \mbox{}\\
       A description of how something was ``published''. For example,
       ``Unpublished manuscript'' or ``Paper presented at the meeting
       of the American Professional Society on the Abuse of Children''.
       Also used for more retrieval information about electronic
       documents, e.g., ``Retrieved November 19, 2000, from the
       PsycARTICLES database'', or
\begin{verbatim}
  howpublished = {Retrieved August 24, 2000, from Columbia University,
                  Institute for Learning Technologies Web site:
                  \url{http://www.ilt.columbia.edu/
                    publications/papers/newwine1.html}\bibnodot{.}}
\end{verbatim}
        However, if the retrieval information consists only of a
        date and/or a URL, it is better to use the \fieldname{lastchecked}
        and \fieldname{url} fields for this and let \pkg{apacite}
        format this information. See also the \fieldname{note} field
        for an alternative to the \fieldname{howpublished} field.

    \item[\fieldname{institution}\LC] \mbox{}\\
       The institution, university, or company that published a
       (technical) report.

    \item[\fieldname{journal}\LC] \mbox{}\\
       The journal, magazine, newspaper, etc.{} in which an
       article, a review, or an abstract of a thesis was published.

    \item[\fieldname{key}\LC] \mbox{}\\
       See \fieldname{firstkey}. The \fieldname{key} field, if not
       empty, is used for second and subsequent citations, or all citations
       if \fieldname{firstkey} is missing. If \fieldname{author} is
       empty and \fieldname{editor} is empty or can not be used as
       author (e.g., in \entryname{incollection}), the \fieldname{key}
       field may be necessary to obtain a useful citation. This is
       so, because the APA manual requires an abbreviation of the
       title as in-text citation, and the abbreviation must be
       sensible. In the current version, \pkg{apacite} uses the
       whole title if \fieldname{firstkey} and \fieldname{key} are missing.
       Therefore, if the title is considered too long to use in citations,
       the user must provide an abbreviation in the \fieldname{key} field.
       Furthermore, the user must then also define the formatting:
       If the key is used for a difficult kind of author (e.g.,
       corporate author), it should be formatted as an author,
       i.e., in plain text, with names capitalized.
       If the key is used for an abbreviation of an article
       title, it should be in plain text, with major words capitalized
       (unlike in the reference list), and between double quotes
       (`` and ''; also unlike in the reference list).
       If the key is used for an abbreviation of a book title, it
       should be emphasized, with major words capitalized
       (unlike in the reference list), but not between quotes.

       In a field in the \fname{.bib} file that is also
       used for the citations, such as the \fieldname{key} field,
       formatting through, e.g.,
\begin{verbatim}
  key = {{\itshape Text}},
  key = {{\em Text\/}},
\end{verbatim}
       can be done (note the extra pair of braces!), but the
       seemingly more logical variations
\begin{verbatim}
  key = {\textit{Text}},
  key = {{\textit{Text}}},
  key = {\emph{Text}},
  key = {{\emph{Text}}},
\end{verbatim}
       do not work.
       However, it is generally preferable to use as less explicit
       formatting in the \fname{.bib} files as possible, because this
       decreases the possibilities of successfully using the
       same \fname{.bib} file with other styles. The following works
       excellent:
\begin{verbatim}
  key = {{\APACcitebtitle{Text}}},
\end{verbatim}
       where the \cmd{\APACcitebtitle} macro recognizes that the argument
       should be formatted as a booktitle (i.e., in italics according to the
       APA rules). This macro, and its companion \cmd{\APACciteatitle} for
       article title formatting, are used by \pkg{apacite} if the
       \fieldname{firstkey} and \fieldname{key} fields are missing,
       but can also be used by the user. Note that if you use such a
       \fname{.bib} file with another style, you have to provide
       definitions of these macros yourself (which can be copied from
       the \pkg{apacite} source code).

       \emph{Warning:} the \fieldname{key} field, which acts
       as a kind of pseudo-author, should not be confused with the
       (citation) \opt{key} that is used to match citations with
       entries in a \fname{.bib} file.

    \item[\fieldname{lastchecked}] \mbox{}\\
       The date on which a web page was last visited. Only used in
       combination with the \fieldname{url} field. Currently,
       \pkg{apacite} does not contain language-specific code to
       dissect this date, but copies its contents literally to the
       \fname{.bbl} file. Hence, if you intend to use the same
       bibliography database for documents in different languages,
       you may have to use a self-defined command for this. You can
       use the \pkg{apacite} commands \cmd{\APACrefYearMonthDay}
       and \cmd{\APACmonth} as templates for this. I will probably
       provide such a facility in a future version of \pkg{apacite}.

    \item[\fieldname{month}\LC] \mbox{}\\
       The month something was published. Mainly used for
       magazine or newspaper articles, lectures, and electronic documents.
       Use the month macros \verb+jan+, \verb+feb+, etc. These are
       predefined strings in the \fname{.bst} files, reverting to
       ``\verb+{\APACmonth{01}}+'', etc. You can also use the additional
       macros \verb+winter+, \verb+spring+, \verb+summer+, and \verb+fall+,
       which the \fname{.bst} files translate into
       ``\verb+{\APACmonth{13}}+''--``\verb+{\APACmonth{16}}+''.
       The \cmd{\APACmonth} command translates the numbers to the month or
       season names. This system allows language-specific behavior at
       the \LaTeX{} stage.

    \item[\fieldname{note}\LC] \mbox{}\\
       A note. This puts additional information between parentheses
       at the end of a reference list entry. In the examples from
       the APA manual, it is used for NTIS No., ERIC No., and UMI No.,
       and for notes about how to obtain the work
       (``Available from \opt{organization}, \opt{full address}'').
       If however, the work has been obtained from the internet
       or from an ``aggregated database'', then the
       \fieldname{howpublished} or \fieldname{url} field should be
       used, because it should not be between parentheses then.

       Finally, the \fieldname{note} field is used to give the
       recording date (i.e., year) of a song when this is different
       from the date (year) of copyright. The latter should be
       put in the \fieldname{year} field.

       Do not use the \fieldname{note} field to denote the original
       publication of a reprint or translation, because the
       \fieldname{originalyear} field must be used in those cases to
       obtain the correct citation in the text \cite<e.g.,>{ex39}.

    \item[\fieldname{number}\LC] \mbox{}\\
       The number of a journal issue or a report. This can be quite
       complex, for example, ``\verb+PRM~92-01+'', or
       ``\verb+3, Pt.~2+'', or ``\verb+1, Serial No.~231+''.
       These latter examples imply that the generality (language and
       style independence) of the \fname{.bib} file is somewhat lost.
       Furthermore, if the journal paginates by year and not by issue,
       the issue number should not be mentioned at all (except when
       referring to a whole special issue). Of course, \pkg{apacite}
       does not know whether the journal paginates by issue or by year.
       If the \fieldname{number} field is available, \pkg{apacite}
       simply assumes that it should be included. It is the user's
       responsibility to ensure that this is indeed the case.

    \item[\fieldname{organization}\LC] \mbox{}\\
       Used for the \entryname{unpublished} reference type to denote
       the organization in which the unpublished work was produced.

    \item[\fieldname{originaladdress}]
    \item[\fieldname{originalbooktitle}]
    \item[\fieldname{originaledition}]
    \item[\fieldname{originaleditor}]
    \item[\fieldname{originaljournal}]
    \item[\fieldname{originalnumber}]
    \item[\fieldname{originalpages}]
    \item[\fieldname{originalpublisher}]
    \item[\fieldname{originalvolume}]
    \item[\fieldname{originalyear}] \mbox{}\\
        These (\fieldname{original*-}) fields have the same
        meaning as their counterparts without the ``original'' prefix,
        except that they refer to the book or journal in which the
        work was originally published. This can be used in referring to
        translations or reprints of articles in journals or books. If the
        original work is a book or other ``standalone'' work,
        only the \fieldname{originalyear} field should be used. If the
        original work is a (PhD or Master's) thesis that is also abstracted
        in \emph{Dissertation Abstracts International},
        \emph{Masters Abstracts International}, or comparable, the
        \fieldname{originalyear} field should be used to denote the year
        of the dissertation and the \fieldname{year} field to
        denote the year of publication of the abstract, even if they
        are the same.

    \item[\fieldname{pages}\LC] \mbox{}\\
        The (inclusive) page numbers of the article that is referred to,
        in the journal or book in which it was published. If a range of
        pages is given (which is usually the case), an  en-dash should
        be used: ``\verb+29--43+''. Other styles sometimes allow a
        single hyphen (``\verb+29-43+''), which is then automatically
        formatted as an en-dash (``29--43''), rather than as a hyphen
        (``29-43''), but I have encountered situations, such as software
        manuals (LISREL) and reports for the U.S. Government, in which
        the page number was of the form ``II-3'',
        meaning page~3 of chapter~2. In such a situation, you may
        get page numbers like ``II-1--II-15'', where the distinction
        between a hyphen and an en-dash becomes important. Therefore,
        \pkg{apacite} does not perform such automatic transformations.

    \item[\fieldname{publisher}\LC] \mbox{}\\
        The publisher of the item. Primarily used for books.

    \item[\fieldname{school}\LC] \mbox{}\\
        The school or university for which a PhD thesis or
        master's thesis was written.

    \item[\fieldname{series}\LC] \mbox{}\\
        Not used, although the APA manual has a rule for series.
        If you refer to a volume in a series, the series title,
        volume number, and volume title should be joined into
        a two-part title , e.g., \emph{Handbook of child psychology:
        Vol.~4. Socialization, personality, and social development},
        see ex.~36. In \pkg{apacite} this whole part must be put in
        the \fieldname{title} or \fieldname{booktitle} field
        (whichever is appropriate).

        For a long time, I have intended to support the
        \fieldname{series} field to allow disentangling such
        situations. However, in the end, I have decided not to
        do this. The reason for this is that, according to my
        interpretation, the meaning of ``series'' in the APA manual
        is quite different from the meaning of the \fieldname{series}
        field, as intended by Oren Patashnik (the author of \BibTeX{}
        and the original style files). Many books are published in
        some sort of series. For example, my book with Tom Wansbeek
        \cite{WaMe00}, is vol.~37 in the \emph{Advanced Textbooks
        in Economics} series, of which the series editors are
        C.~J. Bliss and M.~D. Intriligator. The intention of the
        \fieldname{series} field is to generate a reference list entry
        like
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{list}{\relax}{\labelsep=0em%
              \parsep=0pt%
              \itemsep=0pt plus .3pt\relax%
              \leftmargin=2.5em%
              \itemindent=-2.5em}%
\sloppy\clubpenalty4000\widowpenalty4000
\sfcode`\.=1000\relax
\item
Wansbeek, T., \& Meijer, E.
\unskip\ \hskip .11em plus .33em minus .07em
(2000).
\unskip\ \hskip .11em plus .33em minus .07em
\Bem{Measurement error and latent variables in econometrics}
(Advanced Textbooks in Economics No.~37).
\unskip\ \hskip .11em plus .33em minus .07em
Amsterdam: North-Holland.
\end{list}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        In economics (and often in psychology, I guess), mentioning
        the series usually does not add much relevant information,
        and it is therefore typically omitted. I think this is how
        the APA intends it as well. However, in computer science, it
        is often very convenient, because certain series, like Springer's
        \emph{Lecture Notes in Computer Science} (LNCS) have a certain
        status of their own, and researchers know how to find volumes
        in this series.

        In my interpretation, the APA ``series'' refers to a single
        multivolume work with separate editors for the constituent
        volumes, but with a series editor who initiates the whole
        series. In the example from the APA manual, the
        \emph{Handbook of child psychology} is not a loose collection
        of separate books by different authors, but a combined effort
        managed by the series editor to give an overview of the field.
        In this case, the series editor may be considered the primary
        author and it makes sense to have the different volumes of the
        series together in the reference list. With my book with
        Tom Wansbeek, the series editors act more like journal editors,
        and different volumes of the series are unrelated books that
        do not need to be gathered together in the reference list.
        It would make no sense to cite this book as
        ``Bliss, Intriligator, Wansbeek, \& Meijer (2000)''.

        Because in my interpretation, the usual meaning of the
        \fieldname{series} field should not be included in the
        reference list according to the APA rules, \pkg{apacite}
        ignores the \fieldname{series} field. Perhaps I'll
        implement the APA manual ``series'' rules by introducing
        a \fieldname{volumetitle} field, but this will further reduce
        compatibility with other citation styles.

    \item[\fieldname{symposium}] \mbox{}\\
        The name of the symposium or meeting at which a
        lecture was given. This is typically used for the
        construction ``In \opt{chair} (Chair), \opt{symposium}'',
        see ex.~51. I have never used it myself, however,
        I always use the ``Paper presented \dots'' form,
        which puts this information in the \fieldname{howpublished}
        field.

    \item[\fieldname{text}] \mbox{}\\
        Used for items of type \entryname{literal}. This field contains
        the complete literal text to be used in the bibliography.
        I've never used it.

    \item[\fieldname{title}\LC] \mbox{}\\
        The title of the work.

    \item[\fieldname{translator}] \mbox{}\\
        The translator of a book or article. This should
        be formatted in the same way as \fieldname{author} and
        \fieldname{editor}. If the \fieldname{translator} and
        \fieldname{editor} fields are identical, they are
        formatted as if there were only an editor, except that the
        editor receives the suffix ``(Ed. \& Trans.)'' instead of
        just ``(Ed.)'', or similarly if there is more than 1 editor.

    \item[\fieldname{type}\LC] \mbox{}\\
        The type of \entryname{phdthesis} (e.g.,
        ``Doctoral dissertation''), type of \entryname{article}
        (e.g., ``Letter to the editor''), type of \entryname{techreport}
        (e.g., ``DHHS Publication''), type of \entryname{book}
        (e.g., ``Brochure''), type of \entryname{misc}
        (e.g., ``Cassette recording''), and so forth.

        With a review (which is typically an \entryname{article}),
        the \fieldname{type} field contains a lot of information
        and formatting, e.g.:
\begin{verbatim}
  type = {Review of the book {\APACcitebtitle{Life in the middle:
            Psychological and social development in middle age}}},
\end{verbatim}
        where I used the \cmd{\APACcitebtitle} command introduced above in
        the discussion of the \fieldname{key} field.

        In one of the APA manual examples, I used the \fieldname{type}
        field to give a description of the subject of an unpublished
        raw data file (``Auditory response latencies in rat auditory
        cortex''), leaving the \fieldname{title} field blank.

        For most reference types, if the \fieldname{type} field
        is missing, it is simply ignored and no type description
        is given. For a \entryname{techreport}, however, if the
        \fieldname{type} field is missing, the default type
        (``Tech.\ Rep.\hbox{}'') is inserted. In ex.~42 of the APA manual,
        a report without a type description is given. To make it
        possible to format a report successfully without a
        type description, \pkg{apacite} recognizes
\begin{verbatim}
  type = {\bibnotype},
\end{verbatim}
        indicating that there should be no type description.

        Another special purpose use of the \fieldname{type}
        field is for a computer program, software, programming
        language and/or manual. These are put into a \entryname{misc}
        entry, but unlike other \entryname{misc} types (such as
        motion pictures) the titles of these types should not
        be italicized. This is now recognized by \pkg{apacite}
        in the following way: When referring to a computer program,
        software, programming language and/or manual, you should
        use the \entryname{misc} reference type with
        one of the following commands in the \fieldname{type} field:\\
        \cmd{\bibcomputerprogram},\\
        \cmd{\bibcomputerprogrammanual},\\
        \cmd{\bibcomputerprogramandmanual},\\
        \cmd{\bibcomputersoftware},\\
        \cmd{\bibcomputersoftwaremanual},\\
        \cmd{\bibcomputersoftwareandmanual}, or\\
        \cmd{\bibprogramminglanguage}.\\
        Using any of these commands as type designator of a
        \entryname{misc} entry ensures that the title is not italicized,
        as required. The \entryname{manual} entry is now equal to
        \entryname{misc} with default type \cmd{\bibcomputersoftwaremanual}
        if the \fieldname{type} field is empty.

        Similarly, if you refer to a message that has been posted to
        a newsgroup, internet forum, etc., you should use the
        \entryname{misc} reference type with \cmd{\bibmessage} as
        \fieldname{type} field.

    \item[\fieldname{url}] \mbox{}\\
       The web address of a document. Used if the cited document (or
       other work) is a website or was obtained from a website. Long
       web addresses can cause problems, because \BibTeX{} splits long
       lines (more than 80 characters) in the \fname{.bbl} file and inserts
       a \TeX{} comment (percent sign). In most situations, this works fine,
       because the percent sign ``hides'' the line break, which would be
       processed as an undesired space by \TeX{}. But within the argument of
       a \cmd{\url} command, a percent sign is copied to the output, because
       it is a valid character in a URL. To prevent this problem, insert
       line breaks and/or spaces in the URL in the \fname{.bib} file:
\begin{verbatim}
  url = {ftp://ftp.princeton.edu/harnad/Psycoloquy/
         2000.volume.11/psyc.00.11.001.
         language-sex-chromosomes.1.crow},
\end{verbatim}
       Then \BibTeX{} breaks lines at the spaces/line breaks if a line
       break in the output is considered necessary (but not otherwise).
       These spaces are suppressed by default in the output, which is usually
       the desired behavior. But see the \pkg{hyperref} and \pkg{url}
       documentation if you want this differently. Also note that in the
       \fieldname{url} field, special characters like `|%|'
       and `|#|' should be entered without a backslash, unlike the normal
       situation if they would be used in the text.

    \item[\fieldname{urldate}] \mbox{}\\
       See \fieldname{lastchecked}. This one is apparently defined in the
       \pkg{jurabib} package. It is unfortunate that different packages define
       different fields for the same function.

    \item[\fieldname{volume}\LC] \mbox{}\\
        The volume or volumes of the referenced book(s) or
        of the book in which the referenced article was published,
        or the volume of the journal (magazine, newspaper, \ldots)
        in which the referenced article was published.

    \item[\fieldname{year}\LC] \mbox{}\\
        The year in which the referenced item was published, or
        if it was not published, the year in which it was written
        or presented. For manuscripts or books that are accepted
        for publication but have not yet been published, ``in press''
        should be used according to the APA rules. The best way to do
        this is to use the ``\cmd{\BIP}'' command, which can be redefined
        by the user if the language or editorial style requires
        something else than ``in press''. Furthermore, \cmd{\BIP}
        is recognized by \pkg{apacite} and treated a little differently,
        because for multiple ``in press'' references with the same
        author(s), a hyphen (``-'') should be inserted between the
        ``year'' (i.e., ``in press'') and the ``a'', ``b'', etc., that
        follow it to distinguish the works, whereas this hyphen must
        be omitted if the ``year'' is an ordinary year (1991a, 1991b).

        If no date is explicitly given in (or on) the referenced work,
        a ``n.d.'' (no date) should be given as year description.
        For this, \pkg{apacite} supports the \cmd{\bibnodate}
        command. This sometimes leads to different formatting as well,
        e.g., by referencing a translation of a work of which there
        is no original date. Then the \fieldname{originalyear}
        field should be \cmd{\bibnodate} and the \fieldname{year} field
        is then, e.g., \verb+1931+. If the \fieldname{translator}
        field is not empty, the citation in the text is then formatted
        as, e.g., ``\citeA{3.100-2}''.
\end{description}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Overriding the default sorting orders}
\label{subsec:sort}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Occasionally, it may be necessary to override \BibTeX's default sorting.
For example, the way \BibTeX{} handles accents and other nonstandard
characters, which is typically fine for documents in English, may
not be acceptable for documents in other languages:
``\verb+\"{u}+'' is treated as ``\verb+u+'', ``\verb+\ss+'' is treated as
``\verb+ss+'', and ``\verb+\ae+'' is treated as ``\verb+ae+''.
In non-English languages this sorting may not be appropriate and one
may desire that ``\verb+\"{u}+'' is treated as ``\verb+ue+''.
Numerous problems are caused by different conventions in different languages.
Some examples are given in the documentation of the \textsf{amsrefs}
package. Non-latin scripts (Greek, Hebrew, Arabic, Chinese, etc.) may not be
handled correctly as well. I am not able to judge this, nor does it seem
to be a problem that must be solved in \textsf{apacite}. It has been
announced that \BibTeX~1.0, when it will be released, will support
non-English languages as well.

An issue that occurs in English (APA) documents is that, according to
the APA, numbers should be sorted as if they were spelled in words:
``2003'' must be sorted as if it says ``\mbox{twothousandandthree}'';
see example~4.04 in section~\ref{sec:xmpl} below.

\DescribeMacro{\APACSortNoop}
Overriding the default sorting order can be done by using the
\cmd{\APACSortNoop} command in the \fname{.bib} file. This is a \LaTeX{}
command provided by \pkg{apacite}. It has one mandatory argument, but it
outputs nothing. However, \BibTeX{} does not know this and uses the
contents of this command to sort the entry. For example,
\begin{verbatim}
  author = {M{\"{u}}ller, Gerd},
\end{verbatim}
is sorted as ``\verb*+muller  g+'', whereas
\begin{verbatim}
  author = {{\APACSortNoop{Mueller}}M{\"{u}}ller, Gerd},
\end{verbatim}
is sorted as ``\verb*+muellermuller  g+'', which typically results
in the correct ordering. In the typeset document, both look like
``M{\"{u}}ller''. Note that the extra pair of braces around the
\cmd{\APACSortNoop} command are necessary to suggest to \BibTeX{}
that it is an ``accent''. The specification
\begin{verbatim}
  author = {\APACSortNoop{Mueller}M{\"{u}}ller, Gerd},
\end{verbatim}
is sorted as ``\verb*+apacsortnoopmuellermuller  g+'', which is
incorrect.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Customization}
\label{sec:custom}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The description in the previous sections, with the exception of
section~\ref{sec:options}, primarily discussed the default behavior of
\pkg{apacite}. However, as mentioned in the introduction, in addition to the
options, \pkg{apacite} offers many possibilities for customization. Most
punctuation used in the citations and reference list are implemented through
\LaTeX{} commands instead of explicit symbols. Consequently, the user can
fine-tune the behavior of \pkg{apacite} by redefining these commands, through
\cmd{\renewcommand} after \pkg{apacite} has been loaded. Analogously, most
fixed texts, like ``Tech.\ Rep.\hbox{}'' and ``Eds.\hbox{}'' are implemented
through \LaTeX{} commands as well, and can similarly be changed by the user.
The commands used by \pkg{apacite} are discussed in this section. Of course,
the defaults are based on the rules of the APA manual.

Some commands, predominantly punctuation, are used both in citations and in
the reference list. If you want their definitions in citations to be different
from their definitions in the reference list, you can simply redefine their
definitions before starting the bibliography.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Punctuation and small formatting issues}
\label{sec:custom-punct}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The following punctuation commands are provided and used for
the citations and reference list.

\DescribeMacro{\BAstyle}
\DescribeMacro{\BAastyle}
\cmd{\BAstyle} defines the text style of the authors (or whatever
takes their place) for an in-text citation. It defaults to nothing:
The authors use the same fonts as the text surrounding it. Introduced
because some journals use a different style. For example,
\emph{Statistica Neerlandica} uses small caps, so for that journal,
you would define
\begin{verbatim}
\renewcommand{\BAstyle}{\scshape}
\end{verbatim}
Do not use the \cmd{\textsc}-type commands, but \cmd{\scshape},
\cmd{\bfseries}, and so forth. The \cmd{\BAstyle} command is used for
the author part by the \pkgoption{apaciteclassic} citation commands,
except the author-only citation commands. \cmd{\BAastyle} is the same
as \cmd{\BAstyle}, except that \cmd{\BAastyle} is used for the
author-only citation commands.

\DescribeMacro{\APACrefauthstyle}
\cmd{\APACrefauthstyle} is similar to \cmd{\BAstyle}, except
that this one is used for formatting authors in the reference list.
In the current implementation, it also applies to editors in the
author position, but not to editors in the editor position and
not to titles and other elements that take the position of authors
if there are no authors and editors.

\DescribeMacro{\BBAA}
\DescribeMacro{\BBAB}
\DescribeMacro{\BAnd}
\cmd{\BBAA} is the ``and'' between authors in a parenthetical
citation and in the reference list, as in
``(Mooijaart \& Bentler, 1986)'' or ``Mooijaart, A., \&
Bentler, P.~M. (1986).''. Its default is ``\&''.
\cmd{\BBAB} is the same ``and'' in a text citation, as in
``Mooijaart and Bentler (1986)''. Its default is ``and''.
The third ``and'', \cmd{\BAnd}, is used in the reference list
if someone is both editor and translator:
``In J. Strachey (Ed. \& Trans.),''. Default is ``\&''.

\DescribeMacro{\BBOP}
\DescribeMacro{\BBCP}
\cmd{\BBOP} (opening parenthesis) and \cmd{\BBCP} (closing parenthesis)
are used for the parentheses in a citation, as in ``(Rao, 1973)'' or
``Rao (1973)'', and the year in the reference list, as in
``Rao, C.~R. (1973).'' By default, they are round parentheses
``('' and ``)''.

\DescribeMacro{\BAP}
\cmd{\BAP} is inserted after the prefix and before the first citation
in a parenthetical citation. It defaults to an ordinary space. Note
that if the prefix ends with a period, \TeX{} interprets this as a
sentence ending and typically inserts a larger space, which is often
not desirable. The standard way to avoid this would be to insert an
explicit space (``|\ |''), but this does not work in a prefix. The
solution is to insert an empty |\hbox{}| after the period:
|\cite<cf.\hbox{}>{Jone01}|.

\DescribeMacro{\BBAY}
\DescribeMacro{\BBYY}
\DescribeMacro{\BBN}
\cmd{\BBAY} is the punctuation between author(s) and year in a
parenthetical citation, as in ``(Rao, 1973)''. \cmd{\BBYY} is the
punctuation between two subsequent years, if two works by the same
author(s) are referenced in a single citation command, as in
``(Rao, 1965, 1973)'' or ``Rao (1965, 1973)''. \cmd{\BBN} is the
punctuation before a note (postfix) after a citation, as in
``(Rao, 1973, p.~25)''.  Default for all three is a comma and a
space (``, '').

\DescribeMacro{\BBC}
\cmd{\BBC} is the punctuation between multiple cites, as in
``(Rao, 1973; Mooijaart \& Bentler, 1986)''. Default is a semicolon
and a space (``; '').

\DescribeMacro{\BBOQ}
\DescribeMacro{\BBCQ}
\cmd{\BBOQ} (opening quote) and \cmd{\BBCQ} (closing quote) are the
quotes around an article title in the reference list, for example the
double quotes in ``Random polynomial factor analysis.'' Default is
the empty string: no quotes are used. (The \pkg{theapa} package
required the closing period to be part of the closing quote, but this
has been changed, because the period must be left out if title
comments, such as type, English translation of non-English title, or
translator follow the title.)

\DescribeMacro{\BPBI}
\cmd{\BPBI} is the period between initials. Default is a period and a
non-breaking space (``.~''), as required by the APA manual. However,
many users prefer removing or reducing the space and in some
non-English speaking countries this is customary. This can be achieved
by redefining this command to, for example, just a period (no space),
or ``|.\,|'' (small space). This command cannot be used to remove
periods altogether, because there is still a period at the end. That
is, redefining it as an empty string gives awkward results like
``Bentler, PM., \& Mooijaart, A.''.

\DescribeMacro{\BHBI}
\cmd{\BHBI} is the hyphen between initials. Introduced for analogy with
\cmd{\BPBI} and used for authors who have two or more first names
with a hyphen between them, e.g., Jean-Paul Sartre. Default is
a period and a hyphen. Unlike \cmd{\BPBI}, I think this one will not be
changed often, although \BibTeX{} suppresses hyphens when it suppresses
spaces between initials as well, so there are people who have different
preferences. (Hence, \pkg{apacite} partly bypasses the standard
\BibTeX{} formatting functions to make this work.)

\DescribeMacro{\BCBT}
\DescribeMacro{\BCBL}
\cmd{\BCBT} is the comma between authors in the reference section when
there are two authors, as in
``Mooijaart, A., \& Bentler, P.~M. (1986).'' The comma after the ``A.''
is this one. Default is a comma. The APA manual requires it, but other
styles leave out this comma. In such a case, you would redefine this
``comma'' to be the empty string:
\begin{verbatim}
\renewcommand{\BCBT}{}
\end{verbatim}
Analogously, \cmd{\BCBL} is the comma before the last author when there
are three or more authors in a citation and in the reference section,
as in ``(Gill, Murray, \& Wright, 1981)'' or
``Gill, P.~E., Murray, W., \& Wright, M.~H. (1981).'' Its default is
also a comma, as required by the APA manual, which is standard U.S.
usage. Other styles, particularly European, such as British English,
omit this comma. Again, in such a case, you would redefine this
``comma'' to be the empty string. (This is in fact done in several of
the language files. See section~\ref{sec:language}.)

\DescribeMacro{\BDBL}
\cmd{\BDBL} is the dots before the last author in the reference
section when the reference has more than seven authors. The default
is ``|, \dots{} |''. The APA manual seems to imply that there
shouldn't be space around the dots, but I think it's better to have
the space and I assume editors won't mind. However, if they insist on
removing the space, you can redefine \cmd{\BDBL} accordingly.

\DescribeMacro{\theBibCnt}
\DescribeMacro{\BCnt}
\DescribeMacro{\BCntIP}
\DescribeMacro{\BCntND}
If there are multiple citations with the same author and year, a
letter should be added to the year to distinguish the references.
For example, one may refer to two or more articles by J.~Smith
published in 1982. They should be referred to as ``Smith (1982a)'',
``Smith (1982b)'', and so forth. To accomplish this, the counter
|BibCnt| is defined in \fname{apacite.sty}. The \cmd{\theBibCnt}
command defines how the value of |BibCnt| is formatted. The default
is ``|\alph{BibCnt}|'', that is, as a plain lowercase letter. To
emphasize (italicize) the ``a'', ``b'', and so forth, you can redefine
this as
\begin{verbatim}
\renewcommand{\theBibCnt}{{\em\alph{BibCnt}\/}}
\end{verbatim}
(This presumably works better than ``\verb+\emph{\alph{BibCnt}}+''.)
To control this behavior, redefining the \cmd{\theBibCnt} command
should normally be sufficient. However, the complete formatting
commands are \cmd{\BCnt}, \cmd{\BCntIP}, and \cmd{\BCntND}. The
second of these is for ``in press'' works, which need an extra hyphen
between ``in press'' and the ``a'' and ``b'' suffixes. The third is
similar, for works without a date, which is formatted as
``n.d.\hbox{}'' in APA style. Their default definitions
in \fname{apacite.sty} are
\begin{verbatim}
\DeclareRobustCommand{\BCnt}[1]{\setcounter{BibCnt}{#1}\theBibCnt}
\DeclareRobustCommand{\BCntIP}[1]{\setcounter{BibCnt}{#1}\mbox{-\theBibCnt}}
\DeclareRobustCommand{\BCntND}[1]{\setcounter{BibCnt}{#1}\mbox{-\theBibCnt}}
\end{verbatim}

\DescribeMacro{\APACciteatitle}
\DescribeMacro{\APACcitebtitle}
\cmd{\APACciteatitle} determines the formatting of the title of an
article (or similar work) when used as a citation in the text when no
author or editor is available for that purpose. Its default definition
is
\begin{verbatim}
\newcommand{\APACciteatitle}[1]{``#1''}
\end{verbatim}
that is, the title is put between double quotes. Similarly,
\cmd{\APACcitebtitle} determines the formatting of the title of a book
(or other independent work) when used as a citation in the text when no
author or editor is available for that purpose. Its default definition
is
\begin{verbatim}
\newcommand{\APACcitebtitle}[1]{{\em #1\/}}
\end{verbatim}
that is, the title is emphasized (in italics) but not put between
double quotes.

\DescribeMacro{\APACmetastar}
\cmd{\APACmetastar} is the asterisk that precedes an item in the
bibliography to denote that it is included in the meta-analysis.
The default value is ``\verb+\ensuremath{{}^\ast}+'', which
prints as ``\APACmetastar''.

\DescribeMacro{\bibnewpage}
If the \pkgoption{bibnewpage} option is chosen, \cmd{\bibnewpage} is
included before the bibliography. Its default definition is
\cmd{\clearpage}, but \fname{apa.cls} used \cmd{\newpage} in a
similar construction with its \pkgoption{man} option. See
\citeA[p.~215]{LaTeXbook} or \citeA[p.~37]{KoDa04} for the differences
between \cmd{\clearpage} and \cmd{\newpage}.

\DescribeMacro{\bibliographytypesize}
\cmd{\bibliographytypesize} is used before the reference list, but
after the section or chapter heading. It is intended for the font size
of the reference list: For \citeA{WaMe00}, I defined it as \cmd{\small}
(and even then the reference list took up 34 pages). The default value
is \cmd{\normalsize}.

\DescribeMacro{\bibleftmargin}
\DescribeMacro{\bibindent}
\DescribeMacro{\bibitemsep}
\DescribeMacro{\bibparsep}
\DescribeMacro{\biblabelsep}
Several parameters determine the layout of the reference list.
\cmd{\bibleftmargin} gives the indentation of the second and subsequent
lines of a reference list entry, relative to the usual left margin. It
is not a proper command, but a rubber length, which means that it is
not changed by \cmd{\renewcommand} but by \cmd{\setlength}. Its default
value is 2.5em. \cmd{\bibindent} gives the indentation of the
first line of a reference list entry, relative to the second line. It
is also a rubber length, with default value is |-\bibleftmargin|, which
means that the first line starts at the original left margin, and the
second and subsequent lines are indented by 2.5em. \cmd{\biblabelsep}
gives the horizontal separation between the reference list label and
the rest of the entry. Normally, there are no reference list labels
when using \pkg{apacite}, but this command allows one to define them
through redefining \cmd{\@biblabel} and \cmd{\@lbibitem} without having
to redefine the whole \envirname{bibliography} environment. I once used
this to generate a numbered reference list for my CV. It is a rubber
length in principle, but the default is a fixed length of 0pt.
\cmd{\bibitemsep} gives the vertical separation between two reference
list entries. It is also a rubber length, with default value
``|0pt plus .3pt|'', i.e., 0pt, but it may be stretched a little to
fill the page nicely. If you want to change it, e.g., to get a blank
line between reference list entries, you can use
\begin{verbatim}
\setlength{\bibitemsep}{\baselineskip}
\end{verbatim}
Finally, \cmd{\bibparsep} gives the vertical separation between two
paragraphs within the same reference list entry. Such a situation does
not occur in the default setup, so it is not used, but it is
conceivable that certain customizations lead to its use. It is a
rubber length with default value 0pt.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Labels}
\label{subsec:labels}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
There are many specific pieces of text that can be put into the reference
list or a citation by \pkg{apacite}. Here, these pieces are called
\emph{labels}. Almost all of these are to some extent language-specific, and
sometimes style-specific even within the same language. Therefore, they are
implemented through \LaTeX{} commands, so that users can easily change them.
In this section, these commands and their purposes are described, and their
(U.S.\ English) defaults are given. Section~\ref{sec:compat-babel} below will
discuss how these commands are changed if another language is used.

The following label commands are used:
\begin{description}

  \item[\cmd{\onemaskedcitationmsg}] \DescribeMacro{\onemaskedcitationmsg}
  \item[\cmd{\maskedcitationsmsg}] \DescribeMacro{\maskedcitationsmsg}
      These commands have one mandatory argument (which should always
      be 1 for \cmd{\onemaskedcitationmsg}) and define a message
      stating that citations are removed for a masked review. The
      default messages are
      ``\emph{(1\ citation removed for masked review)}'' and
      ``\emph{(}|#1|\emph{\ citations removed for masked review)}'',
      respectively.

  \item[\cmd{\bibmessage}] \DescribeMacro{\bibmessage}
      This is the first of 9 specific type
      commands that are recognized by \pkg{apacite}. If you
      define the \fieldname{type} field of a \entryname{misc}
      entry as ``\cmd{\bibmessage}'', the formatting of the
      entry is changed (e.g., the title is not italicized),
      see the discussion of the \fieldname{type} field in
      section~\ref{subsec:fields} above. This one is used for
      messages in newsgroups, internet forums, etc.
      Default is ``\verb+Msg+''.

  \item[\cmd{\bibcomputerprogram}] \DescribeMacro{\bibcomputerprogram}
      Default is ``\verb+Computer program+''.

  \item[\cmd{\bibcomputerprogrammanual}] \DescribeMacro{\bibcomputerprogrammanual}
      Default is ``\verb+Computer program manual+''.

  \item[\cmd{\bibcomputerprogramandmanual}] \DescribeMacro{\bibcomputerprogramandmanual}
      Default is ``\verb+Computer program and manual+''.

  \item[\cmd{\bibcomputersoftware}] \DescribeMacro{\bibcomputersoftware}
      Default is ``\verb+Computer software+''.

  \item[\cmd{\bibcomputersoftwaremanual}] \DescribeMacro{\bibcomputersoftwaremanual}
      Default is ``\verb+Computer software manual+''.

  \item[\cmd{\bibcomputersoftwareandmanual}] \DescribeMacro{\bibcomputersoftwareandmanual}
      Default is ``\verb+Computer software and manual+''.

  \item[\cmd{\bibprogramminglanguage}] \DescribeMacro{\bibprogramminglanguage}
      Default is ``\verb+Programming language+''.

  \item[\cmd{\bibnotype}] \DescribeMacro{\bibnotype}
      This one is a bit different from the previous 8. It is used for
      \entryname{techreport} entries to indicate that the type specifier
      should be suppressed. Its default value is the empty string, but this
      will not have an effect on \pkg{apacite} behavior, because the type
      specifier is suppressed anyway by \pkg{apacite}. However, by defining it
      as the empty string, formatting may become better (i.e., closer to the
      desired formatting) with other styles.

  \item[\cmd{\bibnodate}] \DescribeMacro{\bibnodate}
      Used in the \fieldname{year} and
      \fieldname{originalyear} fields to indicate that no
      publication date has been given. Default value is ``\verb+n.d.\hbox{}+''.
      The ``\verb+\hbox{}+'' ensures that \TeX{} does not treat
      the last period as a sentence-ending period, after which
      more space is inserted. This also applies to several other
      labels discussed below.

  \item[\cmd{\BOthers}] \DescribeMacro{\BOthers}
      Used for ``others'' if the number of authors
      or editors is too large, as in ``(Gill et al., 1981)''.
      The default is ``\verb+et al.\hbox{}+''.

      However, the definition contains a slight adaptation, because
      in a previous version of \pkg{apacite}, there was a problem
      implying that in some cases \BibTeX{} might put an extra period after
      \cmd{\BOthers}, not recognizing that it already contains a period,
      so that you would get ``et al.\hbox{}.'', which is undesirable.
      It depends on the definition of \cmd{\BOthers} whether there should
      be a period or not: If it is defined as ``\verb+et al.\hbox{}+'',
      there should not be an additional period, but if it is defined
      as, say, ``\verb+and others+'', then there should be an additional
      period. But \BibTeX{} does not know what the (later) definition
      of this command will be in \LaTeX{}. Therefore, the \cmd{\BOthers}
      command is defined to have one argument. In \BibTeX,
      \pkg{apacite} inserts \verb+\BOthers{.}+ in the output, so no
      additional period is inserted by \BibTeX. By default, this
      command is defined as ``\verb+et al.\hbox{}+'', and the argument is
      simply ignored.

      If you redefine the \cmd{\BOthers} command and need the additional
      period, you can redefine it appropriately. However, in the current
      version, the \cmd{\BOthers} command is distinguished from the
      \cmd{\BOthersPeriod} command and I think the mentioned problems
      do not occur anymore. Nevertheless, I have kept the definition of the
      previous version. I may decide, after thorough testing, to change
      this again in a next version.

      There is still a complication, however. If you use a \cmd{\citeauthor}
      at the end of a sentence, there may be a period too many, if
      you end the sentence explicitly with it and \cmd{\BOthers} is
      ``et al.\hbox{}''. On the other hand, if you omit the sentence-finishing
      period but decide to redefine \cmd{\BOthers} to ``and others'',
      the period is missing. Therefore, it seems wise not to end a sentence
      with a \cmd{\citeauthor}, or you could define a command, e.g.,
      \cmd{\finishsentence}, and insert it in an appropriate place.
      Then, this command should be changed along with \cmd{\BOthers}.

  \item[\cmd{\BOthersPeriod}] \DescribeMacro{\BOthersPeriod}
      Also used for ``others'' if the number of
      authors or editors is too large, as in
      ``Gill, P. E., et al.\hbox{} (1981)''.
      But this one is used for situations when it should always end with
      a period. The default is ``\verb+et al.\hbox{}+''.

  \item[\cmd{\bibcorporate}] \DescribeMacro{\bibcorporate}
      This command can be used in the \fieldname{author}
      field (and \fieldname{editor} and \fieldname{translator}) to tell
      \pkg{apacite} that the author is a corporate author. See
      section~\ref{subsec:fields} for an example of its usage. In combination
      with the \pkgoption{includecorporate} and \pkgoption{suppresscorporate}
      options, it can be used to include or exclude corporate authors from
      the author index. The usage as described above is structured as if
      \cmd{\bibcorporate} has an argument, the corporate author name, but
      by default, this argument simply would have to be copied to the output
      without further processing. Therefore, in the actual implementation,
      \cmd{\bibcorporate} does not have an argument and reduces to \cmd{\relax},
      i.e., it does nothing in \LaTeX{} and exerts its influence at the
      \BibTeX{} stage.

  \item[\cmd{\BIP}] \DescribeMacro{\BIP}
      ``In press'', the string to be used as year for
      in-press references. In the \fname{.bib} file, the \fieldname{year}
      field should be ``\verb+\BIP+'', so that \pkg{apacite} can recognize
      this and use appropriate formatting and sorting.
      The default value is ``\verb+in press+''.

  \item[\cmd{\BIn}] \DescribeMacro{\BIn}
      Used for \entryname{incollection} and
      \entryname{intechreport}, for ``In \opt{editor} (Ed.\hbox{}),
      \opt{booktitle}'', and similar phrases. Default value is ``\verb+In+''.

  \item[\cmd{\BCHAP}] \DescribeMacro{\BCHAP}
      Used for \entryname{incollection} if the
      \fieldname{pages} field is empty, to denote the chapter number
      of the referenced work in the collection. Used primarily for
      internet documents, where there are no page numbers.
      Default value is ``chap.\hbox{}''. Note that in the text, in
      particular in a citation, the APA (p.~179) prescribes ``Chapter'':
      ``(Shimamura, 1989, Chapter~3)''. This is, however, something that
      would be typed by the author of the manuscript, not inserted by
      \pkg{apacite}, and thus \pkg{apacite} does not have a command
      for this.

  \item[\cmd{\BCHAPS}] \DescribeMacro{\BCHAPS}
      Just like \cmd{\BCHAP}, but this one is used
      if the \fieldname{chapter} field refers to more than 1 chapter.
      Default value is ``chap.\hbox{}''.

  \item[\cmd{\BED}] \DescribeMacro{\BED}
      Editor in reference list, as in
      ``In P. R. Krishnaiah (Ed.\hbox{})''. Default is ``\verb+Ed.\hbox{}+''.

  \item[\cmd{\BEDS}] \DescribeMacro{\BEDS}
      Editors (more than one editor) in reference list,
      as in ``In C.~R. Rao \& J.~K. Ghosh (Eds.\hbox{})''.
      Default is ``\verb+Eds.\hbox{}+''.

  \item[\cmd{\BTRANS}] \DescribeMacro{\BTRANS}
      Translator, as in ``(J. Strachey, Trans.\hbox{})''.
      Default is ``\verb+Trans.\hbox{}+''.

  \item[\cmd{\BTRANSS}] \DescribeMacro{\BTRANSS}
      Translators. Default is ``\verb+Trans.\hbox{}+''.

  \item[\cmd{\BTRANSL}] \DescribeMacro{\BTRANSL}
      Translation. Used in a text citation when
      referring to a translated work for which there is no date
      for the original work. This is then formatted as
      ``Aristotle (trans.\hbox{} 1931)''. Default is
      ``\verb+trans.\hbox{}+''.

  \item[\cmd{\BCHAIR}] \DescribeMacro{\BCHAIR}
      Chair of a symposium, etc.
      Default is ``\verb+Chair+''.

  \item[\cmd{\BCHAIRS}] \DescribeMacro{\BCHAIRS}
      Chairs. Default is ``\verb+Chairs+''.

  \item[\cmd{\BVOL}] \DescribeMacro{\BVOL}
      Volume, as in ``Vol.\hbox{}~1''.
      Default is ``\verb+Vol.\hbox{}+''.

  \item[\cmd{\BVOLS}] \DescribeMacro{\BVOLS}
      Volumes, as in ``Vols.\hbox{} 1--4''.
      Default is ``\verb+Vols.\hbox{}+''.

  \item[\cmd{\BNUM}] \DescribeMacro{\BNUM}
      Number, as in ``Tech.\ Rep.\hbox{}
      No.\hbox{}~12''.
      Default is ``\verb+No.\hbox{}+''.

  \item[\cmd{\BNUMS}] \DescribeMacro{\BNUMS}
      Numbers, as in ``Nos.\hbox{} 3--5''.
      Default is ``\verb+Nos.\hbox{}+''.

  \item[\cmd{\BEd}] \DescribeMacro{\BEd}
      Edition, as in ``2nd ed.\hbox{}''.
      Default is ``\verb+ed.\hbox{}+''.

  \item[\cmd{\BPG}] \DescribeMacro{\BPG}
      Page, default is ``\verb+p.\hbox{}+''.

  \item[\cmd{\BPGS}] \DescribeMacro{\BPGS}
      Pages, default is ``\verb+pp.\hbox{}+''.

  \item[\cmd{\BTR}] \DescribeMacro{\BTR}
      The (default) technical report type name, which can be
      overridden by the \fieldname{type} field. Default is
      ``\verb+Tech.\ Rep.\hbox{}+''

  \item[\cmd{\BPhD}] \DescribeMacro{\BPhD}
      The (default) PhD thesis type name, which can be
      overridden by the \fieldname{type} field. Default is
      ``\texttt{Doctoral dissertation}''.

  \item[\cmd{\BUPhD}] \DescribeMacro{\BUPhD}
      The (default) Unpublished PhD thesis type name,
      which can be overridden by the \fieldname{type} field. Default is
      ``\texttt{Unpublished doctoral dissertation}''.

  \item[\cmd{\BMTh}] \DescribeMacro{\BMTh}
      The (default) master's thesis type name, which can be
      overridden by the \fieldname{type} field. Default is
      ``\texttt{Master's thesis}''.

  \item[\cmd{\BUMTh}] \DescribeMacro{\BUMTh}
      The (default) unpublished master's thesis type name,
      which can be overridden by the \fieldname{type} field. Default is
      ``\texttt{Unpublished master's thesis}''.

  \item[\cmd{\BOWP}] \DescribeMacro{\BOWP}
      ``Original work published'', default is
      ``\texttt{Original work published}''.

  \item[\cmd{\BREPR}] \DescribeMacro{\BREPR}
      ``Reprinted from'', default is
      ``\texttt{Reprinted from}''.

  \item[\cmd{\Bby}] \DescribeMacro{\Bby}
      ``by'' in the construction
       ``by P.~R. Krishnaiah, Ed.\hbox{}'' referring to the original
       editor of a reprinted work. Default is ``\verb+by+''.

  \item[\cmd{\BAuthor}] \DescribeMacro{\BAuthor}
      ``Author'' as a description of the publisher
       if the author and publisher are the same. Default is
       ``\verb+Author+''

  \item[\cmd{\BAvailFrom}] \DescribeMacro{\BAvailFrom}
      ``Available from''. This is used in versions
       of \pkg{apacite} up to [2009/03/01] if the \fieldname{url}
       field is specified but the \fieldname{lastchecked} field is not.
       This is now superseded by \cmd{\BRetrievedFrom}.
       Default is ``\verb+Available from\ +''. Note the extra space.
       This construction allows customization by redefining this command
       as being empty, thereby omitting the phrase altogether, without
       undesirable extra space.

  \item[\cmd{\BRetrieved}] \DescribeMacro{\BRetrieved}
      ``Retrieved from'', used if both the
       \fieldname{url} field and the \fieldname{lastchecked} field are
       specified. It has one argumnt: the date, i.e., the contents of
       the \fieldname{lastchecked} field. The default is
       ``\verb+Retrieved {#1}, from\ +'', again with extra space.

  \item[\cmd{\BRetrievedFrom}] \DescribeMacro{\BRetrievedFrom}
      ``Retrieved from'', used if the \fieldname{url}
       field is specified but the \fieldname{lastchecked} field is not.
       This was introduced, because the APA manual (p.~192) now states
       that retrieval dates should be omitted ``unless the source
       material may change over time'', and prescribes ``Retrieved from''
       (p.~199).
       Default is ``\verb+Retrieved from\ +'', again with extra space.

  \item[\cmd{\BMsgPostedTo}] \DescribeMacro{\BMsgPostedTo}
       Used for messages to newsgroups and the like.
       Default is ``\verb+Message posted to\ +'', with space.

  \item[\cmd{\refname}] \DescribeMacro{\refname}
      Name of the reference list if it's a section.
      (So it's the section name.) Default is ``\verb+References+''.
      A problem with the current implementation is, that if you use
      \pkg{babel}'s \cmd{\selectlanguage} command, then \cmd{\refname}
      and \cmd{\bibname} are overwritten. Because \pkg{babel}'s
      definitions of these commands are often (for various languages)
      different from the names prescribed by the APA manual and analogous
      bodies in other countries, it will often be necessary to redefine
      \cmd{\refname} or \cmd{\bibname} if you have used
      \cmd{\selectlanguage}. I hope to provide a fix in a next version
      of \pkg{apacite}.

  \item[\cmd{\bibname}] \DescribeMacro{\bibname}
      Name of the reference list if it's a chapter.
      Default is ``\verb+References+''. See also \cmd{\refname}.

  \item[\cmd{\bibliographyprenote}] \DescribeMacro{\bibliographyprenote}
      This command is used before
      the reference list, but after the section or chapter heading,
      and immediately after \cmd{\bibliographytypesize}.
      It is intended for an optional note just before the references
      in the reference list. It defaults to nothing, but can be changed
      to a list of commands (e.g., if some commands should be different
      in the reference list than in the text) and/or some text.

  \item[\cmd{\APACmetaprenote}] \DescribeMacro{\APACmetaprenote}
      If a meta-analysis is reported, the
      works included in the meta-analysis should in the bibliography be
      preceded by an asterisk, see the description of \cmd{\APACmetastar}
      above. This should then be explained in a note before the references.
      This command contains the text of that note. Default is
      ``\texttt{References marked with an asterisk indicate studies
      included in the meta-analysis.}''.

  \item[\cmd{\authorindexname}] \DescribeMacro{\authorindexname}
      Name (heading) of the author index.
      Default is ``\verb+Author Index+''.

  \item[\cmd{\doiprefix}] \DescribeMacro{\doiprefix}
      String that is printed before a DOI.
      Default is ``\verb+doi:+''.

\end{description}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{More drastic formatting changes to the reference list}
\label{sec:custom-big-formatting}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
In earlier versions of \pkg{apacite}, most of the formatting of the
reference list was done in the \BibTeX{} stage, i.e., by the \fname{.bst}
files. This corresponds with most other \BibTeX{} styles. This makes
it difficult for users to customize the formatting of the reference
list: They would have to make their own \fname{.bst} file, by adapting
\fname{apacite.bst}. Certain small changes are relatively easy to make,
but \BibTeX's ``bst'' language is not easy to understand for most users,
and thus most desired changes, though seemingly small, may be too
complicated to implement. Another drawback of this setup is that, each
time I release a new version of \pkg{apacite}, users would have to make
the same adaptations again. In the early days of \pkg{apacite}, wasting
disk space was another drawback, but this is not important anymore.

To overcome the most salient of these problems, \pkg{apacite} has always
deferred some formatting choices to the \LaTeX{} stage, by using tailor-made
formatting commands instead of explicit formatting, as discussed in
sections~\ref{sec:custom-punct} and~\ref{subsec:labels} above. The amount of
formatting thus handled has slightly grown over time, but still most choices
were hard wired in the \BibTeX{} styles.

Since the \APACversiondate{2007/09/03} version of \pkg{apacite}, a big step
has been made in transferring these choices to the \LaTeX{} domain. Hence,
a much larger set of commands, with wider-ranging scope, has been defined,
and considerably fewer choices are made at the \BibTeX{} stage. For
example, \fname{apacite.bst} now inserts
\mbox{}\vspace{0.7\baselineskip}\\
\mbox{\cmd{\APACjournalVolNumPages}%
      \marg{journal}%
      \marg{volume}%
      \marg{number}%
      \marg{pages}%
     }
\mbox{}\vspace{0.7\baselineskip}\\
in the \fname{.bbl} file for an \entryname{article} entry, and
the actual formatting of this information is defined in
\fname{apacite.sty}. If all four components are available, the
default (APA manual) formatting of this looks like
\mbox{}\vspace{0.7\baselineskip}\\
\mbox{\Bem{Acta Paedopsychiatrica},
      \Bem{38}(9),
      {229--231}}
\mbox{}\vspace{0.7\baselineskip}\\
but by redefining this command, users can change this, e.g., to
\mbox{}\vspace{0.7\baselineskip}\\
\mbox{\Bem{Acta Paedopsychiatrica}
      \textbf{38}, No.~9:
      {229--231}}
\mbox{}\vspace{0.7\baselineskip}\\
The advantage of this is that users can fairly easily construct a
customized style by redefining only a few commands in \LaTeX, by
using \cmd{\renewcommand}. Users will generally find it much easier
to do this than adapt the \fname{.bst} files. Furthermore, only
the affected commands need to be redefined, so that, when a new
version of \pkg{apacite} becomes available, all the new features
can be used---with the exception of the redefined commands, of
course---without having to adapt everything again. The drawback
is that the \fname{.bbl} file becomes less readable and more
difficult to adapt: Previously, it was easy to make ad-hoc changes
by editing the \fname{.bbl} file, but this has now become more
difficult. However, I intend to make this facility more user-friendly
in the future, e.g., by introducing options in the \LaTeX{} package
(say, \pkgoption{boldvolume}) or by introducing user-friendly
commands that accomplish the same (say, \cmd{\boldvolume}), so that
the advantages will clearly outweigh the disadvantages for the vast
majority of users.

Some packages (\pkg{amsrefs} and \pkg{biblatex} are the ones I am aware of)
handle the formatting of the reference list completely in the \LaTeX{} domain,
using \BibTeX{} only for sorting the reference list. The current version of
\pkg{apacite} does not go that far; there are still certain choices that are
hardwired in the \BibTeX{} code. Examples are the ordering of the various blocks
(most notably the position of the year; some styles have this at the end) and
the formatting of names. It is doubtful whether \pkg{apacite} will follow the
path toward the end, like these other packages. Some formatting choices are
closely connected with sorting of entries (e.g., by title if there is no author;
this assumes that the title then takes the author position) or other cross-entry
relations (such as adding `a' and `b' suffixes to the year). Therefore, it does
not seem useful to disconnect these choices by handing them over to \LaTeX.

The following commands are currently implemented to format the reference
list. If you want to customize them, you can study the source code in
the file \fname{apacite.sty}, copy it to you own package file, and adapt
the code as desired.\\[-0.3\baselineskip]
\par\noindent\DescribeMacro{\APACmonth}
\makebox[2.1in][l]{\cmd{\APACmonth}}
\makebox{Month name (as function of a number)}
\par\noindent\DescribeMacro{\APACrefYear}
\makebox[2.1in][l]{\cmd{\APACrefYear}}
\makebox{Year in the reference list}
\par\noindent\DescribeMacro{\APACrefYearMonthDay}
\makebox[2.1in][l]{\cmd{\APACrefYearMonthDay}}
\makebox{Year + month + day}
\par\noindent\DescribeMacro{\APACrefatitle}
\makebox[2.1in][l]{\cmd{\APACrefatitle}}
\makebox{Title (article style, default upright)}
\par\noindent\DescribeMacro{\APACrefbtitle}
\makebox[2.1in][l]{\cmd{\APACrefbtitle}}
\makebox{Title (book style, default italicized)}
\par\noindent\DescribeMacro{\APACrefaetitle}
\makebox[2.1in][l]{\cmd{\APACrefaetitle}}
\makebox{English translation of title (article)}
\par\noindent\DescribeMacro{\APACrefbetitle}
\makebox[2.1in][l]{\cmd{\APACrefbetitle}}
\makebox{English translation of title (book)}
\par\noindent\DescribeMacro{\APACjournalVolNumPages}
\makebox[2.1in][l]{\cmd{\APACjournalVolNumPages}}
\makebox{Journal, volume, number, and pages}
\par\noindent\DescribeMacro{\APACaddressPublisher}
\makebox[2.1in][l]{\cmd{\APACaddressPublisher}}
\makebox{Address and publisher}
\par\noindent\DescribeMacro{\APACaddressInstitution}
\makebox[2.1in][l]{\cmd{\APACaddressInstitution}}
\makebox{Address and institution (for technical reports)}
\par\noindent\DescribeMacro{\APACaddressPublisherEqAuth}
\makebox[2.1in][l]{\cmd{\APACaddressPublisherEqAuth}}
\makebox{Address and publisher if the publisher is the author}
\par\noindent\DescribeMacro{\APACaddressInstitutionEqAuth}
\makebox[2.1in][l]{\cmd{\APACaddressInstitutionEqAuth}}
\makebox{Address and institution if the latter is the author}
\par\noindent\DescribeMacro{\APAChowpublished}
\makebox[2.1in][l]{\cmd{\APAChowpublished}}
\makebox{\fieldname{howpublished} field}
\par\noindent\DescribeMacro{\APACorigED}
\makebox[2.1in][l]{\cmd{\APACorigED}}
\makebox{Original editor for reprints and translations}
\par\noindent\DescribeMacro{\APACorigEDS}
\makebox[2.1in][l]{\cmd{\APACorigEDS}}
\makebox{Ditto, multiple editors}
\par\noindent\DescribeMacro{\APACrefnote}
\makebox[2.1in][l]{\cmd{\APACrefnote}}
\makebox{Formatting of \fieldname{note} field}
\par\noindent\DescribeMacro{\APACorigyearnote}
\makebox[2.1in][l]{\cmd{\APACorigyearnote}}
\makebox{Original year + optional note}
\par\noindent\DescribeMacro{\APACorigjournalnote}
\makebox[2.1in][l]{\cmd{\APACorigjournalnote}}
\makebox{Original journal (+ volume, number, pages) + optional note}
\par\noindent\DescribeMacro{\APACorigbooknote}
\makebox[2.1in][l]{\cmd{\APACorigbooknote}}
\makebox{Formatting of ``original'' information if the original is a book}
\par\noindent\DescribeMacro{\APACbVolEdTR}
\makebox[2.1in][l]{\cmd{\APACbVolEdTR}}
\makebox{Technical report information}
\par\noindent\DescribeMacro{\APACbVolEdTRpgs}
\makebox[2.1in][l]{\cmd{\APACbVolEdTRpgs}}
\makebox{Ditto, for \entryname{intechreport}}
\par\noindent\DescribeMacro{\doi}
\makebox[2.1in][l]{\cmd{\doi}}
\makebox{Formatting of DOI string}\\[0.7\baselineskip]
In addition, the following environments are used:\\[-0.3\baselineskip]
\par\noindent\DescribeEnv{APACrefauthors}   \makebox[1.3in][l]{\envirname{APACrefauthors}   } \makebox{Formatting of authors (or editors acting as authors) in the reference list.}
\par\noindent\DescribeEnv{APACrefURL}       \makebox[1.3in][l]{\envirname{APACrefURL}       } \makebox{Formatting of \fieldname{url} field}
\par\noindent\DescribeEnv{APACrefDOI}       \makebox[1.3in][l]{\envirname{APACrefDOI}       } \makebox{Formatting of \fieldname{doi} field}
\par\noindent\DescribeEnv{APACrefURLmsg}    \makebox[1.3in][l]{\envirname{APACrefURLmsg}    } \makebox{Formatting of \fieldname{url} field for messages}
\par\noindent\DescribeEnv{APACrefannotation}\makebox[1.3in][l]{\envirname{APACrefannotation}} \makebox{Formatting of \fieldname{annote} or \fieldname{annotate} fields for annotated bibliographies.}
\\[0.7\baselineskip]
It is likely that these lists will be expanded in future versions of
\pkg{apacite}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Language support}
\label{sec:compat-babel}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The APA is, of course, American, and therefore the rules in the APA manual
are also based on the (U.S.) English language. Because \pkg{apacite} was
primarily designed to implement the APA rules, and because I write all
my scientific work in English, \pkg{apacite} originally did not contain
explicit support for other languages. However, most language-specific
elements have been implemented in the form of \LaTeX{} commands, so that
users could define their own \LaTeX{} package in which these elements were
changed. The labels discussed in section~\ref{subsec:labels} above are the
most important part of this.

Furthermore, when writing in a non-English language, the \pkg{babel} package
will usually be loaded. The \pkg{babel} package is an extensive package that
facilitates using \LaTeX{} for documents in languages other than English.
There have been some compatibility problems between \pkg{babel} and
\pkg{apacite}, and therefore since 2003 \pkg{apacite} contained some
explicit code to overcome the compatibility problems. I think this works
well, provided that \pkg{apacite} is loaded \emph{after} \pkg{babel}.

Thus, although \pkg{apacite} did not support non-English languages
explicitly, it did facilitate them. Supporting non-English languages is
not a main objective of \pkg{apacite}, because it is not needed for
the APA. Nevertheless, it potentially is a useful addition. Many journals in
non-English languages and universities in countries where other languages
are spoken base their rules on the APA manual. Therefore, it is
efficient if, with a few adaptations, \pkg{apacite} can also be used in
these circumstances. For this reason, and based on user requests,
\pkg{apacite} has contained some explicit language support since June 2005.

The unpacked \pkg{apacite} distribution contains files that have names
according to the construction \opt{language}\fname{.apc}, i.e.,
\fname{english.apc}, \fname{dutch.apc}, etc.
These files define the language-specific modifications of \pkg{apacite},
mainly translations of terms like ``and'', ``Ed.\hbox{}'', etc. They have been
written by \pkg{apacite} users who are (native) speakers of the languages
involved. If the \pkg{babel}, \pkg{german}, or \pkg{ngerman} package is
loaded, \pkg{apacite} is able to determine the language of the document that
is processed. Then the corresponding \fname{.apc} file, when available, is
read. In this way, language-specific elements are changed to the relevant
language. This is done fully automatically, the user does not have to do
anything explicitly. However, sometimes an \fname{.apc} file makes some
assumptions or choices that are nontrivial. Therefore, look at the source
code of the \fname{.apc} file (or in the Implementation section of this
manual if you have generated this manual with the \cmd{\AlsoImplementation}
option) if you obtain unexpected results. These files contain some brief
documentation of the specific issues relevant for the language at hand.

The list with available \fname{.apc} files has been given in
section~\ref{sec:usage}. One file is defined for each ``language'', which can
be used for several ``dialects'' (in \pkg{babel} terminology). For example,
\fname{english.apc} is also used if the language is ``american''. See the
documentation of the \pkg{babel} and \pkg{(n)german} packages for a list of
dialects of the language files supplied. If an \fname{.apc} file is not
available for the language you need, you can use one of the supplied ones as a
template and write your own. If you send it to me, I can include it in a next
version of \pkg{apacite}.

The \pkg{babelbib} package offers very sophisticated support of
different languages. Perhaps some of the features that it offers are
useful additions to \pkg{apacite} as well, and these may be included
in a future version of \pkg{apacite}.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Language-specific issues}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This section lists issues that are specific to one or more language
files. It is currently very incomplete. Again, I suggest you study
the \fname{.apc} file of your language for more information.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Spanish}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pkg{apacite}'s usage of |<| and |>| for pre-notes, as in
|\cite<e.g.,>{jones06}| (inherited from its predecessor, \fname{theapa.sty}),
conflicts with \pkg{babel}'s \pkgoption{spanish} option, which makes |<| and |>|
active characters. Hence, either you must avoid using prenotes with
\pkg{apacite}'s construction or you must disable \pkg{babel}'s behavior by
inserting the command \cmd{\deactivatequoting} after loading \pkg{babel}.

\DescribeMacro{\usespanishe}
The default ``and'' between authors in Spanish is `y', but when the
subsequent author's last name starts with an `I', this should be `e'.
Therefore, \fname{spanish.apc} introduces the command \cmd{\usespanishe},
which takes a comma-separated list of citation keys as argument. The ``and''
in these citations is then formatted as `e'. So
\begin{verbatim}
\citeA{AnIn93},
\citeA{AnIn95},
\usespanishe{AnIn93, AnIn95}
\citeA{AnIn93},
\citeA{AnIn95}.
\end{verbatim}
gives as output ``Anderson y Ingram (1993), Anderson y Ingram (1995),
Anderson e Ingram (1993), Anderson e Ingram (1995).''

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Setting up \MiKTeX}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\MiKTeX{} preloads the \pkg{babel} package and often uses \pkgoption{french}
as the default language. The result is that \pkg{apacite} formats
the heading of the reference list and other text strings in French.
(Other distributions also preload \pkg{babel} but use
\pkgoption{english} or \pkgoption{nohyphenation} as default.)
I have received many reports from \pkg{apacite} users who use \MiKTeX{},
who just want the default English, but get French output and don't
know how to turn this off. Therefore, even though I believe this is a
\MiKTeX{} issue and not an \pkg{apacite} issue, I\footnote{Actually,
most of this investigation, testing, etc., was done by David Huffer,
because I don't have \MiKTeX. Thanks, David!} have reluctantly
decided to investigate this issue, and as a result of my investigation,
provide this section.

So here is the way to solve this problem (for \MiKTeX{} version 2.7;
presumably it works similar for other versions):
\begin{enumerate}
\item
Click Start $\rightarrow$ Programs $\rightarrow$ MiKTeX 2.7 $\rightarrow$
Settings to open the \MiKTeX{} Options window. Click on the Languages tab.
\item
Select ``\pkgoption{english}'', ``\pkgoption{nohyphenation}'', or whatever
else you'd like to be the default language, and use the Down button to move
this to the bottom. The \emph{last} checked language is the default main
document language.
\item
Click on the General tab and click on Update Formats.
\end{enumerate}
If you do this with ``\pkgoption{english}'' or ``\pkgoption{nohyphenation}''
as default language, \pkg{apacite} will use English strings and punctuation.

If you want to override the default (and/or you are not able to set the
default, perhaps because you don't have the administrative permissions),
you can also insert the line
\begin{verbatim}
\usepackage[english]{babel}
\end{verbatim}
in your document, before loading \pkg{apacite}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Compatibility}
\label{sec:compat}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Generally speaking, I would want \pkg{apacite} to be compatible with other
packages, of course. However, what does compatibility mean? It can mean
various things:
\begin{enumerate}
\item \label{compat1}%
      The same \fname{.bib} file can be used with
      different \BibTeX{} styles and \LaTeX{} citation packages;
\item \label{compat2}%
      The same citation commands as other citation packages;
\item \label{compat3}%
      Another \LaTeX{} citation package can be used with a
      \fname{.bbl} file that is generated by the \pkg{apacite}
      \BibTeX{} style;
\item \label{compat4}%
      The \pkg{apacite} \LaTeX{} citation package can be used with a
      \fname{.bbl} file that is generated by another \BibTeX{} style;
\item \label{compat5}%
      The \pkg{apacite} \LaTeX{} citation package can be loaded at the
      same time as other packages without errors or undesirable
      side-effects.
\end{enumerate}
Because of the complicated rules of the APA manual, it is not always possible
to achieve all kinds of compatibility with all other packages. Later in this
section, I will discuss compatibility issues with other packages with which
known incompatibility problems exist or have existed. A first example of this,
the \pkg{babel} package, has already been mentioned above in
section~\ref{sec:compat-babel}.

Point~\ref{compat1} is the most important. If you have to write a completely
different \fname{.bib} file for different citation styles, there does not seem
to be an advantage in using \BibTeX{}. You might as well write the reference
list explicitly in \LaTeX{} then. However, not even this point can be achieved
completely, although the vast majority of the items will be the same for
different styles. But there remain a number of choices that are style-specific
and that lead to differences in the \fname{.bib} file. Examples from the APA
manual are:
\begin{itemize}
\item If a referenced book is volume~III according to its title
      page, this should be referenced as Vol.~3 according to the
      APA manual rules, but that may not be the case with other
      styles;
\item Journal names are abbreviated by some styles, but not
      according to the APA manual rules;
\item Publisher names should be abbreviated according to the
      APA manual, e.g., ``John Wiley \& Sons'' becomes ``Wiley''.
      Other styles do not do this;
\item The issue number of a journal should only be given if
      the journal starts each issue with page~1, not if page
      numbers of different issues in the same volume are consecutive.
      Other styles may require the issue number in all cases;
\item Page ranges are given as ``341--351'' in APA style, whereas
      other styles use ``341--51'';
\item The APA rules require a capital after a colon (`\verb+:+'),
      so that subtitles start with a capital as well. Other styles
      may not do this;
\item The APA has specific rules about the address: For a U.S. city,
      the state (or territory) should be given as a 2-letter code
      from the U.S. Postal Services, and the province and country
      should be given if it is a non-U.S. city. There
      are some exceptions if the name of the state (and sometimes
      even city) is already mentioned in the university name and
      the university acts as publisher;
\item Yearbooks like \emph{Annual Review of Psychology} should be treated
      as journals according to the APA rules, whereas other styles
      treat these as books;
\item The additional fields (such as \fieldname{translator} and the
      \fieldname{original*}-fields) that are used by \pkg{apacite} but are
      not defined in other \BibTeX{} styles are of course
      \pkg{apacite}-specific.
\end{itemize}
Some of these problems can be handled relatively elegantly. For example,
the user could use a command like ``\verb+\RomanVol{3}+'' in the
\fieldname{volume} field. Then, the user could define a counter,
\verb+RomanVolcounter+, say, in \LaTeX{} and then define
\cmd{\RomanVol} (similar to \cmd{\BCnt} discussed earlier) as
\begin{verbatim}
\newcommand{\RomanVol}[1]{%
  \setcounter{RomanVolcounter}{#1}\theRomanVolcounter}
\end{verbatim}
where \cmd{\theRomanVolcounter} is defined as \verb+\arabic{RomanVolcounter}+
if \pkg{apacite} is loaded and as \verb+\Roman{RomanVolcounter}+ if another
package is loaded that desires this. The example with style-specific
\fname{.bib} files that contain the definitions of journal-strings was already
given in section~\ref{sec:bib} above. However, many users will not go through
all this trouble, and not all problems can be solved in this way. So we have
to realize that not all entries in the \fname{.bib} file will be suitable for
all citation styles. On the other hand, most citation styles and journals are
not as critical as APA journals and many styles in psychology and other social
sciences (including economics) are very similar, so a \fname{.bib} file that
is tailor-made for \pkg{apacite} is likely to be suitable enough for the
styles of most relevant alternative journals.

Point~\ref{compat2} above is currently not fulfilled. The \pkg{apacite}
citation commands are directly based on those of its immediate
predecessor, \pkg{theapa}. But the use of `|<|' and `|>|' for prefixes
is not used by other packages. The \pkg{chicago} package uses
\cmd{\citeA} instead of \cmd{\citeauthor}, many ``numerical'' citation
styles only recognize \cmd{\cite}, and so forth. Because \pkg{natbib}
is widely used and versatile, the \pkgoption{natbibapa} option loads
\pkg{natbib} for the citation commands, thereby allowing at least a
little ``compatibility'' (actuallu, borrowing) of citation commands.

I think that points~\ref{compat3} and~\ref{compat4} are not that
important. It seems to me that there is not much wrong with defining
a style through a combination of a \fname{.sty} and \fname{.bst} file,
each requiring the other to work. However, given the possibilities and
philosophy of the \pkg{natbib} package, it is desirable that
\fname{natbib.sty} can be used with \fname{apacite.bst}. This is the
case, especially with the \pkgoption{natbibapa} option.

Point~\ref{compat5} is very important, especially with other packages that are
complementary to \pkg{apacite} in some sense. It would be very annoying having
to choose between using \pkg{babel} and \pkg{apacite}, or between
\pkg{hyperref} and \pkg{apacite}, etc. These packages serve totally different
purposes, cannot usefully be compared, and are more valuable when they can be
used jointly. The rest of this section addresses this issue for a number of
packages with which compatibility problems are known to exist or have existed.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\pkg{natbib}}
\label{sec:compat-natbib}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The \pkg{natbib} package is a general purpose citation package that is
intended to work with a broad range of \BibTeX{} (and non-\BibTeX{}) styles
that generate the bibliography. The \pkg{natbib} package is quite advanced and
can be used to switch easily between completely different citation styles.
Furthermore, the apparent popularity of \pkg{natbib} has inspired writers of
packages that would otherwise be incompatible with \pkg{natbib} to write code
to resolve these incompatibilities. I will mention some of these packages
below.

Using \pkg{natbib} for the citations has some advantages over using
\pkg{apacite} for the citations. Apart from the abovementioned sorting
of citations within a single citation command, these are mainly
\pkg{natbib}'s better compatibility with some other important packages,
although many compatibility problems with \pkg{apacite} have now been
solved.

When you want to use \pkg{natbib} for citation and \pkg{apacite} for the
reference list, you still need to load the \LaTeX{} package \fname{apacite.sty}
(with \cmd{\usepackage}), because of the commands that are included in the
\BibTeX{} output (as defined in section~\ref{sec:custom} above). The best
interoperability is obtained by loading \pkg{apacite} with the
\pkgoption{natbibapa} option. There is then no need to load
\pkg{natbib} explicitly, because \pkg{apacite} already does this.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\pkg{hyperref}, \pkg{backref}, and \pkg{url}}
\label{sec:compat-hyper}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The \pkg{hyperref} package turns (\mbox{cross-}) references into hypertext
links. This can be used in conjunction with a program such as \latextohtml{} to
compose \fname{.html} files with clickable links, to internet pages or within
the same document, or it can be used to create a \fname{.pdf} document with
clickable crossreferences. Evidently, citations are also references. Therefore,
the \pkg{hyperref} package transforms these into hypertext links as well, and
needs to redefine the citation commands and reference list commands in order to
do so. These redefinitions have caused severe incompatibility problems between
\pkg{apacite} and \pkg{hyperref} in the past. These incompatibility
problems have been solved and \pkg{apacite} is compatible with \pkg{hyperref},
provided that \pkg{apacite} is loaded \emph{after} \pkg{hyperref}.
However, some of the ``dirty tricks'' I needed for
complicated examples in section~\ref{sec:xmpl} still conflict with
\pkg{hyperref}. You will probably not encounter these problems very often, but
if you do these can be easily solved by editing the \fname{.bbl} file instead of
using dangerous tricks; see also section~\ref{sec:autindex} below.

The \pkg{backref} package adds to each entry in the bibliography a list of pages
(or sections) on which it is referenced. Hence, it serves as an alternative to
an author index, in which not the entries themselves are backreferenced, but the
authors of these entries, see section~\ref{sec:autindex}. Note that \pkg{natbib}
offers yet another possibility, viz.\ the citations in the standard index, or a
separate citation index, see the \pkg{natbib} documentation. In my opinion, the
\pkg{backref} way of indexing the page numbers of the citations is more logical.
Moreover, it is more condensed as well.

Obviously, the \pkg{backref} package has to change the citation commands and
reference list to be able to do its backreferencing. Because \pkg{apacite}
redefines these as well, they are conflicting to some degree. A similar
compatibility problem between \pkg{backref} and \pkg{natbib} was noticed by the
author of \pkg{backref}. Therefore, \pkg{backref} contains some code to make it
compatible with \pkg{natbib}. This code has been adapted for \pkg{apacite} and
incorporated in \pkg{apacite}. Thus, \pkg{backref} as a standalone package has
been made compatible with \pkg{apacite}. The drawback of this solution is that
if changes are made in the \pkg{backref} package, this may result in new
incompatibilities with \pkg{apacite} unless \pkg{apacite} is changed as well.
Whether, and if so, when, this will occur will be a question for the future.

Apart from being a standalone package, \pkg{backref} can also be combined with
\pkg{hyperref}. It is then not loaded separately, but through the
\pkgoption{backref} or \pkgoption{pagebackref} option of the \pkg{hyperref}
package. In this case, the backreferences become hypertext links. See the
discussion of the \pkg{hyperref} package above.

The \pkg{url} package provides the \cmd{\url} command for formatting URLs, i.e.,
web addresses. It is typically loaded if \pkg{hyperref} is also loaded, but it
is very useful on its own as well. There are no compatibility problems with
\pkg{apacite} and it is not required when using \pkg{apacite}. However, if you
use the \fieldname{url} field, \pkg{apacite} puts it into a \cmd{\url} command.
If the \cmd{\url} command is not defined by another package, \pkg{apacite}
provides a crude definition, so that no errors are generated. But the formatting
thus obtained usually does not satisfy the APA rules about formatting,
especially its rules about line breaking within a URL. The default line breaking
rules of the \pkg{url} package are fairly close to the APA rules, but there are
some differences. Therefore, \pkg{apacite} provides several URL-styles that
adhere to the APA line breaking rules, supplemented by the additional
suggestions in \citeA[p.~645]{chicago}. These styles apply to URL formatting
through the \cmd{\url} command anywhere in the document, not only in the
reference list and not only in the \fieldname{url} field.

The only difference between the URL styles defined by \pkg{apacite} is which
font family they use: \verb+APACtt+ uses \cmd{\ttfamily}, \verb+APACsf+ uses
\cmd{\sffamily}, \verb+APACrm+ uses \cmd{\rmfamily}, and \verb+APACsame+ does
not define a font family, and thus uses the font family that is active at the
start of the URL. \verb+APACtt+ is selected by default, but you can select
another URL style by inserting the command \cmd{\urlstyle}\marg{style} in your
document, after \verb+\begin{document}+. See the documentation of the \pkg{url}
package for more details.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Multiple bibliographies}
\label{sec:compat-chapterbib}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The \pkg{chapterbib} package allows separate bibliographies for separate
chapters of a book, or, technically, separate \cmd{\include}d files. To work
properly, it needs some small changes to the citation package, which are
clearly described in the \pkg{chapterbib} documentation. These changes have
been incorporated in \pkg{apacite}, and therefore \pkg{apacite} is compatible
with \pkg{chapterbib}.

It is generally advisable not to use the \pkgoption{sectionbib} option of
\pkg{chapterbib}, because this redefines \cmd{\thebibliography}, which
interferes with the redefinition by \pkg{apacite}. You can use the
\pkgoption{sectionbib} option of \pkg{apacite} to accomplish that the
bibliography or bibliographies are sections, rather than chapters.

Moreover, \pkg{apacite} is configured such that it takes a section as default
if it is in the main matter (signified by \cmd{\mainmatter}) of the document.
In the back matter (\cmd{\backmatter}) the bibliography is put in a chapter.
This is also the case if \cmd{\chapter} is defined but \cmd{\mainmatter} not.
(Is this possible? Perhaps for reports?) Consequently, the
\pkgoption{sectionbib} option is only useful in specific circumstances. The
\pkgoption{nosectionbib} forces the bibliography to be a chapter, provided
\cmd{\chapter} is defined. (I figured a \pkgoption{chapterbib} option would be
a bit confusing, so I stuck with \pkgoption{nosectionbib}.)

The \pkg{bibunits} package is an alternative to \pkg{chapterbib}. It allows a
greater flexibility in choosing the scope of a bibliography (chapter, section,
or arbitrarily defined part of the document). In previous versions, there
have been some compatibility problems between \pkg{apacite} and \pkg{bibunits},
but these have now been solved.

The \pkg{multibib} and \pkg{multibbl} packages support using multiple
bibliographies simultaneously. Thus, one can cite entries from multiple
bibliographies in the same part of the document. This may be useful of one
wants thematically different bibliographies or separate bibliographies for
references in different scripts (e.g., Latin and Greek). These packages
accomplish this by introducing different citation commands for the different
bibliographies. \pkg{apacite} contains compatibility code such that these
packages can be used jointly with \pkg{apacite}.

The \pkg{bibtopic} package offers a similar functionality, but instead of
using separate citation commands, it requires the user to keep the references
in different \fname{.bib} files, so that there is one bibliography per
\fname{.bib} file. \pkg{apacite} contains a little bit of compatibility code,
which largely seems to work, but ``and'' between authors is always ``\&'', even
in \cmd{\citeA}. I hope to fix this in a future version of \pkg{apacite}.

Another package that offers similar functionality is \pkg{splitbib}. This
uses neither different citation commands, nor separate \fname{.bib} files.
rather, it requires the user to declare the ``category'' of each cited
reference, typically at the beginning of the document. Again, \pkg{apacite}
contains compatibility code such that simultaneous redefinitions of some
of the citation and reference list commands do not conflict.

A few caveats must be mentioned here. First, simultaneous bibliographies
only work well if it is guaranteed that there are no ambiguities in the
reference lists. With a single bibliography, ambiguities are resolved at the
\BibTeX{} stage by adding initials to ambiguous first author names,
adding additional authors before (or instead of) ``et al.\hbox{}'' to
ambiguous multiple-author lists, and adding ``a'' and ``b'' suffixed to
the year for references to different documents with the same authors published
in the same year. Because, with the exception of \pkg{splitbib}, these
packages require multiple \BibTeX{} runs on separate selections of references,
\fname{apacite.bst} can only resolve ambiguities within the same bibliography.
When there are cross-bibliography ambiguities, these are not resolved. It
seems like these packages are primarily intended to work with numbered
citation styles, or otherwise labeled citation styles, so that unique
cross-bibliography numbers or labels can be generated at the \LaTeX{} stage.

Second, I wrote the compatibility code in early 2006 and have not
recently tested it thoroughly.
Please let me know if you encounter problems. Then I'll
try to fix them or at the least mention them in the next version of the
manual. In particular, I believe that usage of \cmd{\nocitemeta} is not
prefectly integrated yet: You may get the ``References marked\dots'' message
even if the relevant bibliography does not contain marked references,
or references that are \cmd{\nocitemeta}'d for one bibliography but not
for another are marked for both. I don't think the \cmd{\nocitemeta}
command is used much, so I would be surprised if anybody encountered
such problems, but please let me know if you do. Then I'll try to fix them.

Third, the compatibility code for all of these packages either follows
instructions given in those packages, or brutally redefines part of the
code of those packages. If these packages change, this may mean that
new compatibility problems are created, or that improved features of
these packages are not available when combined with \pkg{apacite}. I do
not have the time to regularly check for updates of these packages and
then study changes and/or test compatibility again. Instead, I only take
action when a user notifies me of a problem, or I coincidentally find out
myself. Therefore, again, please let me know if you encounter problems.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{\pkg{bibentry}}
\label{sec:compat-bibentry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pkg{bibentry} is a package that allows including a complete reference
list entry in the text (or a footnote, which is arguably more common).
Previous versions of \pkg{apacite} were incompatible with \pkg{bibentry},
but I believe this has been fixed now. However, the APA reference format,
which uses periods to separate the elements of a reference list entry and
not commas, does not appear to be very suitable for in-text use, so this
is most likely only useful for footnotes that do not contain any other text.
Also note that the final period of the reference entry is not suppressed.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Programs for conversion to html, rtf, etc.}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
There are several programs that convert \LaTeX{} files to other types
of files, most notably \fname{html} and \fname{rtf}. This may, for example,
be useful if you want to publish your document on the internet or if you
are requested to send a ``Word'' file to a journal. I have received reports
that \latextohtml{} and \LaTeXrtf{} do not handle documents that use
\pkg{apacite} well. Therefore, I have studied these programs. This section
contains my observations. Note that these are quite old and not updated, and
it is quite likely that the software mentioned in this section has been
altered (improved) considerably. Therefore, the information may be outdated.
Please let me know if there are major changes that I should be aware of.

\latextohtml{} is a \Perl{} program that converts a \LaTeX{} input
file into one or more \fname{.html} files, so that a document that is prepared
with \LaTeX{} can be used as a (user-friendly) internet document.
Similarly, \LaTeXrtf{} is a standalone program that converts a \LaTeX{}
document to \fname{.rtf} format, which can be read by most word processors.
This may be convenient if you (a \LaTeX{} user) want to share a document with
someone who does not work with \LaTeX{}, or as mentioned above, if you are
required to send a ``Word'' file to a journal.
Both \latextohtml{} and \LaTeXrtf{} implement \LaTeX{} macros etc.\ in
another programming language (\latextohtml{}: \Perl{}; \LaTeXrtf{}: C) and
process the \fname{.tex} files directly. This design implies that the
conversion program must know the definitions of all \LaTeX{} macros that
are used. A drawback of this design is that essentially the same code has
to be written in different programming languages (\LaTeX{} macros for the
\fname{.sty} file, \Perl{} for \latextohtml{}, and C for \LaTeXrtf{}), but
typically with some adaptations specific for the application at hand.

With \LaTeXrtf{}, the \LaTeX{} macros that it is able to process are included
in the C source code that is compiled. Consequently, no user additions are
possible in principle. However, the source code is freely available, so if you
define a \LaTeX{} macro, you could adapt \LaTeXrtf{}'s source code and
recompile \LaTeXrtf{}. It is obvious that this is very inconvenient,
especially if \LaTeX{} macros are defined differently for different styles or
if they are defined differently in different parts of the same document.
Version~1.9.15 and higher of \LaTeXrtf{} contains some support for
\pkg{apacite}, but lags a few versions of \pkg{apacite} behind and thus
doesn't work with recent versions of \pkg{apacite}. Moreover, even if this
would be fixed, e.g., because I (or you) send patches to the \LaTeXrtf{}
authors, this wouldn't do justice to the flexibility of \pkg{apacite}, i.e.,
its customization options.

In contrast with this, \latextohtml{} allows the possibility to supply
external \Perl{} scripts. If \latextohtml{} encounters a
\cmdtwo{usepackage}{package} command in the document, it attempts to read the
corresponding \opt{package}\fname{.perl} \Perl{} script. \latextohtml{} is
shipped with many such \Perl{} scripts. There is not one for \pkg{apacite},
but there is one for \pkg{natbib}, which could possibly be adapted for
\pkg{apacite}. Alternatively, you could use the \pkg{natbib} citation commands
and use the \pkg{natbib} package (e.g., through loading \pkg{apacite}
with the \pkgoption{natbibapa} option), which should work.

An alternative to both \latextohtml{} and \LaTeXrtf{} is \TeXht{}. This is
a collection of programs and style files that convert \LaTeX{} to
various formats, such as html, xml, and OpenOffice format. If you have
OpenOffice, the latter can be used to convert to Word (or rtf) format.
The principle of \TeXht{} is to let \LaTeX{} do most of the formatting and
processing of commands, and do the conversion at low-level \TeX{} commands.
In this way, all newly defined commands and user-defined changes are
automatically supported. This even carries over to redefinitions of macros
in the middle of a document. However, for some specific purposes, there are
some additional things that must be arranged. Therefore, \TeXht{} contains a
large list of \fname{.4ht} files that are necessary to support various
\LaTeX{} packages. One of these is the \fname{apacite.4ht} file. The main
purpose of this file is to make citations into hyperlinks to the corresponding
entries in the reference list. Currently, this only works partially, but
the citation text itself is formatted correctly, so this is only a
relatively minor inconvenience. But, of course, it would be better if this
would work perfectly. Perhaps I'll study the problems in the future and
solve this for a future version (although, technically, it is a \TeXht{}
problem and not an \pkg{apacite} problem).

The choice of which converter to use will typically not (only) depend on how
good it works in conjunction with \pkg{apacite}. Furthermore, apart from the
converters mentioned above, there are several additional converters that I
haven't studied at all. I will only study them if I receive reports about
incompatibility and even then it is far from certain that I will be willing or
able to fix the problems. It would be very demanding if I would have to define
the \pkg{apacite} commands in a large number of programming languages for a
large number of different converters. Because I prefer the design of \TeXht{}
and because this converter seems to work best at the moment, I will give a
bit more attention to this one.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Generating an author index}
\label{sec:autindex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The \pkg{apacite} package contains an option to (almost) automatically
generate an author index. This is done by using the \fname{apacitex.bst}
\BibTeX{} style file instead of \fname{apacite.bst} and loading the
\fname{apacite.sty} \LaTeX{} package with the \pkgoption{index} option,
either explicitly or implicitly through one of the \pkgoption{stdindex},
\pkgoption{tocindex}, \pkgoption{emindex}, or \pkgoption{ltxemindex} options.

In earlier versions of \pkg{apacite}, the \pkgoption{index} option
automatically loaded the \pkg{index} package for multiple indexes, so that
you can have a subject index as well as an author index. However,
the current document uses the standard \pkg{ltxdoc} class for documenting
\LaTeX{} packages, and this class uses another method for supporting
multiple indexes, which appears incompatible with the \pkg{index} package.
I have been unable to resolve these compatibility problems and,
therefore, have implemented another way to generate an author index in
addition to other indexes. This uses the same principles as \pkg{ltxdoc}
and thus does work for this user's manual. As a consequence,
\pkg{apacite} now offers options that generate the author index either
with the \pkg{index} package or without it.

The \pkgoption{indexpackage} option implies that author indexing is done
according to the \pkg{index}-scheme, whereas the \pkgoption{noindexpackage}
uses the \pkg{ltxdoc}-based scheme. These options are ignored if the
\pkgoption{index} option of \pkg{apacite} is not requested. When the
\pkgoption{index} option is requested, the \pkgoption{indexpackage} option
loads the \pkg{index} package. This is the default unless it is disabled
by using either the \pkgoption{noindexpackage} option or the
\pkgoption{ltxemindex} option.

Obviously, the \pkg{index} package must be available in a directory that
is read by \LaTeX{} if the \pkgoption{indexpackage} option is requested,
either explicitly or implicitly. If a subject index is desired, it must be
defined by the user, it is not defined by \pkg{apacite}. See the manual of
the \pkg{index} package on how to do this. A default author index \emph{is}
defined by \pkg{apacite}. The author index is then requested by putting
\begin{verbatim}
\printindex[autx]
\end{verbatim}
at the point in the \LaTeX{} document where the index is supposed to appear.
To include the author index in the processed document, the following sequence
must be followed: First, \LaTeX{}, which puts citation entries in the
\fname{.aux} file. Second, \BibTeX{}, which generates the bibliography in the
\fname{.bbl} file. Third, \LaTeX{} (at least) twice, which puts index entries
in a \fname{.adx} file, Fourth, \MakeIndex{}, which uses the \fname{.adx} file
as input and puts the formatted index in a \fname{.and} file, which can be
processed by \LaTeX{}. So, if the main document is \fname{filename.tex}, then
\MakeIndex{} must be called as follows:
\begin{verbatim}
makeindex -o filename.and filename.adx
\end{verbatim}
although the command with which the \MakeIndex{} program must be called
may on some systems be slightly different, e.g., \fname{makeinde} or
\fname{makeindx}. Furthermore, several additional options may be chosen
on the \MakeIndex{} command line. Fifth, run \LaTeX{} again, which
(finally) includes the formatted author index in the typeset document
(\fname{.dvi} or \fname{.pdf} file).

The \pkg{apacite} package provides some options to change the appearance of
the index somewhat. With (only) the \pkgoption{index} option, the indexing
facility is turned on, but the \envirname{theindex} environment is not explicitly
(re)defined by \pkg{apacite}. This means that this environment is defined just
like in standard \LaTeX{}, or the \pkg{index} package, or some other package
that has been loaded that redefines this environment.

The \pkgoption{stdindex} option explicitly uses the definition of the
\envirname{theindex} environment that is defined in the \pkg{index} package
[1995/09/28 v4.1beta Improved index support (dmj)].
With this definition, the index does not appear in the table of contents. With
the \pkgoption{tocindex} option, this definition is augmented with a table of
contents entry. With the \pkgoption{emindex} option, there are some alternative
definitions. It writes a table of contents entry as well, but the index itself
is now set in two columns using the \pkg{multicol} package instead of the
\cmd{\twocolumn} command, the text of the index is set in small type, and the
page head is not put in uppercase. The \pkgoption{ltxemindex} option uses
the same style as the \pkgoption{emindex} option, except that it does not
load the \pkg{index} package and is thus tailored to a somewhat different
indexing method.

When a table of contents entry is desired, another additional \LaTeX{} run is
required to obtain the table of contents with the author index included. In
exceptional cases, the extra line in de table of contents may cause the text
to be moved as well, so that it may be necessary to run \MakeIndex{} a second
time, followed by yet one or two more \LaTeX{} runs.

\DescribeMacro{\APACstdindex}
\DescribeMacro{\APACtocindex}
\DescribeMacro{\APACemindex}
\DescribeMacro{\APACltxemindex}
The definitions of the index discussed apply to all indexes in the
document, so to, for example, the subject index as well as the author
index. This may be undesirable, and therefore \pkg{apacite} provides
the \cmd{\APACstdindex}, \cmd{\APACtocindex}, \cmd{\APACemindex}, and
\cmd{\APACltxemindex} commands to switch index styles.
These correspond to the package options \pkgoption{stdindex},
\pkgoption{tocindex}, \pkgoption{emindex}, and \pkgoption{ltxemindex},
respectively. Note, however, that the \pkgoption{ltxemindex} option
and/or the \cmd{\APACltxemindex} command generally cannot be used in
a document that uses one of the other styles, and vice versa, because
the way \pkg{index} works is incompatible with how standard \LaTeX{}
indexing works.

If you want a different index style, either for all indexes in your document or
only for some indexes, you can define such a style using the
\cmd{\renewenvironment} command in the appropriate place. See the standard
\LaTeX{} documentation for this command. The source code of the four commands
mentioned here can be used as a template for such a style definition.

Finally, some elements of the formatting of the index itself can be changed
by using (and/or writing) an \fname{.ist} file containing the preferred
options. \MakeIndex{} should then be called with the filename of this index
style file after a ``\verb+-s+'' option on the command line, so, e.g.,
\begin{verbatim}
makeindex -s mystyle.ist -o filename.and filename.adx
\end{verbatim}
The \MakeIndex{} documentation discusses the possible options that can be put
into the \fname{.ist} file.

As discussed in sections~\ref{sec:options}, \ref{subsec:fields}, and
\ref{subsec:labels}, the \pkgoption{suppresscorporate} and
\pkgoption{includecorporate} options can be used to either
exclude corporate authors from the author index or include them in it.
The \cmd{\bibcorporate} command must be used in the \fname{.bib} file
to denote a corporate author.

For some of the examples from the APA manual, I had to use quite advanced
\LaTeX{} tricks to obtain the correct formatting in the text, the reference
list, and the author index; see section~\ref{sec:xmpl} below. This will
typically not be necessary in practice. In the unlikely event that you
encounter similar difficult cases, it will usually be sufficient to use
a relatively simple trick in the \fname{.bib} file. In rare situations,
this may still give incorrect formatting, most likely in the author index.
Somewhat less rare is the situation when there is such a problematic case
but you also want to use the \pkg{hyperref} package. The tricks I used
conflict with \pkg{hyperref}.

An easy solution to incorrect formatting and/or sorting in the author index is
to edit the \fname{.bbl} file manually. This should be done at a time when
\BibTeX{} will not have to be run again. Otherwise, the changes would be
overwritten by the next \BibTeX{} run. This editing of the \fname{.bbl} file
is not in the \TeX-spirit, but in my experience---I used it for two books
with lots of references \cite{meijer1998, WaMe00}, with a previous version of
\pkg{apacite} that caused a fair amount of problematic cases---this takes very
little time, usually only minutes. Compare that with the time spent on writing
a book, or with the time that would be necessary to manually make an author
index. I also used it more recently for an edited book \cite{dLMe08a}
with an adapted version of \pkg{apacite}, with essentially the current
author indexing code, and had to do very little editing. The author index
of the current document is automatically generated and does not contain
any manual editing, although it does contain some advanced \LaTeX{} code
to fix some issues.

\DescribeMacro{\AX}
The connection between the \fname{.bbl} file and the author index is through
\cmd{\AX} commands that are entered by \fname{apacitex.bst} in the
\fname{.bbl} file. These are responsible for the author indexing facilities.
By looking at the contents of the \fname{.bbl} file, it is not difficult
to see how problematic cases must be edited. For example, the entry for Bender
is generated by the following lines:
\begin{verbatim}
\AX{bender  jdirector
@Bender, J\BPBI
  {\protect\bibliteral{(Director)}\protect\indexskipbracenodot}.}%
\end{verbatim}
This can be changed to
\begin{verbatim}
\AX{bender  j
@Bender, J.}%
\end{verbatim}
which is formatted correctly in the author index without the need for
advanced \LaTeX{} code, and conflicts with \pkg{hyperref} are resolved.
Note that \pkg{apacite} uses the \opt{key}|@|\opt{visual} form of
indexing. This form is used in \MakeIndex{} to distinguish between the actual
representation in the index and the place where it should occur. The \opt{key}
is used by \MakeIndex{} to sort the entry, but the entry actually appearing in
the index is \opt{visual}. In the \opt{key} part as formatted by
\pkg{apacite}, all names are in lower case letters and all accents and
punctuation are removed. Furthermore, \pkg{apacite} inserts \emph{two} spaces
between surname and initials, and to \MakeIndex{}, two spaces are different
from one space. Spaces between surnames are removed, as well as spaces between
initials. Finally, note that \pkg{apacite} always inserts a new line before
the ``|@|''. This is to avoid bad line breaks by \BibTeX. To \MakeIndex,
this means that each citation \opt{key} ends with a space.

The author index of the current document does not contain entries for the authors
Shocked and Goodenough as cited in section~\ref{sec:xmpl}, although it does for
the reference list part. The reason for this is that the \fieldname{key} field was
used for the citations. If you use the \fieldname{key} (and \fieldname{firstkey})
field and you want the authors in the author index as well, you have to include
the index command \cmd{\AX} explicitly. For example, the \fieldname{key} field
for Michelle Shocked is
\begin{verbatim}
  key = {{\protect\bibsong{Shocked}{1992}{Over the
         Waterfall}{track~5}}},
\end{verbatim}
and if we change this into
\begin{verbatim}
  key = {{\protect\bibsong{Shocked\AX{shocked  m
         @Shocked, M.}}{1992}{Over the Waterfall}{track~5}}},
\end{verbatim}
then citations to her are included in the author index.

\DescribeMacro{\corporateAX}
For corporate authors, the \cmd{\corporateAX} command is used instead of the
\cmd{\AX} command. Depending on whether the \pkgoption{suppresscorporate}
option or the \pkgoption{includecorporate} option is requested, either explicitly
or implicitly, \cmd{\corporateAX} either swallows its argument or is equivalent
to \cmd{\AX}. To make sure that this ends up correctly in the author index,
it is important that this command as entered in the \fieldname{key} and/or
\fieldname{firstkey} field is exactly as output by \fname{apacite.bst} for
the \fieldname{author} field. The easiest way to accomplish this is to start
with \fieldname{key} and/or \fieldname{firstkey} fields that do not have
the \cmd{\corporateAX} command yet. Then, run \LaTeX{} and \BibTeX{} and
extract the correct \cmd{\corporateAX} command from the \fname{.bbl} file
and insert this in the \fieldname{key} and/or \fieldname{firstkey} fields.
Rerun \BibTeX{} and after that proceed as usual. For example, the following
is an excerpt from an entry for one of the examples from section~3.96 in the
APA manual:
\begin{verbatim}
  author   = {{\bibcorporate{National Institute of Mental Health}}},
  firstkey = {{National Institute of Mental Health [NIMH]}},
  key      = {{NIMH}},
\end{verbatim}
If I run \LaTeX{} and \BibTeX{} on the current document, the \fname{.bbl}
file contains the lines
\begin{verbatim}
\corporateAX{nationalinstituteofmentalhealth
@{\bibcorporate{National Institute of Mental Health}}}%
\end{verbatim}
Note the \cmd{\bibcorporate} command and the additional braces. If these
are left out,
\begin{verbatim}
  firstkey = {{National Institute of Mental Health
              [NIMH]}\corporateAX{nationalinstituteofmentalhealth
              @{National Institute of Mental Health}}},
  key      = {{NIMH}\corporateAX{nationalinstituteofmentalhealth
              @{National Institute of Mental Health}}},
\end{verbatim}
then this organization gets two separate entries in the author index, which
is incorrect. Instead, if we copy them literally,
\begin{verbatim}
  firstkey = {{National Institute of Mental Health
              [NIMH]}\corporateAX{nationalinstituteofmentalhealth
              @{\bibcorporate{National Institute of Mental Health}}}},
  key      = {{NIMH}\corporateAX{nationalinstituteofmentalhealth
              @{\bibcorporate{National Institute of Mental Health}}}},
\end{verbatim}
then everything is as desired. The additional spaces before the ``\verb+@+''
sign make no difference, but percentage signs should not be included in
the \fname{.bib} file at the end of lines to hide a line break (as in
\LaTeX{}), because \BibTeX{} does not recognize the percentage sign as
a comment. Rather, it includes it in the \fname{.bbl} file and sometimes
puts additional code behind it, which would then not be read by \LaTeX{}
because \LaTeX{} does interpret the percent sign as a comment. This
behavior has now become less likely, because \pkg{apacite} inserts
numerous line breaks in the \fname{.bbl} file to avoid this problem and,
more importantly, line breaks inserted by \BibTeX{} at undesired
locations (e.g., in the middle of a command name or in the argument of
a \cmd{\url} command), but is still a possibility.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Annotated bibliographies}
\label{sec:annotate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Annotated bibliographies can be obtained by requesting
\begin{verbatim}
\bibliographystyle{apacann}
\end{verbatim}
instead of
\begin{verbatim}
\bibliographystyle{apacite}
\end{verbatim}
or
\begin{verbatim}
\bibliographystyle{apacannx}
\end{verbatim}
instead of
\begin{verbatim}
\bibliographystyle{apacitex}
\end{verbatim}
The \BibTeX{} style files \fname{apacann.bst} and \fname{apacannx.bst} are
almost identical to \fname{apacite.bst} and \fname{apacitex.bst}, respectively.
The only relevant difference is that these styles include the contents of the
\fieldname{annote} or \fieldname{annotate} field in the output, thereby
generating an annotated bibliography.

According to \citeA[pp.~810--811]{TLC2}, the \pkg{annotation} style uses the
\fieldname{annote} field for annotations, whereas the \pkg{annotate} style
defines the \fieldname{annotate} field for this purpose. To be compatible with
both, \pkg{apacann} and \pkg{apacannx} support both of these fields. However,
they are not both included in the output for the same reference, in case
someone wants to make a file that is compatible with both the \pkg{annotate}
and \pkg{annotation} styles and thus duplicates the information. In such a case,
the contents of the \fieldname{annote} field is included in the output.

\DescribeEnv{APACrefannotation}
The annotation is inserted in the \fname{.bbl} file within a
\envirname{APACrefannotation} environment. Hence, its formatting can be
changed by the user by redefining this environment.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Auxiliary, ad hoc, and experimental commands in
   \fname{apacdoc.sty}}
\label{sec:apacdoc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Section~\ref{sec:xmpl} below cites all examples from the APA manual.
This is a test of \pkg{apacite} and a proof that it does what it's
supposed to do---format citations and reference lists complying with
the APA rules. However, the APA manual discusses many nonstandard
issues and several of them need nonstandard treatment. Some of these
can only be formatted by what I call ``tricking'' the system. This
has been done by defining several \LaTeX{} commands that are too
specifically tailored for a certain reference, or ad hoc in other
ways, or more generally experimental and not well tested, and likely
to lead to more (compatibility) errors. Therefore,
I do not consider these commands suitable for inclusion in the
\pkg{apacite} package proper, that is, the file \fname{apacite.sty}.

They are not important enough for that, and thus you would rarely need
them, and for most of them I anticipated (or hoped) at one point that
better solutions would be available in the future. Thus, it seemed
quite likely that major changes in these commands would be made,
and I didn't want to feel obliged to keep supporting them for backwards
compatibility. Rather, I considered these as illustrations of the
power of \LaTeX{} and templates that users can base their own tricks
upon. I still largely feel the same way about these commands, although
I'm not convinced anymore that within reasonable time I will come up
with elegant solutions that make them obsolete. Nevertheless, I still
make improvements in this direction.

These auxiliary, ad hoc, and experimental commands are defined in a
supplementary package file, \fname{apacdoc.sty}. As
this name indicates, it is a package that is intended to be used
for the \pkg{apacite} documentation (i.e., the current document).
It contains several commands and settings (like page margins) that
are not interesting outside this document. However, as mentioned
above, I needed many of the commands defined in this file for the
examples in section~\ref{sec:xmpl}. Thus, you might encounter
similar situations as well, and these commands may be useful for you.

Because most of the commands in \fname{apacdoc.sty} will not be
useful for you, it is generally not a good idea to load this file with
\cmd{\usepackage} to use the commands that are useful to you.
Instead, if you want to use them, you can copy their definitions
to the top of your own document or personal style file (say,
\fname{mysettings.sty}), study their behavior, and perhaps improve
them. This reflects the ``illustration'' or ``template'' nature
of these commands.

Accordingly, this section briefly mentions the commands that may
be useful outside the context of the current document. Thorough
documentation is outside the scope of this manual; their definitions
can be studied in the source code of \fname{apacdoc.sty}, and their
usage is illustrated in section~\ref{sec:xmpl}. I will mildly
support them, though: If you want to use them, you can ask me
questions, but I will not put as much effort in fixing possible
problems as I do with proper \pkg{apacite} issues.

The list below mentions (some of) the numbered examples in
section~\ref{sec:xmpl} in which the commands are used.
\begin{description}

\item[\cmd{\biblecite}]
\DescribeMacro{\biblecite}
\DescribeMacro{\bibleciteA}
\DescribeMacro{\bibleciteNP}
\DescribeMacro{\fullbiblecite}
\DescribeMacro{\fullbibleciteA}
\DescribeMacro{\fullbibleciteNP}
\DescribeMacro{\shortbiblecite}
\DescribeMacro{\shortbibleciteA}
\DescribeMacro{\shortbibleciteNP}
This command, and its siblings \cmd{\bibleciteA}, \cmd{\bibleciteNP},
\cmd{\fullbiblecite}, \cmd{\fullbibleciteA}, \cmd{\fullbibleciteNP},
\cmd{\shortbiblecite}, \cmd{\shortbibleciteA}, and
\cmd{\shortbibleciteNP} are commands for citing the Bible. They
have one mandatory argument: the relevant chapter and verse, for
example, |\biblecite{1~Cor.\ 13:1}| (ex.~3.100-3).

\item[\cmd{\bibleversion}]
\DescribeMacro{\bibleversion}
This defines the version of the Bible used:
|\bibleversion{Revised Standard Version}|. Use this before using
the bible citing commands, typically in the preamble of your document.
Note that the Bible is not included in the reference list. You can use
these commands as templates for references to other ``classic'' works.
See ex.~3.100-3.

\item[\cmd{\citesong}]
\DescribeMacro{\citesong}
\DescribeMacro{\citeAsong}
\DescribeMacro{\citesongNP}
\DescribeMacro{\fullcitesong}
\DescribeMacro{\fullciteAsong}
\DescribeMacro{\fullcitesongNP}
\DescribeMacro{\shortcitesong}
\DescribeMacro{\shortciteAsong}
\DescribeMacro{\shortcitesongNP}
This command and its siblings \cmd{\citeAsong}, \cmd{\citesongNP},
\cmd{\fullcitesong}, \cmd{\fullciteAsong}, \cmd{\fullcitesongNP},
\cmd{\shortcitesong}, \cmd{\shortciteAsong}, and \cmd{\shortcitesongNP}
cite a song as required by the APA (except for the relative
placement of closing quotes and comma). See ex.~69.

\item[\cmd{\bibsong}]
\DescribeMacro{\bibsong}
For \cmd{\citesong} and its siblings, the \fieldname{key} field
(and possibly \fieldname{firstkey}) should contain the relevant
information in the form of a protected \cmd{\bibsong} command:
\begin{verbatim}
  key = {{\protect\bibsong{author}{year}{song title}{track info}}},
\end{verbatim}
See ex.~69.

\item[\cmd{\bibInstring}]
\DescribeMacro{\bibInstring}
This command has one argument. The macro changes the definition of
the macro \cmd{\BIn} to the argument and then immediately changes
the definition back to the old definition. So it makes a one-time
change. Used to change ``In'' a book to ``On'' a CD for citing songs.
See ex.~69.

\item[\cmd{\BOn}]
\DescribeMacro{\BOn}
``On'', for citing songs ``On'' a CD. See ex.~69.

\item[\cmd{\DSMcite}]
\DescribeMacro{\DSMcite}
\DescribeMacro{\DSMciteA}
\DescribeMacro{\DSMciteNP}
\DescribeMacro{\DSMfullcite}
\DescribeMacro{\DSMfullciteA}
\DescribeMacro{\DSMfullciteNP}
\DescribeMacro{\DSMshortcite}
\DescribeMacro{\DSMshortciteA}
\DescribeMacro{\DSMshortciteNP}
This command and its siblings \cmd{\DSMciteA}, \cmd{\DSMciteNP},
\cmd{\DSMfullcite}, \cmd{\DSMfullciteA}, \cmd{\DSMfullciteNP},
\cmd{\DSMshortcite}, \cmd{\DSMshortciteA}, and \cmd{\DSMshortciteNP}
cite the DSM. See ex.~29. They can also be used for other
``named'' works. \pkg{natbib} offers a similar functionality
through the definition of an \emph{alias}, but I think that to
get this working in the way the APA wants (i.e., the alias is not
used for the first citation, but only for second and subsequent
citations), it cannot be directly used. But the technical
implementation of its functionality may form a useful basis
for a better (more elegant) solution for this type of citation.

\item[\cmd{\bibDSM}]
\DescribeMacro{\bibDSM}
For \cmd{\DSMcite} and its siblings, the \fieldname{key} field
(and possibly \fieldname{firstkey}) should contain the relevant
\cmd{\bibDSM} command:
\begin{verbatim}
  key = {{\bibDSM{American Psychiatric Association}{Diagnostic
         and Statistical Manual of Mental Disorders}{4th
         ed.\hbox{}}{DSM-IV}}},
\end{verbatim}
See ex.~29.

\item[\cmd{\DSMauthor},
\cmd{\DSMfulltitle},
\cmd{\DSMedition},
\cmd{\DSMshorttitle}]
\DescribeMacro{\DSMauthor}
\DescribeMacro{\DSMfulltitle}
\DescribeMacro{\DSMedition}
\DescribeMacro{\DSMshorttitle}
These four commands extract the four elements of a \cmd{\bibDSM}
command. They are used in the \cmd{\DSMcite} command and its
siblings, but may occasionally be useful by themselves.

\item[\cmd{\bibliteral}] \DescribeMacro{\bibliteral}
This command is used in some of the examples in
section~\ref{sec:xmpl} to put some literal text into the
reference list that would otherwise be abbreviated to a
single ``initial'' at the \BibTeX{} stage. For example, in
ex.~4.08, the authors are ``Bulatao, E. (with Winford, C.~A.)'',
where ``(with Winford, C.~A.)'' is inserted by wrapping it
in a \cmd{\bibliteral} command, which itself is wrapped in
an additional pair of braces, so that \BibTeX{} treats it a
a complicated ``accent'' and the argument as a complicated
single character. This text should not be put in the author
index, and therefore some manipulation through redefining
the meaning of this command before and after the reference
list is used to suppress this text, as well as an additional
period, there. Used in examples 4.08, 65, 66, 68, and 70.

\item[\cmd{\bibinitial}] \DescribeMacro{\bibinitial}
This command is similar to \cmd{\bibliteral}. It is used in
one example (ex.~67), where the ``author'' is a ``(Producer)'',
but the initial of the author is put in the text because there
is another author with the same surname (Miller). This
causes problems not encountered in the examples where
\cmd{\bibliteral} is used, and after a lot of trial and error,
the current definition of \cmd{\bibinitial} was developed
to format this particular author correctly in text, reference
list, and author index. It looks like this is an improved
version of the \cmd{\bibliteral} command, so perhaps in the
next release I'll use \cmd{\bibinitial} for all the examples
in which now \cmd{\bibliteral} is used.

\item[\cmd{\bibreftext}] \DescribeMacro{\bibreftext}
This command takes two arguments. By default, it ignores the
first and inserts the second in the output. In this manual,
it is redefined before the reference list to ignore its
second argument and insert the first argument in the output.
This is used in ex.~17, where the year in the in-text
citation should be ``1992/1993'', whereas in the reference
list, it should be 1992 (and the 1993 is mentioned elsewhere).
For reprints and translations, this is handled automatically
by \pkg{apacite} if you use the \fieldname{original*} fields,
but this one is different.

\item[\cmd{\Dutchvon}] \DescribeMacro{\Dutchvon}
This command is equivalent to \cmd{\bibreftext}, but is used
for a different situation, and therefore, depending on
language, subtle style differences, and other preferences,
you might want to change the definition of one but not of
the other. This one illustrates how the Dutch way to treat
``von'' parts of surnames can be handled. It is discussed
in ex.~B-2, although it is not actually used in the examples,
because the Dutch way to treat ``von'' parts is not APA
style.

\item[\cmd{\SwapArgs}] \DescribeMacro{\SwapArgs}
This command takes two arguments and swaps their order. This
is useful if you cite a work whose title, (corporate) author,
or other element starts with an article that should be
disregarded for ordering. \pkg{apacite} disregards ``a'',
``an'', and ``the'' in the sorting of titles, but these are
obviously English. For French, you could say
\begin{verbatim}
  title = {\SwapArgs{Marseillaise}{La }},
\end{verbatim}
which is thus alphabetized under M. (Not used in the examples.)

\item[\cmd{\swallownext}] \DescribeMacro{\swallownext}
Eats up the next character. Dangerous but sometimes useful.
Used in the definitions of some of the following commands.

\item[\cmd{\swallowdot}] \DescribeMacro{\swallowdot}
Eats up the next character, but only if it's a dot (`.').
Used in the definitions of some of the following commands.

\item[\cmd{\bibnodot}] \DescribeMacro{\bibnodot}
Used as |\bibnodot{.}|. Eats the period, but prevents \BibTeX{}
from adding one. Used in examples 78, 79, 87, 91, and 95.
This is likely to be useful for many users, and is stable, so it
may be upgraded to \fname{apacite.sty} in the next release of
\pkg{apacite}. The only thing against this is that it is used in
highly unelegant manual formatting of a fairly large piece of the
description of a reference to a website in a
\fieldname{howpublished} field. I'd prefer to avoid this, but that
would require either adding another idiosyncratic field or even
less elegant trickery in the \fname{.bib} file.

\item[\cmd{\bibskipbracenodot}] \DescribeMacro{\bibskipbracenodot}
Suppresses the period after a subsequent closing brace. Quickly leads
to errors because it uses very low level \TeX{} code that (locally)
changes some fundamental settings. This is used in some examples
(65, 68) where \cmd{\bibliteral} is used to insert a description
of a first ``author'', such as ``(Producer)''. This is
interpreted by \BibTeX{} as a complicated one-letter first
name, and thus it adds a period to make it into an initial.
This period is the one that's eaten by this command.
Used in examples 65 and 68.

\item[\cmd{\indexskipbracenodot}] \DescribeMacro{\indexskipbracenodot}
This serves the same purpose as \cmd{\bibskipbracenodot}, and it
uses the same code, but whereas \cmd{\bibskipbracenodot} is
activated for the reference list, \cmd{\indexskipbracenodot}
is only activated for the author index. This has technical
reasons and it does not work under all circumstances. Used in
examples 4.08-3, 65, 66, and 68.

\item[\cmd{\bibeditortype}] \DescribeMacro{\bibeditortype}
This has one argument. The macro changes the definitions of the macros
\cmd{\BED} and \cmd{\BEDS} to the argument and then immediately
changes the definitions back to their old definitions. So it makes a
one-time change. This is used when there is someone in an ``editor-type''
role, but with another designation, such as ``producer'' or ``director''.
Ex.\ 36, 67, and 68.

\item[\cmd{\renewbibeditortype}] \DescribeMacro{\renewbibeditortype}
The above-mentioned definition of \cmd{\bibeditortype} is only relevant
in the reference list: In the citations in the text and in the author
index, the command should do nothing. Therefore, the command is
initially defined as ``nothing''. The definition discussed above is
initialized by \cmd{\renewbibeditortype}. This command is executed
just before the reference list in the current document. (After the
reference list, \cmd{\bibeditortype} becomes ``nothing'' again.)

\item[\cmd{\BAbstractRetrieved}] \DescribeMacro{\BAbstractRetrieved}
This command is similar to \cmd{\BRetrieved}, except that it
inserts ``Abstract retrieved'' instead of ``Retrieved''. Used in
examples 82 and 83.

\item[\cmd{\BmakeAbstractRetrieved}]
\DescribeMacro{\BmakeAbstractRetrieved}
This command functions much like \cmd{\bibeditortype}: It replaces
the next instance of \cmd{\BRetrieved} by \cmd{\BAbstractRetrieved}.
Used in examples 82 and 83.

\item[\cmd{\noedition}] \DescribeMacro{\noedition}
Suppresses the ``ed.'' (or ``\cmd{\BEd}'', rather) of an
\fieldname{edition}. Used in examples 92 and 94 to format a
string like ``Version~4'' as an \fieldname{edition}.

\item[\cmd{\APACmanBeforeBib}] \DescribeMacro{\APACmanBeforeBib}
Illustrates how some of the commands defined above are used in practice:
This command is given just before the \cmd{\bibliography} command, and
redefines some of the commands above, so that their meaning
is different in the reference list from their meaning in the main text.
Similar commands: \cmd{\APACmanBeforeIndex}, \cmd{\APACmanAfterIndex}.

\end{description}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Known problems and todo-list}
\label{sec:todo}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
With any kind of software, there is usually a list with known problems (bugs)
and desirable future work (to-do), and \pkg{apacite} is no exception. These
subjects will be discussed in this section.

A class of problems was already discussed in section~\ref{sec:compat} above.
This concerns the incompatibility of the \fname{.bib} file with other citation
styles, through \pkg{apacite}-specific fields, APA-specific contents of
fields, or through special tricks. These lead to correctly formatted
references in APA style, but may cause problems with using the \fname{.bib}
file with other styles (in case APA journals reject your article~\ldots). As
discussed there, however, this problem is unavoidable and presumably not a
very big problem to most users.

An incomplete list of other known problems and things that I would
like to do with \pkg{apacite} follows below. Several items of this list
are the direct result of the tricks I had to use for the examples in
section~\ref{sec:xmpl} below.
\begin{itemize}
\item Fix a bug (which is unlikely to show up) in the \fname{.bst} file:
      If there are two or more references, published in the same year, each
      with 6 authors, the first 5 of which are the same but the 6th authors
      are different, then these lead to ambiguous citations. The same thing
      happens when one has 6 authors and another 7, with the same first 6
      authors.
\item In an \entryname{unpublished} entry, if \fieldname{author} and
      \fieldname{organization} are equivalent, replace the latter with
      ``Author'' in the output, analogous to the situation where
      \fieldname{publisher} or \fieldname{institution} are equal to
      \fieldname{author} in several of the other entry types.
\item Solve several other rare cases where \pkgoption{apacite} does not
      correctly implement the APA rules: (p.~175) If additional authors
      are needed to resolve an ambiguity, end with ``et al.\hbox{}'',
      even if this is only one author; (p.~179) citing the Qur'an;
      (p.~184) same last name and same initials, but different first name;
      (p.~185) ``ca.\hbox{}''; (p.~198) Advance online publication;
      (p.~202) Abstract retrieved from; (pp.~208, 212) better deal with
      named archives; (p.~208) treat theses with a
      URL as published theses; (p.~208) ``Doctoral thesis'' instead of
      ``Doctoral dissertation'', form a university outside the United
      States; (p.~214) uncertain author;
      update the language files (\fname{.apc}) with correct definitions
      of new text string commands; finish the examples file.
      Many of these cases will not be a feature, but an ad-hoc workaround,
      similar to the tricks that are described in section~\ref{sec:xmpl}.
      Please contact me if you encounter any of these (or other
      formatting errors) and need a workaround.
\item Study referencing legal materials (Appendix~7.1).
\item Support nonstandard types of authors, like ``Director'' and
      ``Series Ed.\hbox{}''. This currently must be tricked in a
      nonelegant way. Perhaps I (or you) can think of a better solution.
\item If a work is authored by someone, ``with'' someone else: This
      currently must be tricked in a nonelegant way. Perhaps I (or you)
      can think of a better solution.
\item Add more options and/or commands for easier customization of reference
      list and author index.
\item Continue with transferring reference list formatting code from
      \BibTeX{} to \LaTeX.
\item Introduce options for the \BibTeX{} part, e.g., index vs.\ noindex (so
      that \fname{apacitex.bst} becomes superfluous); full first names
      instead of only initials, or perhaps options for putting initials
      in front of (2nd and later) author names; unsorted reference lists
      or lists sorted chronologically (forward or reverse; for CVs); etc.
\item Extend the \cmd{\bibcorporate} command with an optional argument that
      gives the abbreviated form, so that the \fieldname{firstkey} and
      \fieldname{key} fields do not have to be used for this common situation.
\item Define \BibTeX{} macros or strings for commonly encountered
      journals (at least the APA journals).
\item Allow \fieldname{lastchecked} fields of the form |2009-02-01| and/or
      |2009/02/01| and/or other schemes, and translate these into
      language-specific date strings.
\item Rewrite and reorganize the documentation; perhaps create a ``getting
      started'' document.
\item Improve the source code documentation, esp.\ the formatting,
      indexing, and cross-referencing. (You only see this if you regenerate
      this manual with the \cmd{\AlsoImplementation} flag set.)
\end{itemize}
Quite likely, other problems will come up when using the current version of
\pkg{apacite}. I have lots of ideas for improvements, extensions, options, and
so forth, but not much time to devote to it. Therefore, it is difficult to give
a good estimate of when I will release a new update. However, in the meantime,
if you have questions, remarks, suggestions, or bug reports, you can e-mail them
to me.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Examples of the APA manual}
\label{sec:xmpl}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\bfseries Note: the text of this section has not been updated and
reflects the working of the [2009/03/01] version of \pkg{apacite}
vis-\`a-vis the 5th edition of the APA manual. The actual formatting
is done by the current version of \pkg{apacite} and thus may not
correspond to the text. This section is retained for the moment, because
the majority may still be relevant and I haven't finished incorporating
the examples from the 6th edition yet, and because it describes various
workarounds and tips that may still be useful.}

In this section, the \pkg{apacite} package is tested by citing the examples of
the 5th edition of the APA manual \cite[pp.~207--281]{APAManual5}, and some
additional references for additional purposes.

The following list gives the examples from chapter~3 of the 5th edition of
the APA manual, with
section number. For these and all later examples, whenever I thought it
necessary or desirable, I added some comments. These are indicated by the \EM{}
symbol. Especially for later examples (from Chapter~4), the comments frequently
pertain to the corresponding reference list entry.

\begin{itemize}
\item[3.94]  \citeA{3.94-1} compared reaction times\\
             In a recent study of reaction times \cite{3.94-1}\\
             In \citeyearNP{3.94-1} \citeauthor{3.94-1} compared
               reaction times\\
             In a recent study of reaction times, \citeA{3.94-1}
             described the method\ldots. \citeauthor{3.94-1} also found
\item[3.95]  \citeA{3.95-1} found\\
             \citeA{3.95-1} found\\
             \citeauthor{3.95-1} found\\
             \fullcite{3.95-2} and \fullcite{3.95-3}\\
             \citeA{3.95-2} and \citeA{3.95-3}\\
             \EM It seems that if ``et al.\hbox{}'' would refer to one additional
             author, then this author is named instead of the ``et al.\hbox{}''
             clause.\\
             \citeA{3.95-4} and \citeA{3.95-5}\\
             as \citeA{3.95-6} demonstrated\\
             \EM The comma after ``Nightlinger'' in the reference list
             does not look right, but is explicitly required by the APA.
             Of course, with people as authors,
             one almost always has initials (although I have seen
             an example of an econometrician who only had
             one name), so this problem is not likely to occur.
             With nicknames (``screen names'' as they are called in the
             APA manual below ex. 85) in messages to newsgroups, initials
             are typically missing, but then there is usually (always?)
             only one author, so the problem does not exist either.
             The problem can, however, come up when there are two authors,
             the first of which is a corporate author, or with artists,
             e.g., the song ``Into the Groove'' is written by
             Madonna and Stephen Bray. \\
             as has been shown \cite{3.95-7}
\item[3.96]  \cite{3.96-1}\\
             \cite{3.96-1}\\
             \cite{3.96-2}\\
             \EM If the \fieldname{firstkey} field is different for different
             references
             and the \fieldname{key} field is the same, then, analogous
             to the use of extra authors in 3.95 above, \pkg{apacite}
             uses the \fieldname{firstkey} field for all citations:\\
             \citeA{3.96-3}, \citeA{3.96-4}, \citeA{3.96-5}, \citeA{3.96-6};\\
             \citeA{3.96-3}, \citeA{3.96-4}, \citeA{3.96-5}, \citeA{3.96-6}.\\
             Although this is a constructed example, these organizations
             really exist. The ``Koninklijke Nederlandse Schaakbond''
             is the Royal Dutch Chess Association and the
             ``Koninklijke Nederlandse Schaatsbond'' is the Royal Dutch
             Skating Association. Both are abbreviated to KNSB and
             presumably, both publish an annual report each year.
             Furthermore, in these examples, I copied the contents of the
             \fieldname{author} field to the \fieldname{publisher} field.
             \pkg{apacite} recognizes this and puts the APA-requirement
             ``Author'' as publisher description in the reference list.
             Other styles may prefer the full publisher name again.
\item[3.97]  on free care \cite{3.97-1}\\
             \EM The order of the
             closing quotes and the comma is different from the
             APA manual. I think this one is more logical, although the
             APA manual's is the conventional one, presumably for
             aesthetic reasons. I hope to implement this in a future
             version.\\
             the book \citeA{3.97-2}\\
             \cite{3.97-3}\\
             \EM If two articles both have no author and the title and
             the year are the same, a's and b's should be used:
             \citeA{3.97-4}, \citeA{3.97-5}, and \citeA{3.97-6}.
             The latter two entries are correctly sorted by month,
             through the way the month macros are defined in
             the \fname{.bst} files.
\item[3.98]  \citeA{3.98-1} and \citeA{3.98-2} also found\\
             \citeA{3.98-3} and \citeA{3.98-4} studied
\item[3.99]  Past research \cite{3.99-1,3.99-2}\\
             Past research \cite{3.99-3,3.99-4,3.99-5}\\
             Several studies
               \cite{3.99-6,3.99-7,3.99-8,3.99-9,3.99-10,3.99-11}\\
             Several studies \cite{3.99-12,3.99-13,3.99-14}\\
             \EM \pkg{apacite} does not (yet?) sort the cited
             references in the text (of course it does for the reference
             list), as required by the APA manual.\\
             (\citeNP{3.99-15}; see also \citeNP{3.99-16,3.99-17})\\
             \EM Note that I had to use \cmd{\citeNP} here.
\item[3.100] \cite{3.100-1}\\
             \EM This is not an example, but a rule in the text.
             The ``\bibnodate'' is handled by the \cmd{\bibnodate}
             macro. It is not clear whether it is really meant that the
             in-text form is \citeauthor{3.100-1}, \citeyearNP{3.100-1}
             or the more logically consistent \citeA{3.100-1}.
             The former can (currently) only be accomplished by using
             \cmd{\citeauthor} and \cmd{\citeyearNP} explicitly,
             whereas the latter is simply obtained by \cmd{\citeA}.\\
             \cite{3.100-1b}\\
             \EM Again, this is not an example, but a rule in the text.\\
             \cite{3.100-2}\\
             \citeA{3.100-3}\\
             \EM For citations to the bible, I used \cmd{\biblecite} and
             several obvious variations on it, as discussed in
             section~\ref{sec:apacdoc}:\\
             \cmd{\bibleciteA}, first cite:  \bibleciteA{1 Cor.\ 13:1}\\
             \cmd{\bibleciteA}, second cite: \bibleciteA{1 Cor.\ 13:1}\\
             \cmd{\biblecite}, first cite: \fullbiblecite{1 Cor.\ 13:1}\\
             \cmd{\biblecite}, second cite: \biblecite{1 Cor.\ 13:1}\\
             (\cmd{\bibleciteNP}, first cite:
              \fullbibleciteNP{1 Cor.\ 13:1} and some text surrounding it)\\
             (\cmd{\bibleciteNP}, second cite:
              \bibleciteNP{1 Cor.\ 13:1} and some text surrounding it)\\
             \EM Here, there probably should be a comma if it's the first
             cite and not a comma when it's a later cite. A difficult one.\\
             \EM Ancient Greek and Roman works should be treated similarly,
             i.e., not be listed in the reference list. But it seems to me
             that title and/or author must be given in the text as well.
             Maybe I will try to construct a tentative example of this in
             a future release.
\item[3.101] \cite[p.~332]{3.101-1}\\
             \cite[Chapter~3]{3.101-2}\\
             \EM If you like, you can use the \pkg{apacite}-defined
             abbreviation commands \verb+\BPG+ and \verb+\BCHAP+.\\
             \cite[\P~5]{3.101-3}\\
             \cite[Conclusion section, para.~1]{3.101-4}
\item[3.102] \EM Personal communication is not really citation and should
             be done manually:\\
             T.~K. Lutes (personal communication, April 18, 2001)\\
             (V.-G. Nguyen, personal communication, September 28, 1998)
\item[3.103] \cite<see Table~2 of>[for complete data]{3.103-1}
\end{itemize}

\noindent
Chapter~4 of the APA manual deals with the reference list
and only mentions some in-text citation issues in passing.
Therefore, the rest mainly requires a lot of moving back and forth
between the reference list and this part. I start with the
more general part, sections 4.01--4.15, presented similar to
the sections from chapter~3 as presented above.
\begin{itemize}
\item[4.04] \EM First, some examples mentioned in the text:\\
            \citeA{4.04-t1},
            \citeA{4.04-t2},
            \citeA{4.04-t3},
            \citeA{4.04-t4},
            \citeA{4.04-t5},
            \citeA{4.04-t6},
            \citeA{4.04-t7},
            \citeA{4.04-t8},
            \citeA{4.04-t9}\\
            \EM The APA manual states that prefixes must be treated
            according to the rules of the language of origin. These rules
            can differ a lot between languages (and countries) and it
            is impossible to know all these rules. The APA manual gives two
            examples, one in which ``De Vries'' is treated as the surname,
            and one in which ``Helmholtz'' is the surname and ``von'' is
            the ``von'' part of the name.

            In the former case, the author is referred to as, say, ``De Vries
            (1999)'' in text and ``De Vries, J. (1999).'', alphabetized under
            ``D'' in the reference list. In the second example, the author is
            referred to as, say, ``Helmholtz (1870)'' and listed in the
            reference list as ``Helmholtz, H. L. F. von. (1870).'',
            alphabetized under ``H''. To get this right, the author must be
            defined as
\begin{verbatim}
  author = {H. L. F. von Helmholtz},
\end{verbatim}
            or
\begin{verbatim}
  author = {von Helmholtz, H. L. F.},
\end{verbatim}
            then \BibTeX{} will assign the correct parts to the first names,
            ``von''-part, and last name. The seemingly logical
\begin{verbatim}
  author = {Helmholtz, H. L. F. von},
\end{verbatim}
            will not be formatted correctly, because ``von'' is now
            considered to be part of the first names and therefore
            abbreviated to ``v.''.

            Below, under example B-2, I will further discuss some
            issues about ``von'' parts.

            \EM The APA manual requires that numerals are alphabetized
            as if they were spelled out. This is not done by \pkg{apacite},
            so when applicable should be done by the user, e.g.\ by using
            the \cmd{\APACSortNoop} command as discussed in
            section~\ref{subsec:sort}. I give one fictitious example
            \cite{4.04-t10}.

            \citeA{4.04-1}\\
            \citeA{4.04-2}\\
            \citeA{4.04-3}\\
            \citeA{4.04-4}\\
            \citeA{4.04-5}\\
            \citeA{4.04-6}\\
            \citeA{4.04-7}\\
            \citeA{4.04-8}\\
            \citeA{4.04-9}\\
            \citeA{4.04-10}\\
            \citeA{4.04-11}\\
            \citeA{4.04-12}\\
            \EM As stated in the APA manual, an exception to the rule
            of sorting by title if author and year are the same occurs
            when the works are identified as a series. Then ordering
            the parts of the series sequentially can be done using the
            \cmd{\APACSortNoop} command.\\
            \EM Here, it says that only ``A'' and ``The'' are excluded
            from the sorting (if they are the initial words), but I
            assume they mean ``An'' as well. This is how it is
            implemented in \pkg{apacite}.

            \citeA{4.04-13}\\
            \citeA{4.04-14}\\
            \EM I have not (yet?) studied referencing legal materials.
            In the first version of \pkg{apacite}, I defined a
            \entryname{literal} type, so that the users can
            literally format such entries themselves. This is still
            available. However, I think that if you need to refer to
            legal cases, you can find a way to use the
            \entryname{misc} type to get it right. I might study this
            and give examples in a next version of \pkg{apacite}.
\item[4.05] \citeA{4.05-1}\\
            \nocitemeta{4.05-2}\citeA{4.05-2}\\
            \EM Here I used the \cmd{\nocitemeta} command to let
            \pkg{apacite} know that a meta-analysis is reported and this
            work is included in it. As you can see, you can still cite
            the work by using the normal citation commands such as
            \cmd{\citeA}.
\item[4.08] \citeA{4.08-1}\\
            \citeA{4.08-2}\\
            \citeA{4.08-3}\\
            \EM To obtain the ``(with \dots)'' description in the
            reference list, I used the \cmd{\bibliteral} command.
            Furthermore, to get this formatted correctly in the author
            index, I used the \cmd{\indexskipbracenodot} command to
            suppress an additional period. These commands are described
            in section~\ref{sec:apacdoc}.

            To \BibTeX{}, the \cmd{\bibliteral} construction is a complicated
            accented character, which is the second initial of the author.
            Consequently, this does not work properly with styles that put
            the initials \emph{before} the surnames, and care must be
            exercised with ``junior'' parts (see ex.~70). Furthermore,
            this construction must be put between a pair of
            braces in order for \BibTeX{} to treat it as an accented letter,
            instead of abbreviating it.
\item[4.09] \citeA{4.09-1}
\item[4.10] \citeA{4.10-1}\\
            \citeA{4.10-2}
\item[4.11] \citeA{4.11-1}\\
            \citeA{4.11-2}\\
            \EM Note that in the \fname{.bib} file, the ``junior'' part comes
            directly after the surname and a comma, with the initials
            after the ``junior'' part, whereas in the formatted
            reference list, the more logical order \opt{surname},
            \opt{initials}, \opt{junior}, is used.
\item[4.12] \citeA{4.12-1}
\item[4.13] \citeA{4.13-1}\\
            \EM ``For substantial reference works with a large editorial
            board, naming the lead editor followed by \texttt{et al.} is
            acceptable''. This is now implemented in \pkg{apacite} as
            follows: If there are 7 or more editors, only the first one
            is named, followed by ``et al.\hbox{}'' \cite{4.13-2}.
\item[4.15] \citeA{4.15-1}\\
            \EM Here I used the new \fieldname{url} and
            \fieldname{lastchecked} fields.\\
            \citeA{4.15-2}
\end{itemize}

\noindent
The rest is from section~4.16, the examples section. The section number
is omitted, but A--I are used instead for the unnumbered examples. For
the numbered examples, only the number is given.
The following enumerated list gives the example number, and
the two basic in-text citation commands, both in a full and
short form, of the examples.
\begin{enumerate}
\item[A-1] \cite{A-1}  \\ \cite{A-1} \\ \fullciteA{A-1} \\ \citeA{A-1}
\item \cite{ex1}  \\ \cite{ex1} \\ \fullciteA{ex1} \\ \citeA{ex1}
\item \cite{ex2}  \\ \cite{ex2} \\ \fullciteA{ex2} \\ \citeA{ex2}
\item \cite{ex3}  \\ \cite{ex3} \\ \fullciteA{ex3} \\ \citeA{ex3}
\item \cite{ex4}  \\ \cite{ex4} \\ \fullciteA{ex4} \\ \citeA{ex4}\\
      \cite{ex4-2} \\ \cite{ex4-2} \\ \fullciteA{ex4-2} \\ \citeA{ex4-2}\\
      \EM Note that the list of authors can be finished with
      ``\verb+and others+'' if there are more than 6 authors, or
      all authors can be given, in which case \pkg{apacite} truncates
      the list after the first~6. For compatibility with other styles,
      the latter is preferable.
\item \cite{ex5}  \\ \cite{ex5} \\ \fullciteA{ex5} \\ \citeA{ex5}
\item \cite{ex6}  \\ \cite{ex6} \\ \fullciteA{ex6} \\ \citeA{ex6}
\item \cite{ex7}  \\ \cite{ex7} \\ \fullciteA{ex7} \\ \citeA{ex7}\\
      \EM Here, I used
\begin{verbatim}
  month = spring,
\end{verbatim}
      using the new \verb+spring+ macro defined in the \fname{.bst} files.
\item \cite{ex8}  \\ \cite{ex8} \\ \fullciteA{ex8} \\ \citeA{ex8}\\
      \EM Here, again, the order of the closing quotes and the
      following comma should be reversed according to the APA rules.\\
      \EM The \fieldname{month} field is formatted as
\begin{verbatim}
  month = aug # "/" # sep,
\end{verbatim}
      which uses the month macros and \BibTeX's concatenation
      operator `\verb+#+'.
\item \cite{ex9}  \\ \cite{ex9} \\ \fullciteA{ex9} \\ \citeA{ex9}\\
      \EM Here, again, the order of the closing quotes and the
      following comma should be reversed according to the APA rules.
\item \cite{ex10} \\ \cite{ex10}\\ \fullciteA{ex10}\\ \citeA{ex10}
\item \cite{ex11} \\ \cite{ex11}\\ \fullciteA{ex11}\\ \citeA{ex11}\\
      \EM Apparently, a weekly newspaper is not a magazine and should
      therefore include ``p.\hbox{}'' or ``pp.\hbox{}'' in front of
      the page
      number(s), whereas a magazine article should not. I do not
      understand the distinction very well and find it not very
      useful as well, but will adhere to it. It means that the
      \entryname{newspaper} type gets the ``pp.\hbox{}'', whereas
      \entryname{magazine} and \entryname{article}, which are now
      identical, do not.
\item \cite{ex12} \\ \cite{ex12}\\ \fullciteA{ex12}\\ \citeA{ex12}\\
      \EM Here, \verb+\emph{DSM-IV}+ must be entered without an extra
      pair of braces in the title field; see ex.~73 for the intricacies
      of braces and \verb+\emph+ in the title field.
\item \cite{ex13} \\ \cite{ex13}\\ \fullciteA{ex13}\\ \citeA{ex13}\\
      \EM Here, the \fieldname{number} field is \verb+1, Serial No.~231+.
\item \cite{ex14} \\ \cite{ex14}\\ \fullciteA{ex14}\\ \citeA{ex14}\\
      \EM Here, the \fieldname{number} field is \verb+3, Pt.~2+.
\item \cite{ex15} \\ \cite{ex15}\\ \fullciteA{ex15}\\ \citeA{ex15}
\item \cite{ex16} \\ \cite{ex16}\\ \fullciteA{ex16}\\ \citeA{ex16}
\item \cite{ex17} \\ \cite{ex17}\\ \fullciteA{ex17}\\ \citeA{ex17}\\
      \EM This case is the opposite of the more common situation where a
      reprint is cited and an original publication year is given. I could
      implement similar code to handle this case (and I may if I get requests
      to do this), but for the moment, I decided to trick the system: I
      used the \cmd{\bibreftext} command mentioned in
      section~\ref{sec:apacdoc}. It must be called with two
      arguments. Initially, it places the second argument in the text, but
      just before the bibliography, its definition is changed so that the
      first argument is placed in the reference list. By defining
\begin{verbatim}
  year = {{\protect\bibreftext{1992}{1992/1993}}},
\end{verbatim}
      in the \fname{.bib} file, the year is ``1992'' in the reference
      list and ``1992/1993'' in the text citations. The \cmd{\protect}
      is necessary to make sure that the \cmd{\bibreftext} macro is not
      written out in the label-part of the bibliography, because then
      only ``1992'' would appear in the text reference. The additional
      pair of braces are necessary to make sure that the entry
      is alphabetized correctly. When these are omitted, the entry
      is alphabetized under the ``P'' of ``protect''. Of course, the
      latter is only important if the reference list contains
      multiple works by the same author(s), but the same phenomenon
      is encountered when the \fieldname{author} or \fieldname{editor}
      field starts with a command, or when there is no author or editor
      and the \fieldname{title} field starts with a command, as in
      the entry \citeA{4.04-t10} introduced in 4.04 above.

      Of course, you can save yourself a lot of trouble by
      obtaining the original article and citing that.
\item \cite{ex18} \\ \cite{ex18}\\ \fullciteA{ex18}\\ \citeA{ex18}\\
      \EM Here, the \fieldname{number} field is \verb+Suppl.~2+.
\item \cite{ex19} \\ \cite{ex19}\\ \fullciteA{ex19}\\ \citeA{ex19}\\
      \EM Other styles treat the \emph{Annual Review} as a book
      (\emph{Sociological Methodology} is an even stronger example),
      so this is a point where the \fname{.bib} file becomes
      highly incompatible between styles. This cannot be avoided.
\item \cite{ex20} \\ \cite{ex20}\\ \fullciteA{ex20}\\ \citeA{ex20}\\
      \EM Here, the \fieldname{englishtitle} field is used for the
      English translation of the German title. To get the German
      capitalization of the title right, the capitalized words must
      be protected by an additional pair of braces.
\item \cite{ex21} \\ \cite{ex21}\\ \fullciteA{ex21}\\ \citeA{ex21}\\
      \EM Apparently, a translator and original publication date
      do not have to be mentioned here.
\item Seidenberg and McClelland's study \cite<as cited in>{ex22}\\
      %\cite{ex22} \\ \cite{ex22}\\ \fullciteA{ex22}\\ \citeA{ex22}\\
      \EM The APA website (\url{http://www.apastyle.org/faqs.html})
      mentions that the year should generally also be mentioned,
      making it a complete cite, except that there is no reference
      list entry. In my opinion, it would be better to list the
      complete original work in the reference list as well, in case
      readers do have access to the original work, but not to the
      secondary source. But this is not the APA rule. \\
      \EM You may like to have the authors of the unlisted reference
      in the author index as well. Use the \cmd{\AX} command for
      this, as explained in section~\ref{sec:autindex}.
\item[B-1] \cite{B-1}  \\ \cite{B-1} \\ \fullciteA{B-1} \\ \citeA{B-1}
\item \cite{ex23} \\ \cite{ex23}\\ \fullciteA{ex23}\\ \citeA{ex23}\\
      \EM Here, and in several other references, I put \verb+\hbox{}+
      after the ``\verb+Jr.+'', so that \TeX{} does not consider the
      period as a sentence-ending period.\\
      \EM \pkg{apacite} now supports only an integer value (``\verb+3+'')
      in the \fieldname{edition} field, and transforms this to
      ``3rd''.
\item \cite{ex24} \\ \cite{ex24}\\ \fullciteA{ex24}\\ \citeA{ex24}\\
      \EM The APA manual gives a number, which would not ordinarily be
      done with proper books and which suggests that it could also
      be treated as a report. In that case, the default
      ``Tech.\ Rep.\hbox{}''
      description should be left out, however. This can be accomplished
      by defining
\begin{verbatim}
  type = {\bibnotype},
\end{verbatim}
      which flags that the type must be left out, see ex.~42.
      However, for books, it now works fine leaving the \fieldname{type}
      field empty and giving the number in the \fieldname{number} field.
\item \cite{ex25} \\ \cite{ex25}\\ \fullciteA{ex25}\\ \citeA{ex25}\\
      \EM According to the note after ex.~25 in the APA manual,
      an edited book with ``just one'' author should list
      the editor (and translator, when available) after the
      title, just like the translator. An example of this is
      \citeA{ex25-t1}. (Should the original years of publication
      be used here?)

      However, what does ``just one author'' mean here? Does it mean that if
      there are 2 authors and 1 or more editors, the editors should
      not be mentioned, or the authors should not be mentioned?
      Presumably, it means the following:
      In the default case, an edited book consists of several chapters,
      with different chapters written by different authors. In this case,
      the reference to the whole book lists only the editor(s).
      If every chapter is written by the same author, and there are 1
      or more editors, their condition holds. I think that if all
      chapters are written by the same $n$ ($\geq 2$) authors, it should
      also be treated in this way, i.e., with the authors in the
      author position and the editor behind the title. A difficult
      case would appear if the book were a collection of works of, say,
      2 authors, with some chapters written by one and some by the
      other, and some jointly, as in \citeA{ex25-t2}. These choices have
      to be made by the user, however, \pkg{apacite} will format author,
      editor, and translator, whenever available.
\item \cite{ex26} \\ \cite{ex26}\\ \fullciteA{ex26}\\ \citeA{ex26}\\
      \EM According to section~3.97, the title should be in italics.
      In this example, in the citation, it is not given in italics,
      but this must be an error, because they do give it in italics
      on p.~219 (but give no date there).
\item \cite{ex27} \\ \cite{ex27}\\ \fullciteA{ex27}\\ \citeA{ex27}\\
      \EM Here, the \fieldname{edition} field has value
      ``\verb+Rev.\hbox{}+'' and \pkg{apacite} handles this
      noninteger value correctly as well.
\item \cite{ex28} \\ \cite{ex28}\\ \fullciteA{ex28}\\ \citeA{ex28}\\
      \EM Use the en-dash (``\verb+--+'') and not simply a hyphen
      (``\verb+-+''), because the latter is not considered to mean
      ``to'' by \pkg{apacite} (cf.\hbox{} ``Vol.~A-1'').
\item \EM As mentioned in section~\ref{sec:apacdoc}, \fname{apacdoc.sty}
      provides the \cmd{\DSMcite} macro and some related
      alternatives to get the \emph{DSM} references right. On rereading
      the description in the APA manual, I discovered that previous
      versions of \pkg{apacite} did not format the first citation
      correctly, although the description is a bit ambiguous as to
      how exactly the first citation should be formatted. Therefore,
      I looked at a recent issue of
      \emph{Journal of Abnormal Psychology}, \emph{116}(3); and
      \emph{Psychological Assessment}, \emph{19}(2). These show
      some slight variations, some of which have good reasons, but
      others seem arbitrary. In all articles I looked at, the first
      citation was an in-text citation, and the following form was
      the most frequently used, and thus implemented in
      \fname{apacdoc.sty}:\\
      \cmd{\DSMciteA}, first citation: \DSMciteA{ex29} \\
      \EM The following citations then only use the abbreviated title:\\
      \cmd{\DSMciteA}, second citation: \DSMciteA{ex29} \\
      \EM Because I haven't found a parenthetical first cite, I
      have to use some logic and common sense to define it:\\
      \cmd{\DSMcite}, first citation: \DSMfullcite{ex29} \\
      \EM Subsequent parenthetical cites are formatted as\\
      \cmd{\DSMcite}, second citation: \DSMcite{ex29} \\
      \EM Finally, here are ``\verb+NP+'' versions of them:\\
      \cmd{\DSMciteNP}, first citation: \DSMfullciteNP{ex29} \\
      \cmd{\DSMciteNP}, second citation: \DSMciteNP{ex29} \\
      To use these citation commands, you have to provide a
      \fieldname{key} field that contains a \cmd{\bibDSM}
      command:
\begin{verbatim}
  key = {{\bibDSM{American Psychiatric Association}{Diagnostic
         and Statistical Manual of Mental Disorders}{4th
         ed.\hbox{}}{DSM-IV}}},
\end{verbatim}
      As is evident from this example, the four arguments are
      author, full title, edition, short title. Thus, because
      all this information is provided in the \fname{.bib}
      entry (and not preprogrammed in \pkg{apacite}), it is
      conceivable that this command is useful for other types
      of works as well. The generality is a bit limited, though,
      because all four arguments must be available and have
      meaningful content (i.e., should not be empty). But it
      is relatively straightforward to write your own specialized
      citation commands, based on the \cmd{\DSMcite} code,
      which do not require all parts to be available.

      However, the \cmd{\DSM*} macros are still very rough. Multiple
      citations are not handled well, so only one work should
      be cited with such a macro. Furthermore, the pre- and
      postfixes (through \verb+<...>+ and \verb+[...]+) are not
      available. Note also that the edition should be spelled
      out as ``\verb+4th ed.\hbox{}+''. When I experimented with
      just ``\verb+4+'', trying to use the \cmd{\PrintOrdinal}
      function, things went terribly wrong. Even if I put
      \verb+\PrintOrdinal{4}+ in the \fieldname{key} field, it
      didn't work. Finally, the ``ed.\hbox{}'' must be added
      to allow reference to the ``3rd ed., rev.\hbox{}'' and the
      ``4th ed., text rev.\hbox{}'' as well.

      \EM In some of the articles I studied, ordinary citations
      were used, esp.\ when page numbers were given in
      parenthetical cites. Thus, you can also use\\
      \verb+\cite[p.~25]{ex29}+: \cite[p.~25]{ex29}
\item \cite{ex30} \\ \cite{ex30}\\ \fullciteA{ex30}\\ \citeA{ex30}\\
      \EM Here, ``6th ed.'' comes before ``Vols.\ 1--20'', so it is
      Vols.\ 1--20 of the 6th edition. Pre-[2003/09/05] versions
      of \pkg{apacite} placed volumes before editions,
      which is appropriate when different volumes of a series
      are not updated jointly, so that you may have the 3rd edition
      of Vol.~2, but only the 1st edition of Vol.~6. Should you
      want this, you have to trick the system by putting both
      elements in the \fieldname{edition} field:
\begin{verbatim}
  edition = {\BVOLS\ 1--20, 6th},
\end{verbatim}
      and leaving the \fieldname{volume} field empty.\\
      \EM Does the remark about large editorial boards mean that the
      APA intended to add ``et al.\hbox{}'' here? Anyway, here is an
      example of such a situation: \citeA{ex30-2}.
\item \cite{ex31} \\ \cite{ex31}\\ \fullciteA{ex31}\\ \citeA{ex31}
\item \cite{ex32} \\ \cite{ex32}\\ \fullciteA{ex32}\\ \citeA{ex32}
\item \cite{ex33} \\ \cite{ex33}\\ \fullciteA{ex33}\\ \citeA{ex33}\\
      \EM This illustrates that a \fieldname{type} field can be used
      with a \entryname{book} entry.
\item[B-2] \cite{B-2} \\ \cite{B-2} \\ \fullciteA{B-2} \\ \citeA{B-2} \\
      \EM This is a suitable point to discuss ``von'' parts further.
      One of the editors in the current example is called
      P. van den Broek. I am Dutch and I recognize this as a Dutch
      name, so let's assume that this person is Dutch. Let us now
      consider the situation that this person is the (only) author.
      Then according to the Dutch rules, this person would be listed in the
      reference list as ``Broek, P. van den. (1992)'' and listed under ``B'',
      but referred to in the text as ``Van den Broek (1992)'', including
      the ``von'' part and capitalizing the first letter. When an
      initial precedes the ``von'' part (e.g., when there are two
      primary authors with this surname, but with different initials),
      then this person would be referred to in the text as
      ``P. van den Broek (1992)'', including the ``von'' part, but now
      in lower case. The Dutch rules are very difficult to do right in
      \BibTeX{}/\LaTeX{} and they conflict with the rules for other
      languages, and presumably with the rules of the APA, which would
      require this person to be alphabetized under ``V'', at least.

      For the current editor position, there is no big problem with
      the APA rules. The ``von'' part can really be put in the ``von''
      part as recognized by \BibTeX{}, which I did, or it can be enclosed
      in braces, making the whole last name one part. Either will come
      out right and the editor will not be referred to in the text
      anyway. With styles that put the initials behind the surname,
      it will only work right when put in the ``von'' part. In the
      author position, however, things are different. Then this author
      could be formatted as
\begin{verbatim}
  author = {Van {\lowercase{D}}en Broek, P.},
\end{verbatim}
      where the \verb+{\lowercase{D}}+ construction is used to prevent
      \BibTeX{} from interpreting it as a ``von'' part, or
\begin{verbatim}
  author = {Van{\ }den{\ }Broek, P.},
  author = {{Van den Broek}, P.},
\end{verbatim}
      which in most situations gives the correct version according to the
      Dutch rules with the correct alphabetizing according to the APA
      rules. Only in situations when the initial would appear
      \emph{before} the surname (when there are other authors with the
      same surname or when using other styles), this would lead to
      unwanted results.

      If you really want to alphabetize according to the Dutch rules
      (which is \emph{not} APA in my interpretation), you can use the
      following trick. \fname{apacdoc.sty} defines a macro \cmd{\Dutchvon}
      with two arguments, which is equivalent to the \cmd{\bibreftext}
      macro discussed in ex.~17 above. That is, in the beginning
      of the document, it is defined as echoing its second argument,
      and just before the reference list, it is redefined to echo
      its first argument. Then define the author as
\begin{verbatim}
  author = {van den {\protect\Dutchvon{Broek}{Van den Broek}}, P.},
\end{verbatim}
      which, combined with the \pkg{apacite} formatting implies
      that in text, ``Van den Broek'' is used, whereas the author
      is alphabetized under ``B'' in the reference list, and listed
      as ``Broek, P. van den''. Of course, we could simply have
      used \cmd{\bibreftext} again, but that was used to cover a
      completely different situation, and I can easily imagine that
      when switching to another citation style, the former application
      (i.e., 1992/1993) must be kept, but the ``von'' part is handled
      differently, so that \cmd{\Dutchvon} must be redefined.
      Based on this example, users should be able to define their
      own tricks for similar peculiarities.

      Finally, note that in Belgium, where many people
      speak Dutch as well, it is customary to alphabetize under ``V''
      anyway (``Van Damme'').
\item \cite{ex34} \\ \cite{ex34}\\ \fullciteA{ex34}\\ \citeA{ex34}
\item \cite{ex35} \\ \cite{ex35}\\ \fullciteA{ex35}\\ \citeA{ex35}\\
      \EM The series title, volume number, and volume title are all
      put into the \fieldname{booktitle} field.
\item \cite{ex36} \\ \cite{ex36}\\ \fullciteA{ex36}\\ \citeA{ex36}\\
      \EM Again, the series title, volume number, and volume title are
      all put into the \fieldname{booktitle} field.\\
      \EM I had to use some tricks to get the Series and Volume Editors'
      descriptions right. The ``(Series Ed.\hbox{})'' is according to
      \BibTeX{} part of the last name of the first editor,
      and I used the \cmd{\bibeditortype} macro from
      \fname{apacdoc.sty} to get the volume editor right.
      See section~\ref{subsec:fields} for my interpretation of
      APA's usage of the term ``series''.
\item \cite{ex37} \\ \cite{ex37}\\ \fullciteA{ex37}\\ \citeA{ex37}\\
      \EM Note that ``Van'' in the first editor's surname is
      capitalized here, as in the APA manual. In the original Dutch,
      this would be in lower case.
\item \cite{ex38} \\ \cite{ex38}\\ \fullciteA{ex38}\\ \citeA{ex38}
\item \cite{ex39} \\ \cite{ex39}\\ \fullciteA{ex39}\\ \citeA{ex39}\\
      \EM Here, it is stated that the translator's name should be put
      after the editor's name when both are different, but in ex.~40,
      the translators are put after the title, before the editors.
      Apparently, if the book is a collection of works by one
      author(-group), edited and translated, then the translator
      should come after the editor, but if different chapters
      are translated by different translators, or perhaps not all
      are translated works, then the translator should come after
      the title. Of course, \pkg{apacite} has no way of knowing this.
      In the current implementation, for an \entryname{incollection},
      if the editor and translator are the same, they are formatted as
      in this example, whereas if they are different, they are treated
      as in ex.~40 below. I think this will be satisfactory in
      most cases. If you really want the translator after the editor
      when they are different, you can trick the system in a way
      similar to ex.~36.
\item \cite{ex40} \\ \cite{ex40}\\ \fullciteA{ex40}\\ \citeA{ex40}\\
      \EM See my comments to ex.~39 above.

      A test of the \fieldname{originaljournal} formatting:
      \citeA{ex40-t1}.
\item[C-1] \cite{C-1}  \\ \cite{C-1} \\ \fullciteA{C-1} \\ \citeA{C-1}\\
      \EM The APA manual initially formats the number with an
      en-dash: ``91--5''. When it discusses the number separately,
      however (p.~256), it uses a single hyphen: ``91-5''. Logically,
      the latter makes more sense to me (and is generally used in
      other numbers in the APA manual as well), so that's what I
      did here. Moreover, if the en-dash would be entered as
      ``\verb+--+'' in the \fieldname{number} field, \pkg{apacite}
      would interpret this as ``to'' and insert ``Nos.\hbox{}''
      instead of ``No.\hbox{}''. Thus, if you want the en-dash,
      you have to put this in the \fname{.bib} file in a different
      way, e.g., using the \cmd{\textendash} command.
\item \cite{ex41} \\ \cite{ex41}\\ \fullciteA{ex41}\\ \citeA{ex41}
\item \cite{ex42} \\ \cite{ex42}\\ \fullciteA{ex42}\\ \citeA{ex42}\\
      \EM I used the \cmd{\bibnotype} command to suppress the default
      ``(Tech.\ Rep.\hbox{})'' description. Actually, I don't think
      there is anything wrong with calling a report a report, be it
      ``technical'' by default, or by specifying
\begin{verbatim}
  type = {Report},
\end{verbatim}
      except that it's not done so in this specific example in the
      APA manual. But there does not seem to be a rule against it.

      \EM The NTIS information is put in a \fieldname{note} field.
\item \cite{ex43} \\ \cite{ex43}\\ \fullciteA{ex43}\\ \citeA{ex43}\\
      \EM The ERIC number is given in the \fieldname{note} field.
\item \cite{ex44} \\ \cite{ex44}\\ \fullciteA{ex44}\\ \citeA{ex44}
\item \cite{ex45} \\ \cite{ex45}\\ \fullciteA{ex45}\\ \citeA{ex45}
\item \cite{ex46} \\ \cite{ex46}\\ \fullciteA{ex46}\\ \citeA{ex46}\\
      \EM Note that in the example in the APA manual, ``Western Australia''
      \emph{is} mentioned in the publisher location, whereas their rule
      explicitly states that this should not be the case in this
      situation, and they stress that again below the example.
      Therefore, I did not mention ``Western Australia'' in the
      \fieldname{publisher} field.
\item \cite{ex47} \\ \cite{ex47}\\ \fullciteA{ex47}\\ \citeA{ex47}
\item \cite{ex48} \\ \cite{ex48}\\ \fullciteA{ex48}\\ \citeA{ex48}
\item \cite{ex49} \\ \cite{ex49}\\ \fullciteA{ex49}\\ \citeA{ex49}
\item \cite{ex50} \\ \cite{ex50}\\ \fullciteA{ex50}\\ \citeA{ex50}
\item \cite{ex51} \\ \cite{ex51}\\ \fullciteA{ex51}\\ \citeA{ex51}\\
      \EM As of this version of \pkg{apacite}, the location of a
      \entryname{lecture} can be given in the \fieldname{address}
      field.
\item \cite{ex52} \\ \cite{ex52}\\ \fullciteA{ex52}\\ \citeA{ex52}
\item \cite{ex53} \\ \cite{ex53}\\ \fullciteA{ex53}\\ \citeA{ex53}
\item \cite{ex54} \\ \cite{ex54}\\ \fullciteA{ex54}\\ \citeA{ex54}
\item \cite{ex55} \\ \cite{ex55}\\ \fullciteA{ex55}\\ \citeA{ex55}\\
      \EM It seems logical to suppress the original year in the
      citation if it's the same as the year of the abstract, cf.\
      the comment to ex.~17 in the APA manual (5th ed., p.~245).

      \EM According to example 54 and the text below it, an ``A''
      or ``B'' should be added to the volume number of \emph{DAI}
      of this entry, presumably an ``A'', but because they did not
      give one, I left it out as well.
\item \cite{ex56} \\ \cite{ex56}\\ \fullciteA{ex56}\\ \citeA{ex56}
\item \cite{ex57} \\ \cite{ex57}\\ \fullciteA{ex57}\\ \citeA{ex57}\\
      \EM In ex.~59, the city should not be mentioned because it is
      already mentioned in the name of the university. Here, the
      city \emph{is} mentioned again, which seems contradictory.
      This is all in the \fname{.bib} file; \pkg{apacite} uses
      whatever is given there, so this is not a formatting problem
      for \pkg{apacite} itself.
\item \cite{ex58} \\ \cite{ex58}\\ \fullciteA{ex58}\\ \citeA{ex58}
\item \cite{ex59} \\ \cite{ex59}\\ \fullciteA{ex59}\\ \citeA{ex59}\\
      \EM See ex.~57 for the city issue.
\item \cite{ex60} \\ \cite{ex60}\\ \fullciteA{ex60}\\ \citeA{ex60}
\item \cite{ex61} \\ \cite{ex61}\\ \fullciteA{ex61}\\ \citeA{ex61}\\
      \EM The description of the data goes into the
      \fieldname{type} field. It may be more logical to put it
      in the \fieldname{title} field, with some trickery to indicate
      that it's a description and not a title, but putting it in the
      \fieldname{type} field already ensures that it's formatted
      correctly, so I think I'm gonna be lazy on this one. The same
      applies more or less to reviews (G-1, 63, 64), although there
      it is logical to put at least ``Review'' in the \fieldname{type}
      field, so as we're already there, we might as well make it
      complete.
\item \cite{ex62} \\ \cite{ex62}\\ \fullciteA{ex62}\\ \citeA{ex62}\\
      \EM ``Available from'' an address should be spelled out in the
      \fieldname{note} field, to get the parentheses. ``Available
      from'' a website is without parentheses, see ex.~95.
\item[G-1] \cite{G-1}  \\ \cite{G-1} \\ \fullciteA{G-1} \\ \citeA{G-1}\\
      \EM See my comments to ex.~61 above about the logic of the
      \fieldname{type} field. For a review, the \fieldname{type}
      field must contain the message that it is a review of a
      \emph{book} (or motion picture, or whatever it is a review of)
      and give the title of the reviewed work in italics, which must
      be manually formatted, e.g., by using the \cmd{\APACcitebtitle}
      macro. The author of the reviewed work should apparently not be
      mentioned.
\item \cite{ex63} \\ \cite{ex63}\\ \fullciteA{ex63}\\ \citeA{ex63}
\item \cite{ex64} \\ \cite{ex64}\\ \fullciteA{ex64}\\ \citeA{ex64} \\
      \EM Here, the title of the motion picture,
      \APACcitebtitle{Discovering Psychology}, is capitalized,
      whereas this was not done with book titles in ex.~G-1 and 63.
      I don't know whether this is an error or an implicit rule,
      but this formatting must be done in the \fname{.bib} file,
      so it's up to the user to do this as desired.
\item \EM The rules for movies, television series, etc.\ do not appeal
      very much to me, although they are not nearly as bad as those
      for music recordings (ex.~69 and further, see below). My
      primary objection is that when referring to movies and TV series,
      the title is the most important characteristic. The director
      may be a good second in some cases, but producers and writers are
      almost always unknown to the general public and not relevant
      when referring to them. You talk about the movie \emph{Jaws}
      and not about Spielberg (1975) or whoever wrote the script.
      Recognizing the primary creative input or authorship may be
      politically correct, but not particularly informative.
      However, you may think that my objections are mainly
      driven by the difficulties of trying to format the entries
      in \BibTeX{}. Anyway, here are my attempts to implement
      the APA rules.\\
      \cite{ex65-1} \\ \cite{ex65-1}\\ \fullciteA{ex65-1}\\ \citeA{ex65-1} \\
      \EM I find ``United States'' a somewhat uninformative address.

      \cite{ex65-2} \\ \cite{ex65-2}\\ \fullciteA{ex65-2}\\ \citeA{ex65-2} \\
      \EM Note again that this and the following ``Available from''
      must be between
      parentheses (accomplished by putting it in the \fieldname{note} field),
      whereas ``Available from'' some web site must not be between
      parentheses, cf.\ ex.~95.

      \EM In these examples, I used the \cmd{\bibliteral},
      \cmd{\bibskipbracenodot}, and  \cmd{\indexskipbracenodot} commands
      from \fname{apacdoc.sty}.\\
      \cite{ex65-3} \\ \cite{ex65-3}\\ \fullciteA{ex65-3}\\ \citeA{ex65-3}\\
      \EM Here, I simply let ``(Producer)'' be part of the author name,
      but because of this addendum, the entry is not sorted correctly
      in the reference list: It should be before \citeA{APAManual6},
      but because of the addendum, the authors are different to \BibTeX{}
      and this one comes after \citeA{APAManual6}. The ordering can be
      corrected by using the \cmd{\APACSortNoop} command as discussed in
      section~\ref{subsec:sort}. However, the authors of these entries will
      still be different. If it's important that they are the same (e.g.,
      for the author index), the \fname{.bbl} file should be edited manually.
      This seems an extremely rare event, though.
\item \cite{ex66} \\ \cite{ex66}\\ \fullciteA{ex66}\\ \citeA{ex66} \\
      \EM Here, I used the same tricks as in ex.~65.
\item \cite{ex67} \\ \cite{ex67}\\ \fullciteA{ex67}\\ \citeA{ex67} \\
      \EM I used several tricks introduced before: the \cmd{\bibeditortype}
      (cf.\ ex.~36) construction to be able to use ``(Producer)'' in
      the editor position instead of  ``(Ed.\hbox{})'', and the ones used
      in the previous examples. Because there is another Miller as well,
      the initial is given here. To make sure that \BibTeX{} thinks
      that there is only one initial, but the ``(Producer)'' is formatted
      correctly, the name is defined as follows:
\begin{verbatim}
  editor = {Miller, {\bibinitial{R\bibeditortype{Producer}}}},
\end{verbatim}
      using the \cmd{\bibinitial} and \cmd{\bibeditortype} commands from
      \fname{apacdoc.sty}.
      It is then formatted correctly both in the text and in the reference
      list if \cmd{\bibeditortype} is defined to swallow its argument
      in the text, and redefined prior to the bibliography. After the
      bibliography (before the index), it has to be redefined again
      to swallow its argument.
\item \cite{ex68} \\ \cite{ex68}\\ \fullciteA{ex68}\\ \citeA{ex68}\\
      \EM Again, I used several tricks that were also used in the previous
      examples.
\item \EM The rules for music recordings do not make any sense, and they
      are not entirely clear as well. It would seem to me that
      most pop, rock, and other ``light'' music songs are almost always
      attributed to the performing artist. You can usually read who the
      composer and lyricist of the song are on the inlay-details
      of the CD, but if you want the reader to refer to ``My Way'',
      the reader will easier find it (in a CD store or on the
      internet, for example) under ``Frank Sinatra'' than under
      the composer's name (whoever that may be). Furthermore, the
      year of release of the CD (or other medium) seems more relevant
      in referring to the CD than the year of copyright of the
      specific song, or the recording date.

      For classical music, things are different. Then, the writer (composer)
      is often more important than the performing artist, although
      the percentage of people who know who wrote the lyrics for
      Mozart's operas may not be high. Furthermore, it may be
      time-consuming and not very relevant for most authors and
      readers to find the year in which a certain piece was written,
      although strictly speaking, we should use the ``date of copyright'',
      which is not relevant for a lot of classical music.

      However, when referring to Beethoven's 9th symphony, say, it will
      typically not be very informative to refer to a specific recording on a
      specific CD, unless that specific recording is the subject of interest,
      but then it would seem that the ``performing artist'' (conductor or
      orchestra) should take the role of ``author''. For example, when
      comparing a performance of this symphony conducted in 1975 by Masur with
      a performance of this symphony conducted in 1990 by Bernstein (assuming
      this exists), it does not seem logical to compare ``9th Symphony''
      (Beethoven, 1823a, tracks~1--4) with ``9th Symphony'' (Beethoven, 1823b,
      tracks~1--4), but more logical to compare Masur (1975) with
      Bernstein (1990).

      Finally, it seems a bit strange that the track number should be
      mentioned in text, but not in the reference list.

      Again, you may think that my objections are mainly
      driven by the difficulties of trying to format the entries
      in \BibTeX. Nevertheless, here are my attempts to implement
      the APA rules, using variations of the \cmd{\citesong}
      command, defined in \fname{apacdoc.sty}:\\
      \begin{tabular}{ll}
      \cmd{\citeAsong}:  & \citeAsong{ex69-1} \\
      \cmd{\citesong}:   & \citesong{ex69-1}  \\
      \cmd{\citesongNP}: & \citesongNP{ex69-1}\\
      \cmd{\citeAsong}:  & \citeAsong{ex69-2} \\
      \cmd{\citesong}:   & \citesong{ex69-2}  \\
      \cmd{\citesongNP}: & \citesongNP{ex69-2}
      \end{tabular}\\
      \EM The \fieldname{key} field contains the relevant
      information in the form of a protected \cmd{\bibsong} command:
\begin{verbatim}
  key = {{\protect\bibsong{author}{year}{song title}{track info}}},
\end{verbatim}
      Furthermore, I used some tricks to get the reference list
      entry right. I used the \entryname{incollection} type as
      a basis, with the CD title in the \fieldname{booktitle} field.
      At first sight, it seems natural to define
\begin{verbatim}
  type = {CD},
\end{verbatim}
      but with an \entryname{incollection}, the \fieldname{type}
      field is put after the title, not after the book title.
      I may change this for music-types (CD, record, etc.),
      but this is currently not yet implemented. This means that the
      ``[CD]'' description must be put in the \fieldname{booktitle}
      field, after the CD title and with explicit formatting
      commands:
\begin{verbatim}
  booktitle = {Arkansas Traveler {\upshape[\uppercase{CD}]}},
\end{verbatim}
      On the other hand, we can now use the \fieldname{type}
      field to put the recording artists in for the second example:
\begin{verbatim}
  type = {Recorded by G. Bok, A. Mayo, \& E. Trickett},
\end{verbatim}
      We have to change the ``In'' string to ``On''
      (``In'' a book versus ``On'' a CD). This is done with a
      macro similar to the \cmd{\bibeditortype} macro discussed
      in ex.~36. In this case, the macro is \cmd{\bibInstring},
      defined in \fname{apacdoc.sty},
      which has one argument. The macro changes the definition of
      the macro \cmd{\BIn} to the argument and then immediately changes
      the definition back to the old definition. So it makes a one-time
      change. Of course, the \cmd{\bibInstring} macro only works
      if it is executed \emph{before} the \cmd{\BIn} macro. The latter
      macro comes before the \fieldname{booktitle}, so
      \cmd{\bibInstring} must be added to a field that comes before
      that. I put it in the \fieldname{title} field:
\begin{verbatim}
  title = {Over the Waterfall{\bibInstring{\BOn}}},
\end{verbatim}
      where \cmd{\BOn} is defined by default as ``\BOn''.
      Finally, the recording date of the second example (1990) must
      be put in the \fieldname{note} field.

      If you want an author index, you would want the authors of
      these works in the index as well. Because of the usage of the
      \fieldname{key} field, this is not automatically done for the
      citations. The \cmd{\AX} command has to be inserted explicitly,
      see section~\ref{sec:autindex} above.

      Note that this is all trickery within the \LaTeX{} domain
      and the \fname{.bib} file, i.e., the user-definable and
      user-customizable area.
\item \cite{ex70} \\ \cite{ex70}\\ \fullciteA{ex70}\\ \citeA{ex70}
\item \cite{ex71-1} \\ \cite{ex71-1}\\ \fullciteA{ex71-1}\\ \citeA{ex71-1} \\
      \cite{ex71-2} \\ \cite{ex71-2}\\ \fullciteA{ex71-2}\\ \citeA{ex71-2} \\
      \EM In contrast with earlier versions of \pkg{apacite}, in which
      the ``Retrieved \dots'' message had to be formatted in the
      \fieldname{howpublished} field, this is now formatted
      automatically by using the \fieldname{url} and
      \fieldname{lastchecked} fields.
\item \cite{ex72} \\ \cite{ex72}\\ \fullciteA{ex72}\\ \citeA{ex72}
\item \cite{ex73} \\ \cite{ex73}\\ \fullciteA{ex73}\\ \citeA{ex73} \\
      \EM Note that the APA manual breaks a line \emph{after} a
      period instead of before, against their own rules. Furthermore,
      the APA manual uses a typeface in which `1' (one) and `l' (ell)
      are not distinguishable. This requires some guessing of the
      correct URLs. I think that this conflicts with their own stress
      on accuracy w.r.t.\ URLs.

      \EM Note the subtle use of braces to get \emph{Homo sapiens}
      correctly formatted: The capital in \verb+\emph{Homo}+
      is retained by \BibTeX, whereas the capital in
      \verb+{\emph{Sapiens}}+ is changed into a lower case letter
      by \BibTeX, because of the extra pair of braces.
\item \cite{ex74} \\ \cite{ex74}\\ \fullciteA{ex74}\\ \citeA{ex74}
\item \cite{ex75} \\ \cite{ex75}\\ \fullciteA{ex75}\\ \citeA{ex75}\\
      \EM Note that \BibTeX{} does not consider a question mark
      or an exclamation point as the end of the title and the beginning
      of the subtitle. Hence, if there is a subtitle after it, the
      capitalization of its first word is not retained (unlike
      after a colon), so we have to protect it using braces in the
      \fname{.bib} file.
\item \cite{ex76} \\ \cite{ex76}\\ \fullciteA{ex76}\\ \citeA{ex76}
\item \cite{ex77} \\ \cite{ex77}\\ \fullciteA{ex77}\\ \citeA{ex77}
\item \cite{ex78} \\ \cite{ex78}\\ \fullciteA{ex78}\\ \citeA{ex78}\\
      \EM For this example, the source is not simply the URL, but
      with the qualification ``Columbia University, Institute for
      Learning Technologies Web site:''. This means that we cannot
      simply use the \fieldname{lastchecked} and \fieldname{url}
      fields, but must revert to the way I proposed to format
      references to electronic sources in previous versions of
      \pkg{apacite}: by putting all the information in a
      \fieldname{howpublished} field. This includes explicitly using
      the \cmd{\url} command and adding ``\verb+\bibnodot{.}+''
      immediately after the URL. The \cmd{\bibnodot} command,
      defined in \fname{apacdoc.sty}, swallows the period, so that
      there is no period after the URL in the reference list, thus
      complying with the APA rules. This also applies to examples
      79, 87, 91, and 95, and all the examples that do not list
      a specific URL, but only a description, like
      ``the PsycARTICLES database'' (ex.~88).
\item \cite{ex79} \\ \cite{ex79}\\ \fullciteA{ex79}\\ \citeA{ex79}
\item \cite{ex80} \\ \cite{ex80}\\ \fullciteA{ex80}\\ \citeA{ex80}
\item \cite{ex81} \\ \cite{ex81}\\ \fullciteA{ex81}\\ \citeA{ex81}
\item \cite{ex82} \\ \cite{ex82}\\ \fullciteA{ex82}\\ \citeA{ex82}\\
      \EM Here and in ex.~83, I used the \cmd{\BAbstractRetrieved}
      and \cmd{\BmakeAbstractRetrieved} commands defined in
      \fname{apacdoc.sty} to replace ``Retrieved'' by
      ``Abstract retrieved''.
\item \cite{ex83} \\ \cite{ex83}\\ \fullciteA{ex83}\\ \citeA{ex83} \\
\item \cite{ex84} \\ \cite{ex84}\\ \fullciteA{ex84}\\ \citeA{ex84}
\item \cite{ex85} \\ \cite{ex85}\\ \fullciteA{ex85}\\ \citeA{ex85} \\
      \EM When referring to a message to a newsgroup, internet forum, etc.,
      use the \entryname{misc} type. Then define
\begin{verbatim}
  type = {\bibmessage},
\end{verbatim}
      and use the \fieldname{number} field when relevant. The URL
      of the message is given in the \fieldname{url} field.  Then
      the entry is formatted
      correctly: If the message has a number, say 1, it reverts to
      ``\verb+[\bibmessage~1]+'', i.e., ``[Msg~1]'' with the default
      definition of \cmd{\bibmessage}. If there is no number, the
      type identifier is omitted (because it is mentioned as
      ``Message posted to [\dots]'' anyway). In both cases,
      the title is formatted as an article title, i.e., not
      italicized.
\item \cite{ex86} \\ \cite{ex86}\\ \fullciteA{ex86}\\ \citeA{ex86}
\item \cite{ex87} \\ \cite{ex87}\\ \fullciteA{ex87}\\ \citeA{ex87}
\item \cite{ex88} \\ \cite{ex88}\\ \fullciteA{ex88}\\ \citeA{ex88}
\item \cite{ex89} \\ \cite{ex89}\\ \fullciteA{ex89}\\ \citeA{ex89}
\item \cite{ex90} \\ \cite{ex90}\\ \fullciteA{ex90}\\ \citeA{ex90} \\
      \EM Here, ``de Ridder'' may well be a Dutch name. If the APA
      manual is serious about its rule to format names as they
      should according to the rule of the country of origin,
      this name should then be formatted as ``De Ridder''.
\item \cite{ex91} \\ \cite{ex91}\\ \fullciteA{ex91}\\ \citeA{ex91}
\item \cite{ex92} \\ \cite{ex92}\\ \fullciteA{ex92}\\ \citeA{ex92}\\
      \EM From ex.~94 below, I deduce that the version information
      should be treated as an edition and not as part of the title.
      Therefore, in this example and ex.~94, the version is formatted
      in the \fieldname{edition} field:
\begin{verbatim}
  edition = {Version~4.0\noedition\ignorespaces},
\end{verbatim}
      using the \cmd{\noedition} command from \fname{apacdoc.sty},
      which temporarily redefines \cmd{\BEd} to do nothing, and
      \cmd{\ignorespaces}, which eats up the space that is ordinarily
      present between the edition number and the ``ed.\hbox{}'' string.
\item \cite{ex93} \\ \cite{ex93}\\ \fullciteA{ex93}\\ \citeA{ex93}\\
      \EM To test the \entryname{manual} entry: \citeA{ex93-t1}.
\item \cite{ex94} \\ \cite{ex94}\\ \fullciteA{ex94}\\ \citeA{ex94}\\
      \EM The example in the APA manual does not list a date, not even
      a ``n.d.\hbox{}''. Given the logic of the APA manual, this seems
      an error to me, so I added a ``\cmd{\bibnodate}'' in the
      \fieldname{year} field, which becomes ``\bibnodate'' in the
      output. If it would really be the rule to omit the year, then
      it is not clear when a year must be omitted and when not, or
      replaced by ``n.d.\hbox{}''. Furthermore, formatting in both
      the \fname{.sty} file and the \fname{.bst} file would have to
      be adapted to anticipate a missing year. Currently, I assume
      that there should always be something that acts like a date
      (a year, an ``in press'', or a ``n.d.\hbox{}'').

      \EM See ex.~92 for the treatment of the version.
\item \cite{ex95} \\ \cite{ex95}\\ \fullciteA{ex95}\\ \citeA{ex95}\\
      \EM Note that here, unlike ex.~44 and ex.~91,
      ``U.S.'' is omitted before ``Department of Health and Human
      Services''.
\end{enumerate}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\StopEventually{%
\MakePercentComment
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Change History
\PrintChanges
%
% Redefine commands that should be different in the bibliography.
\APACmanBeforeBib
%
% Request apacite or apacitex bibliography style
% depending on whether an index option was requested or not.
\bibliographystyle{\APACbibstyle}%
% Include the bibliography
\bibliography{apa5ex}%
%
% Again redefine commands.
\APACmanBeforeIndex
%
% Include the author index if the index option is on.
\printindex[autx]
%
% Again redefine commands.
\APACmanAfterIndex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\PrintIndex
\MakePercentIgnore
}
%
\MakePercentIgnore
% \iffalse
%</dtx>
% \fi
%
% \clearpage
% \APACcodePageLayout
% \section{Implementation}
% The following sections describe the source code of the various
% constituent parts of \pkg{apacite}.
%
%
% \section{\LaTeX\ package (\fname{apacite.sty})}
% This is the \LaTeX\ package part of \pkg{apacite}. We start with some
% comments at the top of the package to recognize borrowed code.
%
%    \begin{macrocode}
%<*package>
%%
%% apacite.sty : citation and reference list according to APA manual
%% Written by Erik Meijer
%%
%% Contains code adapted from
%%   index.sty [1995/09/28 v4.1beta Improved index support (dmj)],
%%   hyperref.dtx [6.71, 2000/10/04],
%%   babel.def [2001/03/01, v3.7h],
%%   backref.dtx [1.20, 2002/06/09],
%%   ltbibl.dtx [2004/02/15 v1.1q LaTeX Kernel (Bibliography)],
%%   bibtopic.dtx [2002/08/22 v1.0k],
%%   multibib.dtx [2004/01/28 v1.3 Multiple bibliographies for one document.],
%%   multibbl.dtx [2004/07/27 v1.1],
%%   amsrefs.dtx [2004/06/30 v2.0]
%%   ltidxglo.dtx [1996/01/20 v1.1e LaTeX Kernel (Index and Glossary)]
%%   doc.dtx [2004/02/09 v2.1b Standard LaTeX documentation package (FMi)]
%% and code (used with permission) provided by:
%%   Stefan Bj\"ork.
%%
%    \end{macrocode}
%
% \subsection{Options}
%
% ^^A There does not appear to be a \cmd{\DescribeOption} command.
%
% \subsubsection{Backwards compatibility}
%
% \begin{macro}{\@year@}
% The \pkg{theapa} package used the \cmd{\BCAY} command where \pkg{newapa}
% used \cmd{\citeauthoryear} for the same purpose. Because the first version
% of \pkg{apacite} descended from \pkg{theapa}, it used \cmd{\BCAY} as well.
% However, \pkg{natbib} does not recognize \cmd{\BCAY}, but it does
% recognize \cmd{\citeauthoryear}. Therefore, since
% \APACversiondate{2003/09/05}, \pkg{apacite} uses \cmd{\citeauthoryear}.
% Unfortunately, the construction below can only be defined for one of them.
% Therefore, this is a backwards compatibility option.
%    \begin{macrocode}
\def\@year@\citeauthoryear#1#2#3{#3} % default
\DeclareOption{BCAY}{% compatibility with old .bbl files
   \def\@year@\BCAY#1#2#3{#3}%
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Citation}
%
% \begin{macro}{\if@APAC@classic@cite}
% \begin{macro}{\if@APAC@natbib@emu}
% \begin{macro}{\if@APAC@natbib@apa}
% \begin{macro}{\if@APAC@classic@or@emu}
% \begin{macro}{\if@APAC@any@natbib}
% \begin{macro}{\if@APAC@anycitation}
% Allow different sets of citation commands through different options,
% implemented through |\if| commands that enable and disable the relevant
% parts of the code. \pkgoption{apaciteclassic} is the default, but this
% may change in the future.
%    \begin{macrocode}
\newif\if@APAC@classic@cite
\newif\if@APAC@natbib@emu
\newif\if@APAC@natbib@apa
\newif\if@APAC@classic@or@emu
\newif\if@APAC@any@natbib
\newif\if@APAC@anycitation
\DeclareOption{apaciteclassic}{%
  \@APAC@classic@citetrue
  \@APAC@natbib@emufalse
  \@APAC@natbib@apafalse
  \@APAC@classic@or@emutrue
  \@APAC@any@natbibfalse
  \@APAC@anycitationtrue
}
\DeclareOption{natbibemu}{%
  \@APAC@classic@citefalse
  \@APAC@natbib@emutrue
  \@APAC@natbib@apafalse
  \@APAC@classic@or@emutrue
  \@APAC@any@natbibtrue
  \@APAC@anycitationtrue
}
\DeclareOption{natbibapa}{%
  \@APAC@classic@citefalse
  \@APAC@natbib@emufalse
  \@APAC@natbib@apatrue
  \@APAC@classic@or@emufalse
  \@APAC@any@natbibtrue
  \@APAC@anycitationtrue
}
\DeclareOption{nocitation}{%
  \@APAC@classic@citefalse
  \@APAC@natbib@emufalse
  \@APAC@natbib@apafalse
  \@APAC@classic@or@emufalse
  \@APAC@any@natbibfalse
  \@APAC@anycitationfalse
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% The \pkgoption{mask} option masks citations that are flagged as
% self-citations with the |\mask|-citation commands. The
% \pkgoption{unmask} option (default) ignores the masking.
%
%    \begin{macrocode}
\newif\if@APAC@mask
\DeclareOption{mask}{\@APAC@masktrue}
\DeclareOption{unmask}{\@APAC@maskfalse}
%    \end{macrocode}
%
% \subsubsection{Bibliography}
%
% Various options for changing the formatting of the reference list. Most of
%% ^^A \cmd{\if} somehow gives an error
% these are implemented through |\if| commands, deferring the actual
% implementation.
% \begin{macro}{\if@numberedbib}
% Should the bibliography section or chapter be numbered?
%    \begin{macrocode}
\newif\if@numberedbib
%    \end{macrocode}
% \end{macro}
% The bibliography is a section or chapter with a number (e.g.,
% section~6 or chapter~10). This does not work properly when the section or
% chapter is in the backmatter.
%    \begin{macrocode}
\DeclareOption{numberedbib}{\@numberedbibtrue}
%    \end{macrocode}
% The bibliography is a section or chapter without a number (i.e.,
% a section* or chapter*). This is the default.
%    \begin{macrocode}
\DeclareOption{unnumberedbib}{\@numberedbibfalse}
%    \end{macrocode}
% The next options determine whether the bibliography should be a section or
% a chapter.
% \begin{macro}{\if@sectionbib}
% With the \pkgoption{sectionbib} option, the bibliography is a section. This
% is typically used with the \pkg{chapterbib} package; then each chapter has a
% bibliography section. The \pkgoption{nosectionbib} option makes the
% bibliography a chapter (if chapters are defined). If none of these options
% are requested, \pkg{apacite} tries to guess the most logical choice. The
% bibliography is a section if chapters are not defined or if we are in the
% ``mainmatter'' of a document. Otherwise, i.e., in the ``backmatter'' of a
% document that has chapters, it is a chapter.
%    \begin{macrocode}
\DeclareOption{sectionbib}{%
  \@ifundefined{@sectionbibtrue}{\newif\if@sectionbib}{}%
  \@sectionbibtrue
}
\DeclareOption{nosectionbib}{%
  \@ifundefined{@sectionbibfalse}{\newif\if@sectionbib}{}%
  \@sectionbibfalse
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@tocbib}
% These options determine whether the bibliography should be in the table of
% contents.
%    \begin{macrocode}
\newif\if@tocbib
%    \end{macrocode}
% The bibliography in the table of contents, even if it's unnumbered. This is
% the default.
%    \begin{macrocode}
\DeclareOption{tocbib}{\@tocbibtrue}
%    \end{macrocode}
% The bibliography not in the table of contents if it's unnumbered. This is
% ignored if it's numbered.
%    \begin{macrocode}
\DeclareOption{notocbib}{\@tocbibfalse}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@bibnewpage}
% Start the bibliography on a new page? This is ignored if it's a chapter.
%    \begin{macrocode}
\DeclareOption{bibnewpage}{\def\@bibnewpage{\bibnewpage}}
\DeclareOption{nobibnewpage}{\let\@bibnewpage\relax}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@doi}
% Should DOI information be printed in the reference list?
%    \begin{macrocode}
\newif\if@doi
\DeclareOption{doi}{\@doitrue}
\DeclareOption{nodoi}{\@doifalse}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Author indexing}
%
% \begin{macro}{\if@APAC@index}
% No author index.
%% ^^A \cmd{\if} somehow gives an error
% The |\if| is necessary because packages can not be required here, so
% we must handle the consequences of the \pkgoption{index} and
% \pkgoption{noindex} options later.
%    \begin{macrocode}
\newif\if@APAC@index
\DeclareOption{noindex}{\@APAC@indexfalse}%
%    \end{macrocode}
% \end{macro}
%
% Request author index.
%    \begin{macrocode}
\DeclareOption{index}{\@APAC@indextrue}%
%    \end{macrocode}
%
% \begin{macro}{\if@APAC@include@corporate}
% Include corporate authors in index?
%% ^^A \cmd{\if} somehow gives an error
% Use an |\if| here, the real definitions are handled within the index
% options.
%    \begin{macrocode}
\newif\if@APAC@include@corporate
\DeclareOption{includecorporate}{\@APAC@include@corporatetrue}%
\DeclareOption{suppresscorporate}{\@APAC@include@corporatefalse}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@APAC@index@package}
% Use \pkg{index} package or standard \LaTeX\ index? Again, we only define the
% boolean.
%    \begin{macrocode}
\newif\if@APAC@index@package
\DeclareOption{indexpackage}{\@APAC@index@packagetrue}%
\DeclareOption{noindexpackage}{\@APAC@index@packagefalse}%
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{index}
% Some options for changing the \envirname{index} environment. The actual
% definitions are done through macros below; here these macros are used.
%
% The first option uses the definition from the \pkg{index} package
% |[1995/09/28 v4.1beta Improved index support (dmj)]|,
% which is the same code as in |(v3.02, 15 September 1993)|,
% i.e., without table of contents entry.
%    \begin{macrocode}
\DeclareOption{stdindex}{%
  \ExecuteOptions{index}%         Request author index
  \ExecuteOptions{indexpackage}%  This option requires the index package
  \AtEndOfPackage{\APACstdindex}% index environment as in index package
}%
%    \end{macrocode}
% The next option adds a table of contents entry to the standard index.
%    \begin{macrocode}
\DeclareOption{tocindex}{%
  \ExecuteOptions{index}%         Request author index
  \ExecuteOptions{indexpackage}%  This option requires the index package
  \AtEndOfPackage{\APACtocindex}% index environment as in index package
                               %% with toc entry added
}%
%    \end{macrocode}
% This option defines my (EM) own favorite index style. Maybe you like it too.
%    \begin{macrocode}
\DeclareOption{emindex}{%
  \ExecuteOptions{index}%         Request author index
  \ExecuteOptions{indexpackage}%  This option requires the index package
  \AtEndOfPackage{\APACemindex}%  EM's index environment (see below)
}%
%    \end{macrocode}
% The next option is a variation on the \pkgoption{emindex} option, but uses
% standard \LaTeX\ code (adapted from the \pkg{ltxdoc} class) instead of the
% the \pkg{index} package to support multiple indexes.
%    \begin{macrocode}
\DeclareOption{ltxemindex}{%
  \ExecuteOptions{index}%           Request author index
  \ExecuteOptions{noindexpackage}%  Don't use the index package
  \AtEndOfPackage{\APACltxemindex}% EM's index environment without the index
                                 %% package (see below)
}
%    \end{macrocode}
% \end{environment}
%
% \subsubsection{Obsolete compatibility options}
%
% For compatibility with older versions of \pkg{apacite}.
%    \begin{macrocode}
\DeclareOption{hyper}{%
  \PackageWarningNoLine{apacite}{Obsolete option `hyper' ignored}%
}
\DeclareOption{nohyper}{%
  \PackageWarningNoLine{apacite}{Obsolete option `nohyper' ignored}%
}
\DeclareOption{accentfix}{%
  \PackageWarningNoLine{apacite}{Obsolete option `accentfix' ignored}%
}
\DeclareOption{noaccentfix}{%
  \PackageWarningNoLine{apacite}{Obsolete option `noaccentfix' ignored}%
}
%    \end{macrocode}
%
% \subsection{Option processing}
%
% Execute default options.
%    \begin{macrocode}
\ExecuteOptions{apaciteclassic,noindex,indexpackage,unnumberedbib,tocbib,%
                nobibnewpage,suppresscorporate,doi,unmask}
%    \end{macrocode}
% Execute user-requested options.
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}
%
% \subsection{Citation commands}
%
% \begin{macro}{\citeauthoryear}
% The \cmd{\citeauthoryear} command is defined within the citation commands,
% but some packages (\pkg{splitbib}, \pkg{bibentry}) choke if it has not
% been defined. Therefore, we start with defining it to do nothing. However,
% \pkg{natbib} defines this with a \cmd{\newcommand}, so if \pkg{natbib} is
% loaded after \pkg{apacite}, defining it here would give an error. Therefore,
% we postpone this to |\begin{document}| and only initialize it then if it
% hasn't been defined before.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifundefined{citeauthoryear}{\def\citeauthoryear#1#2#3{}}{}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\themaskedRefs}
% A counter for the number of masked citations, which should be
% defined for all the citation options.
% This construction ensures that there is no conflict if the
% |maskedRefs| counter has already been defined (in \fname{apa6.cls}).
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifundefined{themaskedRefs}{\newcounter{maskedRefs}}{}}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Shared code between the \pkgoption{apaciteclassic} and
% \pkgoption{natbibemu} options}
%
% Define a few |\if|s outside the main |\if|, because \TeX{} otherwise
% chokes.
% \begin{macro}{\if@F@cite}
% First citation in a multi-citation.
%    \begin{macrocode}
\newif\if@F@cite\@F@citetrue
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@A@cite}
% \begin{macro}{\if@Y@cite}
% Two flags to denote whether only the author or only the year must be cited
% or both.
%    \begin{macrocode}
\newif\if@A@cite\@A@citefalse
\newif\if@Y@cite\@Y@citefalse
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
\if@APAC@classic@or@emu
%    \end{macrocode}
%
% \begin{macro}{\nocite}
% This induces an entry in the reference list, but not in the text. It is
% also called by the other citation commands to handle some bookkeeping.
%    \begin{macrocode}
\def\nocite#1{%
%    \end{macrocode}
% No flag-setting in \cmd{\nocite}: a no-cite is not a citation, so a
% subsequent citation may be the first one.
%    \begin{macrocode}
  \@bsphack
  \ifx\@onlypreamble\document
%    \end{macrocode}
%   We are after |\begin{document}|, so we can do the citations.
%    \begin{macrocode}
    \@for\@citeb:=#1\do{%
      \edef\@citeb{\expandafter\@firstofone\@citeb}%
%    \end{macrocode}
%     The \cmd{\@newciteauxhandle} is for compatibility with \pkg{multibib}.
%    \begin{macrocode}
      \if@filesw
        \immediate\write\@newciteauxhandle{\string\citation{\@citeb}}%
      \fi
      \@ifundefined{b@\@citeb\APAC@extra@b@citeb}{%
%    \end{macrocode}
%       Check for |\nocite{*}|.
%    \begin{macrocode}
        \edef\B@my@dummy{*}%
        \ifx\@citeb\B@my@dummy
        \else
          \G@refundefinedtrue
          \@latex@warning{Citation `\@citeb' undefined}%
        \fi
      }{}%
    }%
  \else
%    \end{macrocode}
%    \pkg{apacite} has no compatibility problems with \LaTeX~2.09, because it
%    does not work with \LaTeX~2.09 anyway, so we can do the following,
%    suggested in \fname{ltbibl.dtx}:
%    \begin{macrocode}
     \AtBeginDocument{\nocite{#1}}%
  \fi
  \@esphack
%    \end{macrocode}
% For compatibility with \pkg{multibib}.
%    \begin{macrocode}
  \@restore@auxhandle
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\B@my@dummy}
% This needs to be initialized to avoid errors with \pkg{tex4ht}.
%    \begin{macrocode}
\global\def\B@my@dummy{*}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ifauthorsequalc@de}
% Code to be executed if current author(s) equal(s) previous.
%    \begin{macrocode}
\def\@ifauthorsequalc@de#1{%
  \if@F@cite
     \@F@citefalse
  \else
     \if@Y@cite
        {\@BBY}%
     \fi
  \fi
  \if@Y@cite
     \hyper@natlinkstart{#1}%
     {\csname Y@\@citeb\APAC@extra@b@citeb\endcsname}%
     \hyper@natlinkend
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ifauthorsunequalc@de}
% Code to be executed if current author(s) do(es) not equal previous.
%    \begin{macrocode}
\def\@ifauthorsunequalc@de#1{%
  \if@F@cite
     \@F@citefalse
  \else
     \if@Y@cite
        {\@BAY}%
     \fi
     {\@BBC}%
  \fi
  \edef\@cite@undefined{?}%
  \def\BBA{\@BBA}%
  \if@A@cite
     \hyper@natlinkstart{#1}%
     {\csname b@\@citeb\APAC@extra@b@citeb\endcsname}%
     \hyper@natlinkend
     \if@Y@cite
        {\@BBAY}%
     \fi
  \fi
  \if@Y@cite
     \hyper@natlinkstart{#1}%
     {\csname Y@\@citeb\APAC@extra@b@citeb\endcsname}%
     \hyper@natlinkend
  \fi
  \let\BBA\relax
}
%    \end{macrocode}
% \end{macro}
%
% End of shared code.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
% \subsubsection{\pkg{apacite} ``classic'' commands}
%
% This defines the citation commands and syntax with angled brackets that
% have traditionally been used by \pkg{apacite}.
%    \begin{macrocode}
\if@APAC@classic@cite
%    \end{macrocode}
%
% \begin{macro}{\cite}
% \begin{macro}{\fullcite}
% \begin{macro}{\shortcite}
% Parenthetical citation commands.
%    \begin{macrocode}
\def\cite{%
    \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    \def\@BBOP{\BBOP}% % open parenthesis
    \def\@BBCP{\BBCP}% % close parenthesis
    \@ifnextchar<%     % >
        {\@cite}%
        {\@cite<>}%
}
\def\fullcite{%
    \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    \def\@BBOP{\BBOP}% % open parenthesis
    \def\@BBCP{\BBCP}% % close parenthesis
    \@ifnextchar<%     % >
        {\@cite}%
        {\@cite<>}%
}
\def\shortcite{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \def\@BBOP{\BBOP}% % open parenthesis
    \def\@BBCP{\BBCP}% % close parenthesis
    \@ifnextchar<%     % >
        {\@cite}%
        {\@cite<>}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\citeNP}
% \begin{macro}{\fullciteNP}
% \begin{macro}{\shortciteNP}
% Parenthetical citation commands, but without the actual parentheses.
%    \begin{macrocode}
\def\citeNP{%
    \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    \def\@BBOP{}% % open parenthesis
    \def\@BBCP{}% % close parenthesis
    \@ifnextchar<%% >
        {\@cite}%
        {\@cite<>}%
}
\def\fullciteNP{%
    \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    \def\@BBOP{}% % open parenthesis
    \def\@BBCP{}% % close parenthesis
    \@ifnextchar<%% >
        {\@cite}%
        {\@cite<>}%
}
\def\shortciteNP{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \def\@BBOP{}% % open parenthesis
    \def\@BBCP{}% % close parenthesis
    \@ifnextchar<%% >
        {\@cite}%
        {\@cite<>}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@cite}
% Second layer of the parenthetical and NP citation commands.
%    \begin{macrocode}
\def\@cite<#1>{%
    \def\@BAP{\BAP}%   % after precitation [=#1] before first citation
    \def\@BBA{\BBAA}%  % `and' between authors
    \def\@BBAY{\BBAY}% % between author and year
    \def\@BAY{}%       % after year
    \def\@BBY{\BBYY}%  % between years of multiple citations with same author
    \def\@BBC{\BBC}%   % between cites
    \def\@BBN{\BBN}%   % after last citation before note/postcitation [=#2]
    \def\@BAstyle{\BAstyle}% text style of authors
    \@A@citetrue%       % cite authors
    \@Y@citetrue%       % cite years
    \@ifnextchar[%      % ]
        {\@@cite<#1>}%
        {\@@cite<#1>[]}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\citeA}
% \begin{macro}{\fullciteA}
% \begin{macro}{\shortciteA}
% In-text citation commands.
%    \begin{macrocode}
\def\citeA{%
    \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    \@ifnextchar<%          %>
        {\@citeA}%
        {\@citeA<>}%
}
\def\fullciteA{%
    \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    \@ifnextchar<%          %>
        {\@citeA}%
        {\@citeA<>}%
}
\def\shortciteA{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \@ifnextchar<%          %>
        {\@citeA}%
        {\@citeA<>}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@citeA}
% Second layer of in-text citation commands.
%    \begin{macrocode}
\def\@citeA<#1>{%
    \def\@BBOP{}%      % open parenthesis.
    \def\@BAP{\BAP}%   % after precitation [=#1] before first citation
    \def\@BBA{\BBAB}%  % `and' between authors
    \def\@BBAY{ \BBOP}%% between author and year
    \def\@BAY{\BBCP}%  % after year
    \def\@BBY{\BBYY}%  % between years of multiple citations with same author
    \def\@BBC{\BBC}%   % between cites
    \def\@BBN{\BBN}%   % after last citation before note/postcitation [=#2]
    \def\@BBCP{}%      % close parenthesis
    \def\@BAstyle{\BAstyle}% text style of authors
    \@A@citetrue%      % cite authors
    \@Y@citetrue%      % cite years
    \@ifnextchar[%     % ]
        {\@@cite<#1>}%
        {\@@cite<#1>[]}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\citeauthor}
% \begin{macro}{\fullciteauthor}
% \begin{macro}{\shortciteauthor}
% \begin{macro}{\citeauthorNP}
% \begin{macro}{\fullciteauthorNP}
% \begin{macro}{\shortciteauthorNP}
% Commands that only cite the author, for parenthetical and in-text citations,
% the difference being that `\&' is used in the parenthetical versions,
% whereas the in-text versions use `and' between the authors. Note that all
% are without parentheses; \cmd{\citeauthorA} would be a better name for
% \cmd{\citeauthor} to clarify its role (cf.~\cmd{\citeA}, \cmd{\cite}, and
% \cmd{\citeNP}), but for backwards compatibility and compatibility with
% some other citation packages, it is \cmd{\citeauthor}.
%    \begin{macrocode}
\def\citeauthor{%
    \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    \@ifnextchar<%    %>
        {\@citeauthor}%
        {\@citeauthor<>}%
}
\def\fullciteauthor{%
    \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    \@ifnextchar<%    %>
        {\@citeauthor}%
        {\@citeauthor<>}%
}
\def\shortciteauthor{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \@ifnextchar<%    %>
        {\@citeauthor}%
        {\@citeauthor<>}%
}
\def\citeauthorNP{%
    \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    \@ifnextchar<%    %>
        {\@citeauthorNP}%
        {\@citeauthorNP<>}%
}
\def\fullciteauthorA{%
    \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    \@ifnextchar<%    %>
        {\@citeauthorNP}%
        {\@citeauthorNP<>}%
}
\def\shortciteauthorA{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \@ifnextchar<%    %>
        {\@citeauthorNP}%
        {\@citeauthorNP<>}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@citeauthor}
% \begin{macro}{\@citeauthorNP}
% Second layer of the author citation commands.
%    \begin{macrocode}
\def\@citeauthor<#1>{%
    \def\@BBOP{}%      % open parenthesis
    \def\@BAP{\BAP}%   % after precitation [=#1] before first citation
    \def\@BBA{\BBAB}%  % `and' between authors
    \def\@BBAY{}%      % between author and year
    \def\@BAY{}%       % after year
    \def\@BBY{}%       % between years of multiple citations with same author
    \def\@BBC{\BBC}%   % between cites
    \def\@BBN{\BBN}%   % after last citation before note/postcitation [=#2]
    \def\@BBCP{}%      % close parenthesis
    \def\@BAstyle{\BAastyle}% text style of authors
    \@A@citetrue%      % cite authors
    \@Y@citefalse%     % do not cite years
    \@ifnextchar[%     % ]
        {\@@cite<#1>}%
        {\@@cite<#1>[]}%
}
\def\@citeauthorNP<#1>{%
    \def\@BBOP{}%      % open parenthesis
    \def\@BAP{\BAP}%   % after precitation [=#1] before first citation
    \def\@BBA{\BBAA}%  % `and' between authors
    \def\@BBAY{}%      % between author and year
    \def\@BAY{}%       % after year
    \def\@BBY{}%       % between years of multiple citations with same author
    \def\@BBC{\BBC}%   % between cites
    \def\@BBN{\BBN}%   % after last citation before note/postcitation [=#2]
    \def\@BBCP{}%      % close parenthesis
    \def\@BAstyle{\BAastyle}% text style of authors
    \@A@citetrue%      % cite authors
    \@Y@citefalse%     % do not cite years
    \@ifnextchar[%     % ]
        {\@@cite<#1>}%
        {\@@cite<#1>[]}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\citeyear}
% \begin{macro}{\citeyearNP}
% Cite only the year; parenthetical and without parentheses.
%    \begin{macrocode}
\def\citeyear{%
    \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    \def\@BBOP{\BBOP}% % open parenthesis
    \def\@BBCP{\BBCP}% % close parenthesis
    \@ifnextchar<%     % >
        {\@citeyear}%
        {\@citeyear<>}%
}
\def\citeyearNP{%
    \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    \def\@BBOP{}%   % open parenthesis
    \def\@BBCP{}%   % close parenthesis
    \@ifnextchar<%  % >
        {\@citeyear}%
        {\@citeyear<>}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@citeyear}
% Second layer of the year citation commands.
%    \begin{macrocode}
\def\@citeyear<#1>{%
    \def\@BAP{\BAP}%   % after precitation [=#1] before first citation
    \def\@BBA{}%       % `and' between authors
    \def\@BBAY{}%      % between author and year
    \def\@BAY{}%       % after year
    \def\@BBY{\BBYY}%  % between years of multiple citations with same author
    \def\@BBC{\BBC}%   % between cites
    \def\@BBN{\BBN}%   % after last citation before note/postcitation [=#2]
    \def\@BAstyle{}%   % text style of authors
    \@A@citefalse%     % do not cite authors
    \@Y@citetrue%      % cite years
    \@ifnextchar[%     % ]
        {\@@cite<#1>}%
        {\@@cite<#1>[]}%
}
%    \end{macrocode}
% \end{macro}
%
% We are now arriving at the core citation routines. The following commands
% must have been defined:\\
% \begin{tabular}{@{\qquad}ll@{}}
% \cmd{\@BBOP}    & open parenthesis                                     \\
% \cmd{\@BAP}     & after precitation before first citation              \\
% \cmd{\@BBA}     & `and' between authors                                \\
% \cmd{\@BBAY}    & between author and year                              \\
% \cmd{\@BAY}     & after year                                           \\
% \cmd{\@BBY}     & between years of multiple citations with same author \\
% \cmd{\@BBC}     & between cites                                        \\
% \cmd{\@BBN}     & after last citation before note/postcitation         \\
% \cmd{\@BBCP}    & close parenthesis                                    \\
% \cmd{\@BAstyle} & formatting style of authors (e.g., \cmd{\scshape})
% \end{tabular}
%
% \begin{macro}{\@@cite}
% The core citation command. Standard \LaTeX{} and other packages use
% \cmd{\@citex} for this. It may be useful to change this as well, to increase
% the likelihood of compatibility with some packages.
%    \begin{macrocode}
\def\@@cite<#1>[#2]#3{%
%    \end{macrocode}
%   Write citation(s) to .aux file(s)
%    \begin{macrocode}
    \nocite{#3}%
%    \end{macrocode}
%   The previous cite, for multiple citations with same author.
%    \begin{macrocode}
    \edef\@citeP{}%
%    \end{macrocode}
%   Open parenthesis and pre-note. The \cmd{\mbox} is to avoid \pkg{hyperref}
%   problems if a \cmd{\citeA} follows an \cmd{\item}.
%    \begin{macrocode}
    \mbox{\@BBOP}%
    \ifx\@empty#1\@empty
    \else%
      {\ignorespaces #1\@BAP}%
    \fi%
%    \end{macrocode}
%   Loop over citation entries
%    \begin{macrocode}
    \@for\@citeb:=#3\do{%
%    \end{macrocode}
%       Removes a possible space before the citation key, so that, e.g.,
%       \verb*+\cite{key1, key2}+ can be done.
%    \begin{macrocode}
        \edef\@citeb{\expandafter\@firstofone\@citeb}%
%    \end{macrocode}
%       For \pkg{backref}.
%    \begin{macrocode}
        \back@cite{\@citeb}%
%    \end{macrocode}
%       Check whether the citation is defined.
%    \begin{macrocode}
        \@ifundefined{b@\@citeb\APAC@extra@b@citeb}%
          {\expandafter\def\csname b@\@citeb\APAC@extra@b@citeb\endcsname{?}%
           \expandafter\def\csname Y@\@citeb\APAC@extra@b@citeb\endcsname{?}%
           %% The following is now handled by \nocite
           %% \G@refundefinedtrue
           %% \@latex@warning{Citation `\@citeb' undefined}%
          }%%
%    \end{macrocode}
%       If the citation is defined, check whether the flag has been set that
%       identifies that this is not the first citation to the work. If this
%       flag has not been set, it will be set to |DUMMY|. If this is the first
%       citation to the work, the full citation is used; else the short version
%       is used.
%    \begin{macrocode}
          {\@ifundefined{flag@\@citeb\APAC@extra@b@citeb}%
             {\global\expandafter
              \def\csname flag@\@citeb\APAC@extra@b@citeb\endcsname{DUMMY}%
              \def\BCA##1##2{{\@BAstyle ##1}}%
             }%
             {\def\BCA##1##2{{\@BAstyle ##2}}%
             }%
          }%
%    \end{macrocode}
%       Check whether the current author(s) is (are) equivalent to the
%       previous. If so, only the year is cited in the text and a \cmd{\@BBY}
%       (probably comma and space) is inserted between the two years. The
%       \cmd{\protected@edef} fixes the problem with authors with accents
%       (e.g., J{\"{o}}reskog). Older versions of \pkg{apacite} solved this
%       less elegantly (\pkgoption{accentfix} option). This fix was provided by
%       Robert Schlicht. See also the new definition of \cmd{\@citeP} below.
%    \begin{macrocode}
        \protected@edef\B@my@dummy{\csname
                                   b@\@citeb\APAC@extra@b@citeb\endcsname}%
        \ifx\@citeP\B@my@dummy
            \@ifauthorsequalc@de{\@citeb\APAC@extra@b@citeb}%
        \else
            \@ifauthorsunequalc@de{\@citeb\APAC@extra@b@citeb}%
        \fi
%    \end{macrocode}
%       Store the current author(s) for comparison in the next citation (if
%       any).
%    \begin{macrocode}
        \protected@edef\@citeP{\csname b@\@citeb\APAC@extra@b@citeb\endcsname}%
        \let\BCA\relax
    }%%
%    \end{macrocode}
%   End of the loop over citation entries. Add the post-note and closing
%   parenthesis.
%    \begin{macrocode}
    \ifx\@empty#2\@empty
    \else%
      {\@BBN #2}%
    \fi%
    \if@Y@cite%
       {\@BAY}%
    \fi%
    {\@BBCP}%
%    \end{macrocode}
%   We're finished with this citation command. Initialize for the next
%   \cmd{\@@cite} call.
%    \begin{macrocode}
    \@F@citetrue %
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\maskcitations}
% \begin{macro}{\unmaskcitations}
% \begin{macro}{\masknocite}
% \begin{macro}{\maskcite}
% \begin{macro}{\maskfullcite}
% \begin{macro}{\maskshortcite}
% \begin{macro}{\maskciteNP}
% \begin{macro}{\maskfullciteNP}
% \begin{macro}{\maskshortciteNP}
% \begin{macro}{\maskciteA}
% \begin{macro}{\maskfullciteA}
% \begin{macro}{\maskshortciteA}
% \begin{macro}{\maskciteauthor}
% \begin{macro}{\maskfullciteauthor}
% \begin{macro}{\maskshortciteauthor}
% \begin{macro}{\maskciteauthorNP}
% \begin{macro}{\maskfullciteauthorNP}
% \begin{macro}{\maskshortciteauthorNP}
% \begin{macro}{\maskciteyear}
% \begin{macro}{\maskciteyearNP}
% \begin{macro}{\masktext}
% These commands allow masking of (self-)citations  for a masked
% review.
% The \cmd{maskcitations} command defines the masked citation commands;
% \cmd{unmaskcitations} does the same, but lets them be equal to the
% non-mask versions. The advantage of putting these definitions within
% a command is that we can switch between masked and unmasked within
% the same document. This is not likely to be used very often in
% practice, but is useful for writing tutorials.
%    \begin{macrocode}
\newcommand{\maskcitations}{%
    \def\masknocite##1{}%
    \def\maskcite{%
        \@ifnextchar<%     % >
            {\mask@cite}%
            {\mask@cite<>}%
    }%
    \def\mask@cite<##1>{%
        \@ifnextchar[%      % ]
            {\mask@@cite<##1>}%
            {\mask@@cite<##1>[]}%
    }%
    \def\mask@@cite<##1>[##2]##3{%
        \relax
%    \end{macrocode}
% Count number of masked references.
%    \begin{macrocode}
        \setcounter{maskedRefs}{0}%
        \@for\@citeb:=##3\do{%
            \addtocounter{maskedRefs}{1}%
        }%
        \ifnum\value{maskedRefs} = 1%
            \onemaskedcitationmsg{\themaskedRefs}%
        \else
            \maskedcitationsmsg{\themaskedRefs}%
        \fi
    }%
%    \end{macrocode}
% Let all other citation commands be identical to \cmd{\maskcite}.
% We could try to do fancy things with parentheses, but it's unlikely
% we will be able to cover all cases of interest, and users can easily
% change their document if they don't like how this comes out.
%    \begin{macrocode}
    \let\maskfullcite\maskcite
    \let\maskshortcite\maskcite
    \let\maskciteNP\maskcite
    \let\maskfullciteNP\maskciteNP
    \let\maskshortciteNP\maskciteNP
    \let\maskciteA\maskcite
    \let\maskfullciteA\maskciteA
    \let\maskshortciteA\maskciteA
    \let\maskciteauthor\maskcite
    \let\maskfullciteauthor\maskciteauthor
    \let\maskshortciteauthor\maskciteauthor
    \let\maskciteauthorNP\maskciteauthor
    \let\maskfullciteauthorNP\maskciteauthorNP
    \let\maskshortciteauthorNP\maskciteauthorNP
    \let\maskciteyear\maskcite
    \let\maskciteyearNP\maskciteyear
%    \end{macrocode}
% A user command to flexibly mask or unmask certain pieces of text.
% An environment is technically more stable than a command, but less
% intuitive for users. Under masking, this command prints the optional
% alternative text |#1|, which defaults to nothing.
%    \begin{macrocode}
    \DeclareRobustCommand{\masktext}[2][]{##1}%
}
%    \end{macrocode}
%
% The ``mask'' citation commands revert to the same commands without
% ``mask'' if the \pkgoption{mask} option is not set.
%    \begin{macrocode}
\newcommand{\unmaskcitations}{%
    \let\masknocite\nocite
    \let\maskcite\cite
    \let\maskfullcite\fullcite
    \let\maskshortcite\shortcite
    \let\maskciteNP\citeNP
    \let\maskfullciteNP\fullciteNP
    \let\maskshortciteNP\shortciteNP
    \let\maskciteA\citeA
    \let\maskfullciteA\fullciteA
    \let\maskshortciteA\shortciteA
    \let\maskciteauthor\citeauthor
    \let\maskfullciteauthor\fullciteauthor
    \let\maskshortciteauthor\shortciteauthor
    \let\maskciteauthorNP\citeauthorNP
    \let\maskfullciteauthorNP\fullciteauthorNP
    \let\maskshortciteauthorNP\shortciteauthorNP
    \let\maskciteyear\citeyear
    \let\maskciteyearNP\citeyearNP
%    \end{macrocode}
% Unmasked, this command prints the mandatory second argument |#2|.
%    \begin{macrocode}
    \DeclareRobustCommand{\masktext}[2][]{##2}
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% End of ``classic'' citation commands.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
% \subsubsection{Emulation of \pkg{natbib} citation commands}
%
% If requested, this section defines the \pkg{natbib} citation commands,
% using the same syntax, without actually loading \pkg{natbib}. We also
% define a few additional commands that \pkg{natbib} did not implement,
% but that fit the scheme and serve some useful purpose for APA style
% citation.
%
% |\if@APAC@alias@cite| needs to be defined outside the
% |\if@APAC@natbib@emu| because otherwise \TeX{} does not process the
% nested |\if|'s below correctly.
%    \begin{macrocode}
\newif\if@APAC@alias@cite
\@APAC@alias@citefalse
\if@APAC@natbib@emu
%    \end{macrocode}
%
% \begin{macro}{\citep}
% \begin{macro}{\shortcitep}
% Parenthetical citation commands.
%    \begin{macrocode}
\DeclareRobustCommand\citep{%
    \@ifstar{% full cite
        \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    }{% else
        \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    }%
    \def\@BBOP{\BBOP}% % open parenthesis
    \def\@BBCP{\BBCP}% % close parenthesis
    \@ifnextchar[%     % ]
        {\APACNAT@citep}%
        {\APACNAT@citep[]}%
}
\DeclareRobustCommand\shortcitep{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \def\@BBOP{\BBOP}% % open parenthesis
    \def\@BBCP{\BBCP}% % close parenthesis
    \@ifnextchar[%     % ]
        {\APACNAT@citep}%
        {\APACNAT@citep[]}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\citealp}
% \begin{macro}{\shortcitealp}
% Parenthetical citation commands, but without the actual parentheses.
%    \begin{macrocode}
\DeclareRobustCommand\citealp{%
    \@ifstar{% full cite
        \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    }{% else
        \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    }%
    \def\@BBOP{}% % open parenthesis
    \def\@BBCP{}% % close parenthesis
    \@ifnextchar[%% ]
        {\APACNAT@citep}%
        {\APACNAT@citep[]}%
}
\DeclareRobustCommand\shortcitealp{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \def\@BBOP{}% % open parenthesis
    \def\@BBCP{}% % close parenthesis
    \@ifnextchar[%% ]
        {\APACNAT@citep}%
        {\APACNAT@citep[]}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACNAT@citep}
% Second layer of the parenthetical and alp citation commands.
%    \begin{macrocode}
\newcommand\APACNAT@citep{}
\def\APACNAT@citep[#1]{%
    \def\@BAP{\BAP}%   % after precitation [=#1] before first citation
    \def\@BBA{\BBAA}%  % `and' between authors
    \def\@BBAY{\BBAY}% % between author and year
    \def\@BAY{}%       % after year
    \def\@BBY{\BBYY}%  % between years of multiple citations with same author
    \def\@BBC{\BBC}%   % between cites
    \def\@BBN{\BBN}%   % after last citation before note/postcitation [=#2]
    \def\@BAstyle{\BAstyle}% text style of authors
    \@A@citetrue%       % cite authors
    \@Y@citetrue%       % cite years
    \@ifnextchar[%      % ]
        {\@citex[#1]}%
        {\@citex[][#1]}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\citet}
% \begin{macro}{\shortcitet}
% In-text citation commands.
%    \begin{macrocode}
\DeclareRobustCommand\citet{%
    \@ifstar{%
        \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    }{% else
        \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    }%
    \def\@BBAY{ \BBOP}%% between author and year
    \@ifnextchar[%          %]
        {\APACNAT@citet}%
        {\APACNAT@citet[]}%
}
\DeclareRobustCommand\shortcitet{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \def\@BBAY{ \BBOP}%% between author and year
    \@ifnextchar[%          %]
        {\APACNAT@citet}%
        {\APACNAT@citet[]}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\citealt}
% \begin{macro}{\shortcitealt}
% Text citation commands, but without the actual parentheses. Not sure when
% this would be useful, but \pkg{natbib} defines them.
%    \begin{macrocode}
\DeclareRobustCommand\citealt{%
    \@ifstar{% full cite
        \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    }{% else
        \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    }%
    \def\@BBOP{}% % open parenthesis
    \def\@BBCP{}% % close parenthesis
    \def\@BBAY{ }%% between author and year
    \@ifnextchar[%% ]
        {\APACNAT@citet}%
        {\APACNAT@citet[]}%
}
\DeclareRobustCommand\shortcitealt{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \def\@BBOP{}% % open parenthesis
    \def\@BBCP{}% % close parenthesis
    \def\@BBAY{ }%% between author and year
    \@ifnextchar[%% ]
        {\APACNAT@citet}%
        {\APACNAT@citet[]}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACNAT@citet}
% Second layer of in-text and alt citation commands.
%    \begin{macrocode}
\newcommand\APACNAT@citet{}
\def\APACNAT@citet[#1]{%
    \def\@BBOP{}%       % open parenthesis.
    \def\@BAP{\BAP}%    % after precitation [=#1] before first citation
    \def\@BBA{\BBAB}%   % `and' between authors
%%   \def\@BBAY{ \BBOP}%% between author and year
    \def\@BAY{\BBCP}%   % after year
    \def\@BBY{\BBYY}%   % between years of multiple citations with same author
    \def\@BBC{\BBC}%    % between cites
    \def\@BBN{\BBN}%    % after last citation before note/postcitation [=#2]
    \def\@BBCP{}%       % close parenthesis
    \def\@BAstyle{\BAstyle}% text style of authors
    \@A@citetrue%       % cite authors
    \@Y@citetrue%       % cite years
    \@ifnextchar[%      % ]
        {\@citex[#1]}%
        {\@citex[][#1]}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\citeauthort}
% \begin{macro}{\shortciteauthort}
% \begin{macro}{\citeauthorp}
% \begin{macro}{\shortciteauthorp}
% \begin{macro}{\citeauthor}
% \begin{macro}{\citefullauthor}
% \begin{macro}{\shortciteauthor}
% Commands that only cite the author, for parenthetical and in-text citations,
% the difference being that `\&' is used in the parenthetical versions,
% whereas the in-text versions use `and' between the authors. Note that all
% are without parentheses.
%    \begin{macrocode}
\DeclareRobustCommand\citeauthort{%
    \@ifstar{%
        \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    }{% else
        \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    }%
    \@ifnextchar[%    %]
        {\APACNAT@citeauthort}%
        {\APACNAT@citeauthort[]}%
}
\DeclareRobustCommand\shortciteauthort{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \@ifnextchar[%    %]
        {\APACNAT@citeauthort}%
        {\APACNAT@citeauthort[]}%
}
\DeclareRobustCommand\citeauthorp{%
    \@ifstar{%
        \def\BCAY##1##2##3{\BCA{##1}{##1}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##1}}%
    }{% else
        \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
        \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    }%
    \@ifnextchar[%    %]
        {\APACNAT@citeauthorp}%
        {\APACNAT@citeauthorp[]}%
}
\DeclareRobustCommand\shortciteauthorp{%
    \def\BCAY##1##2##3{\BCA{##2}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##2}{##2}}%
    \@ifnextchar[%    %]
        {\APACNAT@citeauthorp}%
        {\APACNAT@citeauthorp[]}%
}
\DeclareRobustCommand\citeauthor{\citeauthort}
\DeclareRobustCommand\citefullauthor{\citeauthort*}
\DeclareRobustCommand\shortciteauthor{\shortciteauthort}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACNAT@citeauthort}
% \begin{macro}{\APACNAT@citeauthorp}
% Second layer of the author citation commands.
%    \begin{macrocode}
\newcommand\APACNAT@citeauthort{}
\def\APACNAT@citeauthort[#1]{%
    \def\@BBOP{}%      % open parenthesis
    \def\@BAP{\BAP}%   % after precitation [=#1] before first citation
    \def\@BBA{\BBAB}%  % `and' between authors
    \def\@BBAY{}%      % between author and year
    \def\@BAY{}%       % after year
    \def\@BBY{}%       % between years of multiple citations with same author
    \def\@BBC{\BBC}%   % between cites
    \def\@BBN{\BBN}%   % after last citation before note/postcitation [=#2]
    \def\@BBCP{}%      % close parenthesis
    \def\@BAstyle{\BAastyle}% text style of authors
    \@A@citetrue%      % cite authors
    \@Y@citefalse%     % do not cite years
    \@ifnextchar[%     % ]
        {\@citex[#1]}%
        {\@citex[][#1]}%
}
\newcommand\APACNAT@citeauthorp{}
\def\APACNAT@citep[#1]{%
    \def\@BBOP{}%      % open parenthesis
    \def\@BAP{\BAP}%   % after precitation [=#1] before first citation
    \def\@BBA{\BBAA}%  % `and' between authors
    \def\@BBAY{}%      % between author and year
    \def\@BAY{}%       % after year
    \def\@BBY{}%       % between years of multiple citations with same author
    \def\@BBC{\BBC}%   % between cites
    \def\@BBN{\BBN}%   % after last citation before note/postcitation [=#2]
    \def\@BBCP{}%      % close parenthesis
    \def\@BAstyle{\BAastyle}% text style of authors
    \@A@citetrue%      % cite authors
    \@Y@citefalse%     % do not cite years
    \@ifnextchar[%     % ]
        {\@citex[#1]}%
        {\@citex[][#1]}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\citeyearpar}
% \begin{macro}{\citeyear}
% Cite only the year; parenthetical and without parentheses. Note that these
% are the \pkg{natbib} conventions, so unlike traditional \pkg{apacite}
% \cmd{\citeyear}, \cmd{\citeyear} here does not include the parentheses.
%    \begin{macrocode}
\DeclareRobustCommand\citeyearpar{%
    \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    \def\@BBOP{\BBOP}% % open parenthesis
    \def\@BBCP{\BBCP}% % close parenthesis
    \@ifnextchar[%     % ]
        {\APACNAT@citeyear}%
        {\APACNAT@citeyear[]}%
}
\DeclareRobustCommand\citeyear{%
    \def\BCAY##1##2##3{\BCA{##1}{##2}}% kept for compat. with prev. versions
    \def\citeauthoryear##1##2##3{\BCA{##1}{##2}}%
    \def\@BBOP{}%   % open parenthesis
    \def\@BBCP{}%   % close parenthesis
    \@ifnextchar[%  % ]
        {\APACNAT@citeyear}%
        {\APACNAT@citeyear[]}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACNAT@citeyear}
% Second layer of the year citation commands.
%    \begin{macrocode}
\newcommand\APACNAT@citeyear{}
\def\APACNAT@citeyear[#1]{%
    \def\@BAP{\BAP}%   % after precitation [=#1] before first citation
    \def\@BBA{}%       % `and' between authors
    \def\@BBAY{}%      % between author and year
    \def\@BAY{}%       % after year
    \def\@BBY{\BBYY}%  % between years of multiple citations with same author
    \def\@BBC{\BBC}%   % between cites
    \def\@BBN{\BBN}%   % after last citation before note/postcitation [=#2]
    \def\@BAstyle{}%   % text style of authors
    \@A@citefalse%     % do not cite authors
    \@Y@citetrue%      % cite years
    \@ifnextchar[%     % ]
        {\@citex[#1]}%
        {\@citex[][#1]}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACNAT@citex}
% The core citation command. We will let \cmd{\@citex} revert to this.
%    \begin{macrocode}
\newcommand\APACNAT@citex{}
\def\APACNAT@citex[#1][#2]#3{%
%    \end{macrocode}
%   Write citation(s) to \fname{.aux} file(s)
%    \begin{macrocode}
    \nocite{#3}%
%    \end{macrocode}
%   The previous cite, for multiple citations with same author.
%    \begin{macrocode}
    \edef\@citeP{}%
%    \end{macrocode}
%   Open parenthesis and pre-note. The \cmd{\mbox} is to avoid \pkg{hyperref}
%   problems if a citation command follows an \cmd{\item}. Better to change
%   this to using \cmd{\citetext}; for the todo list.
%    \begin{macrocode}
    \mbox{\@BBOP}%
    \ifx\@empty#1\@empty
    \else%
      {\ignorespaces #1\@BAP}%
    \fi%
%    \end{macrocode}
%   Loop over citation entries
%    \begin{macrocode}
    \@for\@citeb:=#3\do{%
%    \end{macrocode}
%       Removes a possible space before the citation key, so that, e.g.,
%       \verb*+\cite{key1, key2}+ can be done.
%    \begin{macrocode}
        \edef\@citeb{\expandafter\@firstofone\@citeb}%
%    \end{macrocode}
%       For \pkg{backref}.
%    \begin{macrocode}
        \back@cite{\@citeb}%
%    \end{macrocode}
% If this is an alias cite, we should include the alias but not author
% or year, so the code is slightly different.
%    \begin{macrocode}
        \if@APAC@alias@cite
%    \end{macrocode}
% Check whether the alias is defined.
%    \begin{macrocode}
          \@ifundefined{al@\@citeb\APAC@extra@b@citeb}%
            {\PackageWarning{apacite}{Undefined alias for citation \@citeb}
             \expandafter\def\csname al@\@citeb\APAC@extra@b@citeb\endcsname{?}%
            }{}%
%    \end{macrocode}
% Replace the authors by the alias and don't cite years.
%    \begin{macrocode}
          \@Y@citefalse  % do not cite years
          \def\BCA##1##2{{\@BAstyle \csname
            al@\@citeb\APAC@extra@b@citeb\endcsname}}%
%    \end{macrocode}
% Use the ``unequal'' code because the alias takes the place of the
% authors.
%    \begin{macrocode}
          \@ifauthorsunequalc@de{\@citeb\APAC@extra@b@citeb}%
        \else
%    \end{macrocode}
% The usual author and/or year citation. Check whether the citation is
% defined.
%    \begin{macrocode}
          \@ifundefined{b@\@citeb\APAC@extra@b@citeb}%
            {\expandafter\def\csname b@\@citeb\APAC@extra@b@citeb\endcsname{?}%
             \expandafter\def\csname Y@\@citeb\APAC@extra@b@citeb\endcsname{?}%
            }%
%    \end{macrocode}
% If the citation is defined, check whether the flag has been set that
% identifies that this is not the first citation to the work. If this
% flag has not been set, it will be set to |DUMMY|. If this is the first
% citation to the work, the full citation is used; else the short version
% is used.
%    \begin{macrocode}
            {\@ifundefined{flag@\@citeb\APAC@extra@b@citeb}%
               {\global\expandafter
                \def\csname flag@\@citeb\APAC@extra@b@citeb\endcsname{DUMMY}%
                \def\BCA##1##2{{\@BAstyle ##1}}%
               }%
               {\def\BCA##1##2{{\@BAstyle ##2}}%
               }%
            }%
%    \end{macrocode}
% Check whether the current author(s) is (are) equivalent to the
% previous. If so, only the year is cited in the text and a \cmd{\@BBY}
% (probably comma and space) is inserted between the two years. The
% \cmd{\protected@edef} fixes the problem with authors with accents
% (e.g., J{\"{o}}reskog). Older versions of \pkg{apacite} solved this
% less elegantly (\pkgoption{accentfix} option). This fix was provided by
% Robert Schlicht. See also the new definition of \cmd{\@citeP} below.
%    \begin{macrocode}
          \protected@edef\B@my@dummy{\csname
            b@\@citeb\APAC@extra@b@citeb\endcsname}%
          \ifx\@citeP\B@my@dummy
              \@ifauthorsequalc@de{\@citeb\APAC@extra@b@citeb}%
          \else
              \@ifauthorsunequalc@de{\@citeb\APAC@extra@b@citeb}%
          \fi
%    \end{macrocode}
% Store the current author(s) for comparison in the next citation (if
% any).
%    \begin{macrocode}
          \protected@edef\@citeP{\csname
            b@\@citeb\APAC@extra@b@citeb\endcsname}%
          \let\BCA\relax
        \fi
    }%
%    \end{macrocode}
%   End of the loop over citation entries. Add the post-note and closing
%   parenthesis.
%    \begin{macrocode}
    \ifx\@empty#2\@empty
    \else%
      {\@BBN #2}%
    \fi%
    \if@Y@cite%
       {\@BAY}%
    \fi%
    {\@BBCP}%
%    \end{macrocode}
%   We're finished with this citation command. Initialize for the next
%   \cmd{\APACNAT@citex} call.
%    \begin{macrocode}
    \@F@citetrue %
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\citetext}
% To place any arbitrary text inside the citation braces, use
% \cmd{\citetext}.
%    \begin{macrocode}
\newcommand\citetext[1]{\mbox{}\BBOP{}#1\BBCP}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@citex}
% The core citation command.
%    \begin{macrocode}
\let\@citex\APACNAT@citex
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cite}
% The use of \cmd{\cite} is considered deprecated in \pkg{natbib}, but
% we provide it as a backwards compatibility definition just like \pkg{natbib}.
% Without optional arguments, it reverts to \cmd{\citep} and with optional
% arguments (even empty ones), it reverts to \cmd{\citet}.
%    \begin{macrocode}
\DeclareRobustCommand\cite{%
  \@ifstar{%
    \@ifnextchar[%    %]
        {\citep*}%
        {\citet*}%
  }{%
    \@ifnextchar[%    %]
        {\citep}%
        {\citet}%
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Citet}
% \begin{macro}{\Citep}
% \begin{macro}{\Citealt}
% \begin{macro}{\Citealp}
% \begin{macro}{\Citeauthort}
% \begin{macro}{\Citeauthorp}
% \begin{macro}{\Citeauthor}
% \begin{macro}{\Citefullauthor}
% \begin{macro}{\Cite}
% Commands that capitalize the first name in a citation, to be used at the
% beginning of a sentence. These are currently not implemented yet, so let's
% just define them to be equal to the non-capitalized versions.
%    \begin{macrocode}
\DeclareRobustCommand\Citet{\citet}
\DeclareRobustCommand\Citep{\citep}
\DeclareRobustCommand\Citealt{\citealt}
\DeclareRobustCommand\Citealp{\citealp}
\DeclareRobustCommand\Citeauthort{\citeauthort}
\DeclareRobustCommand\Citeauthorp{\citeauthorp}
\DeclareRobustCommand\Citeauthor{\citeauthor}
\DeclareRobustCommand\Citefullauthor{\citefullauthor}
\DeclareRobustCommand\Cite{\cite}
\DeclareRobustCommand\shortCitet{\shortcitet}
\DeclareRobustCommand\shortCitep{\shortcitep}
\DeclareRobustCommand\shortCitealt{\shortcitealt}
\DeclareRobustCommand\shortCitealp{\shortcitealp}
\DeclareRobustCommand\shortCiteauthort{\shortciteauthort}
\DeclareRobustCommand\shortCiteauthorp{\shortciteauthorp}
\DeclareRobustCommand\shortCiteauthor{\shortciteauthor}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\shortcites}
% This declares a list of citations that should be cited in their
% short form. This can be overridden by using the starred form of
% the citation commands later.
%    \begin{macrocode}
\newcommand\shortcites[1]{%
  \@bsphack
    \@for\@citeb:=#1\do{%
      \edef\@citeb{\expandafter\@firstofone\@citeb}%
      \global\expandafter
         \def\csname flag@\@citeb\APAC@extra@b@citeb\endcsname{DUMMY}%
    }%
  \@esphack
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\defcitealias}
% \begin{macro}{\citetalias}
% \begin{macro}{\citepalias}
% Define an ``alias'', which can be an arbitrary text string, and use
% this instead of the author and year in a citation. Adapted from
% \fname{natbib.dtx}.
%    \begin{macrocode}
\newcommand\defcitealias[2]{%
   \@ifundefined{al@#1\APAC@extra@b@citeb}{}
   {\PackageWarning{apacite}{Overwriting existing alias for citation #1}}
   \@namedef{al@#1\APAC@extra@b@citeb}{#2}}
\DeclareRobustCommand\citetalias{%
  \@APAC@alias@citetrue
  \citet
}
\DeclareRobustCommand\citepalias{%
  \@APAC@alias@citetrue
  \citep
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Define \cmd{\citeindextype}, |\citeindextrue|, and |\citeindexfalse|
% for compatibility with \pkg{natbib}. However, these don't do anything
% in \pkg{apacite}, which supports author indexes using one of the
% ``index'' options and back referencing of specific citations using
% the \pkg{backref} package.
%    \begin{macrocode}
\newif\ifciteindex \citeindexfalse
\newcommand\citeindextype{default}
%    \end{macrocode}
%
% \begin{macro}{\citenumfont}
% The \pkg{natbib} command \cmd{\citenum} is undefined and thus gives an
% error, but the \cmd{\citenumfont} declaration is harmless and can stay.
%    \begin{macrocode}
\let\citenumfont=\@empty
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bibpunct}
% This sets various punctuation commands equal to its arguments.
% In contrast with the \pkg{natbib} implementation, the 5th argument
% (4th mandatory argument) is ignored, because \pkg{apacite} currently
% only supports author-year citations. Also, in contrast to the
% \pkg{natbib} implementation, this does not disable subsequent
% \cmd{\bibstyle} commands.
%    \begin{macrocode}
\newcommand\bibpunct[7][, ]%
  {\gdef\BBOP{#2}\gdef\BBCP{#3}\gdef\BBC{#4}%
   \gdef\BBAY{#6}\gdef\BBYY{#7}\gdef\BBN{#1}%
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bibstyle@apacite}
% \begin{macro}{\bibstyle@apa}
% These commands define the punctuation to be the \pkg{apacite}
% default. This is normally not very useful, because this only
% defines things as they are by default in \pkg{apacite} anyway, but
% it may be useful as a simple reset if different parts of the
% document need to use different styles.
%    \begin{macrocode}
\newcommand\bibstyle@apacite{%
    \bibpunct[, ]{(}{)}{; }{a}{, }{, }%
    \setlength{\bibhang}{2.5em}%
    \setlength{\bibsep}{0pt}%
}
\let\bibstyle@apa=\bibstyle@apacite
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\citestyle}
% This command selects a predefined citation punctuation style.
% In contrast to the \pkg{natbib} implementation, this is not
% deactivated at |\begin{document}|, so it's possible to change
% to a different style in the document body.
%    \begin{macrocode}
\newcommand\citestyle[1]{\csname bibstyle@#1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setcitestyle}
% This sets individual punctuation parameters. Adapted from
% \fname{natbib.dtx}.
%    \begin{macrocode}
\newcommand\setcitestyle[1]{%
 \@for\@tempa:=#1\do
 {\def\@tempb{round}\ifx\@tempa\@tempb
    \renewcommand\BBOP{(}\renewcommand\BBCP{)}\fi
  \def\@tempb{square}\ifx\@tempa\@tempb
    \renewcommand\BBOP{[}\renewcommand\BBCP{]}\fi
  \def\@tempb{angle}\ifx\@tempa\@tempb
    \renewcommand\BBOP{$<$}\renewcommand\BBCP{$>$}\fi
  \def\@tempb{curly}\ifx\@tempa\@tempb
    \renewcommand\BBOP{\{}\renewcommand\BBCP{\}}\fi
  \def\@tempb{semicolon}\ifx\@tempa\@tempb
    \renewcommand\BBC{; }\fi
  \def\@tempb{colon}\ifx\@tempa\@tempb
    \renewcommand\BBC{: }\fi
  \def\@tempb{comma}\ifx\@tempa\@tempb
    \renewcommand\BBC{, }\fi
%    \end{macrocode}
% \pkg{apacite} supports author-year citation only, so |authoryear|,
% |numbers|, and |super| are ignored. (Alternatively, we could have
% issued an error for |numbers| and |super|.)
%    \begin{macrocode}
  \def\@tempb{authoryear}\ifx\@tempa\@tempb
    \fi
  \def\@tempb{numbers}\ifx\@tempa\@tempb
    \fi
  \def\@tempb{super}\ifx\@tempa\@tempb
    \fi
  \expandafter\APAC@find@eq\@tempa=\relax\@nil
  \if\@tempc\relax\else
    \expandafter\APAC@rem@eq\@tempc
    \def\@tempb{open}\ifx\@tempa\@tempb
     \xdef\BBOP{\@tempc}\fi
    \def\@tempb{close}\ifx\@tempa\@tempb
     \xdef\BBCP{\@tempc}\fi
    \def\@tempb{aysep}\ifx\@tempa\@tempb
     \xdef\BBAY{\@tempc}\fi
    \def\@tempb{yysep}\ifx\@tempa\@tempb
     \xdef\BBYY{\@tempc}\fi
    \def\@tempb{notesep}\ifx\@tempa\@tempb
     \xdef\BBN{\@tempc}\fi
    \def\@tempb{citesep}\ifx\@tempa\@tempb
     \xdef\BBC{\@tempc}\fi
  \fi
 }%
}
\def\APAC@find@eq#1=#2\@nil{\def\@tempa{#1}\def\@tempc{#2}}
\def\APAC@rem@eq#1={\def\@tempc{#1}}
%    \end{macrocode}
% \end{macro}
%
% End of \pkg{natbib} emulation code.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
% \subsubsection{Using \pkg{apacite} with \pkg{natbib} for citations}
%
% If requested, this section loads \pkg{natbib} with the options
% \pkgoption{longnamesfirst} and \pkgoption{sort}, which are
% necessary for APA-style adherence. Then, we redefine some
% \pkg{natbib} and \pkg{apacite} commands to improve APA adherence of
% the combination. We also define a few additional commands that
% \pkg{natbib} did not implement, but that fit the scheme and serve
% some useful purpose for APA style citation. Defer loading this part
% until the end of the package, after loading the bibliography part.
% (This needs to be fixed.)
%
%    \begin{macrocode}
\newcommand{\BBA@nat}{%
  \ifNAT@swa
%    \end{macrocode}
% parenthetical; ``\&''
%    \begin{macrocode}
    \BBAA
  \else
%    \end{macrocode}
% in-text; ``and''
%    \begin{macrocode}
    \BBAB
  \fi
}
\if@APAC@natbib@apa
\AtEndOfPackage{%
\RequirePackage[longnamesfirst,sort]{natbib}
%    \end{macrocode}
%
% \begin{macro}{\NAT@parse@date}
% Redefine \pkg{natbib}'s date parsing function to avoid dropping the
% year in ``(2008a, 2008b)''.
%    \begin{macrocode}
\renewcommand\NAT@parse@date{}
\def\NAT@parse@date#1#2#3#4#5#6@@{%
    \def\NAT@year{#1#2}\def\NAT@exlab{{#3}}}
%    \end{macrocode}
% \end{macro}
% ``and'' vs.\ ``\&''.
%    \begin{macrocode}
\DeclareRobustCommand{\BBA}{\BBA@nat}
%    \end{macrocode}
% In the reflist ``\&''.
%    \begin{macrocode}
\let\orig@nat@@lbibitem\@lbibitem
\def\@lbibitem{\NAT@swatrue\orig@nat@@lbibitem}
%    \end{macrocode}
%
% Make sure we're in parenthetical mode when in \cmd{\citetext}
%    \begin{macrocode}
\renewcommand\citetext[1]{\NAT@open\begingroup\NAT@swatrue
  #1\endgroup\NAT@close}
%    \end{macrocode}
%
% \begin{macro}{\citeauthort}
% \begin{macro}{\citeauthorp}
% \begin{macro}{\citefullauthort}
% \begin{macro}{\citefullauthorp}
% \begin{macro}{\Citeauthort}
% \begin{macro}{\Citeauthorp}
% \begin{macro}{\Citefullauthort}
% \begin{macro}{\Citefullauthorp}
% There's only one \cmd{\citeauthor}, but we need to distinguish
% between parenthetical and in-text. The most common is in-text, so
% let \cmd{\citeauthor} be the in-text one, but define
% \cmd{\citeauthort} to be the same, and add \cmd{\citeauthorp}.
%    \begin{macrocode}
\DeclareRobustCommand\citeauthort{\citeauthor}
\DeclareRobustCommand\Citeauthort{\Citeauthor}
\DeclareRobustCommand\citeauthorp
   {\begingroup\NAT@swatrue\let\NAT@ctype\@ne\NAT@parfalse
    \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}}
\DeclareRobustCommand\Citeauthorp
   {\begingroup\NAT@swatrue\let\NAT@ctype\@ne\NAT@parfalse
     \let\NAT@up\NAT@Up
    \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}}
%    \end{macrocode}
% For completeness of the system.
%    \begin{macrocode}
\DeclareRobustCommand{\Citefullauthor}{\Citeauthor*}
\DeclareRobustCommand{\citefullauthort}{\citeauthort*}
\DeclareRobustCommand{\citefullauthorp}{\citeauthorp*}
\DeclareRobustCommand{\Citefullauthort}{\Citeauthort*}
\DeclareRobustCommand{\Citefullauthorp}{\Citeauthorp*}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibstyle@apacite}
% \begin{macro}{\bibstyle@apa}
% Other settings. I think the \pkg{natbib} defaults are good, but
% let's define this explicitly and allow the usual \pkg{apacite}
% customization options.
%    \begin{macrocode}
\providecommand\bibstyle@apacite{%
%    \end{macrocode}
% \pkg{natbib} is inconsistent with adding space.
%    \begin{macrocode}
    \renewcommand{\BBAY}{,\ignorespaces }%
    \bibpunct[\BBN ]{\BBOP }{\BBCP }{\BBC }{a}{\BBAY }{\BBYY }%
    \setlength{\bibhang}{2.5em}%
    \setlength{\bibsep}{0pt}%
}
\providecommand\bibstyle@apa{\bibstyle@apacite}
\citestyle{apacite}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% End of \pkg{natbib}--\pkg{apacite} code.
%    \begin{macrocode}
}% end \cmd{\AtEndOfPackage}
\fi
%    \end{macrocode}
%
% \subsubsection{Shared code for \pkgoption{natbibemu} and
% \pkgoption{natbibapa}}
%
% This section defines some extensions of \pkg{natbib} that are
% useful with both the \pkgoption{natbibemu} and \pkgoption{natbibapa}
% options.
%
%    \begin{macrocode}
\if@APAC@any@natbib
%    \end{macrocode}
%
% \begin{macro}{\maskcitations}
% \begin{macro}{\unmaskcitations}
% \begin{macro}{\masknocite}
% \begin{macro}{\maskcitep}
% \begin{macro}{\maskcitealp}
% \begin{macro}{\maskcitet}
% \begin{macro}{\maskcitealt}
% \begin{macro}{\maskciteauthor}
% \begin{macro}{\maskcitefullauthor}
% \begin{macro}{\maskciteyearpar}
% \begin{macro}{\maskciteyear}
% \begin{macro}{\maskcite}
% \begin{macro}{\maskcitetalias}
% \begin{macro}{\maskcitepalias}
% \begin{macro}{\maskCitet}
% \begin{macro}{\maskCitep}
% \begin{macro}{\maskCitealt}
% \begin{macro}{\maskCitealp}
% \begin{macro}{\maskCiteauthor}
% \begin{macro}{\maskcitenum}
% \begin{macro}{\maskciteauthort}
% \begin{macro}{\maskciteauthorp}
% \begin{macro}{\maskCitefullauthor}
% \begin{macro}{\maskCiteauthort}
% \begin{macro}{\maskCiteauthorp}
% \begin{macro}{\masktext}
% These commands allow masking of (self-)citations  for a masked
% review.
% The \cmd{maskcitations} command defines the masked citation commands;
% \cmd{unmaskcitations} does the same, but lets them be equal to the
% non-mask versions. The advantage of putting these definitions within
% a command is that we can switch between masked and unmasked within
% the same document. This is not likely to be used very often in
% practice, but is useful for writing tutorials.
%    \begin{macrocode}
\newcommand{\maskcitations}{%
    \def\masknocite##1{}%
    \DeclareRobustCommand\maskcite{%
        \@ifnextchar[%     % ]
            {\mask@cite}%
            {\mask@cite[]}%
    }%
    \def\mask@cite[##1]{%
        \@ifnextchar[%      % ]
            {\mask@@cite[##1]}%
            {\mask@@cite[##1][]}%
    }%
    \def\mask@@cite[##1][##2]##3{%
        \relax
%    \end{macrocode}
% Count number of masked references.
%    \begin{macrocode}
        \setcounter{maskedRefs}{0}%
        \@for\@citeb:=##3\do{%
            \addtocounter{maskedRefs}{1}%
        }%
        \ifnum\value{maskedRefs} = 1%
            \onemaskedcitationmsg{\themaskedRefs}%
        \else
            \maskedcitationsmsg{\themaskedRefs}%
        \fi
    }%
%    \end{macrocode}
% Let all other citation commands be identical to \cmd{\maskcite}.
% We could try to do fancy things with parentheses, but it's unlikely
% we will be able to cover all cases of interest, and users can easily
% change their document if they don't like how this comes out.
%    \begin{macrocode}
    \let\maskcitep\maskcite
    \let\maskcitealp\maskcite
    \let\maskcitet\maskcite
    \let\maskcitealt\maskcite
    \let\maskciteauthor\maskcite
    \let\maskcitefullauthor\maskcite
    \let\maskciteyearpar\maskcite
    \let\maskciteyear\maskcite
    \let\maskcitetalias\maskcite
    \let\maskcitepalias\maskcite
    \let\maskCitet\maskcite
    \let\maskCitep\maskcite
    \let\maskCitealt\maskcite
    \let\maskCitealp\maskcite
    \let\maskCiteauthor\maskcite
    \let\maskcitenum\maskcite
    \let\maskciteauthort\maskcite
    \let\maskciteauthorp\maskcite
    \let\maskCitefullauthor\maskcite
    \let\maskCiteauthort\maskcite
    \let\maskCiteauthorp\maskcite
%    \end{macrocode}
% A user command to flexibly mask or unmask certain pieces of text.
% An environment is technically more stable than a command, but less
% intuitive for users. Under masking, this command prints the optional
% alternative text |#1|, which defaults to nothing.
%    \begin{macrocode}
    \DeclareRobustCommand{\masktext}[2][]{##1}%
}
%    \end{macrocode}
%
% The ``mask'' citation commands revert to the same commands without
% ``mask'' if the \pkgoption{mask} option is not set.
%    \begin{macrocode}
\newcommand{\unmaskcitations}{%
    \let\masknocite\nocite
    \let\maskcitep\citep
    \let\maskcitealp\citealp
    \let\maskcitet\citet
    \let\maskcitealt\citealt
    \let\maskciteauthor\citeauthor
    \let\maskcitefullauthor\citefullauthor
    \let\maskciteyearpar\citeyearpar
    \let\maskciteyear\citeyear
    \let\maskcite\cite
    \let\maskcitetalias\citetalias
    \let\maskcitepalias\citepalias
    \let\maskCitet\Citet
    \let\maskCitep\Citep
    \let\maskCitealt\Citealt
    \let\maskCitealp\Citealp
    \let\maskCiteauthor\Citeauthor
    \let\maskcitenum\citenum
    \let\maskciteauthort\citeauthort
    \let\maskciteauthorp\citeauthorp
    \let\maskCitefullauthor\Citefullauthor
    \let\maskCiteauthort\Citeauthort
    \let\maskCiteauthorp\Citeauthorp
%    \end{macrocode}
% Unmasked, this command prints the mandatory second argument |#2|.
%    \begin{macrocode}
    \DeclareRobustCommand{\masktext}[2][]{##2}
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% End of \pkg{natbib} code.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
% This is part of the shared code, but has to be put after loading
% of \pkg{natbib}, so we'll put it here for the moment.
%    \begin{macrocode}
\if@APAC@anycitation
    \AtEndOfPackage{%
        \if@APAC@mask
            \maskcitations
        \else
            \unmaskcitations
        \fi
    }%
\fi
%    \end{macrocode}
%
% \subsubsection{Meta analysis}
%
% To my knowledge. \cmd{\nocitemeta} is not defined by any other citation
% package, so we'll provide it here regardless of the citation option
% chosen.
% \begin{macro}{\definemetaflag}
% \begin{macro}{\nocitemeta}
% This induces an entry in the reference list, but not in the text, and
% compared to \cmd{\nocite} defines an additional flag that indicates that the
% reference has been used in the meta-analysis reported. The construction
% with \cmd{\definemetaflag} is necessary to support \cmd{\nocitemeta} in
% an appendix \emph{after} the reference list. However, the previous version
% did not require the |\if@filesw|, which suggests that that would work if
% we can't write to the \fname{.aux} file, whereas the current one wouldn't.
% I don't know under what conditions this would happen or be useful, but it
% seems extremely rare. If somebody complains, I'll make a fix.
%    \begin{macrocode}
\def\definemetaflag#1{%
  \@bsphack
%    \end{macrocode}
% Define the note that precedes the reference list.
%    \begin{macrocode}
  \expandafter\global\expandafter\def
    \csname APAC@metaprenote@\APAC@extra@b@citeb\endcsname{%
      \APACmetaprenote}%
  \@for\@citeb:=#1\do{%
    \edef\@citeb{\expandafter\@firstofone\@citeb}%
%    \end{macrocode}
% Define the meta-analysis flag for the current item.
%    \begin{macrocode}
    \@ifundefined{flagmeta@\@citeb\APAC@extra@b@citeb}%
      {\global\expandafter
       \def\csname flagmeta@\@citeb\APAC@extra@b@citeb\endcsname{DUMMY}%
      }%
      {}%
  }%
  \@esphack
}
\def\nocitemeta#1{%
    \nocite{#1}%
    \@bsphack
    \if@filesw
      \@for\@citeb:=#1\do{%
        \edef\@citeb{\expandafter\@firstofone\@citeb}%
        \immediate\write
          \@newciteauxhandle{\string\definemetaflag{\@citeb}}%
    }%
    \fi
    \@esphack
    \@restore@auxhandle
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Bibliography structure}
%
% Here we define commands and environments that handle the structure of the
% reference list, various global style parameters, and the communication with
% the citation commands. Commands for detailed aspects of the entries
% themselves are defined below.
%
% \begin{macro}{\bibnewpage}
% Macro for starting a new page before the bibliography, if requested.
%    \begin{macrocode}
\def\bibnewpage{\clearpage}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@biblabel}
% No labels in the bibliography.
%    \begin{macrocode}
\def\@biblabel#1{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@lbibitem}
% Label-bibitem. If \pkg{natbib} is loaded after \pkg{apacite} (or
% \pkg{apacite} is loaded with the \pkgoption{natbibapa} option),
% this is overwritten. I should introduce an option that disables
% \pkg{apacite}'s bibliography-defining commands and/or senses whether
% \pkg{natbib} is loaded, so this is never defined in such cases.
%    \begin{macrocode}
\def\@lbibitem[#1]#2{%
    \def\BBA{\BBAA}%    ``\&''
%    \end{macrocode}
%   For compatibility with \pkg{chapterbib}, \pkg{bibunits}, \pkg{backref}, and
%   \pkg{hyperref}. Adapted from \fname{natbib.dtx}.
%    \begin{macrocode}
    \item[\hyper@natanchorstart{#2\APAC@extra@b@citeb}%
          \@biblabel{#1}%
          \hyper@natanchorend]%
    \if@filesw{%
        \def\BBA{\string\BBA}%
        \let\protect\noexpand
%    \end{macrocode}
%       \pkg{bibunits} redefines \cmd{\bibcite} through \cmd{\AtBeginDocument}
%       in a way that is incompatible with \pkg{apacite}'s definition. The
%       simplest way to get things working automatically seems to be
%       introducing the parallel \cmd{\APACbibcite} command. This should also
%       solve many other compatibility problems.
%    \begin{macrocode}
        \immediate\write\@newciteauxhandle{\string\bibcite{#2}{#1}}%
        \immediate\write\@newciteauxhandle{\string\APACbibcite{#2}{#1}}%
        \def\BBA{\BBAA}%
    }%
    \fi
    \ignorespaces
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACbibcite}
% \begin{macro}{\bibcite}
% These commands pass the author-year information from the reference list to
% the citation commands. See above for the necessity for \cmd{\APACbibcite}.
%    \begin{macrocode}
\def\APACbibcite#1#2{%
  \global\expandafter
    \def\csname b@#1\APAC@extra@binfo\endcsname{#2}%        names
  \global\expandafter
    \def\csname Y@#1\APAC@extra@binfo\endcsname{\@year@#2}% year
}
%    \end{macrocode}
% We don't need this one anymore, but other packages may use it.
%    \begin{macrocode}
\let\bibcite\APACbibcite
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\st@rtbibsection}
% Start a new section for the reference list.
%    \begin{macrocode}
\def\st@rtbibsection{%
  \@bibnewpage%           start a new page if desired
  \if@numberedbib%
    \section{\refname}%   e.g.,   6. References
  \else%
    \section*{\refname}%  e.g.,   References
    \if@tocbib%
      \addcontentsline{toc}{section}{\refname}%
    \fi%
%    \end{macrocode}
%   Ideally, we'd use something like |\sectionmark{{\refname}}|, so that
%   user-defined page heading styles are respected. But this does not work
%   properly, because it generates section numbers. Therefore, we define the
%   complete headings here. I need to find a better solution for this.
%    \begin{macrocode}
    \@ifundefined{chapter}
      {\@mkboth{{\refname}}{{\refname}}}%
      {\markright{{\refname}}}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\st@rtbibchapter}
% Start a new chapter for the reference list.
%    \begin{macrocode}
\def\st@rtbibchapter{%
%    \end{macrocode}
% Here no \cmd{\@bibnewpage}, because it is assumed that the \cmd{\chapter}
% starts a new page.
%    \begin{macrocode}
  \if@numberedbib%
    \chapter{\bibname}%   e.g.,   6. References
  \else%
    \chapter*{\bibname}%   e.g.,   References
    \if@tocbib%
      \addcontentsline{toc}{chapter}{\bibname}%
    \fi%
%    \end{macrocode}
%   Again, \cmd{\chaptermark} and \cmd{\sectionmark} don't work properly, so
%   define headings at a lower level.
%    \begin{macrocode}
    \@mkboth{{\bibname}}{{\bibname}}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{thebibliography}
% This environment contains the reference list. For historical reasons, it is
% defined in the plain \TeX{} way through definition of the
% \cmd{\thebibliography} and \cmd{\endthebibliography} macros instead of
% \cmd{\renewenvironment}.
%    \begin{macrocode}
\def\thebibliography#1{%
%    \end{macrocode}
% If \cmd{\chapter} is not defined, start a bibliography section.
%    \begin{macrocode}
  \@ifundefined{chapter}%
    {\st@rtbibsection}%
%    \end{macrocode}
%   Else, chapter is defined. Check first whether an explicit option has been
%   chosen.
%    \begin{macrocode}
    {\@ifundefined{@sectionbibtrue}%
%    \end{macrocode}
%      No explicit option chosen, so we have to speculate. If \cmd{\mainmatter}
%      is not defined (typically a report), assume that the bibliography is
%      a chapter. If \cmd{\mainmatter} is defined, a bibliography in the
%      main matter is typically a chapter-specific one, so generate a
%      bibliography section. A bibliography in the back matter is most likely
%      a global one, so then generate a bibliography chapter.
%    \begin{macrocode}
       {\@ifundefined{@mainmatterfalse}%
          {\st@rtbibchapter}%
          {\if@mainmatter
             \st@rtbibsection
           \else
             \st@rtbibchapter
           \fi
          }%
       }%
%    \end{macrocode}
%      If an explicit option has been chosen, simply use this.
%    \begin{macrocode}
       {\if@sectionbib
          \st@rtbibsection
        \else
          \st@rtbibchapter
        \fi
       }%
    }%
%    \end{macrocode}
% Insert some code between the chapter or section heading and the reference
% list. \cmd{\bibliographytypesize} will typically be used for some font
% settings and \cmd{\bibliographyprenote} for explanatory text, but this is
% up to the user. The ``metaprenote'' is a fixed text indicating that
% marked references are included in the meta-analysis reported.
%    \begin{macrocode}
  \bibliographytypesize % e.g., to put the bibliography in \small type
  \bibliographyprenote  % some explanatory note before the references
  \@ifundefined{APAC@metaprenote@\APAC@extra@b@citeb}%
    {}% skip
    {\csname APAC@metaprenote@\APAC@extra@b@citeb\endcsname}%
%    \end{macrocode}
% Initialize the list environment that holds the reference list.
%    \begin{macrocode}
  \list{\relax}{\labelsep=\biblabelsep
%               \parskip\z@ \@plus .3\p@\relax
                \parsep=\bibparsep
                \itemsep=\bibitemsep
                \leftmargin=\bibleftmargin
                \itemindent=\bibindent}% changed to cope with 4th ed.
%    \end{macrocode}
%  \cmd{\newblock} is inserted between ``blocks'' of a reference entry and
%  inserts some stretchable and shrinkable extra space between the blocks.
%    \begin{macrocode}
   \def\newblock{\hskip .11em plus .33em minus .07em}%
   \sloppy\clubpenalty4000\widowpenalty4000
   \sfcode`\.=1000\relax %'
%    \end{macrocode}
%  For compatibility with \pkg{bibtopic}.
%    \begin{macrocode}
   \bt@beg@thb@hook
%    \end{macrocode}
%  To overrule \pkg{backref}.
%    \begin{macrocode}
   \APACrestorebibitem
}
\def\endthebibliography{%
%    \end{macrocode}
%  For compatibility with \pkg{bibtopic}.
%    \begin{macrocode}
   \bt@end@thb@hook
%    \end{macrocode}
%  Warning if no item was included in the list and return to normal font size.
%  If \cmd{\bibliographytypesize} includes other formatting as well, the user
%  has to reset this explicitly after the bibliography, at least if there is
%  text after it.
%    \begin{macrocode}
   \def\@noitemerr{%
       \@latex@warning{Empty `thebibliography' environment}%
   }%
   \endlist\normalsize
}
%    \end{macrocode}
% \end{environment}
%
% \subsection{Reference list formatting}
%
% Traditionally, the reference list formatting is almost completely done by
% the bibliography style (\fname{.bst} file). Modeled after its predecessor,
% \pkg{theapa}, \pkg{apacite} has always supported some possibilities for
% customization through redefinable macros in the reference list. Due to my
% own customization needs, requests by users, and the language support, an
% increasing amount of reference list formatting is handled in this way. This
% section defines the default implementation of these macros, which users
% thus can redefine.
%
% \begin{macro}{\@connect@with@commas}
% An auxiliary function: Make a comma-separated output list of the input,
% recognizing empty arguments. Must be called with one argument, and the
% argument contains a comma-separated list of elements. The elements of this
% should generally be enclosed in braces.
%    \begin{macrocode}
\def\@connect@with@commas#1{%
  \def\@comma@space{\unskip, }%
  \let\@connect@string\relax
%    \end{macrocode}
% Loop over elements.
%    \begin{macrocode}
  \@for\@element@:=#1\do{%
%    \end{macrocode}
%    Commas should only be inserted if both sides are nonempty.
%    \begin{macrocode}
     \ifx\@empty\@element@%
     \else
%    \end{macrocode}
%      Not empty: insert connect string (nothing for the first nonempty
%      element, a comma and space afterwards).
%    \begin{macrocode}
       \@connect@string\@element@%
       \let\@connect@string\@comma@space
     \fi
  }%
  \let\@connect@string\@undefined
  \let\@comma@space\@undefined
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACmetastar}
% \begin{macro}{\APACinsertmetastar}
% Insert an asterisk before the names in the reference list for entries that
% are used in a meta-analysis.
%    \begin{macrocode}
\newcommand{\APACmetastar}{\ensuremath{{}^\ast}}
\def\APACinsertmetastar#1{%
  \@for\@citeb:=#1\do{%
    \edef\@citeb{\expandafter\@firstofone\@citeb}%
    \@ifundefined{flagmeta@\@citeb\APAC@extra@b@citeb}%
      {}% skip
      {{\APACmetastar}}%
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{environment}{APACrefauthors}
% An environment that allows some limited customization of author
% formatting in the reference list. In this implementation customization
% is handled through the \cmd{\APACrefauthstyle} macro, which allows some
% style definition, in particular font changes such as \cmd{\sc}.
%    \begin{macrocode}
\newenvironment{APACrefauthors}{%
  \begingroup \APACrefauthstyle
}{\endgroup }
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\APACrefYear}
% Formatting of the year in the reference list. Note that instead of redefining
% this command, one can also redefine the parentheses themselves. The argument
% should never be empty. The companion macro \cmd{\APACrefYearMonthDay} is
% defined below in the language-specific section.
%    \begin{macrocode}
\newcommand{\APACrefYear}[1]{%
  {\BBOP}{#1}{\BBCP}%
}
%    \end{macrocode}
% \end{macro}
%
% Title formatting. In these, |#1| is the capitalized title and |#2| is the
% sentence-case title.
%
% \begin{macro}{\APACrefatitle}
% Article title (roman, not capitalized).
%    \begin{macrocode}
\newcommand{\APACrefatitle}[2]{#2}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\APACrefbtitle}
% Book title (italic, not capitalized).
%    \begin{macrocode}
\newcommand{\APACrefbtitle}[2]{\Bem{#2}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\APACrefaetitle}
% English translation of a foreign article title (bracketed, roman, not
% capitalized).
%    \begin{macrocode}
\newcommand{\APACrefaetitle}[2]{[#2]}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\APACrefbetitle}
% English translation of a foreign book title (bracketed, roman, not
% capitalized).
%    \begin{macrocode}
\newcommand{\APACrefbetitle}[2]{[#2]}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACjournalVolNumPages}
% Journal, volume, number, pages
% (|#1| = journal, |#2| = volume, |#3| = number, |#4| = formatted pages).
%    \begin{macrocode}
\newcommand{\APACjournalVolNumPages}[4]{%
  \Bem{#1}%             journal
  \ifx\@empty#2\@empty
  \else
    \unskip, \Bem{#2}%  volume
  \fi
  \ifx\@empty#3\@empty
  \else
    \unskip({#3})%      issue number
  \fi
  \ifx\@empty#4\@empty
  \else
    \unskip, {#4}%      pages
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACaddressPublisher}
% \begin{macro}{\APACaddressInstitution}
% Address and publisher/institution (|#1| = address, |#2| = publisher).
%    \begin{macrocode}
\newcommand{\APACaddressPublisher}[2]{%
  \ifx\@empty#1\@empty
    \ifx\@empty#2\@empty
    \else
      {#2}%                 publisher
    \fi
  \else
    {#1}%                   address
    \ifx\@empty#2\@empty
    \else
      \unskip: {#2}%        publisher
    \fi
  \fi
}
\let\APACaddressInstitution\APACaddressPublisher
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACaddressPublisherEqAuth}
% \begin{macro}{\APACaddressInstitutionEqAuth}
% Address and publisher/institution if the latter is also the author.
% (|#1| = address, |#2| = publisher).
%    \begin{macrocode}
\newcommand{\APACaddressPublisherEqAuth}[2]{%
  \ifx\@empty#1\@empty
    {\BAuthor{}}% Publisher formatted as ``Author''
  \else
    {#1\unskip: \BAuthor{}}% Address: Author
  \fi
}
\let\APACaddressInstitutionEqAuth\APACaddressPublisherEqAuth
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APAChowpublished}
% Formatting of the \fieldname{howpublished} field. The
% \cmd{\APAChowpublished} macro is only inserted in the \fname{.bbl} file if
% the argument is nonempty. Because we don't want any special formatting, and
% |\def\APAChowpublished#1{#1}| leads to problems with hash marks (`|#|') in
% url's that may be present in \fieldname{howpublished}, we simply pretend
% that \cmd{\APAChowpublished} does not have an argument and does nothing.
%    \begin{macrocode}
\let\APAChowpublished\relax
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{APACrefURL}
% URL formatting. Use an environment instead of a macro to avoid some problems
% with url's as arguments of macros. The optional argument is the date that
% the url was last checked.
%    \begin{macrocode}
\newenvironment{APACrefURL}[1][]{%
  \ifx\@empty#1\@empty
    \BRetrievedFrom % Retrieved from
  \else
    \BRetrieved{#1}%  Retrieved <date>, from
  \fi
}{}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{APACrefDOI}
% DOI formatting. Use an environment instead of a macro to avoid some problems
% with url's as arguments of macros.
%    \begin{macrocode}
\newenvironment{APACrefDOI}{%
  \global\let\old@doi\doi
  \if@doi
    \doiprefix
  \else
%    \end{macrocode}
% Suppression of DOIs. For non-APA styles.
%    \begin{macrocode}
    \global\let\doi\@gobble
  \fi
%    \end{macrocode}
% Restore definition of \cmd{\doi}, in case a user wants to use this
% command explicitly.
%    \begin{macrocode}
  }{\global\let\doi\old@doi }
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{APACrefURLmsg}
% URLs of messages.
%    \begin{macrocode}
\newenvironment{APACrefURLmsg}{%
  \BMsgPostedTo
}{}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\APACorigED}
% \begin{macro}{\APACorigEDS}
% Original editor(s) for reprints and translations.
%    \begin{macrocode}
\newcommand{\APACorigED}[1]{%
  \ifx\@empty#1\@empty
  \else
    \Bby\ {#1}, \BED{}% ``by E. D. Itor (Ed.)''
  \fi
}
\newcommand{\APACorigEDS}[1]{%
  \ifx\@empty#1\@empty
  \else
    \Bby\ {#1}, \BEDS{}% ``by E. D. Itor \& A. N. Other (Eds.)''
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACbVolEdTR}
% Volume, edition, type, number, for a technical report (|#1| = formatted
% edition + volume, |#2| = formatted technical report type + number).
%    \begin{macrocode}
\newcommand{\APACbVolEdTR}[2]{%
  \ifx\@empty#1\@empty
    \ifx\@empty#2\@empty
    \else
      {(#2)}%            (Technical Report No.\ <no>)
    \fi
  \else
    ({#1}%               (2nd ed., Vol.~1
    \ifx\@empty#2\@empty
    \else
      \unskip; {#2}%     ; Technical Report No.\ <no>
    \fi
    )%                   Final parenthesis.
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACbVolEdTRpgs}
% Volume, edition, type, number, pages for an \entryname{@intechreport}.
% Arguments: |#1| = formatted edition + volume, |#2| = formatted technical
% report type + number, |#3| = formatted pages.
%    \begin{macrocode}
\newcommand{\APACbVolEdTRpgs}[3]{%
  \ifx\@empty#1\@empty
    \ifx\@empty#2\@empty
      \ifx\@empty#3\@empty
      \else
        {(#3)}%% (pp. 10--30)
      \fi
    \else
      %% (Technical Report No.\ <no>, pp. 10--30)
      (\@connect@with@commas{{#2},{#3}})%
    \fi
  \else
    ({#1}%                  (2nd ed., Vol.~1
    \ifx\@empty#2\@empty
      \ifx\@empty#3\@empty
      \else
        \unskip; {#3}%      ; pp. 10--30
      \fi
    \else
      %%                    ; Technical Report No.\ <no>, pp. 10--30
      \unskip; \@connect@with@commas{{#2},{#3}}%
    \fi
    )%                      Final parenthesis.
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% Various note formatting functions.
%
% \begin{macro}{\APACrefnote}
% Only a note.
%    \begin{macrocode}
\newcommand{\APACrefnote}[1]{%
  \ifx\@empty#1\@empty
  \else
    ({#1})%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACorigyearnote}
% Original year + optional note (|#1| = year, |#2| =  note).
%    \begin{macrocode}
\newcommand{\APACorigyearnote}[2]{%
  \ifx\@empty#1\@empty
%    \end{macrocode}
%   Original year empty: format note.
%    \begin{macrocode}
    \APACrefnote{#2}%
  \else
%    \end{macrocode}
%   Check for \cmd{\bibnodate}. I think the following command does not check
%   whether |#1| = `\cmd{\bibnodate}', but expands them; but that should also
%   be OK and saves a lot of juggling with \cmd{\expandafter} commands.
%    \begin{macrocode}
    \ifx\bibnodate#1\@empty
%    \end{macrocode}
%     Original year unknown: Format (only) note.
%    \begin{macrocode}
      \APACrefnote{#2}%
    \else
%    \end{macrocode}
%     Original year has been given: ``Original work published''.
%    \begin{macrocode}
      (\BOWP{} {#1}%
%    \end{macrocode}
%     Insert note.
%    \begin{macrocode}
      \ifx\@empty#2\@empty
      \else
        \unskip; {#2}%
      \fi
%    \end{macrocode}
%    Final parenthesis.
%    \begin{macrocode}
      )%
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACorigjournalnote}
% Original journal + optional note.
% Arguments: |#1| = year, |#2| = journal, |#3| = volume, |#4| = issue number,
%            |#5| = formatted pages, |#6| = note.
%    \begin{macrocode}
\newcommand{\APACorigjournalnote}[6]{%
  (\BREPR{} %          ``(Reprinted from '' (note the space)
  \Bem{#2}%            Journal (should not be empty)
  \ifx\@empty#1\@empty
  \else
    \unskip, {#1}%     , year
  \fi
  \ifx\@empty#3\@empty
  \else
    \unskip, \Bem{#3}% , volume
  \fi
  \ifx\@empty#4\@empty
  \else
    \unskip{[#4]}%     [issue number]
  \fi
  \ifx\@empty#5\@empty
  \else
    \unskip, {#5}%     , pages
  \fi
  \ifx\@empty#6\@empty
  \else
    \unskip; {#6}%     ; note
  \fi
  )%                   Final parenthesis
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACorigbooknote}
% Original book + optional note. Arguments:
% |#1| = year, |#2| = formatted editor, |#3| = formatted title,
% |#4| = formatted edition, |#5| = formatted volume, |#6| = formatted pages,
% |#7| = address, |#8| = publisher, |#9| = note.
%    \begin{macrocode}
\newcommand{\APACorigbooknote}[9]{%
    %% ``(Reprinted from '' (note the space)
  (\BREPR{} %
    %% Title, edition, volume, pages, editor, year, address: publisher
%    \end{macrocode}
%   These should not all be empty, but this is not checked here, because it's
%   done in the \fname{.bst} file.
%    \begin{macrocode}
  \@connect@with@commas{%
    {#3},{#4},{#5},{#6},{#2},{#1},{\APACaddressPublisher{#7}{#8}}%
  }%%
  \ifx\@empty#9\@empty
  \else
    ; #9%%              ; note
  \fi
  )%                    Final parenthesis.
}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{APACrefannotation}
% Annotations; for annotated bibliographies. Cf.~\citeA[pp.~810--811]{TLC2}.
%    \begin{macrocode}
\newenvironment{APACrefannotation}{%
  \begin{quotation}\noindent\ignorespaces
}{\end{quotation}}
%    \end{macrocode}
% \end{environment}
%
% \subsection{Various specific style settings and utility macros}
%
% \begin{macro}{\BAstyle}
% Text style of authors for citations that include the year as well
% (\cmd{\cite}, \cmd{\shortcite}, \cmd{\fullcite}, \cmd{\citeA},
% \cmd{\shortciteA}, \cmd{\fullciteA}, \cmd{\citeNP}, \cmd{\shortciteNP},
% \cmd{\fullciteNP}).
%    \begin{macrocode}
\newcommand{\BAstyle}{}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\BAastyle}
% Text style of authors for \cmd{\citeauthor} and its variants
% (\cmd{\shortciteauthor}, \cmd{\fullciteauthor}, \cmd{\citeauthorNP},
% \cmd{\shortciteauthorNP}, \cmd{\fullciteauthorNP}).
%    \begin{macrocode}
\newcommand{\BAastyle}{}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACrefauthstyle}
% Text style of authors in reference list.
%    \begin{macrocode}
\newcommand{\APACrefauthstyle}{}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACciteatitle}
% \begin{macro}{\APACcitebtitle}
% Formatting of ``article'' and ``book'' titles when they are used in a
% citation, typically when there is no author and the title takes this role.
%    \begin{macrocode}
\newcommand{\APACciteatitle}[1]{``#1''}
\newcommand{\APACcitebtitle}[1]{{\em #1\/}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACyear}
% \begin{macro}{\APACexlab}
% Formatting of the year and the extra label (`a', `b', etc.) that is used to
% distinguish different works by the same author(s) in the same year. These
% macros have been introduced to solve some problems with \pkg{natbib}'s
% parsing macros.
%    \begin{macrocode}
\newcommand{\APACyear}[1]{{#1}}%
\newcommand{\APACexlab}[1]{{#1}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\theBibCnt}
% \begin{macro}{\BCnt}
% The |BibCnt| counter is used to distinguish multiple citations with the same
% author(s) and year. Using a counter allows the user control over its
% formatting. The default formatting (APA style) is to add roman lowercase
% letters: ``(Kruskal, 1964a, 1964b)''. The \cmd{\protect} is necessary when
% \pkg{natbib} is used.
%    \begin{macrocode}
\newcounter{BibCnt}
\renewcommand{\theBibCnt}{\alph{BibCnt}}
\DeclareRobustCommand{\BCnt}[1]{\setcounter{BibCnt}{#1}\theBibCnt}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BCntIP}
% \begin{macro}{\BCntND}
% Variations of \cmd{\BCnt} for in-press and no-date citations. The \cmd{\mbox}
% prevents a line break at the hyphen.
%    \begin{macrocode}
\DeclareRobustCommand{\BCntIP}[1]{\setcounter{BibCnt}{#1}\mbox{-\theBibCnt}}
\DeclareRobustCommand{\BCntND}[1]{\setcounter{BibCnt}{#1}\mbox{-\theBibCnt}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibliographytypesize}
% Font size of the references, but this macro can be abused to insert lots of
% other style commands and/or text between the section or chapter heading and
% the actual references as well.
%    \begin{macrocode}
\let\bibliographytypesize\normalsize
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bibliographyprenote}
% An optional note just before the references in the reference list (but after
% \cmd{\bibliographytypesize}). It defaults to nothing, but can be changed to
% a list of commands (e.g., if author formatting should be different in the
% reference list) and/or text (e.g., for an explanatory note).
%    \begin{macrocode}
\newcommand{\bibliographyprenote}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bibleftmargin}
% \begin{macro}{\bibindent}
% \begin{macro}{\bibparsep}
% \begin{macro}{\bibitemsep}
% \begin{macro}{\biblabelsep}
% Declare a few length parameters for the reference list and give them
% default values. Supporting the \pkg{natbib} length \cmd{\bibhang} would
% be nice, but I don't see a way to do this in a user-friendly way that
% allows loading \pkg{apacite} both with and without \pkg{natbib} and
% also allows changing \cmd{\bibindent} and \cmd{\bibleftmargin}
% separately.
%    \begin{macrocode}
\newskip{\bibleftmargin}
\newskip{\bibindent}
\newskip{\bibparsep}
\newskip{\bibitemsep}
\newskip{\biblabelsep}
\setlength{\bibleftmargin}{2.5em}
\setlength{\bibindent}{-\bibleftmargin}
\setlength{\bibparsep}{0pt}
\setlength{\bibitemsep}{0pt plus .3pt}
\setlength{\biblabelsep}{0pt}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibcorporate}
% Formatting of corporate (group) authors. Its primary function is in the
% \BibTeX{} stage. It is recognized by \fname{apacite.bst}, which handles
% such authors slightly differently from ordinary authors.
%    \begin{macrocode}
\let\bibcorporate\relax
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\BBA}
% Initialize this command, which formats the ``and'' between authors.
%    \begin{macrocode}
\newcommand{\BBA}{\BBAA}% `\&'
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Bem}
% Emphasis in the bibliography. A relic from \pkg{theapa}. It allows to use
% underlining in the bibliography and italics in the text, but the default is
% italics.
%    \begin{macrocode}
\let\Bem\emph
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bibnotype}
% This macro indicates that the type information should be left empty. It is
% used for \entryname{@techreport} and \entryname{@intechreport}, where
% ``\cmd{\BTR}'' is the default type if the field is left empty. As such, it
% primarily modifies the behavior of \fname{apacite.bst}.
%    \begin{macrocode}
\newcommand{\bibnotype}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACSortNoop}
% \begin{macro}{\bibphant}
% The \cmd{\APACSortNoop} macro can be used to change the sorting order:
% When put between a pair of braces at the beginning of a field, the entry is
% sorted on the argument of this command, but the argument is never displayed.
% \cmd{\bibphant} is the same as \cmd{\APACSortNoop}, so it is not discussed
% in the main documentation. It is only kept for backwards compatibility with
% old versions of \pkg{apacite}, in which it was documented.
%    \begin{macrocode}
\newcommand{\APACSortNoop}[1]{}
\let\bibphant\APACSortNoop
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\makehashother}
% \begin{macro}{\makehashmacropar}
% Setting the catcode of the hash mark `|#|'. This is mainly useful in some
% cases in which the bibliography contains urls containing `|#|' symbols.
% These are analogous to \cmd{\makeatother} and \cmd{\makeatletter}.
% (They are undocumented in the main documentation!)
%    \begin{macrocode}
\def\makehashother{\catcode`\#=12\relax}
\def\makehashmacropar{\catcode`\#=6\relax}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Author index setup and index styles}
%
% Here, the author index options are implemented. It also defines some index
% styles and defines most of the index-related commands to do nothing in case
% no author index is requested.
%
% \begin{macro}{\AX}
% \begin{macro}{\corporateAX}
% \begin{macro}{\@AXfile}
% \begin{macro}{\currentindexname}
% \begin{macro}{\printindex}
% \begin{macro}{\PrintAX}
% \begin{macro}{\orig@printindex}
% \begin{macro}{\APAC@printindex}
% \begin{macro}{\check@printindex}
% Define the author-indexing macros and the index-printing commands.
%    \begin{macrocode}
\if@APAC@index
%    \end{macrocode}
%   Author index requested.
%    \begin{macrocode}
    \if@APAC@index@package
%    \end{macrocode}
%       Load \pkg{index} package.
%    \begin{macrocode}
        \RequirePackage{index}[1995/09/28]
%    \end{macrocode}
%       Define the author index. This may be changed in the preamble of the
%       document (or in a user-provided package) by a \cmd{\renewindex}
%       command.
%    \begin{macrocode}
        \newindex{autx}{adx}{and}{\authorindexname}
%    \end{macrocode}
%       Author indexing command. Some trial and error and adapting code from
%       other packages to get this right, esp.\ when \pkg{hyperref} is also
%       loaded.
%    \begin{macrocode}
        \DeclareRobustCommand{\AX}[1]{%
          \if@filesw{%
            \protected@write\@auxout{}{%
              \string\protected@write\string\tf@autx{}{%
              \string\string\string
              \indexentry{\string#1|hyperpage}{\thepage}}}%
          }%
          \fi
        }%
    \else
%    \end{macrocode}
%       Without the \pkg{index} package, using standard \LaTeX{}. This includes
%       a bit of code adapted from \fname{ltidxglo.dtx} and \fname{doc.dtx}.
%    \begin{macrocode}
        \newwrite\@AXfile
        \immediate\openout\@AXfile=\jobname.adx
        \typeout
            {Writing author index file \jobname.adx }%
        \DeclareRobustCommand{\AX}[1]{%
            \protected@write\@AXfile{}%
                {\string\indexentry{\string#1}{\thepage}}%
        }%
        \def\PrintAX{\edef\currentindexname{\authorindexname}%
             \@input@{\jobname.and}%
             \global\let\PrintAX\@empty
        }%
        \AtBeginDocument{%
%    \end{macrocode}
%         Make sure that \cmd{\printindex} is defined.
%    \begin{macrocode}
          \@ifundefined{printindex}{\makeindex}{}%
%    \end{macrocode}
%         Now, redefine \cmd{\printindex} to accommodate both \cmd{\printindex}
%         without argument and |\printindex[autx]|.
%    \begin{macrocode}
          \let\orig@printindex\printindex
          \def\printindex{\@ifnextchar[{\APAC@printindex}{%
                                        \orig@printindex}}%
          \def\APAC@printindex[autx]{\PrintAX}%
        }%
    \fi
%    \end{macrocode}
%   Include corporate authors in the author index?
%    \begin{macrocode}
    \if@APAC@include@corporate
      \let\corporateAX\AX
    \else
      \let\corporateAX\@gobble
    \fi
\else
%    \end{macrocode}
%   No author index. Wait until |\begin{document}| for checking whether another
%   package is loaded that defines \cmd{\printindex}.
%    \begin{macrocode}
    \AtBeginDocument{%
      \@ifundefined{printindex}%
        {%
%    \end{macrocode}
%         \cmd{\printindex} has not been defined. Define \cmd{\printindex} so
%         that it suppresses the indexes.
%    \begin{macrocode}
          \def\printindex{\@ifnextchar[{\check@printindex}{%
                                        \check@printindex[]}}%
          \def\check@printindex[#1]{\relax }%
        }%
        {%
%    \end{macrocode}
%         \cmd{\printindex} has been defined, so save its definition.
%    \begin{macrocode}
          \let\orig@printindex\printindex
%    \end{macrocode}
%         Redefine \cmd{\printindex} so that it suppresses the author index
%         but does not change other indexes: (1) If there is no optional
%         argument, use the original definition.
%    \begin{macrocode}
          \def\printindex{\@ifnextchar[{\check@printindex}{\orig@printindex}}%
%    \end{macrocode}
%         (2) If there is an optional argument, check whether it is equal to
%         ``|autx|''. If so, suppress this (author) index. If not, use the
%         original definition.
%    \begin{macrocode}
          \def\check@printindex[#1]{%
%    \end{macrocode}
%           Use a clumsy way to check whether |#1| = |autx|, but seemingly more
%           elegant ways somehow didn't work.
%    \begin{macrocode}
            \expandafter\def\csname APAC@#1\endcsname{DUMMY}%
            \@ifundefined{APAC@autx}%
              {\orig@printindex[#1]}%
              {\let\APAC@autx\@undefined}%
          }%
        }%
    }%
%    \end{macrocode}
%   Empty author indexing commands.
%    \begin{macrocode}
    \let\AX\@gobble
    \let\corporateAX\@gobble
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{environment}{theindex}
% \begin{macro}{\APACstdindex}
% The \envirname{index} environment as defined in the \pkg{index} package;
% literally copied from \fname{index.sty}.
%    \begin{macrocode}
\newcommand{\APACstdindex}{%
    \@ifclassloaded{article}{%
       \renewenvironment{theindex}{%
           \edef\indexname{\the\@nameuse{idxtitle@\@indextype}}%
           \if@twocolumn
               \@restonecolfalse
           \else
               \@restonecoltrue
           \fi
           \columnseprule \z@
           \columnsep 35\p@
           \twocolumn[%
               \section*{\indexname}%
               \ifx\index@prologue\@empty\else
                   \index@prologue
                   \bigskip
               \fi
           ]%
           \@mkboth{\MakeUppercase\indexname}%
                   {\MakeUppercase\indexname}%
           \thispagestyle{plain}%
           \parindent\z@
           \parskip\z@ \@plus .3\p@\relax
           \let\item\@idxitem
       }{%
           \if@restonecol
               \onecolumn
           \else
               \clearpage
           \fi
       }
    }{%
       \renewenvironment{theindex}{%
           \edef\indexname{\the\@nameuse{idxtitle@\@indextype}}%
           \if@twocolumn
               \@restonecolfalse
           \else
               \@restonecoltrue
           \fi
           \columnseprule \z@
           \columnsep 35\p@
           \twocolumn[%
               \@makeschapterhead{\indexname}%
               \ifx\index@prologue\@empty\else
                   \index@prologue
                   \bigskip
               \fi
           ]%
           \@mkboth{\MakeUppercase\indexname}%
                   {\MakeUppercase\indexname}%
           \thispagestyle{plain}%
           \parindent\z@
           \parskip\z@ \@plus .3\p@\relax
           \let\item\@idxitem
       }{%
           \if@restonecol
               \onecolumn
           \else
               \clearpage
           \fi
       }%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACtocindex}
% The \envirname{index} environment as defined in the \pkg{index} package, but
% with a table of contents entry added.
%    \begin{macrocode}
\newcommand{\APACtocindex}{%
    \@ifclassloaded{article}{%
       \renewenvironment{theindex}{%
           \edef\indexname{\the\@nameuse{idxtitle@\@indextype}}%
           \if@twocolumn
               \@restonecolfalse
           \else
               \@restonecoltrue
           \fi
           \columnseprule \z@
           \columnsep 35\p@
           \twocolumn[%
               \section*{\indexname}%
               \ifx\index@prologue\@empty\else
                   \index@prologue
                   \bigskip
               \fi
           ]%
           \@mkboth{\MakeUppercase\indexname}%
                   {\MakeUppercase\indexname}%
%    \end{macrocode}
%          The following line added by EM.
%    \begin{macrocode}
           \addcontentsline{toc}{section}{\indexname}%
           \thispagestyle{plain}%
           \parindent\z@
           \parskip\z@ \@plus .3\p@\relax
           \let\item\@idxitem
       }{%
           \if@restonecol
               \onecolumn
           \else
               \clearpage
           \fi
       }
    }{%
       \renewenvironment{theindex}{%
           \edef\indexname{\the\@nameuse{idxtitle@\@indextype}}%
           \if@twocolumn
               \@restonecolfalse
           \else
               \@restonecoltrue
           \fi
           \columnseprule \z@
           \columnsep 35\p@
           \twocolumn[%
               \@makeschapterhead{\indexname}%
               \ifx\index@prologue\@empty\else
                   \index@prologue
                   \bigskip
               \fi
           ]%
           \@mkboth{\MakeUppercase\indexname}%
                   {\MakeUppercase\indexname}%
%    \end{macrocode}
%          The following line added by EM.
%    \begin{macrocode}
           \addcontentsline{toc}{chapter}{\indexname}%
           \thispagestyle{plain}%
           \parindent\z@
           \parskip\z@ \@plus .3\p@\relax
           \let\item\@idxitem
       }{%
           \if@restonecol
               \onecolumn
           \else
               \clearpage
           \fi
       }%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACemindex}
% An alternative style for the \envirname{index} environment, such that
% automatically a chapter or section title is generated, with a corresponding
% table of contents entry. The index is now in a \envirname{multicol}
% environment.
%    \begin{macrocode}
\newcommand{\APACemindex}{%
    \RequirePackage{multicol}
    \renewenvironment{theindex}{%
        \edef\@indexname{\the\@nameuse{idxtitle@\@indextype}}%
        \@ifundefined{chapter}%
          {\section*{\@indexname}%
           \addcontentsline{toc}{section}{\@indexname}%
%%          \sectionmark{{\@indexname}}% doesn't work: generates numbers
          }%
          {\chapter*{\@indexname}%
           \addcontentsline{toc}{chapter}{\@indexname}%
%%          \chaptermark{{\@indexname}}% doesn't work: generates numbers
%%                                     % (except in the backmatter)
%%          \sectionmark{{\@indexname}}% doesn't work: generates numbers
          }%
        \@mkboth{{\@indexname}}{{\@indexname}}% Hence we need this.
        \parindent\z@
        \parskip\z@ \@plus .3\p@\relax
        \let\item\@idxitem
        \setlength{\columnsep}{2em}
        \small
        \begin{multicols}{2}
        \raggedright
      }%
      {\end{multicols}\normalsize
      }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACltxemindex}
% A variation on \cmd{\APACemindex}, but without using the \pkg{index} package,
% which conflicts with the standard \LaTeX{} documentation classes.
%    \begin{macrocode}
\newcommand{\APACltxemindex}{%
    \RequirePackage{multicol}
    \renewenvironment{theindex}{%
%    \end{macrocode}
%       The index naming scheme of the \pkg{index} package is also absent.
%       Therefore, try to guess an index name.
%    \begin{macrocode}
        \@ifundefined{currentindexname}{%
          \@ifundefined{indexname}{%
            \edef\@indexname{Index}%
          }{\edef\@indexname{\indexname}}%
        }{\edef\@indexname{\currentindexname}}%
        \@ifundefined{chapter}%
          {\section*{\@indexname}%
           \addcontentsline{toc}{section}{\@indexname}%
%%          \sectionmark{{\@indexname}}% doesn't work: generates numbers
          }%
          {\chapter*{\@indexname}%
           \addcontentsline{toc}{chapter}{\@indexname}%
%%          \chaptermark{{\@indexname}}% doesn't work: generates numbers
%%                                     % (except in the backmatter)
%%          \sectionmark{{\@indexname}}% doesn't work: generates numbers
          }%
        \@mkboth{{\@indexname}}{{\@indexname}}% Hence we need this.
        \def\pfill{\relax{}}%
        \parindent\z@
        \parskip\z@ \@plus .3\p@\relax
        \let\item\@idxitem
        \setlength{\columnsep}{2em}
        \small
        \begin{multicols}{2}
        \raggedright
      }%
      {\end{multicols}\normalsize
      }%
}
%    \end{macrocode}
% \end{macro}
% \end{environment}
%
% \subsection{Formatting of urls}
%
% \begin{macro}{\Url@force@Tilde}
% \begin{macro}{\Url@APACdot}
% \begin{macro}{\Url@APACcomma}
% \begin{macro}{\Url@APACquestionmark}
% \begin{macro}{\Url@APACexclamation}
% \begin{macro}{\Url@APAChyphen}
% \begin{macro}{\Url@APACunderscore}
% \begin{macro}{\APACurlBreaks}
% \begin{macro}{\url@APACttstyle}
% \begin{macro}{\url@APACrmstyle}
% \begin{macro}{\url@APACsfstyle}
% \begin{macro}{\url@APACsamestyle}
% The APA manual requires breaking of urls \emph{after} a slash or
% \emph{before} a dot. In particular, there should not be a break between
% ``|http:|'' and ``|//|''. This differs from the standard line breaking
% style of the \pkg{url} package. Therefore, we define an APA-style for
% url formatting here. (Maybe this should be part of the \pkg{apa} class,
% but urls occur most often in the reference list, so we do it here.)
% The \pkg{url} package also defines many other (punctuation) symbols at
% which a line break may occur. The APA manual does not mention these, but
% it seems in the spirit of the APA manual to use these as well. See also
% \citeA[pp.~645--646]{chicago}.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{url}{%
%    \end{macrocode}
%   To circumvent an ``undefined'' error.
%    \begin{macrocode}
    \@ifundefined{Url@force@Tilde}{\def\Url@force@Tilde{\relax}}{}%
%    \end{macrocode}
%   The original dot. Simply using `|.|' causes an infinite loop. This command
%   is used below, so that encoding-issues can be resolved easier by redefining
%   \cmd{\Url@APACdot}. The same argument holds for the other punctuation
%   marks.
%    \begin{macrocode}
    \def\Url@APACdot{\mathchar"2E }%
    \def\Url@APACcomma{\mathchar"2C }%
    \def\Url@APACquestionmark{\mathchar"3F }%
    \def\Url@APACexclamation{\mathchar"21 }%
    \def\Url@APAChyphen{\mathchar"2D }%
    \def\Url@APACunderscore{\_}%
%    \end{macrocode}
%   Define the APA-style line breaks for urls.
%    \begin{macrocode}
    \def\APACurlBreaks{%
%    \end{macrocode}
%     Remove dot (`|.|') and slash (`|/|') from the ordinary breaks and add
%     the slash to the big breaks, so that |http://| is broken after the second
%     slash instead of after the colon. The \cmd{\UrlNoBreaks} and
%     \cmd{UrlOrds} are the default ones from the \pkg{url} package, but they
%     are repeated here to obtain a complete style, so that we don't have to
%     rely on what is the \pkg{url} default (which might change).
%    \begin{macrocode}
      \def\UrlBreaks{\do\@\do\\\do\|\do\;\do\>\do\]\do\)\do\'\do+\do\=\do\#}%
      \def\UrlBigBreaks{\do\/\do\:\do@url@hyp}%
      \def\UrlNoBreaks{\do\(\do\[\do\{\do\<}% \)
      \def\UrlOrds{\do\*\do\~\do\'\do\"}%
%    \end{macrocode}
%     Define the dot as an empty binary relation (after which a break may
%     occur) followed by a dot-symbol (after which no break may occur).
%     \citeA{chicago} requires the same treatment of a few other punctuation
%     marks, different from \pkg{url}'s default behavior. We implement these
%     as well.
%    \begin{macrocode}
      \def\UrlSpecials{%
        \do\.{\mathbin{}\Url@APACdot }%
        \do\,{\mathbin{}\Url@APACcomma }%
        \do\-{\mathbin{}\Url@APAChyphen }%
        \do\?{\mathbin{}\Url@APACquestionmark }%
        \do\!{\mathbin{}\Url@APACexclamation }%
        \do\_{\mathbin{}\Url@APACunderscore }%
        \do\ {\Url@space}\do\%{\Url@percent}\do\^^M{\Url@space}%
        \Url@force@Tilde}% package option may force faked text-ascii-tilde
    }%%
%    \end{macrocode}
%   Change the underscore for when a non-tt font is used.
%    \begin{macrocode}
    \def\Url@OTnonTT{\do\<{\langle}\do\>{\mathbin{\rangle}}\do
      \_{\mathbin{}\_}\do\|{\mid}\do\{{\lbrace}\do\}{\mathbin{\rbrace}}\do
      \\{\mathbin{\backslash}}\UrlTildeSpecial}
%    \end{macrocode}
%   Define four APA url-styles, based on the standard styles in
%   \fname{url.sty}, and use the |APACtt|-style as default.
%    \begin{macrocode}
    \def\url@APACttstyle{\def\UrlFont{\ttfamily}\APACurlBreaks }%
    \def\url@APACrmstyle{\def\UrlFont{\rmfamily}\APACurlBreaks }%
    \def\url@APACsfstyle{\def\UrlFont{\sffamily}\APACurlBreaks }%
    \def\url@APACsamestyle{\def\UrlFont{}\APACurlBreaks }%
    \urlstyle{APACtt}%
  }{}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\url}
% In case \cmd{\url} is undefined, define a very simple version.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifundefined{url}{%
    \def\url#1{\texttt{#1}}%
  }{}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\doi}
% \begin{macro}{\doiprefix}
% Similarly, define \cmd{\doi}. Adapted from code in \fname{plainnat.bst}.
%    \begin{macrocode}
\AtBeginDocument{%
  \expandafter\ifx\csname urlstyle\endcsname\relax
    \providecommand{\doi}[1]{#1}\else
    \providecommand{\doi}{\begingroup \urlstyle{APACsame}\Url}\fi
}
\@ifundefined{doiprefix}{%
  \newcommand{\doiprefix}{doi:\penalty0{}}%
}{}%
%    \end{macrocode}
% \end{macro}
%
% \subsection{Compatibility code}
%
% Many other packages redefine citation commands and reference list commands,
% or at least affect them, even if that is not their core business. This leads
% to all kinds of compatibility problems. Here, these are repaired.
%
% \subsubsection{\pkg{babel}}
%
% From \fname{hyperref.dtx}:
% \begin{quote}
%   Package \pkg{babel} redefines \cmd{\bibcite} with macro
%   \cmd{\bbl@cite@choice}. It needs to be overwritten to avoid the warning
%   ``Label(s) may have changed.''.
% \end{quote}
% Here, a slightly adapted version of the code mentioned above is inserted. The
% other \cmd{\bibcite}-restoring compatibility code above does something
% similar, but does not do the job correctly if \pkg{babel} is loaded (why?).
% This only works if \pkg{babel} is loaded before \pkg{apacite}; putting it in
% a \cmd{\AtBeginDocument} does not work well.
%    \begin{macrocode}
\@ifundefined{bbl@cite@choice}{}{%
  \g@addto@macro\bbl@cite@choice{%
    \let\bibcite\APACbibcite
  }%
}
%    \end{macrocode}
%
% \subsubsection{\pkg{natbib}}
%
% Above, we implemented some code for the \pkgoption{natbibapa} option.
% The code here is intended as a fix for more general cases, but we
% have to make sure not to conflict with the code above. This applies
% to the redefinition of the \cmd{\NAT@parse@date} command.
%    \begin{macrocode}
\if@APAC@natbib@apa
\else
\AtBeginDocument{%
  \@ifpackageloaded{natbib}{%
%    \end{macrocode}
% Redefine a \pkg{natbib} command. This may be ethically dubious, but without
% it, \pkg{natbib} simply cannot handle \pkg{apacite}-generated \fname{.bbl}
% files. The only reason I can think of why both \pkg{apacite} and \pkg{natbib}
% would be loaded is exactly the situation when you want to use \pkg{natbib}
% for the citations and \pkg{apacite} for the reference list. In this
% situation you would load \fname{apacite.sty}, not for the citation commands,
% but for the punctuation commands and labels defined by \pkg{apacite}. In this
% situation, the redefinition below is necessary and therefore I do this here.
%    \begin{macrocode}
    \def\NAT@parse@date#1#2#3#4#5#6@@{%
      \def\NAT@year{{#1}}\def\NAT@exlab{{#2}}%
    }%
  }{}%
}
\fi
%    \end{macrocode}
% \pkg{natbib} redefines \cmd{\thebibliography}, which interferes a little with
% our purposes. Therefore, add some patches.  This goes wrong if
% \cmd{\bibpreamble} is redefined later on, i.e., by the user, but I haven't
% come up with a better hack yet.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{natbib}{%
    \let\@oldbibpreamble\bibpreamble
    \def\bibpreamble{%
      \@oldbibpreamble%
      \bibliographytypesize%
      \bibliographyprenote%
      \@ifundefined{APAC@metaprenote@\APAC@extra@b@citeb}%
        {}% skip
        {\csname APAC@metaprenote@\APAC@extra@b@citeb\endcsname}%
    }%
    \let\@old@endthebibliography\endthebibliography
    \def\endthebibliography{\@old@endthebibliography%
                            \normalsize}%
  }{}%
}
%    \end{macrocode}
%
% \subsubsection{\pkg{hyperref}}
%
% The code here is adapted from \pkg{hyperref}, \pkg{natbib}, and their
% respective documentation, to make use of their interoperability.
%    \begin{macrocode}
\AtBeginDocument{%
    \@ifundefined{NAT@parse}{%
      \def\NAT@parse{This is a fake natbib command to fool hyperref.}}{}%
    \@ifundefined{hyper@natlinkstart}{%
      \let\hyper@natlinkstart\@gobble}{}%
    \@ifundefined{hyper@natlinkend}{%
      \let\hyper@natlinkend\relax}{}%
    \@ifundefined{hyper@natanchorstart}{%
      \let\hyper@natanchorstart\@gobble}{}%
    \@ifundefined{hyper@natanchorend}{%
      \let\hyper@natanchorend\relax}{}%
    \@ifundefined{hyperpage}{%
      \def\hyperpage#1{#1}}{}%
%    \end{macrocode}
% Remove spaces from hyperlinks (\pkg{hyperref} keeps them, even if they are
% removed from the visible output, so you'd get awkward results like
% |\href{http://my .link}{http://my.link}|).
%    \begin{macrocode}
    \@ifpackageloaded{hyperref}{%
%    \end{macrocode}
%     The next should always be true, but just to be sure\ldots
%    \begin{macrocode}
      \@ifpackageloaded{url}{%
%    \end{macrocode}
%       Is \pkgoption{obeyspaces} option requested? If not, then remove spaces
%       from hyperlinks.
%    \begin{macrocode}
        \ifx\@empty\Url@ObeySp\@empty
          \def\url@#1{\def\@tmp@arg{\string#1}%
                      \HyPsd@Subst{ }{}{\@tmp@arg}%
                      \hyper@linkurl{\Hurl{#1}}{\@tmp@arg}}%
        \fi
      }{}%
    }{}%
}
%    \end{macrocode}
%
% \subsubsection{\pkg{backref}}
%
% \begin{macro}{\back@cite}
% \begin{macro}{\CurrentBib}
% \begin{macro}{\PrintBackRefs}
% \begin{macro}{\APACrestorebibitem}
% A bit of code that makes life a little easier, adapted from
% \fname{amsrefs.dtx}.
%    \begin{macrocode}
\def\back@cite{}%
\def\CurrentBib{}%
\def\PrintBackRefs{}%
\def\APACrestorebibitem{}%
\AtBeginDocument{%
  \@ifpackageloaded{backref}{%
%    \end{macrocode}
%   Make sure that \cmd{\ifBR@verbose} is defined.
%    \begin{macrocode}
    \@ifundefined{ifBR@verbose}{%
      \let\ifBR@verbose\iffalse
      \let\fi\fi}{}%
%    \end{macrocode}
%   A backcite command that makes the code of other commands better readable.
%    \begin{macrocode}
    \def\back@cite#1{%
      \ifBR@verbose
        \PackageInfo{backref}{back cite \string`#1\string'}%
      \fi
      \Hy@backout{#1\APAC@extra@b@citeb}%
    }%
%    \end{macrocode}
%   Adaptation of the \cmd{\bibitem} command so that \pkg{backref} does not
%   scan the whole entry. The placement of the backrefs is explicitly done
%   through \cmd{\PrintBackRefs}.
%    \begin{macrocode}
    \def\APACrestorebibitem{%
      \def\BR@@lbibitem[##1]##2{%
        \BRorg@bibitem[{##1}]{##2}%
        \def\CurrentBib{##2\APAC@extra@b@citeb}%
      }%
    }%
%    \end{macrocode}
%   Printing the backrefs: Revert to the standard \pkg{backref} macro.
%    \begin{macrocode}
    \def\PrintBackRefs#1{\BR@backref{#1}}%
  }{%
%    \end{macrocode}
%   Else: \pkg{backref} not loaded.
%    \begin{macrocode}
    \let\back@cite\@gobble
    \let\PrintBackRefs\@gobble
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BR@@lbibitem}
% Frankly, at the moment, I do not completely understand why we need this. But
% I'm sure it was for a good reason when I included this.
%    \begin{macrocode}
\def\BR@@lbibitem[#1]#2#3\par{%
  \BRorg@bibitem[#1]{#2}#3%
  \BR@backref{#2}%
}%
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{\pkg{chapterbib}}
%
% \begin{macro}{\@extra@b@citeb}
% \begin{macro}{\@extra@binfo}
% From the instructions of the \pkg{chapterbib} package.
%    \begin{macrocode}
\@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{}
\gdef\@extra@binfo{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APAC@extra@b@citeb}
% \begin{macro}{\APAC@extra@binfo}
% Replacements of the \pkg{chapterbib} \cmd{\@extra@b@citeb} and
% \cmd{\@extra@binfo} commands. These accumulate all kinds of additional flags
% to accommodate multiple bibliographies of various packages (\pkg{chapterbib},
% \pkg{bibunits}, \pkg{multibbl}).
%    \begin{macrocode}
\def\APAC@extra@b@citeb{\APAC@curr@aux\APAC@bu\@extra@b@citeb}%
\def\APAC@extra@binfo{\APAC@curr@aux\APAC@bu\@extra@binfo}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{\pkg{bibunits}}
%
% \begin{macro}{\APACstd@cite}
% \begin{macro}{\APACstd@nocite}
% \begin{macro}{\APACstd@lbibitem}
% \begin{macro}{\APAC@bu}
% Store the standard \pkg{apacite} definitions.
%    \begin{macrocode}
\AtEndOfPackage{%
  \let\APACstd@cite\cite
  \let\APACstd@nocite\nocite
  \let\APACstd@lbibitem\@lbibitem
}
%    \end{macrocode}
% Default definition, if \pkg{bibunits} is not loaded.
%    \begin{macrocode}
\@ifundefined{APAC@bu}{\def\APAC@bu{}}{}
\AtBeginDocument{%
  \@ifpackageloaded{bibunits}{%
%    \end{macrocode}
%   To mimic \pkg{chapterbib} behavior (with flags etc.).
%    \begin{macrocode}
    \def\APAC@bu{%
      \ifx\cite\std@cite
%    \end{macrocode}
%       Outside a bibunit. The ``|@APACbu|'' strings are intended to minimize
%       the possibility of wrong matches, such as |\b@ex11| = |ex11| from the
%       global aux or |\b@ex11| = |ex1| from bibunit~1. The last `|@|' is
%       similarly intended to avoid confusion if both \pkg{bibunits} and
%       \pkg{chapterbib} are loaded (``|11@1|'' = 11th bibunit, 1st
%       \pkg{chapterbib} unit; ``|1@11|'' = 1st bibunit, 11th
%       \pkg{chapterbib} unit). It seems unlikely that both packages would be
%       used at the same time, but safety first.
%    \begin{macrocode}
        @APACbu0@%
      \else
%    \end{macrocode}
%       Within a bibunit: Use bibunit number to distinguish the bibunits.
%    \begin{macrocode}
        @APACbu\the\@bibunitauxcnt @%
      \fi
    }%
%    \end{macrocode}
%   Standard \pkg{apacite} definition of the \cmd{\cite} and \cmd{\nocite}
%   commands. The latter is mainly necessary to avoid incorrect ``Citation
%   undefined'' warnings.
%    \begin{macrocode}
    \let\std@cite\APACstd@cite
    \let\std@nocite\APACstd@nocite
%    \end{macrocode}
%   Restore the \pkg{apacite} definition of \cmd{\bibitem}, mainly because of
%   the \cmd{\@newciteauxhandle} instead of \cmd{\@auxout}.
%    \begin{macrocode}
    \def\std@lbibitem[#1]#2{%
      \let\@APACtemp@auxout\@newciteauxhandle
      \let\@newciteauxhandle\@bibunitaux
      \APACstd@lbibitem[#1]{#2}%
      \let\@newciteauxhandle\@APACtemp@auxout
    }%
%    \end{macrocode}
%   To make sure everything works whether \pkg{bibunits} is loaded before or
%   after \pkg{apacite}.
%    \begin{macrocode}
    \let\@lbibitem\std@lbibitem
  }{}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{\pkg{bibtopic}}
%
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{bibtopic}{%
%    \end{macrocode}
%   Somewhat rudely disable this command to prevent an undesired error
%   message of \pkg{bibtopic}.
%    \begin{macrocode}
    \renewcommand*\bt@change@thb{\relax}%
  }{%
%    \end{macrocode}
%   These \pkg{bibtopic} hooks are included in the
%   \envirname{thebibliography} environment as generated by
%   \fname{apacite.bst}, so \pkg{bibtopic} should work correctly. If
%   \pkg{bibtopic} is not loaded, they should do nothing.
%    \begin{macrocode}
    \providecommand{\bt@beg@thb@hook}{\relax}
    \providecommand{\bt@end@thb@hook}{\relax}
  }%
}
%    \end{macrocode}
%
% \subsubsection{\pkg{multibbl}}
%
% Almost all of \pkg{multibbl}'s code is redefined here, mainly because
% \pkg{apacite} needs to distinguish which citation refers to which
% bibliography, so that flags can be correctly set whether a citation
% is the first citation to the work from the specific bibliography and
% correctly includes the meta-analysis flags with the various
% bibliographies.
%
% \begin{macro}{\APAC@curr@aux}
% Default flag definition if \pkg{multibbl} is not loaded.
%    \begin{macrocode}
\@ifundefined{APAC@curr@aux}{\def\APAC@curr@aux{}}{}
\AtBeginDocument{%
  \@ifpackageloaded{multibbl}{%
%    \end{macrocode}
%   To mimic \pkg{chapterbib} behavior (with flags etc.).
%    \begin{macrocode}
    \def\APAC@def@curr@aux#1{\def\APAC@curr@aux{@APACaux@#1@}}%
%    \end{macrocode}
% \begin{macro}{\newbibliography}
%   Ditto. This puts the \cmd{\bibcite} commands in |#1.aux| instead of in
%   the main \fname{.aux} file, so that the flags can be differentiated.
%   This also means that the \fname{.aux} file has to be read by \LaTeX{}
%   before it is overwritten.
%    \begin{macrocode}
    \def\newbibliography#1{%
      \APAC@def@curr@aux{#1}%
      \@input@{#1.aux}%
      \begingroup
        \if@filesw
          \expandafter\newwrite\csname #1@auxfile\endcsname
          \expandafter\immediate\openout
            \csname #1@auxfile\endcsname #1.aux\relax
          \typeout{Writing auxiliary file #1.aux }%
        \fi
      \endgroup
    }%%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APAC@mbbl@bibliography}
% \begin{macro}{\bibliography}
%   Add the flag to the bibliography.
%    \begin{macrocode}
    \let\APAC@mbbl@bibliography\bibliography
    \def\bibliography#1#2#3{%
      \APAC@def@curr@aux{#1}%
      \let\@APACtemp@auxout\@newciteauxhandle
      \def\@APACtemp{\csname #1@auxfile\endcsname}%
      \let\@newciteauxhandle\@APACtemp
      \APAC@mbbl@bibliography{#1}{#2}{#3}%
      \let\@newciteauxhandle\@APACtemp@auxout
    }%%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@orig@@cite}
% \begin{macro}{\@@cite}
%   Add an extra argument to \cmd{\@@cite}.
%    \begin{macrocode}
    \let\@orig@@cite\@@cite
    \def\@@cite<#1>[#2]#3#4{%
      \nocite{#3}{#4}%
      \let\@temp@nocite\nocite
      \let\nocite\@gobble
      \APAC@def@curr@aux{#3}%
      \@orig@@cite<#1>[#2]{#4}%
      \let\nocite\@temp@nocite
      \let\@temp@nocite\@undefined
    }%%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@orig@nocite}
% \begin{macro}{\nocite}
%   Add an extra argument to \cmd{\nocite}.
%    \begin{macrocode}
    \let\@orig@nocite\nocite
    \def\nocite#1#2{%
%    \end{macrocode}
%     Define a flag.
%    \begin{macrocode}
      \APAC@def@curr@aux{#1}%
%    \end{macrocode}
%     No flag-setting in \cmd{\nocite}: A no-cite is not a citation,
%     so a subsequent citation may be the first citation.
%    \begin{macrocode}
      \@bsphack
      \ifx\@onlypreamble\document
%    \end{macrocode}
%       Since we are after |\begin{document}| we can do the citations:
%    \begin{macrocode}
        \@for\@citeb:=#2\do{%
          \edef\@citeb{\expandafter\@firstofone\@citeb}%
%    \end{macrocode}
%         \cmd{\@newciteauxhandle} for compatibility with \pkg{multibib};
%         |#1@auxfile| for compatibility with \pkg{multibbl}.
%    \begin{macrocode}
          \@ifundefined{#1@auxfile}{%
            \if@filesw
              \immediate\write\@newciteauxhandle{\string\citation{\@citeb}}%
            \fi
          }{\if@filesw
              \expandafter\immediate%
              \write\csname #1@auxfile\endcsname{\string\citation{\@citeb}}%
            \fi
          }%
          \@ifundefined{b@\@citeb\APAC@extra@b@citeb}{%
            \edef\B@my@dummy{*}%
            \ifx\@citeb\B@my@dummy
            \else
              \G@refundefinedtrue
              \@latex@warning{Citation `\@citeb' undefined}%
            \fi
          }{}%
        }%
      \else
%    \end{macrocode}
%        \pkg{apacite} has no compatibility problems with \LaTeX~2.09,
%        because it does not work with \LaTeX~2.09 anyway, so we can do the
%        following, suggested in \fname{ltbibl.dtx}:
%    \begin{macrocode}
         \AtBeginDocument{\nocite{#1}{#2}}%
      \fi
      \@esphack
%    \end{macrocode}
%     For compatibility with \pkg{multibib}.
%    \begin{macrocode}
      \@restore@auxhandle
    }%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@orig@nocitemeta}
% \begin{macro}{\nocitemeta}
%   Add an extra argument to \cmd{\nocitemeta}.
%    \begin{macrocode}
    \let\@orig@@nocitemeta\nocitemeta
    \def\nocitemeta#1#2{%
      \nocite{#1}{#2}%
      \let\@temp@nocite\nocite
      \let\nocite\@gobble
      \@orig@@nocitemeta{#2}%
      \let\nocite\@temp@nocite
      \let\@temp@nocite\@undefined
    }%
  }{}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{\pkg{multibib}}
%
% From the instructions in \fname{multibib.dtx}.
%    \begin{macrocode}
\providecommand\@newciteauxhandle{\@auxout}
\def\@restore@auxhandle{\gdef\@newciteauxhandle{\@auxout}}
\AtBeginDocument{%
  \@ifundefined{newcites}{\global\let\@restore@auxhandle\relax}{}%
}
%    \end{macrocode}
% List of citation commands.
%    \begin{macrocode}
\if@APAC@classic@cite
\def\@mb@citenamelist{%
  cite,fullcite,shortcite,citeNP,fullciteNP,shortciteNP,%
  citeA,fullciteA,shortciteA,citeauthor,fullciteauthor,shortciteauthor,%
  citeauthorNP,fullciteauthorNP,shortciteauthorNP,%
  citeyear,citeyearNP,nocite,nocitemeta,%
  maskcite,maskfullcite,maskshortcite,maskciteNP,maskfullciteNP,%
  maskshortciteNP,maskciteA,maskfullciteA,maskshortciteA,%
  maskciteauthor,maskfullciteauthor,maskshortciteauthor,%
  maskciteauthorNP,maskfullciteauthorNP,maskshortciteauthorNP,%
  maskciteauthorA,maskfullciteauthorA,maskshortciteauthorA,%
  maskciteyear,maskciteyearNP,masknocite%
}
\fi
\if@APAC@natbib@apa
\AtEndOfPackage{%
%    \end{macrocode}
% The \pkg{natbib} commands, if they haven't been declared already.
%    \begin{macrocode}
\@ifundefined{@mb@citenamelist}{%
  \def\@mb@citenamelist{%
    nocite,citep,citealp,citet,citealt,citeauthor,citefullauthor,%
    citeyearpar,citeyear,citetext,cite,shortcites,citetalias,%
    citepalias,Citet,Citep,Citealt,Citealp,Citeauthor,citenum}%
}{}
%    \end{macrocode}
% The commands \pkg{apacite} adds.
%    \begin{macrocode}
\let\orig@mb@citenamelist\@mb@citenamelist
\edef\@mb@citenamelist{%
  \orig@mb@citenamelist,%
  citeauthort,citeauthorp,citefullauthort,citefullauthorp,Citeauthort,%
  Citeauthorp,Citefullauthort,Citefullauthorp,%
  masknocite,maskcitep,maskcitealp,maskcitet,maskcitealt,%
  maskciteauthor,maskcitefullauthor,maskciteyearpar,maskciteyear,%
  maskcite,maskcitetalias,maskcitepalias,maskCitet,maskCitep,%
  maskCitealt,maskCitealp,maskCiteauthor,maskcitenum,maskciteauthort,%
  maskciteauthorp,maskCitefullauthor,maskCiteauthort,maskCiteauthorp,%
  nocitemeta%
}
}
\fi
%    \end{macrocode}
%
%
% \subsection{Language-specific macros and loading of language file}
% \label{sec:language-code}
%
% This section initializes a number of macros that are likely to be subject
% to redefinition in the language-specific files. Most of these are fairly
% obvious, particularly literal text strings, but some style issues are
% language-specific as well, e.g., whether or not a comma should be inserted
% before the last author. After initializing these macros, \pkg{apacite} tries
% to infer which language-specific (\fname{.apc}) file must be loaded, if any,
% and then loads this file.
%
% \subsubsection{Literal text strings}
%
% \begin{macro}{\onemaskedcitationmsg}
% \begin{macro}{\maskedcitationsmsg}
% Messages that are inserted in the text if citations are masked.
% Put these messages in separate commands so that they're easily
% changed; e.g., for different languages. We use \cmd{\emph} instead
% of \cmd{\textit}, so that this is put upright if it's executed
% within an italic surrounding, and the parentheses are included
% within the \cmd{\emph}, which looks better if this is included in
% another pair of parentheses. But all of this is easily changed.
%    \begin{macrocode}
\newcommand{\onemaskedcitationmsg}[1]{%
    \emph{(#1\ citation removed for masked review)}}
\newcommand{\maskedcitationsmsg}[1]{%
    \emph{(#1\ citations removed for masked review)}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\refname}
% \begin{macro}{\bibname}
% \begin{macro}{\authorindexname}
% The section/chapter headings to be used for the reference list and the
% author index. One of the first two is typically already defined by the
% document class (e.g., \fname{article.cls} defines \cmd{\refname},
% \fname{book.cls} defines \cmd{\bibname}. When using \pkg{babel}, these are
% both redefined at each \cmd{\selectlanguage} invocation. The
% language-specific (\fname{.apc}) file typically should override that, because
% the strings defined by \pkg{babel} are often not the same as the strings
% prescribed by the style guides for Psychology. For example, the standard
% definition of \cmd{\bibname} in English is ``Bibliography'', whereas the
% APA insists on ``References'' (with a few exceptions). In other languages,
% the \cmd{\refname} may also be defined differently from the \pkg{babel}
% definition. See the various \fname{.apc} files for how \pkg{babel} is
% overridden.
%    \begin{macrocode}
\def\refname{References}% Name of ref. list if it's a section.
\def\bibname{References}% Name of ref. list if it's a chapter.
\newcommand{\authorindexname}{Author Index}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACmetaprenote}
% A note used just before the references in the reference list when a
% meta-analysis is reported.
%    \begin{macrocode}
\newcommand{\APACmetaprenote}{%
  References marked with an asterisk indicate studies included in
  the meta-analysis.}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bibmessage}
% \begin{macro}{\bibcomputerprogram}
% \begin{macro}{\bibcomputerprogrammanual}
% \begin{macro}{\bibcomputerprogramandmanual}
% \begin{macro}{\bibcomputersoftware}
% \begin{macro}{\bibcomputersoftwaremanual}
% \begin{macro}{\bibcomputersoftwareandmanual}
% \begin{macro}{\bibprogramminglanguage}
% Commands for specific types of \entryname{@misc} entries. Besides the strings
% themselves (as language-specific text), these are significant in that they
% are recognized by \fname{apacite.bst} and used to modify the formatting of
% the corresponding reference list entries.
%    \begin{macrocode}
\newcommand{\bibmessage}{Msg}% Message, for internet forums and the like
\newcommand{\bibcomputerprogram}{Computer program}
\newcommand{\bibcomputerprogrammanual}{Computer program manual}
\newcommand{\bibcomputerprogramandmanual}{Computer program and manual}
\newcommand{\bibcomputersoftware}{Computer software}
\newcommand{\bibcomputersoftwaremanual}{Computer software manual}
\newcommand{\bibcomputersoftwareandmanual}{Computer software and manual}
\newcommand{\bibprogramminglanguage}{Programming language}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibnodate}
% \begin{macro}{\BIP}
% Two types of ``special'' years: ``no date'' and ``in press''. These are not
% only text strings unlike normal years, but also are recognized by
% \fname{apacite.bst} and treated differently there. Here and in many other
% macros below, the \cmd{\hbox} ensures that \TeX{} does not interpret the
% final period as a sentence-ending period, and thus does not insert the extra
% space associated with that.
%    \begin{macrocode}
\newcommand{\bibnodate}{n.d.\hbox{}}% no date
\newcommand{\BIP}{in press}         % in press
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BOthers}
% \begin{macro}{\BOthersPeriod}
% ``and others''. The argument contains a period to suppress an additional one
% in the reference list, i.e., it is used as |\BOthers{.}| and the period in the
% argument is seen by \BibTeX{}, which does not insert an additional one, so
% that we now correctly get |et al.| and not |et al..| in the reference list.
% The difference between \cmd{\BOthers} and \cmd{\BOthersPeriod} is that the
% latter is used in a context where there should always be a period at the
% end. Given that \BibTeX{} does not insert it because of the mentioned usage
% of a period in the argument, this explicit distinction is necessary here.
% Hence, if an unabbreviated string is used to define these commands, their
% definitions become different. For example,
% \begin{verbatim}
% \renewcommand{\BOthers}{and others}
% \renewcommand{\BOthersPeriod}{and others.}
% \end{verbatim}
% This does not work perfectly if \cmd{\citeauthor} is used at the end of a
% sentence. This is on the todo-list. For the moment, the user will have to
% employ an explicit workaround, i.e., insert an additional period if
% \cmd{\BOthers} does not contain one and omit this period if it does.
%    \begin{macrocode}
\newcommand{\BOthers}[1]{et al.\hbox{}}%       ``and others''
\newcommand{\BOthersPeriod}[1]{et al.\hbox{}}% ``and others.'', with a period
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BIn}
% \begin{macro}{\Bby}
% Used for ``In Editor (Ed.), \emph{Booktitle}'' and
% ``by Editor, Ed., \emph{Booktitle}'', respectively.
%    \begin{macrocode}
\newcommand{\BIn}{In}                 % for ``In '' editor...
\newcommand{\Bby}{by}                 % for ``by '' editor... (in reprints)
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BED}
% \begin{macro}{\BEDS}
% \begin{macro}{\BTRANS}
% \begin{macro}{\BTRANSS}
% \begin{macro}{\BTRANSL}
% \begin{macro}{\BCHAIR}
% \begin{macro}{\BCHAIRS}
% Various types of non-author contributions.
%    \begin{macrocode}
\newcommand{\BED}{Ed.\hbox{}}         % editor
\newcommand{\BEDS}{Eds.\hbox{}}       % editors
\newcommand{\BTRANS}{Trans.\hbox{}}   % translator
\newcommand{\BTRANSS}{Trans.\hbox{}}  % translators
\newcommand{\BTRANSL}{trans.\hbox{}}  % translation, for the year field
\newcommand{\BCHAIR}{Chair}           % chair of symposium
\newcommand{\BCHAIRS}{Chairs}         % chairs
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BVOL}
% \begin{macro}{\BVOLS}
% \begin{macro}{\BNUM}
% \begin{macro}{\BNUMS}
% \begin{macro}{\BEd}
% \begin{macro}{\BCHAP}
% \begin{macro}{\BCHAPS}
% \begin{macro}{\BPG}
% \begin{macro}{\BPGS}
% Various strings that indicate what kind of number is given.
%    \begin{macrocode}
\newcommand{\BVOL}{Vol.\hbox{}}       % volume (of a multi-volume book)
\newcommand{\BVOLS}{Vols.\hbox{}}     % volumes
\newcommand{\BNUM}{No.\hbox{}}        % number (of a technical report)
\newcommand{\BNUMS}{Nos.\hbox{}}      % numbers
\newcommand{\BEd}{ed.\hbox{}}         % edition
\newcommand{\BCHAP}{chap.\hbox{}}     % chapter (for electronic documents)
\newcommand{\BCHAPS}{chap.\hbox{}}    % chapters
\newcommand{\BPG}{p.\hbox{}}          % page
\newcommand{\BPGS}{pp.\hbox{}}        % pages
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BTR}
% \begin{macro}{\BPhD}
% \begin{macro}{\BUPhD}
% \begin{macro}{\BMTh}
% \begin{macro}{\BUMTh}
% Various strings that indicate what kind of work is referenced.
%    \begin{macrocode}
%% Default technical report type name.
\newcommand{\BTR}{Tech.\ Rep.\hbox{}}
%% Default PhD thesis type name.
\newcommand{\BPhD}{Doctoral dissertation}
%% Default unpublished PhD thesis type name.
\newcommand{\BUPhD}{Unpublished doctoral dissertation}
%% Default master's thesis type name.
\newcommand{\BMTh}{Master's thesis}
%% Default unpublished master's thesis type name.
\newcommand{\BUMTh}{Unpublished master's thesis}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BAuthor}
% ``Author'', the string used for the publisher if the publisher is also the
% author of the work.
%    \begin{macrocode}
\newcommand{\BAuthor}{Author}% ``Author'' if publisher = author
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\BOWP}
% \begin{macro}{\BREPR}
% Two strings that are used for reprints and translations.
%    \begin{macrocode}
\newcommand{\BOWP}{Original work published}
\newcommand{\BREPR}{Reprinted from}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BAvailFrom}
% \begin{macro}{\BRetrieved}
% \begin{macro}{\BRetrievedFrom}
% \begin{macro}{\BMsgPostedTo}
% Strings that indicate where on the internet the referenced document was
% obtained.
%    \begin{macrocode}
\newcommand{\BAvailFrom}{Available from\ }%          Websites; note the space.
%% The argument is the date on which it was last checked.
\newcommand{\BRetrieved}[1]{Retrieved {#1}, from\ }% Websites; note the space.
\newcommand{\BRetrievedFrom}{Retrieved from\ }%      Websites; note the space.
\newcommand{\BMsgPostedTo}{Message posted to\ }%     Messages; note the space.
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Punctuation}
%
% Most of this is more style-specific than language specific, but there are
% some punctuation differences between different languages, or even
% ``dialects'' (in \pkg{babel}'s terminology) of the same ``language''.
% Therefore, these are all included here and redefined in the \fname{.apc}
% files.
%
% \begin{macro}{\BBOP}
% \begin{macro}{\BBCP}
% Opening and closing parentheses. Used to enclose the whole citation for a
% parenthetical citation (e.g., \cmd{\cite}), only the year and post-note for
% in-text citations (e.g., \cmd{\citeA}), and the year (and month and day, if
% present) in the reference list. If different punctuation is desired for
% the reference than used in citations, these commands can be redefined
% immediately before the location of the \cmd{\bibliography} command. If
% different punctuation is desired for parenthetical citations than for in-text
% citations (seems unlikely), the citation commands themselves have to be
% redefined.
%    \begin{macrocode}
\newcommand{\BBOP}{(}   % opening parenthesis
\newcommand{\BBCP}{)}   % closing parenthesis
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BBOQ}
% \begin{macro}{\BBCQ}
% Opening and closing quotes for article-type titles in the reference list.
%    \begin{macrocode}
\newcommand{\BBOQ}{}    % opening quote for article title
\newcommand{\BBCQ}{}    % closing quote for article title
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BBAA}
% \begin{macro}{\BBAB}
% \begin{macro}{\BAnd}
% Three forms of ``and''. Of course, the word ``and'' is a literal text string,
% so this part could also have been allocated to the the section that handles
% those.
%    \begin{macrocode}
\newcommand{\BBAA}{\&}  % between authors in parenthetical cites and ref. list
\newcommand{\BBAB}{and} % between authors in in-text citation
\newcommand{\BAnd}{\&}  % for ``Ed. \& Trans.'' in ref. list
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BPBI}
% \begin{macro}{\BHBI}
% Punctuation between initials. This is primarily used to reduce or eliminate
% space between initials. Note that there is currently not a similar command
% for the last period after the initials, so that removing the periods in these
% macros will generally give undesirable results.
%    \begin{macrocode}
\DeclareRobustCommand{\BPBI}{.~}% Period between initials
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BAP}
% \begin{macro}{\BBAY}
% \begin{macro}{\BBYY}
% \begin{macro}{\BBC}
% \begin{macro}{\BBN}
% \begin{macro}{\BCBT}
% \begin{macro}{\BCBL}
% \begin{macro}{\BDBL}
% Punctuation between various parts of citations and reference list entries.
%    \begin{macrocode}
\newcommand{\BAP}{ }    % after prefix, before first citation
\newcommand{\BBAY}{, }  % between author(s) and year
\newcommand{\BBYY}{, }  % between years of multiple citations with same author
\newcommand{\BBC}{; }   % between cites
\newcommand{\BBN}{, }   % before note
\newcommand{\BCBT}{,}   % comma between authors in ref. list when no. of
                       %% authors = 2
\newcommand{\BCBL}{,}   % comma before last author when no. of authors > 2
\newcommand{\BDBL}{, \dots{} }% dots before last author when no. of authors > 7
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Date formatting}
%
% This consists of literal strings (names of the months), relative ordering of
% year, month, and day, and punctuation between the elements.
%
% \begin{macro}{\APACmonth}
% This takes one argument. If it is a number between 1 and 12, the name of
% the corresponding month is produced (1 = January, \dots, 12 = December),
% and 13--16 represent the seasons. Anything else is copied literally. In this
% way, other kinds of dates can be handled as well, such as
% ``August/September''. Note that this in its turn can be flexibly entered
% as |\APACmonth{08}/\APACmonth{09}| in the \fname{.bib} file.
%    \begin{macrocode}
\newcommand{\APACmonth}[1]{\ifcase #1\or January\or February\or March\or
    April\or May\or June\or July\or August\or September\or October\or
    November\or December\or Winter\or Spring\or Summer\or Fall\else
    {#1}\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACrefYearMonthDay}
% Year, month, and day in the reference list. Often used for newspaper articles
% and presentations at conferences. By default, this results in something like
% ``(2005, July~5)''. The month and day should be seen as parenthetical
% refinements of the year, so that in other languages, the year should be
% named first as well, regardless of the conventions for representing dates in
% such languages.
%    \begin{macrocode}
\newcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%           year (+ addendum); should not be empty
  \ifx\@empty#2\@empty
    \ifx\@empty#3\@empty
    \else
      \unskip, {#3}%     day
    \fi
  \else
    \unskip, {#2}%       month
    \ifx\@empty#3\@empty
    \else
      \unskip~{#3}%      day
    \fi
  \fi
  {\BBCP}%               closing parenthesis
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACdate}
% A date in the ordinary form, like \cmd{\today}. This is needed for processing
% the \fieldname{lastchecked} field. Should be able to handle dates in both
% typical \LaTeX{} input format (|2005/07/05|) and ISO format
% (|2005-07-05|, possibly with time after it, which will be ignored). Maybe
% other formats as well; e.g., |20050705|, as in the Un*x |touch| command.
% Not yet implemented.
% \end{macro}
%
% \subsubsection{Ordinal numbers}
%
% Some functions, for use with the \fieldname{edition} field, which transform
% a (cardinal) number (``1'', ``2'', \dots) to an ordinal number (``1st'',
% ``2nd'', \dots).
%
% I copied the functions here literally from \fname{amsrefs.dtx} (starting
% with \cmd{\PrintEdition} there) and made only one slight adaptation: removing
% \cmd{\editiontext}. In the \APACversiondate{2007/09/03} version of
% \pkg{apacite}, \cmd{\PrintOrdinal} and \cmd{\print@ordinal} were called
% \cmd{\PrintCardinal} and \cmd{\print@cardinal}, respectively, and what is
% called ``ordinal'' now was called ``cardinal''. This terminology was copied
% from the documentation of \pkg{amsrefs}, but it is incorrect and has
% therefore been changed in the current version. This causes a slight
% incompatibility between versions of \pkg{apacite}. So in case users have
% redefined one of these macros to fit their own needs, they should rename
% these accordingly. Note, however, that the current version of \pkg{apacite}
% redefines these macros in the language-specific files, so for most users,
% this will presumably be sufficient.
%
% \begin{macro}{\@xp}
% Abbreviation.
%    \begin{macrocode}
\let\@xp\expandafter
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PrintOrdinal}
% \begin{macro}{\print@ordinal}
% \begin{macro}{\CardinalNumeric}
% \begin{macro}{\keep@last@digit}
% |\PrintOrdinal{2}| gives ``2nd'', etc. If the argument is not an integer
% number, it is copied literally to the output. At least, apparently, because
% I do not really understand how it works. The \pkg{amsrefs} documentation
% suggests that \cmd{\CardinalNumeric} already gives the ordinal number
% (incorrectly called ``cardinal number'' there), and the name
% \cmd{\CardinalNumeric} without `|@|' sign likewise suggests that it is a
% user command, but some tests using this give garbage. Therefore,
% \cmd{\PrintOrdinal} (a slight adaptation of \pkg{amsrefs}'
% \cmd{\PrintEdition}) is the command that ultimately should be used.
%    \begin{macrocode}
\newcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\z@
            \CardinalNumeric\count@
        \else
            ??th%
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}
\newcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        th%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1th\or st\or nd\or rd\else th\fi
    \fi
}
\def\keep@last@digit#1#2{%
    \ifx\relax#2%
        \@xp\@gobbletwo
    \else
        #1=#2\relax
    \fi
    \keep@last@digit#1%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Load language dependent sections from an external file. Based on code by
% Stefan Bj\"ork [2004/12/25], although heavily modified.
%    \begin{macrocode}
\AtBeginDocument{%
%    \end{macrocode}
% Both \pkg{babel} and \pkg{(n)german} use \cmd{\iflanguage} to check the main
% language. They both also use \cmd{\languagename}, but that gives more
% problems with ``dialects''. For example, if \cmd{\languagename} = |austrian|
% then |\iflanguage{german}{Yes}{No}| gives Yes. This allows us to provide only
% \fname{.apc} files for the language class without complicated code to check
% whether a certain ``dialect'' is used.
%
% Check whether \cmd{\iflanguage} is defined. If not, no language support
% is offered.
%    \begin{macrocode}
  \@ifundefined{iflanguage}%
    {\relax }%
    {%
%    \end{macrocode}
%     Some \TeX{} distributions automatically preload \pkg{babel} with default
%     language ``|nohyphenation|'', so this language should revert to doing
%     nothing. Strangely enough, \cmd{\iflanguage} does not work correctly, so
%     I'll use a trick. (Some trial and error, because \fname{babel.dtx} states
%     that there must be a ``\verb*+\string +'' before the ``|nohyphenation|'',
%     but apparently in this situation this is not the case.)
%    \begin{macrocode}
      \edef\APAC@tmp{nohyphenation}%
      \ifx\languagename\APAC@tmp
      \else
%    \end{macrocode}
%       Check whether $\langle$\cmd{\languagename}$\rangle$\fname{.apc} exists.
%       If so, load this file.
%    \begin{macrocode}
        \InputIfFileExists{\languagename.apc}{}{%
%    \end{macrocode}
%       Else, i.e., $\langle$\cmd{\languagename}$\rangle$\fname{.apc} does not
%       exist. Try whether the current language is a dialect of one of the
%       known languages. This is not perfect, because languages for which no
%       hyphenation patterns have been found revert to the default language,
%       so that the wrong language file may be loaded here in that case. Also,
%       |UKenglish| uses different hyphenation patterns from |english|. I have
%       to find a better way to solve this.
%
% \begin{macro}{\APAC@iflang}
%       Define a modification of \cmd{\iflanguage} that executes the ``true''
%       code if the language is defined and equal to the current language and
%       does nothing otherwise. (Just \cmd{\iflanguage} gives an error if the
%       language is not loaded.)
%    \begin{macrocode}
          \def\APAC@iflang##1##2{%
            \expandafter\ifx\csname l@##1\endcsname\relax
            \else
              \ifnum\csname l@##1\endcsname=\language
                {##2}%
              \fi
            \fi
          }%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APAC@apcfile}
%         Define the language support file. The \cmd{\def} instead of a direct
%         \cmd{\input} is done to provide a mechanism to check whether any
%         language file has been defined.
%    \begin{macrocode}
          \APAC@iflang{dutch}{\gdef\APAC@apcfile{dutch.apc}}%
          \APAC@iflang{finnish}{\gdef\APAC@apcfile{finnish.apc}}%
          \APAC@iflang{french}{\gdef\APAC@apcfile{french.apc}}%
          \APAC@iflang{german}{\gdef\APAC@apcfile{german.apc}}%
          \APAC@iflang{ngerman}{\gdef\APAC@apcfile{ngerman.apc}}%
          \APAC@iflang{greek}{\gdef\APAC@apcfile{greek.apc}}%
          \APAC@iflang{norsk}{\gdef\APAC@apcfile{norsk.apc}}%
          \APAC@iflang{spanish}{\gdef\APAC@apcfile{spanish.apc}}%
          \APAC@iflang{swedish}{\gdef\APAC@apcfile{swedish.apc}}%
%    \end{macrocode}
%         The hyphenation patterns for UK English are different from
%         US English, so this needs to be accommodated explicitly to avoid a
%         warning. Australian, New Zealand, and Canadian all use either the
%         British or American hyphenation patterns, so do not need to be
%         treated separately here.
%    \begin{macrocode}
          \APAC@iflang{UKenglish}{\gdef\APAC@apcfile{english.apc}}%
%    \end{macrocode}
%         The default English as the last one. If a language is loaded without
%         hyphenation patterns, the English hyphenation patterns are used by
%         default in \pkg{babel}. In such a case, both this particular
%         language and English give a hit. Having English as the last one
%         means that in such a case, \pkg{apacite} assigns English,
%         corresponding with \pkg{babel}'s default.
%    \begin{macrocode}
          \APAC@iflang{english}{\gdef\APAC@apcfile{english.apc}}%
%    \end{macrocode}
% \end{macro}
%
%         Give a warning if the process so far has not resulted in a target
%         language file, or if the target language file cannot be found.
%    \begin{macrocode}
          \@ifundefined{APAC@apcfile}{%
            \PackageWarningNoLine{apacite}{%
              No suitable language definition file (\languagename.apc) found}%
          }{%
             \InputIfFileExists{\APAC@apcfile}{}{%
               \PackageWarningNoLine{apacite}{%
                 Language definition file \APAC@apcfile\space not found}%
             }%
          }%
%    \end{macrocode}
%         Clear up some macros that are no longer needed.
%    \begin{macrocode}
          \let\APAC@apcfile\@undefined
        }%
      \fi
      \let\APAC@tmp\@undefined
    }%
    \let\APAC@iflang\@undefined
}
%%
%</package>
%    \end{macrocode}
%
%
% \section{Documentation package (\fname{apacdoc.sty})}
% The \pkg{apacdoc} package is written for generating the \pkg{apacite}
% user's manual. But it also contains a few commands that are too
% experimental or otherwise unsuitable to be included in \fname{apacite.sty},
% but which are necessary to format some examples from the APA manual
% correctly. As such, these commands may be useful for users if they
% encounter similar citation problems. In such a case, it is probably
% better to copy the definitions of the desired commands to the top
% of your \fname{.tex} document (before \verb+\begin{document}+) or
% to a tailor-made \fname{.sty} file, rather than loading the \pkg{apacdoc}
% package.
%
%    \begin{macrocode}
%<*docpkg>
%%
%% apacdoc.sty : Style package that is used for the apacite documentation.
%% Written by Erik Meijer
%    \end{macrocode}
% \subsection{Options}
% \begin{macro}{\if@APACdoc@AX}
% Generate author index?
%    \begin{macrocode}
\newif\if@APACdoc@AX
\DeclareOption{makeAX}{\@APACdoc@AXtrue}%
\@APACdoc@AXfalse
\ProcessOptions
%    \end{macrocode}
% \end{macro}
%
% \subsection{Document-specific definitions that may be useful for wider use}
% \begin{macro}{\bibliteral}
% \begin{macro}{\bibinitial}
% Echo argument literally. Can be used to define a certain author type
% (``Producer'') in a place where \BibTeX{} expects a first name.
% Using this command between a pair of braces makes sure that the text
% is not abbreviated into an initial.
% This is the result of lots of trial and error. If I change something
% in another part, I typically have to change something here as well.
% The \verb+\space+ is necessary because in the current setup, an additional
% space is inserted in the bibliography, and \MakeIndex{} is space-sensitive.
%    \begin{macrocode}
%% \DeclareRobustCommand{\bibliteral}[1]{\string\bibliteral{#1}}
%% \newcommand{\bibliteral}[1]{#1}
%% \newcommand{\bibliteral}[1]{\string\bibliteral{#1}}
\newcommand{\bibliteral}[1]{\string\bibliteral\space{#1}}
\DeclareRobustCommand{\bibinitial}[1]{\string#1}
%% \newcommand{\bibinitial}{\string\bibinitial\space}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibnodot}
% If the argument is a period (`|.|'), \BibTeX{} puts no period after it.
%    \begin{macrocode}
\newcommand{\bibnodot}[1]{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SwapArgs}
% Reverse order of the two arguments. Can be used for various reasons,
% mostly related to sorting in the reference list.
%    \begin{macrocode}
\newcommand{\SwapArgs}[2]{#2#1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bibreftext}
% \begin{macro}{\Dutchvon}
% The following macro is especially useful if the \fieldname{year}
% field must be different in the text and the reference list,
% e.g., ``1992/1993'' in the text and ``1992'' in reference list.
% Then \fieldname{year} can be defined as |\bibreftext{1992}{1992/1993}|.
% The definition below displays only the second argument (``text'').
% Just before the reference list, this can then be redefined to
% display only the first argument (``ref'').
%    \begin{macrocode}
\newcommand{\bibreftext}[2]{#2}
%    \end{macrocode}
% The same command, but now intended for Dutch-style ``von'' parts,
% so in order to create some flexibility in formatting items from
% a \fname{.bib} file, it is useful to have a separate macro for
% this application.
%    \begin{macrocode}
\newcommand{\Dutchvon}[2]{#2}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibeditortype}
% \begin{macro}{\renewbibeditortype}
% The following macro changes the definitions of the macros \cmd{\BED}
% and \cmd{\BEDS} to the argument of this macro and then immediately
% changes the definitions back to their old definitions. So it makes a
% one-time change. Can be used to use ``Producer'' instead of ``Ed.''
% etc.
%    \begin{macrocode}
\DeclareRobustCommand{\bibeditortype}[1]{\relax }%
\def\renewbibeditortype{%
  \def\oldBED{}%
  \def\oldBEDS{}%
  \DeclareRobustCommand{\bibeditortype}[1]{%
    \global\let\oldBED\BED
    \global\let\oldBEDS\BEDS
    \global\def\BED{##1\global\let\BED\oldBED  \global\let\BEDS\oldBEDS}%
    \global\def\BEDS{##1\global\let\BED\oldBED \global\let\BEDS\oldBEDS}%
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibInstring}
% \begin{macro}{\BOn}
% The following macro changes the definition of the macro \cmd{\BIn} to the
% argument and then immediately changes the definition back to the old
% definition. So it makes a one-time change. Can be used to use ``On''
% instead of ``In'' for a CD-track, for which  \cmd{\BOn} is supplied.
%    \begin{macrocode}
\newcommand{\bibInstring}[1]{%
  \global\let\oldBIn\BIn
  \global\def\BIn{#1\global\let\BIn\oldBIn}%
}
\newcommand{\BOn}{On}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BAbstractRetrieved}
% \begin{macro}{\BmakeAbstractRetrieved}
% The following macros are used to change ``Retrieved'' into
% ``Abstract retrieved''. They use the same principle as
% \cmd{\renewbibeditortype}.
%    \begin{macrocode}
\global\def\BAbstractRetrieved#1{Abstract retrieved {#1}, from\ }%
\DeclareRobustCommand{\BmakeAbstractRetrieved}{%
  \global\def\oldBRetrieved{}%
  \global\let\oldBRetrieved\BRetrieved
  \global\def\BRetrieved##1{%
     \BAbstractRetrieved{##1}%
     \global\let\BRetrieved\oldBRetrieved%
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\noedition}
% Suppress ``ed.'' to format ``Version 4.0'' in an \fieldname{edition}
% field.
%    \begin{macrocode}
\DeclareRobustCommand{\noedition}{%
  \global\def\oldBEd{}%
  \global\let\oldBEd\BEd
  \global\def\BEd{%
     \unskip
     \global\let\BEd\oldBEd
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\swallownext}
% \begin{macro}{\swallowdot}
% \begin{macro}{\bibskipbracenodot}
% \begin{macro}{\indexskipbracenodot}
% The \cmd{\bibskipbracenodot} macro suppresses the period after a
% following closing brace. It does not work entirely well at the
% moment. In particular, it works differently in an \cmd{\AX} macro
% in text and an \cmd{\AX} macro in the reference list. This probably
% has something to do with robust vs.\ fragile macros and/or expansion
% of the macro. I have experimented a lot with many variations, but
% don't seem to get it right. I don't understand these issues well yet.
% \cmd{\swallownext} swallows its argument; \cmd{\swallowdot} swallows
% the next character if it's a period.
%    \begin{macrocode}
\def\swallownext#1{\relax}
\def\swallowdot{%
    \@ifnextchar.%
      {\swallownext}%
      {\relax}%
}
%    \end{macrocode}
% When the above does not work, \cmd{\bibskipbracenodot} should reduce
% to nothing. This is the current definition. Just before the
% bibliography, it is redefined. \cmd{\indexskipbracenodot} has the
% same purpose, but for the author index instead of the reference list.
%    \begin{macrocode}
%% \def\bibskipbracenodot{\string\bibskipbracenodot}
%% \def\bibskipbracenodot{\aftergroup\swallowdot}
%% \let\bibskipbracenodot\relax
\def\bibskipbracenodot{\noexpand\bibskipbracenodot}
\def\indexskipbracenodot{\noexpand\indexskipbracenodot}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACmanBeforeBib}
% Redefine commands that should be different in the bibliography.
%    \begin{macrocode}
\newcommand{\APACmanBeforeBib}{%
    \renewcommand{\bibreftext}[2]{##1}%
    \renewcommand{\Dutchvon}[2]{##1}%
    \renewbibeditortype
    \global\let\oldbibskipbracenodot\bibskipbracenodot
    \global\def\bibskipbracenodot{\aftergroup\swallowdot}%
    \global\let\oldbibliteral\bibliteral
    \renewcommand{\bibliteral}[1]{##1}%
    \global\let\oldbibinitial\bibinitial
    \renewcommand{\bibinitial}[1]{##1}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACbibstyle}
% Dirty trick: request \fname{apacitex.bst} if \pkg{apacite} is loaded
% with one of the index options, and request \fname{apacite.bst}
% otherwise.
%    \begin{macrocode}
\def\APACbibstyle{%
  \if@APAC@index
    apacitex% with index option
  \else
    apacite% without index option
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACmanBeforeIndex}
% Redefine commands that should be different in the author index.
%    \begin{macrocode}
\newcommand{\APACmanBeforeIndex}{%
    \clearpage
    \renewcommand{\bibeditortype}[1]{}%
    \renewcommand{\bibliteral}[1]{\unskip}%
    \global\let\indexskipbracenodot\bibskipbracenodot
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACmanAfterIndex}
% Revert to the old definitions of commands after the index.
%    \begin{macrocode}
\newcommand{\APACmanAfterIndex}{%
    \global\let\bibskipbracenodot\oldbibskipbracenodot
    \global\def\indexskipbracenodot{\noexpand\indexskipbracenodot}%
    \APACdocindex
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SetupAPACdocPrologues}
% Redefine some indexing-related commands from \fname{doc.sty} and
% \fname{ltxdoc.cls}. Unfortunately, I couldn't get the code index
% and change history working with the \pkg{index} package, so I have
% to tweak everything so that the \pkg{apacite} manual does not use the
% \pkg{index} package (which is loaded by apacite when an
% \pkgoption{index} option is requested).
%    \begin{macrocode}
\newcommand{\SetupAPACdocPrologues}{%
  \@ifundefined{IndexPrologue}{}{%
    \IndexPrologue{%
      \clearpage\section*{{Code Index}}%
      \addcontentsline{toc}{section}{Code Index}%
      \markboth{{Code Index}}{{Code Index}}%
      Numbers written in italic refer to the page where the corresponding
      entry is described; numbers underlined refer to the
      \ifcodeline@index
        code line of the
      \fi
      definition; numbers in roman refer to the
      \ifcodeline@index
        code lines
      \else
        pages
      \fi
      where the entry is used.
    }%
  }%
  \@ifundefined{GlossaryPrologue}{}{%
    \GlossaryPrologue{\section{{Change History}}%
      \markboth{{Change History}}{{Change History}}%
    }%
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACdocindex}
% From \fname{doc.dtx}.
%    \begin{macrocode}
\def\APACdocindex{%
    \ifhave@multicol
      \renewenvironment{theindex}
        {\begin{multicols}\c@IndexColumns[\index@prologue][\IndexMin]%
          \IndexParms \let\item\@idxitem \ignorespaces}%
        {\end{multicols}}
    \else
      \typeout{Can't find multicol.sty -- will use normal index layout if
         necessary.}
      \def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
        \columnseprule \z@  \columnsep 35\p@
        \twocolumn[\index@prologue]%
        \IndexParms \let\item\@idxitem \ignorespaces}
      \def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
    \fi
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Citations to the Bible}
% The \emph{APA manual} gives some rules how the Bible and other
% classic works should be cited. These rules are not implemented
% in standard \pkg{apacite}, so I provide a workaround here. This
% needs to be fixed and generalized because the \emph{APA manual}
% now also gives a Qur'an example.
%
% \begin{macro}{\bibleversion}
% \begin{macro}{\@bibleversion}
% To define which Bible version one has used.
%    \begin{macrocode}
\def\bibleversion#1{\gdef\@bibleversion{#1}}
\def\@bibleversion{Revised Standard Version}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibleciteA}
% \begin{macro}{\fullbibleciteA}
% \begin{macro}{\shortbibleciteA}
% \begin{macro}{\biblecite}
% \begin{macro}{\fullbiblecite}
% \begin{macro}{\shortbiblecite}
% \begin{macro}{\bibleciteNP}
% \begin{macro}{\fullbibleciteNP}
% \begin{macro}{\shortbibleciteNP}
% The Bible citation commands follow the same names and syntax as the
% ordinary citation commands, except that ``|bible|'' is inserted in
% the command names.
%    \begin{macrocode}
\def\bibleciteA#1{%
   {\@ifundefined{flag@bible}%
      {\fullbibleciteA{#1}}%
      {\shortbibleciteA{#1}}%
   }%
}
\def\fullbibleciteA#1{%
%    \end{macrocode}
% Insert chapter and verse.
%    \begin{macrocode}
   {#1}%
%    \end{macrocode}
% Add Bible version.
%    \begin{macrocode}
   { \BBOP\@bibleversion\BBCP}%
%    \end{macrocode}
% Flag that the Bible has been cited.
%    \begin{macrocode}
   {\global\expandafter\def\csname flag@bible\endcsname{DUMMY}}%
}
\def\shortbibleciteA#1{%
   {#1}%
%    \end{macrocode}
% Is this appropriate to flag that Bible has been cited, given that
% we don't give the version here?
%    \begin{macrocode}
   {\global\expandafter\def\csname flag@bible\endcsname{DUMMY}}%
}
\def\biblecite#1{%
   {\@ifundefined{flag@bible}%
      {\fullbiblecite{#1}}%
      {\shortbiblecite{#1}}%
   }%
}
\def\fullbiblecite#1{%
   {\BBOP}%
   {#1}%
   {\BBAY{} \@bibleversion}%
   {\BBCP}%
   {\global\expandafter\def\csname flag@bible\endcsname{DUMMY}}%
}
\def\shortbiblecite#1{%
   {\BBOP}%
   {#1}%
   {\BBCP}%
   {\global\expandafter\def\csname flag@bible\endcsname{DUMMY}}%
}
\def\bibleciteNP#1{%
   {\@ifundefined{flag@bible}%
      {\fullbibleciteNP{#1}}%
      {\shortbibleciteNP{#1}}%
   }%
}
\def\fullbibleciteNP#1{%
   {#1}%
   {\BBAY{} \@bibleversion}%
   {\global\expandafter\def\csname flag@bible\endcsname{DUMMY}}%
}
\def\shortbibleciteNP#1{%
   {#1}%
   {\global\expandafter\def\csname flag@bible\endcsname{DUMMY}}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Citing songs}
% The \emph{APA manual} gives some rules how songs should be cited.
% These rules require some tweaking of standard \pkg{apacite}. This is
% done here.
%
% \begin{macro}{\bibsong}
% \begin{macro}{\citeAsong}
% \begin{macro}{\fullciteAsong}
% \begin{macro}{\shortciteAsong}
% \begin{macro}{\citesong}
% \begin{macro}{\fullcitesong}
% \begin{macro}{\shortcitesong}
% \begin{macro}{\citesongNP}
% \begin{macro}{\fullcitesongNP}
% \begin{macro}{\shortcitesongNP}
% The names of these macros are a bit internally inconsistent and
% inconsistent with the \cmd{\biblecite} and \cmd{DSMcite} suites.
% Fix this in a next version.
%    \begin{macrocode}
\newcommand{\bibsong}[4]{}
\newcommand{\citeAsong}[1]{%
  \def\bibsong##1##2##3##4{%
    \APACciteatitle{##3} {\BBOP}{##1}{\BBAY}{##2}{\BBN}{##4}{\BBCP}%
  }%
  \citeauthor{#1}%
  \def\bibsong##1##2##3##4{}%
}
\newcommand{\fullciteAsong}[1]{%
  \def\bibsong##1##2##3##4{%
    \APACciteatitle{##3} {\BBOP}{##1}{\BBAY}{##2}{\BBN}{##4}{\BBCP}%
  }%
  \fullciteauthor{#1}%
  \def\bibsong##1##2##3##4{}%
}
\newcommand{\shortciteAsong}[1]{%
  \def\bibsong##1##2##3##4{%
    \APACciteatitle{##3} {\BBOP}{##1}{\BBAY}{##2}{\BBN}{##4}{\BBCP}%
  }%
  \shortciteauthor{#1}%
  \def\bibsong##1##2##3##4{}%
}
\newcommand{\citesong}[1]{%
  \def\bibsong##1##2##3##4{%
    {\BBOP}\APACciteatitle{##3},{\BAP}{##1}{\BBAY}{##2}{\BBN}{##4}%
    {\BBCP}%
  }%
  \citeauthor{#1}%
  \def\bibsong##1##2##3##4{}%
}
\newcommand{\fullcitesong}[1]{%
  \def\bibsong##1##2##3##4{%
    {\BBOP}\APACciteatitle{##3},{\BAP}{##1}{\BBAY}{##2}{\BBN}{##4}%
    {\BBCP}%
  }%
  \fullciteauthor{#1}%
  \def\bibsong##1##2##3##4{}%
}
\newcommand{\shortcitesong}[1]{%
  \def\bibsong##1##2##3##4{%
    {\BBOP}\APACciteatitle{##3},{\BAP}{##1}{\BBAY}{##2}{\BBN}{##4}%
    {\BBCP}%
  }%
  \shortciteauthor{#1}%
  \def\bibsong##1##2##3##4{}%
}
\newcommand{\citesongNP}[1]{%
  \def\bibsong##1##2##3##4{%
    \APACciteatitle{##3},{\BAP}{##1}{\BBAY}{##2}{\BBN}{##4}%
  }%
  \citeauthor{#1}%
  \def\bibsong##1##2##3##4{}%
}
\newcommand{\fullcitesongNP}[1]{%
  \def\bibsong##1##2##3##4{%
    \APACciteatitle{##3},{\BAP}{##1}{\BBAY}{##2}{\BBN}{##4}%
  }%
  \fullciteauthor{#1}%
  \def\bibsong##1##2##3##4{}%
}
\newcommand{\shortcitesongNP}[1]{%
  \def\bibsong##1##2##3##4{%
    \APACciteatitle{##3},{\BAP}{##1}{\BBAY}{##2}{\BBN}{##4}%
  }%
  \shortciteauthor{#1}%
  \def\bibsong##1##2##3##4{}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Commands to cite the \emph{DSM}}
% The \emph{APA manual} gives some rules how the \emph{DSM} should be
% cited, which is a bit different from ordinary citations. These rules
% are not implemented in standard \pkg{apacite}, so I provide a
% workaround here.
%
% \begin{macro}{\bibDSM}
% \begin{macro}{\origbibDSM}
% \begin{macro}{\DSMauthor}
% \begin{macro}{\DSMfulltitle}
% \begin{macro}{\DSMshorttitle}
% \begin{macro}{\DSMedition}
% The \cmd{\bibDSM} macro has four arguments: (1) author, (2) full
% title, (3) edition, (4) abbreviated title. The default definition
% prints the author, so this gives something decent if an ordinary
% citation command is used. The other macros extract the separate
% arguments.
%    \begin{macrocode}
\DeclareRobustCommand{\bibDSM}[4]{#1}
\newcommand\origbibDSM{}
\let\origbibDSM\bibDSM
\newcommand{\DSMauthor}[1]{%
  \def\bibDSM##1##2##3##4{##1}%
  \citeauthor{#1}%
  \let\bibDSM\origbibDSM
}
\newcommand{\DSMfulltitle}[1]{%
  \def\bibDSM##1##2##3##4{##2}%
  \citeauthor{#1}%
  \let\bibDSM\origbibDSM
}
\newcommand{\DSMshorttitle}[1]{%
  \def\bibDSM##1##2##3##4{##4}%
  \citeauthor{#1}%
  \let\bibDSM\origbibDSM
}
\newcommand{\DSMedition}[1]{%
  \def\bibDSM##1##2##3##4{##3}%
  \citeauthor{#1}%
  \let\bibDSM\origbibDSM
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\DSMciteA}
% \begin{macro}{\DSMfullciteA}
% \begin{macro}{\DSMshortciteA}
% \begin{macro}{\DSMcite}
% \begin{macro}{\DSMfullcite}
% \begin{macro}{\DSMshortcite}
% \begin{macro}{\DSMciteNP}
% \begin{macro}{\DSMfullciteNP}
% \begin{macro}{\DSMshortciteNP}
% The \emph{DSM} citation commands follow the same names and syntax as the
% ordinary citation commands, except that ``|DSM|'' is inserted in
% the command names.
%    \begin{macrocode}
\newcommand{\DSMciteA}[1]{%
    \@for\@citeb:=#1\do{%
      \edef\@citeb{\expandafter\@firstofone\@citeb}%
      \@ifundefined{flag@\@citeb\APAC@extra@b@citeb}%
         {\DSMfullciteA{#1}}%
         {\DSMshortciteA{#1}}%
    }%
}
\newcommand{\DSMfullciteA}[1]{%
%    \end{macrocode}
% \emph{Full Title} (edition; \emph{Short Title}; author, year)
%    \begin{macrocode}
  \APACcitebtitle{\DSMfulltitle{#1}}
  \BBOP
  \DSMedition{#1};
  \APACcitebtitle{\DSMshorttitle{#1}};
  \citeNP{#1}%
  \BBCP
}
\newcommand{\DSMshortciteA}[1]{%
%    \end{macrocode}
% \emph{Short Title}
%    \begin{macrocode}
  \APACcitebtitle{\DSMshorttitle{#1}}%
}
\newcommand{\DSMcite}[1]{%
    \@for\@citeb:=#1\do{%
      \edef\@citeb{\expandafter\@firstofone\@citeb}%
      \@ifundefined{flag@\@citeb\APAC@extra@b@citeb}%
         {\DSMfullcite{#1}}%
         {\DSMshortcite{#1}}%
    }%
}
\newcommand{\DSMfullcite}[1]{%
  \BBOP
  \APACcitebtitle{\DSMfulltitle{#1}},
  \DSMedition{#1};
  \APACcitebtitle{\DSMshorttitle{#1}};
  \citeNP{#1}%
  \BBCP
}
\newcommand{\DSMshortcite}[1]{%
  \BBOP\APACcitebtitle{\DSMshorttitle{#1}}\BBCP
}
\newcommand{\DSMciteNP}[1]{%
    \@for\@citeb:=#1\do{%
      \edef\@citeb{\expandafter\@firstofone\@citeb}%
      \@ifundefined{flag@\@citeb\APAC@extra@b@citeb}%
         {\DSMfullciteNP{#1}}%
         {\DSMshortciteNP{#1}}%
    }%
}
\newcommand{\DSMfullciteNP}[1]{%
  \APACcitebtitle{\DSMfulltitle{#1}},
  \DSMedition{#1};
  \APACcitebtitle{\DSMshorttitle{#1}};
  \citeNP{#1}%
}
\newcommand{\DSMshortciteNP}[1]{%
  \APACcitebtitle{\DSMshorttitle{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Document-specific definitions}
%
% \begin{macro}{\SetupAPACdoc}
% These are some commands that are used in the \pkg{apacite} manual,
% but are presumably not especially relevant for users.
%
% \begin{macro}{\MiKTeX}
% \begin{macro}{\BibTeX}
% \begin{macro}{\MakeIndex}
% \begin{macro}{\latextohtml}
% \begin{macro}{\LaTeXrtf}
% \begin{macro}{\TeXht}
% \begin{macro}{\Perl}
% Names of programs and packages.
%    \begin{macrocode}
\newcommand{\SetupAPACdoc}{%
  \newcommand{\MiKTeX}{MiK\TeX}
  \@ifundefined{BibTeX}{%
    \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
        T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}% from bibtex.web
  }{}
  \newcommand{\MakeIndex}{\textit{MakeIndex}}
  \newcommand{\latextohtml}{\textup{\LaTeX2\texttt{HTML}}}% from html.sty
  \newcommand{\LaTeXrtf}{\textup{\LaTeX2RTF}}%
  \newcommand{\TeXht}{\textup{\TeX4ht}}%
  \newcommand{\Perl}{\textsl{Perl}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\EM}
% My comments accompanying the examples. To be removed with better
% source code documentation.
%    \begin{macrocode}
  \newcommand{\EM}{\ensuremath{\triangleright\quad}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACversiondate}
% The date of a version of \pkg{apacite}. Makes it easy to search the
% document for these dates. The \cmd{\relax} is a safety measure
% (probably not needed), which ensures that the square brackets are
% never interpreted as an optional argument.
%    \begin{macrocode}
  \newcommand{\APACversiondate}[1]{\relax [##1]}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LC}
% \begin{macro}{\X}
% \begin{macro}{\Y}
% \begin{macro}{\A}
% Some symbols that are used in the \pkg{apacite} manual.
%    \begin{macrocode}
  \newcommand{\LC}{\mbox{${}^{\dag}$}}% \LaTeX{} Companion
  \newcommand{\X}{\ensuremath{\times}}% for one table
  \newcommand{\Y}{\ensuremath{c}}% for one table
  \newcommand{\A}{\ensuremath{a}}% for one table
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pkg}
% \begin{macro}{\fname}
% \begin{macro}{\fieldname}
% \begin{macro}{\entryname}
% \begin{macro}{\pkgoption}
% \begin{macro}{\envirname}
% Formatting of package names, options, etc.
%    \begin{macrocode}
  \newcommand{\pkg}[1]{\textsf{##1}}% package name
  \newcommand{\fname}[1]{\texttt{##1}}% file name
  \newcommand{\fieldname}[1]{\texttt{##1}}% field name
  \newcommand{\entryname}[1]{\texttt{##1}}% entry type name
  \newcommand{\pkgoption}[1]{\texttt{##1}}% package option
  \newcommand{\envirname}[1]{\texttt{##1}}% environment name
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\cmd}
% \begin{macro}{\bs}
% \begin{macro}{\opt}
% \begin{macro}{\cmdtwo}
% \begin{macro}{\cmdthree}
% \begin{macro}{\cmdthreepre}
% \begin{macro}{\cmdthreealt}
% \begin{macro}{\cmdfour}
% Formatting of macros.
%    \begin{macrocode}
  \AtBeginDocument{%
    \@ifundefined{cmd}{%
      \newcommand{\cmd}[1]{\texttt{\string##1}}% command, incl. `\'
    }{}%
  }
%    \end{macrocode}
% Some trickery with backslashes and |@| signs.
%    \begin{macrocode}
  \newcommand{\bs}{{\ttfamily \@backslashchar}}% backslash
  \newcommand{\opt}[1]{$\langle${\itshape ##1}$\rangle$}% generic text
%    \end{macrocode}
% For \cmdtwo{nocite}{keys}:
%    \begin{macrocode}
  \newcommand{\cmdtwo}[2]{{\mdseries\bs\texttt{##1\{}\opt{##2}%
                          \texttt{\}}}}%
%    \end{macrocode}
% For \cmdthree{cite}{post}{keys}:
%    \begin{macrocode}
  \newcommand{\cmdthree}[3]{{\mdseries\bs\texttt{##1[}\opt{##2}%
                          \texttt{]\{}\opt{##3}%
                          \texttt{\}}}}%
%    \end{macrocode}
% For \cmdthreepre{cite}{pre}{keys}:
%    \begin{macrocode}
  \newcommand{\cmdthreepre}[3]{{\mdseries\bs\texttt{##1<}\opt{##2}%
                          \texttt{>\{}\opt{##3}%
                          \texttt{\}}}}%
%    \end{macrocode}
% For \cmdthreealt{usepackage}{options}{apacite}:
%    \begin{macrocode}
  \newcommand{\cmdthreealt}[3]{{\mdseries\bs\texttt{##1[}\opt{##2}%
                          \texttt{]\{##3\}}}}%
%    \end{macrocode}
% For all \cmdfour{cite}{pre}{post}{keys} variants:
%    \begin{macrocode}
  \newcommand{\cmdfour}[4]{{\mdseries\bs\texttt{##1<}\opt{##2}%
                          \texttt{>[}\opt{##3}%
                          \texttt{]\{}\opt{##4}%
                          \texttt{\}}}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\flqq}
% \begin{macro}{\frqq}
% \begin{macro}{\simpleguillemots}
% It is not clear where and how the \cmd{\flqq} command is defined, so
% provide an escape if it is not available. Use definitions from
% \fname{fguill.sty} included here to avoid requiring a package that
% may not be available. This can probably be improved by using
% \cmd{\providecommand}.
%    \begin{macrocode}
  \AtBeginDocument{%
    \@ifundefined{flqq}{%
      \newcommand{\flqq}{%
        {\fontencoding{T1}\fontfamily{cmr}\selectfont\symbol{19}}}%
      \newcommand{\frqq}{%
        {\fontencoding{T1}\fontfamily{cmr}\selectfont\symbol{20}}}%
    }{}%
  }%
  \newcommand{\simpleguillemots}{%
    \renewcommand{\flqq}{\raisebox{2.5pt}{%
      \tiny{\ensuremath{\mathord{<\!\!<}}}}}%
    \renewcommand{\frqq}{\raisebox{2.5pt}{%
      \tiny{\ensuremath{\mathord{>\!\!>}}}}}%
  }%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\APACdocPageLayout}
% The basic page setup of the \pkg{apacite} manual.
%    \begin{macrocode}
  \newcommand{\APACdocPageLayout}{%
      \normalsize
      \let\oldhoffset\hoffset
      \let\oldvoffset\voffset
      \let\oldoddsidemargin\oddsidemargin
      \let\oldevensidemargin\evensidemargin
      \let\oldtopmargin\topmargin
      \let\oldheadheight\headheight
      \let\oldheadsep\headsep
      \let\oldtextheight\textheight
      \let\oldfootskip\footskip
      \let\oldtextwidth\textwidth
      \let\oldlinewidth\linewidth
      \let\oldmarginparsep\marginparsep
      \let\oldmarginparwidth\marginparwidth
      \let\oldmarginparpush\marginparpush
      %%
      %% \setlength{\hoffset}{-1in} % top-left reference point is
      \setlength{\voffset}{-1in} % the top-left corner of the page
      %% \setlength{\oddsidemargin}{1.3in}
      %% \setlength{\evensidemargin}{1.3in}
      \setlength{\topmargin}{1.35in}
      %% %% \setlength{\headheight}{\baselineskip}
      \setlength{\headheight}{0.12in}
      \setlength{\headsep}{0.24in}
      \setlength{\textheight}{7.9in}
      \setlength{\footskip}{30pt}
      %% \setlength{\textwidth}{5.9in}
      %% \setlength{\linewidth}{\textwidth}
      %% \setlength{\marginparsep}{0pt}
      %% \setlength{\marginparwidth}{0pt}
      %% \setlength{\marginparpush}{0pt}
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\APACcodePageLayout}
% The page setup of the source code documentation part of the
% \pkg{apacite} manual.
%    \begin{macrocode}
  \newcommand{\APACcodePageLayout}{%
      \let\hoffset\oldhoffset
      \let\oddsidemargin\oldoddsidemargin
      \let\evensidemargin\oldevensidemargin
      \let\textwidth\oldtextwidth
      \let\linewidth\oldlinewidth
      \let\marginparsep\oldmarginparsep
      \let\marginparwidth\oldmarginparwidth
      \let\marginparpush\oldmarginparpush
  }
}
%%
%</docpkg>
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \section{Language definition files}
%
% This section describes the code for the language-specific files
% supplied with \pkg{apacite}.
%
% \subsection{\fname{english.apc}}
%
% This file redefines the language-specific elements of \pkg{apacite}
% for the English language and its ``dialects'' in \pkg{babel}
% terminology.
%
%    \begin{macrocode}
%<*english>
%%
%% english.apc - english version of apacite elements
%% Written by Erik Meijer
%%
%    \end{macrocode}
% A fancy way to store and restore the category code of the |@| sign,
% per Heiko Oberdiek.
%    \begin{macrocode}
\edef\APACrestoreAtCode{%
   \catcode`@=\the\catcode`@\relax
}%
\makeatletter
\renewcommand{\onemaskedcitationmsg}[1]{%
    \emph{(#1\ citation removed for masked review)}}%
\renewcommand{\maskedcitationsmsg}[1]{%
    \emph{(#1\ citations removed for masked review)}}%
\renewcommand{\refname}{References}% Name of ref. list if it's a section.
\renewcommand{\bibname}{References}% Name of ref. list if it's a chapter.
\renewcommand{\authorindexname}{Author Index}% Name of Author Index
%%
%% A note before the references if a meta-analysis is reported.
\renewcommand{\APACmetaprenote}{%
  References marked with an asterisk indicate studies
  included in the meta-analysis.}%
%%
%% Commands for specific types of @misc entries.
\renewcommand{\bibmessage}{Msg}%
\renewcommand{\bibcomputerprogram}{Computer program}%
\renewcommand{\bibcomputerprogrammanual}{Computer program manual}%
\renewcommand{\bibcomputerprogramandmanual}{Computer program and manual}%
\renewcommand{\bibcomputersoftware}{Computer software}%
\renewcommand{\bibcomputersoftwaremanual}{Computer software manual}%
\renewcommand{\bibcomputersoftwareandmanual}{Computer software and manual}%
\renewcommand{\bibprogramminglanguage}{Programming language}%
%%
%% Other labels
\renewcommand{\bibnodate}{n.d.\hbox{}}%   % ``no date''
\renewcommand{\BIP}{in press}%            % ``in press''
\renewcommand{\BOthers}[1]{et al.\hbox{}}% ``and others''
\renewcommand{\BOthersPeriod}[1]{et al.\hbox{}}% ``and others'' with a period
\renewcommand{\BIn}{In}%                  % for ``In '' editor...
\renewcommand{\Bby}{by}%                  % for ``by '' editor... (in reprints)
\renewcommand{\BED}{Ed.\hbox{}}%          % editor
\renewcommand{\BEDS}{Eds.\hbox{}}%        % editors
\renewcommand{\BTRANS}{Trans.\hbox{}}%    % translator
\renewcommand{\BTRANSS}{Trans.\hbox{}}%   % translators
\renewcommand{\BTRANSL}{trans.\hbox{}}%   % translation, for the year field
\renewcommand{\BCHAIR}{Chair}%            % chair of symposium
\renewcommand{\BCHAIRS}{Chairs}%          % chairs
\renewcommand{\BVOL}{Vol.\hbox{}}%        % volume
\renewcommand{\BVOLS}{Vols.\hbox{}}%      % volumes
\renewcommand{\BNUM}{No.\hbox{}}%         % number
\renewcommand{\BNUMS}{Nos.\hbox{}}%       % numbers
\renewcommand{\BEd}{ed.\hbox{}}%          % edition
\renewcommand{\BCHAP}{chap.\hbox{}}%      % chapter
\renewcommand{\BCHAPS}{chap.\hbox{}}%     % chapters
\renewcommand{\BPG}{p.\hbox{}}%           % page
\renewcommand{\BPGS}{pp.\hbox{}}%         % pages
%% Default technical report type name.
\renewcommand{\BTR}{Tech.\ Rep.\hbox{}}
%% Default PhD thesis type name.
\renewcommand{\BPhD}{Doctoral dissertation}
%% Default unpublished PhD thesis type name.
\renewcommand{\BUPhD}{Unpublished doctoral dissertation}
%% Default master's thesis type name.
\renewcommand{\BMTh}{Master's thesis}
%% Default unpublished master's thesis type name.
\renewcommand{\BUMTh}{Unpublished master's thesis}
%%
\renewcommand{\BAuthor}{Author}% ``Author'' if publisher = author
\renewcommand{\BOWP}{Original work published}%
\renewcommand{\BREPR}{Reprinted from}%
\renewcommand{\BAvailFrom}{Available from\ }%        Websites; note the space.
%% The argument is the date on which it was last checked.
\renewcommand{\BRetrieved}[1]{Retrieved {#1}, from\ }% Websites; note the space.
\renewcommand{\BRetrievedFrom}{Retrieved from\ }% Websites; note the space.
\renewcommand{\BMsgPostedTo}{Message posted to\ }%     Messages; note the space.
%%
%% Punctuation
\renewcommand{\BBOP}{(}%   opening parenthesis
\renewcommand{\BBCP}{)}%   closing parenthesis
\renewcommand{\BBOQ}{}%    opening quote for article title
\renewcommand{\BBCQ}{}%    closing quote for article title
\renewcommand{\BBAA}{\&}%  between authors in parenthetical cites and ref. list
\renewcommand{\BBAB}{and}% between authors in in-text citation
\renewcommand{\BAnd}{\&}%  for ``Ed. \& Trans.'' in ref. list
\DeclareRobustCommand{\BPBI}{.~}% Period between initials
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
\renewcommand{\BAP}{ }%   after prefix, before first citation
\renewcommand{\BBAY}{, }% between author(s) and year
\renewcommand{\BBYY}{, }% between years of multiple citations with same author
\renewcommand{\BBC}{; }%  between cites
\renewcommand{\BBN}{, }%  before note
\renewcommand{\BCBT}{,}%  comma between authors in ref. list when no. of
                      %%  authors = 2
\renewcommand{\BCBL}{,}%  comma before last author when no. of authors > 2
%%
%% Date formatting
\renewcommand{\APACmonth}[1]{\ifcase #1\or January\or February\or March\or
    April\or May\or June\or July\or August\or September\or October\or
    November\or December\or Winter\or Spring\or Summer\or Fall\else
    {#1}\fi}%
\renewcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%           year (+ addendum); should not be empty
  \ifx\@empty#2\@empty
    \ifx\@empty#3\@empty
    \else
      \unskip, {#3}%     day
    \fi
  \else
    \unskip, {#2}%       month
    \ifx\@empty#3\@empty
    \else
      \unskip~{#3}%      day
    \fi
  \fi
  {\BBCP}%               closing parenthesis
}%
%% Some macros that transform a number (say, `2') to an ordinal one (`2nd')
\renewcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}%
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\z@
            \CardinalNumeric\count@
        \else
            ??th%
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}%
\renewcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        th%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1th\or st\or nd\or rd\else th\fi
    \fi
}%
%    \end{macrocode}
% Differences between different versions of English, in particular British
% and Australian vs.\ the default American.
%    \begin{macrocode}
\def\APAC@tempb{US}%
\edef\APAC@tempa{\string UKenglish}%
\ifx\languagename\APAC@tempa
    \def\APAC@tempb{UK}%
\fi
\edef\APAC@tempa{\string british}%
\ifx\languagename\APAC@tempa
    \def\APAC@tempb{UK}%
\fi
\def\APAC@tempa{UK}
\ifx\APAC@tempa\APAC@tempb
    \renewcommand{\BCBT}{}% no comma before `\&' in British
    \renewcommand{\BCBL}{}% no comma before `\&' in British
%    \end{macrocode}
% According to \pkg{babel}'s \fname{english.dtx}, in UK English, the date
% is of the form 1st~January, although I thought January~1st was more common.
%    \begin{macrocode}
    \renewcommand{\APACrefYearMonthDay}[3]{%
      {\BBOP}{#1}%           year (+ addendum); should not be empty
      \ifx\@empty#3\@empty
        \ifx\@empty#2\@empty
        \else
          \unskip, {#2}%     month
        \fi
      \else
        \unskip, {\PrintOrdinal{#3}}%   day
        \ifx\@empty#2\@empty
        \else
          \unskip~{#2}%      month
        \fi
      \fi
      {\BBCP}%               closing parenthesis
    }%
\fi
%%
\edef\APAC@tempa{\string australian}%
\ifx\languagename\APAC@tempa
    \def\APAC@tempb{AU}%
\fi
%    \end{macrocode}
% New Zealand is equivalent to Australian for our purposes.
%    \begin{macrocode}
\edef\APAC@tempa{\string newzealand}%
\ifx\languagename\APAC@tempa
    \def\APAC@tempb{AU}%
\fi
\def\APAC@tempa{AU}
\ifx\APAC@tempa\APAC@tempb
    \renewcommand{\BCBT}{}% no comma before `\&' in AU/NZ (?)
    \renewcommand{\BCBL}{}% no comma before `\&' in AU/NZ (?)
%    \end{macrocode}
% According to \pkg{babel}'s \fname{english.dtx}, In Australian and New
% Zealand, the date is of the form 1~January.
%    \begin{macrocode}
    \renewcommand{\APACrefYearMonthDay}[3]{%
      {\BBOP}{#1}%           year (+ addendum); should not be empty
      \ifx\@empty#3\@empty
        \ifx\@empty#2\@empty
        \else
          \unskip, {#2}%     month
        \fi
      \else
        \unskip, {#3}%       day
        \ifx\@empty#2\@empty
        \else
          \unskip~{#2}%      month
        \fi
      \fi
      {\BBCP}%               closing parenthesis
    }%
\fi
%    \end{macrocode}
% Clear up some macros that are no longer needed.
%    \begin{macrocode}
\let\APAC@tempa\@undefined
\let\APAC@tempb\@undefined
%    \end{macrocode}
% Restore category code of |@| sign.
%    \begin{macrocode}
\APACrestoreAtCode
%</english>
%    \end{macrocode}
%
%
%
% \subsection{\fname{dutch.apc}}
%
% This file redefines the language-specific elements of \pkg{apacite}
% for the Dutch language. The \pkg{babel} package considers Afrikaans
% as a ``dialect'' of Dutch, but my limited knowledge of Afrikaans
% suggests that most words are spelt differently (though are phonetically
% similar), and many other words are simply different. So I doubt whether
% this file can be directly applied to Afrikaans.
%
% For compiling the translated elements, the following sources were
% used:
% \begin{enumerate}
% \item Instructions for the Dutch psychology journal ``De Psycholoog''
%       \cite{DePsych01}; indicated below as ``DP''.
% \item Instructions for the Dutch psychology journal ``Nederlands Tijdschrift
%       voor de Psychologie en haar Grensgebieden'' \cite{NTPG04};
%       indicated below as ``NTPG''.
% \item Instructions from the well-known book
%       \APACcitebtitle{Schrijfwijzer} \cite[pp.~404--410]{Renk02};
%       indicated below as ``SW''.
% \item The previous three all state that their rules are adapted from the
%       APA manual. For translations that are not explicitly mentioned in
%       these sources, I used the extensive reference list from \citeA{Schr04}.
% \item Finally, I consulted the \emph{Van Dale} English-Dutch dictionary
%       \cite{VanDale89}.
% \end{enumerate}
%
%    \begin{macrocode}
%<*dutch>
%%
%% dutch.apc - dutch translation of apacite elements
%% Written by Erik Meijer
%%
%% DP   = De Psycholoog
%% NTPG = Nederlands Tijdschrift voor de Psychologie en haar Grensgebieden
%% SW   = Schrijfwijzer
%%
%    \end{macrocode}
% A fancy way to store and restore the category code of the |@| sign,
% per Heiko Oberdiek.
%    \begin{macrocode}
\edef\APACrestoreAtCode{%
   \catcode`@=\the\catcode`@\relax
}%
\makeatletter
%%
%    \end{macrocode}
%
% Name of the reference list according to DP and NTPG.
% SW gives the following general names:
% \begin{itemize}
% \item
% ``Literatuuropgave'' [literally approx. ``Literature specification'']
% \item
% ``Literatuurlijst''  [literally ``Literature list'']
% \end{itemize}
% For more specific applications, SW gives the following names:
% \begin{itemize}
% \item
% ``Bibliografie'' [``Bibliography'', ``a more or less complete survey
%                  of publications in a certain area'']
% \item
% ``Geraadpleegde literatuur'' [``Consulted literature'']
% \item
% ``Aangehaalde literatuur'' [``Referenced literature'']
% \end{itemize}
%
%    \begin{macrocode}
\renewcommand{\onemaskedcitationmsg}[1]{%
    \emph{(#1\ citation removed for masked review)}}% !!! CHANGE
\renewcommand{\maskedcitationsmsg}[1]{%
    \emph{(#1\ citations removed for masked review)}}% !!! CHANGE
\renewcommand{\refname}{Literatuur}% Name of ref. list if it's a section.
\renewcommand{\bibname}{Literatuur}% Name of ref. list if it's a chapter.
\renewcommand{\authorindexname}{Auteursindex}% Name of author index
%%
%% A note before the references if a meta-analysis is reported.
%%
\renewcommand{\APACmetaprenote}{%
  Met een asterisk gemarkeerde referenties betreffen studies die in de
  meta-analyse zijn gebruikt.}%
%%
%% Commands for specific types of @misc entries.
\renewcommand{\bibmessage}{Bericht}%
\renewcommand{\bibcomputerprogram}{Computerprogramma}%
\renewcommand{\bibcomputerprogrammanual}{Handleiding van computerprogramma}%
\renewcommand{\bibcomputerprogramandmanual}{Computerprogramma en handleiding}%
\renewcommand{\bibcomputersoftware}{Computersoftware}%
\renewcommand{\bibcomputersoftwaremanual}{Handleiding van computersoftware}%
\renewcommand{\bibcomputersoftwareandmanual}{Computersoftware en handleiding}%
\renewcommand{\bibprogramminglanguage}{Programmeertaal}%
%%
%% Other labels
\renewcommand{\bibnodate}{z.~j.\hbox{}}% [SW] (``zonder jaartal'')
\renewcommand{\BIP}{te verschijnen}%   % [SW]
\renewcommand{\BOthers}[1]{et al.\hbox{}}%       % [DP]
\renewcommand{\BOthersPeriod}[1]{et al.\hbox{}}% % [DP]
%% NTPG requires the following, SW allows both variants:
%% \renewcommand{\BOthers}[1]{e.~a.\hbox{}}%       % [NTPG]
%% \renewcommand{\BOthersPeriod}[1]{e.~a.\hbox{}}% % [NTPG]
%%
\renewcommand{\BIn}{In}%    % for ``In '' editor...
\renewcommand{\Bby}{door}%  % for ``by '' editor... (in reprints)
%    \end{macrocode}
%
% ``Editor(s)'' is almost impossible to get right in Dutch, because SW
% and DP require the translation of ``editor(s)'' to be dependent on
% the language in which the referenced work is written:
% \begin{itemize}
% \item
% ``Red.'' (or ``red.'') for referenced works in Dutch
% \item
% ``Ed.''/``Eds.''       for referenced works in English
% \item
% ``Hrsg.''              for referenced works in German
% \item
% ``edt.''               for referenced works in French
% \end{itemize}
% NTPG does not give an explicit rule for this, but only an example
% in which an English work is referenced and ``Ed.'' is used.
%
% For the moment, I think it makes most sense to give the Dutch versions here:
%    \begin{macrocode}
\renewcommand{\BED}{red.\hbox{}}%          % [DP] (SW gives ``Red.'')
\renewcommand{\BEDS}{red.\hbox{}}%         % [DP] (SW gives ``Red.'')
%    \end{macrocode}
%
% Translators should not be mentioned according to DP.
% NTPG does not explain how to format this.
% SW gives a completely different format: ``Vertaald door:''
% [``Translated by:''] followed by the name of the translator, or if the
% translator is unknown: ``Vertaling van:'' [``Translation of:'']
% followed by the original title. This is much too complicated, so I'll
% choose a simple alternative.
%    \begin{macrocode}
\renewcommand{\BTRANS}{vert.\hbox{}}%   translator
\renewcommand{\BTRANSS}{vert.\hbox{}}%  translators
\renewcommand{\BTRANSL}{vert.\hbox{}}%  translation, for the year field
%%
\renewcommand{\BCHAIR}{voorz.\hbox{}}%  chair of symposium
\renewcommand{\BCHAIRS}{voorz.\hbox{}}% chairs
%    \end{macrocode}
%
% ``Volume'' according to SW. NTPG gives an example with ``Vol.'' but this is
% presumably dependent on the language of the referenced work as well.
%    \begin{macrocode}
\renewcommand{\BVOL}{Dl.\hbox{}}%       volume  [SW]
\renewcommand{\BVOLS}{Dl.\hbox{}}%      volumes [SW]
\renewcommand{\BNUM}{nr.\hbox{}}%       number  [SW]
\renewcommand{\BNUMS}{nr.\hbox{}}%      numbers [SW]
\renewcommand{\BEd}{dr.\hbox{}}%        edition [SW]
\renewcommand{\BCHAP}{hfdst.\hbox{}}%   chapter
\renewcommand{\BCHAPS}{hfdst.\hbox{}}%  chapters
\renewcommand{\BPG}{p.\hbox{}}%         page
\renewcommand{\BPGS}{pp.\hbox{}}% pages [SW]. DP gives ``p.'', NTPG both.
%    \end{macrocode}
% Literally translating ``Tech.'' as ``Technisch'' does not make sense.
%    \begin{macrocode}
%% Default technical report type name.
\renewcommand{\BTR}{Rapport}%
%    \end{macrocode}
% There is no Dutch ``DAI'' and the distinction between ``published'' and
% ``unpublished'' PhD theses would generally be interpreted as ``published as
% a book with an official publisher'' vs.\ ``privately published''. All PhD
% theses in the Netherlands are required to be published with an ISBN number.
% Therefore, in my view it is better to use the same term for ``published''
% and ``unpublished''. (\citeNP{Schr04} use ``dissertatie''.)
%    \begin{macrocode}
%% Default PhD thesis type name.
\renewcommand{\BUPhD}{Academisch proefschrift}% ``published''
\renewcommand{\BPhD}{Academisch proefschrift}%  ``unpublished''
%    \end{macrocode}
% There is no official forum to publish abstracts of master's theses either,
% but, unlike PhD theses, they are (generally) unpublished.
% The term used here refers to the Dutch educational system until ca. 2003.
% Since ca. 2004, universities are gradually converting to a
% bachelor--master system, so it's likely that this term will have to be
% adapted in the near future.
%    \begin{macrocode}
%% Default master's thesis type name.
\renewcommand{\BMTh}{Doctoraalscriptie}%  ``published''
\renewcommand{\BUMTh}{Doctoraalscriptie}% ``unpublished''
%%
\renewcommand{\BAuthor}{Auteur}% ``Author'' if publisher = author
%    \end{macrocode}
% From DP. They also require the original title after the
% \fieldname{originalyear}. This is not implemented here.
%    \begin{macrocode}
\renewcommand{\BOWP}{Oorspronkelijke editie}% Original work published
\renewcommand{\BREPR}{Overgenomen uit}%       Reprinted from
%%
%% THE NEXT FOUR ARE MY OWN TRANSLATIONS. CHECK!!!
%% Websites and newsgroups; note the spaces.
\renewcommand{\BAvailFrom}{Verkrijgbaar van\ }%
%% The argument is the date on which it was last checked.
\renewcommand{\BRetrieved}[1]{Op {#1} verkregen van\ }%
\renewcommand{\BRetrievedFrom}{Verkregen van\ }%
\renewcommand{\BMsgPostedTo}{Bericht geplaatst op\ }%
%%
%% Punctuation
\renewcommand{\BBOP}{(}% opening parenthesis
\renewcommand{\BBCP}{)}% closing parenthesis
\renewcommand{\BBOQ}{}%  opening quote for article title
\renewcommand{\BBCQ}{}%  closing quote for article title
\renewcommand{\BBAA}{\&}%  between authors in parenthetical cites and ref. list
\renewcommand{\BBAB}{en}%  between authors in in-text citation
\renewcommand{\BAnd}{\&}%  for ``Ed. \& Trans.'' in ref. list
\DeclareRobustCommand{\BPBI}{.~}% Period between initials
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
\renewcommand{\BAP}{ }%   after prefix, before first citation
\renewcommand{\BBAY}{, }% between author(s) and year
\renewcommand{\BBYY}{, }% between years of multiple citations with same author
\renewcommand{\BBC}{; }%  between cites
\renewcommand{\BBN}{, }%  before note
%%
%% No commas according to DP and SW. NTPG uses the US/APA comma.
\renewcommand{\BCBT}{}%  comma between authors in ref. list when no. of
                     %%  authors = 2
\renewcommand{\BCBL}{}%    comma before last author when no. of authors > 2
%%
%% Date formatting
\renewcommand{\APACmonth}[1]{\ifcase #1\or januari\or februari\or maart\or
    april\or mei\or juni\or juli\or augustus\or september\or oktober\or
    november\or december\or winter\or lente\or zomer\or herfst\else
    {#1}\fi}%
\renewcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%           year (+ addendum); should not be empty
  \ifx\@empty#3\@empty
    \ifx\@empty#2\@empty
    \else
      \unskip, {#2}%     month
    \fi
  \else
    \unskip, {#3}%       day
    \ifx\@empty#2\@empty
    \else
      \unskip~{#2}%      month
    \fi
  \fi
  {\BBCP}%               closing parenthesis
}%
%% Some macros that transform a number (say, `2') to a ordinal one (`2nd')
\renewcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}%
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\z@
            \CardinalNumeric\count@
        \else
            ??e%
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}%
%    \end{macrocode}
% Dutch ordinal numbers are always obtained by simply putting an `e' after
% the number, so this (and perhaps the code above) can be significantly
% simplified. However, because I have trouble understanding this code (from
% the \pkg{amsrefs} package) and experimenting did not give the expected
% results, I won't mess with the code too much and stay close to the
% English code.
%    \begin{macrocode}
\renewcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        e%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1e\else e\fi
    \fi
}%
%    \end{macrocode}
% Restore category code of |@| sign.
%    \begin{macrocode}
\APACrestoreAtCode
%</dutch>
%    \end{macrocode}
%
%
%
% \subsection{\fname{finnish.apc}}
%
% This file redefines the language-specific elements of \pkg{apacite}
% for the Finnish language. Based on \citeA[Appendix~E]{KLO05}.
%
%    \begin{macrocode}
%<*finnish>
%%
%% finnish.apc - finnish version of apacite elements
%% Written by Kari Pyykk\"o, with some minor edits by Erik Meijer.
%%
%    \end{macrocode}
% A fancy way to store and restore the category code of the |@| sign,
% per Heiko Oberdiek.
%    \begin{macrocode}
\edef\APACrestoreAtCode{%
   \catcode`@=\the\catcode`@\relax
}%
\makeatletter
\renewcommand{\onemaskedcitationmsg}[1]{%
    \emph{(#1\ citation removed for masked review)}}% !!! CHANGE
\renewcommand{\maskedcitationsmsg}[1]{%
    \emph{(#1\ citations removed for masked review)}}% !!! CHANGE
\renewcommand{\refname}{Viitteet}% Name of ref. list if it's a section.
\renewcommand{\bibname}{Viitteet}% Name of ref. list if it's a chapter.
\renewcommand{\authorindexname}{Tekij\"ahakemisto}% Name of Author Index
%%
%% A note before the references if a meta-analysis is reported.
\renewcommand{\APACmetaprenote}{%
  Viitteet merkitty t\"ahtimerkeill\"a osoittaen opintojen
  sis\"altymist\"a meta-analyysiin.}%
%%
%% Commands for specific types of @misc entries.
%%
%% Msg
\renewcommand{\bibmessage}{Sanoma}%
%%
%% Computer program
\renewcommand{\bibcomputerprogram}{Tietokoneohjelma}%
%%
%% Computer program manual
\renewcommand{\bibcomputerprogrammanual}{Tietokoneohjelman k\"asikirja}%
%%
%% Computer program and manual
\renewcommand{\bibcomputerprogramandmanual}{Tietokoneohjelma ja k\"asikirja}%
%%
%% Computer software
\renewcommand{\bibcomputersoftware}{Ohjelmisto}%
%%
%% Computer software manual
\renewcommand{\bibcomputersoftwaremanual}{Ohjelmiston k\"asikirja}%
%%
%% Computer software and manual
\renewcommand{\bibcomputersoftwareandmanual}{Ohjelmisto ja k\"asikirja}%
%%
%% Programming language
\renewcommand{\bibprogramminglanguage}{Ohjelmointikieli}%
%%
%%
%% Other labels
%%
%% n.d.
\renewcommand{\bibnodate}{s.a.\hbox{}}%  ``no date'', ``sine anno''
%%
%% in press
\renewcommand{\BIP}{painossa}%        % used as year for in-press citations
%%
%% et al.: ``and others'', not necessarily with a period
\renewcommand{\BOthers}[1]{et al.\hbox{}}%
%%
%% et al.: ``and others'' with a period
\renewcommand{\BOthersPeriod}[1]{et al.\hbox{}}%
%%
%% In
\renewcommand{\BIn}{Teoksessa}%             ``In'' editor...
%%
%% by
\renewcommand{\Bby}{teoksesta}%             ``by'' editor... (in reprints)
%%
%% Ed.
\renewcommand{\BED}{toim.\hbox{}}%          editor
%%
%% Eds.
\renewcommand{\BEDS}{toim.\hbox{}}%         editors
%%
%% Trans.
\renewcommand{\BTRANS}{k\"a\"ant.\hbox{}}%  translator
%%
%% Trans.
\renewcommand{\BTRANSS}{k\"a\"ant.\hbox{}}% translators
%%
%% trans.
\renewcommand{\BTRANSL}{k\"a\"an.\hbox{}}%  translation, for the year field
%%
%% Chair
\renewcommand{\BCHAIR}{pj.\hbox{}}%         chair of symposium
%%
%% Chairs
\renewcommand{\BCHAIRS}{pj.\hbox{}}%        chairs
%%
%% Vol.
\renewcommand{\BVOL}{osa}%                  volume
%%
%% Vols.
\renewcommand{\BVOLS}{osat}%                volumes
%%
%% No.
\renewcommand{\BNUM}{nro}%                  number
%%
%% Nos.
\renewcommand{\BNUMS}{nro}%                 numbers
%%
%% ed.
\renewcommand{\BEd}{p.\hbox{}}%             edition
%%
%% chap.
\renewcommand{\BCHAP}{luku}%                chapter
%%
%% chap.
\renewcommand{\BCHAPS}{luvut}%              chapters
%%
%% p.
\renewcommand{\BPG}{s.\hbox{}}%             page
%%
%% pp.
\renewcommand{\BPGS}{s.\hbox{}}%            pages
%%
%% Tech.\ Rep.
\renewcommand{\BTR}{Tekn.\ rap.\hbox{}}%    (default) technical report type name
%%
%% (default) PhD thesis type name
\renewcommand{\BPhD}{V\"ait\"oskirja}%
%%
%% (default) unpublished PhD thesis type name
\renewcommand{\BUPhD}{Julkaisematon v\"ait\"oskirja}%
%%
%% (default) master's thesis type name
\renewcommand{\BMTh}{Pro gradu -tutkielma}%
%%
%% (default) unpublished master's thesis type name
\renewcommand{\BUMTh}{Julkaisematon pro gradu -tutkielma}%
%%
\renewcommand{\BAuthor}{Tekij\"a}% ``Author'' if publisher = author
%%
%% Original work published
\renewcommand{\BOWP}{Alkuaan julk.\hbox{}}%
%%
%% Reprinted from
\renewcommand{\BREPR}{Uudelleen julk.\hbox{}}%
%%
%% (websites) Available from; note the space.
\renewcommand{\BAvailFrom}{Saatavilla\ }%
%%
%% (websites) Retrieved ... from; note the space.
%% The argument is the date on which it was last checked.
\renewcommand{\BRetrieved}[1]{Lainattu {#1}, saatavilla\ }%
\renewcommand{\BRetrievedFrom}{Lainattu saatavilla\ }%
%%
%% (newsgroups \& forums) Message posted to; note the space.
\renewcommand{\BMsgPostedTo}{Viesti l\"ahetetty\ }%
%%
%% Punctuation
\renewcommand{\BBOP}{(}%   opening parenthesis
\renewcommand{\BBCP}{)}%   closing parenthesis
\renewcommand{\BBOQ}{}%    opening quote for article title
\renewcommand{\BBCQ}{}%    closing quote for article title
\renewcommand{\BBAA}{\&}%  between authors in parenthetical cites and ref. list
%%
%% and
\renewcommand{\BBAB}{ja}%  between authors in text
%%
\renewcommand{\BAnd}{\&}%  for ``Ed. \& Trans.'' in ref. list
\DeclareRobustCommand{\BPBI}{.~}% Period between initials
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
\renewcommand{\BAP}{ }%   after prefix, before first citation
\renewcommand{\BBAY}{, }% between author(s) and year
\renewcommand{\BBYY}{, }% between years of multiple citations with same author
\renewcommand{\BBC}{; }%  between cites
\renewcommand{\BBN}{, }%  before note
\renewcommand{\BCBT}{,}%  comma between authors in ref. list when no. of
                      %%  authors = 2
\renewcommand{\BCBL}{,}%  comma before last author when no. of authors > 2
%%
%% Date formatting, adapted from babel's finnish.dtx
\renewcommand{\APACmonth}[1]{\ifcase #1\or
    tammikuuta\or helmikuuta\or maaliskuuta\or huhtikuuta\or
    toukokuuta\or kes\"akuuta\or hein\"akuuta\or elokuuta\or
    syyskuuta\or lokakuuta\or marraskuuta\or joulukuuta\or
%%  Winter    Spring         Summer       Fall
    talvea\or kev\"att\"a\or kes\"a\"a\or syksy\"a\else
    {#1}\fi}%
\renewcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%             year (+ addendum); should not be empty
  \ifx\@empty#3\@empty
    \ifx\@empty#2\@empty
    \else
      \unskip, {#2}%       month
    \fi
  \else
    \unskip, {#3}.%        day
    \ifx\@empty#2\@empty
    \else
      \unskip~{#2}%        month
    \fi
  \fi
  {\BBCP}%                 closing parenthesis
}%
%%
%% Some macros that transform a number (say, `2') to an ordinal one (`2nd')
\renewcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}%
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\z@
            \CardinalNumeric\count@
        \else
            ??.%
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}%
%    \end{macrocode}
% In Finnish, ordinal numbers are always obtained by simply
% putting a period after the number. So I am reusing the German code here.
% As mentioned in the section describing \fname{german.apc}, this (and perhaps
% the code above) can then be significantly simplified, but, because I (EM)
% have trouble understanding this code (from the \pkg{amsrefs} package) and
% experimenting did not give the expected results, I won't mess with the code
% too much and stay close to the English code.
%    \begin{macrocode}
\renewcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        .%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1.\else .\fi
    \fi
}%
%    \end{macrocode}
% Restore category code of |@| sign.
%    \begin{macrocode}
\APACrestoreAtCode
%</finnish>
%    \end{macrocode}
%
%
% \subsection{\fname{french.apc}}
%
% This file redefines the language-specific elements of \pkg{apacite}
% for the French language and its ``dialects'' in \pkg{babel}
% terminology.
%
%    \begin{macrocode}
%<*french>
%%
%% french.apc - french version of apacite elements
%% Adapted from english.apc by \'Eric Raufaste
%%
%    \end{macrocode}
% A fancy way to store and restore the category code of the |@| sign,
% per Heiko Oberdiek.
%    \begin{macrocode}
\edef\APACrestoreAtCode{%
   \catcode`@=\the\catcode`@\relax
}%
\makeatletter
\renewcommand{\onemaskedcitationmsg}[1]{%
    \emph{(#1\ citation removed for masked review)}}% !!! CHANGE
\renewcommand{\maskedcitationsmsg}[1]{%
    \emph{(#1\ citations removed for masked review)}}% !!! CHANGE
%%
\renewcommand{\refname}{R\'ef\'erences}% Name of ref. list if it's a section.
\renewcommand{\bibname}{R\'ef\'erences}% Name of ref. list if it's a chapter.
%% The name (heading) of the Author Index
\renewcommand{\authorindexname}{Index des auteurs}%
%%
%% A note before the references if a meta-analysis is reported.
\renewcommand{\APACmetaprenote}{%
  Les r\'ef\'erences marqu\'ees d'un ast\'erisque indiquent des \'etudes
  incluses dans la m\'eta-analyse.}%
%%
%% Commands for specific types of @misc entries.
\renewcommand{\bibmessage}{Msg}%
\renewcommand{\bibcomputerprogram}{Logiciel}%
\renewcommand{\bibcomputerprogrammanual}{Manuel de logiciel}%
\renewcommand{\bibcomputerprogramandmanual}{Logiciel et manuel}%
\renewcommand{\bibcomputersoftware}{Logiciel}%
\renewcommand{\bibcomputersoftwaremanual}{Manuel de logiciel}%
\renewcommand{\bibcomputersoftwareandmanual}{Logiciel et manuel}%
\renewcommand{\bibprogramminglanguage}{Langage de programmation}%
%%
%% Other labels
\renewcommand{\bibnodate}{s.~d.\hbox{}}%         ``no date''
\renewcommand{\BIP}{sous presse}%                ``in press''
\renewcommand{\BOthers}[1]{et al.\hbox{}}%       ``and others''
\renewcommand{\BOthersPeriod}[1]{et al.\hbox{}}% ``and others'' with a period
\renewcommand{\BIn}{In}%                 % for ``In'' editor...
\renewcommand{\Bby}{par}%                % for ``by'' editor... (in reprints)
\renewcommand{\BED}{Ed.\hbox{}}%            % editor
\renewcommand{\BEDS}{Eds.\hbox{}}%          % editors
\renewcommand{\BTRANS}{Trad.\hbox{}}%       % translator
\renewcommand{\BTRANSS}{Trad.\hbox{}}%      % translators
\renewcommand{\BTRANSL}{trad.\hbox{}}%      % translation, for the year field
\renewcommand{\BCHAIR}{Pr\'es.\hbox{}}%     % chair of symposium
\renewcommand{\BCHAIRS}{Pr\'es}%            % chairs
\renewcommand{\BVOL}{Vol.\hbox{}}%          % volume
\renewcommand{\BVOLS}{Vols.\hbox{}}%        % volumes
\renewcommand{\BNUM}{N\textsuperscript{o}}% % number
\renewcommand{\BNUMS}{N\textsuperscript{os}}% numbers
\renewcommand{\BEd}{\'ed.\hbox{}}%          % edition
\renewcommand{\BCHAP}{chap.\hbox{}}%        % chapter
\renewcommand{\BCHAPS}{chap.\hbox{}}%       % chapters
\renewcommand{\BPG}{p.\hbox{}}%             % page
\renewcommand{\BPGS}{pp.\hbox{}}%           % pages
%% Default technical report type name.
\renewcommand{\BTR}{Rapport technique}%
%% Default PhD thesis type name.
\renewcommand{\BPhD}{Th\`ese de doctorat}%
%% Default unpublished PhD thesis type name.
\renewcommand{\BUPhD}{Th\`ese de doctorat non publi\'ee}%
%% Default master's thesis type name.
\renewcommand{\BMTh}{M\'emoire de Master}%
%% Default unpublished master's thesis type name.
\renewcommand{\BUMTh}{M\'emoire de Master non publi\'e}%
%%
\renewcommand{\BAuthor}{Auteur}%% Used if publisher = author
\renewcommand{\BOWP}{\OE uvre originale publi\'ee en}%
\renewcommand{\BREPR}{R\'eimprim\'e \`a partir de}%
\renewcommand{\BAvailFrom}{Disponible sur\ }%      Websites; note the space.
%% Websites; note the space.
%% The argument is the date on which it was last checked.
\renewcommand{\BRetrieved}[1]{Consult\'e le {#1}, sur\ }%
\renewcommand{\BRetrievedFrom}{Consult\'e sur\ }%
\renewcommand{\BMsgPostedTo}{Message post\'e sur\ }% Messages; note the space.
%%
%% Punctuation
\renewcommand{\BBOP}{(}%   opening parenthesis
\renewcommand{\BBCP}{)}%   closing parenthesis
\renewcommand{\BBOQ}{}%    opening quote for article title
\renewcommand{\BBCQ}{}%    closing quote for article title
\renewcommand{\BBAA}{\&}%  between authors in parenthetical cites and ref. list
\renewcommand{\BBAB}{et}%  between authors in text
\renewcommand{\BAnd}{\&}%  for ``Ed. \& Trans.'' in ref. list
\DeclareRobustCommand{\BPBI}{.~}% Period between initials
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
\renewcommand{\BAP}{ }%   after prefix, before first citation
\renewcommand{\BBAY}{, }% between author(s) and year
\renewcommand{\BBYY}{, }% between years of multiple citations with same author
\renewcommand{\BBC}{~; }% between cites
\renewcommand{\BBN}{, }%  before note
\renewcommand{\BCBT}{,}%  comma between authors in ref. list when no. of
                      %%  authors = 2
\renewcommand{\BCBL}{,}%  comma before last author when no. of authors > 2
%%
%% Date formatting
\renewcommand{\APACmonth}[1]{\ifcase #1\or janvier\or f\'evrier\or mars\or
    avril\or mai\or juin\or juillet\or ao\^ut\or septembre\or octobre\or
    novembre\or d\'ecembre\or hiver\or printemps\or \'et\'e\or automne\else
    {#1}\fi}%
%% Structure taken from definition of \today in frenchb.dtx
\makeatletter
\renewcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%          year (+ addendum); should not be empty
  \ifx\@empty#3\@empty
    \ifx\@empty#2\@empty
    \else
      \unskip, {#2}%    month
    \fi
  \else
    \unskip, {#3}%      day
    \edef\APAC@tempa{#3}%
    \edef\APAC@tempb{1}%
    \ifx\APAC@tempa\APAC@tempb\@empty {\ier}\fi
    \let\APAC@tempa\@undefined
    \let\APAC@tempb\@undefined
    %%
    \ifx\@empty#2\@empty
    \else
      \unskip~{#2}%     month
    \fi
  \fi
  {\BBCP}%              closing parenthesis
}%
%%
%% Some macros that transform a number (say, `2') to an ordinal one (`2nd')
%    \end{macrocode}
% Ordinal numbers should all be number + `\textsuperscript{e}',
% except if number = 1, then it is ``1\textsuperscript{er}'' or
% ``1\textsuperscript{re}''. \pkg{babel} provides the
% commands \cmd{\ieme}, \cmd{\ier}, and \cmd{\iere} for formatting this.
% We'll use these commands.
%
% \begin{macro}{\APACfirst}
% \begin{macro}{\PrintOrdinalMale}
% \pkg{apacite} only uses the ordinal numbers for edition numbers, and
% the gender of ``\'edition'' is feminine, so we use the feminine form
% ``1re'' by default. However, we put it in the macro \cmd{\APACfirst}.
% Then we define \cmd{\PrintOrdinalMale} to redefine \cmd{\APACfirst}
% to take the masculine form, then call \cmd{\PrintOrdinal}, and then
% revert again, so that users can use this function for masculine words
% (if desired).
%    \begin{macrocode}
\DeclareRobustCommand{\APACfirst}{1\iere}%
\DeclareRobustCommand{\PrintOrdinalMale}[1]{%
    \DeclareRobustCommand{\APACfirst}{1\ier}%
    \PrintOrdinal{#1}%
    \DeclareRobustCommand{\APACfirst}{1\iere}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
\renewcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}%
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\@ne
            \CardinalNumeric\count@
        \else
            \ifnum1=\count@
                {\APACfirst}%
            \else
                ??{\ieme}%
            \fi
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}%
\renewcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        {\ieme}%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1{\ieme}\else {\ieme}\fi
    \fi
}%
%%
%% In French, there should be a space before a colon `:', so we have to
%% redefine a few macros that insert a colon.
\renewcommand{\APACaddressPublisher}[2]{%
  \ifx\@empty#1\@empty
      %% publisher
    \ifx\@empty#2\@empty
    \else
      {#2}%
    \fi
      %%
  \else
      %% address
    {#1}%
      %% publisher
    \ifx\@empty#2\@empty
    \else
      \unskip{} : {#2}%
    \fi
      %%
  \fi
}%
\let\APACaddressInstitution\APACaddressPublisher
\renewcommand{\APACaddressPublisherEqAuth}[2]{%
  \ifx\@empty#1\@empty
      %% Publisher. This cannot be empty, because it is equal to the
      %% author.
    {\BAuthor{}}%
      %%
  \else
      %% Address and publisher. These are not empty.
    {#1\unskip{} : \BAuthor{}}%
      %%
  \fi
}%
\let\APACaddressInstitutionEqAuth\APACaddressPublisherEqAuth
%    \end{macrocode}
% Restore category code of |@| sign.
%    \begin{macrocode}
\APACrestoreAtCode
%</french>
%    \end{macrocode}
%
%
% \subsection{\fname{german.apc} and \fname{ngerman.apc}}
%
% This file redefines the language-specific elements of \pkg{apacite}
% for the German language. These are based on the APA-inspired
% instructions from the \citeA{DGPs07}. There is the traditional orthography
% (`german') and the new orthography (`ngerman'), which are treated as
% completely different languages by \pkg{babel} (unlike, e.g., the two
% Norwegian languages), which presumably has technical reasons. We start
% with `german'.
%
%    \begin{macrocode}
%<*german>
%%
%% german.apc - Deutsche Uebersetzung der Apacite-Elemente
%%              (German version of apacite elements)
%% Written by Andreas Poege
%% Some additions and adaptations by Erik Meijer.
%%
%    \end{macrocode}
% A fancy way to store and restore the category code of the |@| sign,
% per Heiko Oberdiek.
%    \begin{macrocode}
\edef\APACrestoreAtCode{%
   \catcode`@=\the\catcode`@\relax
}%
\makeatletter
\renewcommand{\onemaskedcitationmsg}[1]{%
    \emph{(#1\ citation removed for masked review)}}% !!! CHANGE
\renewcommand{\maskedcitationsmsg}[1]{%
    \emph{(#1\ citations removed for masked review)}}% !!! CHANGE
%% Bezeichnung fuer das Literaturverzeichnis, falls Section
\renewcommand{\refname}{Literatur}%
%% Bezeichnung fuer das Literaturverzeichnis, falls Chapter
\renewcommand{\bibname}{Literaturverzeichnis}%
%% Bezeichnung (heading) des Autorenverzeichnisses
\renewcommand{\authorindexname}{Autorenregister}%
%%
%% Bemerkung vor Literaturangaben, falls eine Metaanalyse angegeben wurde
\renewcommand{\APACmetaprenote}{Literaturangaben mit Stern kennzeichnen
  Studien der Metaanalyse.}%
%%
%% Befehle fuer die speziellen @misc-Eintraege.
\renewcommand{\bibmessage}{Msg.\hbox{}}% Newsgroup-, Internet-Messages
\renewcommand{\bibcomputerprogram}{Computerprogramm}%
\renewcommand{\bibcomputerprogrammanual}{Programm-Handbuch}%
\renewcommand{\bibcomputerprogramandmanual}{Computerprogramm und Handbuch}%
\renewcommand{\bibcomputersoftware}{Software}%
\renewcommand{\bibcomputersoftwaremanual}{Software-Handbuch}%
\renewcommand{\bibcomputersoftwareandmanual}{Software und Handbuch}%
\renewcommand{\bibprogramminglanguage}{Programmiersprache}%
%%
%% Weitere Labels
\renewcommand{\bibnodate}{o.\,J.\hbox{}}% "`ohne Jahresangabe"'
\renewcommand{\BIP}{in Druck}%          % Jahresangabe bei im Druck bef. Werken
%%
%% "`und andere"', das Argument beinhaltet einen Punkt, um einen weiteren im
%% Literaturverzeichnis zu unterdruecken
\renewcommand{\BOthers}[1]{et al.\hbox{}}%
%% "`und andere"', das Argument beinhaltet einen Punkt, um einen weiteren im
%% Literaturverzeichnis zu unterdruecken.
\renewcommand{\BOthersPeriod}[1]{et al.\hbox{}}%
%%
\renewcommand{\BIn}{In}%            % fuer "`In"' Herausgeber...
\renewcommand{\Bby}{von}%           % fuer "`von"' Herausgeber... (Nachdruck)
\renewcommand{\BED}{Hrsg.\hbox{}}%      % Herausgeber(in)
\renewcommand{\BEDS}{Hrsg.\hbox{}}%     % Herausgeber(innen)
\renewcommand{\BTRANS}{\"Ubers.\hbox{}}%% Uebersetzer(in)
\renewcommand{\BTRANSS}{\"Ubers.\hbox{}}% Uebersetzer(innen)
\renewcommand{\BTRANSL}{\"Ubers.\hbox{}}% Uebersetzung (bei der Jahresangabe)
\renewcommand{\BCHAIR}{Chair}%          % Chair (bei Konferenzen)
\renewcommand{\BCHAIRS}{Chairs}%        % Chairs (bei Konferenzen)
\renewcommand{\BVOL}{Bd.\hbox{}}%       % Band
\renewcommand{\BVOLS}{Bde.\hbox{}}%     % Baende
\renewcommand{\BNUM}{Nr.\hbox{}}%       % Nummer
\renewcommand{\BNUMS}{Nr.\hbox{}}%      % Nummern
\renewcommand{\BEd}{Aufl.\hbox{}}%      % Auflage
\renewcommand{\BCHAP}{Kap.\hbox{}}%     % Kapitel
\renewcommand{\BCHAPS}{Kap.\hbox{}}%    % Kapitel
\renewcommand{\BPG}{S.\hbox{}}%         % Seite
\renewcommand{\BPGS}{S.\hbox{}}%        % Seiten
%%
%% (default) Bezeichnung fuer "`technical report"'
\renewcommand{\BTR}{Bericht}%
%% (default) Bezeichnung fuer Dissertation
\renewcommand{\BPhD}{Dissertation}%
%% (default) Bezeichnung fuer unveroeffentlichte Dissertation
\renewcommand{\BUPhD}{Unver\"offentlichte Dissertation}%
%% (default) Bezeichnung fuer Abschlussarbeit
\renewcommand{\BMTh}{Diplomarbeit}%
%% (default) Bezeichnung fuer unveroeffentlichte Abschlussarbeit
\renewcommand{\BUMTh}{Unver\"offentlichte Diplomarbeit}%
%%
\renewcommand{\BAuthor}{Autor}%      % ``Autor'' falls publisher = author
\renewcommand{\BOWP}{Originalausgabe}% Originalausgabe
\renewcommand{\BREPR}{Nachdruck von}%  Nachdruck von
%% Websites; note the spaces.
\renewcommand{\BAvailFrom}{Verf\"ugbar unter\ }%
%% The argument is the date on which it was last checked.
\renewcommand{\BRetrieved}[1]{Zugriff am {#1} auf\ }%
\renewcommand{\BRetrievedFrom}{Zugriff auf\ }%
%% Note that here the English phrase is left untranslated in German.
\renewcommand{\BMsgPostedTo}{Message posted to\ }%
%%
%% Deutsche Anpassung der Interpunktion und Formatierung
\renewcommand{\BBOP}{(}% % Einleitende Klammer (default "(")
\renewcommand{\BBCP}{)}% % Abschliessende Klammer (default ")")
\renewcommand{\BBOQ}{}%  % Einleitung v. Titel v. Artikel (default "")
\renewcommand{\BBCQ}{}%  % Abschluss v. Titel. von Artikel (default "")
\renewcommand{\BBAA}{\&}%% Zwischen Autoren in Klammern (default "\&")
\renewcommand{\BBAB}{und}% Zwischen Autoren im Text
\renewcommand{\BAnd}{\&}%% Zwischen Hg. und Uebers., falls gleich (default "\&")
\DeclareRobustCommand{\BPBI}{.~}% Period between initials
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
\renewcommand{\BAP}{ }%  % Zeichen zw. Prefix und Zitat (default Leerzeichen)
\renewcommand{\BBAY}{, }% Zwischen Autoren und Jahr(en) (default ", ")
\renewcommand{\BBYY}{, }% Zwischen Jahren, wenn ein Author und mehrere Jahre
\renewcommand{\BBC}{; }%  Zwischen Autoren (mehrere Zitate) (default "; ")
\renewcommand{\BBN}{, }%  Zwischen Zitat und Postfix (default ", ")
\renewcommand{\BCBT}{}%   Zwischen 2 Autoren (zus. zu "&", default ",")
\renewcommand{\BCBL}{}%   Zwischen 3 o. mehr Autoren (zus. zu "&", default ",")
%%
%% Date formatting, adapted from babel's germanb.dtx
\renewcommand{\APACmonth}[1]{\ifcase #1\or
  Januar\or Februar\or M\"arz\or April\or Mai\or Juni\or
  Juli\or August\or September\or Oktober\or November\or Dezember\or
  Winter\or Fr\"uhjahr\or Sommer\or Herbst\else {#1}\fi}%
\renewcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%            year (+ addendum); should not be empty
  \ifx\@empty#3\@empty
    \ifx\@empty#2\@empty
    \else
      \unskip, {#2}%      month
    \fi
  \else
    \unskip, {#3}.%       day
    \ifx\@empty#2\@empty
    \else
      \unskip~{#2}%       month
    \fi
  \fi
  {\BBCP}%                closing parenthesis
}%
%% Some macros that transform a number (say, `2') to an ordinal one (`2nd'),
%% adapted from amsrefs.dtx
\renewcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}%
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\z@
            \CardinalNumeric\count@
        \else
            ??.%
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}%
%    \end{macrocode}
% German ordinal numbers are always obtained by simply putting a period after
% the number, so this (and perhaps the code above) can be significantly
% simplified. However, because I (EM) have trouble understanding this code (from
% the \pkg{amsrefs} package) and experimenting did not give the expected
% results, I won't mess with the code too much and stay close to the
% English code.
%    \begin{macrocode}
\renewcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        .%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1.\else .\fi
    \fi
}%
%    \end{macrocode}
% The DGPs puts a space between the volume and the issue number,
% unlike the APA. So we have to slightly adapt this command.
% (|#1| = journal, |#2| = volume, |#3| = number, |#4| = formatted pages).
%    \begin{macrocode}
\renewcommand{\APACjournalVolNumPages}[4]{%
  \Bem{#1}%             journal
  \ifx\@empty#2\@empty
  \else
    \unskip, \Bem{#2}%  volume
  \fi
  \ifx\@empty#3\@empty
  \else
    \unskip\ ({#3})%    issue number, with the added leading space
  \fi
  \ifx\@empty#4\@empty
  \else
    \unskip, {#4}%      pages
  \fi
}%
%    \end{macrocode}
% Presumably, for the original journal information of a reprint, a similar
% space needs to be added.
% Arguments: |#1| = year, |#2| = journal, |#3| = volume, |#4| = issue number,
%            |#5| = formatted pages, |#6| = note.
%    \begin{macrocode}
\renewcommand{\APACorigjournalnote}[6]{%
  (\BREPR{} %          ``(Reprinted from '' (note the space)
  \Bem{#2}%            Journal (should not be empty)
  \ifx\@empty#1\@empty
  \else
    \unskip, {#1}%     , year
  \fi
  \ifx\@empty#3\@empty
  \else
    \unskip, \Bem{#3}% , volume
  \fi
  \ifx\@empty#4\@empty
  \else
    \unskip\ {[#4]}%   \ [issue number]
  \fi
  \ifx\@empty#5\@empty
  \else
    \unskip, {#5}%     , pages
  \fi
  \ifx\@empty#6\@empty
  \else
    \unskip; {#6}%     ; note
  \fi
  )%                   Final parenthesis
}%
%    \end{macrocode}
% Differences between Austrian and German. (Apparently only the name of
% January---``J\"anner'' vs.\ ``Januar''.)
%    \begin{macrocode}
\edef\APACaustrian{\string austrian}%
\ifx\languagename\APACaustrian
  \renewcommand{\APACmonth}[1]{\ifcase #1\or
    J\"anner\or Februar\or M\"arz\or April\or Mai\or Juni\or
    Juli\or August\or September\or Oktober\or November\or Dezember\or
    Winter\or Fr\"uhjahr\or Sommer\or Herbst\else {#1}\fi}%
\fi
\let\APACaustrian\undefined
%    \end{macrocode}
% Restore category code of |@| sign.
%    \begin{macrocode}
\APACrestoreAtCode
%</german>
%    \end{macrocode}
%
%
% Now, the file for the new orthography. Apparently, \fname{german.apc}
% can also be used for the new orthography, so this is a very brief one:
%
%    \begin{macrocode}
%<*ngerman>
%%
%% ngerman.apc - german translation of apacite elements (new orthography)
%% Written by Erik Meijer, based on instructions of Andreas Poege.
%%
%% According to Andreas Poege, his file german.apc can also be used
%% for the new orthography, so I'll just do this:
%%
\input{german.apc}%
%%
%    \end{macrocode}
% Differences between Austrian and German. (Apparently only the name of
% January---``J\"anner'' vs.\ ``Januar''.) This is not picked up in
% \fname{german.apc}, because that file only checks for ``austrian'',
% not for ``naustrian'', so we have to copy it here.
%    \begin{macrocode}
\edef\APACaustrian{\string naustrian}%
\ifx\languagename\APACaustrian
  \renewcommand{\APACmonth}[1]{\ifcase #1\or
    J\"anner\or Februar\or M\"arz\or April\or Mai\or Juni\or
    Juli\or August\or September\or Oktober\or November\or Dezember\or
    Winter\or Fr\"uhjahr\or Sommer\or Herbst\else {#1}\fi}%
\fi
\let\APACaustrian\undefined
%%
%%
%</ngerman>
%    \end{macrocode}
%
%
% \subsection{\fname{greek.apc}}
%
% This file redefines the language-specific elements of \pkg{apacite}
% for the Greek language.
%
%    \begin{macrocode}
%<*greek>
%%
%% greek.apc - Greek version of apacite elements
%% Greek translations by Athanassios Protopapas and Ioannis Dimakos
%%
%    \end{macrocode}
% A fancy way to store and restore the category code of the |@| sign,
% per Heiko Oberdiek.
%    \begin{macrocode}
\edef\APACrestoreAtCode{%
   \catcode`@=\the\catcode`@\relax
}%
\makeatletter
\renewcommand{\onemaskedcitationmsg}[1]{%
    \emph{(#1\ citation removed for masked review)}}% !!! CHANGE
\renewcommand{\maskedcitationsmsg}[1]{%
    \emph{(#1\ citations removed for masked review)}}% !!! CHANGE
%% Name of ref. list if it's a section.
\renewcommand{\refname}{\textgreek{Bibliograf'ia}}%
%% Name of ref. list if it's a chapter.
\renewcommand{\bibname}{\textgreek{Bibliograf'ia}}%
%% The name (heading) of the Author Index
\renewcommand{\authorindexname}{\textgreek{Euret'hrio suggraf'ewn}}%
%%
%% A note before the references if a meta-analysis is reported.
\renewcommand{\APACmetaprenote}{%
    \textgreek{Oi ergas'iec pou sumperilamb'anontai sth meta-an'alush
    shmei'wnontai me aster'isko}.}%
%%
%% Commands for specific types of @misc entries.
\renewcommand{\bibmessage}{\textgreek{M'hnuma}}%
\renewcommand{\bibcomputerprogram}{\textgreek{Logismik'o}}%
\renewcommand{\bibcomputerprogrammanual}{%
  \textgreek{Egqeir'idio logismiko'u}}%
\renewcommand{\bibcomputerprogramandmanual}{%
  \textgreek{Logismik'o kai egqeir'idio}}%
\renewcommand{\bibcomputersoftware}{\textgreek{Logismik'o}}%
\renewcommand{\bibcomputersoftwaremanual}{%
  \textgreek{Egqeir'idio logismiko'u}}%
\renewcommand{\bibcomputersoftwareandmanual}{%
  \textgreek{Logismik'o kai egqeir'idio}}%
\renewcommand{\bibprogramminglanguage}{%
  \textgreek{Gl'wssa programmatismo'u}}%
%%
%% Other labels
\renewcommand{\bibnodate}{\textgreek{qwr'ic hmeromhn'ia}}% ``no date''
\renewcommand{\BIP}{\textgreek{up'o 'ekdosh}}%           % ``in press''
\renewcommand{\BOthers}[1]{\textgreek{k.\ sun.\hbox{}}}% ``and others''
%% ``and others'' with a period
\renewcommand{\BOthersPeriod}[1]{\textgreek{k.\ sun.\hbox{}}}%
\renewcommand{\BIn}{\textgreek{Sto}}%% for ``In'' editor...
%    \end{macrocode}
% The current command \cmd{\Bby} is problematic for application in Greek.
% If it is followed by 1 male editor, then it should be ``|\textgreek{toy}|'';
% in the case of 1 female editor, it should be ``|\textgreek{ths}|''; with
% multiple editors, ``|\textgreek{twn}|'' is the correct translation. For
% the moment, let's use the latter, which is gender-neutral and perhaps the
% most common one. Note that a user can apply the sort of tricks that we
% used in section~\ref{sec:xmpl} (Example~69) to make a one-time change to
% the definition of \cmd{\Bby}. See the command \cmd{\bibInstring} in
% section~\ref{sec:apacdoc}.
%    \begin{macrocode}
\renewcommand{\Bby}{\textgreek{twn}}%  for ``by'' editor... (in reprints)
\renewcommand{\BED}{\textgreek{Epim.\hbox{}}}%   % editor
\renewcommand{\BEDS}{\textgreek{Epim.\hbox{}}}%  % editors
\renewcommand{\BTRANS}{\textgreek{Mtf.\hbox{}}}% % translator
\renewcommand{\BTRANSS}{\textgreek{Mtf.\hbox{}}}%% translators
\renewcommand{\BTRANSL}{\textgreek{mtf.\hbox{}}}%% translation
\renewcommand{\BCHAIR}{\textgreek{Pr'oedroc}}%   % chair of symposium
\renewcommand{\BCHAIRS}{\textgreek{Pr'oedroi}}%  % chairs
\renewcommand{\BVOL}{\textgreek{t.\hbox{}}}%     % volume
\renewcommand{\BVOLS}{\textgreek{t.\hbox{}}}%    % volumes
\renewcommand{\BNUM}{\textgreek{ar.\hbox{}}}%    % number
\renewcommand{\BNUMS}{\textgreek{ar.\hbox{}}}%   % numbers
\renewcommand{\BEd}{\textgreek{'ekd.\hbox{}}}%   % edition
\renewcommand{\BCHAP}{\textgreek{kef.\hbox{}}}%  % chapter
\renewcommand{\BCHAPS}{\textgreek{kef.\hbox{}}}% % chapters
\renewcommand{\BPG}{\textgreek{sel.\hbox{}}}%    % page
\renewcommand{\BPGS}{\textgreek{sel.\hbox{}}}%   % pages
%% Default technical report type name.
\renewcommand{\BTR}{\textgreek{Teq.\ 'ekj.\hbox{}}}%
%% Default PhD thesis type name.
\renewcommand{\BPhD}{\textgreek{Didaktorik'h diatrib'h}}%
%% (default) unpublished PhD thesis type name
\renewcommand{\BUPhD}{\textgreek{Adhmos'ieuth didaktorik'h diatrib'h}}%
%% (default) master's thesis type name
\renewcommand{\BMTh}{\textgreek{Metaptuqiak'h diplwmatik'h ergas'ia}}%
%% (default) unpublished master's thesis type name
\renewcommand{\BUMTh}{%
  \textgreek{Adhmos'ieuth metaptuqiak'h diplwmatik'h ergas'ia}}%
%% ``Author'' if publisher = author
\renewcommand{\BAuthor}{\textgreek{Auto'ekdosh}}%
%% Original work published
\renewcommand{\BOWP}{\textgreek{'Ekdosh prwtot'upou}}%
%% Reprinted from
\renewcommand{\BREPR}{\textgreek{Anat'upwsh ap'o}}%
%% Websites; note the explicit spaces.
\renewcommand{\BAvailFrom}{\textgreek{Diaj'esimo ap'o}\ }% Available from
%% Retrieved ... from
%% The argument is the date on which it was last checked.
%% Correct only when ``date'' is full, not just month or year
\renewcommand{\BRetrieved}[1]{%
    \textgreek{Anakt'hjhke stis} {#1}, \textgreek{ap'o}\ }%
\renewcommand{\BRetrievedFrom}{%
    \textgreek{Anakt'hjhke stis} \textgreek{ap'o}\ }%
%    \end{macrocode}
% If a URL follows without any leading words/phrase then this string
% should be OK. If there is any other word before the URL then we
% need to know its gender and number in order to produce the correct
% translation. In the current \pkg{apacite} implementation, this is only
% used with a URL immediately following, so we should be OK.
%    \begin{macrocode}
%% Newsgroups, forums, etc.; ``Message posted to ''; note the space.
\renewcommand{\BMsgPostedTo}{\textgreek{M'hnyma anarthm'eno se}\ }%
%%
%% Punctuation
\renewcommand{\BBOP}{(}%   opening parenthesis
\renewcommand{\BBCP}{)}%   closing parenthesis
\renewcommand{\BBOQ}{}%    opening quote for article title
\renewcommand{\BBCQ}{}%    closing quote for article title
\renewcommand{\BBAA}{\&}%  between authors in parenthetical cites and ref. list
\renewcommand{\BBAB}{\textgreek{kai}}% between authors in text
\renewcommand{\BAnd}{\&}%  for ``Ed. \& Trans.'' in ref. list
\DeclareRobustCommand{\BPBI}{.~}% Period between initials
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
\renewcommand{\BAP}{ }%   after prefix, before first citation
\renewcommand{\BBAY}{, }% between author(s) and year
\renewcommand{\BBYY}{, }% between years of multiple citations with same author
\renewcommand{\BBC}{; }%  between cites
\renewcommand{\BBN}{, }%  before note
\renewcommand{\BCBT}{,}%  comma between authors in ref. list when no. of
                      %%  authors = 2
\renewcommand{\BCBL}{,}%  comma before last author when no. of authors > 2
%%
%% Date formatting. Adapted from babel's greek.dtx
\renewcommand{\APACmonth}[1]{\textgreek{\ifcase #1\or
    Ianouar'iou\or Febrouar'iou\or Mart'iou\or April'iou\or
    Ma'"iou\or Ioun'iou\or Ioul'iou\or Augo'ustou\or
    Septembr'iou\or Oktwbr'iou\or Noembr'iou\or Dekembr'iou\or
    Qeim'wnas\or 'Anoixh\or Kaloka'iri\or Fjin'opwro\else
    {#1}\fi}}%
\renewcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%             year (+ addendum); should not be empty
  \ifx\@empty#3\@empty
    \ifx\@empty#2\@empty
    \else
      \unskip, {#2}%       month
    \fi
  \else
    \unskip, {#3}%         day
    \ifx\@empty#2\@empty
    \else
      \unskip~{#2}%        month
    \fi
  \fi
  {\BBCP}%                 closing parenthesis
}%
%%
%    \end{macrocode}
% The ordinal numbers are used only for editions in the current version of
% \pkg{apacite}. Hence, we simply tag a ``|\textgreek{h}|'' to the number.
% We could provide alternative versions later on if desired (see, e.g.,
% \fname{french.apc}).
%    \begin{macrocode}
%% Some macros that transform a number (say, `2') to an ordinal one (`2h').
\renewcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}%
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\z@
            \CardinalNumeric\count@
        \else
            ??\textgreek{h}%
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}%
\renewcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        \textgreek{h}%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1\textgreek{h}\or \textgreek{h}\else \textgreek{h}\fi
    \fi
}%
%    \end{macrocode}
% Restore category code of |@| sign.
%    \begin{macrocode}
\APACrestoreAtCode
%</greek>
%    \end{macrocode}
%
%
% \subsection{\fname{norsk.apc}}
%
% This file redefines the language-specific elements of \pkg{apacite}
% for both Norwegian languages (Bokm{\aa}l and Nynorsk). In \pkg{babel}'s
% setup, `norsk' is Bokm{\aa}l and `nynorsk' is a dialect of `norsk'.
% This does not seem to reflect the relation between these languages
% very well, but for compatibility with \pkg{babel} we use the same
% file structure, i.e., \fname{norsk.apc} defines both languages.
%
% There are no official Norwegian translations of APA style. Some ideas
% for this translation have been taken from \citeA{UIB08} and \citeA{UiO06}.
%
%    \begin{macrocode}
%<*norsk>
%%
%% norsk.apc - Norwegian Bokmal & Nynorsk versions of apacite elements.
%% Version 1.1.
%% Written by Karl Ove Hufthammer.
%%
%    \end{macrocode}
% A fancy way to store and restore the category code of the |@| sign,
% per Heiko Oberdiek.
%    \begin{macrocode}
\edef\APACrestoreAtCode{%
   \catcode`@=\the\catcode`@\relax
}%
\makeatletter
\renewcommand{\onemaskedcitationmsg}[1]{%
    \emph{(#1\ citation removed for masked review)}}% !!! CHANGE
\renewcommand{\maskedcitationsmsg}[1]{%
    \emph{(#1\ citations removed for masked review)}}% !!! CHANGE
\renewcommand{\refname}{Referanser}% Name of ref. list if it's a section.
\renewcommand{\bibname}{Referanser}% Name of ref. list if it's a chapter.
%% The name (heading) of the Author Index
\renewcommand{\authorindexname}{Forfatterregister}%
%%
%% A note before the references if a meta-analysis is reported.
\renewcommand{\APACmetaprenote}{%
    Referanser merket med en stjerne viser til studier som er med i
    metaanalysen.}
%%
%% Commands for specific types of @misc entries.
\renewcommand{\bibmessage}{innlegg}%
\renewcommand{\bibcomputerprogram}{dataprogram}%
\renewcommand{\bibcomputerprogrammanual}{dataprogramh\aa ndbok}%
\renewcommand{\bibcomputerprogramandmanual}{dataprogram og brukerh\aa ndbok}%
\renewcommand{\bibcomputersoftware}{programvare}%
\renewcommand{\bibcomputersoftwaremanual}{programvareh\aa ndbok}%
\renewcommand{\bibcomputersoftwareandmanual}{programvare og brukerh\aa ndbok}%
\renewcommand{\bibprogramminglanguage}{programmeringsspr\aa k}%
%%
%% Other labels
\renewcommand{\bibnodate}{u.d.\hbox{}}%    ``no date''
\renewcommand{\BIP}{under publisering}%    ``in press''
\renewcommand{\BOthers}[1]{et al.\hbox{}}% ``and others''
\renewcommand{\BOthersPeriod}[1]{et al.\hbox{}}% ``and others'', with a period
\renewcommand{\BIn}{I}%               %    for ``In'' editor...
\renewcommand{\Bby}{av}%              %    for ``by'' editor... (in reprints)
\renewcommand{\BED}{red.\hbox{}}%     % editor
\renewcommand{\BEDS}{red.\hbox{}}%    % editors
\renewcommand{\BTRANS}{oms.\hbox{}}%  % translator
\renewcommand{\BTRANSS}{oms.\hbox{}}% % translators
\renewcommand{\BTRANSL}{oms.\hbox{}}% % translation, for the year field
\renewcommand{\BCHAIR}{ordstyrer}%    % chair of symposium
\renewcommand{\BCHAIRS}{ordstyrere}%  % chairs
\renewcommand{\BVOL}{vol.\hbox{}}%    % volume
\renewcommand{\BVOLS}{vol.\hbox{}}%   % volumes
\renewcommand{\BNUM}{nr.\hbox{}}%     % number
\renewcommand{\BNUMS}{nr.\hbox{}}%    % numbers
\renewcommand{\BEd}{utg.\hbox{}}%     % edition
\renewcommand{\BCHAP}{kap.\hbox{}}%   % chapter
\renewcommand{\BCHAPS}{kap.\hbox{}}%  % chapters
\renewcommand{\BPG}{s.\hbox{}}%       % page
\renewcommand{\BPGS}{s.\hbox{}}%      % pages
%% Default technical report type name.
\renewcommand{\BTR}{Teknisk rapport}%
%% Default PhD thesis type name.
\renewcommand{\BPhD}{Akademisk avhandling}%
%% Default unpublished PhD thesis type name.
\renewcommand{\BUPhD}{Upublisert akademisk avhandling}%
%% Default master's thesis type name.
\renewcommand{\BMTh}{Masteroppgave}%
%% Default unpublished master's thesis type name.
\renewcommand{\BUMTh}{Upublisert masteroppgave}%
%%
\renewcommand{\BAuthor}{Forfatter}%  ``Author'' if publisher = author
\renewcommand{\BOWP}{Original publisert}% Original work published
\renewcommand{\BREPR}{Opptrykk fra}%      Reprinted from
\renewcommand{\BAvailFrom}{Tilgjengelig fra\ }% Websites; note the space.
%% The argument is the date on which it was last checked.
\renewcommand{\BRetrieved}[1]{Hentet {#1} fra\ }% Websites; note the space.
\renewcommand{\BRetrievedFrom}{Hentet fra\ }%     Websites; note the space.
\renewcommand{\BMsgPostedTo}{Innlegg p\aa \ }% Messages; note the space.
%    \end{macrocode}
% To be in line with Norwegian rules of punctuation, a comma is never
% used before `\&' or ``and'', and there is no space between initials.
%    \begin{macrocode}
%%
%% Punctuation
\renewcommand{\BBOP}{(}%  opening parenthesis
\renewcommand{\BBCP}{)}%  closing parenthesis
\renewcommand{\BBOQ}{}%   opening quote for article title
\renewcommand{\BBCQ}{}%   closing quote for article title
\renewcommand{\BBAA}{\&}% between authors in parenthetical cites and ref. list
\renewcommand{\BBAB}{og}% between authors in text
\renewcommand{\BAnd}{\&}% for ``Ed. \& Trans.'' in ref. list
\DeclareRobustCommand{\BPBI}{.}% Period between initials; no space
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
\renewcommand{\BAP}{ }%   after prefix, before first citation
\renewcommand{\BBAY}{, }% between author(s) and year
\renewcommand{\BBYY}{, }% between years of multiple citations with same author
\renewcommand{\BBC}{; }%  between cites
\renewcommand{\BBN}{, }%  before note
\renewcommand{\BCBT}{}%   no comma between authors in ref. list when no. of
                      %%  authors = 2
\renewcommand{\BCBL}{}%   no comma before last author when no. of authors > 2
%%
%% Date formatting; adapted from babel's norsk.dtx
\renewcommand{\APACmonth}[1]{\ifcase #1\or
    januar\or februar\or mars\or april\or mai\or juni\or
    juli\or august\or september\or oktober\or november\or desember\or
    vinter\or v{\aa}r\or sommer\or h{\o}st\else
    {#1}\fi}%
\renewcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%             year (+ addendum); should not be empty
  \ifx\@empty#3\@empty
    \ifx\@empty#2\@empty
    \else
      \unskip, {#2}%       month
    \fi
  \else
    \unskip, {#3}.%        day
    \ifx\@empty#2\@empty
    \else
      \unskip~{#2}%        month
    \fi
  \fi
  {\BBCP}%                 closing parenthesis
}%
%% Some macros that transform a number (say, `2') to an ordinal one (`2nd')
\renewcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}%
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\z@
            \CardinalNumeric\count@
        \else
            ??.%
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}%
%    \end{macrocode}
% Norwegian ordinal numbers are always obtained by simply putting a period
% after the number, so this (and perhaps the code above) can be significantly
% simplified. However, because I (EM) have trouble understanding this code (from
% the \pkg{amsrefs} package) and experimenting did not give the expected
% results, I won't mess with the code too much and stay close to the
% English code.
%    \begin{macrocode}
\renewcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        .%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1.\else .\fi
    \fi
}%
%%
%% Differences between norsk (bokmal) and nynorsk.
\edef\APACnynorsk{\string nynorsk}%
\ifx\languagename\APACnynorsk
  \renewcommand{\refname}{Referansar}% Name of ref. list if it's a section.
  \renewcommand{\bibname}{Referansar}% Name of ref. list if it's a chapter.
  \renewcommand{\authorindexname}{Forfattarregister}%
  \renewcommand{\APACmetaprenote}{%
    Referansar merkte med ei stjerne viser til studiar som er med i
    metaanalysen.}%
  \renewcommand{\bibcomputerprogrammanual}{dataprogramhandbok}%
  \renewcommand{\bibcomputerprogramandmanual}{dataprogram og brukarhandbok}%
  \renewcommand{\bibcomputersoftwaremanual}{programvarehandbok}%
  \renewcommand{\bibcomputersoftwareandmanual}{programvare og brukarhandbok}%
  \renewcommand{\BCHAIR}{ordstyrar}%        % chair of symposium
  \renewcommand{\BCHAIRS}{ordstyrarar}%     % chairs
  %% Default master's thesis type name.
  \renewcommand{\BMTh}{Masteroppg\aa ve}%
  %% Default unpublished master's thesis type name.
  \renewcommand{\BUMTh}{Upublisert masteroppg\aa ve}%
  \renewcommand{\BAuthor}{Forfattar}% ``Author'' if publisher = author
  \renewcommand{\BREPR}{Opptrykk fr\aa }% Reprinted from
  \renewcommand{\BAvailFrom}{Tilgjengeleg fr\aa \ }% Websites; note the space.
  \renewcommand{\BRetrieved}[1]{Henta {#1} fr\aa \ }% Websites; note the space.
  \renewcommand{\APACmonth}[1]{\ifcase #1\or
      januar\or februar\or mars\or april\or mai\or juni\or
      juli\or august\or september\or oktober\or november\or desember\or
      vinter\or v{\aa}r\or sommar\or haust\else
      {#1}\fi}%
\fi
\let\APACnynorsk\undefined
%    \end{macrocode}
% Restore category code of |@| sign.
%    \begin{macrocode}
\APACrestoreAtCode
%</norsk>
%    \end{macrocode}
%
%
% \subsection{\fname{spanish.apc}}
%
% This file redefines the language-specific elements of \pkg{apacite}
% for the Spanish language. Note that \pkg{apacite}'s usage of |<| and
% |>| for pre-notes, as in |\cite<e.g.,>{jones06}| (inherited from its
% predecessor, \fname{theapa.sty}), conflicts with \pkg{babel}'s
% \pkgoption{spanish} option, which makes |<| and |>| active characters.
% Hence, either you must avoid using prenotes with \pkg{apacite}'s
% construction or you must disable \pkg{babel}'s behavior by inserting
% the command \cmd{\deactivatequoting} after loading \pkg{babel}.
%
%    \begin{macrocode}
%<*spanish>
%%
%% spanish.apc - Versi\'on espa\~nola de elementos en apacite
%% Escrito por Jorge L\'opez Puga
%%
%    \end{macrocode}
% A fancy way to store and restore the category code of the |@| sign,
% per Heiko Oberdiek.
%    \begin{macrocode}
\edef\APACrestoreAtCode{%
   \catcode`@=\the\catcode`@\relax
}%
\makeatletter
%% El nombre (del encabezado) de la Lista Referencias
%% Nombre de la lista de ref. si es una secci\'on.
\renewcommand{\refname}{Referencias}%
%% Nomber de la lista de refs. si es un cap\'{\i}tulo.
\renewcommand{\bibname}{Referencias}%
%% El nombre (del encabezado) del \'Indice de Autores.
\renewcommand{\authorindexname}{\'Indice de Autores}%
%% Nota previa usada justo antes de la lista de referencias si un
%% meta-an\'alisis es usado.
\renewcommand{\APACmetaprenote}{%
  Las referencias marcadas con un asterisco indican estudios incluidos en
  el meta-an\'alisis.}%
%% Comandos para tipos espec\'{\i}ficos de entradas @misc.
\renewcommand{\bibmessage}{Msj}%
\renewcommand{\bibcomputerprogram}{Programa inform\'atico}%
\renewcommand{\bibcomputerprogrammanual}{Manual de programa inform\'atico}%
\renewcommand{\bibcomputerprogramandmanual}{Programa inform\'atico y manual}%
\renewcommand{\bibcomputersoftware}{Software inform\'atico}%
\renewcommand{\bibcomputersoftwaremanual}{Manual de software inform\'atico}%
\renewcommand{\bibcomputersoftwareandmanual}{Manual y software inform\'atico}%
\renewcommand{\bibprogramminglanguage}{Lenguaje de programaci\'on}%
%%
%% Otras etiquetas
\renewcommand{\bibnodate}{s.f.\hbox{}}%  ``sin fecha''
\renewcommand{\BIP}{en prensa}% Usado como a\~no para citas ``en prensa''
%%
%% El argumento contiene un punto, por tanto, evita poner uno adicional en
%% la lista de referencias. No obstante algunas revistas aceptan ``et al.''
%% que es lo que aparece por defecto.
\renewcommand{\BOthers}[1]{y cols.\hbox{}}%       ``y colaboradores''
\renewcommand{\BOthersPeriod}[1]{y cols.\hbox{}}% ``y colaboradores''
%%
\renewcommand{\BIn}{En}%                   Para ``En'' editor...
\renewcommand{\Bby}{por}%                  ``by'' editor (in reprints)
\renewcommand{\BED}{Ed.\hbox{}}%           editor
\renewcommand{\BEDS}{Eds.\hbox{}}%         editors
\renewcommand{\BTRANS}{Traduc.\hbox{}}%    traductor
\renewcommand{\BTRANSS}{Traducs.\hbox{}}%  traductores
\renewcommand{\BTRANSL}{traduc.\hbox{}}%   traducci\'on, para el campo a\~no
\renewcommand{\BCHAIR}{Presidente}%        Presidente/a de congreso
\renewcommand{\BCHAIRS}{Presidencia}%      Presidencia
\renewcommand{\BVOL}{Vol.\hbox{}}%         volume
\renewcommand{\BVOLS}{Vols.\hbox{}}%       volumes
\renewcommand{\BNUM}{n\sptext{o}}%         number
\renewcommand{\BNUMS}{n\sptext{os}}%       numbers
\renewcommand{\BEd}{ed.\hbox{}}%           edition
\renewcommand{\BCHAP}{cap.\hbox{}}%        cap\'{\i}tulo
\renewcommand{\BCHAPS}{caps.\hbox{}}%      cap\'{\i}tulos
\renewcommand{\BPG}{p.\hbox{}}%            page
\renewcommand{\BPGS}{pp.\hbox{}}%          pages
%% Default technical report type name. --- Informe T\'ecnico
\renewcommand{\BTR}{Inf.\ T\'ec.\hbox{}}%
%% (por defecto) PhD thesis type name --- Tesis Doctoral
\renewcommand{\BPhD}{Tesis Doctoral}%
%% (por defecto) unpublished PhD thesis type name
%% --- Tesis Doctoral no publicada
\renewcommand{\BUPhD}{Tesis Doctoral no publicada}%
%% (por defecto) master's thesis type name --- Tesis de Master
\renewcommand{\BMTh}{Tesis de Master}%
%% (por defecto) unpublished master's thesis type name
%% --- Tesis de Master no publicada
\renewcommand{\BUMTh}{Tesis de Master no publicada}%
%%
\renewcommand{\BAuthor}{Autor}% ``Author'' if publisher = author
\renewcommand{\BOWP}{Trabajo original publicado en}% Original work published
\renewcommand{\BREPR}{Reimpresi\'on de}% Reprinted from
%%
%% Websites and messages to newsgroups, forums, etc.; note the spaces.
\renewcommand{\BAvailFrom}{Disponible en\ }% Available from
%% The argument is the date on which it was last checked.
\renewcommand{\BRetrieved}[1]{Descargado {#1}, de\ }% Retrieved ... from
\renewcommand{\BRetrievedFrom}{Descargado de\ }%      Retrieved from
\renewcommand{\BMsgPostedTo}{Mensaje colgado en\ }% Message posted to
%%
%% Punctuation
\renewcommand{\BBOP}{(}%   opening parenthesis
\renewcommand{\BBCP}{)}%   closing parenthesis
\renewcommand{\BBOQ}{}%    opening quote for article title
\renewcommand{\BBCQ}{}%    closing quote for article title

\renewcommand{\BBAA}{y}% Letra que va entre los autores en las referencias
\renewcommand{\BBAB}{y}% Entre autores en el texto
\renewcommand{\BAnd}{y}% for ``Ed. \& Trans.'' in ref. list
\DeclareRobustCommand{\BPBI}{.~}% Period between initials
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
\renewcommand{\BAP}{ }%   after prefix, before first citation
\renewcommand{\BBAY}{, }% between author(s) and year
\renewcommand{\BBYY}{, }% between years of multiple citations with same author
\renewcommand{\BBC}{; }%  between cites
\renewcommand{\BBN}{, }%  before note
\renewcommand{\BCBT}{,}%  comma between authors in ref. list when no. of
                      %%  authors = 2
\renewcommand{\BCBL}{,}%  comma before last author when no. of authors > 2
%%
%% Date formatting; adapted from babel's spanish.dtx
\renewcommand{\APACmonth}[1]{\ifcase #1\or enero\or febrero\or
    marzo\or abril\or mayo\or junio\or julio\or agosto\or
    septiembre\or octubre\or noviembre\or diciembre\or
    invierno\or primavera\or verano\or oto\~no\else
    {#1}\fi}%
\renewcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%           year (+ addendum); should not be empty
  \ifx\@empty#3\@empty
    \ifx\@empty#2\@empty
    \else
      \unskip, {#2}%     month --- mes
    \fi
  \else
    \unskip, {#3}%       day --- d\'ia
    \ifx\@empty#2\@empty
    \else
      \unskip~de {#2}%   month --- mes
    \fi
  \fi
  {\BBCP}%               closing parenthesis
}%
%% Some macros that transform a number (say, `2') to an ordinal one (`2nd')
\renewcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}%
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\z@
            \CardinalNumeric\count@
        \else
            ??\sptext{a}%
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}%
%    \end{macrocode}
% Spanish ordinal numbers are always obtained by putting
% ``.\textsuperscript{a}'' after the number, at least for editions.
% Therefore, the code here can be significantly simplified. However,
% because I have trouble understanding this code (from the \pkg{amsrefs}
% package) and experimenting did not give the expected results, I won't
% mess with the code too much and stay close to the English code.
% We use the \cmd{\sptext} command from \pkg{babel}'s \fname{spanish.dtx},
% which formats the ``.\textsuperscript{a}'' slightly differently.
%    \begin{macrocode}
\renewcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        \sptext{a}%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1\sptext{a}\else \sptext{a}\fi
    \fi
}%
%    \end{macrocode}
% Some code for using `e' instead of `y' in Spanish if the following
% name starts with `I'.
%    \begin{macrocode}
\def\usespanishe#1{%
    \@bsphack
    \@for\@citeb:=#1\do{%
       \edef\@citeb{\expandafter\@firstofone\@citeb}%
       \@ifundefined{spanishe@\@citeb\APAC@extra@b@citeb}%
         {\global\expandafter
          \def\csname spanishe@\@citeb\APAC@extra@b@citeb\endcsname{DUMMY}%
         }%
         {}%
    }%
    \@esphack
}
\def\APACinsertmetastar#1{%
  \@for\@citeb:=#1\do{%
    \edef\@citeb{\expandafter\@firstofone\@citeb}%
    \@ifundefined{flagmeta@\@citeb\APAC@extra@b@citeb}%
      {}% skip
      {{\APACmetastar}}%
    \@ifundefined{spanishe@\@citeb\APAC@extra@b@citeb}%
      {}% skip
      {{% Use `e' instead of `y' in Spanish
       \global\let\oldBBA\BBA
       \global\def\BBA{e\global\let\BBA\oldBBA}%
      }}%
  }%
}%
\def\@ifauthorsunequalc@de#1{%
  \if@F@cite
     \@F@citefalse
  \else
     \if@Y@cite
        {\@BAY}%
     \fi
     {\@BBC}%
  \fi
  \edef\@cite@undefined{?}%
  \def\BBA{\@BBA}%
  \@ifundefined{spanishe@\@citeb\APAC@extra@b@citeb}%
    {}% skip
    {{% Use `e' instead of `y' in Spanish
     \global\let\oldBBA\BBA
     \global\def\BBA{e\global\let\BBA\oldBBA}%
    }}%
  \if@A@cite
     \hyper@natlinkstart{#1}%
     {\csname b@\@citeb\APAC@extra@b@citeb\endcsname}%
     \hyper@natlinkend
     \if@Y@cite
        {\@BBAY}%
     \fi
  \fi
  \if@Y@cite
     \hyper@natlinkstart{#1}%
     {\csname Y@\@citeb\APAC@extra@b@citeb\endcsname}%
     \hyper@natlinkend
  \fi
  \let\BBA\relax
}%
%    \end{macrocode}
% Restore category code of |@| sign.
%    \begin{macrocode}
\APACrestoreAtCode
%</spanish>
%    \end{macrocode}
%
%
% \subsection{\fname{swedish.apc}}
%
% This file redefines the language-specific elements of \pkg{apacite}
% for the Swedish language. Translation of APA elements into Swedish 
% is not obvious. Ideas of which terms to use have been taken from
% \citeA{Erik01}, \citeA{Johnsson}, and \citeA{GU94}.
%
%    \begin{macrocode}
%<*swedish>
%%
%% swedish.apc - swedish translation of apacite elements
%% Written by Stefan Bjork.
%% Small adaptations by Erik Meijer
%%
%    \end{macrocode}
% A fancy way to store and restore the category code of the |@| sign,
% per Heiko Oberdiek.
%    \begin{macrocode}
\edef\APACrestoreAtCode{%
   \catcode`@=\the\catcode`@\relax
}%
\makeatletter
\renewcommand{\onemaskedcitationmsg}[1]{%
    \emph{(#1\ citation removed for masked review)}}% !!! CHANGE
\renewcommand{\maskedcitationsmsg}[1]{%
    \emph{(#1\ citations removed for masked review)}}% !!! CHANGE
%%
%% Name of ref. list if it's a section.
\renewcommand{\refname}{Referenser}%
%% Name of ref. list if it's a chapter.
\renewcommand{\bibname}{Litteraturf\"orteckning}%
%% Author Index
\renewcommand{\authorindexname}{F\"orfattarindex}% 
%%
%% A note before the references if a meta-analysis is reported.
\renewcommand{\APACmetaprenote}{%
  Referenser markerade med stj\"arna avser studier inkluderade i
  metaanalys.}%
%%
%% Commands for specific types of @misc entries.
\renewcommand{\bibmessage}{meddelande}%
\renewcommand{\bibcomputerprogram}{datorprogram}%
\renewcommand{\bibcomputerprogrammanual}{handbok till datorprogram}%
\renewcommand{\bibcomputerprogramandmanual}{datorprogram och handbok}%
\renewcommand{\bibcomputersoftware}{mjukvara}%
\renewcommand{\bibcomputersoftwaremanual}{handbok till mjukvara}%
\renewcommand{\bibcomputersoftwareandmanual}{mjukvara och handbok}%
\renewcommand{\bibprogramminglanguage}{programmeringsspr{\aa}k}%
%%
%% Other labels
\renewcommand{\bibnodate}{u.~\aa{}.\hbox{}}% ``no date''
\renewcommand{\BIP}{i tryck}%                ``in press''
\renewcommand{\BOthers}[1]{m.~fl.\hbox{}}%   ``and others''
\renewcommand{\BOthersPeriod}[1]{m.~fl.\hbox{}}% ``and others'', with a period
\renewcommand{\BIn}{I}%  for ``In'' editor...
\renewcommand{\Bby}{av}% for ``by'' editor... (in reprints)
\renewcommand{\BED}{red.\hbox{}}%          editor
\renewcommand{\BEDS}{red.\hbox{}}%         editors
\renewcommand{\BTRANS}{\"overs.\hbox{}}%   translator
\renewcommand{\BTRANSS}{\"overs.\hbox{}}%  translators
\renewcommand{\BTRANSL}{\"overs.\hbox{}}%  translation, for the year field
\renewcommand{\BCHAIR}{ordf\"orande}%      chair of symposium
\renewcommand{\BCHAIRS}{ordf\"oranden}%    chairs
\renewcommand{\BVOL}{vol.\hbox{}}%         volume
\renewcommand{\BVOLS}{vol.\hbox{}}%        volumes
\renewcommand{\BNUM}{nr.\hbox{}}%          number
\renewcommand{\BNUMS}{nr.\hbox{}}%         numbers
\renewcommand{\BEd}{utg{\aa}van}%          edition
\renewcommand{\BCHAP}{kap.\hbox{}}%        chapter
\renewcommand{\BCHAPS}{kap.\hbox{}}%       chapters
\renewcommand{\BPG}{s.\hbox{}}%            page
\renewcommand{\BPGS}{s.\hbox{}}%          pages
%% Default technical report type name.
\renewcommand{\BTR}{forskningsrapport}%
%% Default PhD thesis type name.
\renewcommand{\BPhD}{doktorsavhandling}%
%% Default unpublished PhD thesis type name.
\renewcommand{\BUPhD}{opublicerad doktorsavhandling}%
%% Default master's thesis type name.
\renewcommand{\BMTh}{examensuppsats}%
%% Default unpublished master's thesis type name.
\renewcommand{\BUMTh}{opublicerad examensuppsats}%
%%
\renewcommand{\BAuthor}{F\"orfattare}%  ``Author'' if publisher = author
\renewcommand{\BOWP}{Original publicerat}% Original work published
\renewcommand{\BREPR}{{\AA}terutgivning fr{\aa}n}% Reprinted from
\renewcommand{\BAvailFrom}{Tillg\"anglig fr{\aa}n\ }% Websites; note the space.
%% The argument is the date on which it was last checked.
\renewcommand{\BRetrieved}[1]{H\"amtad {#1}, fr{\aa}n\ }% Websites; note the space.
\renewcommand{\BRetrievedFrom}{H\"amtad fr{\aa}n\ }% Websites; note the space.
\renewcommand{\BMsgPostedTo}{Meddelande postat till\ }% Messages; note the space.
%%
%% Punctuation
\renewcommand{\BBOP}{(}%   opening parenthesis
\renewcommand{\BBCP}{)}%   closing parenthesis
\renewcommand{\BBOQ}{}%    opening quote for article title
\renewcommand{\BBCQ}{}%    closing quote for article title
\renewcommand{\BBAA}{\&}%  between authors in parenthetical cites and ref. list
\renewcommand{\BBAB}{och}% between authors in text
\renewcommand{\BAnd}{\&}%  for ``Ed. \& Trans.'' in ref. list
\DeclareRobustCommand{\BPBI}{. }% Period between initials
\DeclareRobustCommand{\BHBI}{.-}% Hyphen between initials
\renewcommand{\BAP}{ }%   after prefix, before first citation
\renewcommand{\BBAY}{, }% between author(s) and year
\renewcommand{\BBYY}{, }% between years of multiple citations with same author
\renewcommand{\BBC}{; }%  between cites
\renewcommand{\BBN}{, }%  before note
\renewcommand{\BCBT}{}%   no comma between authors in ref. list when no. of 
                      %%  authors = 2
\renewcommand{\BCBL}{}%   no comma before last author when no. of authors > 2
%%
%% Date formatting; adapted from babel's swedish.dtx
\renewcommand{\APACmonth}[1]{\ifcase #1\or
    januari\or februari\or mars\or april\or maj\or juni\or
    juli\or augusti\or september\or oktober\or november\or
    december\or
    vinter\or v{\aa}r\or sommar\or h\"ost\else
    {#1}\fi}%
%% Numbered version, which is preferred in the form ``(2008, 21/2)''.
\def\APACswedishnumberedmonth#1{\ifcase #1\or
    1\or 2\or 3\or 4\or 5\or 6\or
    7\or 8\or 9\or 10\or 11\or 12\or
    vinter\or v{\aa}r\or sommar\or h\"ost\else
    {#1}\fi}%
\renewcommand{\APACrefYearMonthDay}[3]{%
  {\BBOP}{#1}%             year (+ addendum); should not be empty
  \ifx\@empty#3\@empty
    \ifx\@empty#2\@empty 
    \else
      %% Use full month if there is no day.
      \unskip, {#2}%       month
    \fi
  \else
    \unskip, {#3}%         day
    \ifx\@empty#2\@empty 
    \else
      %% Use numbered month if there is a day as well.
      \let\APACorigmonth\APACmonth
      \let\APACmonth\APACswedishnumberedmonth
      \unskip{}/{#2}%      month
      \let\APACmonth\APACorigmonth
      \let\APACorigmonth\@undefined
    \fi
  \fi
  {\BBCP}%                 closing parenthesis
}%
%% Some macros that transform a number (say, `2') to an ordinal one (`2nd')
\renewcommand{\PrintOrdinal}[1]{%
    \afterassignment\print@ordinal
    \count@ 0#1\relax\@nil
}%
\def\print@ordinal#1#2\@nil{%
    \ifx\relax#1\relax
        \ifnum\count@>\z@
            \CardinalNumeric\count@
        \else
            ??:e%
        \fi
    \else
        \ifnum \count@>\z@ \number\count@ \fi
        #1#2\relax
    \fi
}%
%    \end{macrocode}
% In swedish, ``1st'' = ``1:a'', ``2nd'' = ``2:a'', everything else =
% ``:e''. From 20 onwards, if the last digit is 1 or 2, ``:a'' should
% be used, and otherwise ``:e''.
%    \begin{macrocode}
\renewcommand{\CardinalNumeric}[1]{%
    \number#1\relax
    \if
        \ifnum#1<14
            \ifnum#1>\thr@@ T\else F\fi
        \else
            F%
        \fi
        T%
        :e%
    \else
        \@xp\keep@last@digit\@xp#1\number#1\relax
        \ifcase#1:e\or :a\or :a\or :e\or :e\or :e\or :e\or :e\or :e\or
                 :e\else :e\fi
    \fi
}%
%    \end{macrocode}
% Restore category code of |@| sign.
%    \begin{macrocode}
\APACrestoreAtCode
%</swedish>
%    \end{macrocode}
%
% \section{Bibliography database (\fname{apa5ex.bib})}
%
% This file includes the reference entries of all examples in the
% APA manual, which are all formatted in the \pkg{apacite} reference
% manual. As such, it shows how ordinary and (especially) difficult
% items can be formatted.
%
% \subsection{References from the 5th edition of the Publication Manual}
%
% This includes some additional references that test some rules that are
% mentioned in the text.
%    \begin{macrocode}
%<*bibdb>
%%
%% apa5ex.bib: References from the 5th edition of the Publication Manual
%%             of the APA, plus a few additional references
%% Written by Erik Meijer

%% Entry labels are section number of the APA manual (5th ed.)
%% plus a sequence number within the section.

@misc{3.94-1,
  author = {Walker},
  year   = {2000},
  type   = {Unknown},
}

@misc{3.95-1,
  author = {Wasserstein and Zappulla and Rosen and Gerstman and Rock},
  year   = {1994},
  type   = {Unknown},
}

@misc{3.95-2,
  author = {Bradley and Ramirez and Soo},
  year   = {1994},
  type   = {Unknown},
}

@misc{3.95-3,
  author = {Bradley and Soo and Ramirez and Brown},
  year   = {1994},
  type   = {Unknown},
}

@misc{3.95-4,
  author = {Kosslyn and Koenig and Barrett and Cave and Tang and Gabrieli},
  year   = {1996},
  type   = {Unknown},
}

@misc{3.95-5,
  author = {Kosslyn and Koenig and Gabrieli and Tang and Marsolek and Daly},
  year   = {1996},
  type   = {Unknown},
}

@misc{3.95-6,
  author = {Nightlinger and Littlewood},
  year   = {1993},
  type   = {Unknown},
}

@book{3.95-7,
  author     = {J{\"{o}}reskog, K[arl] G. and S{\"{o}}rbom, D[ag]},
  year       = {1989},
  title      = {{LISREL} 7: {A} Guide to the Program and Applications},
  edition    = {2},
  address    = {Chicago},
  publisher  = {SPSS},
}

@misc{3.96-1,
  author   = {{\bibcorporate{National Institute of Mental Health}}},
  firstkey = {{National Institute of Mental Health [NIMH]}},
  key      = {{NIMH}},
  year     = {1999},
  type     = {Unknown},
}

@misc{3.96-2,
  author   = {{\bibcorporate{University of Pittsburgh}}},
  year     = {1993},
  type     = {Unknown},
}

@book{3.96-3,
  author       = {{\bibcorporate{Koninklijke Nederlandse Schaakbond}}},
  firstkey     = {{Koninklijke Nederlandse Schaakbond [KNSB]}},
  key          = {{KNSB}},
  year         = {2003},
  title        = {Jaarverslag 2002},
  englishtitle = {Annual Report 2002},
  address      = {Amsterdam},
  publisher    = {{\bibcorporate{Koninklijke Nederlandse Schaakbond}}},
  note         = {Fake entry to study sorting and citing of references with
                  same key, but with different firstkey.},
}

@book{3.96-4,
  author       = {{\bibcorporate{Koninklijke Nederlandse Schaakbond}}},
  firstkey     = {{Koninklijke Nederlandse Schaakbond [KNSB]}},
  key          = {{KNSB}},
  year         = {2004},
  title        = {Jaarverslag 2003},
  englishtitle = {Annual Report 2003},
  address      = {Amsterdam},
  publisher    = {{\bibcorporate{Koninklijke Nederlandse Schaakbond}}},
  note         = {Fake entry to study sorting and citing of references with
                  same key, but with different firstkey.},
}

@book{3.96-5,
  author       = {{\bibcorporate{Koninklijke Nederlandse Schaatsbond}}},
  firstkey     = {{Koninklijke Nederlandse Schaatsbond [KNSB]}},
  key          = {{KNSB}},
  year         = {2003},
  title        = {Jaarverslag 2002},
  englishtitle = {Annual Report 2002},
  address      = {Amsterdam},
  publisher    = {{\bibcorporate{Koninklijke Nederlandse Schaatsbond}}},
  note         = {Fake entry to study sorting and citing of references with
                  same key, but with different firstkey.},
}

@book{3.96-6,
  author       = {{\bibcorporate{Koninklijke Nederlandse Schaatsbond}}},
  firstkey     = {{Koninklijke Nederlandse Schaatsbond [KNSB]}},
  key          = {{KNSB}},
  year         = {2004},
  title        = {Jaarverslag 2003},
  englishtitle = {Annual Report 2003},
  address      = {Amsterdam},
  publisher    = {{\bibcorporate{Koninklijke Nederlandse Schaatsbond}}},
  note         = {Fake entry to study sorting and citing of references with
                  same key, but with different firstkey.},
}

@magazine{3.97-1,
  key     = {{\APACciteatitle{Study Finds}}},
  year    = {1982},
  month   = apr,
  title   = {Study Finds Free Care Used More},
  journal = {{APA} Monitor},
  pages   = {14},
}

@book{3.97-2,
  year      = {1979},
  title     = {College Bound Seniors},
  address   = {Princeton, NJ},
  publisher = {College Board Publications},
}

@misc{3.97-3,
  author = {Anonymous},
  year   = {1998},
  type   = {Unknown},
}

@newspaper{3.97-4,
  year    = {2002},
  month   = mar,
  day     = {3},
  title   = {Editorial},
  journal = {The Edited Newspaper},
  pages   = {2},
  note    = {Fake entry to study sorting and citing of references without
             author, but with the same title.},
}

@newspaper{3.97-5,
  year    = {2003},
  month   = feb,
  day     = {12},
  title   = {Editorial},
  journal = {The Edited Newspaper},
  pages   = {2},
  note    = {Fake entry to study sorting and citing of references without
             author, but with the same title.},
}

@newspaper{3.97-6,
  year    = {2003},
  month   = jan,
  day     = {24},
  title   = {Editorial},
  journal = {The Edited Newspaper},
  pages   = {2},
  note    = {Fake entry to study sorting and citing of references without
             author, but with the same title.},
}

@book{3.98-1,
  author    = {Luce, R. Duncan},
  year      = {1959},
  title     = {Individual Choice Behavior},
  address   = {New York},
  publisher = {Wiley},
}

@misc{3.98-2,
  author = {Luce, P. A.},
  year   = {1986},
  type   = {Unknown},
}

@misc{3.98-3,
  author = {Goldberg, J. M. and Neff},
  year   = {1961},
  type   = {Unknown},
}

@misc{3.98-4,
  author = {Goldberg, M. E. and Wurtz},
  year   = {1972},
  type   = {Unknown},
}

@misc{3.99-1,
  author = {Edeline and Weinberger},
  year   = {1991},
  type   = {Unknown},
}

@misc{3.99-2,
  author = {Edeline and Weinberger},
  year   = {1993},
  type   = {Unknown},
}

@misc{3.99-3,
  author = {Gogel},
  year   = {1984},
  type   = {Unknown},
}

@misc{3.99-4,
  author = {Gogel},
  year   = {1990},
  type   = {Unknown},
}

@misc{3.99-5,
  author = {Gogel},
  year   = {\BIP},
  type   = {Unknown},
}

@misc{3.99-6,
  author = {Johnson},
  year   = {1991},
  title  = {Aaa},
}

@misc{3.99-7,
  author = {Johnson},
  year   = {1991},
  title  = {Bbb},
}

@misc{3.99-8,
  author = {Johnson},
  year   = {1991},
  title  = {Ccc},
}

@misc{3.99-9,
  author = {Singh},
  year   = {1983},
  type   = {Unknown},
}

@misc{3.99-10,
  author = {Singh},
  year   = {\BIP},
  title  = {Aaa},
}

@misc{3.99-11,
  author = {Singh},
  year   = {\BIP},
  title  = {Bbb},
}

@misc{3.99-12,
  author = {Balda},
  year   = {1980},
  type   = {Unknown},
}

@misc{3.99-13,
  author = {Kamil},
  year   = {1988},
  type   = {Unknown},
}

@misc{3.99-14,
  author = {Pepperberg and Funk},
  year   = {1990},
  type   = {Unknown},
}

@misc{3.99-15,
  author = {Minor},
  year   = {2001},
  type   = {Unknown},
}

@misc{3.99-16,
  author = {Adams},
  year   = {1999},
  type   = {Unknown},
}

@misc{3.99-17,
  author = {Storandt},
  year   = {1997},
  type   = {Unknown},
}

@misc{3.100-1,
  author = {Author},
  year   = {\bibnodate},
  type   = {Unknown},
  note   = {no example, but rule given in text},
}

@misc{3.100-1b,
  author = {Author},
  year   = {2003 version},
  type   = {Unknown},
  note   = {no example, but rule given in text},
}

@book{3.100-2,
  author = {Aristotle},
  year   = {1931},
  title  = {Unknown},
  translator = {Someone},
  originalyear = {\bibnodate},
}

@book{3.100-3,
  author = {James},
  year   = {1983},
  title  = {Unknown},
  originalyear = {1890},
}

@misc{3.101-1,
  author = {Cheek and Buss},
  year   = {1981},
  type   = {Unknown},
}

@misc{3.101-2,
  author = {Shimamura},
  year   = {1989},
  type   = {Unknown},
}

@misc{3.101-3,
  author = {Myers},
  year   = {2000},
  type   = {Unknown},
}

@misc{3.101-4,
  author = {Beutler},
  year   = {2000},
  type   = {Unknown},
}

@misc{3.103-1,
  author = {Hashtroudi and Chrosniak and Schwartz},
  year   = {1991},
  type   = {Unknown},
}

@misc{4.04-t1,
  author = {Brown, J. R.},
  year   = {\bibnodate},
  type   = {Unknown},
}

@misc{4.04-t2,
  author = {Browning, A. R.},
  year   = {\bibnodate},
  type   = {Unknown},
}

@misc{4.04-t3,
  author = {MacArthur},
  year   = {\bibnodate},
  type   = {Unknown},
}

@misc{4.04-t4,
  author = {McAllister},
  year   = {\bibnodate},
  type   = {Unknown},
}

@misc{4.04-t5,
  author = {MacNeil},
  year   = {\bibnodate},
  type   = {Unknown},
}

@misc{4.04-t6,
  author = {M'Carthy},
  year   = {\bibnodate},
  type   = {Unknown},
}

@misc{4.04-t7,
  author = {DeBase},
  year   = {\bibnodate},
  type   = {Unknown},
}

@misc{4.04-t8,
  author = {De Vries, J.},
  year   = {\bibnodate},
  type   = {Unknown},
}

@misc{4.04-t9,
  author = {von Helmholtz, H. L. F.},
  year   = {\bibnodate},
  type   = {Unknown},
}

@article{4.04-t10,
  year    = {2003},
  title   = {{\APACSortNoop{Two-Thousand and Three}}2003 Hottest Summer Ever},
  journal = {Journal of Meteorology},
  note    = {This is a fake entry, used for didactical purposes.},
}

@misc{4.04-1,
  author = {Hewlett, L. S.},
  year   = {1996},
  type   = {Unknown},
}

@misc{4.04-2,
  author = {Hewlett, L. S.},
  year   = {1999},
  type   = {Unknown},
}

@misc{4.04-3,
  author = {Alleyne, R. L.},
  year   = {2001},
  type   = {Unknown},
}

@misc{4.04-4,
  author = {Alleyne, R. L. and Evans, A. J.},
  year   = {1999},
  type   = {Unknown},
}

@misc{4.04-5,
  author = {Gosling, J. R. and Jerald, K. and Belfar, S. F.},
  year   = {2000},
  type   = {Unknown},
}

@misc{4.04-6,
  author = {Gosling, J. R. and Tevlin, D. F.},
  year   = {1996},
  type   = {Unknown},
}

@misc{4.04-7,
  author = {Hayward, D. and Firsching, A. and Brown, J.},
  year   = {1999},
  type   = {Unknown},
}

@misc{4.04-8,
  author = {Hayward, D. and Firsching, A. and Smigel, J.},
  year   = {1999},
  type   = {Unknown},
}

@misc{4.04-9,
  author = {Cabading, J. R. and Wright, K.},
  year   = {2000},
  type   = {Unknown},
}

@misc{4.04-10,
  author = {Cabading, J. R. and Wright, K.},
  year   = {2001},
  type   = {Unknown},
}

@article{4.04-11,
  author = {Baheti, J. R.},
  year   = {2001},
  title  = {Control {\ldots}},
}

@article{4.04-12,
  author = {Baheti, J. R.},
  year   = {2001},
  title  = {Roles of {\ldots}},
}

@misc{4.04-13,
  author = {Mathur, A. L. and Wallston, J.},
  year   = {1999},
  type   = {Unknown},
}

@misc{4.04-14,
  author = {Mathur, S. E. and Ahlers, R. J.},
  year   = {1998},
  type   = {Unknown},
}

@book{4.05-1,
  author    = {Bandura, A. J.},
  year      = {1977},
  title     = {Social Learning Theory},
  address   = {Englewood Cliffs, NJ},
  publisher = {Prentice Hall},
}

@article{4.05-2,
  author = {Bretschneider, J. G. and McCoy, N. L.},
  year   = {1968},
  title  = {Sexual Interest and Behavior in Healthy
            80- to 102-Year-Olds},
  journal = {Archives of Sexual Behavior},
  volume  = {14},
  pages   = {343--350},
}

@article{4.08-1,
  author  = {Kernis, M. H. and Cornell, D. P. and Sun, C.-R.
             and Berry, A. and Harlow, T.},
  year    = {1993},
  title   = {There's More to Self-Esteem than Whether it is High
             or Low: The Importance of Stability of Self-Esteem},
  journal = {Journal of Personality and Social Psychology},
  volume  = {65},
  pages   = {1190--1204},
}

@book{4.08-2,
  editor    = {Robinson, D. N.},
  year      = {1992},
  title     = {Social Discourse and Moral Judgment},
  address   = {San Diego, CA},
  publisher = {Academic Press},
}

@misc{4.08-3,
  author    = {Bulatao, E. {\protect\bibliteral{(with
               Winford, C.~A.)}\protect\indexskipbracenodot}},
  year      = {\bibnodate},
  type      = {Unknown},
}

@article{4.09-1,
  author = {Fowers, B. J. and Olson, D. H.},
  year   = {1993},
  title  = {{ENRICH} {Marital} {Satisfaction} {Scale}:
            A Brief Research and Clinical Tool},
  journal = {Journal of Family Psychology},
  volume  = {7},
  pages   = {176--185},
}

@article{4.10-1,
  author  = {Deutsch, F. M. and Lussier, J. B. and Servis, L. J.},
  year    = {1993},
  title   = {Husbands At Home: Predictors of Paternal Participation
             in Childcare and Housework},
  journal = {Journal of Personality and Social Psychology},
  volume  = {65},
  pages   = {1154--1166},
}

@incollection{4.10-2,
  author    = {O'Neil, J. M. and Egan, J.},
  year      = {1992},
  title     = {Men's and Women's Gender Role Journeys:
               Metaphor for Healing, Transition, and Transformation},
  editor    = {Wainrib, B. R.},
  booktitle = {Gender Issues Across the Life Cycle},
  pages     = {107--123},
  address   = {New York},
  publisher = {Springer},
}

@article{4.11-1,
  author  = {Buss, D. M. and Schmitt, D. P.},
  year    = {1993},
  title   = {Sexual Strategies Theory: An Evolutionary Perspective
             on Human Mating},
  journal = {Psychological Review},
  volume  = {100},
  pages   = {204--232},
}

@magazine{4.11-2,
  author  = {Henry, III, W. A.},
  year    = {1990},
  month   = apr,
  day     = {9},
  title   = {Beyond the Melting Pot},
  journal = {Time},
  volume  = {135},
  pages   = {28--31},
}

@book{4.12-1,
  author    = {Saxe, G. B.},
  year      = {1991},
  title     = {Cultural and Cognitive Development: Studies in
               Mathematical Understanding},
  address   = {Hillsdale, NJ},
  publisher = {Erlbaum},
}

@incollection{4.13-1,
  author    = {Baker, F. M. and Lightfoot, O. B.},
  year      = {1993},
  title     = {Psychiatric Care of Ethnic Elders},
  editor    = {Gaw, A. C.},
  booktitle = {Culture, Ethnicity, and Mental Illness},
  pages     = {517--552},
  address   = {Washington, DC},
  publisher = {American Psychiatric Press},
}

@incollection{4.13-2,
  author    = {Merikle, Philip M.},
  year      = {2000},
  title     = {Subliminal Perception},
  editor    = {Kazdin, Alan E. and Blanchard, Edward B. and
               Bootzin, Richard R. and Bower, Gordon and
               Close Conoley, Jane and Deaux, Kay and Fox, Ronald E. and
               Harmon, Lenore W. and Howell, William C. and
               Marsella, Anthony J. and Price, Richard H. and
               Roediger, III, Henry L. and Rosenthal, Robert and
               Schmitt, Neal W. and Singer, Jerome L. and Squire, Larry R. and
               Zahn-Waxler, Carolyn},
  booktitle = {Encyclopedia of Psychology},
  volume    = {7},
  pages     = {497--499},
  address   = {New York},
  publisher = {Oxford University Press},
}

@misc{4.15-1,
  key         = {{\APACcitebtitle{Electronic Reference Formats}}},
  title       = {Electronic Reference Formats Recommended by the
                 {American} {Psychological} {Association}},
  year        = {2000},
  month       = oct,
  day         = {12},
  lastchecked = {October 23, 2000},
  URL         = {http://www.apa.org/journals/webref.html},
}

@article{4.15-2,
  author = {Eid, M. and Langeheine, R.},
  year   = {1999},
  title  = {The Measurement of Consistency and Occasion Specificity
            with Latent Class Models: A New Model and its
            Application to the Measurement of Affect},
  journal = {Psychological Methods},
  volume  = {4},
  pages   = {100--116},
  howpublished = {Retrieved November 19, 2000, from the PsycARTICLES database},
}

%
%  The rest is from section 4.16. Section number is omitted,
%  but A-I are used instead. For the numbered examples, these
%  letters are also omitted in favor of ``ex''.
%

@article{A-1,
  author  = {Herman, L. M. and Kuczaj, III, S. A. and Holder, M. D.},
  year    = {1993},
  title   = {Responses to Anomalous Gestural Sequences by a
             Language-Trained Dolphin: {E}vidence for Processing
             of Semantic Relations and Syntactic Information},
  journal = {Journal of Experimental Psychology: General},
  volume  = {122},
  pages   = {184--194},
}

@article{ex1,
  author  = {Mellers, B. A.},
  year    = {2000},
  title   = {Choice and the Relative Pleasure of Consequences},
  journal = {Psychological Bulletin},
  volume  = {126},
  pages   = {910--924},
}

@article{ex2,
  author  = {Klimoski, R. and Palmer, S.},
  year    = {1993},
  title   = {The {ADA} and the Hiring Process in Organizations},
  journal = {Consulting Psychology Journal: Practice and Research},
  volume  = {45},
  number  = {2},
  pages   = {10--36},
}

@article{ex3,
  author  = {Saywitz, K. J. and Mannarino, A. P. and Berliner, L.
             and Cohen, J. A.},
  year    = {2000},
  title   = {Treatment for Sexually Abused Children and Adolescents},
  journal = {American Psychologist},
  volume  = {55},
  pages   = {1040--1049},
}

@article{ex4,
  author  = {Wolchik, S. A. and West, S. G. and Sandler, I. N. and
             Tein, J. and Coatsworth, D. and Lengua, L. and others},
  year    = {2000},
  title   = {An Experimental Evaluation of Theory-Based Mother and
             Mother-Child Programs for Children of Divorce},
  journal = {Journal of Consulting and Clinical Psychology},
  volume  = {68},
  pages   = {843--856},
}

@article{ex4-2,
  author  = {Swait, Joffre and Adamowicz, Wiktor and Hanemann, Michael
             and Diederich, Adele and Krosnick, Jon and Layton, David
             and Provencher, William and Schkade, David and Tourangeau, Roger},
  year    = {2002},
  title   = {Context Dependence and Aggregation
             in Disaggregate Choice Analysis},
  journal = {Marketing Letters},
  volume  = {13},
  pages   = {195--205},
}

@article{ex5,
  author  = {Zuckerman, M. and Kieffer, S. C.},
  year    = {\BIP},
  title   = {Race Differences in Face-ism: {D}oes Facial Prominence
             Imply Dominance?},
  journal = {Journal of Personality and Social Psychology},
}

@magazine{ex6,
  author  = {Kandel, E. R. and Squire, L. R.},
  year    = {2000},
  month   = nov,
  day     = {10},
  title   = {Neuroscience: {B}reaking Down Scientific Barriers to the
             Study of Brain and Mind},
  journal = {Science},
  volume  = {290},
  pages   = {1113--1120},
}

@article{ex7,
  author  = {Brown, L. S.},
  year    = {1993},
  month   = spring,
  title   = {Antidomination Training as a Central Component of
             Diversity in Clinical Psychology Education},
  journal = {The Clinical Psychologist},
  volume  = {46},
  pages   = {83--87},
}

@article{ex8,
  year    = {1993},
  month   = aug # "/" # sep,
  title   = {The New Health-Care Lexicon},
  journal = {Copy Editor},
  volume  = {4},
  pages   = {1--2},
}

@newspaper{ex9,
  key     = {{\APACciteatitle{New Drug}}},
  year    = {1993},
  month   = jul,
  day     = {15},
  title   = {New Drug Appears to Sharply Cut Risk of Death from
             Heart Failure},
  journal = {The Washington Post},
  pages   = {A12},
}

@newspaper{ex10,
  author  = {Schwartz, J.},
  year    = {1993},
  month   = sep,
  day     = {30},
  title   = {Obesity Affects Economic, Social Status},
  journal = {The Washington Post},
  pages   = {A1, A4},
}

@newspaper{ex11,
  author  = {Berkowitz, A. D.},
  year    = {2000},
  month   = nov,
  day     = {24},
  title   = {How to Tackle the Problem of Student Drinking},
  type    = {Letter to the editor},
  journal = {The Chronicle of Higher Education},
  pages   = {B20},
}

@article{ex12,
  editor  = {Barlow, D. H.},
  year    = {1991},
  title   = {Diagnoses, Dimensions, and \emph{DSM-IV}:
             The Science of Classification},
  type    = {Special issue},
  journal = {Journal of Abnormal Psychology},
  volume  = {100},
  number  = {3},
}

@article{ex13,
  author  = {Harris, P. L. and Kavanaugh, R. D.},
  year    = {1993},
  title   = {Young Children's Understanding of Pretense},
  journal = {Monographs of the Society for Research in Child Development},
  volume  = {58},
  number  = {1, Serial No.~231},
}

@article{ex14,
  author  = {Battig, W. F. and Montague, W. E.},
  year    = {1969},
  title   = {Category Norms for Verbal Items in 56 Categories:
             A Replication and Extension of the {Connecticut}
             Category Norms},
  journal = {Journal of Experimental Psychology Monographs},
  volume  = {80},
  number  = {3, Pt.~2},
}

@article{ex15,
  author  = {Ganster, D. C. and Schaubroeck, J. and Sime, W. E.
             and Mayes, B. T.},
  year    = {1991},
  title   = {The Nomological Validity of the {Type}~{A} Personality
             Among Employed Adults},
  type    = {Monograph},
  journal = {Journal of Applied Psychology},
  volume  = {76},
  pages   = {143--168},
}

@article{ex16,
  author  = {Woolf, N. J. and Young, S. L. and Fanselow, M. S. and
             Butcher, L. L.},
  year    = {1991},
  title   = {{MAP}-2 Expression in Cholinoceptive Pyramidal Cells
             of Rodent Cortex and Hippocampus is Altered by
             {Pavlovian} Conditioning},
  type    = {Abstract},
  journal = {Society for Neuroscience Abstracts},
  volume  = {17},
  pages   = {480},
}

@article{ex17,
  author  = {Nakazato, K. and Shimonaka, Y. and Homma, A.},
  year    = {{\protect\bibreftext{1992}{1992/1993}}},
  title   = {Cognitive Functions of Centenarians: The {Tokyo}
             {Metropolitan} {Centenarian} {Study}},
  journal = {Japanese Journal of Developmental Psychology},
  volume  = {3},
  pages   = {9--16},
  howpublished = {Abstract obtained from
             {\APACcitebtitle{PsycSCAN: Neuropsychology}},
             1993, \emph{2}, Abstract No.~604},
}

@article{ex18,
  author  = {Regier, A. A. and Narrow, W. E. and Rae, D. S.},
  year    = {1990},
  title   = {The Epidemiology of Anxiety Disorders: The Epidemiologic
             Catchment Area ({ECA}) Experience},
  journal = {Journal of Psychiatric Research},
  volume  = {24},
  number  = {Suppl.~2},
  pages   = {3--14},
}

@article{ex19,
  author  = {Fiske, S. T.},
  year    = {1993},
  title   = {Social Cognition and Social Perception},
  journal = {Annual Review of Psychology},
  volume  = {44},
  pages   = {155--194},
}

@article{ex20,
  author  = {Ising, M.},
  year    = {2000},
  title   = {Intensit{\"{a}}tsabh{\"{a}}ngigkeit evozierter {Potenzial} im
             {EEG}: Sind impulsive {Personen} {Augmenter} oder
             {Reducer}?},
  englishtitle = {Intensity Dependence in Event-Related {EEG} Potentials:
             Are Impulsive Individuals Augmenters or Reducers?},
  journal = {Zeitschrift f{\"{u}}r Differentielle und Diagnostische
             Psychologie},
  volume  = {21},
  pages   = {208--217},
}

@article{ex21,
  author  = {Stutte, H.},
  year    = {1972},
  title   = {Transcultural Child Psychiatry},
  journal = {Acta Paedopsychiatrica},
  volume  = {38},
  number  = {9},
  pages   = {229--231},
}

@article{ex22,
  author  = {Coltheart, M. and Curtis, B. and Atkins, P. and Haller, M.},
  year    = {1993},
  title   = {Models of Reading Aloud: Dual-Route and
             Parallel-Distributed-Processing Approaches},
  journal = {Psychological Review},
  volume  = {100},
  pages   = {589--608},
}

@book{B-1,
  author    = {Beck, C. A. J. and Sales, B. D.},
  year      = {2001},
  title     = {Family Mediation: Facts, Myths, and Future Prospects},
  address   = {Washington, DC},
  publisher = {American Psychological Association},
}

@book{ex23,
  author    = {Mitchell, T. R. and Larson, Jr.\hbox{}, J. R.},
  year      = {1987},
  title     = {People in Organizations: An Introduction to
               Organizational Behavior},
  edition   = {3},
  address   = {New York},
  publisher = {McGraw-Hill},
}

@book{ex24,
  author    = {{\bibcorporate{Australian Bureau of Statistics}}},
  year      = {1991},
  title     = {Estimated Resident Population by Age and Sex in
               Statistical Local Areas, {New} {South} {Wales},
               {June} 1990},
  number    = {3209.1},
  address   = {Canberra, Australian Capital Territory},
  publisher = {{\bibcorporate{Australian Bureau of Statistics}}},
}

@book{ex25,
  editor    = {Gibbs, J. T. and Huang, L. N.},
  year      = {1991},
  title     = {Children of Color: Psychological Interventions with
               Minority Youth},
  address   = {San Francisco},
  publisher = {Jossey-Bass},
}

@book{ex25-t1,
  author         = {Vygotsky, L. S.},
  year           = {1978},
  title          = {Mind in Society: {T}he Development of Higher Mental
                    Processes},
  editor         = {Rice, Edgar},
  translator     = {Rice, Edgar},
  address        = {Cambridge, MA},
  publisher      = {Harvard University Press},
  originalyear   = {1930, 1933, 1935},
}

@book{ex25-t2,
  author         = {J{\"{o}}reskog, Karl G. and S{\"{o}}rbom, Dag},
  year           = {1979},
  title          = {Advances in Factor Analysis
                    and Structural Equation Models},
  editor         = {Magidson, Jay},
  address        = {Cambridge, MA},
  publisher      = {Abt Books},
}

@book{ex26,
  year      = {1993},
  title     = {Merriam-{Webster}'s Collegiate Dictionary},
  edition   = {10},
  address   = {Springfield, MA},
  publisher = {Merriam-Webster},
}

@book{ex27,
  author    = {Rosenthal, R.},
  year      = {1987},
  title     = {Meta-Analytic Procedures for Social Research},
  edition   = {Rev.\hbox{}},
  address   = {Newbury Park, CA},
  publisher = {Sage},
}

@book{ex28,
  editor    = {Koch, S.},
  year      = {1959--1963},
  title     = {Psychology: {A} Study of Science},
  volume    = {1--6},
  address   = {New York},
  publisher = {McGraw-Hill},
}

@book{ex29,
  key       = {{\bibDSM{American Psychiatric
               Association}{Diagnostic and Statistical Manual
               of Mental Disorders}{4th ed.\hbox{}}{DSM-IV}}},
  author    = {{\bibcorporate{American Psychiatric Association}}},
  year      = {1994},
  title     = {Diagnostic and Statistical Manual of Mental Disorders},
  edition   = {4},
  address   = {Washington, DC},
  publisher = {{\bibcorporate{American Psychiatric Association}}},
}

@book{ex30,
  editor    = {Sadie, S.},
  year      = {1980},
  title     = {The New {G}rove Dictionary of Music and Musicians},
  edition   = {6},
  volume    = {1--20},
  address   = {London},
  publisher = {Macmillan},
}

@book{ex30-2,
  editor    = {Kazdin, Alan E. and Blanchard, Edward B. and
               Bootzin, Richard R. and Bower, Gordon and
               Close Conoley, Jane and Deaux, Kay and Fox, Ronald E. and
               Harmon, Lenore W. and Howell, William C. and
               Marsella, Anthony J. and Price, Richard H. and
               Roediger, III, Henry L. and Rosenthal, Robert and
               Schmitt, Neal W. and Singer, Jerome L. and Squire, Larry R. and
               Zahn-Waxler, Carolyn},
  year      = {2000},
  title     = {Encyclopedia of Psychology},
  address   = {New York},
  publisher = {Oxford University Press},
}

@book{ex31,
  author    = {Piaget, J. and Inhelder, B.},
  year      = {1951},
  title     = {La Gen{\`{e}}se de l'Id{\'{e}}e de Hasard chez l'Enfant},
  englishtitle = {The Origin of the Idea of Chance in the Child},
  address   = {Paris},
  publisher = {Presses Universitaires de France},
}

@book{ex32,
  author    = {Laplace, P.-S.},
  year      = {1951},
  title     = {A Philosophical Essay on Probabilities},
  translator = {Truscott, F. W. and Emory, F. L.},
  address   = {New York},
  publisher = {Dover},
  originalyear = {1814},
}

@book{ex33,
  author    = {{\bibcorporate{Research and Training Center on
               Independent Living}}},
  firstkey  = {{Research and Training Center on Independent Living [RTCIL]}},
  key       = {RTCIL},
  year      = {1993},
  title     = {Guidelines for Reporting and Writing About People
               with Disabilities},
  edition   = {4},
  type      = {Brochure},
  address   = {Lawrence, KS},
  publisher = {{\bibcorporate{Research and Training Center on
               Independent Living}}},
}

@incollection{B-2,
  author    = {Massaro, D.},
  year      = {1992},
  title     = {Broadening the Domain of the Fuzzy Logical Model of Perception},
  editor    = {Pick, Jr.\hbox{}, H. L. and van den Broek, P. and Knill, D. C.},
  booktitle = {Cognition: Conceptual and Methodological Issues},
  pages     = {51--84},
  address   = {Washington, DC},
  publisher = {American Psychological Association},
}

@incollection{ex34,
  author    = {Bjork, R. A.},
  year      = {1989},
  title     = {Retrieval Inhibition as an Adaptive Mechanism in Human Memory},
  editor    = {Roediger, III, H. L. and Craik, F. I. M.},
  booktitle = {Varieties of Memory \& Consciousness},
  pages     = {309--330},
  address   = {Hillsdale, NJ},
  publisher = {Erlbaum},
}

@incollection{ex35,
  author    = {Auerbach, J. S.},
  year      = {\BIP},
  title     = {The Origins of Narcissism and Narcissistic Personality
               Disorder: A Theoretical and Empirical Reformulation},
  editor    = {Masling, J. M. and Bornstein, R. F.},
  booktitle = {Empirical Studies of Psychoanalytic Theories:
               {Vol}.~4. {Psychoanalytic} Perspectives on Psychopathology},
  address   = {Washington, DC},
  publisher = {American Psychological Association},
}

@incollection{ex36,
  author    = {Maccoby, E. E. and Martin, J.},
  year      = {1983},
  title     = {Socialization in the Context of the Family:
               Parent-Child Interaction},
  editor    = {Mussen (Series Ed.\hbox{}), P. H. and
               Hetherington{\bibeditortype{Vol.\ Ed.\hbox{}}}, E. M.},
  booktitle = {Handbook of Child Psychology:
               {Vol}.~4. {Socialization}, Personality, and Social Development},
  edition   = {4},
  pages     = {1--101},
  address   = {New York},
  publisher = {Wiley},
}

@incollection{ex37,
  author       = {Davydov, V. V.},
  year         = {1972},
  title        = {De Introductie van het Begrip Grootheid in de Eerste
                  Klas van de Basisschool: Een Experimenteel Onderzoek},
  englishtitle = {The Introduction of the Concept of Quantity in the
                  First Grade of the Primary School: An Experimental Study},
  editor       = {Van Parreren, C. F. and Carpay, J. A. M.},
  booktitle    = {Sovjetpsychologen aan het Woord},
  pages        = {227--289},
  address      = {Groningen, The Netherlands},
  publisher    = {Wolters-Noordhoff},
}

@incollection{ex38,
  author       = {Bergmann, P. G.},
  year         = {1993},
  title        = {Relativity},
  booktitle    = {The New Encyclopaedia {Britannica}},
  volume       = {26},
  pages        = {501--508},
  address      = {Chicago},
  publisher    = {Encyclopaedia Britannica},
}

@incollection{ex39,
    author       = {Freud, Sigmund},
    year         = {1961},
    title        = {The Ego and the Id},
    editor       = {Strachey, J.},
    translator   = {Strachey, J.},
    booktitle    = {The Standard Edition of the Complete Psychological
                    Works of {Sigmund} {Freud}},
    volume       = {19},
    pages        = {3--66},
    address      = {London},
    publisher    = {Hogarth Press},
    originalyear = {1923},
}

@incollection{ex40,
    author       = {Piaget, J.},
    year         = {1988},
    title        = {Extracts from {Piaget}'s Theory},
    translator   = {Gellerier, G. and Langer, J.},
    editor       = {Richardson, K. and Sheldon, S.},
    booktitle    = {Cognitive Development to Adolescence: A Reader},
    pages        = {3--18},
    address      = {Hillsdale, NJ},
    publisher    = {Erlbaum},
    originalbooktitle = {Manual of Child Psychology},
    originalpages     = {703--732},
    originaleditor    = {Mussen, P. H.},
    originalyear      = {1970},
    originaladdress   = {New York},
    originalpublisher = {Wiley},
}

@incollection{ex40-t1,
   author          = {Browne, M[ichael] W.},
   year            = {1977},
   title           = {Generalized Least Squares Estimators in the Analysis
                      of Covariance Structures},
   editor          = {Aigner, D[ennis] J. and Goldberger, A[rthur] S.},
   booktitle       = {Latent Variables in Socio-Economic Models},
   pages           = {205--226},
   address         = {Amsterdam},
   publisher       = {North Holland},
   originalyear    = {1974},
   originaljournal = {South African Statistical Journal},
   originalvolume  = {8},
   originalpages   = {1--24},
}


@techreport{C-1,
  author      = {Mazzeo, J. and Druesne, B. and Raffeld, P. C.
                 and Checketts, K. T. and Muhlstein, A.},
  year        = {1991},
  title       = {Comparability of Computer and Paper-and-Pencil Scores
                 for Two {CLEP} General Examinations},
  type        = {College Board Rep.},
  number      = {91-5},
  address     = {Princeton, NJ},
  institution = {Educational Testing Service},
}

@techreport{ex41,
  author      = {{\bibcorporate{National Institute of Mental Health}}},
  firstkey    = {{National Institute of Mental Health [NIMH]}},
  key         = {{NIMH}},
  year        = {1990},
  title       = {Clinical Training in Serious Mental Illness},
  type        = {{DHHS} Publication},
  number      = {ADM 90-1679},
  address     = {Washington, DC},
  institution = {U.S. Government Printing Office},
}

@techreport{ex42,
  author      = {Osgood, D. W. and Wilson, J. K.},
  year        = {1990},
  title       = {Covariation of Adolescent Health Problems},
  type        = {\bibnotype},
  address     = {Lincoln},
  institution = {University of Nebraska},
  note        = {NTIS No.\hbox{} PB~91-154~377/AS},
}

@techreport{ex43,
  author      = {Mead, J. V.},
  year        = {1992},
  title       = {Looking at Old Photographs: Investigating the Teacher
                 Tales that Novice Teachers Bring with Them},
  type        = {Report},
  number      = {NCRTL-RR-92-4},
  address     = {East Lansing, MI},
  institution = {National Center for Research on Teacher Learning},
  note        = {ERIC Document Reproduction Service No.\hbox{} ED346082},
}

@techreport{ex44,
  author      = {{\bibcorporate{U.S. Department of Health and
                 Human Services}}},
  firstkey    = {{U.S. Department of Health and Human Services [DHHS]}},
  key         = {{DHHS}},
  year        = {1992},
  title       = {Pressure Ulcers in Adults: Prediction and Prevention},
  type        = {AHCPR Publication},
  number      = {92-0047},
  address     = {Rockville, MD},
  institution = {{\bibcorporate{U.S. Department of Health and
                 Human Services}}},
}

@intechreport{ex45,
  author      = {Matthews, K. A.},
  year        = {1985},
  title       = {Assessment of {Type}~{A} Behavior, Anger, and Hostility
                 in Epidemiologic Studies of Cardiovascular Disease},
  editor      = {Ostfield, A. M. and Eaker, E. D.},
  booktitle   = {Measuring Psychological Variables in Epidemiologic Studies
                 of Cardiovascular Disease},
  type        = {NIH Publication},
  number      = {85-2270},
  pages       = {153--183},
  address     = {Washington, DC},
  institution = {U.S. Department of Health and Human Services},
}

@techreport{ex46,
  author      = {Broadhurst, R. G. and Maller, R. A.},
  year        = {1991},
  title       = {Sex Offending and Recidivism},
  number      = {3},
  address     = {Nedlands},
  institution = {University of Western Australia, Crime Research Centre},
}

@techreport{ex47,
  editor      = {Shuker, R. and Openshaw, R. and Soler, J.},
  year        = {1990},
  title       = {Youth, Media, and Moral Panic in {New} {Zealand}:
                 From Hooligans to Video Nasties},
  type        = {Delta Research Monograph},
  number      = {11},
  address     = {Palmerston North, New Zealand},
  institution = {Massey University, Department of Education},
}

@techreport{ex48,
  author      = {{\bibcorporate{Employee Benefit Research Institute}}},
  firstkey    = {{Employee Benefit Research Institute [EBRI]}},
  key         = {{EBRI}},
  year        = {1992},
  month       = feb,
  title       = {Sources of Health Insurance and Characteristics of the
                 Uninsured},
  type        = {Issue Brief},
  number      = {123},
  address     = {Washington, DC},
  institution = {{\bibcorporate{Employee Benefit Research Institute}}},
}

@incollection{ex49,
  author       = {Deci, E. L. and Ryan, R. M.},
  year         = {1991},
  title        = {A Motivational Approach to Self:
                  Integration in Personality},
  editor       = {Dienstbier, R.},
  booktitle    = {Nebraska {Symposium} on {Motivation}: Vol.~38.
                  {Perspectives} on Motivation},
  pages        = {237--288},
  address      = {Lincoln},
  publisher    = {University of Nebraska Press},
}

@article{ex50,
  author  = {Cynx, J. and Williams, H. and Nottebohm, F.},
  year    = {1992},
  title   = {Hemispheric Differences in Avian Song Discrimination},
  journal = {Proceedings of the National Academy of Sciences, USA},
  volume  = {89},
  pages   = {1372--1375},
}

@lecture{ex51,
  author       = {Lichstein, K. L. and Johnson, R. S. and Womack, T. D.
                  and Dean, J. E. and Childers, C. K.},
  year         = {1990},
  month        = jun,
  title        = {Relaxation Therapy for Polypharmacy Use in Elderly
                  Insomniacs and Noninsomniacs},
  chair        = {Rosenthal, T. L.},
  symposium    = {Reducing Medication in Geriatric Populations},
  howpublished = {Symposium conducted at the meeting of the First
                  International Congress of Behavioral Medicine},
  address      = {Uppsala, Sweden},
}

@lecture{ex52,
  author       = {Lanktree, C. and Briere, J.},
  year         = {1991},
  month        = jan,
  title        = {Early Data on the {Trauma} {Symptom} {Checklist}
                  for {Children} ({TSC-C})},
  howpublished = {Paper presented at the meeting of the American
                  Professional Society on the Abuse of Children},
  address      = {San Diego, CA},
}

@lecture{ex53,
  author       = {Ruby, J. and Fulton, C.},
  year         = {1993},
  month        = jun,
  title        = {Beyond Redlining: Editing Software that Works},
  howpublished = {Poster session presented at the annual meeting of the
                  Society for Scholarly Publishing},
  address      = {Washington, DC},
}

@phdthesis{ex54,
  author       = {Bower, D. L.},
  year         = {1993},
  title        = {Employee Assistant Programs Supervisory Referrals:
                  Characteristics of Referring and Nonreferring
                  Supervisors},
  journal      = {Dissertation Abstracts International},
  volume       = {54},
  number       = {01},
  pages        = {534B},
  note         = {UMI No.~9315947},
}

@phdthesis{ex55,
  author       = {Ross, D. F.},
  year         = {1990},
  title        = {Unconscious Transference and Mistaken Identity: When
                  a Witness Misidentifies a Familiar but Innocent Person
                  from a Lineup},
  school       = {Cornell University},
  originalyear = {1990},
  journal      = {Dissertation Abstracts International},
  volume       = {51},
  pages        = {417},
}

@phdthesis{ex56,
  author       = {Wilfley, D. E.},
  year         = {1989},
  title        = {Interpersonal Analyses of Bulimia: Normalweight
                  and Obese},
  school       = {University of Missouri},
  address      = {Columbia},
}

@mastersthesis{ex57,
  author       = {Almeida, D. M.},
  year         = {1990},
  title        = {Fathers' Participation in Family Work: Consequences
                  for Fathers' Stress and Father--Child Relations},
  school       = {University of Victoria},
  address      = {Victoria, British Columbia, Canada},
}

@unpublished{ex58,
  author       = {Stinson, C. and Milbrath, C. and Reidbord, S. and Bucci, W.},
  year         = {1992},
  title        = {Thematic Segmentation of Psychotherapy Transcripts for
                  Convergent Analyses},
  howpublished = {Unpublished manuscript},
}

@unpublished{ex59,
  author       = {D{\'{e}}pret, E. F. and Fiske, S. T.},
  year         = {1993},
  title        = {Perceiving the Powerful: Intriguing Individuals Versus
                  Threatening Groups},
  howpublished = {Unpublished manuscript},
  organization = {University of Massachusetts at Amherst},
}

@unpublished{ex60,
  author       = {McIntosh, D. N.},
  year         = {1993},
  title        = {Religion as Schema, with Implications for the Relation
                  Between Religion and Coping},
  howpublished = {Manuscript submitted for publication},
}

@unpublished{ex61,
  author       = {Bordi, F. and LeDoux, J. E.},
  year         = {1993},
  type         = {Auditory response latencies in rat auditory cortex},
  howpublished = {Unpublished raw data},
}

@misc{ex62,
  editor       = {Klombers, N.},
  year         = {1993},
  month        = spring,
  title        = {{ADAA} {Reporter}},
  note         = {Available from the Anxiety Disorders Association of
                  America, 6000 Executive Boulevard, Suite 513,
                  Rockville, MD 20852},
}

@article{G-1,
  author       = {Mroczek, D. K.},
  year         = {2000},
  title        = {The Emerging Study of Midlife},
  type         = {Review of the book {\APACcitebtitle{Life in the middle:
                  Psychological and social development in middle age}}},
  journal      = {Contemporary Psychology: APA Review of Books},
  volume       = {45},
  pages        = {482--485},
}

@article{ex63,
  author       = {Schatz, B. R.},
  year         = {2000},
  title        = {Learning by Text or Context?},
  type         = {Review of the book
                  {\APACcitebtitle{The social life of information}}},
  journal      = {Science},
  volume       = {290},
  pages        = {1304},
}

@article{ex64,
  author       = {Kraus, S. J.},
  year         = {1992},
  title        = {Visions of Psychology: A Videotext of Classic Studies},
  type         = {Review of the motion picture
                  {\APACcitebtitle{Discovering Psychology}}},
  journal      = {Contemporary Psychology},
  volume       = {37},
  pages        = {1146--1147},
}

@misc{ex65-1,
  author    = {Scorsese, M. {\protect\bibliteral{(Producer)}\protect\bibskipbracenodot}
               and Lonergan, K.
               {\protect\bibliteral{(Writer/Director)}\protect\indexskipbracenodot}},
  year      = {2000},
  title     = {You Can Count On Me},
  type      = {Motion picture},
  address   = {United States},
  publisher = {Paramount Pictures},
}

@misc{ex65-2,
  author    = {Harrison, J. {\protect\bibliteral{(Producer)}\protect\bibskipbracenodot}
               and Schmiechen, R.
               {\protect\bibliteral{(Director)}\protect\indexskipbracenodot}},
  year      = {1992},
  title     = {Changing Our Minds: The Story of {Evelyn} {Hooker}},
  type      = {Motion picture},
  note      = {Available from Changing Our Minds, Inc., 170 West End
               Avenue, Suite 25R, New York, NY 10023},
}

@misc{ex65-3,
  author    = {{\bibcorporate{American Psychological Association (Producer)}}},
  firstkey  = {{American Psychological Association [APA]}},
  key       = {{APA}},
  year      = {2000},
  title     = {Responding Therapeutically to Patient Expressions of
               Sexual Attraction: A Stimulus Training Tape},
  type      = {Motion picture},
  note      = {Available from the American Psychological Association,
               750 First Street, NE, Washington, DC 20002-4242},
}

@misc{ex66,
  author    = {Crystal, L. {\protect\bibliteral{(Executive
                            Producer)}\protect\indexskipbracenodot}},
  year      = {1993},
  month     = oct,
  day       = {11},
  title     = {The {MacNeil}/{Lehrer} News Hour},
  type      = {Television broadcast},
  address   = {New York and Washington, DC},
  publisher = {Public Broadcasting Service},
}

@misc{ex67,
  editor    = {Miller, {\bibinitial{R\bibeditortype{Producer}}}},
  year      = {1989},
  title     = {The Mind},
  type      = {Television series},
  address   = {New York},
  publisher = {WNET},
}

@incollection{ex68,
  author    = {Hall, B. {\protect\bibliteral{(Writer)}\protect\bibskipbracenodot}
               and Bender, J.
               {\protect\bibliteral{(Director)}\protect\indexskipbracenodot}},
  year      = {1991},
  title     = {The Rules of the Game},
  type      = {Television series episode},
  editor    = {Sander{\bibeditortype{Producer}}, J.},
  booktitle = {I'll Fly Away},
  address   = {New York},
  publisher = {New York Broadcasting Company},
}

@incollection{ex69-1,
  key       = {{\protect\bibsong{Shocked}{1992}{Over the
               Waterfall}{track~5}}},
  author    = {Shocked, Michelle},
  year      = {1992},
  title     = {Over the Waterfall{\bibInstring{\BOn}}},
  booktitle = {Arkansas Traveler {\upshape[\uppercase{CD}]}},
  address   = {New York},
  publisher = {PolyGram Music},
}

@incollection{ex69-2,
  key       = {{\protect\bibsong{Goodenough}{1982}{Tails
                and Trotters}{track~5}}},
  author    = {Goodenough, J. B.},
  year      = {1982},
  title     = {Tails and Trotters{\bibInstring{\BOn}}},
  type      = {Recorded by G. Bok, A. Mayo, \& E. Trickett},
  booktitle = {And So Will We Yet {\upshape[\uppercase{CD}]}},
  address   = {Sharon, CT},
  publisher = {Folk-Legacy Records},
  note      = {1990},
}

@misc{ex70,
  author    = {Costa, Jr.\hbox{} {\protect\bibliteral{(Speaker)}}, P. T.},
  year      = {1988},
  title     = {Personality, Continuity, and Changes of Adult Life},
  type      = {Cassette Recording},
  number    = {207-433-88A-B},
  address   = {Washington, DC},
  publisher = {American Psychological Association},
}

@article{ex71-1,
  author  = {VandenBos, G. and Knapp, S. and Doe, J.},
  year    = {2001},
  title   = {Role of Reference Elements in the Selection of Resources
             by Psychology Undergraduates},
  type    = {Electronic version},
  journal = {Journal of Bibliographic Research},
  volume  = {5},
  pages   = {117--123},
}

@article{ex71-2,
  author      = {VandenBos, G. and Knapp, S. and Doe, J.},
  year        = {2001},
  title       = {Role of Reference Elements in the Selection of Resources
                 by Psychology Undergraduates},
  journal     = {Journal of Bibliographic Research},
  volume      = {5},
  pages       = {117--123},
  lastchecked = {October 13, 2001},
  url         = {http://jbr.org/articles.html},
}

@article{ex72,
  author      = {Fredrickson, B. L.},
  year        = {2000},
  month       = mar,
  day         = {7},
  title       = {Cultivating Positive Emotions to Optimize Health
                 and Well-Being},
  journal     = {Prevention \& Treatment},
  volume      = {3},
  pages       = {Article 0001a},
  lastchecked = {November 20, 2000},
  url         = {http://journals.apa.org/prevention/volume3/pre0030001a.html},
}

@article{ex73,
  author      = {Crow, T. J.},
  year        = {2000},
  title       = {Did \emph{Homo} {\emph{Sapiens}} Speciate on the
                 {\emph{Y}} Chromosome?},
  journal     = {Psycoloquy},
  volume      = {11},
  lastchecked = {March 25, 2001},
  url         = {ftp://ftp.princeton.edu/harnad/Psycoloquy/
                 2000.volume.11/psyc.00.11.001.
                 language-sex-chromosomes.1.crow},
}

@article{ex74,
  author      = {Glueckauf, R. L. and Whitton, J. and Baxter, J. and Kain, J.
                 and Vogelgesang, S. and Hudson, M. and others},
  year        = {1998},
  month       = jul,
  title       = {Videocounseling for Families of Rural Teens with
                 Epilepsy---{P}roject Update},
  journal     = {Telehealth News},
  volume      = {2},
  number      = {2},
  lastchecked = {June 6, 2000},
  url         = {http://www.telehealth.net/subscribe/newslettr_4a.html#1},
}

@misc{ex75,
  author      = {{\bibcorporate{Greater New Milford (Ct) Area Healthy
                  Community 2000,
                  Task Force on Teen and Adolescent Issues}}},
  firstkey    = {{Greater New Milford (Ct) Area Healthy Community 2000,
                  Task Force on Teen and Adolescent Issues [TFTAI]}},
  key         = {{TFTAI}},
  year        = {\bibnodate},
  title       = {Who Has Time for a Family Meal? {You} Do!},
  lastchecked = {October 5, 2000},
  url         = {http://www.familymealtime.org},
}

@incollection{ex76,
  author      = {{\bibcorporate{Benton Foundation}}},
  year        = {1998},
  month       = jul,
  day         = {7},
  title       = {Barriers to Closing the Gap},
  booktitle   = {Losing Ground Bit by Bit: Low-Income Communities in the
                 Information Age},
  chapter     = {2},
  lastchecked = {August 18, 2001},
  url         = {http://www.benton.org/Library/Low-Income/two.html},
}

@misc{ex77,
  year        = {\bibnodate},
  title       = {{GVU}'s 8th {WWW} User Survey},
  lastchecked = {August 8, 2000},
  url         = {http://www.cc.gatech.edu/gvu/user_surveys/survey-1997-10/},
}

@misc{ex78,
  author    = {Chou, L. and McClintock, R. and Moretti, F. and Nix, D. H.},
  year      = {1993},
  title     = {Technology and Education: New Wine in New Bottles:
               Choosing Pasts and Imagining Educational Futures},
  howpublished   = {Retrieved August 24, 2000, from Columbia University,
               Institute for Learning Technologies Web site:
               \url{http://www.ilt.columbia.edu/
                    publications/papers/newwine1.html}\bibnodot{.}},
}

@misc{ex79,
  author    = {{\bibcorporate{University of California, San Francisco,
               Institute for Health and Aging}}},
  firstkey  = {{University of California, San Francisco, Institute for
                Health and Aging [UCSF-IHA]}},
  key       = {{UCSF-IHA}},
  year      = {1996},
  month     = nov,
  title     = {Chronic Care in {A}merica: {A} 21st Century Challenge},
  howpublished   = {Retrieved September 9, 2000, from the Robert Wood Johnson
               Foundation Web site:
               \url{http://www.rwjf.org/library/chrcare/}\bibnodot{.}},
}

@misc{ex80,
  author      = {{\bibcorporate{United States Sentencing Commission}}},
  firstkey    = {{United States Sentencing Commission [USSC]}},
  key         = {{USSC}},
  year        = {\bibnodate},
  title       = {{\APACSortNoop{Nineteen Ninety-Seven}}1997 Sourcebook of
                 Federal Sentencing Statistics},
  lastchecked = {December 8, 1999},
  url         = {http://www.ussc.gov/annrpt/1997/sbtoc97.htm},
}

@misc{ex81,
  author      = {{\bibcorporate{Canarie, Inc.}}},
  year        = {1997},
  month       = sep,
  day         = {27},
  title       = {Towards a {Canadian} Health {IWAY}: Vision, Opportunities
                 and Future Steps},
  lastchecked = {November 8, 2000},
  url         = {http://www.canarie.ca/press/publications/pdf/
                         health/healthvision.doc},
}

@techreport{ex82,
  author    = {Kruschke, J. K. and Bradley, A. L.},
  year      = {1995},
  title     = {Extensions to the Delta Rule of Associative Learning},
  type      = {Indiana University Cognitive Science Research Report},
  number    = {14\BmakeAbstractRetrieved},
  lastchecked = {October 21, 2000},
  url         = {http://www.indiana.edu/~kruschke/deltarule_abstract.html},
}

@lecture{ex83,
  author       = {Cutler, L. D. and Fr{\"{o}}lich, B. and Hanrahan, P.},
  year         = {1997},
  month        = jan,
  day          = {16},
  title        = {Two-Handed Direct Manipulation on the Responsive
                  Workbench},
  howpublished = {Paper presented at the 1997 Symposium on Interactive 3D
                  Graphics\BmakeAbstractRetrieved},
  lastchecked  = {June 12, 2000},
  url          = {http://www.graphics.stanford.edu/papers/twohanded/},
}

@lecture{ex84,
  author       = {Tan, G. and Lewandowsky, S.},
  year         = {1996},
  title        = {A Comparison of Operator Trust in Humans Versus Machines},
  howpublished = {Paper presented at the CybErg 96 virtual conference},
  lastchecked  = {May 16, 2000},
  url          = {http://www.curtin.edu.au/conference/cyberg/
                  centre/outline.cgi/frame?dir=tan},
}

@misc{ex85,
  author = {Chalmers, D.},
  year   = {2000},
  month  = nov,
  day    = {17},
  title  = {Seeing with Sound},
  type   = {\bibmessage},
  number = {1},
  url    = {news://sci.psychology.consciousness}
}

@misc{ex86,
  author = {Simons, D. J.},
  year   = {2000},
  month  = jul,
  day    = {14},
  title  = {News Resources for Visual Cognition},
  type   = {\bibmessage},
  number = {31},
  url    = {http://groups.yahoo.com/group/visualcognition/message/31},
}

@misc{ex87,
  author = {Hammond, T.},
  year   = {2000},
  month  = nov,
  day    = {20},
  title  = {{YAHC}: {Handle} {Parameters}, {DOI} {Genres}, etc.},
  type   = {\bibmessage},
  howpublished = {Message posted to Ref-Links electronic mailing list,
            archived at \url{http://www.doi.org/mail-archive/
                             ref-link/msg00088.html}\bibnodot{.}},
}

@article{ex88,
  author  = {Borman, W. C. and Hanson, M. A. and Oppler, S. H. and
             Pulakos, E. D. and White, L. A.},
  year    = {1993},
  title   = {Role of Early Supervisory Experience in Supervisor Performance},
  journal = {Journal of Applied Psychology},
  volume  = {78},
  pages   = {443--449},
  howpublished = {Retrieved October 23, 2000, from the PsycARTICLES database},
}

@newspaper{ex89,
  author      = {Hilts, P. J.},
  year        = {1999},
  month       = feb,
  day         = {16},
  title       = {In Forecasting Their Emotions, Most People Flunk Out},
  journal     = {New York Times},
  lastchecked = {November 21, 2000},
  url         = {http://www.nytimes.com},
}

@article{ex90,
  author  = {Fournier, M. and {\lowercase{D}}e Ridder, D. and Bensing, J.},
  year    = {1999},
  title   = {Optimism and Adaptation to Multiple Sclerosis: What Does
             Optimism Mean?},
  journal = {Journal of Behavioral Medicine},
  volume  = {22},
  pages   = {303--326},
  howpublished = {Abstract retrieved October 23, 2000, from PsycINFO database},
}

@techreport{ex91,
  author  = {{\bibcorporate{U.S. General Accounting Office}}},
  year    = {1997},
  month   = feb,
  title   = {Telemedicine: Federal Strategy is Needed to Guide Investments},
  type    = {Publication},
  number  = {GAO/NSAID/HEHS-97-67},
  howpublished = {Retrieved September 15, 2000, from General Accounting Office
             Reports Online via GPO Access:
             \url{http://www.access.gpo.gov/su_docs/aces/
                  aces160.shtml?/gao/index.html}\bibnodot{.}},
}

@misc{ex92,
  author    = {Miller, M. E.},
  year      = {1993},
  title     = {The {Interactive} {Tester}},
  edition   = {Version~4.0\noedition\ignorespaces},
  type      = {\bibcomputersoftware},
  address   = {Westminster, CA},
  publisher = {Psytek Services},
}

@misc{ex93,
  author      = {Schwarzer, R.},
  year        = {1989},
  title       = {Statistics Software for Meta-Analysis},
  type        = {\bibcomputersoftwareandmanual},
  lastchecked = {March 23, 2001},
  url         = {http://www.yorku.ca/faculty/academic/schwarze/meta_e.htm},
}

@manual{ex93-t1,
  author    = {{\bibcorporate{R Development Core Team}}},
  year      = {2004},
  title     = {R: A Language and Environment for Statistical Computing},
  address   = {Vienna, Austria},
  publisher = {R Foundation for Statistical Computing},
  url       = {http://www.r-project.org},
}

@misc{ex94,
  key       = {{\APACcitebtitle{National Health Interview Survey}}},
  title     = {National {Health} {Interview} {Survey}---{Current} Health
               Topics: 1991---{Longitudinal} Study of Aging},
  edition   = {Version~4\noedition\ignorespaces},
  type      = {Data file},
  year      = {\bibnodate},
  address   = {Hyattsville, MD},
  publisher = {National Center for Health Statistics},
}

@misc{ex95,
  author    = {{\bibcorporate{Department of Health and Human Services,
                National Center for Health Statistics}}},
  firstkey  = {{Department of Health and Human Services,
                National Center for Health Statistics [DHHS-NCHS]}},
  key       = {{DHHS-NCHS}},
  year      = {1991},
  title     = {National {Health} {Provider} {Inventory}: Home Health
               Agencies and Hospices, 1991},
  type      = {Data file},
  howpublished = {Available from National Technical Information Service
                  Web site, \url{http://www.ntis.gov}\bibnodot{.}},
}
%</bibdb>
%    \end{macrocode}
%
% \subsection{The examples \LaTeX{} file (\fname{apacxmpl.tex})}
%
% The file \fname{apacxmpl.tex} contains the \LaTeX{} code for formatting
% the examples from the APA manual. It can be studied to see how certain
% nonstandard references can be formatted according to the APA rules,
% to test \pkg{apacite}, and in particular to test compatibility with
% other packages. We start with a standard head.
%    \begin{macrocode}
%<*xmpl>
\documentclass{article}
\usepackage{url}
\usepackage{apacite}
\usepackage{apacdoc}

\title{Testing \textsf{apacite}: Examples from the APA manual}
\author{Erik Meijer\\
        \textsf{apacite at gmail.com}
}
\date{2012/02/25}

\begin{document}
\maketitle
\begin{abstract}
This document tests \textsf{apacite} [2012/02/25 v6.01]. See the
\textsf{apacite} documentation for more information.
\end{abstract}

%</xmpl>
%    \end{macrocode}
%
% \subsection{References from the 6th edition of the Publication Manual}
%
% These examples are from chapter~7 of the 6th edition of the APA manual.
%    \begin{macrocode}
%<*xmpl>
\section{Examples from chapter~7}

\begin{enumerate}
\item
\cite{apa6:ch7-ex1} \\
\cite{apa6:ch7-ex1} \\
\fullciteA{apa6:ch7-ex1} \\
\citeA{apa6:ch7-ex1}

\item
\cite{apa6:ch7-ex2} \\
\cite{apa6:ch7-ex2} \\
\fullciteA{apa6:ch7-ex2} \\
\citeA{apa6:ch7-ex2}
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex1,
  author  = {Herbst-Damm, Kathryn L. and Kulik, James A.},
  year    = {2005},
  title   = {Volunteer Support, Marital Status, and the Survival Times of
             Terminally Ill Patients},
  journal = {Health Psychology},
  volume  = {24},
  pages   = {225--229},
  doi     = {10.1037/0278-6133.24.2.225},
}

@article{apa6:ch7-ex2,
  author  = {Gilbert, David G. and McClernon, F. Joseph and
             Rabinovich, Norka E. and Sugai, Chihiro and
             Plath, Louisette C. and Asgaard, Greg and Zuo, Yantao and
             Huggenvik, Jodi and Botros, Nazeih},
  year    = {2004},
  title   = {Effects of Quitting Smoking on {EEG} Activation and Attention
             Last for More than 31 Days and are More Severe with Stress,
             Dependence, {DRD2~A1} Allele, and Depressive Traits},
  journal = {Nicotine \& Tobacco Research},
  volume  = {6},
  pages   = {249--267},
  doi     = {10.1080/14622200410001676305},
}
%</bibdb>
%    \end{macrocode}
% Note that the page heading of the article itself gives the journal name with
% an ampersand (`\&': \emph{Nicotine \& Tobacco Research}) and not with ``and''
% as in the APA manual.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex3-1} \\
\cite{apa6:ch7-ex3-1} \\
\fullciteA{apa6:ch7-ex3-1} \\
\citeA{apa6:ch7-ex3-1}\\
\mbox{}\\
\cite{apa6:ch7-ex3-2} \\
\cite{apa6:ch7-ex3-2} \\
\fullciteA{apa6:ch7-ex3-2} \\
\citeA{apa6:ch7-ex3-2}
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex3-1,
  author  = {Sillick, Tamra J. and Schutte, Nicola S.},
  year    = {2006},
  title   = {Emotional Intelligence and Self-Esteem Mediate Between Perceived
             Early Parental Love and Adult Happiness},
  journal = {E-Journal of Applied Psychology: Emotional Intelligence},
  volume  = {2},
  number  = {2},
  pages   = {38--48},
  url     = {http://ojs.lib.swin.edu.au/index.php/ejab},
}

@article{apa6:ch7-ex3-2,
  author  = {Light, Matthew A. and Light, Ivan H.},
  year    = {2008},
  title   = {The Geographic Expansion of {Mexican} Immigration in the
             {United} {States} and its Implications for Local Law
             Enforcement},
  journal = {Law Enforcement Executive Forum},
  volume  = {8},
  number  = {1},
  pages   = {73--82},
}
%</bibdb>
%    \end{macrocode}
% This journal appears to prefer the name \emph{Law Enforcement Executive
% Forum} over \emph{Law Enforcement Executive Forum Journal} (see
% \url{http://www.iletsbei.com/lee_forum/}).
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex4} \\
\cite{apa6:ch7-ex4} \\
\fullciteA{apa6:ch7-ex4} \\
\citeA{apa6:ch7-ex4}

\item
\cite{apa6:ch7-ex5} \\
\cite{apa6:ch7-ex5} \\
\fullciteA{apa6:ch7-ex5} \\
\citeA{apa6:ch7-ex5}
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex4,
  author  = {Guimard, Philippe and Florin, Agn\`es},
  year    = {2007},
  title   = {Les \'Evaluations des Enseignants en Grande Section de
             Maternelle Sont-Elles Pr\'edictives des Difficult\'es de
             Lecture au Cours Pr\'eparatoire?},
  englishtitle = {Are Teacher Ratings in Kindergarten Predictive of
             Reading Difficulties in First Grade?},
  journal = {Approche Neuropsychologique des Apprentissages chez l'Enfant},
  volume  = {19},
  pages   = {5--17},
}

@article{apa6:ch7-ex5,
  author       = {Von Ledebur, Sidonia C.},
  year         = {2007},
  title        = {Optimizing Knowledge Transfer by New Employees in Companies},
  journal      = {Knowledge Management Research \& Practice},
  howpublished = {Advance online publication},
  doi          = {10.1057/palgrave.kmrp.8500141},
}
%</bibdb>
%    \end{macrocode}
% Here again the page heading of the article itself gives the journal name with
% an ampersand (`\&') and not with ``and''. Note that the APA explicitly
% changes ``von'' to ``Von'' to satisfy U.S. conventions of names. In
% other languages, ``von'' would be retained. See elsewhere in this manual
% for a discussion of how to treat von-parts.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex6} \\
\cite{apa6:ch7-ex6} \\
\fullciteA{apa6:ch7-ex6} \\
\citeA{apa6:ch7-ex6}

\item
\cite{apa6:ch7-ex7} \\
\cite{apa6:ch7-ex7} \\
\fullciteA{apa6:ch7-ex7} \\
\citeA{apa6:ch7-ex7}
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex6,
  author  = {Briscoe, Robert},
  year    = {\BIP},
  title   = {Egocentric Spatial Representation in Action and Perception},
  journal = {Philosophy and Phenomenological Research},
  url     = {http://cogprints.org/5780/1/ECSRAP.F07.pdf},
}

@magazine{apa6:ch7-ex7,
  author    = {Chamberlin, J. and Novotney, A. and Packard, E.
               and Price, M.},
  year      = {2008},
  month     = may,
  title     = {Enhancing Worker Well-Being: Occupational Health
               Psychologists Convene to Share Their Research on Work,
               Stress, and Health},
  journal   = {Monitor on Psychology},
  volume    = {39},
  number    = {5},
  pages     = {26--29},
}
%</bibdb>
%    \end{macrocode}
% The online version (\url{http://www.apa.org/monitor/2008/05/workstress.aspx})
% does not have a comma in the title before the ``and''.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex8} \\
\cite{apa6:ch7-ex8} \\
\fullciteA{apa6:ch7-ex8} \\
\citeA{apa6:ch7-ex8}
%</xmpl>
%<*bibdb>
@magazine{apa6:ch7-ex8,
  author  = {Clay, Rebecca},
  year    = {2008},
  month   = jun,
  title   = {Science vs.\ Ideology: Psychologists Fight Back Against
             the Misuse of Research},
  journal = {Monitor on Psychology},
  volume  = {39},
  number  = {6},
  url     = {http://www.apa.org/monitor/},
}
%</bibdb>
%    \end{macrocode}
% The APA manual incorrectly says ``about'' instead of ``against''.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex9} \\
\cite{apa6:ch7-ex9} \\
\fullciteA{apa6:ch7-ex9} \\
\citeA{apa6:ch7-ex9}

\item
\cite{apa6:ch7-ex10} \\
\cite{apa6:ch7-ex10} \\
\fullciteA{apa6:ch7-ex10} \\
\citeA{apa6:ch7-ex10}

\item
\cite{apa6:ch7-ex11} \\
\cite{apa6:ch7-ex11} \\
\fullciteA{apa6:ch7-ex11} \\
\citeA{apa6:ch7-ex11}

\item
\cite{apa6:ch7-ex12-1} \\
\cite{apa6:ch7-ex12-1} \\
\fullciteA{apa6:ch7-ex12-1} \\
\citeA{apa6:ch7-ex12-1}\\
\mbox{}\\
\cite{apa6:ch7-ex12-2} \\
\cite{apa6:ch7-ex12-2} \\
\fullciteA{apa6:ch7-ex12-2} \\
\citeA{apa6:ch7-ex12-2}\\
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex9,
  key     = {{\APACciteatitle{Six Sites Meet}}},
  title   = {Six Sites Meet for Comprehensive Anti-Gang
             Initiative Conference},
  year    = {2006},
  month   = nov # "/" # dec,
  journal = {OJJDP News @ a Glance},
  url     =
    {http://www.ncjrs.gov/html/ojjdp/news_at_glance/216684/topstory.html},
}

@newspaper{apa6:ch7-ex10,
  author  = {Schwartz, John},
  year    = {1993},
  month   = sep,
  day     = {30},
  title   = {Obesity Affects Economic, Social Status},
  journal = {The Washington Post},
  pages   = {A1, A4},
}

@newspaper{apa6:ch7-ex11,
  author  = {Brody, Jane E.},
  year    = {2007},
  month   = dec,
  day     = {11},
  title   = {Mental Reserves Keep Brain Agile},
  journal = {The New York Times},
  url     = {http://www.nytimes.com},
}

@article{apa6:ch7-ex12-1,
  editor  = {Haney, Craig and Wiener, Richard L.},
  year    = {2004},
  title   = {Capital Punishment in the {United} {States}},
  type    = {Special issue},
  journal = {Psychology, Public Policy, and Law},
  volume  = {10},
  number  = {4},
}

@article{apa6:ch7-ex12-2,
  editor  = {Yan, Zheng and Greenfield, Patricia},
  year    = {2006},
  title   = {Children, Adolescents, and the {Internet}},
  type    = {Special section},
  journal = {Developmental Psychology},
  volume  = {42},
  pages   = {391--458},
}
%</bibdb>
%    \end{macrocode}
% The journal lists the editors as Yan and Greenfield (in this order),
% although the first article (editorial introduction/overview) has
% Greenfield and Yan.
%
% The following is an implementation of the second bullet point: a special
% issue with no editors.
%    \begin{macrocode}
%<*xmpl>
\mbox{}\\
\cite{apa6:ch7-ex12-3} \\
\cite{apa6:ch7-ex12-3} \\
\fullciteA{apa6:ch7-ex12-3} \\
\citeA{apa6:ch7-ex12-3}

\item
\cite{apa6:ch7-ex13-1} \\
\cite{apa6:ch7-ex13-1} \\
\fullciteA{apa6:ch7-ex13-1} \\
\citeA{apa6:ch7-ex13-1}\\
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex12-3,
  key     = {{\APACciteatitle{Capital Punishment}}},
  title   = {Capital Punishment in the {United} {States}},
  year    = {2004},
  type    = {Special issue},
  journal = {Psychology, Public Policy, and Law},
  volume  = {10},
  number  = {4},
}

@article{apa6:ch7-ex13-1,
  author  = {Ganster, Daniel C. and Schaubroeck, John and
             Sime, Wesley E. and Mayes, Bronston T.},
  year    = {1991},
  title   = {The Nomological Validity of the {Type~A} Personality Among
             Employed Adults},
  type    = {Monograph},
  journal = {Journal of Applied Psychology},
  volume  = {76},
  pages   = {143--168},
  doi     = {10.1037/0021-9010.76.1.143},
}
%</bibdb>
%    \end{macrocode}
% The bullet points given here were explicit examples in the 5th edition.
% We have to be liberal with what goes in the \fieldname{number} field
% for these:
%    \begin{macrocode}
%<*xmpl>
\mbox{}\\
\cite{apa6:ch7-ex13-2} \\
\cite{apa6:ch7-ex13-2} \\
\fullciteA{apa6:ch7-ex13-2} \\
\citeA{apa6:ch7-ex13-2}\\
\mbox{}\\
\cite{apa6:ch7-ex13-3} \\
\cite{apa6:ch7-ex13-3} \\
\fullciteA{apa6:ch7-ex13-3} \\
\citeA{apa6:ch7-ex13-3}
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex13-2,
  author  = {Harris, Paul L. and Kavanaugh, Robert D.},
  year    = {1993},
  title   = {Young Children's Understanding of Pretense},
  journal = {Monographs of the Society for Research in Child Development},
  volume  = {58},
  number  = {1, Serial No.~231},
}

@article{apa6:ch7-ex13-3,
  author  = {Battig, William F. and Montague, William E.},
  year    = {1969},
  title   = {Category Norms for Verbal Items in 56 Categories:
             A Replication and Extension of the {Connecticut}
             Category Norms},
  journal = {Journal of Experimental Psychology Monographs},
  volume  = {80},
  number  = {3, Pt.~2},
}
%</bibdb>
%    \end{macrocode}
% The 5th edition gives the journal as ``Journal of Experimental
% Psychology Monographs'' and its front cover says ``Journal of Experimental
% Psychology Monograph'', but the volume and issue number and online
% categorization (on JSTOR) suggests that this is just a special issue
% of \emph{Journal of Experimental Psychology}, which would argue in
% favor of dropping the ``Monographs''.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex14} \\
\cite{apa6:ch7-ex14} \\
\fullciteA{apa6:ch7-ex14} \\
\citeA{apa6:ch7-ex14}
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex14,
  key     = {{\APACciteatitle{Editorial}}},
  title   = {Editorial: ``{What} Is a Disaster'' and Why Does This
             Question Matter?},
  year    = {2006},
  type    = {Editorial},
  journal = {Journal of Contingencies and Crisis Management},
  volume  = {14},
  pages   = {1--2},
}
%</bibdb>
%    \end{macrocode}
% The doi is \doi{10.1111/j.1468-5973.2006.00475.x}; normally this would
% be added.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex15} \\
\cite{apa6:ch7-ex15} \\
\fullciteA{apa6:ch7-ex15} \\
\citeA{apa6:ch7-ex15}
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex15,
  author  = {Marshall-Pescini, Sarah and Whiten, Andrew},
  year    = {2008},
  title   = {Social Learning of Nut-Cracking Behavior in {East} {African}
             Sanctuary-Living Chimpanzees (\emph{Pan troglodytes
             schweinfurthii})},
  type    = {Supplemental material},
  journal = {Journal of Comparative Psychology},
  volume  = {122},
  pages   = {186--194},
  doi     = {10.1037/0735-7036.122.2.186.supp},
}
%</bibdb>
%    \end{macrocode}
% Enclosing ``\verb+Pan troglodytes schweinfurthii+'' in exactly one pair of
% braces (which happen to also be the delimiters for the \cmd{\emph} command)
% ensures that the correct capitalization is output.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex16-1} \\
\cite{apa6:ch7-ex16-1} \\
\fullciteA{apa6:ch7-ex16-1} \\
\citeA{apa6:ch7-ex16-1} \\
\mbox{}\\
\cite{apa6:ch7-ex16-2} \\
\cite{apa6:ch7-ex16-2} \\
\fullciteA{apa6:ch7-ex16-2} \\
\citeA{apa6:ch7-ex16-2}
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex16-1,
  author  = {Woolf, Nancy J. and Young, Stacey L. and Fanselow, Michael S.
             and Butcher, Larry L.},
  year    = {1991},
  title   = {{MAP-2} Expression in Cholinoceptive Pyramidal Cells of
             Rodent Cortex and Hippocampus is Altered by {Pavlovian}
             Conditioning},
  type    = {Abstract},
  journal = {Society for Neuroscience Abstracts},
  volume  = {17},
  pages   = {480},
}

@article{apa6:ch7-ex16-2,
  author  = {Lassen, Stephen R. and Steele, Michael M. and Sailor, Wayne},
  year    = {2006},
  title   = {The Relationship of School-Wide {Positive} {Behavior}
             {Support} to Academic Achievement in an Urban Middle School},
  journal = {Psychology in the Schools},
  volume  = {43},
  pages   = {701--712},
  url     = {http://www.interscience.wiley.com},
}
%</bibdb>
%    \end{macrocode}
% The doi is \doi{10.1002/pits.20177}; normally this would be added. In
% the title and the abstract, ``Positive Behavior Support'' is capitalized,
% so presumably this is the proper name of an experimental program.
% Therefore I have enclosed it in braces here as well, so that this
% capitalization is preserved.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex17} \\
\cite{apa6:ch7-ex17} \\
\fullciteA{apa6:ch7-ex17} \\
\citeA{apa6:ch7-ex17}
%</xmpl>
%<*bibdb>
@article{apa6:ch7-ex17,
  author  = {Hare, Linda R. and O'Neill, Kevin},
  year    = {2000},
  title   = {Effectiveness and Efficiency in Small Academic Peer Groups:
             A Case Study},
  journal = {Small Group Research},
  volume  = {31},
  pages   = {24--53},
  howpublished = {Abstract retrieved from {Sociological} {Abstracts}
             database},
  note    = {(Accession No.\ 200010185)},
}
%</bibdb>
%    \end{macrocode}
% The construction using the \fieldname{howpublished} and \fieldname{note}
% fields does the job, but is not very elegant.
% The doi (of the whole article) is \doi{10.1177/104649640003100102}, which
% presumably normally would be added. The abstract is also freely available
% on the Sage website (\url{http://sgr.sagepub.com/content/31/1/24} on
% July 10, 2010), which is a lot more accessible than this database.
% Note that the APA manual omits the subtitle. It is remarkable how
% many such small errors there are in the APA manual.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex18} \\
\cite{apa6:ch7-ex18} \\
\fullciteA{apa6:ch7-ex18} \\
\citeA{apa6:ch7-ex18}
%</xmpl>
%<*bibdb>
@book{apa6:ch7-ex18,
  author    = {Shotton, Margaret A.},
  year      = {1989},
  title     = {Computer Addiction? {A} Study of Computer Dependency},
  address   = {London, England},
  publisher = {Taylor \& Francis},
}
%</bibdb>
%    \end{macrocode}
% I am puzzled by ``England''; ``UK'' seems more appropriate to me and that's
% what I'm always using.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex19-1} \\
\cite{apa6:ch7-ex19-1} \\
\fullciteA{apa6:ch7-ex19-1} \\
\citeA{apa6:ch7-ex19-1} \\
\mbox{}\\
\cite{apa6:ch7-ex19-2} \\
\cite{apa6:ch7-ex19-2} \\
\fullciteA{apa6:ch7-ex19-2} \\
\citeA{apa6:ch7-ex19-2}
%</xmpl>
%<*bibdb>
@book{apa6:ch7-ex19-1,
  author    = {Shotton, Margaret A.},
  year      = {1989},
  title     = {Computer Addiction? {A} Study of Computer Dependency},
  type      = {DX Reader version},
  url       = {http://www.ebookstore.tandf.co.uk/html/index.asp},
}

@book{apa6:ch7-ex19-2,
  author    = {Schiraldi, Glenn R.},
  year      = {2000},
  title     = {The Post-Traumatic Stress Disorder Sourcebook:
               A Guide to Healing, Recovery, and Growth},
  type      = {Adobe Digital Editions version},
  doi       = {10.1036/0071393722},
}
%</bibdb>
%    \end{macrocode}
% The website that this doi refers to gives the publication date as 2000,
% so that's what I'm using here. (The APA uses 2001.) This is supposed to
% be a ``free eBook'', but even after installing the Adobe software, the
% link to the actual content gives a ``page not found'' error for me.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex20} \\
\cite{apa6:ch7-ex20} \\
\fullciteA{apa6:ch7-ex20} \\
\citeA{apa6:ch7-ex20}
%</xmpl>
%<*bibdb>
@book{apa6:ch7-ex20,
  author = {O'Keeffe, Elton},
  year   = {\bibnodate},
  title  = {Egoism \& the Crisis in {Western} Values},
  url    = {http://www.onlineoriginals.com/showitem.asp?itemID=135},
}
%</bibdb>
%    \end{macrocode}
% Note the typo in the last name of the author in the APA manual.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex21} \\
\cite{apa6:ch7-ex21} \\
\fullciteA{apa6:ch7-ex21} \\
\citeA{apa6:ch7-ex21}
%</xmpl>
%<*bibdb>
@incollection{apa6:ch7-ex21,
  author       = {Freud, Sigmund},
  year         = {1953},
  title        = {The Method of Interpreting Dreams:
                  An Analysis of a Specimen Dream},
  editor       = {Strachey, James},
  translator   = {Strachey, James},
  booktitle    = {The Standard Edition of the Complete Psychological
                  Works of {Sigmund} {Freud}},
  volume       = {4},
  pages        = {96--121},
  originalyear = {1900},
  url          = {http://books.google.com/books},
}
%</bibdb>
%    \end{macrocode}
% This url did not bring me very far. It took me quite some time and different
% search strings to find the volume referred to. Search for author =
% ``Strachey'', year = 1953, and then select ``The interpretation of dreams,
% first part (1900)''; this leads in my case to
% \url{http://books.google.com/books?id=moN_OQAACAAJ&
%    dq=inauthor:%22James+Strachey%22&hl=en&ei=9E1FTOyVOsHflgems_DrAw&
%    sa=X&oi=book_result&ct=result&resnum=8&ved=0CEcQ6AEwBw}, but there is
% no preview available, and there is no useful information other than the
% title and the author, so exactly what is ``retrieved'' is not clear to
% me. After some internet searching, I did find
% \url{http://www.pep-web.org/static.php?page=standardedition}, which has
% a clickable table of contents, and presumably if you have a registered
% IP address, the actual content. Apparently, my IP address is not registered,
% so I had no access to the actual content.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex22} \\
\cite{apa6:ch7-ex22} \\
\fullciteA{apa6:ch7-ex22} \\
\citeA{apa6:ch7-ex22}
%</xmpl>
%<*bibdb>
@book{apa6:ch7-ex22,
  editor    = {Thomas, Noreen},
  year      = {2002},
  title     = {Perspectives on the Community College: A Journey of Discovery},
  type      = {Monograph},
  url       = {http://eric.ed.gov},
}
%</bibdb>
%    \end{macrocode}
% The ERIC document number is ED\,463\,808.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex23} \\
\cite{apa6:ch7-ex23} \\
\fullciteA{apa6:ch7-ex23} \\
\citeA{apa6:ch7-ex23}
%</xmpl>
%<*bibdb>
@book{apa6:ch7-ex23,
  editor    = {Koch, Sigmund},
  year      = {1959--1963},
  title     = {Psychology: A Study of a Science},
  volume    = {1--6},
  address   = {New York, NY},
  publisher = {McGraw-Hill},
}
%</bibdb>
%    \end{macrocode}
% Note that the correct title has ``a'' before ``science''.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex24} \\
\cite{apa6:ch7-ex24} \\
\fullciteA{apa6:ch7-ex24} \\
\citeA{apa6:ch7-ex24}
%</xmpl>
%<*bibdb>
@incollection{apa6:ch7-ex24,
  author    = {Strong, Edward K., Jr. and Uhrbrock, Richard S.},
  year      = {1923},
  title     = {Bibliography on Job Analysis},
  editor    = {Outhwaite{\bibeditortype{Series Ed.\hbox{}}}, Leonard},
  booktitle = {Personnel {Research} {Series}: Vol.~1. {Job} Analysis and the
               Curriculum},
  pages     = {140--146},
  doi       = {10.1037/10762-000},
}
%</bibdb>
%    \end{macrocode}
% There are several notable things with this reference: (1) The whole book is
% written by the same authors, so I'd think we'd normally list the book title
% in the \fieldname{title} field and in the text refer to the specific chapter
% or pages, rather than single out the chapter in the reference list. (2)
% The doi of the actual chapter is \doi{10.1037/10762-006}; the doi given here
% is the one for the whole book. (3) It is unclear why we would mention the
% series in which the book appears or the series editor. My impression from
% earlier versions of the \emph{APA manual} is that this is only done if the
% ``series'' is to be considered a joint work (like an encyclopedia) where
% different volumes have different editors and there is a series editor. It is
% my impression that the current work is just a book in a series of books, like
% every publisher has its various series with their series editors. (4) It is
% unclear why the series title needs to be capitalized. So in summary, I would
% normally format this example as
% \begin{verbatim}
% @book{apa6:ch7-ex24,
%   author    = {Strong, Edward K., Jr. and Uhrbrock, Richard S.},
%   year      = {1923},
%   title     = {Job Analysis and the Curriculum},
%   doi       = {10.1037/10762-000},
% }
% \end{verbatim}
% where I'm using the url for the whole book, because I refer to the whole book.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex25} \\
\cite{apa6:ch7-ex25} \\
\fullciteA{apa6:ch7-ex25} \\
\citeA{apa6:ch7-ex25}
%</xmpl>
%<*bibdb>
@incollection{apa6:ch7-ex25,
  author    = {Haybron, Daniel M.},
  year      = {2008},
  title     = {Philosophy and the Science of Subjective Well-Being},
  editor    = {Eid, Michael and Larsen, Randy J.},
  booktitle = {The Science of Subjective Well-Being},
  pages     = {17--43},
  address   = {New York, NY},
  publisher = {Guilford Press},
}
%</bibdb>
%    \end{macrocode}
% In previous versions of the \emph{APA manual} (e.g., 5th ed., p.~217), the
% states or countries of a list of cities ``well known for publishing'',
% including New York, were not given, but this has been abandoned in the 6th
% ed.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex26} \\
\cite{apa6:ch7-ex26} \\
\fullciteA{apa6:ch7-ex26} \\
\citeA{apa6:ch7-ex26}
%</xmpl>
%<*bibdb>
@incollection{apa6:ch7-ex26,
    author       = {Piaget, Jean},
    year         = {1988},
    title        = {Extracts from {Piaget}'s Theory},
    translator   = {Gellerier, Guy and Langer, Jonas},
    editor       = {Richardson, Ken and Sheldon, Sue},
    booktitle    = {Cognitive Development to Adolescence: A Reader},
    pages        = {3--18},
    address      = {Hillsdale, NJ},
    publisher    = {Erlbaum},
    originalbooktitle = {Manual of Child Psychology},
    originalpages     = {703--732},
    originaleditor    = {Mussen, Paul H.},
    originalyear      = {1970},
    originaladdress   = {New York, NY},
    originalpublisher = {Wiley},
}
%</bibdb>
%    \end{macrocode}
% It looks like the title of the Mussen book should be
% \emph{Carmichael's Manual of Child Psychology} and it's the third edition.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex27} \\
\cite{apa6:ch7-ex27} \\
\fullciteA{apa6:ch7-ex27} \\
\citeA{apa6:ch7-ex27}
%</xmpl>
%<*bibdb>
@book{apa6:ch7-ex27,
  editor    = {VandenBos, Gary R.},
  year      = {2007},
  title     = {{APA} Dictionary of Psychology},
  address   = {Washington, DC},
  publisher = {American Psychological Association},
}
%</bibdb>
%<*xmpl>
\item
\cite{apa6:ch7-ex28} \\
\cite{apa6:ch7-ex28} \\
\fullciteA{apa6:ch7-ex28} \\
\citeA{apa6:ch7-ex28}
%</xmpl>
%<*bibdb>
@book{apa6:ch7-ex28,
author    = {{\bibcorporate{Real Academia Espa\~{n}ola}}},
  year      = {2001},
  title     = {Diccionario de la Lengua Espa\~{n}ola},
  englishtitle = {Dictionary of the {Spanish} Language},
  edition   = {22},
  address   = {Madrid, Spain},
  publisher = {{\bibcorporate{Real Academia Espa\~{n}ola}}},
}
%</bibdb>
%<*xmpl>
\item
\cite{apa6:ch7-ex29} \\
\cite{apa6:ch7-ex29} \\
\fullciteA{apa6:ch7-ex29} \\
\citeA{apa6:ch7-ex29}
%</xmpl>
%<*bibdb>
@incollection{apa6:ch7-ex29,
    author       = {Graham, George},
    year         = {2007},
    title        = {Behaviorism},
    editor       = {Zalta, Edward N.},
	booktitle    =	{The {Stanford} Encyclopedia of Philosophy},
	edition      =	{Fall 2007},
    url          = {http://plato.stanford.edu/entries/behaviorism/},
}
%</bibdb>
%    \end{macrocode}
% At the time of this writing (June 2011), this url contains the Fall 2010
% version. The Fall 2007 version can be found at
% \url{http://plato.stanford.edu/archives/fall2007/entries/behaviorism/}.
% This is what the website itself says about citation:
% \begin{quote}
%     Please note that you are being asked to cite a URL that is in a fixed,
%     archived edition of the encyclopedia. The reason for this is that the
%     Stanford Encyclopedia of Philosophy recommends that readers use a stable
%     citation for scholarly purposes. You should not cite the dynamic portion
%     of the encyclopedia.
% \end{quote}
% Furthermore,
% \begin{quote}
%     There are over 50 \BibTeX{} styles and no standard format that is
%     guaranteed to work for all 50. So, we suggest you use our string as a
%     `useful suggestion' that might need to be adapted for your particular
%     \BibTeX{} file.
% \end{quote}
% \begin{verbatim}
% @InCollection{sep-behaviorism,
%     author       = {Graham, George},
%     title        = {Behaviorism},
%     booktitle    = {The Stanford Encyclopedia of Philosophy},
%     editor       = {Edward N. Zalta},
%     howpublished = {\url{http://plato.stanford.edu/archives/fall2007/entries/behaviorism/}},
%     year         = {2007},
%     edition      = {Fall 2007},
% }
% \end{verbatim}
% which is pretty similar to what I did above. The only big difference is that
% that they put the url in the \fieldname{howpublished} field, which should
% work fine with \pkg{apacite}, except that the APA wants the ``Retrieved from''
% string, which is generated by \pkg{apacite} if you put the url in the
% \fieldname{url} field but not if you put it in the \fieldname{howpublished}
% field, so you'll have to insert it yourself in the \fieldname{howpublished}
% field if you want to use that.
%    \begin{macrocode}
%<*xmpl>
\item
\cite{apa6:ch7-ex30} \\
\cite{apa6:ch7-ex30} \\
\fullciteA{apa6:ch7-ex30} \\
\citeA{apa6:ch7-ex30}
%</xmpl>
%<*bibdb>
@incollection{apa6:ch7-ex30,
    title        = {Heuristic},
	booktitle    =	{Merriam-{Webster}'s Online Dictionary},
	edition      =	{11},
    url          = {http://www.m-w.com/dictionary/heuristic},
}
%</bibdb>
%    \end{macrocode}
% One could argue that if the online edition refers to the 11th edition of
% the print version, the year should also be the year of the print version,
% instead of ``n.d.''.
%    \begin{macrocode}
%<*xmpl>
\end{enumerate}
\bibliographystyle{apacite}
\bibliography{apa5ex}
\end{document}
%</xmpl>
%    \end{macrocode}
%
%  \subsection{Additional references}
%
%    \begin{macrocode}
%<*bibdb>
@book{APAManual3,
  author    = {{\bibcorporate{American Psychological Association}}},
  firstkey  = {{American Psychological Association [APA]}},
  key       = {{APA}},
  year      = {1984},
  title     = {Publication Manual of the {American} {Psychological}
               {Association}},
  edition   = {3},
  address   = {Washington, DC},
  publisher = {{\bibcorporate{American Psychological Association}}},
  note      = {with revisions},
}

@book{APAManual5,
  author    = {{\bibcorporate{American Psychological Association}}},
  firstkey  = {{American Psychological Association [APA]}},
  key       = {{APA}},
  year      = {2001},
  title     = {Publication Manual of the {American} {Psychological}
               {Association}},
  edition   = {5},
  address   = {Washington, DC},
  publisher = {{\bibcorporate{American Psychological Association}}},
}

@book{APAManual6,
  author    = {{\bibcorporate{American Psychological Association}}},
  firstkey  = {{American Psychological Association [APA]}},
  key       = {{APA}},
  year      = {2009},
  title     = {Publication Manual of the {American} {Psychological}
               {Association}},
  edition   = {6},
  address   = {Washington, DC},
  publisher = {{\bibcorporate{American Psychological Association}}},
}

@book{chicago,
  title     = {The {Chicago} Manual of Style},
  edition   = {15},
  year      = {2003},
  address   = {Chicago},
  publisher = {The University of Chicago Press},
}

@misc{Pata88,
  author    = {Patashnik, Oren},
  year      = {1988},
  title     = {{\BibTeX ing}},
  url       = {http://www.ctan.org/tex-archive/biblio/
               bibtex/distribs/doc/btxdoc.tex},
  lastchecked = {October 4, 2008},
}

@book{LaTeXbook,
  author    = {Lamport, Leslie},
  year      = {1994},
  title     = {{\APACSortNoop{LaTeX}}{\LaTeX}: A Document Preparation System.
               {User}'s Guide and Reference Manual},
  edition   = {2},
  address   = {Reading, MA},
  publisher = {Addison-Wesley},
}

@book{KoDa04,
  author    = {Kopka, Helmut and Daly, Patrick W.},
  year      = {2004},
  title     = {Guide To {\APACSortNoop{LaTeX}}{\LaTeX}},
  edition   = {4},
  address   = {Boston, MA},
  publisher = {Addison-Wesley},
}

@book{TLC2,
  author    = {Mittelbach, Frank and Goossens, Michel},
  year      = {2004},
  title     = {The {\APACSortNoop{LaTeX}}{\LaTeX} Companion},
  edition   = {2},
  address   = {Boston, MA},
  publisher = {Addison-Wesley},
}

@book{dLMe08a,
  editor     = {De Leeuw, Jan and Meijer, Erik},
  year       = {2008},
  title      = {Handbook of Multilevel Analysis},
  address    = {New York, NY},
  publisher  = {Springer},
}

@book{meijer1998,
  author    = {Meijer, Erik},
  year      = {1998},
  title     = {Structural Equation Models for Nonnormal Data},
  address   = {Leiden, Netherlands},
  publisher = {DSWO Press},
}

@article{meijer07,
  author     = {Meijer, Erik},
  year       = {2007},
  title      = {Citations, Reference List, and Author Index with
                \textsf{apacite}},
  journal    = {Eutypon},
  volume     = {16--19},
  pages      = {1--31},
  url        = {http://www.eutypon.gr/eutypon/e-cont-16-19.html},
}

@book{WaMe00,
  author    = {Wansbeek, Tom and Meijer, Erik},
  year      = {2000},
  title     = {Measurement Error and Latent Variables in Econometrics},
  address   = {Amsterdam, Netherlands},
  publisher = {North-Holland},
}

@unpublished{APA-3rd-ed-ex53,
  author       = {Gottfredson, G. D.},
  year         = {1978},
  title        = {Why Don't Vocational Interests Predict Job
                  Satisfaction Better Than They Do?},
  howpublished = {Unpublished manuscript},
  organization = {Johns Hopkins University, Center for Social
                  Organization of Schools},
  address      = {Baltimore},
}

@misc{DePsych01,
  key          = {{\APACciteatitle{Uitgebreide Richtlijnen}}},
  title        = {Uitgebreide Richtlijnen voor het Aanleveren van Kopij},
  englishtitle = {Detailed Guidelines for the Submission of Manuscripts},
  year         = {2001},
  lastchecked  = {January~3, 2005},
  url = {http://upload.lectric.nl/data/nip7/Richtlijnen%20voor%20auteurs.pdf},
}

@article{NTPG04,
  title        = {Aanwijzingen voor Auteurs},
  englishtitle = {Instructions for Authors},
  year         = {2004},
  journal      = {Nederlands Tijdschrift voor de Psychologie en haar
                  Grensgebieden},
  volume       = {59},
  pages        = {inside back cover},
}

@book{Renk02,
  author       = {Renkema, J.},
  year         = {2002},
  title        = {Schrijfwijzer},
  englishtitle = {Writing Indicator},
  edition      = {4},
  address      = {Den Haag, The Netherlands},
  publisher    = {Sdu},
}

@article{Schr04,
  author       = {Schrooten, M. G. S. and Smulders, F. T. Y.},
  year         = {2004},
  title        = {Een Experimentele Kijk op Angst: Aandacht en Automatisme
                  in de Verwerking van Bedreigende Stimuli},
  englishtitle = {Anxiety from an Experimental Point of View: Attention and
                  Automaticity in the Processing of Threatening Stimuli},
  journal      = {Nederlands Tijdschrift voor de Psychologie en haar
                  Grensgebieden},
  volume       = {59},
  pages        = {135--149},
}

@book{VanDale89,
  key          = {{\APACcitebtitle{van Dale}}},
  title        = {van {Dale} Groot Woordenboek {Engels}-{Nederlands}},
  englishtitle = {van {Dale}'s Large Dictionary {English}-{Dutch}},
  edition      = {2},
  year         = {1989},
  address      = {Utrecht, The Netherlands},
  publisher    = {Van Dale},
}

@book{KLO05,
  author       = {Haapam\"aki, Tuula and Hedman, Arne
                  and H\"am\"al\"ainen, Esa and Kurvinen, Birgitta
                  and Lager, Lassi and Lindegren, Yrj\"o
                  and Murtomaa, Eeva and Vainikka, Eila},
  year         = {2005},
  title        = {Monografioiden kuvailu},
  englishtitle = {Description for Monographic Publications},
  address      = {Helsinki, Finland},
  publisher    = {Helsingin yliopiston kirjasto},
  url          = {http://www.kansalliskirjasto.fi/kirjastoala/
                  luettelointisaannot/Files/liitetiedosto2/
                  monografioiden_kuvailu.pdf},
  lastchecked  = {January 19, 2009},
}

@book{DGPs07,
  firstkey  = {Deutsche Gesellschaft f\"ur Psychologie [DGPs]},
  key       = {DGPs},
  author    = {\bibcorporate{Deutsche Gesellschaft f\"ur Psychologie}},
  year      = {2007},
  title     = {Richtlinien zur {Manuskriptgestaltung}},
  englishtitle = {Guidelines for Manuscript Preparation},
  edition   = {3},
  address   = {G\"ottingen, Germany},
  publisher = {Hogrefe-Verlag},
}

@misc{UIB08,
  author       = {{\bibcorporate{University of Bergen}}},
  year         = {2008},
  title        = {American {Psychological} {Association} ({APA})},
  url          = {http://www.sokogskriv.no/norsk/basis/sitering-etikk/APA.pdf},
  lastchecked  = {October 12, 2008},
  address      = {Bergen, Norway},
  publisher    = {University of Bergen, University Library},
}
%% Referenced from
%% \url{http://www.sokogskriv.no/norsk/basis/sitering-etikk/4-stiler.html}
%%
%% Original version:
%% \url{http://www.ub.uib.no/felles/IK/APA.pdf}
%% but this page does not exist anymore on 2008/10/12.
%%
%% Norwegian name:
%% Universitetsbiblioteket, Universitetet I Bergen, 2008

@misc{UiO06,
  author       = {{\bibcorporate{University of Oslo}}},
  year         = {2006},
  title        = {Normer for skriftlig arbeid},
  englishtitle = {Standards for Written Works},
  url          = {http://www.uio.no/studier/emner/medisin/isv/SYKVIT4400/v07/
                  REV_normer_skriftl_arb.pdf},
  lastchecked  = {October 12, 2008},
  address      = {Oslo, Norway},
  publisher    = {University of Oslo, Institute of Nursing and Health Sciences},
}
%% Referenced from
%% \url{http://www.uio.no/studier/emner/medisin/isv/SYKVIT4400/v07/}
%%
%% Norwegian name:
%% Universitetet i Oslo, Sykepleievitenskap, 28.06.06


@misc{Erik01,
  author      = {Erikson, Martin G.},
  year        = {2001},
  title       = {Att Skriva Litteraturreferenser Enligt {Harvard}-Systemet},
  englishtitle = {Citations According to the {Harvard} System},
  url         = {http://www.his.se/upload/10631/referenser.pdf},
  lastchecked = {October 18, 2008},
  Eriksremark = {Originally downloaded December 9, 2004, from
    \url{http://www.ida.his.se/ida/kurser/exjobb/kursmaterial/referenser.pdf},
    but this site does not exist anymore.},
}

@misc{Johnsson,
  author      = {Johnsson, Mattias},
  title       = {Lathund for Referensskrivning},
  englishtitle = {Cheat Sheet for Formatting of References},
  url         = {http://www.ped.gu.se/users/berner/htmarkiv/referens.html},
  lastchecked = {October 18, 2008},
  Eriksremark = {Originally downloaded December 9, 2004},
}

@misc{GU94,
  title  = {Referensskrivning},
  englishtitle = {Formatting of References},
  year   = {1994},
  url    = {http://www.ped.gu.se/forskarutbildning/Referens_skrivning.htm},
  lastchecked = {October 18, 2008},
  Eriksremark = {Originally downloaded December 9, 2004.
                 Site is Gothenburg University Web site, but reference seems
                 specific enough. Authors may be (?)
                 Informatorn/Dahlgren/Ottosson, but I don't know first
                 names.},
}

%%
%</bibdb>
%    \end{macrocode}
%
% \section{\BibTeX\ style (\fname{apacite.bst} and its siblings)}
% The program in \BibTeX's language that formats the reference list.
% Currently, this supplies four files: \fname{apacite.bst}, \fname{apacitex.bst}
% \fname{apacann.bst}, and \fname{apacannx.bst}.
% These files are almost identical, but \fname{apacitex.bst} and
% \fname{apacannx.bst} generate information that can be used to generate an
% author index, and \fname{apacann.bst} and \fname{apacannx.bst} use annotation
% when available for annotated bibliographies.
%
% We start with file headers and a function that prints the version number in
% the \fname{.blg} file.
%    \begin{macrocode}
%<*!annotated>
%<bibstyle>%% apacite.bst : reference list according to APA manual
%<xbibstyle>%% apacitex.bst : reference list according to APA manual
%<xbibstyle>%%                with author indexing information
%</!annotated>
%<*annotated>
%<bibstyle>%% apacann.bst : reference list according to APA manual
%<bibstyle>%%               with annotations
%<xbibstyle>%% apacannx.bst : reference list according to APA manual
%<xbibstyle>%%                with annotations and author indexing information
%</annotated>
%<*bibstyle|xbibstyle>
%% Written by Erik Meijer

FUNCTION {identify.apacite.version}
{ % Put identifying string in the .blg file
%</bibstyle|xbibstyle>
%<*!annotated>
%<bibstyle>  "apacite.bst"
%<xbibstyle>  "apacitex.bst"
%<bibstyle>  " [2012/02/25 v6.01 APA bibliography style]"
%<xbibstyle> " [2012/02/25 v6.01 APA bibl. style with author index info]"
%</!annotated>
%<*annotated>
%<bibstyle>  "apacann.bst"
%<xbibstyle>  "apacannx.bst"
%<bibstyle>  " [2012/02/25 v6.01 APA annotated bibliography style]"
%<*xbibstyle>
" [2012/02/25 v6.01 APA annotated bibl. style with author index info]"
%</xbibstyle>
%</annotated>
%<*bibstyle|xbibstyle>
  * top$
}
%    \end{macrocode}
% Declaration of fields, integers, and strings for each entry.
%    \begin{macrocode}
ENTRY
  { address
    annote
    annotate
    author
    booktitle
    chair
    chapter
    day
    doi
    edition
    editor
    englishtitle
    firstkey
    howpublished
    institution
    journal
    key
    lastchecked
    month
    note
    number
    organization
    originaladdress
    originalbooktitle
    originaledition
    originaleditor
    originaljournal
    originalnumber
    originalpages
    originalpublisher
    originalvolume
    originalyear
    pages
    publisher
    school
    series
    symposium
    text
    title
    translator
    type
    url
    urldate
    volume
    year
  }
  { title.number           %% for sorting titles
    cite.initials          %% dummy (0-1) indicating whether or not
                           %% initials of the 1st author must
                           %% be used for citing
    cite.num.names.full    %% number of names to be cited for full and
    cite.num.names.short   %% short cite
    add.to.year            %% For a, b, c, etc. after year
                           %% in multiple citations with same author-year
  }
  { year.label             %% For sorting entries by year
    author.year.sort.label %% For sorting entries and checking whether
                           %% initials should be added, how many authors
                           %% should be cited and whether a, b, etc.
                           %% after year is necessary
    title.sort.label       %% for sorting titles
    type.2                 %% Replacement for type with misc entries and
                           %% entries that revert to misc.
  }
%    \end{macrocode}
% Declaration of global integers and strings.
%    \begin{macrocode}
INTEGERS { len  pos  name.max  old.number  numnames  numnames.old
           nameptr  lastname  format.num.names  cite.initials.old
           cite.num.names.old add.to.year.old  forward
           multiresult  dot brace.level
         }

STRINGS  { s  t  u old.label  field
           aut1f  aut1s  aut1f.old  aut1s.old
           aut2          aut2.old
           aut3          aut3.old
           aut4          aut4.old
           aut5          aut5.old
           aut6          aut6.old
           year.label.old
         }
%    \end{macrocode}
% A small function for testing purposes.
%    \begin{macrocode}
FUNCTION {test} { #0 }
%    \end{macrocode}
% A small function that indicates whether index entries must be generated.
% This is the only line that is different between \fname{apacite.bst} and
% \fname{apacitex.bst} (and between \fname{apacann.bst} and
% \fname{apacannx.bst}).
%    \begin{macrocode}
%</bibstyle|xbibstyle>
%<bibstyle>FUNCTION {make.index} { #0 }
%<xbibstyle>FUNCTION {make.index} { #1 }
%<*bibstyle|xbibstyle>
%    \end{macrocode}
% Month macros. We use numbers, along with a \LaTeX{} function, which
% translates them into words. This allows language-specific deviations.
%    \begin{macrocode}
MACRO {jan}    {"{\APACmonth{01}}"}
MACRO {feb}    {"{\APACmonth{02}}"}
MACRO {mar}    {"{\APACmonth{03}}"}
MACRO {apr}    {"{\APACmonth{04}}"}
MACRO {may}    {"{\APACmonth{05}}"}
MACRO {jun}    {"{\APACmonth{06}}"}
MACRO {jul}    {"{\APACmonth{07}}"}
MACRO {aug}    {"{\APACmonth{08}}"}
MACRO {sep}    {"{\APACmonth{09}}"}
MACRO {oct}    {"{\APACmonth{10}}"}
MACRO {nov}    {"{\APACmonth{11}}"}
MACRO {dec}    {"{\APACmonth{12}}"}
MACRO {winter} {"{\APACmonth{13}}"}
MACRO {spring} {"{\APACmonth{14}}"}
MACRO {summer} {"{\APACmonth{15}}"}
MACRO {fall}   {"{\APACmonth{16}}"}
%    \end{macrocode}
% Logical ``not'': If the top element on the stack is $A$ then this function
% does the following:
% \begin{verbatim}
%     push { #0 }
%     push { #1 }
% \end{verbatim}
% So now the first three elements of the stack are
%   \verb+{ #1 }+ \verb+{ #0 }+ $A$.
% These are popped and subjected to ``if'':
% If $A > 0$ then \verb+{ #0 }+ is executed, else \verb+{ #1 }+ is executed:
% \begin{verbatim}
%     if A > 0
%     then 0
%     else 1
% \end{verbatim}
% So consider integers as logicals, where 1 = true and 0 = false,
% then this does
% \begin{verbatim}
%     (if A then false else true)
% \end{verbatim}
% which is a logical ``not''.
%    \begin{macrocode}
FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Logical 'and':
% If the first 2 elements on the stack are A B
% then this function does the following:
%     push 'skip$
%     push { pop$ #0 }
% So now first 4 elements are
%     { pop$ #0 } 'skip$ A B
% The first 3 are popped and subjected to 'if' (B is on top of
% the stack):
% If A > 0 then 'skip$ is executed, else { pop$ #0 } is executed:
%     if A > 0
%     then (B stays on top of stack)
%     else (B is popped and #0 is pushed)
% So consider integers as logicals, where 1 = true and 0 = false,
% then this does
%     (if A then B else false)
% which is a logical 'and'.

FUNCTION {and}
{   'skip$
    { pop$ #0 }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Logical 'or':
% If the first 2 elements on the stack are A B
% then this function does the following:
%     push { pop$ #1 }
%     push 'skip$
% So now first 4 elements are
%     'skip$ { pop$ #1 } A B
% The first 3 are popped and subjected to 'if' (B is on top of
% the stack):
% If A > 0 then { pop$ #1 } is executed, else 'skip$ is executed:
%     if A > 0
%     then (B is popped and #1 is pushed)
%     else (B stays on top of stack)
% So consider integers as logicals, where 1 = true and 0 = false,
% then this does
%     (if A then true else B)
% which is a logical 'or'.

FUNCTION {or}
{   { pop$ #1 }
    'skip$
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  GENERAL PURPOSE FUNCTIONS FOR FORMATTING                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % issues warning if field is empty
    % call with
    %    "field"  field  warning.if.empty
    % Note that the first field must be between quotes
    % because it is the fieldname for use in the warning message.
    %
FUNCTION {warning.if.empty}
{ empty$
    { "No "  swap$ * " in " * cite$ * warning$ }
    { pop$ }
  if$
}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % issues warning if title, type, and howpublished are empty
    %
FUNCTION {check.relevant.fields}
{ title        empty$
  type         empty$ and
  howpublished empty$ and
    { "No title, type, and howpublished in " cite$ * warning$ }
    'skip$
  if$
}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % delivers 1 if (both editor and translator
    %                not empty and not equal to each other)
    %          0 if (editor or translator empty) or
    %               (editor = translator)
    %
FUNCTION {editor.ne.trans}
{ translator empty$
    { #0 }
    { editor empty$
        { #0 }
        { translator editor =
            { #0 }
            { #1 }
          if$
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Convert integer to string, assume that integer < 100,000

FUNCTION {conv.int.to.str}
{ duplicate$ #10 <
    { "0000" swap$ int.to.str$ * }
    { duplicate$ #100 <
        { "000" swap$ int.to.str$ * }
        { duplicate$ #1000 <
            { "00" swap$ int.to.str$ * }
            { duplicate$ #10000 <
                { "0" swap$ int.to.str$ * }
                { int.to.str$ }
              if$
            }
          if$
        }
      if$
    }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Delivers 1 if possibly editor in author position
%          2 if editor not in author position
%          3 if not applicable: use key
%          0 if unknown type

FUNCTION {ref.type}
{ type$ "article"      =
    type$ "magazine"     =
      type$ "newspaper"    =
        type$ "book"         =
          type$ "techreport"   =
            type$ "unpublished"  =
              type$ "misc"         =
                type$ "booklet"      =
                  type$ "manual"       =
                    type$ "proceedings"  =
                    or
                  or
                or
              or
            or
          or
        or
      or
    or
    { #1 }
    { type$ "incollection"   =
        type$ "phdthesis"      =
          type$ "mastersthesis"  =
            type$ "lecture"        =
              type$ "inbook"         =
                type$ "inproceedings"  =
                  type$ "conference"  =
                    type$ "intechreport"   =
                    or
                  or
                or
              or
            or
          or
        or
        { #2 }
        { type$ "literal" =
            { #3 }
            { #0 }
          if$
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Delivers 1 if title is formatted as an "article"-type,
%          0 otherwise

FUNCTION {is.atype}
{ type$ "article"        =
    type$ "magazine"       =
      type$ "newspaper"      =
        type$ "incollection"   =
          type$ "inbook"         =
            type$ "inproceedings"  =
              type$ "conference"  =
                type$ "intechreport"   =
                  type$ "manual"         =
                  or
                or
              or
            or
          or
        or
      or
    or
    { #1 }
    { journal empty$ not
        %
      type$ "phdthesis"      =
        type$ "mastersthesis"  =
        or
        %
      and
        { #1 }
        { type$ "misc" =
          type empty$ not and
            { type "\bibmessage" =
                type "\bibcomputerprogram" =
                  type "\bibcomputerprogrammanual" =
                    type "\bibcomputerprogramandmanual" =
                      type "\bibcomputersoftware" =
                        type "\bibcomputersoftwaremanual" =
                          type "\bibcomputersoftwareandmanual" =
                            type "\bibprogramminglanguage" =
                            or
                          or
                        or
                      or
                    or
                  or
                or
                { #1 }
                { #0 }
              if$
            }
            { #0 }
          if$
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % connects two strings with connect string
    % if one of them empty, then connect string
    % is left out
    %
    % call with S1 S2 connectstring connect.check
    %
FUNCTION {connect.check}
{ 'u :=
    %
    % if S2 = ""
    %
  duplicate$ empty$
      %
      % then remove S2
      %
    { pop$
        %
        % S1 is on top of stack.
        % if it is empty, it is replaced by the empty string ""
        %
      duplicate$ empty$
        { pop$ "" }
        'skip$
      if$
    }
      %
      % else swap S1 and S2 so that S1 can be checked
      %
    { swap$
        %
        % if S1 is empty, remove S1 so that S2 is left on the
        % stack and is the result is given
        %
      duplicate$ empty$
        { pop$ }
            %
            % now the real work starts:
            % push the connect string "C"
            % so that top of stack is "C" "S1" "S2"
            % concatenate, so that top of stack is
            % "S1+C" "S2"
            %
        { u *
            %
            % swap and concatenate
            %
          swap$ *
        }
      if$
    }
  if$
}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % connects two strings with space ("\ ")
    % if length of second is 4 or larger,
    % connects them with non-breaking space ("tie", "~")
    % if length of second smaller than 4
    %
    % call with S1 S2 tie.or.space.connect
    % result: "S1\ S2" or "S1~S2"
    %
FUNCTION {tie.or.space.connect}
{ duplicate$ text.length$ #4 <
    { "~" }
    { "\ " }
  if$
  swap$ * *
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % connects two strings with comma (", ")
    % if one of them is empty, the comma is left out
    %
    % call with S1 S2 connect.with.comma.check
    % result: "S1, S2"
    %
FUNCTION {connect.with.comma.check}
{ ", " connect.check }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % connects two strings with semicolon ("; ")
    % if one of them is empty, semicolon is left out
    %
    % call with S1 S2 connect.with.semicolon.check
    % result: "S1; S2"
    %
FUNCTION {connect.with.semicolon.check}
{ "; " connect.check }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % connects two strings with colon (": ")
    % if one of them is empty, colon is left out
    %
    % call with S1 S2 connect.with.colon.check
    % result: "S1: S2"
    %
FUNCTION {connect.with.colon.check}
{ ": " connect.check }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % connects two strings with space ("\ ")
    %
    % call with S1 S2 connect.with.space.check
    % result: "S1\ S2"
    %
FUNCTION {connect.with.space.check}
{ "\ " connect.check }



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % encloses string in pre- and postfix string
    % call with
    %    prefix postfix  S  enclose.check
    % delivers empty string if S empty
    %
FUNCTION {enclose.check}
{ duplicate$ empty$
    { pop$ pop$ pop$
      ""
    }
    { swap$ * * }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % emphasizes top of stack
    % call with
    %     "string" emphasize.check
    %
FUNCTION {emphasize.check}
{ "\Bem{" swap$
  "}"     swap$
  enclose.check
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % brackets top of stack
    % call with
    %     "string" bracket
    %
FUNCTION {bracket.check}
{ "[" swap$
  "]" swap$
  enclose.check
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % parenthesizes top of stack
    % call with
    %     "string" parenthesize
    %
FUNCTION {parenthesize.check}
{ "(" swap$
  ")" swap$
  enclose.check
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % checks whether argument is "multiresult":
    % whether it contains '-', '+', or ',' characters
    % used with pages to check whether pp. or p. must be used
    %
FUNCTION {multi.result.check}
{ 't :=
  #0 'multiresult :=
  %
  % while (not multiresult) and (length(t) > 1) do
  %
    { multiresult not
      t text.length$ #1 >
      and
    }
        %
        % if t(1-2) = "--" or t(1) = "+" or ","
        % then  multiresult = 1
        % else  t = t(2-last)
        %
    { t #1 #2 substring$ 's :=
      "--" s =
        { #1 'multiresult := }
        { t #1 #1 substring$ 's :=
          "+" s =
            "," s =
            or
            { #1 'multiresult := }
            { t #2 global.max$ substring$ 't := }
          if$
        }
      if$
    }
  while$
  multiresult
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % Checks whether an author is a corporate author, i.e.,
    % whether the field starts with "{\bibcorporate".
    % Call with
    %   field is.bibcorporate
    %
FUNCTION {is.bibcorporate}
{ #1 #14 substring$ "{\bibcorporate" = }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  GENERAL PURPOSE FUNCTIONS FOR SORTING                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Remove non-alphanumeric characters
% and change to lower case .

FUNCTION {sortify}
{ purify$
  "l" change.case$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Remove spaces from a string. Used for sorting.
%
% Call with
%     string remove.spaces
%
% E.g.,
%     "fine old day" remove.spaces
% gives "fineoldday" .

FUNCTION {remove.spaces}
{   % Remove spaces from string.
    % Works best if string only contains alphanumeric characters and spaces.
  's :=                    % The original string
  s text.length$ 'len :=   % Its length (no. of characters)
  "" 't :=                 % Initialize the transformed string
  #0 'pos :=
    %
    % while (pos < len) do
    %
  { pos len < }
    { pos #1 +  'pos :=
      s pos #1 substring$  'u :=
        %
        % u is the pos-th character in s
        % If it is a space, move to next character,
        % else copy character to output.
        %
      u " " =
        'skip$
        { t u *  't := }
      if$
    }
  while$
    %
    % Now push the result back on the stack
  t
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                BASIC OUTPUT FUNCTIONS                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % starting new block by writing what's left on the stack,
    % starting a new line and adding some extra space or
    % whatever is more defined in \newblock
    %
FUNCTION {output.end.block}
{ write$
  newline$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % starting new block by writing what's left on the stack,
    % starting a new line and adding some extra space or
    % whatever is more defined in \newblock
    %
FUNCTION {output.new.block}
{ output.end.block
  "\newblock" write$
  newline$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % starting new block by writing what's left on the stack,
    % starting a new line and adding some extra space or
    % whatever is more defined in \newblock
    %
FUNCTION {output.dot.new.block}
{ add.period$
  output.new.block
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Starting new block assuming that stack is empty.
% Starting a new line and adding some extra space or
% whatever is more defined in \newblock

FUNCTION {start.new.block}
{ "\unskip\ " write$ newline$
  "\newblock " write$ newline$
}
%    \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Functions for sorting by author (or substitute),
% year, title}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The ``classic'' versions are the ones with the von part
% treated a in ``Beethoven, L. van'', whereas the nonclassic ones
% have the new approach with the von part always before the last
% name. The ``classic'' versions are not used in this version,
% but I keep them defined so it's easy to switch, and perhaps
% define an option in the future.
%    \begin{macrocode}

FUNCTION {sort.name.format.classic} { "{ll{}}{  f{}}{  vv{}}{  jj{}}" }

FUNCTION {cite.name.format.classic} { "{ll}" }

FUNCTION {author.name.format.classic} { "{ll}{, f{\BPBI }.}{ vv}{, jj}" }

FUNCTION {index.name.format.classic} { "{ll}{, f{\BPBI }.}{ vv}{, jj}" }

FUNCTION {sort.name.format} { "{vv{}}{ll{}}{  f{}}{  jj{}}" }

FUNCTION {cite.name.format} { "{vv }{ll}" }

FUNCTION {cite.initials.name.format} { "{f{\BPBI }.~~}{vv }{ll}{ jj}" }

FUNCTION {author.name.format} { "{vv }{ll}{, f{\BPBI }.}{, jj}" }

FUNCTION {editor.name.format} { "{f{\BPBI }.~~}{vv }{ll}{ jj}" }

FUNCTION {index.name.format} { "{vv }{ll}{, f{\BPBI }.}{, jj}" }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Check whether initials must be added (1).
% Initialization.

FUNCTION {init.initials}
{ "yyyyy"  'aut1f.old :=
  "yyyyy"  'aut1s.old :=
  #0       'cite.initials.old :=
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Check whether initials must be added (2).
% Update when author, editor, and key fields are not used.
%
% Call with
%   field  update.no.initials

FUNCTION {update.no.initials}
{ 'field :=
  field  'aut1f.old :=
  field  'aut1s.old :=
  #0     'cite.initials.old :=
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Check whether initials must be added (3).

FUNCTION {check.add.initials.aut}
{   %
    % If last name is equal to previous last name
    % but initials are different, then initials should
    % be cited. If initials are also the same, initials
    % should be cited if that is the case for the previous
    % author .
    %
  aut1s aut1s.old =
    { aut1f aut1f.old =
        { cite.initials.old  'cite.initials := }
        { #1             'cite.initials :=
          aut1f          'aut1f.old :=
          aut1s          'aut1s.old :=
          cite.initials  'cite.initials.old :=
        }
      if$
    }
    {  %
       % Different last name.
      aut1f          'aut1f.old :=
      aut1s          'aut1s.old :=
      cite.initials  'cite.initials.old :=
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Check whether initials must be added (4).
% Call with
%   field  check.add.initials.field

FUNCTION {check.add.initials.field}
{ 'field :=
  field #1 cite.initials.name.format format.name$  'aut1f :=
  field #1 cite.name.format          format.name$  'aut1s :=
    %
    % Now do the actual work
    %
  check.add.initials.aut
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Check whether initials must be added (4).

FUNCTION {check.add.initials}
{   %
    % Check whether author or editor or other field acts as author.
    % Initials are only relevant with author or editor.
    %
  firstkey empty$ not
    { key empty$ not
        {   %
            % Both key and firstkey are nonempty.
            % Then, key is treated as last name of first author,
            % and firstkey is treated as last name + initials of
            % first author .
            %
          firstkey  sortify  remove.spaces  'aut1f :=
          key       sortify  remove.spaces  'aut1s :=
          check.add.initials.aut
        }
        { firstkey  sortify  remove.spaces  update.no.initials }
      if$
    }
    { key empty$ not
        { key  sortify  remove.spaces  update.no.initials }
        {   %
            % No key or firstkey, so find out which field
            % to use as author.
            %
            % Check reference type:
            %   if result is 1 then possibly editor acts as author
            %                2 then editor does not act as author
            %                3 then key should have been used
            %                0 then unknown reference type
          ref.type  #2 =
            {   %
                % Format first author with and without initials
              author empty$
                { title.sort.label  update.no.initials }
                { author  check.add.initials.field }
              if$
            }
            {   %
                % Format first author with and without initials
              author empty$
                { editor empty$
                    { title.sort.label  update.no.initials }
                    { editor check.add.initials.field }
                  if$
                }
                { author check.add.initials.field }
              if$
            }
          if$
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compute tentative number of names that must be cited (1).
% Call with
%   field  tentative.cite.num.names.field

FUNCTION {tentative.cite.num.names.field}
{ 'field :=
  field num.names$  'numnames :=
  numnames #3 <
    {   %
        % 1 or 2 names: always cite all of them.
      numnames  'cite.num.names.full  :=
      numnames  'cite.num.names.short :=
    }
    { numnames #6 <
        {   %
            % 3-5 names: cite all of them the first time,
            % only the first name later times
          numnames  'cite.num.names.full  :=
          #1        'cite.num.names.short :=
        }
        {   %
            % 6 or more names: cite only the first name
          #1  'cite.num.names.full  :=
          #1  'cite.num.names.short :=
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compute tentative number of names that must be cited (2).

FUNCTION {tentative.cite.num.names}
{   %
    % Check whether author or editor or other field acts as author.
    % Number of names is only relevant with author or editor.
    %
  firstkey empty$ not
    {
      #1 'cite.num.names.full  :=
      #1 'cite.num.names.short :=
    }
    { key empty$ not
        {
          #1 'cite.num.names.full  :=
          #1 'cite.num.names.short :=
        }
        {   %
            % No key or firstkey, so find out which field
            % to use as author.
            %
            % Check reference type:
            %   if result is 1 then possibly editor acts as author
            %                2 then editor does not act as author
            %                3 then key should have been used
            %                0 then unknown reference type
          ref.type  #2 =
            {   %
                % Format first author with and without initials
              author empty$
                {
                  #1 'cite.num.names.full  :=
                  #1 'cite.num.names.short :=
                }
                { author tentative.cite.num.names.field }
              if$
            }
            {   %
                % Format first author with and without initials
              author empty$
                { editor empty$
                    {
                      #1 'cite.num.names.full  :=
                      #1 'cite.num.names.short :=
                    }
                    { editor tentative.cite.num.names.field }
                  if$
                }
                { author tentative.cite.num.names.field }
              if$
            }
          if$
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Initialize "number of names to be cited" before
% looping over entries.

FUNCTION {init.cite.num.names}
{ #0      'cite.num.names.old  :=
  #0      'numnames.old        :=
  "yyyy"  'year.label.old      :=
  #0      'add.to.year.old     :=
  ""      'aut1f.old           :=
  ""      'aut2.old            :=
  ""      'aut3.old            :=
  ""      'aut4.old            :=
  ""      'aut5.old            :=
  ""      'aut6.old            :=
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Update "number of names to be cited" .

FUNCTION {update.cite.num.names}
{ cite.num.names.short  'cite.num.names.old  :=
  numnames              'numnames.old        :=
  year.label            'year.label.old      :=
  add.to.year           'add.to.year.old     :=
  aut1f                 'aut1f.old           :=
  aut2                  'aut2.old            :=
  aut3                  'aut3.old            :=
  aut4                  'aut4.old            :=
  aut5                  'aut5.old            :=
  aut6                  'aut6.old            :=
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Format (maximally) 6 authors for comparison issues
% to determine number of authors that must be cited.
% It is assumed that the 'field' and 'numnames' variables
% have already been defined.

FUNCTION {format.6.authors}
{   %
    % First author: with initials.
    %
  field #1 cite.initials.name.format format.name$  'aut1f :=
    %
    % Second and later authors: without initials.
    %
  numnames #1 >
    name.max #1 >
      and
    {   %
        % 2nd author
      field #2 cite.name.format format.name$  'aut2 :=
        %
      numnames #2 >
        name.max #2 >
          and
        {   %
            % 3nd author
          field #3 cite.name.format format.name$  'aut3 :=
            %
          numnames #3 >
            name.max #3 >
              and
            {   %
                % 4th author
              field #4 cite.name.format format.name$  'aut4 :=
                %
              numnames #4 >
                name.max #4 >
                  and
                {   %
                    % 5th author
                  field #5 cite.name.format format.name$  'aut5 :=
                    %
                  numnames #5 >
                    name.max #5 >
                      and
                    {   %
                        % 6th author
                      field #6 cite.name.format format.name$  'aut6 :=
                    }
                    {   %
                        % 5 authors: 6 is empty
                        %
                      "" 'aut6 :=
                    }
                  if$
                }
                {   %
                    % 4 authors: 5-6 are empty
                    %
                  "" 'aut5 :=
                  "" 'aut6 :=
                }
              if$
            }
            {   %
                % 3 authors: 4-6 are empty
                %
              "" 'aut4 :=
              "" 'aut5 :=
              "" 'aut6 :=
            }
          if$
        }
        {   %
            % 2 authors: 3-6 are empty
            %
          "" 'aut3 :=
          "" 'aut4 :=
          "" 'aut5 :=
          "" 'aut6 :=
        }
      if$
    }
    {   %
        % Only 1 author: 2-6 are empty
        %
      "" 'aut2 :=
      "" 'aut3 :=
      "" 'aut4 :=
      "" 'aut5 :=
      "" 'aut6 :=
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compute definitive number of names that must be cited
% and whether a's or b's must be added to year (1).
% a's or b's are necessary: update add.to.year variable

FUNCTION {change.add.to.year}
{
  forward  #1  =
    {   %
        % Moving forward: this add.to.year number must be 1 higher than
        % previous.
        %
      add.to.year.old  #0  >
        { add.to.year.old  #1 +    'add.to.year  := }
        { #2  'add.to.year  := }
      if$
    }
    {   %
        % Moving backward: this add.to.year number must be 1 lower than
        % previous.
        %
      add.to.year.old  #1 -    'add.to.year  :=
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compute definitive number of names that must be cited
% and whether a's or b's must be added to year (1).
% Current and/or previous entry has 1 or 2 authors
% or editors acting as authors and they are published in the
% same year. The number of authors does not need to be changed
% in this case, but a's or b's may be necessary.

FUNCTION {definitive.cite.num.names.1.or.2}
{   %
  numnames  numnames.old  =
    {   %
        % Same number of names: ambiguity could arise. Check whether current
        % and previous have the same author(s).
        %
      aut1f aut1f.old =
        {   %
            % Same first author: if the second author is also the same or if
            % there is only one author, a's and b's should be added.
            %
          aut2  aut2.old  =
            numnames  #2  =
              and
                %
          numnames  #1  =
            or
            {   %
                % Same author(s): add to year.
                %
              change.add.to.year
            }
            {   %
                % Different second author: no ambiguity possible.
                %
              skip$
            }
          if$
        }
        {   %
            % Different first author: no ambiguity possible.
            %
          skip$
        }
      if$
    }
    {   %
        % Different number of names: no ambiguity possible.
        %
      skip$
    }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compute definitive number of names that must be cited
% and whether a's or b's must be added to year (2).
% Both current and previous entries have 3 or more authors
% or editors acting as authors and they are published in the
% same year.

FUNCTION {definitive.cite.num.names.3.or.more}
{   %
    % Check whether current and previous have the same first author.
    %
  aut1f aut1f.old =
    {   %
        % Same first author: check second author
        %
      aut2 aut2.old =
        {   %
            % Same 1st & 2nd author: check 3rd.
            %
          aut3 aut3.old =
            {   %
                % Same 1st-3rd authors: check 4th.
                %
              numnames.old #3 =
                { numnames #3 =
                    {   %
                        % Both current and previous have 3 authors, which are
                        % the same, so both have identical author-year
                        % combinations, so ambiguity should be resolved by
                        % a's and b's. Check whether more authors were
                        % necessary for previous one.
                        %
                      change.add.to.year
                      cite.num.names.short  cite.num.names.old  <
                        { cite.num.names.old
                            'cite.num.names.short :=
                        }
                        'skip$
                      if$
                    }
                    {   %
                        % Previous has 3 authors, current has more, with same
                        % first 3, so at least 4 must be used for current to
                        % make a difference.
                        %
                      cite.num.names.short  #4  <
                        { #4  'cite.num.names.short := }
                        'skip$
                      if$
                    }
                  if$
                }
                { numnames #3 =
                    {   %
                        % Current has 3 authors, previous has more, with same
                        % first 3, so all 3 of current must be used.
                        %
                      numnames  'cite.num.names.short :=
                    }
                    {   %
                        % Same 1st-3rd author and both current and previous
                        % have at least 4 authors: check 4th.
                        %
                      aut4 aut4.old =
                        {   %
                            % Same 1st-4th authors: check 5th.
                            %
                          numnames.old #4 =
                            { numnames #4 =
                                {   %
                                    % Both current and previous have 4 authors,
                                    % which are the same, so both have
                                    % identical author-year combinations, so
                                    % ambiguity should be resolved by a's and
                                    % b's. Check whether more authors were
                                    % necessary for previous one.
                                    %
                                  change.add.to.year
                                  cite.num.names.short cite.num.names.old  <
                                    { cite.num.names.old
                                        'cite.num.names.short :=
                                    }
                                    'skip$
                                  if$
                                }
                                {   %
                                    % Previous has 4 authors, current has more,
                                    % with same first 4, so at least 5 must be
                                    % used for current to make a difference.
                                    %
                                  cite.num.names.short  #5  <
                                    { #5  'cite.num.names.short := }
                                    'skip$
                                  if$
                                }
                              if$
                            }
                            { numnames #4 =
                                {   %
                                    % Current has 4 authors, previous has more,
                                    % with same first 4, so all 4 of current
                                    % must be used.
                                    %
                                  numnames  'cite.num.names.short :=
                                }
                                {   %
                                    % Same 1st-4th author and both current and
                                    % previous have at least 5 authors: check
                                    % 5th.
                                    %
                                  aut5 aut5.old =
                                    {   %
                                        % Same 1st-5th authors: check 6th.
                                        %
                                      numnames.old #5 =
                                        { numnames #5 =
                                            {   %
                                                % Both current and previous
                                                % have 5 authors, which are the
                                                % same, so both have identical
                                                % author-year combinations, so
                                                % ambiguity should be resolved
                                                % by a's and b's. Check whether
                                                % more authors were necessary
                                                % for previous one.
                                                %
                                              change.add.to.year
                                              cite.num.names.short
                                                cite.num.names.old  <
                                                { cite.num.names.old
                                                    'cite.num.names.short  :=
                                                }
                                                'skip$
                                              if$
                                            }
                                            {   %
                                                % Previous has 5 authors,
                                                % current has more, with same
                                                % first 5, so at least 6 must
                                                % be used for current to make
                                                % a difference.
                                                %
                                              cite.num.names.short #6 <
                                                { #6 'cite.num.names.short := }
                                                'skip$
                                              if$
                                            }
                                          if$
                                        }
                                        { numnames #5 =
                                            {   %
                                                % Current has 5 authors,
                                                % previous has more, with same
                                                % first 5, so all 5 of current
                                                % must be used.
                                                %
                                              numnames 'cite.num.names.short :=
                                            }
                                            {   %
                                                % Same 1st-5th author and both
                                                % current and previous have at
                                                % least 6 authors. If one has
                                                % 6 authors and the other has
                                                % more or the 6th is different,
                                                % 6 should be used (which is
                                                % the maximum).
                                                %
                                              numnames #6 >
                                                numnames.old #6 =
                                                  and
                                                %
                                              numnames #6 =
                                                numnames.old #6 >
                                                  and
                                                %
                                              or
                                                %
                                              aut6 aut6.old =
                                                not
                                                %
                                              or
                                                { #6 cite.num.names.short <
                                                    { #6
                                                        'cite.num.names.short
                                                          :=
                                                    }
                                                    'skip$
                                                  if$
                                                }
                                                {   %
                                                    % The first 6 authors are
                                                    % the same and either both
                                                    % have 6 or both have more.
                                                    % So for all practical
                                                    % purposes they have
                                                    % identical author-year
                                                    % combination, so ambiguity
                                                    % should be resolved by a's
                                                    % and b's. Check whether
                                                    % more authors were
                                                    % necessary for previous
                                                    % one.
                                                    %
                                                  change.add.to.year
                                                  cite.num.names.short
                                                    cite.num.names.old
                                                      <
                                                    { cite.num.names.old
                                                        'cite.num.names.short
                                                          :=
                                                    }
                                                    'skip$
                                                  if$
                                                }
                                              if$
                                            }
                                          if$
                                        }
                                      if$
                                    }
                                    {   %
                                        % Different 5th author: citing 5 authors is
                                        % sufficient for this comparison.
                                        %
                                      cite.num.names.short #5 <
                                        { #5 'cite.num.names.short := }
                                        'skip$
                                      if$
                                    }
                                  if$
                                }
                              if$
                            }
                          if$
                        }
                        {   %
                            % Different 4th author: citing 4 authors is
                            % sufficient for this comparison.
                            %
                          cite.num.names.short #4 <
                            { #4 'cite.num.names.short := }
                            'skip$
                          if$
                        }
                      if$
                    }
                  if$
                }
              if$
            }
            {   %
                % Different 3rd author: citing 3 authors is sufficient for this
                % comparison.
                %
              cite.num.names.short #3 <
                { #3 'cite.num.names.short := }
                'skip$
              if$
            }
          if$
        }
        {   %
            % Different 2nd author: citing 2 authors is sufficient for this
            % comparison.
            %
          cite.num.names.short #2 <
            { #2 'cite.num.names.short := }
            'skip$
          if$
        }
      if$
    }
    {   %
        % Different first author: no ambiguity, move to next entry.
        %
      skip$
    }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compute definitive number of names that must be cited
% and whether a's or b's must be added to year (3).
% Current entry has an author or editor acting as author.
%
% Call with
%   field  definitive.cite.num.names.field
%
% What should we do with explicit "others"? Is now ignored.
% If this causes ambiguity that could be resolved, the user
% should have added additional author names.

FUNCTION {definitive.cite.num.names.field}
{ 'field :=
  field num.names$  'numnames :=
    %
    % Format authors
    %
  format.6.authors
    %
    % Now compare authors with authors of previous entry.
    %
  cite.num.names.short   numnames.old    >
    {   %
        % The previous entry has less authors than already defined
        % necessary to be cited. No ambiguity is possible and we're ready.
        %
      skip$
    }
    {   %
        % Both previous and current entry have at least one author .
        %
      year.label   year.label.old  =
        {   %
            % Same year label: possibly ambiguous citation.
            %
            % First check: current and/or previous have 1 or
            % 2 authors.
            %
          numnames  #3  <
            numnames.old  #3  <
              or
               %
            { definitive.cite.num.names.1.or.2 }
            { definitive.cite.num.names.3.or.more }
          if$
        }
        {   %
            % Different year label: everything's fine,
            % move to next entry.
            %
          skip$
        }
      if$
    }
  if$
    %
    % If during the previous process the name maximum is exceeded
    % (which was not checked), correct this. NOTE: If the name
    % maximum is smaller than 6, this could lead to ambiguous
    % citations if, e.g., the year and the first 5 authors are
    % the same, but the 6th author is different.
    %
  cite.num.names.short   name.max   >
    { name.max  'cite.num.names.short  := }
    'skip$
  if$
    %
    % For a "full" cite, the number of names should always be at least
    % as large as for a "short" cite.
    %
  cite.num.names.full   cite.num.names.short   <
    { cite.num.names.short 'cite.num.names.full := }
    'skip$
  if$
    %
    % Update "old" variables for next entry.
    %
  update.cite.num.names
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compute definitive number of names that must be cited (4)
% and especially whether a's and b's should be added.
% This function is for the situation when author or editor
% are not used and firstkey, key, or something else is
% used to cite the referenced work.
%
% Call with
%   formatted.field   definitive.cite.no.names

FUNCTION {definitive.cite.no.names}
{   %
    % The formatted field that acts as author is on top
    % of the stack.
      'aut1f :=
  ""  'aut2 :=
  ""  'aut3 :=
  ""  'aut4 :=
  ""  'aut5 :=
  ""  'aut6 :=
  #1  'numnames  :=
    %
  year.label   year.label.old  =
    {   %
        % Same year label: possibly ambiguous citation.
        %
      definitive.cite.num.names.1.or.2
    }
    {   %
        % Different year label: everything's fine,
        % move to next entry.
        %
      skip$
    }
  if$
    %
    % Update "old" variables for next entry.
    %
  update.cite.num.names
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compute definitive number of names that must be cited (5).

FUNCTION {definitive.cite.num.names}
{   %
    % Check whether author or editor or other field acts as author.
    % Number of names is only relevant with author or editor.
    %
  firstkey empty$ not
    { firstkey  sortify  remove.spaces  definitive.cite.no.names }
    { key empty$ not
        { key  sortify  remove.spaces  definitive.cite.no.names }
        {   %
            % No key or firstkey, so find out which field
            % to use as author.
            %
            % Check reference type:
            %   if result is 1 then possibly editor acts as author
            %                2 then editor does not act as author
            %                3 then key should have been used
            %                0 then unknown reference type
          ref.type  #2 =
            {   %
                % Format first author with and without initials
              author empty$
                { title.sort.label  definitive.cite.no.names }
                { author  definitive.cite.num.names.field }
              if$
            }
            {   %
                % Format first author with and without initials
              author empty$
                { editor empty$
                    { title.sort.label  definitive.cite.no.names }
                    { editor definitive.cite.num.names.field }
                  if$
                }
                { author definitive.cite.num.names.field }
              if$
            }
          if$
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make a tentative year sorting label (without `a' and `b').

FUNCTION {make.tentative.year.sort.label}
{   %
    % Implicit or explicit ``no date'' is put at the front
    % (the year zero; years B.C. will imply complications)
    % because these are possibly old works.
    % ``In press'' is put at the end.
    %
  year empty$
    { "0000" 'year.label := }
    { year "\bibnodate" =
      year "l" change.case$ "no date" = or
      year "l" change.case$ "n.d."    = or
        { "0000" 'year.label := }
        { year "\BIP" =
          year "l" change.case$ "in press"    =  or
          year "l" change.case$ "forthcoming" =  or
            { "9999" 'year.label := }
            {   % It is not checked whether the year field
                % makes sense.
              year  sortify  remove.spaces  'year.label :=
            }
          if$
        }
      if$
    }
  if$
    %
    % Push year sort label on the stack
  year.label
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Give month and day when available.

FUNCTION {month.number.day}
{ month empty$
    { "" }
    { month sortify remove.spaces
        %
        % Add the day when available.
      day empty$
        'skip$
        { "/" *
          day  sortify  remove.spaces  *
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make tentative sort label with names in field on top of
% the stack.
%
% Call with
%   field make.name.sort.label
% where 'field' is the field that takes the author-role.

FUNCTION {make.name.sort.label}
{   %
    % Author or editor-acting-as-author available.
    % => Make tentative "short cite with initials" author
    %    label (L1) of one of the forms
    %     "Last1  F1"
    %     "Last1  F1   Last2"
    %     "Last1  F1   zzzz"  ("zzzz" representing et al.)
    % => If more than 2 'authors': make label (L2) for 2nd-6th authors
    %    of one of the forms
    %     "Last2   Last3"
    %     "Last2   Last3   Last4"
    %     "Last2   Last3   Last4   Last5"
    %     "Last2   Last3   Last4   Last5   Last6"
    %     "Last2   Last3   Last4   Last5   Last6   zzzz"
    %
    % Then format year label (L3) of one of the forms:
    %     "0000"  (missing year or explicit 'no date')
    %     "9999"  ('in press')
    %     year    (otherwise; don't use originalyear here yet)
    %
    % From earlier sorting of titles, we have title number. Convert
    % to string, which gives title label (L4) .
    %
    % Then tentative sorting label (author.year.sort.label) is a
    % concatenation of
    %     L1
    %     "    "
    %     L3
    %     "    "
    %     L2
    %     "    "
    %     L4
    %
    % The name field is on top of the stack.
  'field :=
    %
    % numnames is the total number of names contained in field
  field num.names$ 'numnames :=
    %
    % Format first author
  field  #1  sort.name.format  format.name$
    %
    % Format the second author if there are two, or else "zzzz" = et al.
  numnames #1 =
    'skip$
    { numnames #2 =
        {   %
            % Two authors: format second author
          field  #2  "{ll{}}"  format.name$  's :=
          s "others" =
            { "   zzzz" * }    % Add "et al."-substitute
            { "   " * s * }    % Add second author
          if$
        }
        { "   zzzz" * } % 3 or more authors: add "et al."-substitute
      if$
    }
  if$
  "    "  *                          % Add spaces
  make.tentative.year.sort.label *   % Add year (L3).
  "    "  *                          % Add spaces
    %
    % Now build up L2 if applicable
  numnames #3 <
    'skip$
    {   %
        % Treat last author slightly differently
      numnames name.max >
        { name.max  'lastname  :=
          "   zzzz"                 % Push "et al."-substitute on stack
        }
        { numnames  'lastname  :=
          ""                        % Push empty string on stack
        }
      if$
        %
        % Names 2 to "last" - 1
      ""                            % Push empty string on stack
      #2 'nameptr :=
      { nameptr lastname < }
        {   % Add name no. nameptr
          field  nameptr  "{ll{}}"  format.name$ *
          "   " *
          nameptr #1 +  'nameptr :=
        }
      while$
        %
        % "Last" author
      field  lastname  "{ll{}}"  format.name$  's :=
      s "others" =
        { "zzzz" * }    % Add "et al."-substitute
        { s * }         % Add last author
      if$
        %
      swap$ *  % Add the previously formatted empty string or
               % "et al."-substitute if there are many authors.
      *        % Add L2 to the earlier labels.
    }
  if$
    %
  "    "  *                          % Add spaces
  title.number  conv.int.to.str  *   % Add sorted title number (L4).
  sortify                            % Clean up and convert to lowercase
  "    "  *                          % Add spaces
  month.number.day  *                % Add month and day when available
  'author.year.sort.label :=         % Assign result to sort label.
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Called by make.tentative.sort.label to make tentative
% sort label if key or firstkey is available or author and
% editor are empty or unusable.
%
% Call with
%   field make.field.year.sort.label
% where 'field' is the field that takes the author-role,
% perhaps already subjected to removing articles from the
% beginning.

FUNCTION {make.field.year.sort.label}
{   %
    % 'field' acts as first author (L1), subsequent authors
    % are empty (L2).
    %
    % Then format year label (L3) of one of the forms:
    %     "0000"  (missing year or explicit 'no date')
    %     "9999"  ('in press')
    %     year    (otherwise; don't use originalyear here yet)
    %
    % From earlier sorting of titles, we have title number. Convert
    % to string, which gives title label (L4) .
    %
    % Then tentative sorting label (author.year.sort.label) is a
    % concatenation of
    %     L1
    %     "    "
    %     L3
    %     "    "
    %     L2
    %     "    "
    %     L4
    %
    % 'field' is on top of the stack. It is already supposed to be cleaned
    % (i.e., sortified and space-removed), so this is already L1.
  "    "  *                          % Add spaces to L1
  make.tentative.year.sort.label *   % Add year (L3).
  "    "  *                          % Add spaces
  "    "  *                          % L2 is empty, add spaces
  title.number  conv.int.to.str  *   % Add sorted title number (L4).
  sortify                            % Clean up and convert to lowercase
  "    "  *                          % Add spaces
  month.number.day  *                % Add month and day when available
  'author.year.sort.label :=         % Assign result to sort label.
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Called by make.tentative.sort.label to make tentative
% sort label if key or firstkey are not available and
% author or editor may be used

FUNCTION {make.author.editor.sort.label}
{ author empty$
    { editor empty$
        {   %
            % Use what has previously been stored in title.sort.label
            % as author substitute .
          title.sort.label   make.field.year.sort.label
        }
        { editor make.name.sort.label }
      if$
    }
    { author make.name.sort.label }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Called by make.tentative.sort.label to make tentative
% sort label if key or firstkey are not available and
% author (but not editor) may be used

FUNCTION {make.author.sort.label}
{ author empty$
    {   %
        % Use what has previously been stored in title.sort.label
        % as author substitute .
      title.sort.label   make.field.year.sort.label
    }
    { author make.name.sort.label }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make tentative label for citing and sorting and do some
% preprocessing.

FUNCTION {make.tentative.sort.label}
{   %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % General strategy:
    %
    % Ordinary situation: author or editor-acting-as-author
    % available.
    % => Make tentative "short cite with initials" author
    %    label (L1) of one of the forms
    %     "Last1  F1"
    %     "Last1  F1   Last2"
    %     "Last1  F1   zzzz"  ("zzzz" representing et al.)
    % => If more than 2 'authors': make label (L2) for 2nd-6th authors
    %    of one of the forms
    %     "Last2   Last3"
    %     "Last2   Last3   Last4"
    %     "Last2   Last3   Last4   Last5"
    %     "Last2   Last3   Last4   Last5   Last6"
    %     "Last2   Last3   Last4   Last5   Last6   zzzz"
    % When key is available (overrules author and editor fields):
    % => L1 = key, L2 = ""
    % No author, editor, and key: define title or substitute as key
    % and format as key.
    %
    % Then format year label (L3) of one of the forms:
    %     "0000"  (missing year or explicit 'no date')
    %     "9999"  ('in press')
    %     year    (otherwise; don't use originalyear here yet)
    %
    % From earlier sorting of titles, we have title number. Convert
    % to string, which gives title label (L4) .
    %
    % Then tentative sorting label (author.year.sort.label) is a
    % concatenation of
    %     L1
    %     "    "
    %     L3
    %     "    "
    %     L2
    %     "    "
    %     L4
    %
    % This can then be sorted, from which it can be derived
    % whether initials are necessary, how many names must
    % be used for short and full citations, and whether "a"'s and
    % "b"'s etc. are necessary behind the year labels.
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % key and firstkey overrule author information
    %
  firstkey empty$ not
    { key empty$ not
        {   %
            % Both key and firstkey available:
            % for sorting and checking initials, treat key as last
            % name and firstkey as initials.
            %
          key       sortify  remove.spaces
          "  " *
          firstkey  sortify  remove.spaces *
          make.field.year.sort.label
        }
        { firstkey  sortify  remove.spaces make.field.year.sort.label }
      if$
    }
    { key empty$ not
        { key   sortify  remove.spaces make.field.year.sort.label }
        {   %
            % No key or firstkey, so find out which field
            % to use as author.
            %
            % Check reference type:
            %   if result is 1 then possibly editor acts as author
            %                2 then editor does not act as author
            %                3 then key should have been used
            %                0 then unknown reference type
          ref.type
          duplicate$ #1 =
            { pop$
              make.author.editor.sort.label
            }
            { duplicate$ #2 =
                { pop$
                  make.author.sort.label
                }
                { #3 =
                    { "no key in " cite$ * warning$
                      make.author.editor.sort.label
                    }
                    { make.author.editor.sort.label }
                  if$
                }
              if$
            }
          if$
        }
      if$
    }
  if$
    %
  author.year.sort.label  'sort.key$ :=
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make final sort label with names in field on top of
% the stack.
%
% Call with
%   field  make.definitive.name.sort.label
%
% where 'field' is the field that takes the author-role.

FUNCTION {make.definitive.name.sort.label}
{   %
    % Author or editor-acting-as-author available.
    % => Make author-with-initials label (L1) of one of the forms
    %     "Last1  F1   Last2  F2   ...   LastN  FN"
    %     "Last1  F1   Last2  F2   ...   Last6  F6   zzzz"
    %     (where N <= 6 is the total number of authors, and
    %      "zzzz" represents et al. if there are more than 6 authors)
    % No author, editor, and key: define title or substitute as sort key.
    %
    % The name field is on top of the stack.
  'field :=
    %
    % numnames is the total number of names contained in field
  field num.names$ 'numnames :=
    %
    % If there are more than 6 authors, only 6 are mentioned.
  numnames  name.max  >
    { name.max  'format.num.names  := }
    { numnames  'format.num.names  := }
  if$
    % Initialize stack with empty string
  ""
    %
    % Cycle over authors.
  #1  'nameptr  :=
    { nameptr  format.num.names  < }
    { % Format author and add spaces
       field  nameptr  sort.name.format  format.name$  *
       "   " *
       nameptr #1 + 'nameptr :=
    }
  while$
    % Format last author that must be formatted
  field  nameptr  sort.name.format  format.name$  *
    % Add et al. if necessary
  nameptr numnames  <
    { "   zzzz" * }
    'skip$
  if$
  sortify                            % Clean up and change case
  "    "  *                          % Add spaces
  year.label *                       % Add year
  "    "  *                          % Add spaces
  title.number  conv.int.to.str  *   % Add sorted title number
  "    "  *                          % Add spaces
  month.number.day  *                % Add month and day when available
  'author.year.sort.label :=         % Assign result to sort label.
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Called to make definitive sort label if author and
% editor are empty or unusable.
%
% Call with
%   field make.definitive.field.year.sort.label
% where 'field' is the field that takes the author-role,
% perhaps already subjected to removing articles from the
% beginning.

FUNCTION {make.definitive.field.year.sort.label}
{   %
    % 'field' acts as author (L1).
    %
    % Then format year label (L2) of one of the forms:
    %     "0000"  (missing year or explicit `no date')
    %     "9999"  (`in press')
    %     year    (otherwise; don't use originalyear here yet)
    %
    % From earlier sorting of titles, we have title number. Convert
    % to string, which gives title label (L3) .
    %
    % Then tentative sorting label (author.year.sort.label) is a
    % concatenation of
    %     L1
    %     "    "
    %     L2
    %     "    "
    %     L3
    %
    % 'field' is on top of the stack. It is already supposed to be cleaned
    % (i.e., sortified and space-removed), so this is already L1.
  "    "  *                          % Add spaces
  year.label *                       % Add year
  "    "  *                          % Add spaces
  title.number  conv.int.to.str  *   % Add sorted title number
  "    "  *                          % Add spaces
  month.number.day  *                % Add month and day when available
  'author.year.sort.label :=         % Assign result to sort label.
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Called by make.final.sort.key if author or editor
% may be used.

FUNCTION {make.definitive.author.editor.sort.label}
{ author empty$
    { editor empty$
        {   %
            % Use what has previously been stored in title.sort.label
            % as author substitute .
          title.sort.label   make.definitive.field.year.sort.label
        }
        { editor  make.definitive.name.sort.label }
      if$
    }
    { author  make.definitive.name.sort.label }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Called by make.final.sort.key if author but not editor
% may be used.

FUNCTION {make.definitive.author.sort.label}
{ author empty$
    {   %
        % Use what has previously been stored in title.sort.label
        % as author substitute .
      title.sort.label   make.definitive.field.year.sort.label
    }
    { author  make.definitive.name.sort.label }
  if$
}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make final sort key .

FUNCTION {make.final.sort.key}
{   %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % General strategy:
    %
    % Ordinary situation: author or editor-acting-as-author
    % available.
    % => Make author-with-initials label (L1) of one of the forms
    %     "Last1  F1   Last2  F2   ...   LastN  FN"
    %     "Last1  F1   Last2  F2   ...   Last6  F6   zzzz"
    %     (where N <= 6 is the total number of authors, and
    %      "zzzz" represents et al. if there are more than 6 authors)
    % No author, editor, and key: define title or substitute as sort key.
    %
    % Then format year label (L2) of one of the forms:
    %     "0000"  (missing year or explicit `no date')
    %     "9999"  (`in press')
    %     year    (otherwise; don't use originalyear here yet)
    %       Add "/"month"/"day to the latter when available.
    %
    % From earlier sorting of titles, we have title number. Convert
    % to string, which gives title label (L3) .
    %
    % Then final sorting label (author.year.sort.label) is a
    % concatenation of
    %     L1
    %     "    "
    %     L2
    %     "    "
    %     L3
    %
    % This can then be sorted.
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    %
    % Find out which field
    % to use as author.
    %
    % Check reference type:
    %   if result is 1 then possibly editor acts as author
    %                2 then editor does not act as author
    %                3 then key should have been used
    %                0 then unknown reference type
  ref.type  #2 =
    { make.definitive.author.sort.label }
    { make.definitive.author.editor.sort.label }
  if$
    %
  author.year.sort.label  'sort.key$ :=
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  FUNCTIONS THAT ALLOW SORTING BY TITLE                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Remove first N characters of string if they are equal to
% teststring .
%
% Call with
%     teststring N string chop.word
%
% E.g.,
%     "A " #2 "A fine old day" chop.word
% gives "fine old day"
% and
%     "A " #2 "The fine old day" chop.word
% gives "The fine old day".

FUNCTION {chop.word}
{ 's :=
  'len :=
  s #1 len substring$ =
    { s len #1 + global.max$ substring$ }
    { s }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Remove "a ", "an ", and "the " from beginning of string.
%
% Call with
%     string chop.articles

FUNCTION {chop.articles}
{ 's :=
  "a " #2
    "an " #3
      "the " #4
        s
      chop.word
    chop.word
  chop.word
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Format title and other non-name/date entries for sort key.
%
% Call with
%    field format.sort.title
%
% Make sure that field is not empty, this is not checked here!

FUNCTION {format.sort.title}
{   %
    % Remove non-alphanumeric characters and change to lower case .
  sortify
    %
    % Remove "a ", "an ", and "the " from the front .
  chop.articles #1 entry.max$ substring$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make title sorting label or substitute.

FUNCTION {make.sort.title}
{ title empty$
    { text empty$
        { type empty$
            { howpublished empty$
                { note empty$
                    { url empty$
                        { " " }
                        { url  format.sort.title }
                      if$
                    }
                    { note  format.sort.title }
                  if$
                }
                { howpublished  format.sort.title }
              if$
            }
            { type  format.sort.title }
          if$
        }
        { text format.sort.title }
      if$
    }
    { title  format.sort.title }
  if$
  remove.spaces
  'title.sort.label :=
  title.sort.label 'sort.key$ :=
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make title number: rank number of sorted title .

FUNCTION {make.title.number}
{ title.sort.label  old.label  =
    {   %
        % A tie: old and new label are the same .
      old.number  'title.number :=
    }
    {   %
        % The usual situation: titles are different.
      old.number  #1  +  'title.number :=
      title.number       'old.number   :=
      title.sort.label   'old.label    :=
    }
  if$
}
%    \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  \subsection{Name formatting}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In order to support removal of spaces between the initials,
% we have to split the formatting of the constituent parts,
% because something like |"{ll}{, f{\BPBI }.}{ vv}{, jj}"| removes
% the hyphens between initials as well. The ``classic'' versions
% treat the von part differently. They were used in pervious versions
% of \pkg{apacite}.
%
%    \begin{macrocode}

FUNCTION {last.part.name.format.classic} { "{ll}" }

FUNCTION {von.junior.name.format.classic} { "{ vv}{, jj}" }

FUNCTION {last.part.name.format} { "{vv }{ll}" }

FUNCTION {initials.with.space.name.format} { "{f.}" }

FUNCTION {von.last.junior.name.format} { "{vv }{ll}{ jj}" }

FUNCTION {von.junior.name.format} { "{, jj}" }

FUNCTION {one.complete.name.format} { "{vv }{ll}{, jj}{, ff}" }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% text.length$ views "special characters" as 1, whereas
% substring$ looks at the number of actual characters.
% So
%  "{\TeX}" text.length$   = 1
%  "{TeX}"  text.length$   = 3
% but
%  "{\TeX}" #4 #2 substring$ = "eX"
%  "{TeX}"  #4 #2 substring$ = "X}"
% Therefore, it is convenient to have a string length function
% that uses the same numbering as substring$:
%  "{\TeX}" string.length  = 6
%  "{TeX}"  string.length  = 5

FUNCTION {string.length}
{ #0 'pos :=
  % If the next character exists, i.e., is not empty,
  % add 1 to the string length.
  % We cannot use empty$ because " " empty$ is true.
  { duplicate$ pos #1 + #1 substring$ "" = not }
    { pos #1 + 'pos := }
  while$
  pop$ pos
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Replace ". " and ".~" with "\BPBI " (period between initials)
% and     ".-" with "\BHBI " (hyphen between initials)
% but only at brace level 0.

FUNCTION {transform.spaces.and.hyphens}
{ 's :=                    % The original string
  s string.length 'len :=  % Its length (no. of characters)
  "" 't :=                 % Initialize the transformed string
  #1 'pos :=
  #0 'brace.level :=
    %
    % while (pos < len) do
    %
  { pos len < }
    { % First, check whether we are at brace level 0
      brace.level #0 =
        {
          % At least two characters left: check for ". ", ".~", and ".-".
          % If so, replace and shift two positions.
          s pos #2 substring$  ". " =
          s pos #2 substring$  ".~" = or
            { t "\BPBI " *  't :=
              pos #2 +  'pos :=
            }
            { s pos #2 substring$  ".-" =
                { t "\BHBI " *  't :=
                  pos #2 +  'pos :=
                }
                { % neither is true, copy one character and shift one position
                  t   s pos #1 substring$   *   't :=
                  % Check whether we need to increase brace level.
                  % Note that this is not sophisticated: it does not capture
                  % \{, \verb+}+, etc.
                  % Note also that unbalanced braces cause problems.
                  s pos #1 substring$ "{" =
                    { brace.level #1 + 'brace.level := }
                    'skip$
                  if$
                  pos #1 +  'pos :=
                }
              if$
            }
          if$
        }
        { % Not at brace level 0: copy result literally
          t   s pos #1 substring$   *   't :=
          % Check whether we need to increase or decrease brace level.
          % Note that this is not sophisticated: it does not capture
          % \{, \verb+}+, etc.
          s pos #1 substring$ "{" =
            { brace.level #1 + 'brace.level := }
            { s pos #1 substring$ "}" =
                { brace.level #1 - 'brace.level := }
                'skip$
              if$
            }
          if$
          pos #1 +  'pos :=
        }
      if$
    }
  while$
    %
  pos len =
    { % Last character, copy
      t   s pos #1 substring$   *   't :=
    }
    { % pos = len + 1, so s ends with ". " or ".-"
      % This should not have happened, but make the best out of it.
      % Push last two characters of s on the stack, i.e., ". " or ".-".
      s len #1 - #2 substring$
      % Remove "\BPBI " or "\BHBI " from t
      t text.length$ 'len :=   % Length of t (no. of characters)
      t #1 len #6 - substring$
      % Concatenate and assign to t
      swap$ * 't :=
    }
  if$
    %
    % Now push the result back on the stack
  t
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Format only the initials of a name, retaining hyphens, but
% removing spaces between first names. So "Jean Pierre" becomes "J.P."
% and "Jean-Pierre" becomes "J.-P.".

FUNCTION {format.initials.with.hyphen}
{ % Format initials.
  % Call with
  %   field authornumber format.initials.with.hyphen
  % e.g.
  %   author #1 format.initials.with.hyphen
  % Instead of field, a string may also be used.
  %
  % First, format initials in the default way, retaining spaces
  % and hyphens.
  initials.with.space.name.format format.name$
  transform.spaces.and.hyphens
}

FUNCTION {format.last.part.name}
{ % Format a name with last.part.name.format,
  % as part of more complicated things.
  % Call with
  %   field authornumber format.last.part.name
  % e.g.
  %   author #1 format.last.part.name
  % Instead of field, a string may also be used.
  last.part.name.format  format.name$
}

FUNCTION {format.von.last.junior.name}
{ % Format a name with von.last.junior.name.format,
  % for citing or as part of more complicated things.
  % Call with
  %   field authornumber format.von.last.junior.name
  % e.g.
  %   author #1 format.von.last.junior.name
  % Instead of field, a string may also be used.
  von.last.junior.name.format  format.name$
}

FUNCTION {format.von.junior.name}
{ % Format a name with von.last.junior.name.format,
  % for citing or as part of more complicated things.
  % Call with
  %   field authornumber format.von.junior.name
  % e.g.
  %   author #1 format.von.junior.name
  % Instead of field, a string may also be used.
  von.junior.name.format  format.name$
}

FUNCTION {format.cite.initials.name}
{ % Format a name for citing with initials.
  % Call with
  %   field authornumber format.cite.initials.name
  % e.g.
  %   author #1 format.cite.initials.name
  % Instead of field, a string may also be used.
  %
  % First, extract the complete name, format it in the canonical form,
  % and push on the stack.
  one.complete.name.format format.name$
  %
  % Format the initials and push on the stack.
  duplicate$ #1 format.initials.with.hyphen
  %
  % Format the von-last-junior part and push on the stack.
  swap$ #1 format.von.last.junior.name
  %
  % Connect with "~" hyphen (if they're both non-empty).
  "~" connect.check
}

FUNCTION {format.author.name}
{ % Format an author name for the reference list.
  % Call with
  %   field authornumber format.author.name
  % e.g.
  %   author #1 format.author.name
  % Instead of field, a string may also be used.
  %
  % First, extract the complete name, format it in the canonical form,
  % and push on the stack.
  one.complete.name.format format.name$
  %
  % Make two copies of the name, format the last name and push on the stack.
  duplicate$ duplicate$ #1 format.last.part.name
  %
  % Format the initials and push on the stack.
  swap$ #1 format.initials.with.hyphen
  %
  % Connect with last name.
  connect.with.comma.check
  %
  % Format the von-junior part and connect with initials.
  swap$ #1 format.von.junior.name "" connect.check
}

FUNCTION {format.editor.name}
{ % Format a name for the reference list as an editor.
  % Call with
  %   field authornumber format.editor.name
  % e.g.
  %   author #1 format.editor.name
  % Instead of field, a string may also be used.
  %
  format.cite.initials.name
}

FUNCTION {format.index.name}
{ % Format an author name for the index.
  % Call with
  %   field authornumber format.index.name
  % e.g.
  %   author #1 format.index.name
  % Instead of field, a string may also be used.
  %
  format.author.name
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  CITATION LABELS                                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%    \end{macrocode}
%
% \begin{macro}{comma.between.two}
% \begin{macro}{comma.between.names}
% \begin{macro}{comma.before.last}
% \begin{macro}{dots.before.last}
% \begin{macro}{and.before.last}
% \begin{macro}{et.al.string.cite}
% \begin{macro}{et.al.string}
% \begin{macro}{et.al.string.period}
% Some macro strings about commas etc.\ between authors.
%    \begin{macrocode}
FUNCTION {comma.between.two} { "\BCBT {}" }

FUNCTION {comma.between.names} { ", " }

FUNCTION {comma.before.last} { "\BCBL {}" }

FUNCTION {dots.before.last} { "\BDBL {}" }

FUNCTION {and.before.last} { "\ \BBA {} " }

FUNCTION {et.al.string.cite} { "\ \protect \BOthers {.}" }

FUNCTION {et.al.string} { "\ \BOthers {.}" }

FUNCTION {et.al.string.period} { "\ \BOthersPeriod {.}" }

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Add author index entry when desired.
% "field" must have been defined before and must contain the
%   contents of the relevant author field.
% "nameptr" must also have been defined before. It is the
%   number of the author that must be formatted. (So if it is
%   #2, then the 2nd author must be formatted.)
% What's on top of the stack (the formatted author) is written
% to the .bbl file.

FUNCTION {add.name.index}
{   %
    %
  make.index
    { "%" * write$ newline$
        % Check for corporate author
      field is.bibcorporate
        { "\corporateAX{" }
        { "\AX{" }
      if$
      write$
      field nameptr sort.name.format  format.name$  sortify  write$ newline$
      "@"  write$
      field nameptr format.index.name
      "}%"  *   write$ newline$
    }
    { "%" * write$ newline$ }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Citation labels when author or editor may be used.
% Field is on top of the stack.
%
% Call with
%   format.num.names  field  make.name.cite.label

FUNCTION {make.name.cite.label}
{ 'field  :=
  'format.num.names  :=
    %
  field  num.names$  'numnames :=   % numnames is the total number of names
                                    %   contained in field
    %
    % It is implicit in the APA manual that if "et al." would refer
    % to exactly one author, then this author should be named
    % instead of "et al."
    %
  format.num.names  numnames  #1  -  =
    { numnames  'format.num.names  := }
    'skip$
  if$
    %
    % Format first author: with or without initials
    %
  #1 'nameptr :=
  cite.initials  #1  =
    { field  nameptr  format.cite.initials.name     }
    { field  nameptr  cite.name.format format.name$ }
  if$
  add.name.index  % Add index entry when desired.
    %
  numnames  #1  =
    'skip$
    { format.num.names  #1  =
        {   %
            % First author et al.
            %
          et.al.string.cite write$
        }
        { numnames  #2  =
            {   %
                % Given that  format.num.names > 1, it is 2.
                % Format second author.
                %
              #2  'nameptr :=
              field  nameptr  cite.name.format  format.name$  's :=
                %
                % Check if 2nd author is explicit "others".
                % If so, insert "et al." string.
                %
              s "others" =
                { et.al.string.cite write$ }  % First et al.
                {   %
                    % First \& Second
                    %
                  and.before.last write$
                  s
                  add.name.index  % Add index entry when desired.
                }
              if$
            }
            {   %
                % 3 or more names, 2 or more must be cited
                %
                % for nameptr := 2  to  format.num.names - 1  do
                %
              #2  'nameptr  :=
                { nameptr  format.num.names  < }
                {   %
                    % Put comma between consecutive authors
                    %
                  comma.between.names  write$
                    %
                    % Format and add next author
                    %
                  field  nameptr  cite.name.format  format.name$
                  add.name.index  % Add index entry when desired.
                    %
                    % Move to next author
                    %
                  nameptr  #1  +  'nameptr :=
                }
              while$
                %
                % nameptr  =  format.num.names
                % Format this author.
                %
              field  nameptr  cite.name.format  format.name$  's :=
                %
              format.num.names  numnames  =
                {   %
                    % This is also the last author. Add (optional) comma.
                    %
                  comma.before.last  write$
                    %
                    % Check if this author is explicit "others".
                    % If so, insert "et al." string.
                    %
                  s "others" =
                    { et.al.string.cite  write$ }
                    { and.before.last    write$
                      s
                      add.name.index  % Add index entry when desired.
                    }
                  if$
                }
                {   %
                    % This is not the last author.
                    % Add comma, author name, and "et al."
                    %
                  comma.between.names  write$
                  s
                  add.name.index  % Add index entry when desired.
                    %
                  comma.before.last  et.al.string.cite  *  write$
                }
              if$
            }
          if$
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Citation labels when no author, editor, firstkey or key
% is available.

FUNCTION {make.title.cite.label}
{   %
    % Formatting: check if formatted as article title or
    % as book title, and insert this formatting.
    %
  is.atype
    { "\APACciteatitle {" }
    { "\APACcitebtitle {" }
  if$
    %
  title empty$
    { text empty$
        { type empty$
            { howpublished empty$
                { note empty$
                    { url empty$
                        { cite$ }
                        { url   }
                      if$
                    }
                    { note  }
                  if$
                }
                { howpublished }
              if$
            }
            { type }
          if$
        }
        { text }
      if$
    }
    { title }
  if$
    %
    % Connect with formatting.
    %
  * "}" *
    %
    % Write to output
    %
  write$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Citation labels when author or editor may be used.

FUNCTION {make.author.editor.cite.label}
{ author empty$
    { editor empty$
        {   %
            % No author or editor:
            % Use title or other description as citation label.
            %
          make.title.cite.label
          "}{%"  write$ newline$
          make.title.cite.label
        }
        { cite.num.names.full   editor  make.name.cite.label
          "}{%"  write$ newline$
          cite.num.names.short  editor  make.name.cite.label
        }
      if$
    }
    { cite.num.names.full   author  make.name.cite.label
      "}{%"  write$ newline$
      cite.num.names.short  author  make.name.cite.label
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Citation labels when author (but not editor) may be used.

FUNCTION {make.author.cite.label}
{ author empty$
    {   %
        % No author:
        % Use title or other description as citation label.
        %
      make.title.cite.label
      "}{%"  write$ newline$
      make.title.cite.label
    }
    { cite.num.names.full   author  make.name.cite.label
      "}{%"  write$ newline$
      cite.num.names.short  author  make.name.cite.label
    }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make "a" or "b" supplement to year label when necessary.

FUNCTION {make.definitive.year.supplement}
{   %
    % Add "a", "b", etc. when necessary.
    %
  add.to.year  #0  =
    { "" }
    { "{\protect "
      year empty$
        { "\BCntND " * }
        { year "\bibnodate" =
          year "l" change.case$ "no date" = or
          year "l" change.case$ "n.d."    = or
            { "\BCntND " * }
            { year "\BIP" =
              year "l" change.case$ "in press"    =  or
              year "l" change.case$ "forthcoming" =  or
                { "\BCntIP " * }
                { "\BCnt " * }
              if$
            }
          if$
        }
      if$
      "{" * add.to.year int.to.str$ * "}}" *
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Add \protect if year is \BIP or \bibnodate.

FUNCTION {protect.year}
{ year empty$
    { "{\protect \bibnodate {}}" }
    { year "\bibnodate" =
      year "l" change.case$ "no date" = or
      year "l" change.case$ "n.d."    = or
        { "{\protect \bibnodate {}}" }
        { year "\BIP" =
          year "l" change.case$ "in press"    =  or
          year "l" change.case$ "forthcoming" =  or
            { "{\protect \BIP {}}" }
            { year }
          if$
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make year label that is used for citations in text.

FUNCTION {make.definitive.year.label}
{ "{\protect \APACyear {"
  originalyear empty$
    { protect.year }
    { originalyear "\bibnodate" =    % date of original publication unknown
      originalyear "l" change.case$ "no date" = or
      originalyear "l" change.case$ "n.d."    = or
        { translator empty$
            { protect.year }
            { "{\protect \BTRANSL {}}~" protect.year * }
          if$
        }
        { year empty$
            { originalyear "/{\protect \bibnodate {}}"   * }  % 1923/n.d.
            { originalyear year =
                { protect.year }
                { originalyear  "/"  *  protect.year * }    % 1923/1961
              if$
            }
          if$
        }
      if$
    }
  if$
  * "}}%" * write$ newline$
    %
    % Add "a", "b", etc. when necessary.
    %
  "{\protect \APACexlab {" "}}"
  make.definitive.year.supplement enclose.check
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make citation labels:
% - Full formatted author list (or substitute if no author
%   available) for first citation;
% - Short formatted author list (ditto) for subsequent
%   citations;
% - Year, with originalyear when applicable, and "a" or "b"
%   etc. addendum when necessary.

FUNCTION {make.cite.labels}
{ newline$
    %
    % Write a few lines for testing purposes.
    %
  test
    { "\bibitem [] {} \fullciteA {" cite$ * "}" *  write$ newline$
      "\bibitem [] {} \citeA {"     cite$ * "}" *  write$ newline$
    }
    'skip$
  if$
    %
  "\bibitem [\protect \citeauthoryear {%" write$ newline$
    %
    % When key or firstkey is available, this takes precedence.
    %
  firstkey  empty$  not
    {   %
        % Full cite: firstkey.
        %
      firstkey  write$
      "}{%"     write$ newline$
        %
        % Short cite: if key is not empty and cite.initials is 0,
        % then key, else firstkey.
        %
      cite.initials  #0  =
        key empty$ not
          and
        { key      }
        { firstkey }
      if$
      write$
    }
    { key empty$ not
        {   %
            % No firstkey, but key available:
            % Both full and short labels are key.
            %
          key    write$
          "}{%"  write$ newline$
          key    write$
        }
        {   % No key or firstkey, so find out which field
            % to use as author.
            %
            % Check reference type:
            %   if result is 1 then possibly editor acts as author
            %                2 then editor does not act as author
            %                3 then key should have been used
            %                0 then unknown reference type
          ref.type  #2  =
            { make.author.cite.label }
            { make.author.editor.cite.label }
          if$
        }
      if$
    }
  if$
  "}{%"  write$ newline$
    %
    % Make year label that's used for citations
    %
  make.definitive.year.label  write$
  "}]{%"                      write$ newline$
  cite$                       write$
  "} "                        write$ newline$
  % author.year.sort.label      write$ newline$ % for testing purposes
  % year.label                  write$ newline$ % for testing purposes
    %
    % If the item is used in a meta-analysis, indicate this with
    % a star.
    %
  "\APACinsertmetastar {%"    write$ newline$
  cite$                       write$
  "}%"                        write$ newline$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  FORMATTING OF REFERENCE LIST                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% "(Ed.)" or "(Eds.)" postfix.
% editor must not be empty

FUNCTION {editor.postfix}
{ editor num.names$ #1 >
    { "(\BEDS)" }
    { "(\BED)"  }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% "(Ed. \& Trans.)" postfix
% editor must not be empty

FUNCTION {editor.trans.postfix}
{ editor num.names$ #1 >
    { "(\BEDS{} \BAnd{} \BTRANSS)" }
    { "(\BED{} \BAnd{} \BTRANS)"   }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % "(Trans.)" postfix
    % translator must not be empty
    %
FUNCTION {trans.postfix}
{ translator num.names$ #1 >
    { "(\BTRANSS)" }
    { "(\BTRANS)" }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Format authors (or editors acting as authors) for the
% reference list, according to APA 5th ed. rules.
%
% Call with
%    dot  field  authors.editors.reflist.apa5
% where field is the field (string) that contains the authors
% (or editors acting as authors) that must be formatted and
% dot is 1 or 0 indicating whether or not a period must end
% the formatting.

FUNCTION {authors.editors.reflist.apa5}
{ 'field  :=
  'dot    :=
    %
  field  num.names$  'numnames :=   % numnames is the total number of names
                                    %   contained in field
  numnames  'format.num.names  :=   % Format all authors
  format.num.names   name.max  >    % Unless this exceeds the maximum of 6.
    { dot
        { name.max             'format.num.names := } % Format 6 authors
        { cite.num.names.full  'format.num.names := } % Format 1 editor
      if$
    }
    'skip$
  if$
    %
    % Enclose authors in APACrefauthors environment to allow crude style
    % options in \LaTeX.
  "\begin{APACrefauthors}%"
  write$ newline$
    %
    % It is kind of explicit in the APA manual that if "et al." would
    % refer to exactly one author (the 7th), then this author should
    % still be replaced by "et al.", unlike with citations.
    % So format.num.names is not adapted.
    %
    % Format first author
    %
  #1  'nameptr :=
  field  nameptr  format.author.name
    %
    % Add period if required and if this is the only author.
    %
  numnames  #1  =
    dot
    and
    { add.period$ }
    'skip$
  if$
  add.name.index  % Add index entry when desired.
    %
  numnames  #1  =
    'skip$
    { format.num.names  #1  =
        {   %
            % First author et al.
            %
          comma.between.two
            %
            % Add period if required.
            %
          dot
            { et.al.string.period * }
            { et.al.string * }
          if$
          write$
        }
        { numnames  #2  =
            {   %
                % Given that  format.num.names > 1, it is 2.
                %
              comma.between.two  write$
                %
                % Format second author.
                %
              #2  'nameptr :=
              field  nameptr  format.author.name  's :=
                %
                % Check if 2nd author is explicit "others".
                % If so, insert "et al." string.
                %
              s "others" =
                {   %
                    % First et al.
                    % Add period if required.
                    %
                  dot
                    { et.al.string.period }
                    { et.al.string }
                  if$
                  write$
                }
                {   %
                    % First \& Second
                    %
                  and.before.last write$
                    %
                    % Add period if required.
                    %
                  dot
                    { s add.period$ }
                    { s }
                  if$
                  add.name.index  % Add index entry when desired.
                }
              if$
            }
            {   %
                % 3 or more names, 2 or more must be cited
                %
                % for nameptr := 2  to  format.num.names - 1  do
                %
              #2  'nameptr  :=
                { nameptr  format.num.names  < }
                {   %
                    % Put comma between consecutive authors
                    %
                  comma.between.names  write$
                    %
                    % Format and add next author
                    %
                  field  nameptr  format.author.name
                  add.name.index  % Add index entry when desired.
                    %
                    % Move to next author
                    %
                  nameptr  #1  +  'nameptr :=
                }
              while$
                %
                % nameptr  =  format.num.names
                % Format this author.
                %
              field  nameptr  format.author.name  's :=
                %
              format.num.names  numnames  =
                {   %
                    % This is also the last author. Add (optional) comma.
                    %
                  comma.before.last  write$
                    %
                    % Check if this author is explicit "others".
                    % If so, insert "et al." string.
                    %
                  s "others" =
                    {   %
                        % Add period if required.
                        %
                      dot
                        { et.al.string.period }
                        { et.al.string }
                      if$
                      write$
                    }
                    { and.before.last  write$
                        %
                        % Add period if required.
                        %
                      dot
                        { s add.period$ }
                        { s }
                      if$
                      add.name.index  % Add index entry when desired.
                    }
                  if$
                }
                {   %
                    % This is not the last author.
                    % Add comma, author name, and "et al."
                    %
                  comma.between.names  write$
                  s
                  add.name.index  % Add index entry when desired.
                    %
                  comma.before.last
                    %
                    % Add period if required.
                    %
                  dot
                    { et.al.string.period * }
                    { et.al.string * }
                  if$
                  write$
                }
              if$
            }
          if$
        }
      if$
    }
  if$
    %
    % End APACrefauthors environment.
  "\end{APACrefauthors}%"
  write$ newline$
}

%
% \begin{macro}{authors.reflist.apa6}
% Format authors for the reference list according to the rules of the
% 6th edition of the \emph{APA Manual}, i.e., if there are more than 7
% authors, list the first 6, then dots, and then the last.
% Call with
% \begin{verbatim}
%    dot  field  authors.reflist.apa6
% \end{verbatim}
% where \texttt{field} is the field (string) that contains the authors
% (or editors acting as authors) that must be formatted and \texttt{dot}
% is 1 or 0 indicating whether or not a period must end the formatting.
%    \begin{macrocode}
FUNCTION {authors.reflist.apa6}
{ 'field  :=
  'dot    :=
%    \end{macrocode}
% \texttt{numnames} is the total number of names in the \texttt{field}.
% \texttt{format.num.names} is the number of names to be formatted,
% which is \texttt{numnames} or 7, whichever is smaller
%    \begin{macrocode}
  field  num.names$  'numnames :=
  numnames  #7  >
    { #7        'format.num.names := }
    { numnames  'format.num.names := }
  if$
%    \end{macrocode}
% Enclose authors in \envirname{APACrefauthors} environment to allow crude
% style options in \LaTeX.
%    \begin{macrocode}
  "\begin{APACrefauthors}%"
  write$ newline$
%    \end{macrocode}
% Format first author.
%    \begin{macrocode}
  #1  'nameptr :=
  field  nameptr  format.author.name
  numnames  #1  =
%    \end{macrocode}
% Add period if required and if this is the only author, and add index
% entry when desired.
%    \begin{macrocode}
    { dot
        { add.period$ }
        'skip$
      if$
      add.name.index
    }
    { add.name.index
      numnames  #2  =
%    \end{macrocode}
% Optional comma between two authors; format second author and store in
% \texttt{s}.
%    \begin{macrocode}
        { comma.between.two write$
          #2  'nameptr :=
          field  nameptr  format.author.name  's :=
          s "others" =
%    \end{macrocode}
% Second author is explicit ``|others|''. Therefore, insert
% ``et al.'' string. Note that this does not correspond with the
% 6th edition of the \emph{APA manual}, so give a warning here,
% but after that format the authors as in the 5th edition:
% ``First, et al.''. Add a period if required.
%    \begin{macrocode}
            { "`others' not consistent with 6th ed. of the APA Manual"
              warning$
              dot
                { et.al.string.period }
                { et.al.string }
              if$
              write$ newline$
            }
%    \end{macrocode}
% There really are two authors: ``First, \& Second'', with a period
% after the latter if required.
%    \begin{macrocode}
            { and.before.last write$
              dot
                { s add.period$ }
                { s }
              if$
              add.name.index
            }
          if$
        }
%    \end{macrocode}
% Three or more authors, Format all the ones that need to be formatted,
% except the last one, which needs special treatment.
%    \begin{macrocode}
        { %% for nameptr := 2  to  format.num.names - 1  do
          #2  'nameptr  :=
            { nameptr  format.num.names  < }
%    \end{macrocode}
% Put comma between consecutive authors and format and add the next
% author and the optional index entry, and increase the loop variable.
%    \begin{macrocode}
            { comma.between.names write$
              field  nameptr  format.author.name
              add.name.index
              nameptr  #1  +  'nameptr :=
            }
          while$
%    \end{macrocode}
% Format the last author. If all authors are formatted, add an
% ampersand; otherwise, add dots (new in 6th ed.).
%    \begin{macrocode}
          field  numnames  format.author.name  's :=
          format.num.names  numnames  =
            { comma.before.last write$
%    \end{macrocode}
% Check if this author is an explicit ``|others|''. If so, insert
% ``et al.'' string. Note that this does not correspond with the
% 6th edition of the \emph{APA manual}, so give a warning here. Add
% a period if required.
%    \begin{macrocode}
              s "others" =
                { "`others' not consistent with 6th ed. of the APA "
                  "Manual" *
                  warning$
                  dot
                    { et.al.string.period }
                    { et.al.string }
                  if$
                  write$
                }
                { and.before.last  write$
                  dot
                    { s add.period$ }
                    { s }
                  if$
                  add.name.index
                }
              if$
            }
%    \end{macrocode}
% We skipped some authors. Indicate by dots.
%    \begin{macrocode}
            { dots.before.last write$
              s
              add.name.index
            }
          if$
        }
      if$
    }
  if$
%    \end{macrocode}
% End \envirname{APACrefauthors} environment.
%    \begin{macrocode}
  "\end{APACrefauthors}%"
  write$ newline$
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{format.author.names}
% Format authors (or editors acting as authors) for the reference list.
% Call with
% \begin{verbatim}
%    dot  field  format.author.names
% \end{verbatim}
% where \texttt{field} is the field (string) that contains the authors
% (or editors acting as authors) that must be formatted and \texttt{dot}
% is 1 or 0 indicating whether or not a period must end the formatting.
%    \begin{macrocode}
FUNCTION {format.author.names}
{ 'field  :=
  'dot    :=
%    \end{macrocode}
% This is a temporary trick, which needs to be cleaned up. We
% now check whether |dot| is 1, which indicates it's an author
% field. If it's not, it's an editor field. In the former case,
% if there are more than 7 authors, the first 6 plus dots plus
% the last author must be given, whereas in the latter case,
% only the first and ``et al.'' needs to be given. The latter
% is the same behavior as in the 5th edition, so we use that
% function, whereas we use an adapted function for authors in
% the 6th edition.
%    \begin{macrocode}
  dot
    { dot  field  authors.reflist.apa6 }
    { dot  field  authors.editors.reflist.apa5 }
  if$
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Format authors in reference list, where it is given that
% the author field is not empty.

FUNCTION {format.authors}
{ #1 author format.author.names }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Format editors in reference list in case editors act as
% authors (such as reference to entire edited book)
%
% Letheridge, S., \& Cannon, C. R. (Eds.).
%     or
% Letheridge, S. (Ed.).    (if only 1 editor)
%
% editor must not be empty

FUNCTION {format.editors.as.authors}
{ #0  editor  format.author.names
  "\ " editor.postfix * add.period$ write$ newline$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Format editors in reference list in case editors are also
% translators and act as authors (such as reference to entire
% edited book of translated articles)
%
% Letheridge, S., \& Cannon, C. R. (Eds. and Trans.).
%     or
% Letheridge, S. (Ed. and Trans.).    (if only 1 editor)
%
% editor must not be empty

FUNCTION {format.ed.trans.as.authors}
{ #0  editor  format.author.names
  "\ " editor.trans.postfix * add.period$ write$ newline$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Format a list of names with the initials before the
% last names (i.e., names in the editor position),
% commas between names (not between 2),
% and ampersand (\&) before last name.
% These names are not put in the author index.
%
% Call with
%     field format.editor.names

FUNCTION {format.editor.names}
{ 'field  :=
    %
  field  num.names$  'numnames :=   % numnames is the total number of names
                                    %   contained in field
  numnames  'format.num.names  :=   % Format all authors
  format.num.names   name.max  >    % Unless this exceeds the maximum of 6.
    { #1 'format.num.names := }     % Then it becomes 1 (First et al.)
    'skip$
  if$
    %
    % Format first editor
    %
  field  #1  format.editor.name
    %
  numnames  #1  =
    'skip$
    { format.num.names  #1  =
        { et.al.string * } % First editor et al., no comma.
        { numnames  #2  =
            {   %
                % Given that  format.num.names > 1, it is 2.
                % No comma. Format second editor.
                %
              field  #2  format.editor.name  's :=
                %
                % Check if 2nd editor is explicit "others".
                % If so, insert "et al." string.
                %
              s "others" =
                { et.al.string  * }          % First et al.
                { and.before.last  *  s * }  % First \& Second
              if$
            }
            {   %
                % 3 or more names, 2 or more must be cited
                %
                % for nameptr := 2  to  format.num.names - 1  do
                %
              #2  'nameptr  :=
                { nameptr  format.num.names  < }
                {   %
                    % Put comma between consecutive editors
                    %
                  comma.between.names  *
                    %
                    % Format and add next editor
                    %
                  field  nameptr  format.editor.name  *
                    %
                    % Move to next editor
                    %
                  nameptr  #1  +  'nameptr :=
                }
              while$
                %
                % nameptr  =  format.num.names
                % Format this editor.
                %
              field  nameptr  format.editor.name  's :=
                %
              format.num.names  numnames  =
                {   %
                    % This is also the last editor. Add (optional) comma.
                    %
                  comma.before.last  *
                    %
                    % Check if this editor is explicit "others".
                    % If so, insert "et al." string.
                    %
                  s "others" =
                    { et.al.string     *     }
                    { and.before.last  * s * }
                  if$
                }
                {   %
                    % This is not the last editor.
                    % Add comma, editor name, and "et al."
                    %
                  comma.between.names  * s *
                  comma.before.last    * et.al.string  *
                }
              if$
            }
          if$
        }
      if$
    }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format editors in case editors do not act as authors
    % (such as reference to chapter in edited book)
    %
    % L. W. Poon (Ed.)                         (1 editor)
    %    or
    % A. S. Gurman \& D. P. Kniskern (Eds.)    (2 editors)
    %    or
    % L. Poon, A. Jones, \& D. P. Smith (Eds.) (>2 editors)
    %
    % editor must not be empty
    %
FUNCTION {format.editors.in.line}
{ editor           format.editor.names
  editor.postfix   connect.with.space.check
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format editors in case editors are also translators
    % and do not act as authors
    % (such as reference to chapter in edited book
    %  of translated articles)
    %
    % L. W. Poon (Ed. and Trans.)                         (1 editor)
    %    or
    % A. S. Gurman \& D. P. Kniskern (Eds. and Trans.)    (2 editors)
    %    or
    % L. Poon, A. Jones, \& D. P. Smith (Eds. and Trans.) (>2 editors)
    %
    % editor must not be empty
    %
FUNCTION {format.editors.trans.in.line}
{ editor                 format.editor.names
  editor.trans.postfix   connect.with.space.check
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format translators in case translators act as editors
    % (such as reference to chapter in translated book)
    %
    % L. W. Poon (Trans.)                         (1 translator)
    %    or
    % A. S. Gurman \& D. P. Kniskern (Trans.)    (2 translators)
    %    or
    % L. Poon, A. Jones, \& D. P. Smith (Trans.) (>2 translators)
    %
    % translator must not be empty
    %
FUNCTION {format.translators.in.line}
{ translator      format.editor.names
  trans.postfix   connect.with.space.check
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format translators in case translator does not act as editor
    % (such as reference to translated book)
    %
    % L. Solotaroff, Trans.
    %
FUNCTION {format.translators.in.paren.check}
{ translator empty$
    { "" }
    { translator format.editor.names
      translator num.names$ #1 >
        { ", \BTRANSS{}" * }
        { ", \BTRANS{}" * }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format editors and translators in case neither act as editor
    % (such as reference to edited or translated book with a
    % a single author)
    %
    % L. Solotaroff, Ed.
    % L. Solotaroff, Ed. \& Trans.
    % L. Solotaroff, Trans.
    % L. Solotaroff, Ed. \& S. Prokofieff, Trans.
    %
FUNCTION {format.editors.translators.in.paren.check}
{ editor empty$
    { translator empty$
        { "" }
        { translator format.editor.names
          translator num.names$ #1 >
            { ", \BTRANSS{}" * }
            { ", \BTRANS{}" * }
          if$
        }
      if$
    }
    { editor format.editor.names
      editor num.names$ #1 >
        { ", \BEDS{}" * }
        { ", \BED{}" * }
      if$
      translator empty$
        'skip$
        { editor translator =
            { editor num.names$ #1 >
                { " \BAnd{} \BTRANSS" * }
                { " \BAnd{} \BTRANS" * }
              if$
            }
            { " \BAnd{} " *
              translator format.editor.names *
              translator num.names$ #1 >
                { ", \BTRANSS{}" * }
                { ", \BTRANS{}" * }
              if$
            }
          if$
        }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % translator of article
    %
FUNCTION {format.atrans.check}
{ format.translators.in.paren.check   parenthesize.check }




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format "In editor (Ed.), "
    %
FUNCTION {format.in.editors}
{ "\BIn{} "
  editor empty$
    'skip$
    { format.editors.in.line * ", " * }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format "In translator (Trans.),"
    %
FUNCTION {format.in.trans}
{ "\BIn{} "
  translator empty$
    'skip$
    { format.translators.in.line * ", " * }
  if$
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format "In editor (Ed. and Trans.)"
    %  or "In editor (Ed.)" if editor not equal to translator
    %
FUNCTION {format.in.editors.trans}
{ "\BIn{} "
  editor empty$
    { translator empty$
        'skip$
        { format.translators.in.line * ", " * }
      if$
    }
    { translator empty$
        { format.editors.in.line * }
        { editor translator =
            { format.editors.trans.in.line * }
            { format.editors.in.line * }
          if$
        }
      if$
      ", " *
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                            DATE                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Formats year (+ extra label) between parentheses (which
% may be redefined by \BBOP and \BBCP).
% Extra label can be used for
% Bentler, P. M. (1983a) <article 1>
% Bentler, P. M. (1983b) <article 2>

FUNCTION {format.year.check}
{ "\APACrefYear{"
  protect.year *
    %
    % Add "a", "b", etc. when necessary.
    %
  make.definitive.year.supplement *
  "}" *
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Formats year (+ extra label)  + month + day between
% parentheses (which may be redefined by \BBOP and \BBCP).
% Extra label can be used for
% Bentler, P. M. (1983a, June 7)  <article 1>
% Bentler, P. M. (1983b, April 4) <article 2>

FUNCTION {format.year.month.day.check}
{ "\APACrefYearMonthDay{"
  protect.year *
    %
    % Add "a", "b", etc. when necessary.
    %
  make.definitive.year.supplement *
  "}{" *
    %
    % Add month and day when present.
    %
  month empty$
    'skip$
    { month * }
  if$
  "}{" *
  day empty$
    'skip$
    { day * }
  if$
  "}" *
}

%    \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Title formatting}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \begin{macro}{format.atitle.no.dot}
% Title of article in journal or book, without finishing period.
% The field must be on top of stack (so \fieldname{englishtitle} can
% be handled as well).
%    \begin{macrocode}
FUNCTION {format.atitle.no.dot}
{ "{\BBOQ}" swap$
  "{\BBCQ}" swap$
  duplicate$ empty$
    'skip$
    { duplicate$
      % Two arguments: Title twice: (1) don't change case; (2) change case
      "\APACrefatitle {" swap$ * "} {" * swap$
      "t" change.case$
      * "}" *
    }
  if$
  enclose.check
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{format.atitle.dot}
% Title of article in journal or book, with finishing period.
% The field must be on top of stack (so \fieldname{englishtitle} can
% be handled as well).
%    \begin{macrocode}
FUNCTION {format.atitle.dot}
{ "{\BBOQ}" swap$
  "{\BBCQ}" swap$
  duplicate$ empty$
    'skip$
    { duplicate$
      % Two arguments: Title twice: (1) don't change case; (2) change case
      "\APACrefatitle {" swap$ * "} {" * swap$
      "t" change.case$
      * "}" * add.period$
    }
  if$
  enclose.check
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{format.atitle.connect}
% Title of article in journal or book. The field must be on top of stack.
% The second element on stack must be connected: if that is empty, then
% |format.atitle.dot|, else |format.atitle.no.dot|, connect, and add a
% period.
%    \begin{macrocode}
FUNCTION {format.atitle.connect}
{ swap$
  duplicate$ empty$
    { pop$
      format.atitle.dot
    }
    { swap$
      format.atitle.no.dot
      swap$ connect.with.space.check
      add.period$
    }
  if$
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{format.btitle.no.dot}
% Title of a book or so, without period. Call with
% \begin{verbatim}
%   field  format.btitle.no.dot
% \end{verbatim}
%    \begin{macrocode}
FUNCTION {format.btitle.no.dot}
{ duplicate$ empty$
    { pop$
      ""
    }
    { duplicate$
      % Two arguments: Title twice: (1) don't change case; (2) change case
      "\APACrefbtitle {" swap$ * "} {" * swap$
      "t" change.case$
      * "}" *
    }
  if$
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{format.btitle.dot}
% Title of book or so, with period. Call with
% \begin{verbatim}
%   field  format.btitle.dot
% \end{verbatim}
%    \begin{macrocode}
FUNCTION {format.btitle.dot}
{ duplicate$ empty$
    { pop$
      ""
    }
    { add.period$ format.btitle.no.dot }
  if$
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % title of book and similar
    % field must be on top of stack
    % second element on stack must be connected:
    %   if that is empty, then btitle.dot
    %   else btitle.no.dot, connect, and add period
    %
FUNCTION {format.btitle.connect}
{ swap$
  duplicate$ empty$
    { pop$
      format.btitle.dot
    }
    { swap$
      format.btitle.no.dot
      swap$   connect.with.space.check
      add.period$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % title of book and similar
    % field must be on top of stack
    % second element on stack must be connected
    %
FUNCTION {format.btitle.connect.no.dot}
{ swap$
  duplicate$ empty$
    { pop$
      format.btitle.no.dot
    }
    { swap$
      format.btitle.no.dot
      swap$   connect.with.space.check
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format englishtitle (of nonenglish article, etc.)
    %
FUNCTION {format.aetitle.check}
{ englishtitle empty$
    { "" }
    { % Two arguments: Title twice: (1) don't change case; (2) change case
      "\APACrefaetitle {" englishtitle * "} {" *
                         englishtitle "t" change.case$ * "}" *
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format englishtitle (of nonenglish book, etc.)
    %
FUNCTION {format.betitle.check}
{ englishtitle empty$
    { "" }
    { % Two arguments: Title twice: (1) don't change case; (2) change case
      "\APACrefbetitle {" englishtitle * "} {" *
                         englishtitle "t" change.case$ * "}" *
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format type (of article, etc.)
    %
FUNCTION {format.atype.check}
{ type bracket.check }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format title and englishtitle (of article, etc.)
    %
FUNCTION {format.atitle.check}
{ format.aetitle.check
  title format.atitle.connect
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format title, englishtitle, and type
    % (of article, etc.)
    %
FUNCTION {format.atitle.type.check}
{ format.aetitle.check
  format.atype.check   connect.with.space.check
  title format.atitle.connect
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format title, englishtitle,
    % and translator (of article, etc.)
    %
FUNCTION {format.atitle.trans.check}
{ format.aetitle.check
  format.atrans.check  connect.with.space.check
  title format.atitle.connect
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format title, englishtitle, type,
    % and translator (of article, etc.)
    %
FUNCTION {format.atitle.type.trans.check}
{ format.aetitle.check
  format.atype.check   connect.with.space.check
  format.atrans.check  connect.with.space.check
  title format.atitle.connect
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                    JOURNAL FORMATTING                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format journal, volume, number and pages
    % call with
    %   formatted.pages format.journal.vol.num.pages.check
    %
FUNCTION { format.journal.vol.num.pages.check }
{ "journal" journal warning.if.empty
  duplicate$ empty$
  journal    empty$ and
  volume     empty$ and
  number     empty$ and
    { pop$ "" }
    { "\APACjournalVolNumPages{" journal "" connect.check
      "}{" *                     volume  "" connect.check
      "}{" *                     number  "" connect.check
      "}{" *                     swap$   "" connect.check
      "}"  *
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%    BOOK VOLUME, EDITION, AND OTHER SUPPLEMENTARY INFO     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % volume of book, checks whether
    % "Volume" or "Volumes"
    %
    % call with
    %   field format.bvolume.check
    %
FUNCTION {format.bvolume.check}
{ duplicate$ empty$
    'skip$
    { duplicate$ multi.result.check
        { "\BVOLS" swap$ tie.or.space.connect }
        { "\BVOL"  swap$ tie.or.space.connect }
      if$
    }
  if$
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % edition of book, must not be empty
    % call with
    %   field format.edition.check
    %
FUNCTION {format.edition.check}
{ duplicate$ empty$
    'skip$
    { "\PrintOrdinal{" swap$ * "}" *
      "\BEd" connect.with.space.check
    }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % volume and edition of book
    %
FUNCTION {format.bvol.edition.check}
{ edition format.edition.check
  volume  format.bvolume.check
  connect.with.comma.check
}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % volume and edition of book
    %
FUNCTION {format.bvol.edition}
{ format.bvol.edition.check
  parenthesize.check
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % volume and edition and translator of translated book
    %
FUNCTION {format.bvol.edition.trans}
{ format.bvol.edition.check
  format.translators.in.paren.check connect.with.semicolon.check
  parenthesize.check
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % volume, edition, editor, and translator of (translated) book
    %
FUNCTION {format.bvol.edition.editor.trans}
{ format.bvol.edition.check
  format.editors.translators.in.paren.check connect.with.semicolon.check
  parenthesize.check
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % formats pages by first checking if 1 or more pages
    % and prefixing pages with "p." or "pp." (these strings
    % are given in the commands \BPG and \BPGS, respectively),
    % whichever is applicable, and do a tie or space connect
    %
    % call with
    %   field format.bpages.check
    %
FUNCTION {format.bpages.check}
{ duplicate$ empty$
    'skip$
    { duplicate$ multi.result.check
        { "\BPGS" swap$ tie.or.space.connect }
        { "\BPG~" swap$ * }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % formats chapters by first checking if 1 or more chapters
    % and prefixing pages with "chap." (this string
    % is given in the commands \BCHAP and \BCHAPS, respectively),
    % whichever is applicable, and do a tie or space connect
    %
    % call with
    %   field format.bchapter.check
    %
FUNCTION {format.bchapter.check}
{ duplicate$ empty$
    'skip$
    { duplicate$ multi.result.check
        { "\BCHAPS" swap$ tie.or.space.connect }
        { "\BCHAP"  swap$ tie.or.space.connect }
      if$
    }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % volume, edition, and pages or chapter of article in book etc.
    %
FUNCTION {format.bvol.edition.pages}
{ format.bvol.edition.check
  pages empty$
    { chapter format.bchapter.check  connect.with.comma.check }
    { pages   format.bpages.check    connect.with.comma.check }
  if$
  parenthesize.check
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % title, volume, edition of book
    %
FUNCTION {format.btitle.vol.edition}
{ format.betitle.check
  format.bvol.edition  connect.with.space.check
  title  format.btitle.connect.no.dot
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % title, volume, edition, and translator of book
    %
FUNCTION {format.btitle.vol.edition.trans}
{ format.betitle.check
  format.bvol.edition.trans  connect.with.space.check
  title  format.btitle.connect.no.dot
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % title, volume, edition, editor, and translator of book
    %
FUNCTION {format.btitle.vol.edition.editor.trans}
{ format.betitle.check
  format.bvol.edition.editor.trans  connect.with.space.check
  title  format.btitle.connect.no.dot
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                 ADDRESS AND PUBLISHER                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format address and publisher of book etc.
    %
    % New York: Wiley
    %      or
    % Wiley      (if address empty)
    %      or
    % New York   (if publisher empty)
    %
FUNCTION {format.address.publisher}
{   %
    % If publisher = author or publisher = "author" or publisher = "Author"
    % then hand over the final choice how to format this to \LaTeX.
    % (I could imagine similar code for editors, but the APA manual does
    % not mention it and then we'd have to check whether the editor is in
    % the author position, so let's keep it simple until someone complains.)
    %
  author empty$
  publisher empty$ or
    { publisher "\APACaddressPublisher{" }
    { author   publisher =
      "author" publisher =  or
      "Author" publisher =  or
        { author    "\APACaddressPublisherEqAuth{" }
        { publisher "\APACaddressPublisher{"       }
      if$
    }
  if$
  address "" connect.check  "}{" *
    % Recover publisher that was pushed onto the stack previously.
  swap$   "" connect.check  "}"  *
}

%    \end{macrocode}
%
% \begin{macro}{format.address.publisher.check}
% Format \fieldname{address} and \fieldname{publisher} of a book etc.:
% ``New York, NY: Wiley'' or ``Wiley'' (if \fieldname{address} is empty)
% or ``New York, NY'' (if \fieldname{publisher} is empty), or do nothing
% if both are empty.
%    \begin{macrocode}
FUNCTION {format.address.publisher.check}
{ publisher empty$
  address   empty$
  and
    'skip$
    {
%    \end{macrocode}
% Clear the stack.
%    \begin{macrocode}
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.address.publisher
    }
  if$
}

%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%            TYPE AND NUMBER OF A REPORT                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format number as in reports: No. 2017
    % call with
    %   field format.rnumber.check
    %
FUNCTION {format.rnumber.check}
{ duplicate$ empty$
    'skip$
    { duplicate$ multi.result.check
        { "\BNUMS" swap$ tie.or.space.connect }
        { "\BNUM"  swap$ tie.or.space.connect }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format type and number of a standalone item
    % call with
    %   format.type.number
    %
FUNCTION { format.type.number }
{ type empty$
    { type.2 }
    { type   }
  if$
  number empty$
    { bracket.check }
    { number format.rnumber.check connect.with.space.check
      parenthesize.check
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     HOWPUBLISHED                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format howpublished if not empty,
    % for various entry types
    % call with
    %   format.howpublished
    %
FUNCTION {format.howpublished}
{ howpublished empty$
    'skip$
    { % clear the stack
      duplicate$ empty$
        'pop$
        { output.dot.new.block }
      if$
      "\APAChowpublished {" howpublished * "}" *
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format howpublished if not empty,
    % for misc
    % call with
    %   output.howpublished
    %
FUNCTION {output.howpublished}
{ howpublished empty$
    'skip$
    { "\APAChowpublished {" howpublished * "}" *
      output.dot.new.block
    }
  if$
}

%    \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{URL formatting functions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \begin{macro}{begin.end.url.env}
% Begin and end of a URL environment.
%    \begin{macrocode}
FUNCTION {begin.end.url.env}
{ "\begin{APACrefURL} "
%    \end{macrocode}
% For ``Retrieved $\langle$\textit{date}$\rangle$, from''
%    \begin{macrocode}
  lastchecked empty$
    { urldate empty$
        'skip$
        { "[{" * urldate * "}]" * }
      if$
    }
    { "[{" * lastchecked * "}]" * }
  if$
  " \end{APACrefURL} "
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{begin.end.doi.env}
% Begin and end of a DOI environment.
%    \begin{macrocode}
FUNCTION {begin.end.doi.env}
{ "\begin{APACrefDOI} "
  " \end{APACrefDOI} "
}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{begin.end.msg.env}
% Begin and end of a message environment.
%    \begin{macrocode}
FUNCTION {begin.end.msg.env}
{ "\begin{APACrefURLmsg} "
  " \end{APACrefURLmsg} "
}

%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format url given that it is not empty,
    % for various entry types
    % call with
    %   format.url
    %
FUNCTION {format.url}
{ % First format begin and end of the enclosing environment.
  % With posted messages, a different environment is used.
  type.2 empty$
    { begin.end.url.env }
    { type.2 "\bibmessage" =
        { begin.end.msg.env }
        { begin.end.url.env }
      if$
    }
  if$
    % The url string.
  "\url{" url * "}" *
    % Enclose in begin and end environment
  enclose.check
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format doi given that it is not empty,
    % for various entry types
    % call with
    %   format.doi
    %
FUNCTION {format.doi}
{ % First format begin and end of the enclosing environment.
  begin.end.doi.env
    % The doi string.
  "\doi{" doi * "}" *
    % Enclose in begin and end environment
  enclose.check
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%              NOTE FORMATTING FUNCTIONS                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format optional note
    %
FUNCTION {format.note}
{ "\APACrefnote{"  "}"  note  enclose.check }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format original year of publication and note
    % (reprint or translation)
    %
FUNCTION {format.orig.year.note}
{ originalyear empty$
    { format.note }
    { "\APACorigyearnote{"
      originalyear    "" connect.check "}{" *
      note            "" connect.check "}"  *
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format original journal of publication and note
    % (reprint or translation)
    %
FUNCTION {format.orig.journal.note}
{ "\APACorigjournalnote{"
  originalyear    "" connect.check "}{" *
  originaljournal "" connect.check "}{" *
  originalvolume  "" connect.check "}{" *
  originalnumber  "" connect.check "}{" *
  originalpages   "" connect.check "}{" *
  note            "" connect.check "}"  *
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format original book of publication and note
    % (reprint or translation)
    %
FUNCTION {format.orig.book.note}
{ "\APACorigbooknote{" originalyear  ""  connect.check "}{" *
    %
  originaleditor empty$
    'skip$
    { originaleditor num.names$ #1 >
        { "\APACorigEDS {" * originaleditor format.editor.names * "}" * }
        { "\APACorigED {"  * originaleditor format.editor.names * "}" * }
      if$
    }
  if$
    %
  "}{" *
  originalbooktitle format.btitle.no.dot "" connect.check "} {" *
  originaledition   format.edition.check "" connect.check "} {" *
  originalvolume    format.bvolume.check "" connect.check "} {" *
  originalpages     format.bpages.check  "" connect.check "} {" *
  originaladdress   "" connect.check "} {" *
  originalpublisher "" connect.check "} {" *
  note              "" connect.check "}"  *
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format information about original publication of reprint
    % and format optional note
    %
FUNCTION {format.orig.note}
{ originaljournal empty$
    { originalbooktitle empty$
        { note empty$
            { originalyear empty$
                'skip$
                { originalyear "\bibnodate" =
                  originalyear "l" change.case$ "no date" = or
                  originalyear "l" change.case$ "n.d."    = or
                    'skip$
                    { output.new.block
                      format.orig.year.note
                    }
                  if$
                }
              if$
            }
            { output.new.block
              format.orig.year.note
            }
          if$
        }
        { output.new.block
          format.orig.book.note
        }
      if$
    }
    { output.new.block
      format.orig.journal.note
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % finish current entry
    % by writing what's left on the stack and starting a new line
    %
FUNCTION {fin.entry}
{ doi empty$
    { output.end.block }
    { output.new.block
      format.doi
      output.end.block
    }
  if$
  "\PrintBackRefs{\CurrentBib}" write$ newline$
  test
    { "\vspace{\baselineskip}" write$ newline$ }
    'skip$
  if$
%<*annotated>
    %
    % According to TLC2, pp. 810-811, both annote and annotate fields are
    % known, so support them both, but do not print them both, in case
    % someone wants to make a file that is compatible with both the annotate
    % and annotation styles and thus duplicates the information. Instead, we
    % give annote priority.
    %
  annote empty$
    {% Try annotate
      annotate empty$
        'skip$
        { % add annotation
          "\begin{APACrefannotation}" write$ newline$
          annotate write$ newline$
          "\end{APACrefannotation}" write$ newline$
        }
      if$
    }
    { % add annotation
      "\begin{APACrefannotation}" write$ newline$
      annote write$ newline$
      "\end{APACrefannotation}" write$ newline$
    }
  if$
%</annotated>
}
%    \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Top-level and near-top level functions for formatting complete
% entries}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Article in periodical: \entryname{journal}, \entryname{magazine},
% \entryname{newspaper}. Call with
% \begin{verbatim}
%   formatted.pages  formatted.date   periodical
% \end{verbatim}
%    \begin{macrocode}
FUNCTION {periodical}
{
%    \end{macrocode}
% \fieldname{author} or \fieldname{editor}, \fieldname{year},
% \fieldname{title}, \fieldname{englishtitle}, \fieldname{type}.
%    \begin{macrocode}
  author empty$
        %
        % no author: possibly special issue with editors as authors
        % (APA manual, ex. 11, p. 121)
        %
    { editor empty$
            %
            % no author or editor: title serves as author.
            % title formatted as article title (APA manual not consistent in this,
            % compare statement on p. 119: ``treat as book title'' and
            % example 8, p. 121: no underlining => article title)
            %
        { format.atitle.type.trans.check output.new.block
            %
            % now formatted date on top of stack
            %
          output.dot.new.block
        }
            %
            % format editor and year, and check if year is present
            % format article title and check if title or type present
            %
        { format.editors.as.authors   start.new.block
            %
            % now formatted date on top of stack
            %
          output.dot.new.block
          format.atitle.type.trans.check output.new.block
        }
      if$
    }
        %
        % format author and year, and check if year is present
        % format article title and check if title or type present
        %
    { format.authors   start.new.block
            %
            % now formatted date on top of stack
            %
      output.dot.new.block
      format.atitle.type.trans.check output.new.block
    }
  if$
    %
    % format journal name, volume and issue number, and pages
    %   and check if journal not empty
    %
  format.journal.vol.num.pages.check
    %
    % if not empty, insert howpublished.
    % (used if article is retrieved from the internet)
    %
  format.howpublished  add.period$
      %
      % format url
      %
  url empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.url
    }
  if$
    %
    % possible reprint and optional note
    %
  format.orig.note
  fin.entry
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % journal article
    %
FUNCTION {article}
{ pages  format.year.month.day.check  periodical }



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % magazine article
    %
FUNCTION {magazine}
{ pages  format.year.month.day.check  periodical }



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % newspaper article
    %
FUNCTION {newspaper}
{ pages  format.bpages.check  format.year.month.day.check  periodical }



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % (translation of) entire book
    %
FUNCTION {book}
{     %
      % author or editor,
      % year, title, englishtitle, translator
      %
  author empty$
        %
        % no author: possibly edited book with editors as authors
        %
    { editor empty$
            %
            % no author or editor: title serves as author.
            % title formatted as book title
            %
        { format.btitle.vol.edition.trans
          format.type.number               connect.with.space.check
          output.dot.new.block
          format.year.check                add.period$
        }
            %
            % format editor and year, and check if year is present
            % format booktitle, volume, and edition and check if title present
            %
        { translator empty$
            { format.editors.as.authors  start.new.block
              format.year.check          output.dot.new.block
              format.btitle.vol.edition
            }
                %
                % format translator correctly
                %
            { translator editor =
              not
                { format.editors.as.authors        start.new.block
                  format.year.check                output.dot.new.block
                  format.btitle.vol.edition.trans
                }
                { format.ed.trans.as.authors  start.new.block
                  format.year.check           output.dot.new.block
                  format.btitle.vol.edition
                }
              if$
            }
          if$
          format.type.number     connect.with.space.check
          add.period$
        }
      if$
    }
        %
        % format author and year, and check if year is present
        % format booktitle, volume, and edition and check if title present
        %
    { format.authors                          start.new.block
      format.year.check                       output.dot.new.block
      format.btitle.vol.edition.editor.trans
      format.type.number                      connect.with.space.check
      add.period$
    }
  if$
      %
      % format address and publisher
      %
  format.address.publisher.check
      %
      % if not empty, insert howpublished.
      % (used if book is retrieved from the internet)
      %
  format.howpublished  add.period$
      %
      % format url
      %
  url empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.url
    }
  if$
      %
      % format original publication (of reprint/translation)
      % and optional note
      %
  format.orig.note
  fin.entry
}
%
%    \end{macrocode}
% Article or chapter in edited book.
%    \begin{macrocode}
FUNCTION {incollection}
{ author empty$
%    \end{macrocode}
% No \fieldname{author}: \fieldname{title} serves as author. The title is
% formatted as an article title.
%    \begin{macrocode}
    { editor.ne.trans
        { format.atitle.type.trans.check }
        { format.atitle.type.check }
      if$
      output.new.block
%    \end{macrocode}
% Format \fieldname{month} and \fieldname{day} as well when available,
% esp.\ for ``collections'' that are not books, such as parts of internet
% documents.
%    \begin{macrocode}
      format.year.month.day.check   add.period$
    }
%    \end{macrocode}
% Format \fieldname{author} and \fieldname{year}, and check whether
% \fieldname{year} is present. Format article title and check whether
% \fieldname{title} or \fieldname{type} are present.
%    \begin{macrocode}
    { format.authors                start.new.block
      format.year.month.day.check   output.dot.new.block
      editor.ne.trans
        { format.atitle.type.trans.check }
        { format.atitle.type.check }
      if$
    }
  if$
%    \end{macrocode}
% Format ``In '' \fieldname{editor} `` (Ed.\ \& Trans.), ''
% \fieldname{booktitle}, \fieldname{volume}, \fieldname{edition},
% \fieldname{pages}. Leave empty if all these fields are missing.
%    \begin{macrocode}
  editor     empty$
  translator empty$ and
  edition    empty$ and
  volume     empty$ and
  pages      empty$ and
  chapter    empty$ and
  booktitle  empty$ and
    'skip$
    {
      output.new.block
      format.in.editors.trans
      format.bvol.edition.pages
      booktitle  format.btitle.connect * add.period$
    }
  if$
%    \end{macrocode}
% Format \fieldname{address} and \fieldname{publisher}.
%    \begin{macrocode}
  format.address.publisher.check
%    \end{macrocode}
% If not empty, insert \fieldname{howpublished}.
%    \begin{macrocode}
  format.howpublished  add.period$
%    \end{macrocode}
% Format \fieldname{url}.
%    \begin{macrocode}
  url empty$
    'skip$
    {
%    \end{macrocode}
% Clear the stack.
%    \begin{macrocode}
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.url
    }
  if$
%    \end{macrocode}
% Format original publication (of reprint/translation) and optional note.
%    \begin{macrocode}
  format.orig.note
  fin.entry
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                       REPORTS                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % technical report number
    %
FUNCTION {format.tr.number}
{ type empty$
    { "\BTR{}" }
    { type "\bibnotype" =
        { ""   }
        { type }
      if$
    }
  if$
  number format.rnumber.check   connect.with.space.check
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % title, volume, edition, report number
    %
FUNCTION {format.tr.title.number}
{ format.betitle.check
    % Single out the situation in which there is no number
    % and type = {\bibnotype}, i.e., no type as well.
    % (Why not use book then?)
  type empty$
    { % Now, we're in the regular situation with at least a
      % number, a type, a volume, or an edition.
      "\APACbVolEdTR{" format.bvol.edition.check * "}{" *
      format.tr.number *  "}" *
    }
    { type "\bibnotype" =
        number empty$
          volume empty$
            edition empty$
            and
          and
        and
        { "" }
        { % Now, we're in the regular situation with at least a
          % number, a type, a volume, or an edition.
          "\APACbVolEdTR {" format.bvol.edition.check * "}{" *
          format.tr.number *  "}" *
        }
      if$
    }
  if$
  connect.with.space.check
  title  format.btitle.connect
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % format address and institution of reports etc.
    %
    % Washington, DC: National Institute of Education
    %      or
    % National Institute of Education (if address empty)
    %
    % warning if no institution
    %
FUNCTION {format.address.institution.check}
{ "institution" institution warning.if.empty
  "address"     address     warning.if.empty
  institution empty$
  address     empty$
  and
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
        %
        % If institution = author or institution = "author"
        % or institution = "Author" then hand over the final choice how to
        % format this to \LaTeX. See also format.address.publisher
        %
      author empty$
      institution empty$ or
        { institution "\APACaddressInstitution{" }
        { author   institution =
          "author" institution =  or
          "Author" institution =  or
            { author      "\APACaddressInstitutionEqAuth{" }
            { institution "\APACaddressInstitution{"       }
          if$
        }
      if$
      address "" connect.check  "}{" *
        % Recover institution that was pushed onto the stack previously.
      swap$   "" connect.check  "}"  *
    }
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % reports
    %
FUNCTION {techreport}
{ author empty$
        %
        % no author: possibly edited report with editors as authors
        %
    { editor empty$
            %
            % no author or editor: title serves as author.
            % title formatted as book title
            %
        { format.tr.title.number      output.dot.new.block
          format.year.month.day.check add.period$
        }
            %
            % format editor and year, and check if year is present
            % format report title and check if title present
            % format volume, edition, type, and number
            %
        { format.editors.as.authors   start.new.block
          format.year.month.day.check output.dot.new.block
          format.tr.title.number      add.period$
        }
      if$
    }
        %
        % format author and year, and check if year is present
        % format report title and check if title present
        % format volume, edition, type, and number
        %
    { format.authors              start.new.block
      format.year.month.day.check output.dot.new.block
      format.tr.title.number      add.period$
    }
  if$
    %
    % format address and institution, check if institution present
    %
  format.address.institution.check
    %
    % if not empty, insert howpublished.
    % (used if report is retrieved from the internet)
    %
  format.howpublished add.period$
      %
      % format url
      %
  url empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.url
    }
  if$
    %
    % format optional note
    %
  note empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.note
    }
  if$
  fin.entry
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % (translated) article or chapter in report
    %
FUNCTION {intechreport}
{ author empty$
        %
        % no author: title serves as author.
        % title formatted as article title (APA manual not consistent in this,
        % compare statement on p. 119: ``treat as book title'' and
        % example 8, p. 121: no underlining => article title)
        %
    { editor.ne.trans
        { format.atitle.trans.check }
        { format.atitle.check }
      if$
      output.new.block
      format.year.month.day.check output.dot.new.block
    }
        %
        % format author and year, and check if year is present
        % format article title and check if title or type present
        %
    { format.authors                start.new.block
      format.year.month.day.check   output.dot.new.block
      editor.ne.trans
        { format.atitle.trans.check }
        { format.atitle.check }
      if$
      output.new.block
    }
  if$
      %
      % format "In " editor " (Ed. \& Trans.), "
      % booktitle, volume, edition, pages
      %
  format.in.editors.trans
      %
      % volume, edition, report type and number, pages
      %
  "\APACbVolEdTRpgs {" format.bvol.edition.check * "} {" *
  format.tr.number *
  "} {" * pages format.bpages.check *
  "}" *
      %
  booktitle format.btitle.connect *
  add.period$
      %
      % format address and publisher
      %
  format.address.institution.check
    %
    % if not empty, insert howpublished.
    % (used if report is retrieved from the internet)
    %
  format.howpublished add.period$
      %
      % format url
      %
  url empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.url
    }
  if$
      %
      % format original publication (of reprint/translation)
      % and optional note
      %
  format.orig.note
  fin.entry
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % papers presented at conferences etc.
    %
FUNCTION {lecture}
{ author empty$
    { "author" author warning.if.empty }
    { format.authors  start.new.block  }
  if$
      %
      % format year, month, and day, and check if year present
      % format title and check if title present
      % format howpublished and check if howpublished present
      %
  format.year.month.day.check output.dot.new.block
  symposium empty$
    { format.betitle.check
      title  format.btitle.connect  output.new.block
      howpublished empty$
        { "symposium and howpublished missing in " cite$ * warning$
          ""
        }
        { "\APAChowpublished {" howpublished * "}" * }
      if$
      address connect.with.comma.check
    }
    { format.atitle.type.check output.new.block
      "\BIn{} "
      chair empty$
        'skip$
        { chair  format.editor.names
          chair num.names$ #1 >
            { "(\BCHAIRS)" }
            { "(\BCHAIR)" }
          if$
          connect.with.space.check * ", " *
        }
      if$
      symposium format.btitle.no.dot *
      format.howpublished
      address connect.with.comma.check
    }
  if$
  add.period$
      %
      % format url
      %
  url empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.url
    }
  if$
      %
      % format optional note
      %
  note empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.note
    }
  if$
  fin.entry
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                        THESES                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % default thesis type is on top of stack
    % now, if type field is empty, this default is used
    % else default is removed and replaced by value of
    % type field
    %
FUNCTION {format.type.school}
{ type empty$
    'skip$
    { pop$
      type "t" change.case$
    }
  if$
  school connect.with.comma.check
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % phd theses, etc.
    % call with
    %   "default.published.thesis" "default.unpublished.thesis" thesis
    %
FUNCTION {thesis}
{ author empty$
    { "author" author warning.if.empty }
    { format.authors  start.new.block  }
  if$
      %
      % format year and check if year present
      %
  format.year.check output.dot.new.block
      %
      % format title and check if title present
      % journal empty => unpublished PhD thesis
      % journal not empty => published (e.g., Dissertation Abstracts Int.)
      %
  journal empty$
    { format.btitle.vol.edition output.dot.new.block
        %
        % pop default unpublished thesis, top is default published thesis
        %
      swap$ pop$
      format.type.school
      address   connect.with.comma.check
    }
        %
        % pop default published thesis, top is default unpublished thesis
        %
    { pop$
      type         empty$
      school       empty$ and
      originalyear empty$ and
        { pop$
          ""
        }
        { format.type.school
          originalyear   connect.with.comma.check
          parenthesize.check
        }
      if$
      format.aetitle.check
      swap$    connect.with.space.check
      "title"  title warning.if.empty
      title    format.atitle.connect   output.new.block
      pages    format.journal.vol.num.pages.check
    }
  if$
    %
    % if not empty, insert howpublished.
    % (used if thesis is retrieved from the internet)
    %
  format.howpublished add.period$
      %
      % format url
      %
  url empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.url
    }
  if$
      %
      % format optional note
      %
  note empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.note
    }
  if$
  fin.entry
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % phd theses, etc.
    %
FUNCTION {phdthesis}
{ "\BPhD"  "\BUPhD"  thesis }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % master's theses, etc.
    %
FUNCTION {mastersthesis}
{ "\BMTh"  "\BUMTh"  thesis }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                        OTHER                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % title of something (used in unpublished and misc)
    % english translation of title
    % type and number of something
    %
FUNCTION {format.btitle.type.num}
{ format.betitle.check
  format.bvol.edition  connect.with.space.check
  format.type.number
  connect.with.space.check
  title empty$
    { add.period$ }
    { title format.btitle.connect }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % title of message or software-related thing (used in misc)
    % english translation of title
    % type and number of something
    %
FUNCTION {format.mtitle.type.num}
{ format.aetitle.check
  format.bvol.edition  connect.with.space.check
  type.2 "\bibmessage" =
    { number empty$
        'skip$
        { type.2 number tie.or.space.connect
          bracket.check
          connect.with.space.check
        }
      if$
    }
    { format.type.number
      connect.with.space.check
    }
  if$
  title empty$
    { add.period$ }
    { title format.atitle.connect }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % title, english translation of title,
    % type and number of something (used in misc)
    %
FUNCTION {output.misctitle.type.num}
{ type.2 empty$
    { format.btitle.type.num }
    { type.2 "\bibmessage"                    =
      type.2 "\bibcomputerprogram"            =  or
      type.2 "\bibcomputerprogrammanual"      =  or
      type.2 "\bibcomputerprogramandmanual"   =  or
      type.2 "\bibcomputersoftware"           =  or
      type.2 "\bibcomputersoftwaremanual"     =  or
      type.2 "\bibcomputersoftwareandmanual"  =  or
      type.2 "\bibprogramminglanguage"        =  or
        { format.mtitle.type.num }
        { format.btitle.type.num }
      if$
    }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % unpublished manuscripts, etc.
    %
FUNCTION {unpublished}
{ check.relevant.fields
  author empty$
        %
        % no author: possibly edited book with editors as authors
        %
    { editor empty$
            %
            % no author or editor: title serves as author.
            % title formatted as book title
            %
        { format.btitle.type.num       output.new.block
          format.year.month.day.check  add.period$
        }
            %
            % format editor and year, and check if year is present
            % format book title, volume, and edition and check if title present
            %
        { format.editors.as.authors    start.new.block
          format.year.month.day.check  output.dot.new.block
          format.btitle.type.num
        }
      if$
    }
        %
        % format author and year, and check if year is present
        % format book title, volume, and edition
        % and check if title or type present
        %
    { format.authors               start.new.block
      format.year.month.day.check  output.dot.new.block
      format.btitle.type.num
    }
  if$
  howpublished empty$
  organization empty$ and
  address      empty$ and
    'skip$
    { output.new.block
      "\APAChowpublished{" "}" howpublished enclose.check
      organization    connect.with.comma.check
      address         connect.with.comma.check
      add.period$
    }
  if$
      %
      % format url
      %
  url empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.url
    }
  if$
      %
      % format optional note
      %
  note empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.note
    }
  if$
  fin.entry
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % nonprint media and other things that don't fit
    %
FUNCTION {misc}
{   %
    % To handle @manual: use type.2 instead of type.
  type.2 empty$
  type   empty$ not and
    { type 'type.2 := }
    'skip$
  if$
    %
  author empty$
        %
        % no author: possibly edited item with editors as authors
        %
    { editor empty$
            %
            % no author or editor: title/type serves as author.
            % title formatted as book title
            %
            % if no title and no type, howpublished is title
            %
        { title  empty$
          type.2 empty$ and
            { howpublished empty$
                { "No author, editor, title, type, and howpublished in "
                  cite$ * warning$
                  ""
                }
                { "\APAChowpublished{" howpublished * "}" * add.period$ }
              if$
              format.year.month.day.check  add.period$
            }
            { output.misctitle.type.num    output.new.block
              format.year.month.day.check  add.period$
              format.howpublished          add.period$
            }
          if$
        }
            %
            % format editor and year, and check if year is present
            % format book title, volume, and edition and check if title present
            %
        { format.editors.as.authors        start.new.block
          format.year.month.day.check      output.dot.new.block
          output.misctitle.type.num
          format.howpublished              add.period$
        }
      if$
    }
        %
        % format author and year, and check if year is present
        % format book title, volume, and edition
        % and check if title or type present
        %
    { format.authors                   start.new.block
      format.year.month.day.check      output.dot.new.block
      output.misctitle.type.num
      format.howpublished              add.period$
    }
  if$
      %
  address   empty$
  publisher empty$ and
      'skip$
      { % Clear the stack
        duplicate$ empty$
          'skip$
          { output.new.block }
        if$
        format.address.publisher add.period$
      }
  if$
      %
      % format url
      %
  url empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.url
    }
  if$
      %
      % format optional note
      %
  note empty$
    'skip$
    { % Clear the stack
      duplicate$ empty$
        'skip$
        { output.new.block }
      if$
      format.note
    }
  if$
  fin.entry
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % for legal cases and other cases that need to be
    % done by hand
    %
FUNCTION {literal}
{ "key"  key  warning.if.empty
  "text" text warning.if.empty
  text empty$
    { "" }
    { text }
  if$
  fin.entry
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % technical documentation
    %
FUNCTION {manual}
{ %
  % If type is empty, assume that it is a computer software manual.
  %
  type empty$
    { "\bibcomputersoftwaremanual"  'type.2 := }
    'skip$
  if$
  misc
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % following functions not used for APA Manual examples
    %





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % booklet
    %
FUNCTION {booklet}
{ misc }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % part of a book
    %
FUNCTION {inbook}
{ incollection }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % article in proceedings
    %
FUNCTION {inproceedings}
{ incollection }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % article in proceedings (Kopka & Daly, 2004, p. 230)
    %
FUNCTION {conference}
{ inproceedings }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % proceedings
    %
FUNCTION {proceedings}
{ misc }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % unknown types
    %
FUNCTION {default.type}
{ misc }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  INITIALIZATION FUNCTIONS                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

FUNCTION {initialize}
{   %
    % Maximum number of names to be formatted .
  #6  'name.max :=
%  #250  'entry.max$ :=
%  #5000  'global.max$ :=
}

FUNCTION {init.old.number}
{   %
    % For numbering the entries according to current sorting order.
  #0  'old.number :=
}

FUNCTION {init.old.label}
{   %
    % For comparing labels across entries .
  "zzzzzz"   'old.label  :=
}

FUNCTION {init.cite.initials.add.to.year}
{   %
    % Initialize "cite initials" indicator for all entries.
  #0  'cite.initials :=
    %
    % Initialize "add to year", i.e., whether a, b, etc. must
    % be added to the year in citation, to "no".
  #0  'add.to.year :=
    %
}

FUNCTION {move.forward}
{   %
    % Indicates that we're moving forward (ITERATE) through the entry list .
  #1 'forward :=
}

FUNCTION {move.backward}
{   %
    % Indicates that we're moving backward (REVERSE) through the entry list .
  #0 'forward :=
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  BASIC BIBLIOGRAPHY OUTPUT FUNCTIONS                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Beginning of the thebibliography environment:
% Write preamble if there is one, write \begin command

FUNCTION {begin.bib}
{ preamble$ empty$
    'skip$
    { preamble$ write$ newline$ }
  if$
  "\begin{thebibliography}{}"  write$ newline$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Write \end{thebibliography} command

FUNCTION {end.bib}
{ newline$
  "\end{thebibliography}"  write$ newline$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Write the citation labels and reference list entry to
% the .bbl file.

FUNCTION {write.bbl.entry}
{   %
    % Output \bibitem and \citeauthoryear command.
    %
  make.cite.labels
    %
    % Format and output reference list entry.
    %
  call.type$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  READ AND PROCESS ENTRIES, MAKE THEBIBLIOGRAPHY           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Read entries .

READ

% Write version info to .blg file

EXECUTE { identify.apacite.version }

% Some initializations .

EXECUTE { initialize }

% Sort items by title in order to replace each title by
% its number in later sorting .

ITERATE { make.sort.title }

SORT

EXECUTE { init.old.number }

EXECUTE { init.old.label }

ITERATE { make.title.number }

% Now generate some tentative author-year labels and do some
% preprocessing for the later definitive author and year
% labels.

ITERATE { make.tentative.sort.label }

SORT

% Now check whether initials must be added to first author,
% how many authors must be formatted, whether an "a", "b",
% etc., must be added to the year label.

ITERATE { init.cite.initials.add.to.year }

EXECUTE { init.initials }

ITERATE { check.add.initials }

EXECUTE { init.initials }

REVERSE { check.add.initials }

ITERATE { tentative.cite.num.names }

EXECUTE { init.cite.num.names }

EXECUTE { move.forward }

ITERATE { definitive.cite.num.names }

EXECUTE { init.cite.num.names }

EXECUTE { move.backward }

REVERSE { definitive.cite.num.names }


% Make final sorting label and do definitive sorting .

ITERATE { make.final.sort.key }

SORT

% Write preamble and \begin{thebibliography}{} statement

EXECUTE { begin.bib }

% Make final cite labels, format reference list entry,
% and write to .bbl file.

ITERATE { write.bbl.entry }


% Write \end{thebibliography} statement

EXECUTE { end.bib }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  DONE                                                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%</bibstyle|xbibstyle>
%    \end{macrocode}
%
%
% \Finale
\endinput
%