summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/footbib/footbib.dtx
blob: b68a1694e58ab99cd9ed2b8640dddae736d66e8e (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
% \iffalse
%%
%% File: footbib.dtx Copyright (C) 1997-2010 Eric Domenjoud
%%
%% Eric Domenjoud,
%% LORIA/CNRS
%% E-mail: Eric.Domenjoud@loria.fr
%%
% This program may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% This program consists of the files footbib.dtx and footbib.ins

\def\fileversion{2.0.7}
\def\filedate{2007/02/20}
%<*driver>
%%
%%  To produce the documentation, do the following:
%%
%%    latex footbib.dtx
%%    latex footbib.dtx
%%    makeindex -s gind.ist footbib.idx -o footbib.ind
%%    makeindex -s gglo.ist footbib.glo -o footbib.gls
%%    latex footbib.dtx
%%
%%  In case makeindex does not find the style files gind.ist and gglo.ist,
%%  either set the environment variable INDEXSTYLE to the path where these
%%  files reside or use the full path in the commands above. 
%%
\documentclass{ltxdoc}
%\DisableCrossrefs % uncomment when index is ready
\CodelineIndex
\RecordChanges
%\OnlyDescription   % comment out for implementation details
%\OldMakeindex     % use if your MakeIndex is pre-v2.9

\title{The \textsf{footbib} package\thanks{This file has version
       number \fileversion, last revised \filedate.}}
\author{Eric Domenjoud\\Eric.Domenjoud@loria.fr}
\date{\filedate}

\hfuzz=20pt
\begin{document}
\DocInput{footbib.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{2069}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \DoNotIndex{\',\+,\-,\.,\:,\<,\=,\>,\?,\^,\`,\~,\,,\@MM,\@Mii}
% \DoNotIndex{\@Miii,\@addmarginpar,\@addtocurcol,\@botlist,\@bsphack,\@cclv}
% \DoNotIndex{\@colht,\@colroom,\@combinefloats,\@currbox,\@currlist}
% \DoNotIndex{\@dbldeferlist,\@dblfloatplacement,\@dbltoplist,\@deferlist}
% \DoNotIndex{\@doclearpage,\@ehb,\@empty,\@esphack,\@finalstrut,\@firstofone}
% \DoNotIndex{\@firstoftwo,\@for,\@freelist,\@gobble,\@holdpg,\@ifnextchar}
% \DoNotIndex{\@ifpackagelater,\@ifstar,\@ifundefined,\@input,\@kludgeins}
% \DoNotIndex{\@latexbug,\@latexerr,\@m,\@M,\@makecol,\@makefcolumn}
% \DoNotIndex{\@makeother,\@makespecialcolbox,\@maxdepth,\@midlist,\@nameuse}
% \DoNotIndex{\@ne,\@next,\@nil,\@nnil,\@onlypreamble,\@opcol,\@outputbox}
% \DoNotIndex{\@outputpage,\@pagedp,\@pageht,\@parboxrestore,\@reinserts}
% \DoNotIndex{\@specialoutput,\@tempa,\@tempb}
% \DoNotIndex{\@tempboxa,\@tempdima,\@tempswafalse,\@tempswatrue,\@textbottom}
% \DoNotIndex{\@texttop,\@toplist,\@undefined,\@whilesw,\active,\addpenalty}
% \DoNotIndex{\advance,\afterassignment,\begingroup,\bfseries,\bigskipamount}
% \DoNotIndex{\box,\boxmaxdepth,\c@fb,\catcode,\clearpage,\color@begingroup}
% \DoNotIndex{\color@endgroup,\columnwidth,\count,\count@,\csname}
% \DoNotIndex{\CurrentOption,\deadcycles,\DeclareOption,\DeclareRobustCommand}
% \DoNotIndex{\def,\dimen}
% \DoNotIndex{\dimen@,\do,\dp,\edef,\else,\end,\endcsname,\endgroup,\endinput}
% \DoNotIndex{\ExecuteOptions,\expandafter,\fi,\floatingpenalty,\footins}
% \DoNotIndex{\footnotesize,\gdef,\GenericError,\global,\hbox,\hfil,\hrule}
% \DoNotIndex{\hsize,\hskip,\ht,\if@fcolmade,\if@filesw,\if@firstcolumn}
% \DoNotIndex{\if@nobreak,\if@tempswa,\if@twocolumn,\ifdim,\iffalse,\ifnum}
% \DoNotIndex{\ifodd,\ifvbox,\ifvoid,\ifx,\ignorespaces,\immediate}
% \DoNotIndex{\input,\inputlineno,\insert,\interfootnotelinepenalty}
% \DoNotIndex{\interlinepenalty,\jobname,\kern,\lastbox,\lccode,\leftskip}
% \DoNotIndex{\let,\long,\lowercase,\maxdepth,\maxdimen,\meaning}
% \DoNotIndex{\MessageBreak,\NeedsTeXFormat,\newcommand,\newcount,\newdimen}
% \DoNotIndex{\newif,\newinsert,\newtoks,\newwrite,\nobreak,\noexpand}
% \DoNotIndex{\normalcolor,\normalfont,\outputpenalty,\p@,\PackageError}
% \DoNotIndex{\PackageWarning,\par,\penalty,\ProcessOptions,\ProvidesPackage}
% \DoNotIndex{\relax,\renewcommand,\reset@font,\rule,\scriptspace,\setbox}
% \DoNotIndex{\settowidth,\skip,\space,\splitmaxdepth,\splittopskip,\string}
% \DoNotIndex{\strutbox,\textheight,\textsuperscript,\the,\thepage,\toks@}
% \DoNotIndex{\unhbox,\unskip,\unvbox}
% \DoNotIndex{\vbox,\vfil,\vskip,\vsplit,\wd,\write,\xdef,\z@}
%
%\makeatletter
% \newcommand\SpecialNonMacroIndex[2]{^^A
%   \@bsphack\index{#2\actualchar{\protect\ttfamily#2} (#1)\encapchar usage}^^A
%   \index{#1s:\levelchar{\protect\ttfamily#2}\encapchar usage}\@esphack}
% \newcommand\SpecialMainNonMacroIndex[2]{^^A
%   \@bsphack\special@index{#2\actualchar{\string\ttfamily\space#2}
%                 (#1)\encapchar main}^^A
%   \index{#1s:\levelchar{\protect\ttfamily#2}\encapchar main}\@esphack} 
% \newcommand*\NonM@cro@[1]{\m@cro@\iffalse{#1}^^A
%   \let\SpecialMainEnvIndex\fb@tmp\ignorespaces}
% \newenvironment{NonMacro}[1]{\let\fb@tmp\SpecialMainEnvIndex
%   \def\SpecialMainEnvIndex{\SpecialMainNonMacroIndex{#1}}^^A
%   \begingroup\@makeother\\\MakePrivateLetters\NonM@cro@}
%   {\endenvironment}
% \newcommand\DescribeNonMacro[2]{^^A
%   {\def\SpecialEnvIndex{\SpecialNonMacroIndex{#1}}\DescribeEnv{#2}}}
% \newcommand\newNonMacro[1]{\@newnonmacro#1\@nil}
% \def\@newnonmacro#1#2\@nil{\uppercase{\@@newnonmacro{#1}}{#1}{#2}}
% \newcommand\@@newnonmacro[3]{^^A
%   \newenvironment{#2#3}{\NonMacro{#2#3}}{\endNonMacro}^^A
%   \@namedef{Special#1#3Index}{\SpecialNonMacroIndex{#2#3}}^^A
%   \@namedef{SpecialMain#1#3Index}{\SpecialMainNonMacroIndex{#2#3}}^^A
%   \@namedef{Describe#1#3}{\DescribeNonMacro{#2#3}}}
% \newNonMacro{option}
% \newNonMacro{package}
% \newcommand\Index[2]{^^A
%     \SortIndex{#1 #2}{#1 #2\encapchar usage}^^A
%     \SortIndex{#2}{#2\levelchar#1 \string\*\encapchar usage}}
% \newcommand*\EndVerbChar{/}
% \begingroup
% \catcode`^=\active
% \gdef\IndexSetup{\catcode\expandafter`\EndVerbChar=\active\begingroup
%   \lccode`^=\expandafter`\verbatimchar\lccode`~=\expandafter`\EndVerbChar
%   \lowercase{\endgroup\def~{^\verbmeta}\def\verbmeta##1{\meta{##1}\verb*^}}}
% \endgroup
% \newcommand*\VerbSetup[1]{\begingroup\lccode`\~=\expandafter`\EndVerbChar
%   \lowercase{\let~\meta#1}\endgroup}
% \newcommand\Fb@Index[2]{\addvspace{-\lastskip}\VerbSetup{#1{#2}}^^A
%   \vskip-\MacrocodeTopsep\leavevmode}
% \newcommand\FbIndex{\Fb@Index\SpecialIndex}
% \newcommand\FbMainIndex{\Fb@Index\SpecialMainIndex}
% \newenvironment{FbPatch}[1]
%   {\vskip-\MacrocodeTopsep$\setbox\z@\hbox{$\braceld\m@th$}^^A
%    \braceld\leaders\vrule \@height\ht\z@ \@depth\z@\hfill
%    \lower.5ex\hbox{\kern1em{\tt footbib} #1\kern1em}^^A
%    \leaders\vrule\@height\ht\z@\@depth\z@\hfill\bracerd\m@th$^^A
%    \nobreak\vskip-\MacrocodeTopsep\nobreak}
%   {\nobreak\vskip-\MacrocodeTopsep$\setbox\z@\hbox{$\braceld\m@th$}^^A
%    \bracelu\leaders\vrule\@height\ht\z@\@depth\z@\hfill\braceru\m@th$^^A
%    \nobreak\vskip-\MacrocodeTopsep}
%\makeatother
%
% \newcommand\LATEX{({\let\TeX\relax\LaTeX})\TeX}
% \maketitle
% \setcounter{tocdepth}{2}
% \tableofcontents
%
% \section{General overview}
%
%   This package makes bibliographic references appear
% as footnotes. It defines a command |\footcite| which is similar to
% the |\cite| command of \LaTeX\ but the references cited in this way
% are inserted at the bottom of the pages. This \emph{foot
% bibliography} does not conflict with the standard one and both may
% exist simultaneously in a document. The command |\cite| may still be
% used to produce the standard bibliography. 
% 
%   The foot bibliography uses its own style and bibliographic
% database which are specified independently of the standard ones.
% Any standard bibliography style may be used. If the style does not provide
% explicit labels (e.g.~|plain|), the references are numbered.
% The default is to number the references in the order in which they
% appear in the |thebibliography| environment. This may be overridden through
% options which allow the user to define a \emph{numbering
% unit}\Index{numbering}{unit}. Then
% the references will be numbered in the order in which they are
% cited in the unit and the numbering restarts from 1 in each unit.
% The numbering unit may be a page, a double page, a chapter, a part or
% the whole document. Chapter and part may be used only if they are
% defined by the document class. 
%
%   The user may also define a \emph{citation unit}\Index{citation}{unit}
% which may be a page, a double page, a chapter, a part or the whole
% document. The text of a reference will be inserted only once in 
% each citation unit, on the page where the first citation occurs in
% the unit. 
%
% The mechanism used to put a reference only once in each citation
% unit may require several runs of \LaTeX\ (usually at least two) before the 
% references find their exact place. If necessary, \LaTeX\ will issue, near
% the end of the document, a warning saying 
% \begin{center}
%   |Package footbib Warning: Bibliography not yet stable. Rerun LaTeX.|
% \end{center}
%
%   Using |footbib| in a document \meta{doc}|.tex| produces a file
% \meta{doc}|.fb.aux|. One must pass the argument \meta{doc}|.fb| to \BibTeX\ 
% to produce the bibliography which will be put in the file
% \meta{doc}|.fb.bbl|. The exact sequence of commands is
% \begin{trivlist}\leftskip=\leftmargini\parindent=0pt\item[]
%   |latex|~\meta{doc}\\
%   |bibtex|~\meta{doc}|.fb|\\
%   |latex|~\meta{doc}\\
%   |latex|~\meta{doc}\\
%   \dots
% \end{trivlist}
%
% \begin{description}
% \item[Note:] The name \meta{doc}|.fb.aux| might cause some
%      problem on systems which do not allow a double extension in
%      a file name or put a limit on the length of file names.
%      A user command is provided to change it (see section~\ref{sec:custom}).
% \end{description}
%
% At the beginning of the document, |footbib| inputs the bibliography
% from the file \meta{doc}|.fb.bbl| (or the name given by the
% user). If one wants to include the |thebibliography|
% environment\SpecialEnvIndex{thebibliography} in the main document,
% this may be done with a |filecontents|
% environment\SpecialEnvIndex{filecontents} before the
% |\documentclass| command. See the \LaTeXe\ documentation for more
% details about this environment.
%
% \section{User interface}
%
% \subsection{Package options}
%
% \subsubsection{\texttt{oneside}/\texttt{twoside}}
%          \DescribeOption{oneside}^^A
%          \DescribeOption{twoside}^^A
%          The |oneside| and |twoside| options affect the behaviour
%          of |footbib| when either unit (citation or numbering) is
%          the page. In |oneside| mode, the actual unit is a single
%          page while in |twoside| mode, the unit is a double page. These
%          options may be used to override a global |oneside| or
%          |twoside| option.
%
% \subsubsection{\texttt{citeonce}{\normalfont[\texttt*]}}
%          \DescribeOption{citeonce}^^A
%          \DescribeOption{citeonce*}^^A
%          The |citeonce| option overrides the default \emph{citation
%          unit}\Index{citation}{unit}. |footbib| puts the text of a
%          reference only once in each citation unit which may be a
%          (double) page, a chapter, a part or the whole document. The
%          default citation unit is the page in |oneside| mode and the
%          double page in |twoside| mode. The new citation unit (|chapter|,
%          |part| or |document|) is given as an optional argument
%          between parentheses (|citeonce(chapter)|, |citeonce(part)|
%          or |citeonce(document)|). If no argument is supplied,
%          |document| is assumed. The argument |chapter| (resp.~|part|) 
%          may be used only if the document class defines |\chapter|
%          (resp.~|\part|). The argument |page| may also be used but has a
%          somehow special meaning. It defines a
%          citation unit which is not overridden by another |citeonce| option
%          but instead has a cumulative effect. For instance if one says 
%\begin{verbatim}
%    \usepackage[twoside,citeonce(page),citeonce(chapter)]{footbib}
%\end{verbatim}
%          then each double page and also each |\chapter| command starts a new
%          citation unit. This may be useful if one wants a chapter to 
%          start a new unit even if it starts on a right page.
%          It is only meaningful in |twoside| mode in conjunction with
%          another |citeonce| option. In all other cases, it has no effect.
%
%          The |citeonce| option has a star form |citeonce*| with the same
%          optional argument. When the star form is used, for each subsequent
%          citation of a reference in the same citation unit but on another
%          (double) page, the text of the reference is not omitted but
%          replaced with a cross reference to the first citation in the
%          same citation unit. The |page| argument is not available since it
%          would have no effect.
%
% \subsubsection{\texttt{firstcite}}
%          \DescribeOption{firstcite}^^A
%          The |firstcite| option affects the way the references are
%          labelled. When the bibliography style does not provide
%          explicit labels, the references are numbered. The default
%          is to assign to each reference a \emph{static}
%          label\Index{static}{label}
%          which is its order in the |thebibliography| environment.
%          The label is then the same for all citations of a
%          given reference. The |firstcite| option causes the
%          references to be numbered dynamically\Index{dynamic}{label}
%          according to the order of their first citations. |firstcite|
%          takes an optional argument between parentheses
%          |firstcite(|\meta{unit}|)| which defines the
%          \emph{numbering unit}\Index{numbering}{unit}.
%          The numbering restarts then from 1 in each numbering unit.
%          The argument \meta{unit} may take the value |page|,
%          |chapter|, |part| 
%          or |document|. If |page| is used, then the numbering
%          unit is a page in |oneside| mode and a double page in
%          |twoside| mode. If no argument is supplied, |document| is
%          assumed. 
%
%          The effect of several |firstcite| options is cumulative in
%          the sense that if one says for instance
%\begin{verbatim}
%    \usepackage[twoside,firstcite(page),firstcite(chapter)]{footbib}
%\end{verbatim}
%          \noindent then each double page \emph{and} each |\chapter| command
%          starts a new numbering unit. This means that a |\chapter|
%          command starts a new numbering unit even if it is on a right page.
%
%          If the bibliography style provides explicit 
%          labels, the |firstcite| option has no effect.
%
% \subsubsection{{\normalfont\texttt{crossrefs}[\texttt*]} and
%                \texttt{nocrossrefs}} 
%          \DescribeOption{crossrefs}^^A
%          \DescribeOption{crossrefs*}^^A
%          \DescribeOption{nocrossrefs}^^A
%          When an entry in the bibliographic database contains a
%          |CROSSREF| field, \BibTeX\ includes the cross-referenced
%          entry in the bibliography and puts a |\cite|
%          command in the entry where the |CROSSREF| field occurs.
%          If no standard bibliography is produced, \LaTeX\ 
%          will complain about an undefined reference. 
%          One may generally inhibit this behaviour of \BibTeX\ by
%          invoking it with the |-min-crossrefs=|\meta{number}
%          option which tells how many times an entry must
%          be cross-referenced before it is included in the
%          bibliography and replaced with a |\cite|
%          command. Setting \meta{number} to a large value will
%          generally inhibit the cross-referencing mechanism.
%          However, this option has no effect if the 
%          cross-referenced entry is explicitely cited in the
%          document. 
%
%          The |crossrefs| option of |footbib| solves this problem by
%          replacing each |\cite| command in a foot reference with
%          |\footcite| (see the description of this command below).
%          The star form |crossrefs*| replaces the 
%          |\cite| command with a |\footcite*|, which means that
%          the text of the reference is not inserted. It is then the
%          responsibility of the user to insert the text in the right
%          place with a |\footnocite| command. Of course, standard
%          citation through |\cite| is not possible anymore in a foot
%          reference when either form of this option is used. 
%
%          A |nocrossrefs| option is also provided to inhibit this
%          behaviour in case it is not wanted but |crossrefs| occurs
%          in the global options.
%
% \subsubsection{{\normalfont\texttt{split}} and \texttt{nosplit}}
%          \DescribeOption{split}^^A
%          \DescribeOption{nosplit}^^A
%          The |nosplit| option tells |footbib| not to split the references
%          across pages. The |split| option allows references to be
%          split. |split| is the default and exists only to allow the
%          user to override a global |nosplit| option.
%
% \subsection{Commands to generate the foot bibliography}
% \begin{list}{}{\leftmargin=0pt \labelsep=0pt}
% \item[]  \DescribeMacro{\footbibliography}
%          |\footbibliography{|\meta{file}|,|\meta{file}|,|\dots|}|\\
%          Defines the list of bibliographic databases for the foot
%          bibliography. This command has the same syntax as the
%          |\bibliography| command of \LaTeX. 
% \item[]  \DescribeMacro{\footbibliographystyle}\leavevmode\noindent
%          |\footbibliographystyle{|\meta{style}|}|\\
%          Defines the style of the foot bibliography. This command has
%          the same syntax as
%          the |\bibliographystyle| command of \LaTeX.
% \item[]  \DescribeMacro{\footcite}\noindent
%          |\footcite{|\meta{key}|,|\meta{key}|,|\dots|}|\\
%          Puts the list of labels in the text and the text of the
%          references at the bottom of the page. The text of each
%          reference is inserted at most once in a citation unit,
%          even if it is cited several times. 
% \item[]  \DescribeMacro{\footcite*}\noindent
%          |\footcite*{|\meta{key}|,|\meta{key}|,|\dots|}|\\ 
%          Puts the list of labels in the text but does not put the
%          reference at the bottom of the page.
% \item[]  \DescribeMacro{\footnocite}\noindent
%          |\footnocite{|\meta{key}|,|\meta{key}|,|\dots|}|\\
%          Puts the reference at the bottom of the page but puts
%          nothing in the text.
% \end{list}
% \begin{description}
% \item[Note:] The main purpose of the commands |\footcite*| and
%        |\footnocite| is to solve the problem of a 
%        |\footcite| occuring inside an environment where the
%        reference will be lost (for instance in a |minipage| or
%        |tabular| environment, in a |\mbox|, etc.). In this case,
%        if the reference is not cited otherwise on the same page, it
%        won't show up at the bottom of the page. It suffices to add
%        a |\footnocite| command just before or after this environment.
%        The command |\footcite{|\meta{key}|}| is more or less (but
%        not completely) equivalent to
%        |\footcite*{|\meta{key}|}\footnocite{|\meta{key}|}|.
% \end{description}
%
% \subsection{Customisation}\label{sec:custom}
%
% \begin{list}{}{\leftmargin=0pt \labelsep=0pt}
% \item[]  \DescribeMacro{\footbibliographyname}
%          The basename of the |.aux| and |.bbl| files used for the
%          foot bibliography may be redefined by
%
%          \qquad |\footbibliographyname{|\meta{name}|}|
%
%           The default value is
%          |\jobname.fb|\footnote{\texttt{\string\jobname} is a
%          primitive \TeX\ command which holds the name of the main
%          document.} which causes |footbib| to read the bibliography
%          from 
%          |\jobname.fb.bbl| and  to use |\jobname.fb.aux| as an
%          auxiliary file. This command may be used only in the preamble.
%          The name supplied to |\footbibliographyname| must be
%          different from the name of the main document.
% \item[]  \DescribeMacro{\footcitelabel}^^A
%          \DescribeMacro{\putfootcitelabel}^^A
%          \DescribeMacro{\footcitelistformat}^^A
%          The list of citations in the text may not be typeset in
%          one step as done by the |\cite| command of \LaTeX. 
%          The reason is that the command which creates the text of
%          the reference must be inserted after each citation.
%          The way \LATEX\ handles insertions makes 
%          them vanish if they occur in a box. Hence if the command
%          which formats the list of citations puts them in a box,
%          the text is lost and the references do not show up at the
%          bottom of the page. All references could be inserted at
%          once, either before or after the list of citations but if
%          this list gets split across pages, the text of some
%          references could show up on the wrong page. Hence 
%          the list is created one piece at a time and the text of
%          the corresponding reference is inserted after each
%          citation. The list of citation is created as follows: 
% \begin{tabbing}
% \qquad\=1)~\=start of list\\
%     \>2)\>for each citation:\\
%     \>\>a)~if it is not the first one, separator of citations\\
%     \>\>b)~label of the reference, to which |\footcitelabel| is applied\\
%     \>\>c)~insertion of the text of the reference\\
%     \>3)\>end of list
% \end{tabbing}
% The separator of citations is made of two parts: \meta{sep$_1$} and
% \meta{sep$_2$}. 
% The command |\putfootcitelabel| is applied to each component of the
% list, excepted \meta{sep$_2$} which is put as such.
% Typically, \meta{sep$_2$} is a separator which may disappear at a line
% break, like a penalty or some spacing. That's why
% |\putfootcitelabel| is not applied to it so that it won't be put
% in a box. The effect is as follows:
% \begin{trivlist}\leftskip=\leftmargini\parindent=0pt\item[]
%   |\putfootcitelabel{|\meta{start of list}|}|\\
%   |\putfootcitelabel{\footcitelabel{|\meta{label $1$}|}}|\\
%   \meta{insertion of the text of reference $1$}\\
%   |\putfootcitelabel{|\meta{sep$_1$}|}|\\
%   \meta{sep$_2$}\\
%   |\putfootcitelabel{\footcitelabel{|label $2$|}}|\\
%   \meta{insertion of the text of reference $2$}\\
%   |\putfootcitelabel{|\meta{sep$_1$}|}|\\
%   \meta{sep$_2$}\\
%   \null\quad\vdots\\
%   |\putfootcitelabel{\footcitelabel{|label $n$|}}|\\
%   \meta{insertion of the text of reference $n$}\\
%   |\putfootcitelabel{|\meta{end of list}|}|
% \end{trivlist}
%
% Each component of the list may be redefined as follows:
% \begin{trivlist}\leftskip=\leftmargini\parindent=0pt\item[]
% |\renewcommand*\footcitelabel[1]{|\dots|}|\\
% |\renewcommand*\putfootcitelabel[1]{|\dots|}|\\
% |\footcitelistformat|\meta{start of list}\meta{sep$_1$}^^A
%     \meta{sep$_2$}\meta{end of list}
% \end{trivlist}
% \end{list}
% Here are some examples of the variations allowed by this mechanism.
% \begin{description}\topsep=0pt
% \item[example 1:]list of citations \emph{a la \LaTeX}: [label $1$,
%       label $2$, \dots]
%\begin{verbatim*}
%\renewcommand*\footcitelabel[1]{#1}
%\renewcommand*\putfootcitelabel[1]{#1}
%\footcitelistformat[,{\penalty1000\ }]
%\end{verbatim*}
% \item[example 2:]ditto but the list may not be cut\par
%     \leavevmode\quad\vdots
%\begin{verbatim*}
%\footcitelistformat[,{\nobreak\ }]
%\end{verbatim*}
% \item[example 3:] the list is raised and the labels are
%       separated only by commas, without any space: 
%     \textsuperscript{\normalfont[label $1$,label $2$,\dots]}
%\begin{verbatim*}
%\renewcommand*\footcitelabel[1]{#1}
%\renewcommand*\putfootcitelabel[1]{\textsuperscript{\normalfont#1}}
%\footcitelistformat[,{\penalty1000\relax}]
%\end{verbatim*}
% \item[example 4:] ditto, but no brackets around the list of labels:
%     \textsuperscript{\normalfont label $1$,label $2$,\dots}\par
%     \leavevmode\quad\vdots
%\begin{verbatim*}
%\footcitelistformat{},{\penalty1000\relax}{}
%\end{verbatim*}
% \item[example 5:] [label $1$], [label $2$], \dots
%\begin{verbatim*}
%\renewcommand*\footcitelabel[1]{[#1]}
%\renewcommand*\putfootcitelabel[1]{#1}
%\footcitelistformat{},{\penalty1000\ }{}
%\end{verbatim*}
% \end{description}
% The default definitions are the ones of example 3 above.
%
% \begin{list}{}{\leftmargin=0pt\labelsep=0pt}
% \item[] \DescribeMacro{\footbibskip}^^A
%         \DescribeMacro{\footbibrule}^^A
%          The foot bibliography is
%          separated from the rest of the page by a vertical skip of
%          length |\footbibskip| in which a horizontal line is
%          drawn by the command |\footbibrule|. The height of the
%          skip and the horizontal 
%          line may be redefined in the preamble by\par\medskip
%            {\leftskip=\leftmargini\parskip=0pt
%            |\setlength\footbibskip{|\dots|}|\par
%            |\renewcommand\footbibrule{|\dots|}|\par}
%          \textbf{CAUTION}~~|\footbibrule| must take zero vertical space.
% \item[]  \DescribeMacro{\footreflabel}^^A
%          The label of the reference is formated by the macro
%          |\footreflabel| which takes the label as argument. It 
%          may be redefined by |\renewcommand*\footreflabel[1]{|\ldots|}|.
% \item[]  \DescribeMacro{\footrefstyle}
%          The label and the text of the reference at the bottom of
%          the page are typeset in the style defined by the command
%          |\footrefstyle| which may be redefined in the preamble by
%          |\renewcommad\footrefstyle{|\dots|}|. The default definition
%          is |\normalfont\footnotesize|.
% \item[]  \DescribeMacro{\footxref}^^A
%          The options |citeonce*(|\meta{unit}|)|\SpecialOptionIndex{citeonce*}
%          tells |footbib| to replace the text of each reference but the first
%          in each citation unit with a cross-reference to the last place where
%          the full text of the reference appeared. The text of the
%          cross-reference is generated by the command |\footxref| which takes
%          two arguments: (1)~the label and (2)~the page of the last full
%          citation. |\footxref| may be redefined in the preamble by
%
%          \qquad |\renewcommand*\footxref[2]{|\dots|}|.
%
% \end{list}
%
% \section{Known and potential problems}
%
% \begin{list}{$\bullet$}{\settowidth\leftmargin{$\bullet$\hskip\labelsep}}
% \item At present, the convergence is not proved. There is no guarantee
%   that the references eventually find their place. However,
%   |footbib| was used in large documents (several
%   hundreds pages) and such a problem never occured. 
%
% \item The foot bibliography is not sorted. The references appear at the
%   bottom of the page in the order in which they are cited on the page.
%
% \item A |\footcite| command may not appear in a floating environment
%   like |figure| or |table|.
%
% \item If a float is inserted at the bottom of the page, the foot
%   bibliography is put \emph{above} it, like footnotes.
%
% \item The result is not very nice in |twocolumn| mode.
%   The references should be balanced between the two columns of the
%   page (if there are two) or put in the right column like the
%   package |ftnright|\SpecialPackageIndex{ftnright} of Frank
%   Mittelbach does for footnotes.  
%
% \item |footbib| does not work with most packages which 
%   modify the output routine of \LaTeX:
%   |multicol|\SpecialPackageIndex{multicol},
%   |ftnright|\SpecialPackageIndex{ftnright},
%   |floatflt|\SpecialPackageIndex{floatflt},
%   |wrapfig|\SpecialPackageIndex{wrapfig}, etc. 
%
% \item The references must not contain any
%   |verbatim|\SpecialEnvIndex{verbatim} environment. But 
%   |\verb|\SpecialUsageIndex{\verb} is allowed since it is sometime used
%   to typeset filenames, \textsc{url}'s, etc.
%
% \item The braces must be balanced in the references, excepted the ones
%   that might occur inside the argument of a |\verb|
%   command\SpecialUsageIndex{\verb}. This implies that a reference 
%   may not contain say |\hbox\bgroup|\dots|}| which is otherwise correct
%   in \LATEX.
%
% \item When references are numbered, the space between the label and
%   the reference itself may be too large because the
%   longest label is determined from the argument of
%   |\begin{thebibliography}{|\meta{longest label}|}| and its length
%   is used for all references. If all references on a page
%   have small numbers and the bibliography contains many references
%   (say more than 100),
%   this length is not reliable. The longest label should be deduced
%   from the maximal number of references on a page,
%   but this may not be known at the beginning of the document, at
%   least at the first run. At the second run, the
%   information could be deduces from what was written into the |.aux| file,
%   provided 
%   the |\nofiles| command was not used (otherwise, the |.aux| file
%   was not written). When per page numbering is used (option
%   |firstcite(page)|), the longest label could also be simply initialised
%   to |99| which is not too large and should be enough.
% \end{list}
%
% \StopEventually{\IndexSetup\PrintIndex\PrintChanges}
%
% \section{Implementation}
%
% \subsection{Identification}
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{footbib}[\filedate\space v\fileversion\space(E.Domenjoud)]
%    \end{macrocode}
%
% \subsection{Initial setup}
%
% Some badly behaved packages (written for \LaTeX\kern.15em2.09) change the
% catcodes before the 
% beginning of the document and make some commands like |\@for|
% unusable. The catcodes needed in the definitions are set here and
% restored at the end of the package. 
%    \begin{macrocode}
\@makeother\`
\edef\@tempa{\catcode\string`\string`\string=\the\catcode\string``\relax}
\def\@tempb#1{\catcode`\noexpand#1\string=\the\catcode`#1\relax}
\edef\@tempa{\@tempa
  \@tempb\:\@tempb\?\@tempb\=\@tempb\<\@tempb\>\@tempb\+\@tempb\-%
  \@tempb\.\@tempb\'\@tempb\~}
\expandafter\AtEndOfPackage\expandafter{\@tempa}
\@makeother\: \@makeother\? \@makeother\= \@makeother\< \@makeother\> 
\@makeother\+ \@makeother\- \@makeother\. \@makeother\' 
\catcode`\~=\active
%    \end{macrocode}
%
% \subsection{Test of the output routine}
%
% If the \LaTeXe\ format is more recent than the package, we test
% whether the output routine changed. If so, a warning is issued
% because the user might get unexpected results. The package should
% work with all previous versions of \LaTeXe.
%
% When |docstrip| is used to extract the package, this code is included only
% if the `|checkoutput|' flag is used in addition to `|package|'.
%
%    \begin{macrocode}
%<*checkoutput>
\@ifpackagelater{footbib}\fmtversion\@tempswafalse\@tempswatrue
\if@tempswa
\def\@tempa#1#2{\def\@tempb{#2}\ifx#1\@tempb\else\@tempswatrue\fi}
\@tempswafalse
\@tempa\@specialoutput{\ifnum\outputpenalty>-\@Mii\@doclearpage\else
  \ifnum\outputpenalty<-\@Miii\ifnum\outputpenalty<-\@MM\deadcycles\z@
  \fi\global\setbox\@holdpg\vbox{\unvbox\@cclv}\else\global\setbox
  \@holdpg\vbox{\unvbox\@holdpg\unvbox\@cclv\setbox\@tempboxa\lastbox
  \unskip}\@pagedp\dp\@holdpg\@pageht\ht\@holdpg\unvbox\@holdpg\@next
  \@currbox\@currlist{\ifnum\count\@currbox>\z@\advance\@pageht\@pagedp
  \ifvoid\footins\else\advance\@pageht\ht\footins\advance\@pageht\skip
  \footins\advance\@pageht\dp\footins\fi\ifvbox\@kludgeins\ifdim\wd
  \@kludgeins=\z@\advance\@pageht\ht\@kludgeins\fi\fi\@reinserts
  \@addtocurcol\else\@reinserts\@addmarginpar\fi}\@latexbug\ifnum
  \outputpenalty<\z@\if@nobreak\nobreak\else\addpenalty\interlinepenalty
  \fi\fi\fi\fi}
\@tempa\@doclearpage{\ifvoid\footins\ifvbox\@kludgeins{\setbox\@tempboxa
  \box\@kludgeins}\fi\setbox\@tempboxa\vsplit\@cclv to\z@
  \unvbox\@tempboxa\setbox\@tempboxa\box\@cclv\xdef\@deferlist{\@toplist
  \@botlist\@deferlist}\global\let\@toplist\@empty\global\let\@botlist
  \@empty\global\@colroom\@colht\ifx\@currlist\@empty\else\@latexerr
  {Float(s) lost}\@ehb\global\let\@currlist\@empty\fi\@makefcolumn
  \@deferlist\@whilesw\if@fcolmade\fi{\@opcol\@makefcolumn\@deferlist
  }\if@twocolumn\if@firstcolumn\xdef\@dbldeferlist{\@dbltoplist
  \@dbldeferlist}\global\let\@dbltoplist\@empty\global\@colht\textheight
  \begingroup\@dblfloatplacement\@makefcolumn\@dbldeferlist\@whilesw
  \if@fcolmade\fi{\@outputpage\@makefcolumn\@dbldeferlist}\endgroup\else
  \vbox{}\clearpage\fi\fi\else\setbox\@cclv\vbox{\box\@cclv\vfil}\@makecol
  \@opcol\clearpage\fi}
\@tempa\@makecol{\ifvoid\footins\setbox\@outputbox\box\@cclv\else\setbox
  \@outputbox\vbox{\boxmaxdepth\@maxdepth\unvbox\@cclv
  \vskip\skip\footins\color@begingroup\normalcolor\footnoterule\unvbox
  \footins\color@endgroup}\fi\let\@elt\relax\xdef\@freelist{\@freelist
  \@midlist}\global\let\@midlist\@empty\@combinefloats\ifvbox\@kludgeins
  \@makespecialcolbox\else\setbox\@outputbox\vbox to\@colht{\@texttop\dimen@
  \dp\@outputbox\unvbox\@outputbox\vskip-\dimen@\@textbottom}\fi\global
  \maxdepth\@maxdepth}
\@tempa\@reinserts{\ifvoid\footins\else\insert\footins{\unvbox\footins}\fi
  \ifvbox\@kludgeins\insert\@kludgeins{\unvbox\@kludgeins}\fi}
\fi
\if@tempswa
  \PackageError{footbib}{the output routine of LaTeX changed}
  {The output routine of LaTeX changed since the current version of
   `footbib'.\MessageBreak Since `footbib' patches this routine, 
   using it may produce unexpected\MessageBreak results. Send a mail to \space 
   Eric.Domenjoud@loria.fr \space to get a new version.\MessageBreak\MessageBreak
   Type \space X <return> \space to quit or cross your fingers and
   just type <return>.\MessageBreak} 
\fi
%</checkoutput>
%    \end{macrocode}
%
% \subsection{Package Options}
%
% \subsubsection{Initial code}
%
% \begin{macro}{\iffb@twoside}
% \begin{macro}{\iffb@citeonce}
% \begin{macro}{\iffb@pagecite}
% \begin{macro}{\fb@chaptercite}
% \begin{macro}{\fb@partcite}
% \begin{macro}{\iffb@firstcite}
% \begin{macro}{\iffb@pagenum}
% \begin{macro}{\fb@chapternum}
% \begin{macro}{\fb@partnum}
% \begin{macro}{\iffb@xref}
% \begin{macro}{\iffb@crossrefs}
% \begin{macro}{\iffb@xcrossrefs}
% \begin{macro}{\iffb@nosplit}
% First we define some switches which record the user options. The
% switch |\iffb@twoside| is initialised from the current value of 
% |\if@twoside| because default global options are not passed to packages. 
% If one says |\documentclass{book}| then the document is in
% |twoside|\SpecialOptionIndex{twoside} mode but the packages
% \emph{don't know} it. 
%    \begin{macrocode}
\newif\iffb@twoside     \let\iffb@twoside\if@twoside
\newif\iffb@citeonce    \fb@citeoncefalse
\newif\iffb@pagecite    \fb@pagecitefalse
\let\fb@chaptercite\@empty
\let\fb@partcite\@empty
\newif\iffb@firstcite   \fb@firstcitefalse
\newif\iffb@pagenum     \fb@pagenumfalse
\let\fb@chapternum\@empty
\let\fb@partnum\@empty
\newif\iffb@xref        \fb@xreffalse
\newif\iffb@crossrefs   \fb@crossrefsfalse
\newif\iffb@xcrossrefs  \fb@xcrossrefsfalse
\newif\iffb@nosplit     \fb@nosplitfalse
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fb@checksec}
% The macro |\fb@checksec| checks whether its first argument (a sectioning
% command) is defined. If so, the second argument (a list of command)
% is executed. Otherwise an error is raised and the second argument
% is discarded. It is called while processing the options which must
% patch a sectioning command.
%    \begin{macrocode}
\newcommand\fb@checksec[2]{%
  \ifx#1\@undefined
    \PackageError{footbib}{Bad option `\CurrentOption'}%
    {{footbib}: The current document class does not define `\string#1'}%
  \else
    #2%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Declaration and processing of options}
% {\MacroFont
% \begin{option}{oneside}
% \begin{option}{twoside}
% \leavevmode\vspace{-1.2\baselineskip}
%    \begin{macrocode}
\DeclareOption{oneside}{\fb@twosidefalse}
\DeclareOption{twoside}{\fb@twosidetrue}
%    \end{macrocode}
% \end{option}
% \end{option}
% \begin{option}{firstcite}
% \leavevmode\vspace{-1.2\baselineskip}
%    \begin{macrocode}
\DeclareOption{firstcite}{\fb@firstcitetrue}
\DeclareOption{firstcite(page)}{\fb@firstcitetrue\fb@pagenumtrue}
\DeclareOption{firstcite(chapter)}{\fb@firstcitetrue
    \fb@checksec\chapter{\def\fb@chapternum{\fb@newnumunit}}}
\DeclareOption{firstcite(part)}{\fb@firstcitetrue
    \fb@checksec\part{\def\fb@partnum{\fb@newnumunit}}}
\DeclareOption{firstcite(document)}{\fb@firstcitetrue}
%    \end{macrocode}
% \end{option}
% \begin{option}{citeonce}
% \begin{option}{citeonce*}
% \leavevmode\vspace{-1.2\baselineskip}
%    \begin{macrocode}
\DeclareOption{citeonce}{\fb@citeoncetrue}
\DeclareOption{citeonce(page)}{\fb@pagecitetrue}
\DeclareOption{citeonce(chapter)}{\fb@citeoncetrue
    \fb@checksec\chapter{\def\fb@chaptercite{\fb@newciteunit}}}
\DeclareOption{citeonce(part)}{\fb@citeoncetrue
    \fb@checksec\part{\def\fb@partcite{\fb@newciteunit}}}
\DeclareOption{citeonce(document)}{\fb@citeoncetrue}
\DeclareOption{citeonce*}{\fb@citeoncetrue\fb@xreftrue}
\DeclareOption{citeonce*(chapter)}{%
    \ExecuteOptions{citeonce(chapter)}\fb@xreftrue}
\DeclareOption{citeonce*(part)}{%
    \ExecuteOptions{citeonce(part)}\fb@xreftrue}
\DeclareOption{citeonce*(document)}{\ExecuteOptions{citeonce*}}
%    \end{macrocode}
% \end{option}
% \end{option}
% \begin{option}{crossrefs}
% \begin{option}{crossrefs*}
% \begin{option}{nocrossrefs}
% \leavevmode\vspace{-1.2\baselineskip}
%    \begin{macrocode}
\DeclareOption{crossrefs}{\fb@crossrefstrue\fb@xcrossrefstrue}
\DeclareOption{crossrefs*}{\fb@crossrefstrue\fb@xcrossrefsfalse}
\DeclareOption{nocrossrefs}{\fb@crossrefsfalse\fb@xcrossrefsfalse}
%    \end{macrocode}
% \end{option}
% \end{option}
% \end{option}
%
% \begin{option}{split}
% \begin{option}{nosplit}
% \leavevmode\vspace{-1.2\baselineskip}
%    \begin{macrocode}
\DeclareOption{split}{\fb@nosplitfalse}
\DeclareOption{nosplit}{\fb@nosplittrue}
%    \end{macrocode}
% \end{option}
% \end{option}
%    \begin{macrocode}
\ProcessOptions*
\iffb@pagecite
  \fb@citeoncefalse
  \fb@xreffalse
\fi
\let\fb@firstcitetrue\@undefined  \let\fb@firstcitefalse\@undefined
\let\fb@citeoncetrue\@undefined   \let\fb@citeoncefalse\@undefined
\let\fb@pagecitetrue\@undefined   \let\fb@pagecitefalse\@undefined
\let\fb@xreftrue\@undefined       \let\fb@xreffalse\@undefined
\let\fb@crossrefstrue\@undefined  \let\fb@crossrefsfalse\@undefined
\let\fb@xcrossrefstrue\@undefined \let\fb@xcrossrefsfalse\@undefined
\let\fb@pagenumtrue\@undefined    \let\fb@pagenumfalse\@undefined
\let\fb@nosplittrue\@undefined    \let\fb@nosplitfalse\@undefined
\let\fb@checksec\@undefined
%    \end{macrocode}
% }
%
% \begin{macro}{\chapter}
% \begin{macro}{\part}
% At the beginning of the document, the commands |\chapter| and |\part| are
% patched if necessary so that they start a new citation or numbering unit. 
% This is achieved by adding in front of them the commands hold in
% |\fb@chaptercite|, |\fb@chapternum|, |\fb@partcite| and |\fb@partnum|
% defined while processing the options. When a command is patched, a
% |\clearpage| is added so that a new unit always starts at the top of a page.
%    \begin{macrocode}
\AtBeginDocument{%
  \begingroup
    \def\@tempb#1{%
      \ifx\@tempa\@empty\else
        \edef\@tempa{\noexpand\clearpage\@tempa}%
        \toks@\expandafter\expandafter\expandafter{\expandafter\@tempa#1}%
        \xdef#1{\the\toks@}%
      \fi}%
    \let\fb@newnumunit\relax
    \let\fb@newciteunit\relax
    \edef\@tempa{\fb@partcite\fb@partnum}%
    \@tempb\part
    \edef\@tempa{\fb@chaptercite\fb@chapternum}%
    \@tempb\chapter
  \endgroup}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Customisation}
%
% \subsubsection{Basename of the files used for the foot bibliography}
%
% \begin{macro}{\footbibliographyname}
% The basename of the |.aux| and |.bbl| files is produced by the
% command |\fb@bibname| which is redefined by a call to
% |\footbibliographyname| in the preamble. 
%
% |\footbibliographyname| first checks that its argument is different
% from |\jobname|. Since the characters in |\jobname| have  catcode
% 12 (other), the first two commands below yield the argument of
% |\footbibliographyname| also with catcodes 12 so that it may be
% compared to |\jobname|.
%    \begin{macrocode}
\newcommand*\footbibliographyname[1]{%
  \edef\@tempa{#1}%
  \edef\@tempa{\expandafter\strip@prefix\meaning\@tempa}%
  \edef\@tempb{\jobname}%
  \ifx\@tempa\@tempb
    \PackageError{footbib}{Bad argument `#1'\on@line}%
      {The name supplied to `\string\footbibliographyname' must be
         different from the name\MessageBreak
       of the current document to avoid conflicts with the standard
         bibliography.\MessageBreak\MessageBreak 
       Type \space X <return> \space to quit.\MessageBreak}%
  \else
    \xdef\fb@bibname{#1}%
  \fi}
\@onlypreamble\footbibliographyname
\footbibliographyname{\jobname.fb}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Layout of the list of citations in the text}
%
% \begin{macro}{\footcitelabel}
% \begin{macro}{\putfootcitelabel}
% \begin{macro}{\footcitelistformat}
% \begin{macro}{\fb@putfootcitelabel}
% \begin{macro}{\fb@citestart}
% \begin{macro}{\fb@citesep}
% \begin{macro}{\fb@citeend}
% Here we define the layout parameters for the list of citations in the
% text. We define an additional macro |\fb@putfootcitelabel| which is
% essentially |\putfootcitelabel|. Only |\scriptspace| and |\mathsurround| are
% set to 0 pt in case |\putfootcitelabel| involves some math.
% The modified version is applied to all components of the citation
% list but |\fb@citeend| to which the standard version is applied.
% This avoids unwanted spacing inside the list while allowing some
% additional spacing after it. The macro |\footcitelistformat| defines the
% macros |\fb@citestart|, |\fb@citesep| and |\fb@citeend| used by |\fb@cite|
% to build the list of citations in the text.
%    \begin{macrocode}
\newcommand*\footcitelabel[1]{#1}
\newcommand*\putfootcitelabel[1]{\textsuperscript{\normalfont#1}}
\newcommand*\fb@putfootcitelabel[1]{%
  {\m@th\scriptspace\z@\putfootcitelabel{#1}}}
\newcommand*\footcitelistformat[4]{%
  \def\fb@citestart{\fb@putfootcitelabel{#1}}%
  \def\fb@citesep{\fb@putfootcitelabel{#2}#3}%
  \def\fb@citeend{\putfootcitelabel{#4}}}%
\footcitelistformat[,{\penalty\@m}]
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Style of the foot bibliography}
% 
% \begin{macro}{\footbibskip}
% \begin{macro}{\footbibrule}
% \begin{macro}{\footrefstyle}
% \begin{macro}{\footreflabel}
% \begin{macro}{\footxref}
% \begin{macro}{\fb@ins}
% Here are defined all the layout parameters for the foot bibliography.
% |\fb@ins| is the insertion number for the foot bibliography. It is not
% really the right place for its declaration but it is needed to define the
% user definable parameter |\footbibskip|. By the way we set
% all the parameters for these insertions: 1 to 1 magnification and
% no limit on the height of the foot bibliography.
%    \begin{macrocode}
\newinsert\fb@ins
\count\fb@ins=1000
\AtBeginDocument{\dimen\fb@ins=\textheight}
\newcommand\footbibskip{\skip\fb@ins}
\footbibskip=\bigskipamount
\newcommand\footbibrule{\kern-3\p@\hrule\kern 2.6\p@}% \hrule is .4pt high
\newcommand\footrefstyle{\normalfont\footnotesize}
\newcommand*\footreflabel[1]{[#1]}
\newcommand*\footxref[2]{See~#1~on page~#2.}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Some useful definitions}
%
% \begin{macro}{\fb@vedef}
% \begin{macro}{\fb@doactive}
% The keys of the references must be read and written \emph{more or
% less} verbatim. Since some packages make some
% characters permanently active, the catcodes should be changed before
% reading or writing a key or a list of keys and reset afterward.
% Unfortunately, in some situations this is not possible because the
% catcodes have already been attached to the characters. One solution is to scan
% the key and replace each active character with its non-active
% equivalent but this is fairly costly and does not work if some active
% character have been let equal to a non-active one or is hidden in a
% command occuring in the (list of) key(s). Another solution is to use
% |\meaning| to get a \emph{verbatim} copy of the keys but this does
% not allow them to contain commands like in |\foocite{\mylistofcitations}|
% The method used here consists in redefining the active characters
% so that their expansion produces the same character with a catcode
% 12 (other). Then an expansion of the key yields an almost
% \emph{verbatim} copy of it. Only then, |\meaning| is used to \emph{remove}
% the category code of any special character which might remain in the key
% like |$| or |_|. This mechanism allows the list of keys
% to contain itself commands which expand in the normal way. 
% All characters which may both be active in the document and appear in the
% key of a reference must be treated in this way. Since \BibTeX\ allows almost
% any character in a key, it is safer to consider all 
% characters which may be active in a document. No matter that they
% indeed are. The command |\dospecials| usually contains, among
% other, all such characters, each one escaped and preceded by |\do|.
% The \LaTeXe\ kernel defines |\dospecials|\SpecialUsageIndex{\dospecials} as
%\begin{trivlist}\leftskip=\parindent\item[]\MacroFont
%  \verb*|\def\dospecials{\do\ \do\\\do\{\do\}\do\$\do\&\do\#\do\^\do\_\do\%\do\~}|
%\end{trivlist}
% \noindent Any package which define new \emph{special} characters
% should add them to this list.
% \medskip
%
% An active character is needed to start with. Since |~| was
% made active at the beginning of the package, it may be safely used 
% for this purpose. 
%    \begin{macrocode}
\newcommand*\fb@doactive[1]{\lccode`~=`#1\lowercase{\def~{\string~}}}
\newcommand*\fb@vedef[2]{%
  \begingroup
    \let\do\fb@doactive \dospecials
    \edef\@tempa{\endgroup\def\noexpand#1{#2}}%
  \@tempa
  \edef#1{\expandafter\strip@prefix\meaning#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\fb@namexdef}
% |\fb@namexdef| is similar to the |\@namedef| command of \LaTeX\ but uses
% |\xdef| instead of |\def|
%    \begin{macrocode}
\newcommand*\fb@namexdef[1]{\expandafter\xdef\csname#1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fb@auxout}
% \begin{macro}{\fb@writeaux}
% |\fb@auxout| is the auxiliary file used to record information about
% citations and as input to \BibTeX.
% The commands |\footbibliographystyle| and |\footbibliography| do an
% immediate |\write| to this file. However, since these commands may
% be used in the preamble, this file might not yet be open for
% writing at the time they are used. We must wait until the end of the
% preamble before opening the auxiliary file to give the user a chance to
% define its name with |\footbibliographyname|. Therefore, we define the
% macro |\fb@writeaux| which postpones the write until the beginning of the
% document. It is somehow a \emph{delayed immediate write} which means that
% the write will be performed as soon as possible, i.e.~as soon as the
% auxiliary file is open for writing. This definition is temporary and will
% be changed to a \emph{true} immediate write by |\AtBeginDocument|. 
%    \begin{macrocode}
\newwrite\fb@auxout
\newcommand*\fb@writeaux[2]{%
  \AtBeginDocument{%
    \if@filesw
      \immediate\write\fb@auxout{\string#1{#2}}%
    \fi}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Units handling}
%
% \begin{macro}{\fb@numunit}
% \begin{macro}{\fb@citeunit}
% \begin{macro}{\fb@xrefunit}
% We handle 3 counters: the \emph{numbering unit}\Index{numbering}{unit}
% counter (|\fb@numunit|), the \emph{citation unit}\Index{citation}{unit}
% counter (|\fb@citeunit|) and the \emph{cross-referencing
% unit}\Index{cross-referencing}{unit} counter (|\fb@xrefunit|). This last
% counter is meaningful only if a |citeonce*| option was used. It essentially
% counts pages in |oneside| mode and double pages in |twoside| mode. However,
% if the citation unit is a chapter (resp.~a part), each |\chapter|
% (resp.~|\part|) command also increments this counter.
%    \begin{macrocode}
\newcount\fb@numunit  \fb@numunit\@ne
\newcount\fb@citeunit \fb@citeunit\@ne
\newcount\fb@xrefunit \fb@xrefunit\@ne
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fb@refciteunit}
% \begin{macro}{\fb@refxrefunit}
% \begin{macro}{\fb@refnumunit}
% \begin{macro}{\fb@refpage}
% \begin{macro}{\fb@theunits}
% \begin{macro}{\fb@getunits}
% \begin{macro}{\fb@get@units}
% The macros |\fb@ref|\dots|unit| and |\fb@refpage| hold the units and the
% page of the current citation.
%    \begin{macrocode}
\newcommand\fb@theunits{%
  {\the\fb@citeunit}{\the\fb@xrefunit}{\the\fb@numunit}{\thepage}}
\newcommand*\fb@getunits[1]{%
  \ifx#1\relax
    \xdef#1{{\fb@key}\fb@theunits}%
  \fi
  \expandafter\fb@get@units#1}
\newcommand*\fb@get@units[5]{%
  \def\fb@refciteunit{#2}%
  \def\fb@refxrefunit{#3}%
  \def\fb@refnumunit{#4}%
  \def\fb@refpage{#5}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fb@newciteunit}
% \begin{macro}{\fb@newnumunit}
% The macros |\fb@newciteunit| and |\fb@newnumunit| are called by the
% patched versions of |\part| or 
% |\chapter| to start a new citation or numbering unit. The patched
% sectioning unit also forces a page break so that a unit always
% starts at the top of a page.
%    \begin{macrocode}
\newcommand\fb@newciteunit{%
  \global\advance\fb@citeunit\@ne
  \global\advance\fb@xrefunit\@ne}
\newcommand\fb@newnumunit{\global\advance\fb@numunit\@ne}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fb@checkpage}
% \begin{macro}{\fb@prevpage}
% Each time the page counter is incremented, i.e.~at the top of a new
% page, the macro |\fb@checkpage| updates the units counters if necessary. We
% first check whether the current page is a right page. In |oneside| mode, it
% is never the case. In |twoside| mode, it is the case if its number is
% |\fb@prevpage|${}+1$ and is odd, where |\fb@prevpage| is a counter which
% holds the number of the last shiped out page. If the number
% of the current page is not |\fb@prevpage|${}+1$, it means that
% either the user has manually changed the page counter or the page numbering
% has changed. In both cases, we consider the current page as a left page. If
% the current page is a right page, we do nothing. Otherwise, it may start a
% new unit\footnote{A right page may actually also start a new unit if for
% instance the |firstcite(chapter)|\SpecialOptionIndex{firstcite}
%  option is in effect and the current
% page starts a new chapter. But in this case, the units are updated by the
% |\string\chapter| command.} and we update the unit counters.
%    \begin{macrocode}
\newcount\fb@prevpage \fb@prevpage\@ne
\newcommand*\fb@checkpage{%
  \@tempswatrue
  \iffb@twoside
    \global\advance\fb@prevpage\@ne
    \ifnum\fb@prevpage=\c@page
      \ifodd\c@page
        \@tempswafalse
      \fi
    \fi
  \fi
  \if@tempswa
%    \end{macrocode}
% The counter |\fb@numunit| is incremented if the switch |\iffb@pagenum| is
% true, i.e.~the option
% |firstcite(page)|\SpecialOptionIndex{firstcite} was used. 
%    \begin{macrocode}
    \iffb@pagenum
      \global\advance\fb@numunit\@ne
    \fi
%    \end{macrocode}
% The switch |\iffb@citeonce| is true iff a
% |citeonce|\SpecialOptionIndex{citeonce} or
% |citeonce*|\SpecialOptionIndex{citeonce*} 
% option was used. In this case, the |\fb@citeunit| counter is
% incremented by the |\chapter| or |\part| command. We just increment
% |\fb@xrefunit| in case |citeonce*| was used. If
% |\iffb@citeonce| is false, the citation unit is the (double) page and
% we increment |\fb@citeunit|. Since no
% |citeonce*|\SpecialOptionIndex{citeonce*} option was 
% used, we do not need to handle |\fb@xrefunit|.
%    \begin{macrocode}
    \iffb@citeonce
      \global\advance\fb@xrefunit\@ne
    \else
      \global\advance\fb@citeunit\@ne
    \fi
  \fi
  \global\fb@prevpage\c@page}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begingroup\lccode`P=`\%\lowercase{\endgroup\begin{macro}{\c@fbPcheckpage}}
% The next definition is a trick to make the macro |\fb@checkpage|
% execute each time the page counter is incremented. Each counter
% \meta{cnt} declared by |\@addtoreset{|\meta{cnt}|}{page}| is reset to
% 0 by |\global\c@|\meta{cnt}|\z@|  when the counter |page| is
% incremented. We define a macro |\c@|\emph{xxx} which \emph{looks like}
% a counter and we say |\@addtoreset{|\emph{xxx}|}{page}|. To
% be sure that the user will never define a counter named \emph{xxx}, we
% name our macro |\c@fb%checkpage|. The name of the associated \emph{pseudo
% counter} is |fb%checkpage| that the user may normally not type. 
% Each time the page counter is incremented, |\global\c@fb%checkpage\z@|
% is executed. The macro |\c@fb%checkpage| starts with an assignment
% (|\count@\z@|) which \emph{uses} the |\global| and ends with a
% counter (|\count@|) which \emph{gobbles} the following |\z@|. Since
% we change the catcode of |%|, it may not be used for comments below.
%    \begin{macrocode}
\catcode`\%=11
\newcommand\c@fb%checkpage{\count@\z@
  \fb@checkpage
  \count@}
\@addtoreset{fb%checkpage}{page}
\catcode`\%=14
%    \end{macrocode}
% \end{macro}
%
% \subsection{Commands to handle the references}
%
% \begin{macro}{\fb@refcount}
% The counter |\fb@refcount| holds the number of the last numbered reference.
% It is reset to 0 at the beginning of each numbering unit.
%    \begin{macrocode}
\newcount\fb@refcount
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fb@lbl}
% \begin{macro}{\fb@txt}
% The token registers |\fb@lbl| and |\fb@txt| always holds the label
% and the text of the current reference.
%    \begin{macrocode}
\newtoks\fb@lbl
\newtoks\fb@txt
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\fb@setref}
% \begin{macro}{\fb@getref}
% \VerbSetup{\begin{macro}{\fb@r.\noexpand~{key}}}
% |\fb@setref| stores the current value of the token registers
% |\fb@lbl| and |\fb@txt| in the macro |\fb@r.|\meta{key} where
% \meta{key} is the key of the current reference. This key is always
% stored in the macro |\fb@key|. |\fb@setref| is called each time a component
% of a reference changes: when it is first read at the beginning of the
% document, and when the dynamic label or the text of the reference has
% been updated. |\fb@getref| does the converse: given
% a key, it updates |\fb@lbl| and |\fb@txt| from |\fb@r.|\meta{key}.
%    \begin{macrocode}
\newcommand\fb@setref{%
  \fb@namexdef{fb@r.\fb@key}{{\the\fb@lbl}{\the\fb@txt}}}
\newcommand\fb@getref{\afterassignment\fb@txt\fb@lbl}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\fb@setlbl}
% \begin{macro}{\fb@getlbl}
% |\fb@setlbl| updates the dynamic label of a reference. |\fb@getlbl| gets
% the label after calling |\fb@setlbl| if necessary to update it.
%    \begin{macrocode}
\newcommand\fb@setlbl{%
  \global\advance\fb@refcount\@ne
  \edef\@tempa{{\fb@refnumunit}{\the\fb@refcount}}%
  \global\fb@lbl\expandafter{\expandafter\fb@getlbl\@tempa}%
  \fb@setref
  \the\fb@refcount}
\newcommand*\fb@getlbl[2]{\ifnum\fb@refnumunit=#1{#2}\else\fb@setlbl\fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\fb@settxt}
% \begin{macro}{\fb@gettxt}
% |\fb@settxt| and |\fb@gettxt| are similar to |\fb@setlbl| and
% |\fb@getlbl| but update the text of the reference instead of the label.
% When |\fb@settxt| is called, the label must have been expanded just
% before so that it has been updated if necessary. Then |\fb@lbl|
% has either the form |{|\meta{static label}|}|\Index{static}{label} or
% the form |\fb@getlbl{|\meta{current numunit}|}{|\meta{dynamic
% label}|}|\Index{dynamic}{label}.
% In the later case, the test at the beginning of |\fb@getlbl| must
% succeed so that in both cases, the first command in |\fb@settxt|
% below assigns the label to |\toks@|. 
%    \begin{macrocode}
\newcommand\fb@settxt[1]{%
  \toks@=\the\fb@lbl
  \toks@\expandafter\expandafter\expandafter{\expandafter
    \footreflabel\expandafter{\the\toks@}}%
  \edef\@tempa{{\fb@refciteunit}{\the\toks@}{\fb@refpage}}%
  \global\fb@txt\expandafter{\expandafter\fb@gettxt\@tempa{#1}}%
  \fb@setref
  #1}
\newcommand\fb@gettxt[4]{%
  \ifnum\fb@refciteunit=#1\relax
    \footxref{#2}{#3}%
  \else
    \fb@settxt{#4}%
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Commands to handle the foot bibliography}
%
% \begin{macro}{\footbibliography}
% \begin{macro}{\footbibliographystyle}
% |\footbibliography| and |\footbibliographystyle| are the commands which
% define the bibliography file and the bibliography style. They just write
% their argument to the auxiliary file. If they are used in the preamble, the
% |\fb@writeaux| macro in use is the delayed one. The write will actually
% take place at the beginning of the document.
%    \begin{macrocode}
\newcommand\footbibliography{\fb@writeaux\bibdata}
\newcommand\footbibliographystyle{\fb@writeaux\bibstyle}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fb@refnotfound}
% When a reference is not found by \LaTeX, it is replaced by a
% default one generated by the command |\fb@refnotfound| which
% takes the key of the reference as an argument and expands to the
% default label and the default text.
%    \begin{macrocode}
\newcommand*\fb@refnotfound[1]{%
  {?}{*** ERROR: citation `{\normalfont\ttfamily\bfseries#1}' undefined ***}}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Creation of the foot references}
%
% \begin{macro}{\footcite}
% \begin{macro}{\footcite*}
% \begin{macro}{\footnocite}
% \begin{macro}{\fb@@cite}
% \begin{macro}{\fb@optlbl}
% \begin{macro}{\iffb@lbl}
% \begin{macro}{\iffb@txt}
% All 3 citation commands |\footcite|, |\footcite*| and |\footnocite|
% actually call the same macro |\fb@cite|. Before this call, they just
% set the flags 
% |\iffb@lbl| and |\iffb@txt| according to whether the label and the
% text of the reference are requested. The settings are as follows:
% \begin{center}
% \DeleteShortVerb\|\MakeShortVerb\"
% \begin{tabular}{|l|c|c|}\hline
%               & "\iffb@lbl" & "\iffb@txt" \\\hline
% "\footcite"   & true        & true  \\
% "\footcite*"  & true        & false \\
% "\footnocite" & false       & true  \\\hline
% \end{tabular}
% \DeleteShortVerb\"\MakeShortVerb\|
% \end{center}
% In addition, |\footcite| calls |\fb@@cite| to get the optional argument
% which is put in |\fb@optlbl|.
%    \begin{macrocode}
\newif\iffb@lbl
\newif\iffb@txt
\DeclareRobustCommand\footcite{%
  \fb@lbltrue\@ifstar{\fb@txtfalse\fb@@cite}{\fb@txttrue\fb@@cite}}
\newcommand\footnocite{\fb@lblfalse\fb@txttrue\fb@cite}
\newcommand*\fb@@cite[1][\@nil]{%
  \def\fb@optlbl{#1}%
  \ifx\fb@optlbl\@nnil
    \let\fb@optlbl\relax
  \else
    \def\fb@optlbl{\fb@putfootcitelabel{, #1}}%
  \fi
  \fb@cite}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fb@cite}
% |\fb@cite| is the macro which handles the list of citations. It
% calls |\fb@xcite| to produce the actual label and insert the text
% of each individual reference.
%    \begin{macrocode}
\newcommand*\fb@cite[1]{%
  \fb@vedef\fb@keys{#1}%
  \iffb@lbl
    \fb@citestart
    \def\fb@citea{\let\fb@citea\fb@citesep}%
  \fi
%    \end{macrocode}
% If the list of citation is empty, the |\@for| loop is not 
% entered and no warning is issued. Therefore, we check for this now.
%    \begin{macrocode}
  \ifx\fb@keys\@empty
    \PackageWarning{footbib}{Empty citation on page \thepage}%
  \fi
  \@for\fb@key:=\fb@keys\do{%
    \iffb@lbl\fb@citea\fi
    \fb@xcite
    \ifx\fb@deferredcite\@empty\else
      \begingroup
        \fb@lblfalse
        \expandafter\fb@xnocite\fb@deferredcite\@nil
      \endgroup
    \fi}%
  \iffb@lbl\fb@optlbl\fb@citeend\fi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fb@xfootcite}
% \begin{macro}{\fb@deferredcite}
% The macro |\fb@xfootcite| is a replacement for the |\cite| command of
% \LaTeX\ inside a foot reference if the
% |crossrefs|\SpecialOptionIndex{crossrefs} or 
% |crossrefs*|\SpecialOptionIndex{crossrefs*} option was used.  
% In both cases, |\fb@xfootcite| performs a 
% |\footcite*|. If the |crossrefs|\SpecialOptionIndex{crossrefs} option was
% used, in addition, |\fb@xfootcite| adds globally the list of citation
% keys to the list |\fb@deferredcite|. After the insertion of the current
% reference has been completed, a |\footnocite|\SpecialUsageIndex{\footnocite}
% will be performed for each key in the list. The format of this list is
% \meta{key}|,|\dots,\meta{key}|,| (the trailing comma makes it easier to
% handle than \meta{key}|,|\dots|,|\meta{key} and allows to distinguish between
% an empty list and a list containing only an empty element). This list is
% initially empty.  
%    \begin{macrocode}
\newcommand\fb@xfootcite[2][\@nil]{%
  \footcite*[#1]{#2}%
  \iffb@xcrossrefs
    \fb@vedef\fb@keys{#2}%
    \xdef\fb@deferredcite{\fb@deferredcite\fb@keys,}%
  \fi}
\let\fb@deferredcite\@empty
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\fb@xnocite}
% After the insertion of the current reference has been completed, if some
% deferred cross-references are present, the macro |\fb@xnocite| is called.
% It calls |\fb@xcite| with |\iffb@lbl|=\emph{false} to insert the text of
% the cross-references if necessary. This might produce more deferred
% cross-references which will be added to |\fb@deferredcite|. 
%    \begin{macrocode}
\def\fb@xnocite#1,#2\@nil{%
  \gdef\fb@deferredcite{#2}%
  \def\fb@key{#1}%
  \fb@xcite
  \ifx\fb@deferredcite\@empty
    \let\@tempa\@gobble
  \else
    \let\@tempa\fb@xnocite
  \fi
  \expandafter\@tempa\fb@deferredcite\@nil}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fb@xcite}
% The macro |\fb@xcite| is called both by |\fb@cite| and
% |\fb@xnocite| to handle each individual citation. It writes to the auxiliary
% file the information about the citation, puts the label in the text if
% requested and put the text of the reference on the page if necessary. If the
% reference is not found, it issues a warning.
%
% The first command in |\fb@xcite| removes any space in front of the key.
% |\@empty| is inserted after the key to prevent an error in case it is
% empty. 
%
% If the key is empty or the reference is undefined, the \LaTeX\ command
% |\G@refundefinedtrue| is used to set the switch
% |\if@refundefined| which indicates that some reference was
% undefined. 
%    \begin{macrocode}
\newcommand\fb@xcite{%
  \edef\fb@key{\expandafter\@firstofone\fb@key\@empty}%
  \ifx\fb@key\@empty
    \PackageWarning{footbib}{Empty citation on page \thepage}%
    \G@refundefinedtrue
  \else
    \@ifundefined{fb@r.\fb@key}%
%    \end{macrocode}
% \FbIndex{\fb@r.\noexpand~{key}}^^A
%    \begin{macrocode}
      {\G@refundefinedtrue
       \PackageWarning{footbib}{%
          Citation `\fb@key' on page \thepage \space undefined}% 
       \fb@getref\fb@refnotfound\fb@key\fb@setref}%
      {\fb@getref\@nameuse{fb@r.\fb@key}}%
%    \end{macrocode}
% \FbIndex{\fb@r.\noexpand~{key}}^^A
%    \begin{macrocode}
    \fb@bibcite
    \iffb@lbl\fb@putfootcitelabel{\footcitelabel{\the\fb@lbl}}\fi
%    \end{macrocode}
% The text of the reference is inserted if requested (|\iffb@txt|=\emph{true})
% and either it has not yet been inserted in the current citation unit, or a
% |citeonce*| option was used and the last citation was on
% another (double) page.
%    \begin{macrocode}
    \iffb@txt
      \expandafter\let\expandafter\@tempa\csname
          fb@fn\fb@key.\fb@refciteunit\endcsname
%    \end{macrocode}
% \FbIndex{\fb@fn\noexpand~{key}.\noexpand~{num}}^^A
%    \begin{macrocode}
      \@tempswatrue
      \ifx\@tempa\relax\else
        \iffb@xref
          \ifx\@tempa\fb@refxrefunit 
            \@tempswafalse
          \fi
        \else
          \@tempswafalse
        \fi
      \fi
      \if@tempswa
        \fb@namexdef{fb@fn\fb@key.\fb@refciteunit}{\fb@refxrefunit}%
%    \end{macrocode}
% \FbMainIndex{\fb@fn\noexpand~{key}.\noexpand~{num}}^^A
%    \begin{macrocode}
        \fb@citefn
      \fi
    \fi
  \fi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fb@bibcite} 
% \begin{macro}{\fb@lastrefnumunit}
% \begin{macro}{\fb@citecount}
% The command |\fb@bibcite| writes 
% to the auxiliary file all the informations about the current
% citation: the key, the units, and the page. It also resets to 0 the counter
% |\fb@refcount| if the numbering unit changed between the last reference and
% the current one. This counter is used to number the references. The counter 
% |\fb@lastrefnumunit| holds the numbering unit of the last reference.
% The counter |\fb@citecount| holds the number of the current citation. 
%    \begin{macrocode}
\newcount\fb@citecount
\newcount\fb@lastrefnumunit \fb@lastrefnumunit\m@ne
\newcommand\fb@bibcite{%
  \fb@writeaux\citation\fb@key
  \global\advance\fb@citecount\@ne
  \expandafter\fb@getunits\csname fb@c.\the\fb@citecount\endcsname
%    \end{macrocode}
% \FbIndex{\fb@c.\noexpand~{num}}^^A
%    \begin{macrocode}
  \ifnum\fb@refnumunit=\fb@lastrefnumunit\else
    \global\fb@lastrefnumunit\fb@refnumunit\relax
    \global\fb@refcount\z@
  \fi
  \if@filesw
    \write\fb@auxout\expandafter{\expandafter\string\expandafter
      \bibcite\expandafter{\fb@key}\fb@theunits}%
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fb@citefn}
% |\fb@citefn| inserts the text of the reference. It is called
% only if the reference was not already cited in the same citation
% unit or a |citeonce*|\SpecialOptionIndex{citeonce*} option was used. 
% The code is mainly borrowed from the footnotes handling in \LaTeX.
%    \begin{macrocode}
\newcommand\fb@citefn{%
  \insert\fb@ins{%
    \reset@font\footrefstyle
    \interlinepenalty\iffb@nosplit\@M\else\interfootnotelinepenalty\fi
    \splittopskip 1.2\ht\strutbox
    \splitmaxdepth \dp\strutbox
    \floatingpenalty \@MM
    \hsize\columnwidth
    \@parboxrestore
    \ifx\newblock\@undefined\let\newblock\relax\fi
    \iffb@crossrefs\let\cite\fb@xfootcite\fi
    \@tempdima\fb@lblwidth
    \advance\@tempdima\labelsep
    \leftskip\@tempdima
    \color@begingroup
      \setbox\@tempboxa\hbox{\footreflabel{\the\fb@lbl}}%
      \hskip-\@tempdima
      \ifdim\wd\@tempboxa<\fb@lblwidth
        \hb@xt@\fb@lblwidth{\unhbox\@tempboxa\hfil}%
      \else
        \box\@tempboxa
      \fi
      \hskip\labelsep
      \rule\z@{1.2\ht\strutbox}\ignorespaces\the\fb@txt\@finalstrut\strutbox
    \color@endgroup}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{AtBeginDocument, AtEndDocument}
%
% At the beginning of the document, we read the bibliography file and
% record all the references. This is memory consuming but the only
% alternative is to read again the bibliography file for each
% |\footcite| command which would be much slower.
% We must wait until the beginning of the document to give the user a
% chance to redefine |\fb@bibname| through |\footbibliographyname|.
% The preamble of the bibliography is executed once for all when the
% bibliography is read. After recording the bibliography, we read the |.aux|
% file (if it exists) and record the parameters (citation and numbering unit,
% page, etc.) of all citations as determined during the previous run. The
% parameters of the $n^{th}$ citation are recorded in the macro 
% |\fb@c.|\meta{n}.
%    \begin{macrocode}
\AtBeginDocument{%
%    \end{macrocode}
% Save the current value of |\thebibliography| and redefine it
%    \begin{macrocode}
  \let\fb@savethebibliography\thebibliography
  \let\thebibliography\fb@thebibliography
  \let\fb@thebibliography\@undefined
%    \end{macrocode}
% Read the |bbl| file. This executes the preamble, and if a
% |thebibliography| environment is found, sets |\fb@lblwidth| to the
% length of the longest label and records all references. |\fb@lblwidth|
% is initialised with a negative value which allows us to detect
% afterward whether a |thebibliography| environment was present.
%    \begin{macrocode}
  \global\fb@lblwidth=-\maxdimen
  \fb@refcount\z@
  \@input{\fb@bibname.bbl}%
%    \end{macrocode}
% Restore the standard value of |\thebibliography|
%    \begin{macrocode}
  \let\thebibliography\fb@savethebibliography
  \let\fb@savethebibliography\@undefined
%    \end{macrocode}
% Assign a default value to |\fb@lblwidth| in case the |bbl| file
% was not found or contained no |thebibliography| environment.
%    \begin{macrocode}
  \ifdim\fb@lblwidth<\z@
    \settowidth\fb@lblwidth
      {\footrefstyle\footreflabel{\expandafter\@firstoftwo\fb@refnotfound{?}}}%
  \fi
%    \end{macrocode}
% \begin{macro}{\bibcite}
% \VerbSetup{\begin{macro}{\fb@c.\noexpand~{num}}}
% Then read the auxiliary file and record the parameters of each citation.
%    \begin{macrocode}
  \fb@citecount\z@
  \begingroup
    \let\citation\@gobble \let\bibstyle\@gobble \let\bibdata\@gobble
    \def\bibcite#1#2#3#4#5{%
        \advance\fb@citecount\@ne
        \fb@vedef\fb@key{#1}%
        \fb@namexdef{fb@c.\the\fb@citecount}{{\fb@key}{#2}{#3}{#4}{#5}}}%
    \@input{\fb@bibname.aux}%
  \endgroup
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\fb@auxout}
% Prepare the auxiliary file for writing
%    \begin{macrocode}
  \if@filesw
    \immediate\openout\fb@auxout=\fb@bibname.aux
    \immediate\write\fb@auxout{\relax}%
  \fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fb@writeaux}
% Finally, define a non delayed version of |\fb@writeaux|.
%    \begin{macrocode}
  \renewcommand*\fb@writeaux[2]{%
    \if@filesw
      \immediate\write\fb@auxout{\string#1{#2}}%
    \fi}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fb@thebibliography}
% \begin{macro}{\fb@lblwidth}
% The macro |\fb@thebibliography| records the length of the longest
% label in the \meta{dimen} register |\fb@lblwidth| and then scans the
% bibliography and stores each reference in a global macro
% |\fb@r.|\meta{key} where \meta{key} is the key 
% of the reference. The references are read one token at a time so that we
% may detect |\verb| commands even if they are hidden in groups.
%    \begin{macrocode}
\newdimen\fb@lblwidth
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\newcommand*\fb@thebibliography[1]{%
%    \end{macrocode}
% We open still a new group to prevent our definitions to conflict with
% macros that might be used by |\end{thebibliography}|. We let
% |\endthebibliography| equal to |\endgroup| so that it closes this group.
%    \begin{macrocode}
  \begingroup
  \let\endthebibliography\endgroup
%    \end{macrocode}
% Record the size of the longest label
%    \begin{macrocode}
  \settowidth\dimen@{\footrefstyle\footreflabel{#1}}%
  \ifdim\dimen@>\fb@lblwidth\global\fb@lblwidth=\dimen@\fi
%    \end{macrocode}
%
% \begin{macro}{\@bracelevel}
% \begin{macro}{\@bgrouplineno}
% \begin{macro}{\@on@line}
% \begin{macro}{\@eat}
% Some definitions necessary to read the bibliography entries.
% All these definitions are local since the command
% |\begin{thebibliography}| opened a new group. They will be
% cancelled when |\end{thebibliography}| is executed.
% The names of global definitions have the form |\fb@|\dots\ while the
% names of local definitions simply start with |\@|\dots\ We reuse as
% much as possible 
% existing global names so that we do not use memory unnecessarily.
% the |\@bracelevel| counter keeps track of groups nesting while
% reading the bibliography. The |\@bgrouplineno| counter holds the
% number of the input line where the current group started. It is
% used for error messages. |\@on@line| is similar to the |\on@line|
% command of the \LaTeXe\ kernel but also shows the name of the
% current file.
%    \begin{macrocode}
  \newcount\@bracelevel
  \newcount\@bgrouplineno
  \def\@on@line{\on@line\space of \fb@bibname.bbl}%
  \def\@eat{\let\@tempa= }%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\@bgroup}
% \begin{macro}{\@egroup}
% \begin{macro}{\bgroup}
% \begin{macro}{\egroup}
% |\bgroup| and |\egroup| are redefined so that we may distinguish
% between explicit and implicit begin or end group characters.
%    \begin{macrocode}
  \let\@bgroup{%
  \let\@egroup}%
  \let\bgroup\relax
  \let\egroup\relax
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\@actlet}
% |\@actlet\|\meta{char}\meta{cmd} makes \meta{char} active and lets it
% equal to \meta{cmd}.
%    \begin{macrocode}
  \def\@actlet##1{%
      \catcode`##1=\active
      \begingroup\lccode`~=`##1\lowercase{\endgroup\let~}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@noitemerror}
% |\@noitemerror| is called to raise an error if anything is seen
% between |\begin{thebibliography}| and the first |\bibitem|. If the
% user types \meta{return} at the prompt, the next token is swallowed
% and the processing goes on.
%    \begin{macrocode}
  \def\@noitemerr{%
      \PackageError{footbib}{Missing \string\bibitem\@on@line}\@empty
      \afterassignment\@readbib\@eat}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@errifbraces}
% |\@errifbraces|\meta{cmp} compares |\@bracelevel| with 0 using
% \meta{cmp} ($=$ or $>$) and raises an error if the test succeeds.
%    \begin{macrocode}
  \def\@errifbraces##1{%
      \ifnum\@bracelevel##1\z@
        {\ifx##1>\let\inputlineno\@bgrouplineno\fi
        \PackageError{footbib}{%
           \ifx##1>Unmatched begin\else Extra end\fi-group
           character\@on@line}\@empty}% 
      \fi}% 
%    \end{macrocode}
% \end{macro}
% Now come all the commands which read and handle the tokens.
%
% \begin{macro}{\@readbib}
% \begin{macro}{\@xreadbib}
% These macros read the next token and take the appropriate action.
%    \begin{macrocode}
  \def\@readbib{\futurelet\@tok\@xreadbib}%
  \def\@xreadbib{%
      \ifx\@tok\@sptoken\let\@tempa\@readsp
      \else\ifx\@tok\par\let\@tempa\@readpar
      \else\ifx\@tok\bibitem\let\@tempa\@endbibitem
      \else\ifx\@tok\end\let\@tempa\@checkendbib
      \else\if@newlist\let\@tempa\@noitemerr
      \else\ifx\@tok\@bgroup\let\@tempa\@eat\afterassignment\@begingroup
      \else\ifx\@tok\@egroup\let\@tempa\@eat\afterassignment\@endgroup
      \else\ifx\@tok\verb\let\@tempa\relax
      \else\let\@tempa\@addtotxt
      \fi\fi\fi\fi\fi\fi\fi\fi\@tempa}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\bibitem}
% \begin{macro}{\@bibitem}
% \begin{macro}{\@lbibitem}
% The macro |\bibitem| is called if the next token is |\bibitem|. It
% calls |\@lbibitem| or |\@bibitem| depending on whether a label is
% provided or not. If no label is provided, |\@bibitem| provides one.
% The definition of this macro depends on the switch |\iffb@firstcite|
% which is true iff a |firstcite|\SpecialOptionIndex{firstcite} option
% was used. If so, a \emph{dynamic} label\Index{dynamic}{label} is
% provided. Otherwise, a \emph{static} label\Index{static}{label} is
% provided which is the current value of the counter |\fb@refcount|.
%    \begin{macrocode}
  \def\bibitem{%
      \@errifbraces>%
      \@newlistfalse
      \@ifnextchar[\@lbibitem\@bibitem}%
  \iffb@firstcite
    \def\@bibitem{\@lbibitem[\fb@setlbl]}%
  \else
    \def\@bibitem{%
      \advance\fb@refcount\@ne
      \expandafter\@lbibitem\expandafter[\the\fb@refcount]}%
  \fi
  \def\@lbibitem[##1]##2{%
      \fb@lbl{{##1}}%
      \fb@vedef\fb@key{##2}%
      \fb@txt{}%
      \let\@lastsptok\@empty
      \@inlabeltrue
      \@readbib}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\@checkendbib}
% The macro |\@checkendbib| is called when the next token is |\end|. It
% reads the argument of |\end| and checks whether it is
% |thebibliography|. If so it calls |\@endbibitem| to terminate the
% current reference (if any) and reinserts |\end{thebibliography}| which will
% terminate the bibliography.
%    \begin{macrocode}
  \def\@checkendbib\end##1{%
      \def\@tempa{##1}\def\@tempb{thebibliography}%
      \ifx\@tempa\@tempb
        \def\@tempa{\@endbibitem\end{##1}}%
      \else
        \if@newlist
          \let\@tempa\@noitemerr
        \else
          \def\@tempa{\@addtotxt{\end{##1}}}%
        \fi
      \fi\@tempa}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@endbibitem}
% The macro |\@endbibitem| terminates the current reference (if any) and
% calls |\fb@setref| which stores it in a macro. If the switch
% |\iffb@xref| is true, i.e~a |citeonce*|\SpecialOptionIndex{citeonce*}
% option was used, 
% |\@endbibitem| adds to the text of the reference the command
% |\fb@settxt| which will modify it dynamically.
%    \begin{macrocode}
  \def\@endbibitem{%
      \if@newlist\else
        \@errifbraces>%
        \iffb@xref
          \fb@txt\expandafter{\expandafter\fb@settxt\expandafter{\the\fb@txt}}%
        \fi
        \fb@setref
      \fi}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@addtotxt}
% The macro |\@addtotxt| adds to the text of the reference so far, first
% the last \emph{space} token (\meta{space} or |\par|) and then its
% argument. 
%    \begin{macrocode}
  \long\def\@addtotxt##1{%
      \fb@txt\expandafter\expandafter\expandafter
        {\expandafter\the\expandafter\fb@txt\@lastsptok##1}%
      \let\@lastsptok\@empty
      \@inlabelfalse
      \@readbib}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@readsp}
% \begin{macro}{\@readpar}
% \begin{macro}{\@lastsptok}
% The \emph{space} tokens \meta{space} and |\par| are handled in a
% delayed way. They are first recorded in a single place
% (|\@lastsptok|), so that each one overrides the previous one. 
% The most recent one is added to the text of the reference each time
% |\@addtotxt| is called. This mechanism discards any space preceding
% a |\par| token and also the |\par| which occurs generally at the
% end of each reference.
%    \begin{macrocode}
  \expandafter\def\expandafter\@readsp\space{%
      \if@inlabel\else\let\@lastsptok\space\fi
      \@readbib}%
  \def\@readpar\par{%
      \if@inlabel\else\def\@lastsptok{\par}\fi
      \@readbib}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\@begingroup}
% \begin{macro}{\@endgroup}
% The macros |\@begingroup| and |\@endgroup| are called when a begin-
% or end-group character is seen. |\@begingroup| opens a new group and
% increments the counter |\@bracelevel|. It also records the number of the
% input line which may be used later for error reporting. |\@endgroup| closes
% the group, which restores the previous value of |\@bracelevel|, and calls
% |\@addtotxt| to add the group to the text of the reference so far.
%    \begin{macrocode}
  \def\@begingroup{%
      \@bgroup
      \advance\@bracelevel\@ne
      \@bgrouplineno=\inputlineno
      \fb@txt{}%
      \let\@lastsptok\@empty
      \@readbib}%
  \def\@endgroup{%
      \@errifbraces=%
      \edef\@tempa{\@egroup\noexpand\@addtotxt{{\the\fb@txt\@lastsptok}}}%
      \@tempa}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\verb}
% \begin{macro}{\@sverb}
% We provide special support for the |\verb| command. The following code
% is essentially borrowed from the \LaTeXe\ kernel. Just we let the
% active characters equal to |\relax| so that they are not expanded.
%    \begin{macrocode}
  \def\verb{%
      \begingroup
%    \end{macrocode}
% First make all special characters `other'
%    \begin{macrocode}
      \let\do\@makeother \dospecials
%    \end{macrocode}
% Avoid ligatures
%    \begin{macrocode}
      \def\do####1{\@actlet####1\relax}\verbatim@nolig@list
%    \end{macrocode}
% An end of line character in the argument of |\verb| is an error.
%    \begin{macrocode}
      \@actlet\^^M\verb@eol@error
      \@ifstar{\@sverb*}{\@actlet\ \relax\@sverb\@empty}}%
  \def\@sverb##1##2{%
      \@actlet##2\verb@egroup
%    \end{macrocode}
% Read the argument of |\verb|.
%    \begin{macrocode}
      \edef\@tempa{\noexpand\verb##1\noexpand~\iffalse}\fi}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\verb@egroup}
% Normal termination of |\verb|. The |~| must be protected against expansion
% because we are still inside the |\edef| started by |\@sverb|.
%    \begin{macrocode}
  \def\verb@egroup{%
      \noexpand~\iffalse{\fi}%
      \expandafter\endgroup\expandafter\@addtotxt\expandafter{\@tempa}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\verb@eol@error}
% The macro |\verb@eol@error| is called if an end of line character
% occurs before the normal termination of |\verb|. Unlike it is done in the
% \LaTeXe\ kernel, we do not terminate the |\verb| because the most frequent
% case is when \BibTeX\ breaks the argument of |\verb| because the line is too
% long. The closing delimiter will generally be found on the next line.
%    \begin{macrocode}
  \def\verb@eol@error{\iffalse{\fi}%
      \GenericError\@empty{LaTeX Error:
          \noexpand\verb ended by end of line\@on@line}\@gobble%
          {The argument of \string\verb\@on@line\space contains 
               an end of line.\MessageBreak 
           Type \space X <return> \space to quit.\MessageBreak}%
%    \end{macrocode}
% We try to recover from error in case the user types \meta{return} at the
% prompt. We where defining |\@tempa| which contains now
% |\verb|?|~|\dots\ where\ ?\ stands for |*| or nothing. 
%    \begin{macrocode}
      \toks@\expandafter{\@tempa}%
      \edef\@tempa{\the\toks@\iffalse}\fi}%
%    \end{macrocode}
% \end{macro}
% Some initialisation before starting to read the
% bibliography. 
%    \begin{macrocode}
  \@bracelevel\z@
  \@newlisttrue
  \@inlabeltrue
%    \end{macrocode}
% And finally start to read the bibliography. This is the end of
% |\fb@thebibliography| 
%    \begin{macrocode}
  \@readbib}
%    \end{macrocode}
% \end{macro}
%
% At the end of the document, we first do a |\clearpage| to be sure
% that all the writes have been performed. Then we close the
% auxiliary file and finally read it to check whether any change
% occured between the previous run and the current one. If so, we issue a
% warning. 
%    \begin{macrocode}
\AtEndDocument{%
  \clearpage
  \if@filesw
    \immediate\closeout\fb@auxout
    \begingroup
      \let\citation\@gobble \let\bibstyle\@gobble \let\bibdata\@gobble
      \def\bibcite#1#2#3#4#5{%
        \advance\fb@citecount\@ne
        \fb@vedef\@tempa{#1}%
        \edef\@tempa{{\@tempa}{#2}{#3}{#4}{#5}}%
        \expandafter\ifx\csname fb@c.\the\fb@citecount\endcsname
%    \end{macrocode}
% \FbIndex{\fb@c.\noexpand~{num}}^^A
%    \begin{macrocode}
          \@tempa\else\@tempswatrue\fi}%
      \fb@citecount\z@
      \@tempswafalse
      \input\fb@bibname.aux
      \if@tempswa
        \PackageWarning{footbib}{Bibliography not yet stable. Rerun
                                   LaTeX\@gobble}% 
      \fi
    \endgroup
  \fi}
%    \end{macrocode}
%
% \subsection{Output routine}
%
% We redefine the macros |\@specialoutput|, |\@doclearpage|,
% |\@makecol| and |\@reinserts| used by the output routine of \LaTeX\
% so that we may insert the foot bibliography.
% The code is just a patch to the macros defined in the \LaTeXe\ kernel.
% 
% \begin{macro}{\@specialoutput}
% If a foot bibliography is present, |\@specialoutput| must add to
% the height of the page the height plus depth of the foot
% bibliography and the length of the skip above it.
%    \begin{macrocode}
\def\@specialoutput{%
  \ifnum \outputpenalty>-\@Mii
    \@doclearpage
  \else
    \ifnum \outputpenalty<-\@Miii
      \ifnum \outputpenalty<-\@MM \deadcycles \z@ \fi
      \global \setbox\@holdpg \vbox {\unvbox\@cclv}%
    \else
      \global \setbox\@holdpg \vbox{%
                     \unvbox\@holdpg
                     \unvbox\@cclv
                     \setbox\@tempboxa \lastbox
                     \unskip}%
      \@pagedp \dp\@holdpg
      \@pageht \ht\@holdpg
      \unvbox \@holdpg
      \@next\@currbox\@currlist{%
        \ifnum \count\@currbox>\z@
          \advance \@pageht \@pagedp
          \ifvoid\footins \else
            \advance \@pageht \ht\footins
            \advance \@pageht \skip\footins
            \advance \@pageht \dp\footins
          \fi
%    \end{macrocode}
% \begin{FbPatch}{addition}
%    \begin{macrocode}
          \ifvoid\fb@ins\else
            \advance\@pageht\ht\fb@ins
            \advance\@pageht\skip\fb@ins
            \advance\@pageht\dp\fb@ins
          \fi
%    \end{macrocode}
% \end{FbPatch}
%    \begin{macrocode}
          \ifvbox \@kludgeins
            \ifdim \wd\@kludgeins=\z@
              \advance \@pageht \ht\@kludgeins
            \fi
          \fi
          \@reinserts
          \@addtocurcol
        \else
          \@reinserts
          \@addmarginpar
        \fi}%
       \@latexbug
      \ifnum \outputpenalty<\z@
        \if@nobreak 
          \nobreak
        \else
          \addpenalty \interlinepenalty
        \fi
      \fi
    \fi
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@doclearpage}
% The test at the beginning of |\@doclearpage| has been modified so that
% it checks that \emph{both} footnotes and the foot bibliography are empty.
%    \begin{macrocode}
\def \@doclearpage {%
%    \end{macrocode}
% \begin{FbPatch}{modification}
%    \begin{macrocode}
%  \ifvoid\footins
  \@tempswatrue
  \ifvoid\footins\else\@tempswafalse\fi
  \ifvoid\fb@ins\else\@tempswafalse\fi
  \if@tempswa
%    \end{macrocode}
% \end{FbPatch}
%    \begin{macrocode}
    \ifvbox\@kludgeins
      {\setbox \@tempboxa \box \@kludgeins}%
    \fi
    \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
    \setbox\@tempboxa\box\@cclv
    \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
    \global \let \@toplist \@empty
    \global \let \@botlist \@empty
    \global \@colroom \@colht
    \ifx \@currlist\@empty
    \else
      \@latexerr{Float(s) lost}\@ehb
      \global \let \@currlist \@empty
    \fi
    \@makefcolumn\@deferlist
    \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
    \if@twocolumn
      \if@firstcolumn
        \xdef\@dbldeferlist{\@dbltoplist\@dbldeferlist}%
        \global \let \@dbltoplist \@empty
        \global \@colht \textheight
        \begingroup
          \@dblfloatplacement
          \@makefcolumn\@dbldeferlist
          \@whilesw\if@fcolmade \fi{\@outputpage\@makefcolumn\@dbldeferlist}%
        \endgroup
      \else
        \vbox{}\clearpage
      \fi
    \fi
  \else
    \setbox\@cclv\vbox{\box\@cclv\vfil}%
    \@makecol\@opcol
    \clearpage
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makecol}
% In addition to footnotes (if any), |\@makecol| must add the foot
% bibliography to the page. It is added immediately below the footnotes.
% The test at the beginning of |\@makecol| has been modified in the same
% way as in |\@doclearpage|
%    \begin{macrocode}
\def \@makecol {%
%    \end{macrocode}
% \begin{FbPatch}{modification}
%    \begin{macrocode}
%  \ifvoid\footins
  \@tempswatrue
  \ifvoid\footins\else\@tempswafalse\fi
  \ifvoid\fb@ins\else\@tempswafalse\fi
  \if@tempswa
%    \end{macrocode}
% \end{FbPatch}
%    \begin{macrocode}
    \setbox\@outputbox \box\@cclv
  \else
    \setbox\@outputbox \vbox {%
      \boxmaxdepth \@maxdepth
      \unvbox \@cclv
%    \end{macrocode}
% \begin{FbPatch}{addition}
%    \begin{macrocode}
      \ifvoid\footins \else
%    \end{macrocode}
% \end{FbPatch}
%    \begin{macrocode}
        \vskip \skip\footins
        \color@begingroup
          \normalcolor
          \footnoterule
          \unvbox \footins
        \color@endgroup
%    \end{macrocode}
% \begin{FbPatch}{addition}
%    \begin{macrocode}
      \fi
      \ifvoid\fb@ins\else
        \vskip\skip\fb@ins
        \color@begingroup
          \normalcolor
          \footbibrule
          \unvbox\fb@ins
        \color@endgroup
      \fi
%    \end{macrocode}
% \end{FbPatch}
%    \begin{macrocode}
      }%
  \fi
  \let\@elt\relax
  \xdef\@freelist{\@freelist\@midlist}%
  \global \let \@midlist \@empty
  \@combinefloats
  \ifvbox\@kludgeins
    \@makespecialcolbox
  \else
    \setbox\@outputbox \vbox to\@colht {%
      \@texttop
      \dimen@ \dp\@outputbox
      \unvbox \@outputbox
      \vskip -\dimen@
      \@textbottom}%
  \fi
  \global \maxdepth \@maxdepth}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@reinserts}
% The macro |\@reinsert| was modified to reinsert also the foot
% bibliography after float processing. 
%    \begin{macrocode}
\def\@reinserts{%
  \ifvoid\footins\else\insert\footins{\unvbox\footins}\fi
%    \end{macrocode}
% \begin{FbPatch}{addition}
%    \begin{macrocode}
  \ifvoid\fb@ins\else\insert\fb@ins{\unvbox\fb@ins}\fi
%    \end{macrocode}
% \end{FbPatch}
%    \begin{macrocode}
  \ifvbox\@kludgeins\insert\@kludgeins{\unvbox\@kludgeins}\fi}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\endinput
%</package>
%    \end{macrocode}
%
% \Finale