summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/biblatex-historian/historian.bbx
blob: 0992609d008fe9c952111b64d17f821584541e9b (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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% historian.bbx, v0.4, 2010/08/22
% A bibliography style for use with biblatex
% Developed and maintained by Sander Gliboff, 
% based on guidelines from the Turabian Manual for Writers, 7th ed.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ProvidesFile{historian.bbx}[2010/08/22 v0.4 historian bibliography style]

   \@ifpackagelater{biblatex}{2010/08/04}
     {}
     {\PackageError{biblatex}
	{Outdated 'biblatex' package
	The 'historian' style requires biblatex v0.9b or later.\MessageBreak
	 You are using: '\csuse{ver@biblatex.sty}'.\MessageBreak
	 This is a fatal error.}%
      \endinput}

%%%%% BIBLIOGRAPHY ENVIRONMENTS AND PARAMETERS %%%%%

%This style is based on verbose-inote.bbx and authortitle.bbx, from which the following macros are taken (with small modifications):

\RequireBibliographyStyle{standard}
%\ExecuteBibliographyOptions{pagetracker}%options all in cbx file

\DeclareBibliographyOption{dashed}[true]{%
  \ifstrequal{#1}{true}
    {\ExecuteBibliographyOptions{pagetracker}%
     \renewbibmacro*{bbx:savehash}{\savefield{fullhash}{\bbx@lasthash}}}
    {\ExecuteBibliographyOptions{pagetracker=false}%
     \renewbibmacro*{bbx:savehash}{}}}

\DeclareFieldFormat{shorthandwidth}{#1}
\setlength{\bibitemsep}{0pt}

\DeclareNameAlias{author}{sortname}
\DeclareNameAlias{editor}{sortname}
\DeclareNameAlias{translator}{sortname}

\defbibenvironment{bibliography}
  {\list
     {}
     {\setlength{\leftmargin}{\bibhang}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}

\defbibenvironment{shorthands}
  {\toggletrue{losflag}
  \list
     {\printfield[shorthandwidth]{shorthand}}
     {\setlength{\labelwidth}{\shorthandwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\InitializeBibliographyStyle{%
  \global\undef\bbx@lasthash}

\newbibmacro*{bbx:savehash}{%
  \savefield{fullhash}{\bbx@lasthash}}

\newbool{bbx@inset}
\DeclareBibliographyDriver{set}{%
  \booltrue{bbx@inset}%
  \entryset{}{}%
  \finentry}

%\renewbibmacro*{author}{% Redefined extensively below
%  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
%    {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
%                 \NOT\iffirstonpage\AND
%		 		\(\NOT\boolean{bbx@inset}\OR
%		   \iffieldequalstr{entrysetcount}{1}\)}
%       {\bibnamedash\setunit{\addcomma\addspace}}%Changed from authortitle to insert comma after namedash
%       {\printnames{author}%
%	\setunit{\addcomma\space}%
%        \usebibmacro{bbx:savehash}}%
%     \usebibmacro{authorstrg}}
%    {\global\undef\bbx@lasthash}}

\renewbibmacro*{editor}{%
  \usebibmacro{bbx:editor}{editorstrg}}
\renewbibmacro*{editor+others}{%
  \usebibmacro{bbx:editor}{editor+othersstrg}}
\newbibmacro*{bbx:editor}[1]{%
  \ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}
    {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                 \NOT\iffirstonpage\AND
		 \(\NOT\boolean{bbx@inset}\OR
		   \iffieldequalstr{entrysetcount}{1}\)}
       {\bibnamedash\setunit{\addcomma\addspace}}%Changed from authortitle to insert comma after namedash
       {\printnames{editor}%
	\setunit{\addcomma\space}%
        \usebibmacro{bbx:savehash}}%
     \usebibmacro{#1}%
     \clearname{editor}}
    {\global\undef\bbx@lasthash}}

\renewbibmacro*{translator}{%
  \usebibmacro{bbx:translator}{translatorstrg}}
\renewbibmacro*{translator+others}{%
  \usebibmacro{bbx:translator}{translator+othersstrg}}
\newbibmacro*{bbx:translator}[1]{%
  \ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{translator}}
    {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                 \NOT\iffirstonpage\AND
		 \(\NOT\boolean{bbx@inset}\OR
		   \iffieldequalstr{entrysetcount}{1}\)}
       {\bibnamedash\setunit{\addcomma\addspace}}%Changed from authortitle to insert comma after namedash
       {\printnames{translator}%
	\setunit{\addcomma\space}%
        \usebibmacro{bbx:savehash}}%
     \usebibmacro{#1}%
     \clearname{translator}}
    {\global\undef\bbx@lasthash}}
    

%%%%% TOGGLES AND VARIABLES %%%%%%%%%%%%%%%%%%%%%%%%%%

%Flag set in .cbx file when there appears to be a page range in the postnote
%(used for suppressing the pages field of articles in the footnotes)
\newtoggle{printpagerange}
\toggletrue{printpagerange}

%Set in the .cbx file by the footciteurllast and citerurllast commands
\newtoggle{urllastflag}
\togglefalse{urllastflag}

%used when crossreferencing from customd:
\newtoggle{printpages}
\newtoggle{printvolume}

%used for flagging repeating author names in bibliography
\newtoggle{namedashflag}
\togglefalse{namedashflag}

%Used for flagging when volume numbers or maintitles have alread been printed
\newtoggle{volumeprinted}
\togglefalse{volumeprinted}
\newtoggle{maintitleprinted}
\togglefalse{maintitleprinted}

%Used for flagging books that are reprint editions or translations, with original publication data
\newtoggle{origdataflag}
\newcommand\reprintoption{\optionnoreprints}

%Used for flagging crossreferences from customd or letter
\newtoggle{xrefflag}\togglefalse{xrefflag}


%Flags set by package and entry options
\newtoggle{printurlsflag}
\newtoggle{printseriesflag}
\newtoggle{shortincollflag}
\newtoggle{addorigflag}\togglefalse{addorigflag}
\newtoggle{addtransfromflag}\togglefalse{addtransfromflag}
\newtoggle{useshorttitles}
\newtoggle{useshortauthors}

%Flag set in list-of-shorthands environment
\newtoggle{losflag}

%Flags used for annotated bibliographies---copied from reading.bbx (new in v. 0.2)
%\newbool{bbx:entrykey}
\newbool{bbx:annotation}
%\newbool{bbx:abstract}
%\newbool{bbx:library}
%\newbool{bbx:file}


%%%%%% PACKAGE AND ENTRY OPTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%

% Define url/doi/eprint options from standard.bbx as EntryOptions as well as BibliographyOptions (New in v.0.3.)

\DeclareEntryOption{url}[true]{%
  \settoggle{bbx:url}{#1}}
\DeclareEntryOption{doi}[true]{%
  \settoggle{bbx:doi}{#1}}
\DeclareEntryOption{eprint}[true]{%
  \settoggle{bbx:eprint}{#1}}
  
% Historian-specific options---see the cbx-file for the citepages options

\DeclareBibliographyOption{printseries}[true]
	{\ifstrequal{#1}{true}
		{\toggletrue{printseriesflag}}%
		{\togglefalse{printseriesflag}}}%
		
\DeclareEntryOption{printseries}[true]
	{\ifstrequal{#1}{true}
		{\toggletrue{printseriesflag}}%
		{\togglefalse{printseriesflag}}}%

\DeclareBibliographyOption{shortincoll}[true]
	{\ifstrequal{#1}{true}
		{\toggletrue{shortincollflag}}%
		{\togglefalse{shortincollflag}}}%
		
\DeclareEntryOption{shortincoll}[true]
	{\ifstrequal{#1}{true}
		{\toggletrue{shortincollflag}}%
		{\togglefalse{shortincollflag}}}%

\DeclareBibliographyOption{reprint}[origfirst]
	{\renewcommand\reprintoption{#1}%
	\ifthenelse{\equal{\reprintoption}{\optionaddoriginal}
		\or\equal{\reprintoption}{\optionorigfirst}
		\or\equal{\reprintoption}{\optiondoubledate}
		\or\equal{\reprintoption}{\optionnoreprints}}
		{%then valid bibliography option
			\relax}%
		{%else not a valid option; don't do reprints at all
			\renewcommand\reprintoption{\optionnoreprints}}%
	}%
	
\DeclareEntryOption{reprint}[origfirst]
	{\renewcommand\reprintoption{#1}%
	\ifthenelse{\equal{\reprintoption}{\optionaddoriginal}
		\or\equal{\reprintoption}{\optionorigfirst}
		\or\equal{\reprintoption}{\optiondoubledate}
		\or\equal{\reprintoption}{\optionnoreprints}
		\or\equal{\reprintoption}{\optiontransfromorig}
		\or\equal{\reprintoption}{\optionorigtransas}}
		{%then valid entry option
			\relax}%
		{%else not a valid option; don't do reprints at all
			\renewcommand\reprintoption{\optionnoreprints}}%
	}%	
			
\DeclareEntryOption{shorttitle}[true]
	{\ifstrequal{#1}{true}
		{\toggletrue{useshorttitles}}%
		{\togglefalse{useshorttitles}}}%
			
\DeclareEntryOption{shortauthor}[true]
	{\ifstrequal{#1}{true}
		{\toggletrue{useshortauthors}}%
		{\togglefalse{useshortauthors}}}%
		
%Option declarations for annotated bibliographies (new in v. 0.2)

\DeclareBibliographyOption{annotation}[true]{%
  \csuse{bool#1}{bbx:annotation}}
\DeclareEntryOption{annotation}[true]{%
  \csuse{bool#1}{bbx:annotation}}
  

			
%%%%% CITE COMMANDS FOR CROSS-REFERENCING %%%%%%%%%%%

%For cross-referencing to collection (or book) in bibliography
\DeclareCiteCommand{\bbx@crosstocoll}[]{}{%
	\toggletrue{xrefflag}%
	\printtext
		{\bibhypertarget{\thefield{entrykey}:\the\value{instcount}}%
		{\iftoggle{shortincollflag}
			{%Then book/collection date are to be abbreviated
				\usebibmacro{getbookinfo-short}}%
			{%Else Print book/collection data in full
				 \usebibmacro{getbookinfo}}}}%
}{}{}%  

%For cross-referencing to periodical in bibliography
\DeclareCiteCommand{\bbx@crosstoper}[]{}{%
	\toggletrue{xrefflag}%
	\printtext
		{\bibhypertarget{\thefield{entrykey}:\the\value{instcount}}%
		{\usebibmacro{journal+issuetitle}}}%
}{}{}%  


%For cross-referencing to reference in bibliography.
%Normally, reference works won't be included in the bibliography, but just in case
%Treated same as xrefs to collections and books
\DeclareCiteCommand{\bbx@crosstoref}[]{}{%
	\toggletrue{xrefflag}%
\printtext
		{\bibhypertarget{\thefield{entrykey}:\the\value{instcount}}%
		{\iftoggle{shortincollflag}
			{\usebibmacro{getbookinfo-short}}%
			{\usebibmacro{getbookinfo}}}}%
}{}{}%  

%For cross-referencing to customa in bibliography
\DeclareCiteCommand{\bbx@crosstoarch}[]{}{%
	\toggletrue{xrefflag}%
	\printtext
		{\bibhypertarget{\thefield{entrykey}:\the\value{instcount}}%
		{\usebibmacro{in:}\usebibmacro{getarchiveinfo}}}%
}{}{}%  


%%%%% BIBLIOGRAPHY CATEGORIES %%%%%%%%%%%
%Certain entrytypes and subtypes need to be omitted or listed separately from the main bibliography. Set up categories for them
\DeclareBibliographyCategory{noteonly} 
\DeclareBibliographyCategory{newspaper}
\DeclareBibliographyCategory{magazine}
\DeclareBibliographyCategory{innewspaper}
\DeclareBibliographyCategory{inmagazine}
\DeclareBibliographyCategory{classic}
\DeclareBibliographyCategory{canonical}
\DeclareBibliographyCategory{biblical}
\DeclareBibliographyCategory{blog}
\DeclareBibliographyCategory{listserv}

%%%%%% PUNCTUATION AND FIELD FORMATS
% Unit punctuation is comma, block punctuation period
\renewcommand\newunitpunct{\addperiod\addspace}%

%Colons before page numbers and between titles and subtitles
\renewcommand{\bibpagespunct}{\addcolon\addspace}%
\renewcommand*{\subtitlepunct}{\addcolon\addspace}%

%...But no colon if title ends in a question mark or exclamation point
%\DefineBibliographyExtras{english}{\DeclarePunctuationPairs{colon}{*}}
\DefineBibliographyExtras{american}{\DeclarePunctuationPairs{colon}{*}}%Should allow colon only after abbreviation dot---doesn't seem to work

%%Put commas, etc. inside quotes
\uspunctuation %This makes sure American-style quote punctuation is enabled

%	Title formatting
% (Titles should have been entered in headline case)

\DeclareFieldFormat{titlecase}{#1}

\DeclareFieldFormat{booktitle}{\mkbibemph{#1}}
\DeclareFieldFormat{issuetitle}{\mkbibquote{#1}}

\DeclareFieldFormat[customd]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[periodical]{title}{%
	\mkbibemph{#1}}%
\DeclareFieldFormat[article]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypepublicdocument}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[incollection]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}%
		\or\equal{\thefield{entrysubtype}}{\subtypepublicdocument}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[inreference]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}%
		\or\equal{\thefield{entrysubtype}}{\subtypepublicdocument}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[jurisdiction]{title}{#1}%
\DeclareFieldFormat[legal]{title}{\mkbibemph{#1}}%
\DeclareFieldFormat[legislation]{title}{\mkbibemph{#1}}%
\DeclareFieldFormat[performance]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[audio]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[music]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[movie]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[video]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeonline}}%
		{\mkbibquote{#1}}%
		{\mkbibemph{#1}}}%
\DeclareFieldFormat[artwork]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[image]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
		{\mkbibemph{#1}}%
		{\mkbibquote{#1}}}%
\DeclareFieldFormat[customa]{title}{#1}%
\DeclareFieldFormat{volumetitle}{\mkbibemph{#1}}%
\DeclareFieldFormat{journalasauthor}{\mkbibemph{#1}}%
\DeclareFieldFormat[online]{title}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypedatabase}}%
		{{#1}}%
		{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
			{\mkbibemph{#1}}%
			{\mkbibquote{#1}}}}%

%Improvised use of booktitle in non-book media
\DeclareFieldFormat[online]{booktitle}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypedatabase}}%
		{{#1}}%
		{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
			{{#1}}%
			{\mkbibemph{#1}}}}%
\DeclareFieldFormat[audio]{booktitle}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
		{{#1}}%
		{\mkbibemph{#1}}}%
\DeclareFieldFormat[customd]{booktitle}{%
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebooklike}}%
		{{#1}}%
		{\mkbibemph{#1}}}%
		
\DeclareFieldFormat{shorthand}{\normalcolor #1\isdot}
				
%Automatic formatting of fields that need to be capitalized in bibliography, when newunitpunct is period, but not in footnotes

\DeclareFieldFormat{usera}{\ifcapital{\MakeCapital{#1}}{#1}}%
\DeclareFieldFormat{userd}{\ifcapital{\MakeCapital{#1}}{#1}}%
\DeclareFieldFormat{note}{\ifcapital{\MakeCapital{#1}}{#1}}%
\DeclareFieldFormat{eventtitle}{\mkbibquote{\ifcapital{\MakeCapital{#1}}{#1}}}%
\DeclareFieldFormat{addendum}{\ifcapital{\MakeCapital{#1}}{#1}}%
\DeclareFieldFormat{type}{\ifcapital{\MakeCapital{#1}}{#1}}%
\DeclareFieldFormat{library}{\ifcapital{\MakeCapital{#1}}{#1}}%
\DeclareFieldFormat{titleaddon}{\ifcapital{\MakeCapital{#1}}{#1}\isdot}%
\DeclareFieldFormat{booktitleaddon}{\ifcapital{\MakeCapital{#1}}{#1}}%
\DeclareFieldFormat{maintitleaddon}{\ifcapital{\MakeCapital{#1}}{#1}}%
\DeclareFieldFormat{edition}{%
  \ifinteger{#1}
    {\mkbibordinal{#1}~\bibstring{edition}}%
    {\ifcapital{\MakeCapital{#1}}{#1}}\isdot}%
\DeclareFieldFormat{howpublished}{\ifcapital{\MakeCapital{#1}}{#1}}%
%\DeclareFieldFormat{pubstate}{\ifcapital{\MakeCapital{#1}}{#1}}% 

% Get rid of default page prefix strings ``p.'' or ``pp.'' in pages field and postnote
\DeclareFieldFormat{pages}{\iffieldundef{bookpagination}{#1\isdot}{\mkpageprefix[bookpagination{#1\isdot}}}%
\DeclareFieldFormat{postnote}{\iffieldundef{pagination}{#1\isdot}{\mkpageprefix[pagination]{#1\isdot}}}%

%Change prefix for parts of book volumes
\DeclareFieldFormat{part}{%
\ifnumeral{#1}
	{\addcomma\addspace bk\adddot\addspace #1}%
	{\ifnumerals{#1}
		{\addcomma\addspace bks\adddot\addspace #1}%
		{\addcomma\addspace #1}}}%

%Automatic bibstring substitutions:
\DeclareFieldFormat{pubstate}{%
	\ifbibstring{#1}
		{\bibstring{#1}}%
		{\ifcapital
			{\MakeCapital{#1}}%
			{#1}}}%
\DeclareListFormat{location}{%
	\ifbibstring{#1}
		{\bibstring{#1}}%
		{\usebibmacro{list:delim}{#1}%
  		#1\isdot
  		\usebibmacro{list:andothers}}}
		
\DeclareListFormat{publisher}{%
	\ifbibstring{#1}
		{\bibstring{#1}}%
		{\usebibmacro{list:delim}{#1}%
  		#1\isdot
  		\usebibmacro{list:andothers}}}

%Field formats for annotated bibliographies (new in v. 0.2)
%(Annotations are printed by a redefined finentry macro)

%First need an indented environment and field formats for the texts (new in v. 0.2)
\newenvironment{indentannote}{%
 \begin{list}{}{%
  \setlength{\topsep}{0pt}%
  \setlength{\leftmargin}{1em}%
  \setlength{\rightmargin}{1em}%
  \setlength{\listparindent}{0pt}%
  \setlength{\itemindent}{0pt}%
  \setlength{\parsep}{0pt}%
 }%
 \item[]}%
{\end{list}}%

%\DeclareFieldFormat{annotation}{%
%	\begin{indentannote}
%		%\bibstring[]{annotation}\textbf{:}%
%		#1
%	\end{indentannote}}%

\DeclareNameFormat{author}{%
	\ifcitation%
		{%then in footnotes, firstname first
			\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
			\usebibmacro{name:andothers}%
			}%end citations
		{%else bibliography or maybe list of shorthands
			\iftoggle{losflag}
				{%then list of shorthands: firstname first here, too 
					\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
					\usebibmacro{name:andothers}%
					}%end los
				{%else bibliography
					\ifnumequal{\value{listcount}}{1}%
						{%then lastname first for first author/editor
							\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}%
							\usebibmacro{name:andothers}}%
						{%else firstname first for remaining authors/editors
							\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
							\usebibmacro{name:andothers}}%
					}%end bib
			}%
	}%

\DeclareNameFormat{editor}{%
	\ifcitation%
		{%then in footnotes, firstname first
			\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
			\usebibmacro{name:andothers}%
			}%end citations
		{%else bibliography or maybe list of shorthands
			\iftoggle{losflag}
				{%then list of shorthands: firstname first here, too 
					\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
					\usebibmacro{name:andothers}%
					}%end los
				{%else bibliography
					\ifnumequal{\value{listcount}}{1}%
						{%then lastname first for first author/editor
							\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}%
							\usebibmacro{name:andothers}}%
						{%else firstname first for remaining authors/editors
							\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
							\usebibmacro{name:andothers}}%
					}%end bib
			}%
	}%


\DeclareNameFormat{translator}{%
	\ifcitation%
		{%then in footnotes, firstname first
			\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
			\usebibmacro{name:andothers}%
			}%end citations
		{%else bibliography or maybe list of shorthands
			\iftoggle{losflag}
				{%then list of shorthands: firstname first here, too 
					\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
					\usebibmacro{name:andothers}%
					}%end los
				{%else bibliography
					\ifnumequal{\value{listcount}}{1}%
						{%then lastname first for first author/editor
							\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}%
							\usebibmacro{name:andothers}}%
						{%else firstname first for remaining authors/editors
							\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
							\usebibmacro{name:andothers}}%
					}%end bib
			}%
	}%
	
%%%%%% BIB-STRINGS %%%%%%%%%%%%%%%%

\NewBibliographyString{namedash}
\NewBibliographyString{letterto}
\NewBibliographyString{nodate}
\NewBibliographyString{noplace}
\NewBibliographyString{nopublisher}
\NewBibliographyString{online}
\NewBibliographyString{postedonline}
\NewBibliographyString{pseudonym}
\NewBibliographyString{incapitalized}
\NewBibliographyString{introto}
\NewBibliographyString{excerptfrom}
\NewBibliographyString{volumeof}
\NewBibliographyString{byline}
\NewBibliographyString{origeditionbib}
\NewBibliographyString{origeditiontitledbib}
\NewBibliographyString{origedition}
\NewBibliographyString{origeditiontitled}
\NewBibliographyString{translatedfromtitle}
\NewBibliographyString{translatedfromtitlebib}
\NewBibliographyString{numbers}
\NewBibliographyString{bycorporate}
\NewBibliographyString{bytranslatorbib}
\NewBibliographyString{translatedas}
\NewBibliographyString{translatedasbib}
%\NewBibliographyString{as	}
\NewBibliographyString{forthcoming}

\DefineBibliographyStrings{american}{%
	bycorporate		        = {by the},
	bytranslator     		= {trans.\isdot},
	bytranslatorbib     	= {translated by},
	translatedas     		= {trans.\isdot as},
	translatedasbib     	= {translated as},
%	as						= {as},
	forthcoming				= {forthcoming},
	incapitalized			= {In},
  	introto     			= {to},
	letterto     			= {to},
	excerptfrom     		= {from},
	volumeof    			= {of},
	byline      			= {by},
	online       			= {},%{available online from},
	postedonline         	= {posted},
	nodate					= {n.\isdot d.\isdot},
	noplace					= {n.\isdot p.\isdot},
	nopublisher				= {n.\isdot p.\isdot},
	origedition				= {orig. ed.\isdot}, 
	origeditiontitled		= {orig. ed.\isdot},
	origeditionbib			= {original edition},
	origeditiontitledbib	= {original edition},
	translatedfromtitle		= {originally},
	translatedfromtitlebib	= {originally published as},
	pseudonym				= {pseud.\isdot},
	numbers					= {nos\adddot},
	namedash				= {---------}
}%




%%%% CONSTANTS %%%%%%%%%%%%%%%%%

%Define comparison strings for entrysubtypes, authortypes, etc.

\newcommand\nameaddonpseud{pseudonym}
\newcommand\subtypemag{magazine}
\newcommand\subtypenewsp{newspaper}
\newcommand\subtypeclassic{classic}
\newcommand\subtypebiblical{biblical}
\newcommand\subtypeearlybook{canon}
\newcommand\subtypevideo{video}
\newcommand\entrytypearchive{customa}
\newcommand\subtypevolume{volume}
\newcommand\subtypeonline{online}
\newcommand\subtypedatabase{database}
\newcommand\subtypeblog{blog}
\newcommand\subtypelistmessage{listmessage}
\newcommand\subtypebooklike{book}
\newcommand\subtypepublicdocument{gov}
\newcommand\authortypeanon{anonymous}
\newcommand\authortypeunsure{anonymous?}
\newcommand\authortyperedundant{redundant}
\newcommand\authortypealternate{alternate}
\newcommand\authortypejournal{journal}
\newcommand\subtypeintro{to}
\newcommand\subtypeexcerpt{from}
\newcommand\subtypenone{none}
\newcommand\edtypecorp{corporate}
\newcommand\entrytypeper{periodical}
\newcommand\entrytypemanual{manual}
\newcommand\entrytypecoll{collection}
\newcommand\entrytypebook{book}
\newcommand\entrytyperef{reference}
\newcommand\entrytypeproc{proceedings}
\newcommand\entrytypereport{report}
\newcommand\entrytypebooklet{booklet}
\newcommand\entrytypemisc{misc}
\newcommand\entrytypeonline{online}
\newcommand\entrytypevideo{video}
\newcommand\entrytypeaudio{audio}
\newcommand\entrytypebookinbook{bookinbook}
\newcommand\entrytypearticle{article}
\newcommand\entrytypelegislation{legislation}
\newcommand\entrytypeletter{letter}
\newcommand\entrytypeperformance{performance}
\newcommand\optionaddoriginal{addorig}
\newcommand\optionnoreprints{none}
\newcommand\optionorigfirst{origfirst}
\newcommand\optiontransfromorig{transfrom}
\newcommand\optionorigtransas{transas}
\newcommand\optiondoubledate{doubledate}
\newcommand\noplace{np}
\newcommand\nopublisher{np}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                          %
%           BIBLIOGRAPHY DRIVERS           %
%                                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%      ARTICLE      %%%%%%%%%%%%%%%%%%

\DeclareBibliographyDriver{article}{%
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypenewsp}}%
	{\addtocategory{noteonly}{\thefield{entrykey}}%
	\addtocategory{innewspaper}{\thefield{entrykey}}}%
	{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypemag}}%
		{\addtocategory{inmagazine}{\thefield{entrykey}}}%
		{\relax}}%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\ifthenelse{\equal{\thefield{authortype}}{\authortypejournal}}%
	{%Special case of journal as author: italicize author and suppress journal title
		\printtext[journalasauthor]{\printnames[lastname]{author}}%
		\setunit{\labelnamepunct}\newblock
		\clearfield{journaltitle}\clearfield{journalsubtitle}}%
	{\ifnameundef{author}
		{\relax}%
		{\usebibmacro{author}%
		\setunit{\labelnamepunct}\newblock}}%
\iffieldundef{type}
	{\relax}%
	{\printfield{type}%Needed here for certain government documents
	\newunit}%
\iffieldundef{title}
	{\iffieldundef{titleaddon}
		{\relax}%
		{\usebibmacro{title}%
		\newunit\newblock}}%
	{\usebibmacro{title}%
	\newunit\newblock}%
\iffieldundef{issuetitle}
	{%Assume any editors go with the article, not the issue
		\iffieldundef{title}
			{\iffieldundef{titleaddon}
				{\relax}% No article title--don't print the editors here after all
				{\usebibmacro{bytranslator+others}%
				\newunit\newblock
				\usebibmacro{byeditor+others}%
				\newunit\newblock}}%
			{\usebibmacro{bytranslator+others}%
			\newunit\newblock
			\usebibmacro{byeditor+others}%
			\newunit\newblock}}%
	{%Else editors come after the ``in,'' and go with issue title
		\usebibmacro{in:}}%
	%Save all the location and subtype info for after the x-ref
	\savefield{entrysubtype}{\childsubtype}%
	\savefield{issuetitle}{\childissuetitle}%
	\savefield{issuesubtitle}{\childsissueubtitle}%
	\savefield{note}{\childnote}\savefield{series}{\childseries}%
	\savefield{volume}{\childvolume}\savefield{number}{\childnumber}%
	\savefield{issue}{\childissue}%
	\savefield{year}{\childyear}\savefield{date}{\childdate}%
%Check for x-ref to periodical record
\iffieldundef{xref}%
	{%then no xref
		\usebibmacro{journal+issuetitle}}%
	{%else x-ref to the parent entry; the citecommands will pass parent data to the journal+issuetitle macro
		\printtext{\unspace}%Just to force the unit punctutation before the xref
		\iffootnote
			{%then footnote routine in cbx file
				\cbx@crosstoper{\thefield{xref}}}%
			{%else bibliography routine here in bbx
				\bbx@crosstoper{\thefield{xref}}}%
	}%endifundef xref
\newunit\newblock
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypemag}%
	\OR\equal{\thefield{entrysubtype}}{\subtypenewsp}}%
	{\setunit{\addcomma\addspace}}%
	{\setunit{\bibpagespunct}}%
\iftoggle{printpagerange}
	{\printfield{pages}}%
	{\relax}%Postnote will be printed instead of full page range
\newunit\newblock
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End of article driver


%%%%%%      ARTWORK	     %%%%%%%%%%%%%%%%%%
\DeclareBibliographyAlias{artwork}{customd}

%%%%%%      AUDIO      %%%%%%
%
\DeclareBibliographyDriver{audio}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printfield{volume}%
\newunit
\iffieldundef{booktitle}
	{}%
	{\usebibmacro{in:}%
	\usebibmacro{booktitle}%
	\newunit}%
\iffieldundef{eventtitle}
	{\relax}%
	{\printtext[title]{\printfield[titlecase]{eventtitle}}}%
\setunit{\addcomma\addspace}%
\printfield{venue}%
\setunit{\addcomma\addspace}%
\printeventdate%
\newunit
\printfield{note}%
\newunit
\printlist{organization}%
\newunit
\printlist{institution}%
\newunit
\printlist{publisher}%
\newunit
\printfield{howpublished}%
\newunit
\printfield{type}%
\newunit
\printfield{usera}%
\newunit
\printfield{userd}%
\newunit
\usebibmacro{date-full}%
\newunit\newblock
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%end of audio driver

%%%%%%      BOOK      %%%%%%

\DeclareBibliographyDriver{book}{%
%Sort out entrysubtypes
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeclassic}
			\OR\equal{\thefield{entrysubtype}}{\subtypebiblical}}
	{\usebibmacro{classic}}%
	{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeearlybook}}%
		{\usebibmacro{earlybook}}%
		{%else default book routine
			\ifthenelse{\equal{\reprintoption}{origtransas}}
				{%then reverse order: orig-fields go first
					\usebibmacro{origtransas}}%
				{%else
					\relax}%
			\usebibmacro{bibindex}%
			\usebibmacro{begentry}%
			%Author Block-----------------------------------------------
			\usebibmacro{author/editor/translator}%
			\setunit*{\labelnamepunct}%
			\newblock
			%First-Level Title Block (for book or volume)--------------
			\usebibmacro{title}%
			\newunit\newblock
			%Editors and/or Translator Blocks--------------------------
%			\usebibmacro{byauthor}% Is this ever needed?
%			\newunit\newblock
			\ifthenelse{\equal{\thefield{entrytype}}{\entrytypereport}}%
				{%Special case of reports with an institutional author and an individual one
					\usebibmacro{bynamea}%
					\newunit\newblock}%
				{\relax}%
			\ifthenelse{\equal{\reprintoption}{\optionorigtransas}}
				{%then save the translator for after the publishing data
					\savename{translator}{\temptranslator}%
					\clearname{translator}}%
				{%else
					\relax}%
			\usebibmacro{byeditor+others}%
			\newunit\newblock
			%Block for vol. no., second-level title, and editors-----------------
			\usebibmacro{title+maintitle}%
			\usebibmacro{collectioneditor}%New unit puctuation set in subroutine
			\newunit\newblock
			%Edition Block -----------------------------------------------------
			\printfield{edition}%
			\newunit\newblock
			%Optional block for book-like videos--------------------------------
			\ifthenelse{\equal{\thefield{entrytype}}{\entrytypevideo}}%
				{%then certain videos have to be entered as books
					\printfield{type}%
					\newunit\newblock}%
				{%else not a video
					\relax}%
			%Series Block (including note field) --------------------------------
			\iftoggle{printseriesflag}%Print series info only when option is set
				{\iffieldundef{series}
					{\relax}%
					{\usebibmacro{series+number}%
					\setunit{\addcomma\addspace}}}%
				{\relax}%
			\printfield{note}%
			\newunit\newblock
			%Special block for book-like entrytypes-------------------
			\ifthenelse
				{\equal{\thefield{entrytype}}{\entrytypemanual}%
				\OR
				\equal{\thefield{entrytype}}{\entrytypebooklet}%
				\OR
				\equal{\thefield{entrytype}}{\entrytypemisc}%
				\OR
				\equal{\thefield{entrytype}}{\entrytypereport}}%
				{%then
					\printfield{type}%
					\newunit
					\printfield{version}%
					\newunit
					\printlist{organization}%
					\newunit\newblock}%
				{%else ordinary book
					\relax}%
			%Publishing Data Block -------------------------------------
			\iffootnote
				{%then location:publisher, year in parentheses
					\setunit{\addspace}%
					\printtext[parens]{\usebibmacro{publisher+location+year}}%
					}%
				{%else no parens and an extra field
					\usebibmacro{publisher+location+year}%
					\newunit\newblock
					\printfield{userc}%Special addendum for exhibit catalogs
					}%
			\newunit\newblock
			%Optional block for original publication data---------------------
			\ifthenelse{\equal{\reprintoption}{\optionaddoriginal}}
				{\usebibmacro{addoriginaledition}}%
				{\ifthenelse{\equal{\reprintoption}{\optiontransfromorig}}
					{\usebibmacro{addtransfrom}}%
					{\ifthenelse{\equal{\reprintoption}{\optionorigtransas}}
						{%then 
							\restorename{translator}{\temptranslator}%
							\usebibmacro{print-translation-data}}%
						{%else
							\relax}%
						}%
					}%
			\newunit\newblock
			%Online locators----------------------------------------------------------
			\usebibmacro{onlinelocation}%
			\newunit\newblock
			%Addendum and finish------------------------------------------------------
			\printfield{addendum}%
			\usebibmacro{pageref}%
			\usebibmacro{finentry}%
		}%End else; end default book routine
	}%
}%End oF book driver

%Subtype of Book for classics and other standard texts for which publication information is unimportant: footnotes only, no punctuation after author, and minimal publication information.
\newbibmacro{classic}{%-----------------------------------------------------------
%Add key to noteonly category
\addtocategory{noteonly}{\thefield{entrykey}}%
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebiblical}}
	{\addtocategory{biblical}{\thefield{etnrykey}}}%
	{\addtocategory{classic}{\thefield{entrykey}}}%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\iffootnote
	{\ifnameundef{shortauthor}
		{\usebibmacro{author/editor/translator}}%
		{\printnames{shortauthor}}}%
	{\usebibmacro{author/editor/translator}}%
\setunit{\addspace}\newblock
\iffootnote
	{\iffieldundef{shorttitle}
		{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebiblical}}
			{\printfield[titlecase]{title}}%
			{\usebibmacro{title}}}%
		{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebiblical}}
			{\printfield[titlecase]{shortitle}\isdot}%
			{\printfield[title]{shorttitle}\isdot}}}%
	{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebiblical}}
		{\printfield[titlecase]{title}}%
		{\usebibmacro{title}}}%
\setunit{\addspace}%
\iffieldundef{edition}
	{\relax}%
	{\printtext[parens]{\printfield{edition}}%
	\newunit}%
\printfield{note}%Use note or series to identify edition, if necessary
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%end of macro; end of classic subtype of book

%Special routine for entrysubtyp ``canon'' of book, for early English literature
\newbibmacro{earlybook}{%-----------------------------------------------------------------
%Add key to noteonly category
\addtocategory{noteonly}{\thefield{entrykey}}%
\addtocategory{canonical}{\thefield{entrykey}}%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\iffootnote
	{%then always use shortauthor and shorttitle in footnotes, if available
		\ifnameundef{shortauthor}
			{\usebibmacro{author/editor/translator}}%
			{\printnames{shortauthor}}%
		\setunit*{\labelnamepunct}%
		\newblock
		\iffieldundef{shorttitle}%
			{\usebibmacro{title}}%
			{\printtext[title]{\printfield[titlecase]{shorttitle}}\isdot}%
		}%end footnote routine
	{%else usual author and title routines in the bibliography
		\usebibmacro{author/editor/translator}%
		\newunit\newblock
		\usebibmacro{title}%
		}%
\setunit{\addspace}%
\iffieldundef{edition}
	{\relax}%
	{\printtext[parens]{\printfield{edition}}}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End earlybook macro


%%%%%%      BOOKINBOOK      %%%%%%

\DeclareBibliographyAlias{bookinbook}{inbook}


%%%%%%      BOOKLET      %%%%%%

\DeclareBibliographyAlias{booklet}{book}%

%%%%%%      COLLECTION     %%%%%%%%%%%

\DeclareBibliographyDriver{collection}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\ifthenelse{\equal{\reprintoption}{\optionorigtransas}}
	{%then reverse order: orig-fields go first
		\usebibmacro{origtransas}}%
	{%else
		\relax}%
%Editor Block-----------------------------------------------
\ifthenelse{\equal{\thefield{editortype}}{\edtypecorp}}
	{%then corporate editor of a proceedings: print without the editor string
  		\printnames{editor}%
		\clearname{editor}}%
  	{%else personal editor: use usual editor routine
		\usebibmacro{editor}}%
\setunit{\labelnamepunct}%
\newblock
%First-Level Title Block (for book or volume)--------------
\usebibmacro{title}%
\newunit\newblock
%Proceedings fields---------------------------------------
\usebibmacro{getproceedingsfields}%
\newunit\newblock
%Editors and/or Translator Blocks--------------------------
\ifthenelse{\equal{\reprintoption}{\optionorigtransas}}
	{%then save the translator for after the publishing data
		\savename{translator}{\temptranslator}%
		\clearname{translator}}%
	{%else
		\relax}%
\usebibmacro{byeditor+others}%
\newunit\newblock
%Block for vol. no., second-level title, and editors-----------------
\usebibmacro{title+maintitle}%
\usebibmacro{collectioneditor}%New unit puctuation set in subroutine
\newunit\newblock
%Edition Block -----------------------------------------------------
\printfield{edition}%
\newunit\newblock
%Series Block (including note field) --------------------------------
\iftoggle{printseriesflag}%Print series info only when option is set
	{\iffieldundef{series}
		{\relax}%
		{\usebibmacro{series+number}%
		\setunit{\addcomma\addspace}}}%
	{\relax}%
\printfield{note}%
\newunit\newblock
%Special fields ----------------------------------------------------
\printfield{type}%
\newunit
\printfield{version}%
\newunit\newblock
%Publishing Data Block ------------------------------------------------
\iffootnote%
	{%then location:publisher, year in parentheses
		\setunit{\addspace}%
		\printtext{\bibleftparen}%
		\usebibmacro{publisher+location+year}%
		\printtext{\bibrightparen}}%
	{%else no parens and an extra field
		\usebibmacro{publisher+location+year}%
		\newunit\newblock
		\printfield{userc}%Special addendum for exhibit catalogs
		}%
\newunit\newblock
%Optional block for original publication data----------------------------------------
\ifthenelse{\equal{\reprintoption}{\optionaddoriginal}}
	{\usebibmacro{addoriginaledition}}%
	{\ifthenelse{\equal{\reprintoption}{\optiontransfromorig}}
		{\usebibmacro{addtransfrom}}%
		{\ifthenelse{\equal{\reprintoption}{\optionorigtransas}}
			{%then 
				\restorename{translator}{\temptranslator}%
				\usebibmacro{print-translation-data}}%
			{%else
				\relax}%
			}%
		}%
\newunit\newblock
%Print urls, etc., if appropriate option\subtype is set
\newunit\newblock
%Online locators----------------------------------------------------------
\usebibmacro{onlinelocation}%
\newunit\newblock
%Addendum and finish------------------------------------------------------
\printfield{addendum}%
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}% End of collection driver

  

%%%%%%      IMAGE	     %%%%%%%%%%%%%%%%%%

\DeclareBibliographyAlias{image}{customd}

%%%%%%      INBOOK      %%%%%%

%Inbook. Similar to incollection, only with author instead of editor.
\DeclareBibliographyDriver{inbook}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
%Author Block------------------------------------------------------
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeearlybook}}
	{%Then for canonical works, add key to noteonly category and use shortauthor
		\addtocategory{noteonly}{\thefield{entrykey}}%
		\addtocategory{canonical}{\thefield{entrykey}}%\iffootnote
		{\ifnameundef{shortauthor}
			{\usebibmacro{author}}%
			{\printnames{shortauthor}}}%
		}%
	{%Else not canonical, use usual author routine
		\usebibmacro{author}}%
\savename{author}{\childauthor}%Need later, to compare with book author
\setunit{\labelnamepunct}%
\newblock
%Inner Title Block--------------------------------------------------------
\usebibmacro{title}%
\newunit\newblock
%Book-Title Block--------------------------------------------------------
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypevolume}%
	\OR\equal{\thefield{entrytype}}{\entrytypebookinbook}}%
	{%then1 reference is to a volume of a larger work. Print volume number here and not at the end
		\printfield{volume}\printfield{part}%
		\clearfield{volume}\clearfield{part}\toggletrue{volumeprinted}%
		\clearfield{title}%Clear title, too, to prevent repetition
		}%
	{%else1 
		\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypevideo}}%
			{%then2 Special case of a video that gets bookvolume-like formatting
				\iffootnote
					{\printfield[noformat]{volume}}%
					{\printtext[noformat]{\MakeCapital{\thefield{volume}}}}%
				\clearfield{volume}\toggletrue{volumeprinted}%
				}%end then2
			{%else2 default case
				\printfield{chapter}%(Turabian doesn't actually use chapter numbers)
				}%end else2, end subtypevideo test
		}%end else1, end subtypevolume test 
\newunit\newblock
%Second-level title and editor, publishing data------------------------------------------
%But first, save info to pass to parent record in case of x-reffing
\savename{author}{\childauthor}%
\savefield{pages}{\childpages}%
\savefield{volume}{\childvolume}%
\savefield{part}{\childpart}%
\usebibmacro{in:}%Macro modifed below for subtypes that need different prepositions
%Where are the book data? 
%First check whether there is an x-ref to the book
\iffieldundef{xref}%
	{%then no xref; get book info from current entry
		\usebibmacro{getbookinfo}}%
	{%else x-ref to the parent entry; the crosstocoll citecommands will then pass parent data to the bibmacro getbookinfo, below
		\printtext[noformat]{\unspace}%Just to force the unit punctutation before the xref
		\iffootnote
			{\cbx@crosstocoll{\thefield{xref}}}%
			{\bbx@crosstocoll{\thefield{xref}}}%
	}%endiffieldundef
\newunit\newblock
%Print rest of inbook data
%Onlineblock---------------------------------------------------------------
\usebibmacro{onlinelocation}%
\newunit\newblock
%Addendum and finish-----------------------------------------------------
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End of inbook driver
  

    
%%%%%%      INCOLLECTION     %%%%%%%

\DeclareBibliographyDriver{incollection}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
%Author Block------------------------------------------------------
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypepublicdocument}}%
	{\usebibmacro{author}}%
	{\usebibmacro{author/editor/translator}}%
\savename{author}{\childauthor}%Need later, to compare with book author
\setunit{\labelnamepunct}%
\newblock
%Inner Title Block--------------------------------------------------------
\usebibmacro{title}%
\newunit\newblock
%Book-Title Block--------------------------------------------------------
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypevolume}}%
	{%then1 reference is to a volume of a larger work. Print volume number here and not at the end
		\printfield{volume}\printfield{part}\toggletrue{volumeprinted}%
		\clearfield{volume}\clearfield{part}%
		}%
	{%else1
		\printfield{chapter}%Turabian doesn't use chapter numbers; not sure it goes here
		}%end else1, end subtypevolume test
\newunit\newblock
%Second-level title and editor, publishing data --------------------------------------
%Save data for after the xref
\savename{author}{\childauthor}%
\savefield{pages}{\childpages}%
\savefield{volume}{\childvolume}%
\savefield{part}{\childpart}%
%Insert preposition
\usebibmacro{in:}%
%Now where are the collection data? 
%First check whether there is an x-ref to the collection
\iffieldundef{xref}%
	{%then no xref; get collection data from the current entry
		\usebibmacro{getbookinfo}}%
	{%else x-ref to the parent entry; the citecommands will pass parent data to the bibmacro getbookinfo, below
		\printtext{\unspace}%Just to force the unit punctutation before the xref
		\iffootnote
			{\cbx@crosstocoll{\thefield{xref}}}%footnote routine in cbx file
			{\bbx@crosstocoll{\thefield{xref}}}%bibliography routine here in bbx
	}%endifundef
%Print rest of incollection data
\newunit\newblock
%Online Block--------------------------------------------------------------------
\usebibmacro{onlinelocation}%
\newunit\newblock
%Addendum and Finish--------------------------------------------------------
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End incollection driver



%%%%%%      INPROCEEDINGS      %%%%%%

%Inproceedings are treated like incollections, even though they have some extra fields
\DeclareBibliographyAlias{inproceedings}{incollection}%
    
%%%%%%      INREFERENCE     %%%%%%%

\DeclareBibliographyDriver{inreference}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypepublicdocument}}%
	{\usebibmacro{author}}%
	{\usebibmacro{author/editor/translator}}%
\setunit{\labelnamepunct}
\newblock
%Inner Title Block--------------------------------------------------------
\usebibmacro{title}%
\newunit\newblock
%Book-Title Block--------------------------------------------------------
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypevolume}}%
	{%then1 reference is to a volume of a larger work. Print volume number here and not at the end
		\printfield{volume}\printfield{part}\toggletrue{volumeprinted}%
		\clearfield{volume}\clearfield{part}%
		}%
	{%else1
		\printfield{chapter}%Turabian doesn't use chapter numbers; not sure it goes here
		}%end else1, end subtypevolume test
\newunit\newblock
%Second-level title and editor, publishing data --------------------------------------
%Save data for after the xref
\savename{author}{\childauthor}%
\savefield{pages}{\childpages}%
\savefield{volume}{\childvolume}%
\savefield{part}{\childpart}%
%Insert preposition
\usebibmacro{in:}%
%Now where are the collection data?
\iffieldundef{xref}%
	{%then no xref
		\iffootnote
			{%Then footnote routine: just title and edition
				\usebibmacro{getbooktitle}%
				\newunit\newblock
				\printfield{edition}%
				\newunit\newblock
				\printfield{note}%
				}%End of footnote routine
			{%Else: bibliography (not normally used) or list of shorthands:
				\usebibmacro{getbookinfo}}%
		}%end then
	{%else x-ref to the parent entry; the citecommands will pass parent data to the bibmacro getbookinfo, below
		\printtext{\unspace}%Just to force the unit punctuation before the xref
		\iffootnote
			{\cbx@crosstoref{\thefield{xref}}}%footnote routine in cbx file
			{\bbx@crosstoref{\thefield{xref}}}%bibliography routine passes parent data to getbookinfo, below
		}%endiffieldundef xref
%Print rest of inreference data
\newunit\newblock
%Online Block--------------------------------------------------------------------
\usebibmacro{onlinelocation}%
\newunit\newblock
%Addendum and Finish--------------------------------------------------------
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%end inreference driver

%%%%%%      JURISDICTION      %%%%%%%%%%%%%%%%%%

\DeclareBibliographyDriver{jurisdiction}{%
\addtocategory{noteonly}{\thefield{entrykey}}%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{type}%
\newunit
\usebibmacro{title}%
\newunit\newblock
\printfield{note}\isdot%
\setunit{\addspace}%
\printfield{pages}%
\setunit{\addspace}%
\printtext[parens]{%
	\printlist{institution}\isdot%
	\setunit{\addspace}%
	\usebibmacro{date-full}}%
\newunit\newblock
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End jurisdiction driver

%%%%%%      LEGAL      %%%%%%%%%%%%%%%%%%

\DeclareBibliographyDriver{legal}{%
\addtocategory{noteonly}{\thefield{entrykey}}%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{type}%
\newunit
\usebibmacro{title}%
\newunit\newblock
\printfield{note}\isdot%
\iffieldundef{issuetitle}
	{\relax}%
	{\usebibmacro{issue}%Prints issuetitle
	\newunit}%
\printfield{note}%
\setunit{\addcomma\addspace}%
\usebibmacro{journal}%
\iffieldundef{series}
	{\setunit*{\addspace}}%
	{\setunit{\addcomma\addspace}%
	\printfield{series}%
	\setunit{\addcomma\addspace}}%
\printfield{volume}%
\setunit{\addcomma\addspace\bibstring{number}\addspace}%
\printfield{number}%
\setunit{\addspace}%
\usebibmacro{issue+date}%
\setunit{\bibpagespunct}%
\printfield{pages}%
\newunit\newblock
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End legal driver

%%%%%%      LEGISLATION      %%%%%%

\DeclareBibliographyDriver{legislation}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\toggletrue{useshortauthors}%Always use shortauthor in footnotes
\usebibmacro{author}%
\setunit*{\labelnamepunct\addspace}\newblock
\printfield{type}%
\newunit
\usebibmacro{title}%
%\newunit
%\usebibmacro{byauthor}%
%\newunit
%\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{edition}%
\newunit
\iffootnote
	{\iffieldundef{shortjournal}
		{\printfield{journaltitle}
		\setunit*{\addcolon\addspace}%
		\printfield{journalsubtitle}}%
		{\printfield{shortjournal}}%
	}%
	{\printfield{journaltitle}%
	\setunit*{\addcolon\addspace}%
	\printfield{journalsubtitle}}%
\newunit\newblock
\printfield{note}\isdot%
\newunit\newblock
%Give facts of publication freeform
\printlist{institution}%
\setunit{\addcomma\addspace}%
\printlist{publisher}%
\setunit{\addcomma\addspace}%
\printfield{howpublished}
\setunit{\addcomma\addspace}%
\usebibmacro{date-full}%
\printfield{usera}%
\newunit\newblock
\printfield{userd}%
\newunit\newblock
\iffootnote
	{\printfield[noformat]{volume}%
	\printfield{part}}%
	{\printfield{volume}%
	\printfield{part}}%
\iffieldundef{volume}
	{\setunit{\addcomma\addspace}}%
  	{\setunit{\bibpagespunct}}%
\printfield{pages}%
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End of legislation driver

%%%%%%      LETTER      %%%%%%

%For correspondence (archival or published) 
\DeclareBibliographyDriver{letter}{%
%Add key to noteonly category
\addtocategory{noteonly}{\thefield{entrykey}}%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
%Just in case, format for bibliography, too
\iffootnote
	{\relax}%
	{\ifcitation
		{\relax}%
		{\setunit{\labelnamepunct}\newblock
		\printnames[byauthor]{author}}}%Repeat name in bibliography
%If there's a recipient in namec, print ``to namec''
\setunit{\addspace\bibstring{letterto}\addspace}%
\printnames{namec}%
\setunit{\addcomma\addspace}%
\usebibmacro{title}%Shouldn't be needed for letters, except maybe if names are missing or uncertain
\setunit{\addcomma\addspace}%
\printfield{type}%
\setunit{\addcomma\addspace}%
\printfield{venue}%
\setunit{\addcomma\addspace}%
\printfield{note}%
\setunit{\addcomma\addspace}%
\usebibmacro{date-full}%
\newunit\newblock
\iffieldundef{xref}%
	{%then no xref; just print what's likely to be available in the customd
		\iffieldundef{booktitle}
			{%then improvise
				\printfield{howpublished}%
				\setunit*{\addcomma\addspace}%
				\printlist{organization}%
				\setunit*{\addcomma\addspace}%
				\printlist{institution}%
				\setunit*{\addcomma\addspace}%
				\printfield{library}%
				\setunit*{\addcomma\addspace}%
				\printfield{userd}%
				\newunit\newblock
				\usebibmacro{volume+pages}%
				}%
			{%else assume it's from a published collection
				\usebibmacro{in:}%
				\usebibmacro{getbookinfo}%
				}% 
		\newunit\newblock
		\usebibmacro{onlinelocation}%
		}%
	{%else x-ref to collection or customa and the getbookinfo macro
	%(but only print `in' if the xref turns out to be to a collection)
		%Save data for after the xref
		\printtext{\unspace}%Just to force the unit punctutation before the xref
		\savename{author}{\childauthor}%
		\savefield{pages}{\childpages}%
		\savefield{volume}{\childvolume}%
		\savefield{part}{\childpart}%
		\iffootnote%
			{\cbx@crosstoarch{\thefield{xref}}}%
			{\bbx@crosstoarch{\thefield{xref}}}%
%		\restorefield{volume}{\childvolume}%
%		\restorefield{part}{\childpart}%
%		\restorefield{pages}{\childpages}%
	}%endif
\newunit\newblock
\printfield{library}%
\setunit{\addcomma\addspace}%
\printfield{userd}%
\newunit\newblock
\iffootnote
	{\usebibmacro{volume+pages}%
	\newunit\newblock}%
	{\relax}%
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%end letter driver

%%%%%%      MANUAL      %%%%%%

%Manuals are treated like books, even though they have some extra fields
\DeclareBibliographyAlias{manual}{book}%

%%%%%%      MISC      %%%%%%

\DeclareBibliographyAlias{misc}{booklet}%
  
%%%%%%      MOVIE      %%%%%%

% Currently not distinguished from performance

\DeclareBibliographyAlias{movie}{performance}%

%%%%%%      MUSIC      %%%%%%

% Currently not distinguished from audio

\DeclareBibliographyAlias{music}{audio}

%%%%%%      ONLINE      %%%%%%

\DeclareBibliographyDriver{online}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor/translator}%
\setunit{\labelnamepunct}\newblock
%Case of entrysubtypes
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeblog}}%
	{%then blog entry by main author
		\usebibmacro{blog}}%
	{%else
		\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypelistmessage}}
			{%then e-mail to listserve
				\usebibmacro{listmessage}}%
			{%else default web site routine
				\usebibmacro{title}%
				\newunit\newblock
				\usebibmacro{byeditor}%
				\newunit\newblock
				\printfield{version}%
				\newunit
				\usebibmacro{date-optional}%
				\newunit
				\printfield{note}%
				\newunit\newblock
				\iffieldundef{booktitle}
					{\relax}%
					{\usebibmacro{in:}%
					\usebibmacro{booktitle}%
					\newunit}%
				\printlist{organization}%
				\newunit
				\printlist{institution}%
				\newunit
				\printlist{publisher}%
				\newunit
				\printfield{howpublished}%
				\newunit
				\printfield{type}%
				\newunit
				\printfield{usera}%
				\newunit
				\printfield{userd}%
				\newunit\newblock
			}%end else; end default web site routine
	}%end case of entrysubtype
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%end online driver

%Subroutine of online driver
\newbibmacro{blog}{%--------------------------------------------
\usebibmacro{title}%
\newunit\newblock
\printfield{type}%
\setunit*{\addspace}%
\bibstring{postedonline}\addspace
\usebibmacro{date-full}%
\newunit
\printfield{note}%
\newunit\newblock
\printlist{organization}%
\setunit{\addcomma\space}
\printlist{institution}%
\newunit
\printfield{howpublished}%
\newunit
\printfield{usera}%
\newunit\newblock
%Add key to noteonly and blog categories
\addtocategory{noteonly}{\thefield{entrykey}}%
\addtocategory{blog}{\thefield{entrykey}}%
}%end blog macro

\newbibmacro{listmessage}{%--------------------------------------------
%No special treatment for listserv messages, at least for the present
	\relax
}%end listmessage macro

%%%%%%      PATENT      %%%%%%

% Currently not distinguished from legislation

\DeclareBibliographyAlias{paten}{legislation}

%%%%%%      PERFORMANCE     %%%%%%%%%%%%%%%%%%

\DeclareBibliographyDriver{performance}{%
%Add key to noteonly category
\addtocategory{noteonly}{\thefield{entrykey}}%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{title}%
\setunit{\addcomma\addspace\bibstring{byauthor}\addspace}%
\printnames[byauthor]{author}%
\setunit{\addcomma\addspace}%
\printfield{type}%
\setunit{\addcomma\addspace}%
\printfield{note}%
\setunit{\addcomma\addspace}%
\printfield{venue}%
\newunit
\printlist{publisher}%
\newunit
\printfield{howpublished}%
\setunit{\addcomma\addspace}%
\usebibmacro{date-full}%
\iffieldundef{origtitle}%
	{\relax}%
	{\setunit{\addspace\bibleftparen}%
	\printfield[titlecase]{origtitle}%
	\setunit*{\addspace}%
	\printorigdate
	\bibrightparen}%
\newunit\newblock
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%end performance driver
  
%%%%%%      PERIODICAL      %%%%%%

\DeclareBibliographyDriver{periodical}{%
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypenewsp}}%
	{\addtocategory{newspaper}{\thefield{entrykey}}}%
	{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypemag}}%
		{\addtocategory{magazine}{\thefield{entrykey}}}%
		{\relax}}%
\usebibmacro{bibindex}%
\ifnameundef{editor}
	{\setunit{\addspace}}%
	{\usebibmacro{editor}%
	\setunit{\labelnamepunct}\newblock}%
\usebibmacro{title+issuetitle}%
\newunit\newblock
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
%\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%end periodical driver

%%%%%%      PROCEEDINGS      %%%%%%

%Proceedings are treated like collections, even though they have some extra fields
\DeclareBibliographyAlias{proceedings}{collection}%

%%%%%%      REFERENCE     %%%%%%%%%%%

\DeclareBibliographyDriver{reference}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\iffootnote
	{%Then footnote routine: just title and edition
		\usebibmacro{title}%Uses shorttitles for references, if available
		\newunit\newblock
		\printfield{edition}%
		\newunit\newblock
		\printfield{note}%
		}%End of footnote routine
	{%Else: bibliography (not normally used) or list of shorthands:
	%(Proceed more or less as for collections, but title first)
		%First-Level Title Block (for book or volume)--------------
		\usebibmacro{title}%
		\newunit\newblock
		%Author Block-----------------------------------------------
		\usebibmacro{byauthor}%
		\newunit\newblock
		%Editors and/or Translator Blocks--------------------------
		\usebibmacro{byeditor+others}%
		\newunit\newblock
		%Block for vol. no., second-level title, and editors-----------------
		\usebibmacro{title+maintitle}%
		\usebibmacro{collectioneditor}%New unit punctuation set in subroutine
		\newunit\newblock
		%Edition Block -----------------------------------------------------
		\printfield{edition}%
		\newunit\newblock
		%Series Block (including note field) --------------------------------
		\iftoggle{printseriesflag}%Print series info only when option is set
			{\iffieldundef{series}
				{\relax}%
				{\usebibmacro{series+number}%
				\setunit{\addcomma\addspace}}}%
			{\relax}%
		\printfield{note}%
		\newunit\newblock
		%Publishing Data Block ------------------------------------------------
		\usebibmacro{publisher+location+year}%
		\newunit\newblock
		%Online locators----------------------------------------------------------
		\usebibmacro{onlinelocation}%
		}%Endif, end of bibliography routine
\newunit\newblock
%Addendum and finish------------------------------------------------------
\printfield{addendum}%
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}% End of refernece driver


\renewbibmacro{byauthor}{%
  \ifboolexpr{
%    test \ifuseauthor
%    or
    test {\ifnameundef{author}}
  }
    {}
    {\usebibmacro{bytypestrg}{author}{author}%
     \setunit{\addspace}%
     \printnames[byauthor]{author}}}
     
%%%%%%      REPORT      %%%%%%

%Reports are treated like books, even though they have some extra fields
\DeclareBibliographyAlias{report}{book}%
  
%%%%%%      THESIS      %%%%%%

\DeclareBibliographyDriver{thesis}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\labelnamepunct}\newblock
\iffieldundef{title}
	{\iffieldundef{titleaddon}
		{\relax}%
		{\usebibmacro{title}}}%
	{\usebibmacro{title}}%
\iffieldundef{note}
	{\relax}
	{\newunit\newblock
	\printfield{note}}%
\iffootnote
	{%then footnote environment: open parentheses
		\setunit{\addspace\bibleftparen}}%
    {%else bibliography environmemt: just start a new unit
    		\newunit}%
\iffieldbibstring{type}
	{\bibstring{\thefield{type}}}%
	{\printfield{type}\isdot}%
\setunit{\addcomma\space}%Yes, comma here, even in bibliography
\printlist{institution}%
\setunit*{\addcomma\addspace}%
\usebibmacro{year}%
\iffootnote
	{%then footnote environment: close parentheses
		\printtext{\bibrightparen}\setunit{\addspace}}%
    {%else bibliography environmemt: just start a new block
    		\newunit\newblock}%
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End thesis driver

%%%%%%      UNPUBLISHED      %%%%%%

%For unpublished sources, such as conference presentations or drafts: a little more structure and extra fields than in biblatex standard; note field before howpublished; in footnotes for conference papers, location, sponsorship and date go in parentheses
\DeclareBibliographyDriver{unpublished}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor/translator}%
\setunit{\labelnamepunct}\newblock
\iffieldundef{title}
	{\iffieldundef{titleaddon}
		{\relax}%
		{\usebibmacro{title}}}%
	{\usebibmacro{title}}%
\iffieldundef{note}
	{\relax}
	{\newunit\newblock
	\printfield{note}}%
\iffootnote
	{%then footnote environment: open parentheses
		\setunit{\addspace\bibleftparen}}%
    {%else bibliography environmemt: just start a new unit
    		\newunit}%
\printfield{type}%
\setunit*{\addcomma\space}%Yes, comma here, even in bibliography
\printfield{howpublished}%
\setunit*{\addcomma\addspace}%
\iffieldundef{eventtitle}
	{\relax}%
	{\printtext[title]{\printfield[titlecase]{eventtitle}}}%
\setunit*{\addcomma\addspace}%
\printlist{organization}%
\setunit*{\addcomma\addspace}
\printfield{venue}%
\setunit*{\addcomma\addspace}%
%Just one date; no separate eventdate
\usebibmacro{date-full}%
\iffootnote
	{%then footnote environment: close parentheses
		\setunit{\unspace}\printtext{\bibrightparen}}%
    {%else bibliography environmemt: just start a new block
    		\newunit\newblock
    }%endif
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End unpublished driver

%%%%%%      VIDEO	     %%%%%%%%%%%%%%%%%%

\DeclareBibliographyDriver{video}{%
%Sort out entrysubtypes
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit*{\labelnamepunct\addspace}\newblock
\usebibmacro{title}%
\newunit\newblock
\printfield{edition}%
\newunit
\printfield{type}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\printfield[noformat]{volume}%In case of multiple discs or cassettes in a set
\iffieldundef{booktitle}%
	{%then
		\relax}%
	{%else print title of the set
		\usebibmacro{in:}%
		\usebibmacro{booktitle}%
		\newunit\newblock}%
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeonline}}%
	{%Unstructured formatting of publishing info for online multimedia
		\printlist{organization}%
		\newunit
		\printlist{institution}%
		\newunit
		\printlist{publisher}%
		\newunit
		\printfield{howpublished}%	
		\newunit
		\printfield{usera}%
		\newunit
		\printfield{userd}}%End online routine
	{%Else use booklike location:publisher format
		\iffootnote%
			{%then in parentheses
				\setunit{\addspace}%
				\printtext{\bibleftparen}%
				\usebibmacro{publisher+location+year}%
				\printtext{\bibrightparen}}%
			{%else without parentheses
				\usebibmacro{publisher+location+year}}%
	}%End if; end publisher/location info
\newunit\newblock
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%end video driver    
  
%%%%%%      CUSTOMA       %%%%%%

%Custom entry type for archival collections
\DeclareBibliographyDriver{customa}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%Prints nameaddon and labelnamepunct, too
\usebibmacro{getcustomainfo}%
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%End customa driver

%Common formatting routine for customa and crossreferences to customa
\newbibmacro{getcustomainfo}{%----------------------------------------------
\printfield[titlecase]{title}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\printlist{organization}%
\setunit*{\addcomma\space}
\printlist{institution}%
\setunit*{\addcomma\space}
\printfield{library}%
\setunit*{\addcomma\space}%
\printlist{location}%
\newunit
\printfield{type}%
\newunit
\printfield{usera}%
\newunit\newblock
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
}%end getcustomainfo

%%%%%%      CUSTOMD      %%%%%%

%Custom entrytype D for archival documents (quasi `inarchive' or `incustoma') 
\DeclareBibliographyDriver{customd}{%
%Add key to noteonly category
\addtocategory{noteonly}{\thefield{entrykey}}%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\clearfield{title}\clearfield{subtitle}\clearfield{titleaddon}%
\setunit{\addspace}%
\printnames{namec}% Needed for the occasional letter, interview
\setunit{\addcomma\addspace}%
\printfield{type}%
\setunit{\addcomma\addspace}%
\printfield{venue}%
\setunit{\addcomma\addspace}%
\printfield{note}%
\setunit{\addcomma\addspace}%
\usebibmacro{date-full}%
\newunit\newblock
\iffieldundef{xref}%
	{%then no xref; just print what's likely to be available in the customd
		\iffieldundef{booktitle}
			{%then improvise
				\printfield{howpublished}%
				\setunit*{\addcomma\addspace}%
				\printlist{organization}%
				\setunit*{\addcomma\addspace}%
				\printlist{institution}%
				\setunit*{\addcomma\addspace}%
				\printfield{library}%
				\setunit*{\addcomma\addspace}%
				\printfield{userd}%
				\newunit\newblock
				\usebibmacro{volume+pages}%
				}%
			{%else assume it's from a published collection
				\usebibmacro{in:}%
				\usebibmacro{getbookinfo}%
				}% 
		\newunit\newblock
		\usebibmacro{onlinelocation}%
		}%
	{%else x-ref to collection or customa or online
		\printtext{\unspace}%Just to force the unit punctutation before the xref
		%Save page range for bibliography
			\savefield{pages}{\childpages}%
			\savefield{volume}{\childvolume}%
			\savefield{part}{\childpart}%
		\iffootnote
			{\cbx@crosstoarch{\thefield{xref}}}%
			{\bbx@crosstoarch{\thefield{xref}}}%
		\newunit\newblock
		\printfield{userd}%
		\newunit\newblock
		\iffootnote
			{\usebibmacro{volume+pages}%
			\newunit\newblock}%
			{\relax}%Volume, pages should already have been printed
		}%endif, end xref routine
\newunit\newblock
\usebibmacro{onlinelocation}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}%end customd driver

%%%%%	CUSTOMD AS FALLBACK TYPE		%%%%%

\DeclareBibliographyAlias{*}{customd}
  
%%%%%      OTHER TYPES, NOT EXPLICITLY SUPPORTED      %%%%%%

\DeclareBibliographyAlias{review}{article}
\DeclareBibliographyAlias{suppbook}{inbook}
\DeclareBibliographyAlias{suppcollection}{incollection}
\DeclareBibliographyAlias{suppperiodical}{article}


%%%%%	SUBROUTINES	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%----------------------------------------------------------------------------------
%					SUBROUTINES OF INBOOK/INCOLLECTION, etc.
%
%For adding book data to an inbook, incollection, or other subordinate record. (One set of routines, for any combination of entrytypes.)
%---------------------------------------------------------------------------------

%Get rid of colon before booktitle in incollection and allow other prepositions, depending on subtype
\renewbibmacro*{in:}{%
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeintro}}%
	{%Then1:`to' instead of `in'
		\setunit{\addspace\bibstring{introto}\addspace}}%
	{%Else1
		\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeexcerpt}}%
			{%Then2 ``from''
				\setunit{\addspace\bibstring{excerptfrom}\addspace}}%
			{%Else2
				\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypevolume}%
					\OR\equal{\thefield{entrytype}}{\entrytypebookinbook}}%
					{%Then3 ``volume...of''
						\setunit{\addspace\bibstring{volumeof}\addspace}}%
					{%Else3
						\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypenone}%
							\or {\equal{\thefield{entrysubtype}}{\subtypemag}}%
							\or {\equal{\thefield{entrytype}}{\entrytypearchive}}%
							\or {\equal{\thefield{entrysubtype}}{\subtypenewsp}}%
							\or {\equal{\thefield{entrysubtype}}{\subtypevideo}}%
							\or {\equal{\thefield{entrytype}}{\entrytypeonline}}%
							\or {\equal{\thefield{entrytype}}{\entrytypeaudio}}%
							\or {\equal{\thefield{entrysubtype}}{\subtypeearlybook}}}%
							{%Then4 no linking preposition at all
								\relax}%
							{%Else4 check for special case after an xref
								\iftoggle{xrefflag}
									{%Then5 have to capitalize manually in bibliography
										\ifbibliography
											{\bibcpstring{in}\addspace}%
											{\bibstring{in}\addspace}}%
									{%else5 default ``in''
										\bibstring{in}\addspace%
									}%end else5
							}%end else4
					}%end else3
			}%end else2
	}%end else1
}%end macro in:

\newbibmacro{getbookinfo}{%------------------------------------------------------
	%Booktitle and Editor Block (including special fields for proceedings)
	\usebibmacro{getbooktitle}%
	\setunit{\addcomma\addspace}%
	%Special fields from entrytypes proceedings or inproceedings
	\usebibmacro{getproceedingsfields}%
	\setunit{\addcomma\addspace}%
	%Now find all the book-level authors and editors
	\usebibmacro{getbookauthoreditor}%
	\newunit\newblock
	%Maintitle Block, including page numbers ---------------------------------------
	%Check whether the book is part of a multivolume set
	\iffieldundef{maintitle}
		{%No maintitle (or maintitle was used instead of booktitle, then cleared)
			\relax}%
		{%\ifthenelse{\iffieldundef{title}\and\iffieldundef{titleaddon}}
			{%no separate volume title (or titleaddon for untitled excerpts) 
				\relax}%
			{\usebibmacro{booktitle+maintitle-multivolume}}}%
	\setunit{\addcomma\addspace}%
	\iffootnote
		{%then pages will come from the postnote field
			\relax}%
		{%else restore child's volume and page range for bibliography
			\restorefield{pages}{\childpages}%
			\iftoggle{volumeprinted}
				{\relax}%
				{\restorefield{volume}{\childvolume}%
				\restorefield{part}{\childpart}}%
			\usebibmacro{volume+pages}%
			}%
	\newunit\newblock
	%Edition Block------------------------------------------------------
	\printfield{edition}%
	\newunit\newblock
	%Series Block (including note field) --------------------------------
	\iftoggle{printseriesflag}%Print series info only when option is set
		{\iffieldundef{series}
			{\relax}%
			{\usebibmacro{series+number}%
			\setunit{\addcomma\addspace}}}%
		{\relax}%
	\printfield{note}%
	\newunit\newblock
	%Special fields-----------------------------------------------------
	\printfield{type}%
	\newunit
	\printfield{version}%
	\newunit\newblock
	%Location: Publisher, Year Block ------------------------------------------
	\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeearlybook}}
		{%Then no publishing data for early English literature
			\relax}%
		{%Else full publishing data, in parens in footnotes
			\iffootnote%
				{%then in parens
					\setunit{\addspace}%
					\printtext{\bibleftparen}%
					\usebibmacro{publisher+location+year}%
					\printtext{\bibrightparen}}%
				{%else no parens in bibliography
					\usebibmacro{publisher+location+year}}%
			}%
}%end macro getbookinfo

%Choose appropriate book-title routine for incollection-like entries
\newbibmacro{getbooktitle}{%----------------------------------------------------
\iftoggle{xrefflag}%
	{%then record is book/collection-like, accessed via xref: find title in title field.
		\usebibmacro{title}%
		}%endthen; end of xref routine
	{%else current record inbook/incollection-like; look in booktitle field
		\iffieldundef{booktitle}
			{%then user must have filled in maintitle instead of booktitle
				\usebibmacro{title+maintitle}%
				\clearfield{maintitle}%Prevents repetition later, in case of multivolume sets
				}%
			{%else booktitle available, but might be redundant
				\iffieldsequal{booktitle}{title}%
					{%then no distinct booktitle after all; again, use maintitle
						\usebibmacro{title+maintitle}%
						\clearfield{maintitle}%Prevents repetition later, in case of multivolume sets
						}%
					{%else normal case with distinct title and booktitle
						\usebibmacro{booktitle+maintitle}%
						}%
				}%endelse; endiffieldundef
		}%
}%end macro getbooktitle
    
\newbibmacro{getbookauthoreditor}{%--------------------------------------------------
	\ifnameundef{bookauthor}
		{%then1 No bookauthor in current record; either it's not an inbook or there's no distinct part author. Check whether current author is different from saved author from the inbook record
			\ifnameequals{author}{\childauthor}%
				{%then2 no need to print the same name again
					\relax}%
				{%else2 current record is the book and has a different overall author from the inbook
					\setunit*{\addcomma\addspace\bibstring{byline}\addspace}%
					\printnames[byauthor]{author}%
				}%end else2, end ifnameequals
		}%end then1
		{%else1 current record has a book author; must be an inbook. Print the bookauthor if distinct from the part author (the bybookauthor macro will compare)
			\setunit{\addcomma\addspace\bibstring{byline}\addspace}%
			\usebibmacro{bybookauthor}%Redefined below
		}%end else1, end iffieldundef
	\setunit{\addcomma\addspace}%
	\usebibmacro{byeditor+others}%
}%end macro getbookauthoreditor

\renewbibmacro*{bybookauthor}{%--------------------------------------------
  \ifnamesequal{author}{bookauthor}
    {%No distinct bookauthor
    		\relax}%
    {%Print book author, firstname first
    		\printnames[byeditor]{bookauthor}}%
}%end macro bybookauthor

\newbibmacro{getproceedingsfields}{%---------------------------------------------
%For now, they will be printed whenever they are present--no test for entrytype
\ifthenelse{\equal{\thefield{editortype}}{\edtypecorp}}
	{%then corporate editor already printed and organization redundant
  		\relax}%
  	{%else print the name of the organization
		\printlist{organization}}%
\setunit{\addcomma\addspace}%
\printfield[titlecase]{eventtitle}%
\setunit{\addcomma\addspace}%
\printfield{venue}%
\setunit{\addcomma\addspace}%
\iffieldundef{eventdate}
	{\relax}%
	{\printeventdate}%
}%end macro

%For inbook and incollection, when the parent is in a multivolume work.
\newbibmacro*{booktitle+maintitle}{%-------------------------------------------------
\iffieldsequal{maintitle}{booktitle}
	{%then maintitles are superfluous
		\clearfield{maintitle}%
    	\clearfield{mainsubtitle}%
		\clearfield{maintitleaddon}}%
    {%else
    		\iffieldundef{maintitle}
    			{%Then: only one title--but is reference to a volume or the whole work?	
					\usebibmacro{booktitle}%
					\iffootnote
						{\setunit{\addspace}%
						\printfield[parens]{userb}}%
						{\newunit
						\printfield{userb}}%
					\setunit{\newunitpunct}%
					\iffieldundef{volume}
						{%Then: no volume number, so must be an independent work
							\printfield{volumes}}%
						{%Else: volume specified, so give the volume- and part numbers
							\ifthenelse{\equal{\thefield{entrytype}}{\entrytypecoll}%
							\OR\equal{\thefield{entrytype}}{\entrytypebook}
							\OR\equal{\thefield{entrytype}}{\entrytyperef}
							\OR\equal{\thefield{entrytype}}{\entrytypeproc}}%
								{\printfield{volume}\printfield{part}%
								\clearfield{volume}\clearfield{part}}%
							{\relax}%
						}%endiffieldundef volume
					}%endthen
     		{%Else: Separate maintitle and volume title, so give  volume title here. Maintitle will come after the editor
				\usebibmacro{booktitle}%
				\iffootnote
					{\setunit{\addspace}%
					\printfield[parens]{userb}}%
					{\newunit
					\printfield{userb}}%
	 			}%Endif
		}%Endif
}%end macro booktitle+maintitle


\newbibmacro{booktitle+maintitle-multivolume}{%-------------------------------------
%Prints volume-titles and maintitles of multivolume incollections; 
% special case of book excerpt in an anthology also handled here
	\iffieldundef{volume}
		{%then print `in Maintitle'
			\setunit{\newunitpunct\addspace\bibstring{in}\addspace}%
			}%
		{%else print `vol. 1 of Maintitle'
			\printfield{volume}%
			\printfield{part}%
			\setunit{\addspace\bibstring{volumeof}\addspace}%
			\toggletrue{volumeprinted}%Something wrong. Doesn't work globally, so clear everything
			\clearfield{volume}\clearfield{part}\savefield{volume}{\childvolume}\savefield{part}{\childpart}%
			}%
	\usebibmacro{maintitle}%
	%Setunit in subroutine
	\usebibmacro{collectioneditor}%
}%end nmacro booktitle+maintitle-multivolume



%----------------------------------------------------------------------
%							GETBOOKINFO-SHORT
%
%	For adding book-level data from the reference entrytype
%   (Used when crossreferencing, under the shortincoll option)
%----------------------------------------------------------------------
\newbibmacro*{getbookinfo-short}{%
\ifnameundef{labelname}
    {\printfield{label}}%
    {\printnames{labelname}}%
\ifsingletitle
    {\relax}%
    {\setunit*{\addcomma\space}%
	\printtext[title]{\printfield[titlecase]{labeltitle}}}%
}%end macro getbookinfo-short


%-----------------------------------------------------------------------------------
%						SUBROUTINES OF BOOK, COLLECTION, etc.
%
%	Publisher-Location-Year: Generalized routines for original publishing data and reprint data, from all the book-like entrytypes.
%-----------------------------------------------------------------------------------

\newbibmacro*{publisher+location+year}{%---------------------------------------------
%Check whether the entry is a reprint (i.e., whether it has ``orig'' data)
\ifthenelse{\equal{\reprintoption}{\optionnoreprints}}
	{\relax}%
	{\usebibmacro{reprinttest}}%
%(New unit has been set in the subroutine)
%Print location, publisher, and year
\iflistundef{location}
	{%Then no location, no automatic n.p., no colon
		\relax}%
	{%Else location and colon
		\usebibmacro{printlocation}%
		\midsentence% In case of question mark after location
		\setunit*{\addcolon\addspace}%
		}%
\iflistundef{publisher}
	{%then use institution instead of publisher
		\iflistundef{institution}
			{%then no institution either; try howpublished
				\iffieldundef{howpublished}
					{%then no publishing data available
						\iflistundef{location}
							{%then publisher, location both blank
								\iffootnote
									{%then no puctuation before date 
										\setunit{\unspace}}%
									{%else
										\newunit}%
								}%
							{%else location, but no publisher
								\setunit{\addcomma\addspace}}%
						}%
					{%else use howpublished field
						\printfield{howpublished}%
						\setunit{\addcomma\addspace}}%
				}%
			{%else institution instead of publisher
				\printlist{institution}%
				\setunit{\addcomma\addspace}%
				}%
		}%
	{%else use publisher field and ignore howpublished and institution
		\printlist{publisher}%
		\setunit{\addcomma\addspace}%
		}%
\usebibmacro{year}%
}%end publisher+location+year

\newbibmacro{printlocation}{%-------------------------------------------------
\ifthenelse{\equal{\thelist{location}}{\noplace}}%Something wrong here. Can't get it to recognize ``np'' in the location list
	{\bibstring{noplace}}%
	{\printlist{location}\isdot}%
}%end macro printlocation

\newbibmacro{reprinttest}{%----------------------------------------------------
\toggletrue{origdataflag}%
\iffieldundef{origyear}%
	{%then no origyear
		\iflistundef{origlocation}%
			{%then no origyear or origlocation
				\iflistundef{origpublisher}
					{%then not enough orig data for default reprint routine
						\iffieldundef{origtitle}%
							{%then not enough orig data for the other options, either
								\togglefalse{origdataflag}}%
							{%else
								\relax}}%
					{%else origpublisher, but no location; entry can still be a reprint
						\usebibmacro{reprintorigfirst}}}%
			{%else origlocation but no origyear; entry can still be a reprint
				\usebibmacro{reprintorigfirst}}}%
	{%else At least origyear available; entry is a reprint
			\usebibmacro{reprintorigfirst}}%
}%end macro reprinttest

\newbibmacro{reprintorigfirst}{%-----------------------------------------------
\ifthenelse{\not\equal{\reprintoption}{\optionorigfirst}}
	{%then original data will be added later (or not at all)
		\relax}%
	{%else default reprint routine: print original data first
		\printlist{origlocation}%
		\iflistundef{origpublisher}
			{\setunit*{\addcomma\addspace}%
				}%
			{\setunit*{\addcolon\addspace}%
			\printlist{origpublisher}%
			\setunit*{\addcomma\addspace}%
				}%
		\iffieldundef{origyear}
			{\bibstring{nodate}}%
			{\printorigdate}%
		\iffootnote
			{%then Footnote environment: use semicolon and abbreviation
				\addsemicolon\addspace\bibstring{reprint}}%
			{%else bibliography: use newunitpunct and long bibstring
				\newunit\bibstring{reprint}}%
		\setunit{\addcomma\addspace}
	}%End else
}%End macro reprintorigfirst

\newbibmacro{addoriginaledition}{%--------------------------------------------
%Check whether original data were entered
\iftoggle{origdataflag}
	{%Then1 introduce orig data with appropriate string
		\iffieldundef{origtitle}
			{%then2 without origtitle
				\iffootnote
					{\bibstring{origedition}}%
					{\bibstring{origeditionbib}}%
				\setunit*{\addcomma\addspace}%
				\printlist{origlocation}%
				\setunit*{\addcomma\addspace}%
				\printorigdate}%
			{%else2 with origtitle
				\iffootnote
					{\bibstring{origeditiontitled}}%
					{\bibstring{origeditiontitledbib}}%
				\setunit{\addcomma\addspace}
				\printtext[title]{\printfield[titlecase]{origtitle}}\addspace%
				\iflistundef{origlocation}
					{\mkbibparens{\printorigdate}}%
					{\printtext[parens]%
						{\printlist{origlocation}%
						\setunit*{\addcomma\addspace}%
						\printorigdate}}%
			}%end else2
		}%End then1
	{%Else1 nothing to print
		\relax
	}%endelse1
}%End macro addoriginaledition

\newbibmacro{addtransfrom}{%--------------------------------------------------
%Check whether original data were entered
\iftoggle{origdataflag}
	{%Then1 introduce orig data with appropriate string
		\iffieldundef{origtitle}
			{%then2 without origtitle
				\iffootnote
					{\bibstring{origedition}}%
					{\bibstring{origeditionbib}}%
				\setunit{\addcomma\addspace}%
				\printlist{origlocation}%
				\setunit*{\addcomma\addspace}%
				\printorigdate}%
			{%else2 with origtitle
				\iffootnote
					{\bibstring{translatedfromtitle}}%
					{\bibstring{translatedfromtitlebib}}%
				\setunit{\addspace}%
				\printtext[title]{\printfield[titlecase]{origtitle}}\addspace%
				\iflistundef{origlocation}
					{\mkbibparens{\printorigdate}}%
					{\printtext[parens]%
						{\printlist{origlocation}%
						\setunit*{\addcomma\addspace}%
						\printorigdate}}%
			}%end else2
	}%End then1
	{%Else1 nothing to print
		\relax}%
}%End macro addtransfrom


\newbibmacro{origtransas}{%--------------------------------------------------
% Swap orig-fields for normal fields
\savefield{title}{\temptitle}\savefield{origtitle}{\temporigtitle}%
\savelist{location}{\templocation}\savelist{origlocation}{\temporiglocation}%
\savelist{publisher}{\temppublisher}\savelist{origpublisher}{\temporigpublisher}%
\iffieldundef{date}
	{\savefield{pubstate}{\tempyear}}%
	{\savefield{date}{\tempdate}}%
\savefield{origdate}{\temporigdate}%
\restorefield{title}{\temporigtitle}\restorefield{origtitle}{\temptitle}%
\restorelist{location}{\temporiglocation}\restorelist{origlocation}{\templocation}%
\restorelist{publisher}{\temporigpublisher}\restorelist{origpublisher}{\temppublisher}%
\restorefield{origdate}{\tempdate}\restorefield{date}{\temporigdate}%
}%End macro origtransas

\newbibmacro{print-translation-data}{%----------------------------------------
	\ifnameundef{translator}
		{\ifbibliography
			{\setunit{\addspace\bibstring{translatedasbib}\addspace}}%
			{\setunit{\addspace\bibstring{translatedas}\addspace}}%
			}%
		{\ifbibliography
			{\bibstring{bytranslatorbib}\addspace}%
			{\bibstring{bytranslator}}%
			\printnames[byauthor]{translator}
			\setunit{as\addspace}}%
	\printtext[title]{\printfield[titlecase]{origtitle}}%
	\ifthenelse{\iflistundef{origlocation}\and\iflistundef{origpublisher}\and\iffieldundef{origyear}}
		{%then no more orig-data
			\relax}%
		{%else orig-data go in parentheses
			\addspace\bibleftparen
			\printlist{origlocation}%
  			\iflistundef{origpublisher}
   				{\setunit*{\addcomma\space}}
				{\setunit*{\addcolon\space}}%
			\printlist{origpublisher}%
			\setunit*{\addcomma\space}%
			\printorigdate
			\bibrightparen}%
}%end macro print-translation-data


%----------------------------------------------------------------------
%							GETARCHIVEINFO 
%
%	For adding collection data from customa or other parent entrytype
%   (Used when crossreferencing from customd or letter)
%----------------------------------------------------------------------
\newbibmacro{getarchiveinfo}{%-----------------------------------------
\usebibmacro{bibindex}%
%\usebibmacro{in:}%
\ifthenelse{\equal{\thefield{entrytype}}{\entrytypearchive}}%
	{%Then archive: print name of collection, first name first, then use main archive routine
		\printnames[byeditor]{author}%
		\setunit{\addspace}%
		\printfield{nameaddon}%
		\usebibmacro{getcustomainfo}}%End main archive routine
	{%Else not an archive
		\ifthenelse{\equal{\thefield{entrytype}}{\entrytypeonline}}%
			{%Then it's an online database
				\usebibmacro{title}%
				\newunit\newblock
				\usebibmacro{byeditor}%
				\newunit\newblock
				\printfield{note}%
				\newunit\newblock
				\printlist{organization}%
				\newunit\newblock
				\iftoggle{xrefflag}
					{\relax}%
					{\usebibmacro{onlinelocation}
					\newunit\newblock}%
				\printfield{addendum}%
			}%
			{%Else use collection routine
				\usebibmacro{getbookinfo}}%
	}%Endif
}%End macro getarchiveinfo

%-----------------------------------------------------------------------------
%			TITLE and SERIES Routines (for all booklike, inbook-like entrytypes)
%
%-----------------------------------------------------------------------------

\newbibmacro*{title+maintitle}{%------------------------------------------
%Title (from Title-field) already printed. See if there is a maintitle, too.
\iffieldsequal{maintitle}{title}
	{%Then maintitle superfluous
		\clearfield{maintitle}\clearfield{mainsubtitle}\clearfield{maintitleaddon}}%
	{%Else distinct maintitle
		\relax}%
\iffieldundef{maintitle}
	{%Then there's only one title--but is it a volume or an entire work?
		\iffieldundef{volume}
			{%Then: no volume number, so must be an entire work. Give no. of volumes
				\iftoggle{volumeprinted}
					{\relax}%exception for subtype volume after x-ref
					{\printfield{volumes}}%
				}%
			{%Else: a volume no. is specified, so give the volume- and part numbers
				\printfield{volume}\printfield{part}%
				}%
		}%
  	{%Else Two-level title: print `vol. 1 of maintitle'
		\printfield{volume}\printfield{part}%
		\setunit{\addspace\bibstring{volumeof}\addspace}%
		\usebibmacro{maintitle}%
		}%
}%end macro title+maintitle


\renewbibmacro*{series+number}{%---------------------------------------------
  \printfield[titlecase]{series}%
  \setunit*{\addspace}%
  \printfield{number}%
  \newunit
}%end macro series+number

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------
%					SUBROUTINES FOR ARTICLES, PERIODICALS
%
%----------------------------------------------------------------------------
%Put in city for newspapers, but print it in Roman
\renewbibmacro*{journal}{%---------------------------------------------------
\iffieldundef{journaltitle}
	{%then
		\relax}%
	{%else
		\printtext[noformat]
			{\printfield[journaltitle]{journaltitle}%
			\setunit{\subtitlepunct}%
			\printfield[journaltitle]{journalsubtitle}
			\iflistundef{location}
				{\relax}%
				{\setunit{\addspace}
				\printtext{\bibleftparen}
				\unspace
      		 	\printlist[location]{location}
				\unspace\printtext{\bibrightparen}
				}%end iflistundef
			\unspace
			}%end printtext
	}% end iffieldundef
}%end macro journal
	
\renewbibmacro*{journal+issuetitle}{%------------------------------------------------
%Restore any location data from the child (aritcle) record that is undefined in the parent (periodical). 
\iffieldundef{issuetitle}
	{\restorefield{issuetitle}{\childissuetitle}%
	\restorefield{issuesubtitle}{\childissuesubtitle}}%
	{\relax}%
\iffieldundef{issuetitle}
	{\relax}%
	{\usebibmacro{issue}%Prints issuetitle
	\setunit{\addcomma\addspace}%
	\usebibmacro{bytranslator+others}%Use translator and editors from parent record in any case
    \setunit{\addcomma\addspace}%
	\usebibmacro{byeditor+others}%
	\newunit}%
\iffieldundef{note}
	{\restorefield{note}{\childnote}}%
	{\relax}%
\iffieldundef{note}
	{\relax}%
	{\printfield{note}%
	\setunit{\addcomma\addspace}}%
\ifthenelse{\equal{\thefield{entrytype}}{\entrytypeper}}%
	{\usebibmacro{periodical}}%
	{\usebibmacro{journal}}%
\setunit{\addcomma\addspace}%
\iffieldundef{entrysubtype}%
	{\restorefield{entrysubtype}{\childsubtype}}%
	{\relax}%
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypemag}%
	\OR \equal{\thefield{entrysubtype}}{\subtypenewsp}}%
	{%Then cite magazines and newspapers by date, without parens
		\usebibmacro{issue+date-mag}}%
	{%Else default routine, with parens
		\iffieldundef{series}
			{\restorefield{series}{\childseries}}%
			{\relax}%
		\iffieldundef{series}
			{\setunit*{\addspace}}%
			{\setunit{\addcomma\addspace}%
			\printfield{series}%
			\setunit{\addcomma\addspace}}%
		\iffieldundef{volume}
			{\restorefield{volume}{\childvolume}}%
			{\relax}%
		\printfield{volume}%
		\iffieldundef{number}
			{\restorefield{number}{\childnumber}}%
			{\relax}%
		\iffieldnums{number}
			{%then could be a single number or a range
				\iffieldnum{number}
					{%then use singular of bibstring
						\setunit{\addcomma\addspace\bibstring{number}\addspace}}%
					{%else use the plural
						\setunit{\addcomma\addspace\bibstring{numbers}\addspace}}%
				}%
			{%else not a number at all; leave out the bibstring
				\setunit{\addcomma\addspace}%
				}%
		\printfield{number}%
		\setunit{\addspace}%
		\iffieldundef{issue}
			{\restorefield{issue}{\childissue}}%
			{\relax}%
		\iffieldundef{year}
			{\restorefield{year}{\childyear}}%
			{\relax}%
		\iffieldundef{date}
			{\restorefield{date}{\childdate}}%
			{\relax}%
		\usebibmacro{issue+date}%
	}%
}%end macro journal+issuetitle

\renewbibmacro*{issue+date}{%---------------------------------------------
\printtext[parens]{%
	\iffieldundef{issue}
      {\usebibmacro{date-full}}%
      {\printfield{issue}%
       \setunit{\addspace}%
       \usebibmacro{year}}}%
  \newunit}%end macro issue+date

\newbibmacro*{issue+date-mag}{%---------------------------------------------
	\printtext[noformat]{%Get rid of parens
		\iffieldundef{issue}
			{\usebibmacro{date-full}}%
			{\printfield{issue}%
			\setunit{\addspace}%
			\usebibmacro{year}}%
		\newunit}%
}%end macro issue+date-mag



%For entrytype periodical: adjust punctuation
\renewbibmacro*{title+issuetitle}{%-----------------------------------------
\iffieldundef{issuetitle}
	{%then untitled issue
		\relax}%
	{%else special case of issue with own title and/or editor
		\usebibmacro{issue}%
		\setunit{\addcomma\addspace}%
		\usebibmacro{byeditor+others}%
		\newunit}%
\iffieldundef{note}
	{}%
	{\printfield{note}\setunit{\addcomma\addspace}}%
\usebibmacro{periodical}%
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypemag}%
			\OR\equal{\thefield{entrysubtype}}{\subtypenewsp}}%
	{%then special treatment for newspapers and magazines
		\newunit
		\usebibmacro{issue+date-mag}%
		}%endthen; end newsp/mag routine
	{%else standard journal article
		\iffieldundef{series}
			{\setunit*{\addspace}}%
			{\setunit{\addcomma\addspace}%
			\printfield{series}%
			\setunit{\addcomma\addspace}}%
		\printfield{volume}%
		\iffieldnum{number}
			{\setunit{\addcomma\addspace\bibstring{number}\addspace}}%
			{\iffieldnums{number}
				{\setunit{\addcomma\addspace\bibstring{numbers}\addspace}}%
				{\relax}}%
		\printfield{number}%
		\setunit{\addspace}%
		\usebibmacro{issue+date}%
		}%end else; end journal article routine
	}%end macro title+issuetitle

\renewbibmacro*{periodical}{%
  \iffieldundef{title}
    {}%
    {\printtext[]{%
       \printfield[]{title}%
       \setunit{\subtitlepunct}%
       \printfield[]{subtitle}}}}

%-----------------------------------------------------------------------------
%						ONLINE LOCATORS (all entrytypes)
%
%-----------------------------------------------------------------------------

\newbibmacro{onlinelocation}{%-----------------------------------------------
\iftoggle{urllastflag}
	{%then special case (from footciteurllast command); postnote comes first
		\usebibmacro{cite:postnote}}%
	{%else let cbx do the postnote as usual
		\relax}%
\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeonline}%
	\OR\equal{\thefield{entrytype}}{\entrytypeonline}}%
	{%then override the option settings for these entrytypes/subtypes
		\printfield{doi}%
		\newunit\newblock%
		\usebibmacro{eprint}%
		\newunit\newblock%
		\iffieldundef{url}%
			{\relax}%
			{\usebibmacro{url+urldate}}%
		}%end then; end override
	{%else use standard routine for online locators
		\usebibmacro{doi+eprint+url}%
	}%end ifthenelse
}%end macro onlinelocation

%--------------------------------------------------------------------------------
%			LOWER-LEVEL ROUTINES, for title, author, editor, year, pubstate
%
%--------------------------------------------------------------------------------

%Standard routine for titles. 
\renewbibmacro*{title}{%---------------------------------------------------------
%Substitute shorttitle where required
\iffootnote
	{\iffieldundef{shorttitle}
		{\relax}%
		{\iftoggle{useshorttitles}%
			{%then shorttitle option is set: replace title with shorttitle
				\clearfield{title}\clearfield{subtitle}%
				\savefield{shorttitle}{\temptitle}%
				\restorefield{title}{\temptitle}}%
			{%else check entrysubtype
				\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeearlybook}
							\or\equal{\thefield{entrytype}}{\entrytyperef}}
					{%Use shorttitles here, too
						\clearfield{title}\clearfield{subtitle}%
						\savefield{shorttitle}{\temptitle}%
						\restorefield{title}{\temptitle}}%
					{\relax}%
			}%end iftoggle
		}%end iffeldundef
	}%end then, end footnote routine		
	{\relax}% No shorttitles in bibliography
\iffieldundef{title}%
	{%then print titleaddon even without title (e.g. for describing untitled works), without preceding punctuation
		\printtext[titlecase]{\printfield{titleaddon}}\isdot%
		\setunit{\addspace}%
		\printfield{usera}}%Special use of usera for year of anthologized article
  	{%else both title and titleaddon
		\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypevolume}
			\OR\equal{\thefield{entrysubtype}}{\subtypepublicdocument}
			\OR\equal{\thefield{entrytype}}{\entrytypebookinbook}}%
			{%then special case, when incollection/inbook is a whole volume or a government document whose title needs to be italicized
				\printtext[volumetitle]{%
					\printfield[titlecase]{title}\isdot%
					\iffieldundef{subtitle}
						{\relax}%
						{\setunit*{\subtitlepunct}%
					\printfield[titlecase]{subtitle}}%
					}%end printtext
				}%end then, end subtype volume
			{%else Other subtypes without italics
				\printtext[title]{%
					\printfield[titlecase]{title}\isdot%
					\iffieldundef{subtitle}
						{\relax}%
						{\setunit*{\subtitlepunct}%
					\printfield[titlecase]{subtitle}}}%
				}%end ifthenelse
		\iffieldundef{usere}
			{\relax}%
			{\setunit*{\addspace}\printtext[brackets]{\printfield[titlecase]{usere}}\setunit*{\addcomma\addspace}}%
		\iffieldundef{titleaddon}
			{\relax}%
			{\newunit\printtext[titlecase]{\printfield{titleaddon}}\isdot}%
		\iffieldundef{usera}
			{\relax}%
			{\iffootnote
				{\setunit*{\addspace}%
				\printfield[parens]{usera}}%
				{\setunit*{\newunitpunct}%
				\printfield{usera}}}%
	}%end else, end iffieldundef{title}
}%end macro title

\renewbibmacro*{booktitle}{%
\iffieldundef{booktitle}%
	{%then
		\printtext[titlecase]{\printfield{booktitleaddon}}\isdot
		}%end then
	{%else
		\printtext[booktitle]{%
			\printfield[titlecase]{booktitle}%
			\setunit{\subtitlepunct}%
			\printfield[titlecase]{booksubtitle}}%
		}%end if
	\iffieldundef{booktitleaddon}
		{\relax}%
		{\setunit{\addcomma\addspace}%
		\printtext[titlecase]{\printfield{booktitleaddon}}\isdot}%
}%end macro booktitle


%Also print maintitleaddon even without title, and capitalize in bib
\renewbibmacro*{maintitle}{%------------------------------------------------------
\iffieldundef{maintitle}%
	{%then
		\printtext[titlecase]{\printfield{maintitleaddon}}\isdot
		}%end then
	{%else
		\printtext[maintitle]{%
			\printfield[titlecase]{maintitle}%
			\setunit{\subtitlepunct}%
			\printfield[titlecase]{mainsubtitle}}%
		}%end if
	\iffieldundef{maintitleaddon}
		{\relax}%
		{\setunit{\addcomma\addspace}%
		\printtext[titlecase]{\printfield{maintitleaddon}}\isdot}%
}%end macro maintitle
 
%Handling anonymous/uncertain authorship; nameaddon
\renewbibmacro*{author}{%--------------------------------------------------------
\ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
	{\ifthenelse{\iffieldequals{namehash}{\bbx@lasthash}\AND\NOT\iffirstonpage}
		{\toggletrue{namedashflag}}%
		{\togglefalse{namedashflag}%
		\savefield{namehash}{\bbx@lasthash}}%
	\iftoggle{useshortauthors}
		{\iffootnote%
			{\ifnameundef{shortauthor}
				{\relax}%
				{\savename{shortauthor}{\tempauthor}%
				\restorename{author}{\tempauthor}}%
			}%
			{\relax}}%
		{\relax}%
	\usebibmacro{authortype+nameaddon}}%
{\global\undef\bbx@lasthash}%
}%end macro author

\newbibmacro{authortype+nameaddon}{%--------------------------------------------
\ifuseauthor
	{%then check for anonymous, but known, authorship
		\ifthenelse{\equal{\thefield{authortype}}{\authortypeanon}}
			{%then anonymous author goes in brackets; usual punctuation outside brackets
				\iftoggle{namedashflag}
					{%then dash in place of name in bibliography
						\mkbibbrackets{\bibnamedash}}%
					{%else use name as usual
						\mkbibbrackets{\printnames{author}}%
					}%end iftoggle
				}%endthen; end anonymous
			{%else check for uncertain authorship
				\ifthenelse{\equal{\thefield{authortype}}{\authortypeunsure}}
					{%then question mark in brackets; usual punctuation outside brackets
						\iftoggle{namedashflag}
							{\mkbibbrackets{\bibnamedash\addquestion}}%
							{\mkbibbrackets{\printnames{author}\addquestion}}%
						}%endthen; end uncertain authorship
					{%else no brackets; check for redundant author and suppress in footnotes
						\ifthenelse {\equal{\thefield{authortype}}{\authortyperedundant}}
							{%then
								\iffootnote
									{%then don't print redundant author in footnote
										\relax}%
									{%else print author or dashes in bibliography, even if redundant
										\iftoggle{namedashflag}
											{\bibnamedash}%
											{\printnames{author}}%
									}%end iffootnote
								}%end then
							{%else authortype not redundant, just print as usual
								\iftoggle{namedashflag}
									{\bibnamedash}%
									{\unspace%Why is this necessary?
									\printnames{author}}%
							}%end ifthenelse redundant
					}%endifthenelse unsure
			}%endifthenelse anon; end uncertain/redundant authorship
	\iffieldundef{nameaddon}
		{\relax}%
		{\setunit*{\addspace}%
		\printfield{nameaddon}%
		\iffootnote
			{\ifpunctmark{.}{\isdot}{\relax}}%
			{\relax}%
		\setunit*{\labelnamepunct\addspace}%
			}%
		}%endthen (from ifuseauthor)
    {%else Author not in use
    		\relax
	}%end ifuseauthor
}%end macro authortype+nameaddon

\newbibmacro*{bynamea}{%-----------------------------------------------------------
%Needed for government reports that give the institution as the author, but also
% credit an individual, whose name goes in namea
  \ifnameundef{namea}
    {\relax}
    {\bibstring{byauthor}%
     \setunit{\addspace}%
     \printnames[byauthor]{namea}}}%
    
\newbibmacro*{volume+pages}{%------------------------------------------------------
\iftoggle{volumeprinted}
	{\setunit{\addcomma\addspace}}%
	{\printfield[noformat]{volume}%
	\printfield{part}%
	\iffieldundef{volume}
		{\setunit{\addcomma\addspace}}%
  		{\setunit{\bibpagespunct}}}%
\printfield{pages}%
}%endmacro volume+pages


%Custom field for general editor of a collection containing an edited collection
%Needed when there is both a booktitle and a maintitle. The editora/b/c fields all go with the booktitle. Here nameb goes with the maintitle.
\newbibmacro{collectioneditor}{%----------------------------------------------------
\iffieldundef{namebtype}
	{%no descriptor in nametype field; use bibstring
%		\iffootnote
%			{\setunit{\addcomma\addspace\bibstring{byeditor}\addspace}}%
%			{\setunit{\addcomma\addspace\bibstring{byeditorbib}\addspace}}%
		\setunit{\addcomma\addspace\bibstring{byeditor}\addspace}%
		}%
	{%Get descriptor from nametype
		\setunit{\addcomma\addspace\thefield{namebtype}\addspace}}%
\printnames{nameb}%
}%endmacro collectioneditor



% Date routine, with pubstate and year as fallbacks
\newbibmacro*{date-full}{%---------------------------------------------------------------
	\ifthenelse{\iffieldundef{year}\and\iffieldundef{month}\and\iffieldundef{day}}
		{%then no date; try pubstate
			\iffieldundef{pubstate}%
				{%then nothing available: insert `n.d.'
					\bibstring{nodate}}%
				{%else'substitute pubstate for date
					\printfield{pubstate}}%
			}%end then
		{%else use the standard date routine
			\usebibmacro{date}%
			}%endif
	}%end macro date	
	

% Date routine, with pubstate and year as fallbacks
\newbibmacro*{date-optional}{%---------------------------------------------------------------
	\ifthenelse{\iffieldundef{year}\and\iffieldundef{month}\and\iffieldundef{day}}
		{%then no date; try pubstate
			\iffieldundef{pubstate}%
				{%then nothing available, but don't insert `n.d.'
					\relax}%
				{%else'substitute pubstate for date
					\printfield{pubstate}}%
			}%end then
		{%else use the standard date routine
			\usebibmacro{date}%
			}%endif
	}%end macro date-optional

%Date routine to leave out month and day
\newbibmacro{year}{%------------------------------------------------------------------
	\iffieldundef{year}%
		{%then no year; try pubstate
			\iffieldundef{pubstate}%
				{%then nothing available: insert `n.d.'
					\bibstring{nodate}}%
				{%else substitute pubstate for date
					\printfield{pubstate}}%
			}%
		{%else print the year (or range, if there's an endyear)
			\printfield{year}%
			\iffieldundef{endyear}
				{\relax}%
				{\setunit*{\bibrangedash}%
				\printfield{endyear}}%
			}%
	}% end macro year
	
	
%%%%%%%%  BIBLIOGRAPHY TWEAKS %%%%%%%%%%%%%%%%%%

%When author names repeat, Turabian calls for eight underlines and a period, instead of biblatex's dashes
\renewcommand*{\bibnamedash}{%
%  \ifdim\leftmargin<0.75em
%    \mbox{\textemdash\space}%
%  \else
%    \makebox[\leftmargin][l]{%
%      \ifdim\leftmargin<1.25em
%        \textendash
%      \else
%        \textemdash
%      \fi}%
%  \fi
%\rule[0pt]{8ex}{.5pt}\unspace
\bibstring{namedash}
  }

%%%%%	ANNOTATED BIBLIOGRAPHIES


\renewbibmacro*{finentry}{%
  \iffootnote
    {%then no annotations in the footnotes
    	\finentry}%
    {%else
    	\ifcitation
			{%then annotations in cite commands are handled in the cbx file
				\finentry}
			{%else bibliography environment: annotate if options are set
				\printtext{\finentrypunct}%
				\ifbool{bbx:annotation}
					{%then add annotation in special environment
						\begin{indentannote}
    						\usebibmacro{annotation}%
							\finentry
						\end{indentannote}%
						}%
    				{%else no annotations
    					\finentry}%
    			}%end bibliography
		}%end iffootnote
}%end macro finentry

\endinput