%
%  Bibliography and Footnote hacks
%
%  Andrew Marc Greene
%
\newcount\Source \Source=0
%
\def\newsource#1#2#3{%  \newsource{code}{short_form}{long_form}
\global\advance\Source by 1
\expandafter\xdef\csname NUM.#1\endcsname{\the\Source}
\expandafter\gdef\csname SHORT.#1\endcsname{#2}%
\expandafter\gdef\csname LONG.#1\endcsname{#3}%
\expandafter\gdef\csname #1\endcsname{\cite{#1}}}
%
\def\CITELAST{0}
%
\def\cite#1{%  does a footnote citation
\xdef\CITETEST{\csname NUM.#1\endcsname}%
\ifnum\CITELAST=\CITETEST%
{\it Ibid.}\else%
\xdef\CITELAST{\csname NUM.#1\endcsname}%
\csname LONG.#1\endcsname%
\expandafter\gdef\csname LONG.#1\endcsname{\csname SHORT.#1\endcsname}\fi}
%
\newcount\fcount\fcount=0
\let\ftnote=\footnote
\def\footnote{\global\advance\fcount by 1\relax\ftnote{$^{\number\fcount}$}}
%
%
%  Test it:
%
\newsource{tb}{Knuth}{Knuth, Donald E., {\it The \TeX book},
Addison-Wesley, 1986}
\newsource{multi}{Mittelbach}{Mittelbach, Frank, ``An environment for
multicolumn output,'' {\it TUGboat \bf 10} (3)}
\newsource{ted}{Ts'o}{Ts'o, Ted, private communication}
%
Here is a short sample document with a bunch of footnotes.  It is a
test of a footnote-citation system for \TeX.\footnote{\tb}  These
macros should be compatible with multi-column formats\footnote{\multi,
p.~407} and the MITeX system.\footnote{\ted}

Using the expandafter command,\footnote{\tb, p. 40} this package is
able to handle ``OpCit'' and ``Ibid'' references automatically.  It
expects the user to use the footnote command\footnote{\tb, p.~82} to
create the footnote.

Now I'll throw in a few gratuitous footnotes\footnote{\multi, p.~410;
also \ted} to show\footnote{\tb} all\footnote{\multi} sorts of
things.\footnote{\multi}

\bye
