summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/opcit/opcit.dtx
blob: 72c04927bf81cc690488098e587bcf95d9863873 (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
% \iffalse meta-comment
%
% opcit - bibliographical references as footnotes.
% Copyright 2002 Federico Garcia (feg8@pitt.edu, fedegarcia@hotmail.com)
% -------------------------------------------
% 
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License distributed from CTAN archives
% in the directory macros/latex/base/lppl.txt; either version 1 of
% the License, or (at your option) any later version.
%
%
%<*driver>
% \fi
\ProvidesFile{opcit.dtx}[2002/12/25 v1.1 Footnote references]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{opcit.dtx}
\title{\texttt{opcit} (version 2.0)\\a package for footnote-style bibliographical references}
\date{\filedate{}}
 \author{Federico Garcia\\\texttt{feg8@pitt.edu}}
\begin{document}
\maketitle
 \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
%\tableofcontents
%
%\section{New features in version 2}
%
%Users of |opcit| that are familiar with the package will be interested in the following new features:
%
%\begin{itemize}
%\item The bug that used to forbid constructions like |\cite[pp| has been fixed, so you no longer need to type |\cite[p{}p| or |\cite[p\relax p|.
%\item The bibliography style has been fully recoded, and it is more complete now.
%\item Cross-referencing has been implemented, both between bibliographical entries (so that an article in a book makes reference to the book) and between footnotes (so that `\emph{op.~cit.}' is a hyperlink to the footnote where the work was first cited, or alternatively a reference can be made to the footnote number).
%\item A way to omit information in the footnotes (but still list it in the final list) is now available. Using this you can avoid the annoying repetition potential to |@INCOLLECTION| entries, like `\dots\ pages 1--20, p.~13'.
%\item |opcit| now checks whether the optional argument to an \emph{Idem}-citation is identical to the last one, in whose case omits it. This prevents things like two consecutive footnotes both saying `\emph{Idem}, p.~13'. Also, appearance of `\emph{Idem}' only happens if it was the immediately previous footnote that referred to the work.
%\item Global and local mechanisms are provided for turning off either or both `\emph{Idem}' or `\emph{op.~cit.}'\ (substituting |hereafter|'s).
%\end{itemize}
%
%These new features are implemented as options to the package. This means that the previous way to load the package, with a custom \textsc{Bib}\TeX\ style as an option, has changed. See section~\ref{loading} below.
%
%\bigskip
%\noindent This second release of |opcit| owes its existence to both the encouragement and the suggestions I got from John~Scott, the first |opcit| user I knew of (that wasn't an acquaintance of mine).
%
%\section{Introduction}
%
%The basic bibliography styles of \LaTeXe\ and \textsc{Bib}\TeX, with labels between [~and~], are very foreign to the common uses of humanities-writing. In recent times, the category of bibliographical styles known as `author-date' seems to have gained acceptance and become the standard way to refer to a final list of references. This category of styles has been successfully implemented in \LaTeX\ and \textsc{Bib}\TeX, for example in formidable packages such as |natbib|, |achicago|, and |harvard|. 
%
%However, certain disciplines still use the `old way' of footnote-referencing, above all in journal articles, which do not have a final list of `References' to which a key can refer. Author-year styles have the significant drawback that the labels interfere with the flow of the discourse, both in writing and in reading; and, as Susan~King and Oren~Patashnik point out in their `Editorial note' in the |apalike.bst| file, the main reason to use them (that changes to the bibliography does not mean ``changing numbers in both references and text") is rendered meaningless by computerized typography. The `footnote category' of bibliographical styles has not been directly addressed by \LaTeX\ package-writers before |opcit|.
%
%Actually, there \emph{is} a package intended to place the bibliography as footnotes, namely |footbib|.\footnote{By Eric Domenjoud, 1995.} In this package, the labels appear as superscripts---$^{[1]}$---and the information about the source is appended to the bottom of the page. This style is a kind of `hybrid' between footnote and label styles: the numbering of the citations is independent from the footnotes, and if other footnotes (not bibliography ones) appear, they appear separated from the citations.
%
%The system provided by |opcit| makes the references footnotes in the full sense. As is customary in this kind of style, it keeps track of the sources already been cited, in order to avoid multiple copies of the same, potentially long, footnote. So, for `post-citations' (a later citation of a work already cited), it makes automatic use of conventions such as \emph{Idem} and \emph{op.~cit.}---which gives the package its name---or allows the user to set `hereafters' to repeatedly refer to the same publication. 
%
%\bigskip
%\noindent What I regret most about this package is that I was not able to make it `|bst|-independent,' i.e., able to run with any \textsc{Bib}\TeX\ style that the user could possibly want to use. (This, for example, is one of the good things about |footbib|.) The main reason why this was not possible is that |bst| files are designed to print the information in a list, not as footnotes, inserting, for example, periods instead of commas, and giving the author names with last-name first. 
%
%The \textsc{Bib}\TeX\ style I provide in this version is much more complete than that in the first one. However, I have maintained the premise that new styles can be created by the users. To that end, I have greatly expanded the comments to the code of |opcit.bst| below, so its adaptation is easier. As usual, any modification is welcome as long as the file name is changed. Also, if you are creating a new style, I would like to (collaborate and) consider it for inclusion in the |opcit| distribution.
%
%\section{Use}
%
%\subsection{Loading the package}\label{loading}
%
%As usual, you have to load the package with 
%
%|\usepackage[|\meta{options}|]{opcit}|
%
%\noindent The \meta{options}, all new to the second version, are:
%\begin{center}\begin{tabular}{lp{9cm}}\hline
%|custombst| & Allows the user to issue a \verb"\bibliographystyle" command to change the \textsc{Bib}\TeX used by default.\\
%|nocustombst| & To use the default style. This is of course the default option.\\\hline
%|hyperref| & Makes the expression `\emph{op.~cit.}' (or the one set by the user) a hyperlink to the first citation of the reference. Default if the \texttt{hyperref} package has been loaded before |opcit|; otherwise, it is not default.\\
%|nohyperref| & No hyperlinks. Default when package \texttt{hyperref} is not loaded.\\\hline
%|omitting| & Omits certain information, such as pages, volume, series, etc., from the footnotes (you can of course control what is omitted and what is not). Selected by default.\\
%|noomitting| & Turns off the omission mechanism altogether.\\\hline
%|idemcheck| & Checks for identical \emph{Idem}-citations, omitting the optional argument. Selected by default.\\
%|noidemcheck| & Turns off the check.\\\hline
%\end{tabular}\end{center}
%
%See below for detailed information on the effects of these options.
%
%\subsection{Citations}
%\DescribeMacro{\cite}
%The user keeps citing with |\cite|. Thus, |\cite{texbook}| will produce the footnote `\footnote{Donald E. Knuth, \emph{The \TeX book} (Reading, Mass.: Addison Wesley, 1986).}'. The optional argument has the usual meaning, so for example, |\cite[p.~100]{taruskin}| creates `\footnote{Richard Taruskin, \emph{Defining Russia musically: Historical and Hermeneutical Essays} (Princeton: Princeton University Press, 1997), p.~100.}'.
%
%Note that |opcit| adds a period at the end of the footnotes; however, if the user adds it (for example, in |\cite[Introduction.]{gellner}|), it will not: `\footnote{Ernest Gellner, \emph{Thought and change} (Chicago: University of Chicago Press, 1964), introduction.}'. It will also avoid it after `?' or `!'; in general, after any character with a |\sfcode| equal to the one of the period. (This is lost in |\frenchspacing| and similar situations, where |opcit| has no way to `see' the period, and will \emph{always} add one.)
%
%A |\cite| command can also occur within the argument of a |\footnote|. In that case, the information on the source is added to the text of the footnote, with \emph{no} period added.\footnote{This is because it is assumed that the user will always `close' the footnote with a final period. Issuing here \texttt{\textbackslash cite\{martinb\}}, which produces Jes\'us Mart\'{\i}n-Barbero, \emph{Communication, culture, and hegemony: From media to mediations} (London: SAGE Publications, 1993), I do not want |opcit| to add a period.}
%
%The starred \DescribeMacro{\cite*}version of |\cite| omits the author's name from the footnote. So: Gellner expanded one of the ideas presented from his mentioned book in a later study.|\cite*{gellner2}|\footnote{\emph{Nations and Nationalism} (Ithaca: Cornell University Press, 1983).}
%
%\subsection{Post-citations}
%Post-citations---later citations of an already cited work---behave differently. For example, a new citation of the \TeX book through |\cite{texbook}| will not render the whole footnote text again, but rather `\footnote{Knuth, \emph{op.~cit.}}'. The author name has been reduced to the last-name, and the rest of the information is replaced by `\emph{op.~cit.}' Again, the period is appropriately handled: no period is added to the one at the end of this expression. But in the case of |\cite[p.~101]{taruskin}|, it is added: `\footnote{Taruskin, \emph{op.~cit.}, p.~101.}'. You can also use |\cite*| to hide the author's name for \emph{op.~cit.}-citations.
%
%This is not good when there are several works by the same author, in whose case |opcit| has no way to know which one is meant at each point. This is handled with the `hereafter' mechanism (section~\ref{hereafter}).
%
%\bigskip
%\noindent Another kind of situation arises when the same work is cited \emph{consecutively}. In that case, the corresponding footnote(s) will say `\emph{Idem}'. In principle, this will be followed by the optional argument, if any. \marginpar{\raggedleft\textsf{New Feature}}However, if two \emph{Idem}-citations have the same optional argument, the second time it will \emph{not} be typeset. \DescribeMacro{nocheckidem}(This can be turned off with the |nocheckidem| option.) In any case, a final period will be added if needed. 
%
%Thus, a further citation here of Taruskin's book (the one that was cited last in the previous paragraph), through |\cite[p.~xxi]{taruskin}|, renders `\footnote{\emph{Idem}, p.~xxi.}'. If the same command (|\cite[p.~xxi]{taruskin}|) is issued again, the footnote will be `\footnote{\emph{Idem}.}', with no `p.~xxi' in it.
%
%Since an \emph{Idem}-citation will always hide the author's name, use of |\cite*| in those situations has has no special effect.
%
%\bigskip
%\noindent As a reader,\marginpar{\raggedleft\textsf{New feature}} I have had the annoying experience of needing to find a reference for which the footnote to the page says only `Barto\v s: \emph{op.~cit.}' You are forced carefully to look through all the previous footnotes in search of the whole information. It was thus very nice to come across a book\footnote{Jamie C. Kassler: \emph{Music, Science, Philosophy: Models in the Universe of Thought} (Aldershot, Burlington, Singapore and Sydney: Ashgate, 2001).} with footnote references, but in which any post-citations indicated the footnote in which the work was first cited---something like `(note 14).' I then decided to implement this in |opcit|.
%
%\DescribeMacro{\bibref}So, command |\bibref{|\meta{key}|}| produces the number in which the \meta{key} reference was |\cite|'d for the first time. (If the reference has not been |\cite|'d before, however, there will be an error message.) You can use |\bibref| anywhere, in the main text, as the optional argument to a |\cite|, or in a footnote. For example, you can post-cite the \TeX Book with |\cite[note~\bibref]{texbook}|, or |\footnote{\cite{texbook} (see footnote \bibref above).}|, etc. In the first case you would get `\footnote{Knuth, \emph{op.~cit.}, note 2.}'. 
%
%\DescribeMacro{hyperref}The footnote number printed by |\bibref| (either a manual or an automatic one) will be a hyperlink if the |hyperref| option is in place. In fact, this option provides satisfactory cross-referencing with hyperlinks: the `\emph{op.~cit.}' expression itself will be a hyperlink if this option is chosen.
%
%The |hyperref| option is in force by default if the |hyperref| package has been loaded (before |opcit|). If the package is loaded, but hyperlinks for citations are not desired, they can be turned off with the |nohyperref| option to |opcit|.
%
%\subsubsection{Extra control}\label{extra}
%
%\DescribeMacro{\resetcites}In long documents, for example books with chapters, it might be desirable to reset the citations so that they are again fully cited in the footnotes (even if they were already cited, say, in a previous chapter). This is done with the command |\resetcites|. It affects all the entries in the bibliography database.
%
%\DescribeMacro{\cited}The contrary procedure---to make the next citation of a work a post-citation, with \emph{op.~cit.} instead of the full information---is possible for individual entries: |\cited{|\meta{key1}|,|\meta{key2}|,|\dots|}| will make |opcit| pretend that the entries in the argument were already cited. This is particularly useful with cross references among entries (see section~\ref{crossrefs}).
%
%\subsection{Customization}
%The user can change \DescribeMacro{\opcittext}\DescribeMacro{\idemtext}the expressions `\emph{op.~cit.}' and `\emph{Idem}' by |\renewcommand|'ing the |\opcittext| and |\idemtext| commands, respectively.
%
%\subsection{The `herafter' mechanism}\label{hereafter}
%
%\DescribeMacro{hereafter = ""}When two or more works by the same author are |\cite|'d, the \emph{op.~cit.}\ mechanism is not reliable. The user should then provide a `\texttt{hereafter}' value for each work by the same author in the \texttt{bib} file. Then, |opcit| will use the value of this entry in the place of \emph{op.~cit.} 
%
%For example, if Gellner's mentioned books had \texttt{hereafter} entries of |"T{\&}C"| and |"N{\&}N"|, respectively, the commands |\cite{gellner}| and |\cite{gellner2}| would produce `\footnote{Gellner: \emph{T\&C}.}' and `\footnote{Gellner: \emph{N\&N}.}' (of course, from the second time these works are cited on). Note that the strings were emphasized. The starred version |\cite*| still hides the author's name, and the `\emph{Idem}' mechanism will apply if any of the works is |\cite|'d for the second time in a row.
%
%If no \texttt{hereafter} entry is found (and there are several references by the same author), a warning will be issued, and the deliberately unacceptable expression \emph{?Op.?Cit.?} substituted. 
%
%The value of \texttt{hereafter}, that replaces `\emph{op.~cit.},' will be a hyperlink if the |hyperref| option is on.
%
%\DescribeMacro{\hereafter}
%The |\hereafter| command typesets the \texttt{hereafter} string of the last |\cite|'d work, so that we can say something like 
%
%\begin{verbatim}
%\footnote{See \cite{gellner}; hereafter I will refer to this text as 
%\hereafter.}
%\end{verbatim}
%
%This mechanism can be used also for single works of a particular author. The result of |\hereafter| is \emph{not} a hyperlink.
%
%\subsection{Omitting text from the footnotes}\label{omits}
%
%Sometimes\marginpar{\raggedleft\textsf{New Feature}} it is desirable to omit some part of the bibliographical information from the footnotes, keeping it on the final references list. \DescribeMacro{\toomit}This is now allowed by |opcit| through the command |\toomit|. You use it in the |.bib| file, like this:
%
%\begin{verbatim}
%address = "Aldershot\toomit{, Burlington, Singapore and Sydney}",
%\end{verbatim}
%
%\noindent The effect is that the argument of |\toomit| will be typeset in the final references list, but not in the footnotes.
%
%Typical cases when this is useful are:
%\begin{itemize}
%\item Long addresses (example above).
%\item Long titles: {\ttfamily title = "The Prisoner of Zenda|\toomit{|: being the story of three months in the life of an English gentleman|}|"}.
%\item Some translated titles: {\ttfamily title = "Music and Discourse|\toomit{| [Musicologie g|{\'e}|n|{\'e}|rale et s|{\'e}|miologie]|}|"}.
%\end{itemize}
%
%A special case of omission concerns page numbers for articles in journals or books. Since the page numbers for articles usually go at the end of the reference, they could clash with the optional argument to |\cite| (something like a `pages~1--20, p.~13'). This cannot be fixed with |\toomit|, because the particle `pages' is added by \textsc{Bib}\TeX, so it's not susceptible of |\toomit|. The same is true of the \texttt{volume}, the \texttt{series}, and \texttt{number} of a |@BOOK| entry, among others. 
%
%The solution is that |opcit| omits these fields altogether from the footnotes (they still appear in the final bibliography list). 
%
%This is the default behavior, but it can be overriden. \DescribeMacro{\with}The |\with{|\meta{field}|}| command forces the \meta{field} of the next reference to appear, even if it would by default be omitted. So, for example, to get a footnote that does include the pages of an article, you type |\with{pages}\cite{foo}|. Similarly, the \texttt{volume} of a book can be `de-omitted' by typing |\with{volume}\cite{foobook}|.
%
%Several |\with| commands can go in succession. For example, if you want the page numbers of the article from a collected edition, \emph{and} the volume of the book that contains, you can say |\with{pages}\with{volume}\cite{book}|.
%
%The scope of |\with| is only the next |\cite| (each |\cite| sets all default omissions back on). On the other hand, nothing happens if a |\cite| does not have the \meta{field} that was requested with |\with|. 
%
%
%A more sophisticated version of |\toomit| allows the user to use |\with| in connection with it. |\toomit[|\meta{category}|]{|\meta{text}|}| will by default omit the \meta{text} (from the footnotes), but it could be forced typing |\with[|\meta{category}|]|. Note that the \meta{category} is not a \textsc{Bib}\TeX\ field.
%
%For example,
%\begin{verbatim}
%title = "Music and discourse: Toward a semiology of 
%   music\toomit[translation]{\ [Musicologie 
%   g{\'e}n{\'e}ral et s{\'e}miologie]}"
%\end{verbatim}
%
%\noindent the translation will by default be omitted in the footnote, but there will be a |\with{translation}| that will include it.
%
%\DescribeMacro{noomitting}You can turn off the omissions by specifying the |noomitting| option to the package. In that case, the commands |\toomit| and |\with| have no effect.
%
%
%\subsection{The final references list}
%
%The command |\bibliography| has the usual effect of producing a final section (or chapter) for `References.' According to the \textsc{Bib}\TeX\ style used, the format of the entries is different in the references list from the footnotes. 
%
%\marginpar{\raggedleft\textsf{New Feature}}Frequently, a document with bibliographical references in footnote style does not include a final references list. \DescribeMacro{\nobibliography}But the user has to tell |opcit| where to find the \textsc{Bib}\TeX\ database, which is done by the |\bibliography| command. So there is now a |\nobibliography| that works just like |\bibliography| but produces no list. The command takes the file name(s) of the database(s) as its argument.
%
%Bear in mind that if you use |\nobibliography| instead of |\bibliography|, some information that is by default omitted from the footnotes (see section~\ref{omits}) might be completely lost. |opcit| emits a warning of this in the \texttt{log} file. 
%
%\section{The \textsc{Bib}\TeX\ style}\label{bstyle}
%
%The  \textsc{Bib}\TeX\ style (|opcit.bst|) that comes with this version~2 of |opcit| is fairly complete, but this does not mean that it can handle every conceivable combination of different pieces of information in any bibliographical reference. I have provided the standard entry types, and the fields are also about the same as in standard styles (with the notable addition of |hereafter|, discussed in section~\ref{hereafter}). So I repeat the \emph{caveat} of Oren~Patashnik: be creative in the use of entries and fields, and you will be able to achieve pretty much anything.\footnote{It is never a bad idea to read Patashnik's ``\textsc{Bib}\TeX ing'' (February 8, 1988),  file \texttt{btxdoc.dvi} in \LaTeX\ standard distribution.}
%
%For example: rather than providing a field for |translation|, which would imply provision of a host of additional fields---|datetranslated|, |original|, |translator|, \dots---and would not be used very often, I have relied on the user's judicious use of fields like |note| and |howpublished|. The following conventions are true of all entry types without exception:
%\begin{itemize}
%\item \texttt{howpublished} is printed \emph{immediately after} \texttt{edition}. 
%\item \texttt{note} is printed \emph{at the end of an entry}. It is also omitted from the footnotes (but can be retrieved with |\with{note}|).
%\end{itemize}
%
%\subsection{Cross referencing}\label{crossrefs}
%
%\DescribeMacro{crossref = ""}Cross referencing through the |crossref| field has been fully implemented in version~2. Its exact behavior depends on whether a reference is being cited in a footnote, or it appears in the final list.
%
%Consider, for example, the entry
%
%\begin{verbatim}
%@INCOLLECTION{derrida,
%  title = "Deconstruction and actuality",
%  author = "Jacques Derrida",
%  crossref = "postmodern",
%  pages="75--78"
%  }
%\end{verbatim}
%
%If there is a |\cite{derrida}| in the document, the result will be equivalent to having typed: {\ttfamily|\footnote{|Jacques Derrida, ``Deconstruction and actuality,'' in |\cite{postmodern}.}|}
%
%The last |\cite| is added automatically by \texttt{opcit}, as a result of the \texttt{crossref} field. Its output will be either a full citation of the book, or an `\emph{op.~cit.}'\ expression, depending on whether the book has already been cited or not.
%
%The citation that results from the |crossref| field will by default \emph{not} count as the first citation of that entry (``\texttt{postmodern}'' in the example). This means that a later citation of this same entry (be it by itself or within another cross reference) will expand the full information again. The command |\cited| (section~\ref{extra}) can be used to override this and make future citations of the cross reference be of the \emph{op.~cit.} type.
%
% In addition, \emph{Idem} is disabled for it. However, post-citations of the main reference (``\texttt{derrida}'') are not affected at all by the cross~reference mechanism, and will use the regular `\emph{op.~cit.}' or `\emph{Idem}' expressions. 
%
%\bigskip\noindent
%In the final references list, the effect of the |crossref| field is more familiar: the entry will get the information for the missing fields from the entry that is being cross-referenced, just as in a standard \textsc{Bib}\TeX\ style.
%
%\subsection{Other tools}
%
%The new field |hereafter| has already been explained (section~\ref{hereafter}), as well as the use of |\toomit| (section~\ref{omits}). Other features will be introduced in this section.
%
%\DescribeMacro{\bibpunctuation}The |\bibpunctuation| command expands into a comma in the footnotes, but into a period in the final references list. It is internally used by |opcit.bst| to separate the different pieces of information within an entry, and the user can use it just as well.
%
%Use of |\bibpunctuation| is likely to need complement for the capitalization of what follows. After a comma, things should start lowercase; after a period, uppercase. This ambiguous case has been conceived for |opcit| as the `bibliography-case,' and implemented in the command \marginpar{\raggedleft\textsf{New Feature}}\DescribeMacro{\bibcase}|\bibcase|. You can insert it anywhere and it will make the first letter of the following word either lower- or uppercase. For example, |opcit.bst| inserts |\bibcase| before the particle `in' of an |@INCOLLECTION| entry. Applying braces, like in |\bibcase{paideia}|, would capitalize or de-capitalize the whole argument.
%
%\DescribeMacro{\bibcite}If you have to know it all, the implementation of |crossref| described in the previous section is made through the |\bibcite| command. It takes two arguments: the label to cite within the citation, and the whole information to be typeset in the final list. You can directly use this command in any field.
%
%\subsection{The entry types}
%
%The |opcit| \textsc{Bib}\TeX\ style accepts the same entry types as the standard styles. Below you find examples of each of the entry types in both footnote and final-list layout, as well as explicit lists of omitted fields (see section~\ref{omits}).
%
%\subsubsection{Book}
%Omitted fields: \texttt{volume} and \texttt{series} (recovered by |\with{volume}|); \texttt{number} and \texttt{series} (|\with{number}|); \texttt{note} (|\with{note}|).
%
%\noindent\hrulefill\ 1\ \hrulefill
%
%\begin{verbatim}
%@BOOK{berlinsky,
%    author="David Berlinsky",
%    title="Newton's Gift\toomit{: How Sir Isaac Newton
%        Unlocked the System of the World}",
%    publisher="Simon {\&} Schuster",
%    address="New~York and London",
%    year="2000"}
%\end{verbatim}
%The first footnote for this entry would read: 
%\begin{quotation}\small\noindent
%David Berlinsky, \emph{Newton's Gift} (New York and London: Simon \& Schuster, 2000).
%\end{quotation}
%In the final reference list, the entry looks like:
%\begin{quotation}\noindent
%\makebox[2.5em][r]{Berlinsky}, David. \emph{Newton's Gift: How Sir Isaac Newton Unlocked the System of the World}. New York and London: Simon \& Schuster, 2000.
%\end{quotation}
%
%\noindent\hrulefill\ 2\ \hrulefill
%
%\begin{verbatim}
%@BOOK{tac,
%    author="Ernest Gellner",
%    title="Thought and Change",
%    series="``The Nature of Human Society'' Series (ed.\ 
%      Julian Pitt-Rivers and Ernest Gellner) Press",
%    number="1",
%    year="1964",
%    address="Chicago",
%    publisher="University of Chicago"}
%\end{verbatim}
%Footnote layout:
%\begin{quotation}\small\noindent
%Ernest Gellner, \emph{Thought and Change} (Chicago: University of Chicago Press, 1964).
%\end{quotation}
%For the final-list of this and the rest of the examples see page~\pageref{examples} (footnote-layout is illustrated in the main text).
%
%\noindent\hrulefill\ 3\ \hrulefill
%
%\begin{verbatim}
%@BOOK{walker,
%    title="The Final Years 1861--1886",
%    volume="3",
%    series="Franz Liszt",
%    author="Alan Walker",
%    publisher="Alfred A. Knopf",
%    address="New York",
%    year="1996"}
%\end{verbatim}
%Footnote layout:
%\begin{quotation}\small\noindent
%Alan Walker, \emph{The Final Years 1861--1886} (New York: Alfred A. Kopf, 1996).
%\end{quotation}
%\noindent This is a case in which you might prefer typing |\with{volume}\cite{walker}|, with the following effect:
%\begin{quotation}\small\noindent
%Alan Walker, \emph{The Final Years 1861--1886}, volume 3 of \emph{Franz Liszt} (New York: Alfred A. Kopf, 1996).
%\end{quotation}
%
%\subsubsection{Article}
%
%Omitted fields: \texttt{pages}, \texttt{month}, \texttt{note}.
%
%\noindent\hrulefill\ 1\ \hrulefill
%
%\begin{verbatim}
%@ARTICLE{sheldon,
%    author="David A. Sheldon",
%    title="The Galant Style Revisited and Re-Evaluated",
%    journal="Acta Musicologica",
%    volume="47",
%    number="2",
%    year="1975",
%    pages="240--70"}
%\end{verbatim}
%Footnote layout:
%\begin{quotation}\small\noindent David A. Sheldon, ``The Galant Style Revisited and Re-Evaluated,'' \emph{Acta Musicologica} 47/2 (1975).\end{quotation}
%
%\noindent\hrulefill\ 2\ \hrulefill
%
%\begin{verbatim}
%@ARTICLE{nattiez,
%    author="{Jean-Jacques} Nattiez and Isabelle Schulte-Technoff",
%    title="L'etnomusicologia: strutturalismo o culturalismo?\toomit{ 
%        Intervista con Jean-Jacques Nattiez di Isabelle Schulte-Technoff}",
%    journal="Musica/Realt{\`a}",
%    volume="61",
%    pages="109--131",
%    year="2000",
%    month="March"}
%\end{verbatim}
%Footnote layout:
%\begin{quotation}\small\noindent Jean-Jacques Nattiez and Isabelle Schulte-Technoff, ``L'etnomusicologia: strutturalismo o culturalismo?,'' \emph{Musica/Realt\`a} 61 (2000).\end{quotation}
%
%\noindent Or, alternatively, |\with{month}\with{pages}\cite{nattiez}| produces:
%\begin{quotation}\small\noindent Jean-Jacques Nattiez and Isabelle Schulte-Technoff, ``L'etnomusicologia: strutturalismo o culturalismo?,'' \emph{Musica/Realt\`a} 61 (March 2000): 109--131.\end{quotation}
%
%\subsubsection{Incollection}
%For articles in an edited book. For use with \textsc{Bib}\TeX\ cross-reference (\texttt{crossref}) see examples 2ff.
%
%Omitted fields: \texttt{pages}, \texttt{chapter}, \texttt{note}.
%
%\noindent\hrulefill\ 1\ \hrulefill
%
%\begin{verbatim}
%@INCOLLECTION{laudan,
%    title="Explaining the Success of Science\toomit{: Beyond 
%         Epistemic Realism and Relativism}",
%    author="Larry Laudan",
%    booktitle="Science and the Quest for Reality",
%    editor="Alfred I. Tauber",
%    address="London",
%    publisher="MacMillan Press Ltd.",
%    pages="137--161",
%    year="1997"}
%\end{verbatim}
%Footnote layout:
%\begin{quotation}\small\noindent Larry Laudan, ``Explaining the Success of Science,'' in Alfred I. Tauber (ed.), \emph{Science and the Quest for Reality} (London: MacMillan Press Ltd., 1997).\end{quotation}
%
%\bigskip\noindent\hrulefill\ 2\ \hrulefill
%
%Given the following entry:
%\begin{verbatim}
%@BOOK{grove,
%   booktitle="Grove Music Online",
%   editor="L. Macy",
%   url="http://www.grovemusic.com/"}
%\end{verbatim}
%another entry can make reference to it:
%\begin{verbatim}
%@INCOLLECTION{weber,
%    title="Weber, Gottfried",
%    author="Janna K. Saslaw",
%    crossref="grove",
%    urldate="October 5, 2005"}
%\end{verbatim}
%Then, citation of the latter in the footnotes will |\cite| the former. The layout of this `nested' |\cite| will depend on the kind of entry it is (usually a book), and might also be \emph{op.~cit.}, if it has already been cited. In this case the result is:
%\begin{quotation}\small\noindent Janna K. Saslaw, ``Weber, Gottfried,'' in L. Macy (ed.), \emph{Grove Music Online},
%\texttt{http://www.grovemusic.com/} (accessed October 5, 2005).\end{quotation}
%
%\subsubsection{Inbook}
%For individual chapters or articles from books by a single author.
%
%Omitted fields: \texttt{pages}, \texttt{chapter}, \texttt{note}.
%
%\noindent\hrulefill\ 1\ \hrulefill
%\begin{verbatim}
%@INBOOK{stuff,
%   title="The Stuff of Change",
%   booktitle="Thought and Change",
%   pages="126--146",
%   chapter="6",
%   crossref="tac"}
%\end{verbatim}
%This entry makes reference to the first example of \texttt{@BOOK} to create the following footnote:
%\begin{quotation}\small\noindent Ernest Gellner, ``The Stuff of Change,'' chapter 6 of \emph{op.~cit.}\end{quotation}
%This would work best if the book entry had a field for \texttt{hereafter}, creating something like ``chapter 6 of \emph{Thought and Change}.'' On the other hand, |\with{pages}| adds ``\dots chapter 6 (pages 126--146) of\dots''
%
%\bigskip\noindent\hrulefill\ 2\ \hrulefill
%   
%\begin{verbatim}
%@INBOOK{attemborough,
%    author="David Attenborough",
%    title="The Infinite Variety",
%    type="Episode",
%    chapter="1",
%    booktitle="Life on Earth\toomit{ \upshape (videorecording)}",
%    publisher="BBC",
%    year="1979"}
%\end{verbatim}
%Footnote layout:
%\begin{quotation}\small\noindent David Attemborough, ``The Infinite Variety,'' episode~1 of \emph{Life on Earth} (BBC, 1979).\end{quotation}
%\subsubsection{PHDthesis}
%
%Omitted fields: \texttt{note}.
%
%\begin{verbatim}
%@PHDTHESIS{saslaw,
%    author="Janna K. Saslaw",
%    title="Gottfried Weber and the Concept of Mehrdeutigkeit",
%    school="Columbia University",
%    year="1992"}
%\end{verbatim}
%Footnote layout:
%\begin{quotation}\small\noindent Janna K. Saslaw, \emph{Gottfried Weber and the Concept of Mehrdeutigkeit} (Ph.\,D.\ diss.), Columbia University, 1992.\end{quotation}
%
%\subsubsection{Mastersthesis}
%
%Analogous to \texttt{phdthesis}, but with `M.\,A. thesis' instead of `Ph.\,D. diss.'
%
%\subsubsection{Proceedings}
%
%Essentially equivalent to |@BOOK|. One difference is the possible presence of |organization| (which only gets typeset if |editor| is missing); another is that there is no |edition|.
%
%\subsubsection{Booklet}
%
%This entry type behaves exactly as |@BOOK|. 
%
%\subsubsection{Inproceedings}
%
%|@INPROCEEDINGS| is to |@PROCEEDINGS| what |@INCOLLECTION| is to |@BOOK|: there is no |edition|, and |organization| can replace |editor|. Otherwise the behavior is similar.
%
%\subsection{Modifying the bibliography style}\label{bsts}
%
%This section makes explicit the conventions that a \textsc{Bib}\TeX\ style (a \texttt{bst} file) should follow in order to support and be supported by |opcit|.
%
%The basic form of a |opcit|-supported |\bibitem| is:
%
%|\bibitem{|\meta{label}|}|
%
%|\biblastnames{|\meta{last name(s)}|}|
%
%\meta{\dots additional declarations\dots}
%
%|\opcitstart |\meta{name(s)}|\bibpunctuation \newblock|
%
%\meta{remaining info}
%
%|\opcitends|
%
%\smallskip
%As long as this scheme is strictly followed, |opcit| will run.\footnote{This can be easily achieved in the style by suitably modifying the |{bibstart}| and |{fin.entry}| functions.} 
%
%The style has therefore to have a method of finding out only the last name(s) of author/editor, to be passed to |opcit| as the argument to |\biblastname|. This is independent from the actual formatting of the names (that happens right before the first |\bibpunctuation|).
%
%Other conventions are probably always needed, but not syntactically required:
%\begin{itemize}
%\item Instead of periods or commas, the style should append |\bibpunctuation| commands (this command is converted into commas in the footnotes, into periods in the references list).
%\item |\bibcase| commands should be added at strategic points (the particle `in' for \texttt{@INCOLLECTION}s, and in general everything that comes after a |\bibpunctuation|). 
%\item \DescribeMacro{\sameauthors}If the style substitutes a line for repeated author(s)' name(s), |opcit| needs a way to know the `real' author. This is achieved by the style not typesetting the line by itself, but rather appending a |\sameauthors| command (defined by |opcit| as a rule of length |\sameauthorsrule|). 
%\item \DescribeMacro{\bibhereafter}The style should provide for handling of the |hereafter| field: its contents (if any) should be passed on to |opcit| as the argument to |\bibhereafter|, as part of the \meta{additional declarations}. 
%\end{itemize}
%
%Another kind of tools are those that are not hard-wired in |opcit|, but whose use is more or less mandatory with footnote-style referencing. For example, it is customary that the author's name appears, in the footnotes, as first-last name (`Ernest~Gellner'), and as last-first (`Gellner, Ernest') in the final list. This is more a feature of the |bst| than of |opcit| itself, so it is supposed to be implemented there. As a result, it should be implemented in any \textsc{Bib}\TeX\ intended for use with |opcit|.
%
%This is done by making the |bst| itself define and use its own commands, advisably at the beginning of the |bbl| file, usually in the |{begin.bib}| function. 
%
%Typically, these definitions will make use of |opcit|'s \DescribeMacro{\newBibCommand}|\newBibCommand|:
%
%|\newBibCommand{|\meta{command name}|}{|\meta{footnote-style}|{|\meta{list-style}|}|
%
%This means that the new command will expand to the first meaning when encountered in footnotes, and to the second when in the final list. Use of arguments with |\newBibCommand| is surprisingly intuitive, and is illustrated in the items below.
%
%|opcit.bst| defines five tools in this way:
%\begin{itemize}
%\item|\bibparenthesis| should parenthesize its argument when in footnotes, but typeset it (after a period) in the final list. This is used for the publisher and the year of books: `(London: Penguin, 1989)' but `. London: Penguin, 1989'. This command is defined with 
%
%\hfill|\newBibCommand{\bibparenthesis[1]}{ (#1)}{. \newblock #1}|.
% 
%Later, the |{make.address.publisher.year}| function of the |bst| makes use of this command.
%\item |\newBibCommand{\SwapNames[2]}{#1 #2}{#2, #1}| implements the ordering of names. The author/editor name then is issued as, for example, |\SwapNames{Ernest}{Gellner}|.
%\item |\bibincite| and |\bibincitestar| are the commands used by the |bst| file to implement cross references between entries. In their definition, they use internal |opcit| commands. I would recommend to copy them from |opcit.bst|, and in any case simply to \emph{add} stuff to them. Leave the |\recover@last| alone, unless you know what you are doing!
%
%\item |\GobbleOrNot| is used to gobble (or not) the punctuation mark when a period ends the previous text. For example, the middle initial in `Donald E. Knuth' would clash with |\bibpunctuation| in the final reference list: `Knuth, Donald~E..\ \emph{The \TeX book}.' But the period has to be included in the footnote (Donald E. Knuth, \emph{The \TeX book}'). Similarly, the particle `Ph.\,D.\ diss.' has to gobble the following period in the final list, but not the closing parenthesis in the footnotes. Thus, |\GobbleOrNot| is defined as
%
%\hfill|\newBibCommand{\GobbleOrNot}{\relax}{\newblock\@gobble}|
%\end{itemize}
%
%\newcommand\bibparenthesis[1]{. \newblock #1}
%\newcommand\bibincite[2]{#2}
%\newcommand\bibincitestar[2]{#2}
%\newcommand\SwapNames[2]{#2, #1}
%\newcommand\GobbleOrNot{\newblock\@gobble}
%\def\biblastnames#1{}\let\opcitstart\relax\def\bibpunctuation{.}\def\bibcase#1{\uppercase{#1}}\let\toomit\relax
%\makeatletter
%\renewenvironment{thebibliography}[1]
%     {\section*{The final list (examples)}
%      \list{}%
%           {\setlength\labelwidth{\z@}%
%            \leftmargin\bibindent
%            \itemindent -\bibindent
%            \parsep \z@
%            \@openbib@code
%            \usecounter{enumiv}%
%            \let\p@enumiv\@empty
%            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
%      \sloppy
%      \clubpenalty4000
%      \@clubpenalty \clubpenalty
%      \widowpenalty4000%
%      \sfcode`\.\@m}
%     {\def\@noitemerr
%       {\@latex@warning{Empty `thebibliography' environment}}%
%      \endlist}
%\makeatother
%\let\opcitend\relax\def\sameauthors{\rule{23pt}{0.4pt}}
%\begin{thebibliography}{}\label{examples}
%
%\bibitem{attemborough}
%\biblastnames{Attenborough}
%\opcitstart \SwapNames{David}{Attenborough}\bibpunctuation
%\newblock ``The Infinite Variety\bibpunctuation''
%\newblock \bibcase Episode 1 of {\em Life on Earth\toomit{ \upshape
%  (videorecording)}}\bibparenthesis{BBC, 1979}\opcitend
%
%\bibitem{berlinsky}
%\biblastnames{Berlinsky}
%\opcitstart \SwapNames{David}{Berlinsky}\bibpunctuation
%\newblock {\em Newton's Gift\toomit{: How Sir Isaac Newton Unlocked the System
%  of the World}}\bibparenthesis{New~York and London: Simon {\&} Schuster,
%  2000}\opcitend
%
%\bibitem{stuff}
%\biblastnames{Gellner}
%\opcitstart \SwapNames{Ernest}{Gellner}\bibpunctuation
%\newblock ``The Stuff of Change\bibpunctuation''
%\newblock \bibcase chapter 6\toomit[pages]{ (pages 126--146)} of
%  \bibincitestar{tac}{{\em Thought and Change}}\opcitend
%
%\bibitem{tac}
%\biblastnames{Gellner}
%\opcitstart \sameauthors\bibpunctuation
%\newblock {\em Thought and Change}\toomit[number]{\bibpunctuation\bibcase
%  \bibcase number~1 in ``The Nature of Human Society'' Series (ed.\ Julian
%  Pitt-Rivers and Ernest Gellner) Press}\bibparenthesis{Chicago: University of
%  Chicago, 1964}\opcitend
%
%\bibitem{laudan}
%\biblastnames{Laudan}
%\opcitstart \SwapNames{Larry}{Laudan}\bibpunctuation
%\newblock ``Explaining the Success of Science\toomit{: Beyond Epistemic Realism
%  and Relativism}\bibpunctuation''
%\newblock \bibcase in {Alfred~I. Tauber (ed.), {\em Science and the Quest for
%  Reality}\bibparenthesis{London: MacMillan Press Ltd.,
%  1997}}\toomit[pages]{\bibcase :  137--161}\opcitend
%
%\bibitem{nattiez}
%\biblastnames{Nattiez and Schulte-Technoff}
%\opcitstart \SwapNames{{Jean-Jacques}}{Nattiez} and Isabelle
%  Schulte-Technoff\bibpunctuation
%\newblock ``L'etnomusicologia: strutturalismo o culturalismo?\toomit{
%  Intervista con Jean-Jacques Nattiez di Isabelle
%  Schulte-Technoff}\bibpunctuation''
%\newblock {\em Musica/Realt{\`a}} 61 (\toomit[month]{March
%  }2000)\toomit[pages]{\bibcase :  109--131}\opcitend
%
%\bibitem{weber}
%\biblastnames{Saslaw}
%\opcitstart \SwapNames{Janna~K.}{Saslaw}\GobbleOrNot\bibpunctuation
%\newblock ``Weber, Gottfried\bibpunctuation''
%\newblock \bibcase in \bibincite{grove}{L. Macy (ed.), {\em Grove Music
%  Online}\bibpunctuation
%\newblock \texttt{http://www.grovemusic.com/} (accessed October 5, 2005)}\opcitend
%
%\bibitem{saslaw}
%\biblastnames{Saslaw}
%\opcitstart \sameauthors\bibpunctuation
%\newblock {\em Gottfried Weber and the Concept of
%  Mehrdeutigkeit}\bibparenthesis{Ph.\,D.\ diss\GobbleOrNot.}\bibpunctuation
%\newblock Columbia University\bibpunctuation
%\newblock 1992\opcitend
%
%\bibitem{sheldon}
%\biblastnames{Sheldon}
%\opcitstart \SwapNames{David~A.}{Sheldon}\GobbleOrNot\bibpunctuation
%\newblock ``The Galant Style Revisited and Re-Evaluated\bibpunctuation''
%\newblock {\em Acta Musicologica} 47/2 (1975)\toomit[pages]{\bibcase :
%  240--70}\opcitend
%
%\bibitem{walker}
%\biblastnames{Walker}
%\opcitstart \SwapNames{Alan}{Walker}\bibpunctuation
%\newblock {\em The Final Years
%  1861--1886}\toomit[volume]{\bibpunctuation\bibcase \bibcase volume~3 of {\em
%  Franz Liszt}}\bibparenthesis{New York: Alfred A. Knopf, 1996}\opcitend
%
%\end{thebibliography}
%
%\clearpage
%\section{Implementation}
%
%\subsection*{Identification}
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{opcit}[2006/09/20 Footnote references (Federico Garcia) Version 2]
\RequirePackage{xspace}
%    \end{macrocode}
%
%\subsection*{Declarations}
%    \begin{macrocode}
\newif\ifopcit@bbl\opcit@bblfalse
\newif\ifopcit@footnote\opcit@footnotefalse
\newif\ifperi@d\peri@dfalse
\newif\ifhyper@opcit
\newif\if@omitting
\newif\if@idem
\newif\ifcheck@idem
\newif\ifcheck@@idem
\newif\if@opcit
\newif\ifcustom@bst
\newcount\@lastcite
\newlength{\sameauthorsrule}\setlength{\sameauthorsrule}{23pt}
\newtoks\opcit@redefs
\newtoks\opcit@defs
\newcommand*{\last@cited}{)OpcitFirst(}
\newcommand*{\opcittext}{\textit{op.\,cit.}}
\newcommand*{\idemtext}{\textit{Idem}}
\newcommand*{\sameauthors}{\rule{\sameauthorsrule}{.4pt}}
\newcommand*\opcitwarning[1]{\PackageWarning{noopcit option is called for, 
   but `#1' has no hereafter.}}
\newcommand*\opcit@noreferror[1]{\PackageError{key `#1' has not been cited.}
    {\string\bibref can be used only after the first citation of a work. 
    (You might also have mistyped the key.) Go on, but there won't be a
    cross reference here.}\textbf{??}}
\let\@quoteornot\relax
%    \end{macrocode}
%
%\subsection*{Options}
%
%    \begin{macrocode}
\DeclareOption{hyperref}{\hyper@opcittrue}
\DeclareOption{nohyperref}{\hyper@opcitfalse}
\DeclareOption{omitting}{\@omittingtrue}
\DeclareOption{noomitting}{\@omittingfalse}
\DeclareOption{noidem}{\@idemfalse}
\DeclareOption{idem}{\@idemtrue}
\DeclareOption{checkidem}{\check@idemtrue}
\DeclareOption{nocheckidem}{\check@idemfalse}
\DeclareOption{opcit}{\@opcittrue}
\DeclareOption{noopcit}{\@opcitfalse}
\DeclareOption{nocustombst}{\newcommand\opcit@bst{\bibliographystyle{opcit}}}
\DeclareOption{custombst}{\let\opcit@bst\relax}
\@ifpackageloaded{hyperref}
    {\ExecuteOptions{omitting,checkidem,nocustombst,idem,opcit,hyperref}}
    {\ExecuteOptions{omitting,checkidem,nocustombst,idem,opcit}}
\ProcessOptions
\ifhyper@opcit\RequirePackage{hyperref}\fi
\opcit@bst
%    \end{macrocode}
%
%\subsection{The macros}
%
%The basic idea behind the working of |opcit| is that the \texttt{bbl} file produced by \textsc{Bib}\TeX\ is read at the beginning of the document, not to produce the list of references, but to define the (internal) commands that will expand into the footnote references. For example, the entry \texttt{texbook} defines the commands |\@texbook|, |\texbook@star|, |\texbook@author|, and so on. These commands contain the actual text to be written in the footnotes.
%
%The |\cite| command itself is redefined, based on circumstances, to execute the appropriate control sequence each time. At the beginning, |\cite{texbook}| means basically |\footnote{\@texbook}|. But it also redefines |\@texbook| so that the next time it is used it will expand to `Knuth, \emph{op.~cit.}'
%
%Before reading the |bbl| file, however, we have to define the `communication commands' that enable the latter to pass information on to |opcit|.
%
%\subsubsection{Communication commands}
%Punctuation marks are to be added only if the last character was not a period, a question or an exclamation mark (which have a |\sfcode| of 2000).
%
%    \begin{macrocode}
\newcommand{\newBibCommand}[3]{%
    \newcommand#1{#2}%
    \opcit@redefs\expandafter{\the\opcit@redefs%
        \renewcommand#1{#3}}}
\let\opcitstart\relax
\newBibCommand{\opcitend}{\relax}{\ifnum\spacefactor=\sfcode`?\else\unskip.\fi}
\newBibCommand{\bibpunctuation}{,\xspace}{%
    \ifnum\spacefactor=\sfcode`?\else\unskip.\fi\xspace}
\newBibCommand{\biblastnames[1]}{%
    \global\@namedef{\@curr@bibitem @authors}{#1}}{\relax}
\newBibCommand{\bibhereafter[1]}{%
    \global\expandafter\edef\csname\@curr@bibitem @hereafter\endcsname{%
    \ifhyper@opcit
        \noexpand\hyperlink{\@curr@bibitem @key}{#1}\else#1\fi}}{\relax}
\newBibCommand{\bibcase[1]}{\lowercase{#1}}{\uppercase{#1}}
\newBibCommand\QuoteOrNot{\gdef\@quoteornot{''\global\let\@quoteornot\relax}}{\relax}
%    \end{macrocode}
%
%\subsubsection{Omitting mechanism}
%
%Here we use a feature of |\@nameuse|: an undefined command called by this method will not be an error, but a |\relax|. Thus, when a |\with{|\meta{field}|}| redefines |\omit@field| to be |\@gobble|, the result of |\toomit| (in the footnotes) will be either |\@gobble\@gobble| or |\relax\@gobble|. In either case, |\with| has to take care of re-omitting (adding its argument to a list, eventually gone over by |\finalize@cite|).
%    \begin{macrocode}
\if@omitting
    \newBibCommand{\toomit[2][omitted]}{%
        \@nameuse{omit@#1}\@gobble{#2}}{#2}%    
        \newcommand\with[1]{%                   
            \global\expandafter\let\csname omit@#1\endcsname\@gobble
            \edef\@reomit{\@reomit,#1}}
    \newcommand\@reomit{omitted}%
\else
    \newcommand\toomit[2][omitted]{#2}
    \let\with\@gobble
\fi
%    \end{macrocode}
%
%\subsubsection{Reading the \texttt{bbl}}
%
%After having set up the communication, the \texttt{bbl} file is read (if it exists). This is done within a group, for |thebibliography| and |\bibitem| are redefined (the former as nothing). At the moment, the communication commands have their `footnote meaning,' the first part of their definition (the second part has been stored in |\opcit@redefs|, to be redeemed later on).
%
%In |\bibitem|, |#1| is the label for the |\cite| command; |#2| is a series of declarations written out to the |bbl| file by the \textsc{Bib}\TeX\ style (one of them, required, is the command |\biblastnames|, whose argument contains only the last name(s) of the author(s)). |#3| is the full author(s)' name(s), that appears the first time the work is |\cite|'d. Finally, |#4| is the rest of the information for the entry.
%
%    \begin{macrocode}
\bgroup
    \renewcommand{\newBibCommand}[3]{%
        \newcommand#1{#2}%
        \global\opcit@defs\expandafter{\the\opcit@defs
            \newBibCommand{#1}{#2}{#3}}}
    \renewenvironment{thebibliography}[1]{\relax}{\relax}
    \def\toomit{\noexpand\toomit}%
    \def\QuoteOrNot{\noexpand\QuoteOrNot}%
    \long\def\bibitem#1#2\opcitstart #3\bibpunctuation \newblock#4\opcitend{%
        \ifx#3\sameauthors\else\def\@lastauthors{#3}\fi
        \global\expandafter\edef\csname#1@author\endcsname{\@lastauthors}%
        \global\def\@curr@bibitem{#1}%
        \global\expandafter\edef\csname #1@first\endcsname{%
            \noexpand\opcit@noreferror{#1}}%
        \global\@namedef{#1@star}{%
            \global\expandafter\edef\csname #1@first\endcsname{\thefootnote}%
            \ifhyper@opcit\hypertarget{#1@key}{}\fi
            #4}%
        \global\def\hereafter{\@nameuse{#1@hereafter}}%
        \global\expandafter\def\csname @#1\endcsname{%
            \@nameuse{#1@author}, \@nameuse{#1@star}}%
        \bibhereafter{\if@opcit\noexpand\opcittext\else\opcitwarning{#1}\fi}%
        #2}
    \InputIfFileExists{\jobname.bbl}{\global\opcit@bbltrue}%
        {\global\opcit@bblfalse\PackageWarningNoLine{opcit}{%
            No \jobname.bbl file. There will be no footnote references}}
\egroup
\the\opcit@defs
\ifopcit@bbl
    \renewcommand{\cite}{\@ifstar{\opcit@cite@star}{\opcit@cite}}%
\fi
%    \end{macrocode}
%
%The last construction ensures that if a |bbl| was not found, \LaTeX\ will still understand |\cite|.
%
%This reading of the |bbl| happens at the beginning of the job, but it can also happen by the user's request (to reset the cites to the full information), with |\resetcites|. Here goes that. I can't remember why exactly---it has something to do with argument expansion---but this cannot be done by defining a common command for both macros.
%
%    \begin{macrocode}
\newcommand*\resetcites{%
   \bgroup
      \renewcommand{\newBibCommand}[3]{%
         \newcommand##1{##2}%
         \global\opcit@defs\expandafter{\the\opcit@defs
               \newBibCommand{##1}{##2}{##3}}}
      \renewenvironment{thebibliography}[1]{\relax}{\relax}
      \def\toomit{\noexpand\toomit}%
      \def\QuoteOrNot{\noexpand\QuoteOrNot}%
      \long\def\bibitem##1##2\opcitstart ##3\bibpunctuation \newblock##4\opcitend{%
         \ifx##3\sameauthors\else\def\@lastauthors{##3}\fi
         \global\expandafter\edef\csname##1@author\endcsname{\@lastauthors}%
         \global\def\@curr@bibitem{##1}%
         \global\expandafter\edef\csname ##1@first\endcsname{%
            \noexpand\opcit@noreferror{##1}}%
         \global\@namedef{##1@star}{%
               \global\expandafter\edef\csname ##1@first\endcsname{\thefootnote}%
               \ifhyper@opcit\hypertarget{##1@key}{}\fi
               ##4}%
         \global\def\hereafter{\@nameuse{##1@hereafter}}%
         \global\expandafter\def\csname @##1\endcsname{%
            \@nameuse{##1@author}, \@nameuse{##1@star}}%
         \bibhereafter{\if@opcit\noexpand\opcittext\else\opcitwarning{##1}\fi}%
         ##2}
      \let\newcommand\renewcommand
      \InputIfFileExists{\jobname.bbl}{\global\opcit@bbltrue}%
         {\global\opcit@bblfalse\PackageWarningNoLine{opcit}{%
               No \jobname.bbl file. There will be no footnote references}}
   \egroup}
%    \end{macrocode}
%
%\subsubsection{The \cs{cite}s}
%
%When |opcit| reads the |bbl| file, a series of commands are defined for each bibliographical entry. The most important are (for the entry |foo|):
%
%\begin{itemize}
%\item|\foo@author| has the full author name(s). It is used only the first time |foo| is |\cite|'d.
%\item|\foo@authors| contains the last name(s), to be used in post-citations.
%\item|\foo@star| contains the rest of the information for the entry. (The name of this command responds to |\cite*| being a |\cite| without author.)
%\item|\foo@hereafter| equals |\opcittext| by default, but is changed by a |\bibhereafter| in the |bbl| file.
%\item|\@foo| expands initially to |\foo@author, \foo@star|---i.e., authors (full name) followed by info.
%\end{itemize}
%
%This information is used by |\cite| and |\cite*| (redefined earlier as |\opcit@cite|). Before expanding into the actual information, they check if they appear in a footnote.\footnote{This requires the document class to set \cs{interfootnotelinepenalty} different from \cs{interlinepenalty}.} If not, they call a |\footnote|, appending a period at the end if necessary. Then, |\cite| calls |\@foo|, while |\cite*| calls |\foo@star|. 
%
%Then they call the redefinition routine |\renew@cites| (section~\ref{renew}). The main task of this latter is to substitute |\foo@authors| (only last names) for the original |\foo@author| (full names), and redefine |\foo@star| (which was the rest of the information) as |\foo@hereafter| (which is either |\opcittext| or the user's |hereafter| field). (However, this simple main task is obscured in the code by the \emph{Idem} mechanism.)
%
%    \begin{macrocode}
\newcommand{\opcit@cite}[2][\@empty]{\nocite{#2}%
    \ifnum\interlinepenalty=\interfootnotelinepenalty\opcit@footnotetrue
        \else\opcit@footnotefalse\expandafter\footnote\fi
    {\@nameuse{@#2}%
    \check@for@period{\@nameuse{@#2}}%
    \finalize@cite{#1}{#2}}}
\newcommand{\opcit@cite@star}[2][\@empty]{\nocite{#2}%
    \ifnum\interlinepenalty=\interfootnotelinepenalty\opcit@footnotetrue
        \else\opcit@footnotefalse\expandafter\footnote\fi
    {\@nameuse{#2@star}%
    \check@for@period{\@nameuse{#2@star}}%
    \finalize@cite{#1}{#2}}}
\newcommand\finalize@cite[2]{%
    \global\@lastcite=\c@footnote\relax
    \ifx\@empty#1\else
        \ifcheck@@idem
            \check@for@period{\idemtext}%
            \def\this@opt{#1}%
            \ifx\last@opt\this@opt\else
                \check@for@period{#1},\@quoteornot\ #1%
            \fi
        \else\check@for@period{#1},\@quoteornot\ #1%
        \fi
    \fi
    \ifopcit@footnote\peri@dtrue\fi
    \ifperi@d\else.\@quoteornot\fi
    \global\def\last@opt{#1}%
    \check@@idemfalse
    \if@omitting
        \@for\@tempcsa :=\@reomit \do
            {\global\expandafter\let\csname omit@\@tempcsa\endcsname\relax}%
        \global\def\@reomit{omitted}%
    \fi
    \renew@cites{#2}%
    }
%    \end{macrocode}
%
%The first lines of |\finalize@cite| are part of the mechanism to catch identical optional arguments to two |\cites| in a row. It is a function whose methods are scattered here and there in the code, but it is simple enough if anyone ever needs to follow it.
%
%\subsubsection{Redefinition routine}\label{renew}
%
% The redefinition routine is in charge of catching two identical |\cite|'s in a row, in which case it typesets |\idemtext|. But the main task is to reduce |\foo@star| (the information other than author of the entry |foo|) to |\foo@hereafter|.
%
%    \begin{macrocode}
\newcommand{\renew@cites}[1]{%
    \recover@last%
    \global\def\last@cited{#1}%
    \cited{#1}%
    \ifopcit@footnote\else\if@idem
        \global\@namedef{@#1}{\@idem{@#1}}%
        \global\@namedef{#1@star}{\@idem{@#1}}%
    \fi\fi
    \global\def\hereafter{\textit{\@nameuse{#1@hereafter}}}}%
\newcommand*\cited[1]{\@for\@tempcsa :=#1 \do{%
    \global\@namedef{@#1}{\@nameuse{#1@authors},~\@nameuse{#1@hereafter}}%
    \global\@namedef{#1@star}{\@nameuse{#1@hereafter}}}}%
\newcommand\recover@last{%
    \global\expandafter\edef\csname @\last@cited\endcsname{%
        \noexpand\@nameuse{\last@cited @authors},%
        ~{\noexpand\@nameuse{\last@cited @hereafter}}}%
    \global\expandafter\edef\csname\last@cited @star\endcsname{%
        {\noexpand\@nameuse{\last@cited @hereafter}}}%
    }
\newcommand\@idem[1]{\advance\@lastcite1\relax
    \ifnum\@lastcite=\c@footnote
        \idemtext\ifcheck@idem\check@@idemtrue\fi
    \else
        \check@@idemfalse\recover@last\@nameuse{#1}%
    \fi}
%    \end{macrocode}
%
%\subsection*{Additional functions and user commands}
%
%    \begin{macrocode}
\def\check@for@period#1{{\normalsfcodes\setbox0\hbox{#1%
    \ifnum\spacefactor=\sfcode`.\global\peri@dtrue\else
    \global\peri@dfalse\fi}}}
\ifhyper@opcit
    \newcommand*\bibref[1]{\hyperlink{#1@key}{\@nameuse{#1@first}}}
\else
    \newcommand*\bibref[1]{\@nameuse{#1@first}}
\fi
\newcommand\nobibliography[1]{\if@filesw 
    \immediate\write\@auxout{\string\bibdata{#1}}\fi
    \if@omitting\PackageWarningNoLine{opcit}{No final references list, 
        there might be information within \string\toomit\space commands that will be lost}\fi}
\let\opcit@bibliography\bibliography
\renewcommand{\bibliography}{%
    \renewcommand\newBibCommand[3]{\relax}%
    \the\opcit@redefs\opcit@bibliography}
\newcommand{\thebib@renew}{}
\@ifundefined{chapter}{%
    \renewcommand{\thebib@renew}{\section*{\refname}\@mkboth{\refname}{\refname}}}{%
    \renewcommand{\thebib@renew}{\chapter*{\bibname}\@mkboth{\bibname}{\bibname}}}%
\renewenvironment{thebibliography}[1]
     {\thebib@renew%
      \the\opcit@redefs%
      \list{}%
           {\setlength\labelwidth{\z@}%
            \leftmargin\bibindent
            \itemindent -\bibindent
            \parsep \z@
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
%    \end{macrocode}
%</package>
%\section{The \texttt{opcit.bst} bibliography style}
%
%I have had no time to fully document this bibliography style, or even to purify it and make it most economical\dots
%    \begin{macrocode}
%<*bst>
ENTRY
  { address
    author
    booktitle
    chapter
    edition
    editor
    hereafter
    howpublished
    institution
    journal
    key
    month
    note
    number
    organization
    pages
    publisher
    school
    series
    title
    type
    url
    urldate
    volume
    year
  }
  {}
  { label }

INTEGERS { output.state before.all mid.sentence after.sentence 
      after.block quoted.state period.state }

STRINGS { s t last.authors quotes }

FUNCTION {init.state.consts}
{ #0 'period.state :=
  #0 'before.all :=
  "" 'last.authors :=
  "" 'quotes :=
}

FUNCTION {new.block}
{ output.state before.all =
    'skip$
    { after.block 'output.state := }
  if$
}
FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}

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

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

FUNCTION {field.or.null}
{ duplicate$ empty$
    { pop$ "" }
    'skip$
  if$
}

FUNCTION {emphasize}
{ duplicate$ empty$
    { pop$ "" }
    { "{\em " swap$ * "}" * }
  if$
}

INTEGERS { nameptr namesleft numnames }

FUNCTION{format.names}
{ 's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr "{ff }{vv~}{ll}{,~jj}" format.name$ 't :=
      nameptr #1 >
        { namesleft #1 >
            { ", " * t * }
            { numnames #2 >
                { "," * }
                'skip$
            if$
            t "others" =
                { " et~al." * }
                { " and " * t * }
            if$
            }
          if$
        }
        't
     if$
     nameptr #1 + 'nameptr :=
     namesleft #1 - 'namesleft :=
   }
   while$
}

FUNCTION {format.swap.names}
{ 's :=
  s num.names$ 'numnames :=
  "\SwapNames{" s #1 "{ff}" format.name$ 
  duplicate$ #-1 #1 substring$ 
  "." =
    { #1 'period.state := }
    'skip$ 
  if$
  * "}{" * 
  s #1 "{vv~}{ll}" format.name$ * "}" *
  s #1 "{, jj}" format.name$ * 
  numnames #3 >
    { " et~al." * #1 'period.state := }
    { numnames #1 > 
        { #2 'nameptr :=
            numnames #1 - 'namesleft :=
                { namesleft #0 > }
                { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
                    namesleft #1 >
                        { ", " * t * }
                        { " and " * t * }
                    if$
                    nameptr #1 + 'nameptr :=
                    namesleft #1 - 'namesleft :=
                }
                while$
        }
        'skip$
      if$
    }
  if$
}

FUNCTION {format.authors}
{   author empty$
    { ""
      "" 'last.authors :=
    }
    { author format.names
      last.authors =
        { "\sameauthors" }
        { before.all output.state =
            { author format.swap.names }
            { author format.names }
          if$ }
      if$
      author format.names 'last.authors :=
    }
  if$
}

FUNCTION {format.editors}
{ editor empty$
    { "" }
    { before.all output.state =
        { editor format.swap.names }
        { editor format.names }
      if$
    }
  if$
}

FUNCTION {format.editors.ed}
{ editor empty$
    { "" }
    { before.all output.state =
        { editor format.swap.names }
        { editor format.names }
      if$
      editor num.names$ #1 > 
        { " (eds.)" * }
        { " (ed.)" * }
      if$
      #0 'period.state :=
    }
  if$
}

FUNCTION {n.dashify}
{ 't :=
  ""
    { t empty$ not }
    { t #1 #1 substring$ "-" =
    { t #1 #2 substring$ "--" = not
        { "--" *
          t #2 global.max$ substring$ 't :=
        }
        {   { t #1 #1 substring$ "-" = }
        { "-" *
          t #2 global.max$ substring$ 't :=
        }
          while$
        }
      if$
    }
    { t #1 #1 substring$ *
      t #2 global.max$ substring$ 't :=
    }
      if$
    }
  while$
}

FUNCTION {format.date}
{ year empty$
    { month empty$
        { "" }
        { "there's a month but no year in " cite$ * warning$
          "\toomit[month]{" month * " }" *
        }
      if$
    }
    { month empty$
        'year
        { "\toomit[month]{" month * " }" * year * }
      if$
    }
  if$
}

FUNCTION {tie.or.space.connect}
{ duplicate$ text.length$ #3 <
    { "~" }
    { " " }
  if$
  swap$ * *
}

FUNCTION{either.warning}
{   empty$
        'pop$
        { "can't use both " swap$ * " fields in " * cite$  * warning$ }
    if$
}
FUNCTION {format.bvolume}
{ volume empty$
    { "" }
    { "\bibcase volume" volume tie.or.space.connect
      series empty$
        'skip$
        { " of " * series emphasize * }
      if$
      "volume and number" number either.warning
    }
  if$
}

FUNCTION {format.number.series}
{ volume empty$
    { number empty$
        { series empty$
            { "" }
            { ", series " * series * "" }
          if$ 
        }
        { "\bibcase number"
          number tie.or.space.connect
          series empty$
            { "there's a number but no series in " cite$ * warning$ }
            { " in " * series * }
          if$
        }
      if$
    }
    { "" }
  if$
}

INTEGERS { multiresult}

FUNCTION {multi.page.check}
{ 't :=
  #0 'multiresult :=
    { multiresult not
      t empty$ not
      and
    }
    { t #1 #1 substring$
      duplicate$ "-" =
      swap$ duplicate$ "," =
      swap$ "+" =
      or or
    { #1 'multiresult := }
    { t #2 global.max$ substring$ 't := }
      if$
    }
  while$
  multiresult
}

FUNCTION {format.pages}
{ pages empty$
    { "" }
    { pages multi.page.check
        { "\toomit[pages]{\bibcase " swap$ * pages n.dashify tie.or.space.connect "}" * }
        { "\toomit[pages]{\bibcase " swap$ * pages tie.or.space.connect "}" * }
      if$
    }
  if$
}

FUNCTION {format.vol.num.date.pages}
{ volume empty$
    'skip$
    { volume }
  if$
  number empty$
    'skip$
    { "/" number * 
      volume empty$
        { "there's a number but no volume in " cite$ * warning$ }
        { * }
      if$
    }
  if$
  " (" * format.date * ")" *
  pages empty$
    'skip$
    { duplicate$ empty$
        { pop$ "" format.pages * }
        { ": " format.pages * }
      if$
    }
  if$
}

FUNCTION {format.chapter.pages}
{ chapter empty$
    { pages empty$
        { "" }
        { ": " format.pages }
      if$
    }
    { "\newblock\bibpunctuation "
      type empty$
        { "\bibcase chapter" * }
        { type "l" change.case$ * }
      if$
      chapter tie.or.space.connect
      pages empty$
    'skip$
    { ", pages " * format.pages * }
      if$
    }
  if$
}

FUNCTION{get.lastnames}
{ 's :=
  s num.names$ 'numnames :=
  s #1 "{vv~}{ll}" format.name$ 
  numnames #3 >
    { " et~al." * }
    { numnames #1 > 
        { #2 'nameptr :=
            numnames #1 - 'namesleft :=
                { namesleft #0 > }
                { s nameptr "{vv~}{ll}" format.name$ 't :=
                    namesleft #1 >
                        { ", " * t * }
                        { " and " * t * }
                    if$
                    nameptr #1 + 'nameptr :=
                    namesleft #1 - 'namesleft :=
                }
                while$
        }
        'skip$
      if$
    }
  if$
}

FUNCTION {make.address.publisher.year}
{   "" 
    address empty$
        'skip$
        { address * }
    if$
    publisher empty$
        'skip$
        { address empty$
            { publisher * }
            { ": " * publisher * }
        if$
        }
    if$
    format.date duplicate$ "" =
        'pop$
        { swap$ duplicate$ "" =
            { * }
            { swap$ ", " swap$ *  * }
        if$}
    if$
    duplicate$ "" =
        'skip$
        { "\bibparenthesis{" swap$ * "}" * }
    if$
}

FUNCTION {make.url}
{   "\url{" url * "}" * 
    urldate empty$
        { "there is url but no urldate in " cite$ * warning$ }
        { " (accessed " * urldate * ")" * }
    if$
}
    
FUNCTION {output.bibitem}
{ newline$
  "\bibitem{" write$
  cite$ "}" * write$
  ""
  newline$
  "\biblastnames{" write$
  author empty$
    { editor empty$ 
        { organization empty$
            { "no last names in " cite$ * warning$ }
            { organization }
            if$
        }
        { editor get.lastnames 
          editor num.names$ #1 >
            { " (eds.)" * }
            { " (ed.)" * }
          if$
        }
      if$
    }
    { author get.lastnames }
    if$
  "}" * write$
  before.all 'output.state :=
}

FUNCTION{output.start}
{   hereafter empty$
        'skip$
        { "\bibhereafter{{\noexpand\em " write$ hereafter "}}" * write$ }
        if$
    newline$
    "\opcitstart " write$
}

FUNCTION{output.as.block}
{   duplicate$ "" =
        'pop$
        { period.state #1 =
            { "\GobbleOrNot" #0 'period.state := }
            { "" }
          if$
          "\bibpunctuation" * quotes * write$ newline$ "\newblock " swap$ * write$ 
          #1 'output.state :=
        }
    if$
    "" 'quotes :=
}

FUNCTION{output.omitted}
{  't :=
   duplicate$ "" =
      { pop$ }
      { "\toomit[" t * "]{\bibpunctuation\bibcase " * swap$ * "}" * write$ }
   if$
}

FUNCTION {fin.entry}
{  write$ 
   note empty$ {""} {note} if$ "note" output.omitted
   "\opcitend" write$
   newline$
}

FUNCTION{empty.warning}
{   't :=
    duplicate$ empty$
        { pop$ "empty " t * " in " * cite$ * warning$ ""}
        'skip$
    if$
}

FUNCTION{empty.chapter.and.pages.warning}
{  't := 
   chapter empty$
      { pages empty$
         { pop$ "empty " t * " in " * cite$ * warning$ "" }
         'skip$
        if$
      }
      'skip$
   if$

}

FUNCTION{book}
{   output.bibitem
    output.start
    author empty$
        { format.editors.ed "author and editor" empty.warning write$ }
        { format.authors "author and editor" editor either.warning write$ }
    if$
    title emphasize "title" empty.warning output.as.block
    edition empty$
        'skip$
        { "\bibcase " edition * " edition" * output.as.block }
    if$ 
    howpublished missing$
        'skip$
        { "\bibcase " howpublished * output.as.block }
    if$
    format.bvolume "volume" output.omitted
    format.number.series "number" output.omitted
    make.address.publisher.year write$
    url empty$ 
        'skip$
        { make.url output.as.block }
    if$
    fin.entry
}

FUNCTION{article}
{   output.bibitem
    output.start
    format.authors "author" empty.warning write$
    "``" title * "title" empty.warning output.as.block "''" 'quotes := 
    howpublished empty$ 
        'skip$
        { "\bibpunctuation'' \newblock\toomit[howpublished]{\bibcase 
            " howpublished  * write$ 
          "}" 'quotes :=
        }
    if$
    journal emphasize "journal" empty.warning 
    " " * format.vol.num.date.pages "year" empty.warning * output.as.block
    url empty$ 
        'skip$
        { make.url output.as.block }
    if$
    fin.entry
}

FUNCTION {incollection}
{ output.bibitem
  output.start
  format.authors "author" empty.warning write$
  "``" title * "title" empty.warning output.as.block "''" 'quotes :=
  "\bibcase in " output.as.block
  crossref empty$ 
    'skip$
    { "\bibincite{" crossref * "}" * write$ }
  if$  
  "{" write$
  editor empty$
    'skip$
    { format.editors.ed ", " * write$ } 
  if$
  booktitle emphasize "booktitle" empty.warning write$
  edition empty$
    'skip$
    { "\bibcase " edition * " edition" * output.as.block }
  if$
  make.address.publisher.year write$
  url empty$ 
      'skip$
      { make.url output.as.block }
  if$
  "}" write$
  format.chapter.pages write$
  fin.entry
}
    
FUNCTION {inbook}
{ output.bibitem
  output.start
  author empty$
      { format.editors.ed "author and editor" empty.warning write$ }
      { format.authors "author and editor" editor either.warning write$ }
  if$
  "``" title * "title" empty.warning output.as.block "''" 'quotes :=
  chapter empty$
    'skip$
    { type empty$
      { "\bibcase chapter "  chapter *  }
      { "\bibcase " type * " " * chapter * }
      if$
    } 
  if$
  pages empty$
      'skip$
      { chapter empty$
        { "\bibcase pages" pages n.dashify tie.or.space.connect }
        { "\toomit[pages]{ (pages" * pages n.dashify tie.or.space.connect ")}" * }
        if$
      }
  if$ 
  "chapter and pages" empty.warning 
  " of " * 
  crossref empty$ 
    { booktitle emphasize * "booktitle" empty.warning 
      edition empty$
         'skip$
         { ", " * edition "l" change.case$ * " edition" * }
      if$
      howpublished missing$
        'skip$
        { ", " * howpublished * }
      if$
      output.as.block
      make.address.publisher.year write$ 
    }
    { "\bibincitestar{" * crossref * "}{" * booktitle emphasize * "}" * output.as.block }
  if$
  fin.entry 
}

FUNCTION{phdthesis}
{ output.bibitem
  output.start
  format.authors "author" empty.warning write$
  title emphasize "title" empty.warning 
  "\bibparenthesis{Ph.\,D.\ diss\GobbleOrNot.}" * output.as.block
  address empty$
    { "" }
    { address ": " * }
  if$
  school "school" empty.warning * output.as.block
  month empty$
    { "" }
    { month " " * }
  if$
  year "year" empty.warning * output.as.block
  fin.entry
}

FUNCTION{mastersthesis}
{ output.bibitem
  output.start
  format.authors "author" empty.warning write$
  title emphasize "title" empty.warning 
  "\bibparenthesis{M.\,A.\ thesis}" * output.as.block
  address empty$
    { "" }
    { address ": " * }
  if$
  school "school" empty.warning * output.as.block
  month empty$
    { "" }
    { month " " * }
  if$
  year "year" empty.warning * output.as.block
  fin.entry
}

FUNCTION{proceedings}
{   output.bibitem
    output.start
    editor empty$
        { organization "editor and organization" empty.warning write$ }
        { format.editors.ed "editor" empty.warning write$ }
    if$
    title emphasize "title" empty.warning output.as.block
    format.bvolume "volume" output.omitted
    format.number.series "number" output.omitted
    make.address.publisher.year write$
    fin.entry
}  
  
FUNCTION {booklet}
{ book }
  
FUNCTION {inproceedings}
{ output.bibitem
  output.start
  format.authors "author" empty.warning write$
  "``" title * "title" empty.warning output.as.block "''" 'quotes :=
  "\bibcase in " output.as.block
  crossref empty$ 
    'skip$
    { "\bibincite{" crossref * "}" * write$ }
  if$  
  "{" booktitle emphasize * "booktitle" empty.warning write$
  editor empty$
    { organization "editor and organization" empty.warning output.as.block }
    { ", edited by " format.editors * write$ }
  if$
  make.address.publisher.year write$
  "}" write$
  format.chapter.pages write$
  fin.entry
}
  
  
FUNCTION {misc}
{ output.bibitem
  output.start
  format.authors "author" empty.warning write$
  title output.as.block
  howpublished missing$
    'skip$
    { howpublished output.as.block }
  if$
  format.date output.as.block
  fin.entry
}

FUNCTION {default.type} { misc }

MACRO {jan} {"January"}

MACRO {feb} {"February"}

MACRO {mar} {"March"}

MACRO {apr} {"April"}

MACRO {may} {"May"}

MACRO {jun} {"June"}

MACRO {jul} {"July"}

MACRO {aug} {"August"}

MACRO {sep} {"September"}

MACRO {oct} {"October"}

MACRO {nov} {"November"}

MACRO {dec} {"December"}

MACRO {acmcs} {"ACM Computing Surveys"}

MACRO {acta} {"Acta Informatica"}

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

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

MACRO {ibmsj} {"IBM Systems Journal"}

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

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

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

MACRO {ipl} {"Information Processing Letters"}

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

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

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

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

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

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

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

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

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

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

MACRO {tcs} {"Theoretical Computer Science"}

READ

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

INTEGERS { len }

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

FUNCTION {sort.format.names}
{ 's :=
  #1 'nameptr :=
  ""
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { nameptr #1 >
        { " " * }
        'skip$
      if$
      s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
      nameptr numnames = t "others" = and
        { "et al" * }
        { t sortify * }
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

FUNCTION {sort.format.title}
{ 't :=
  "A " #2
    "An " #3
      "The " #4 t chop.word
    chop.word
  chop.word
  sortify
  #1 global.max$ substring$
}

FUNCTION {author.sort}
{ author empty$
    { key empty$
    { "to sort, need author or key in " cite$ * warning$
      ""
    }
    { key sortify }
      if$
    }
    { author sort.format.names }
  if$
}

FUNCTION {author.editor.sort}
{ author empty$
    { editor empty$
    { key empty$
        { "to sort, need author, editor, or key in " cite$ * warning$
          ""
        }
        { key sortify }
      if$
    }
    { editor sort.format.names }
      if$
    }
    { author sort.format.names }
  if$
}

FUNCTION {author.organization.sort}
{ author empty$
    { organization empty$
    { key empty$
        { "to sort, need author, organization, or key in " cite$ * warning$
          ""
        }
        { key sortify }
      if$
    }
    { "The " #4 organization chop.word sortify }
      if$
    }
    { author sort.format.names }
  if$
}

FUNCTION {editor.organization.sort}
{ editor empty$
    { organization empty$
    { key empty$
        { "to sort, need editor, organization, or key in " cite$ * warning$
          ""
        }
        { key sortify }
      if$
    }
    { "The " #4 organization chop.word sortify }
      if$
    }
    { editor sort.format.names }
  if$
}

FUNCTION {presort}
{ type$ "book" =
  type$ "inbook" =
  or
    'author.editor.sort
    { type$ "proceedings" =
    'editor.organization.sort
    { type$ "manual" =
        'author.organization.sort
        'author.sort
      if$
    }
      if$
    }
  if$
  "    "
  *
  year field.or.null sortify
  *
  "    "
  *
  title field.or.null
  sort.format.title
  *
  #1 entry.max$ substring$
  'sort.key$ :=
}
FUNCTION {begin.bib}
{ preamble$ empty$
    'skip$
    { preamble$ write$ newline$ }
  if$
  "\newBibCommand{\bibparenthesis[1]}{ (#1)}{. \newblock #1}" write$ newline$
  "\newBibCommand{\bibincite[2]}{\recover@last\@nameuse{@#1}}{#2}" write$ newline$
  "\newBibCommand{\bibincitestar[2]}{\recover@last " write$ newline$
  "     \@nameuse{#1@star}}{#2}" write$ newline$
  "\newBibCommand{\SwapNames[2]}{#1 #2}{#2, #1}" write$ newline$
  "\newBibCommand{\GobbleOrNot}{\relax}{\newblock\@gobble}" write$ newline$
  "\begin{thebibliography}{}"   write$ newline$
}
ITERATE {presort}

SORT

EXECUTE {begin.bib}

EXECUTE {init.state.consts}

ITERATE {call.type$}

FUNCTION {end.bib}
{ newline$
  "\end{thebibliography}" write$ newline$
}

EXECUTE {end.bib}
%</bst>
%    \end{macrocode}