%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Enrico Bertolazzi",
%%%     version         = "0.2",
%%%     date            = "15-SEPT-96",
%%%     filename        = "easybib.sty",
%%%     address         = "Laboratorio di Matematica Applicata
%%%                        Trento University,
%%%                        Via Mesiano, Trento, Italy",
%%%     FAX             = "+39 (461) 882672",
%%%     email           = "bertolaz@ing.unitn.it (Internet)",
%%%     supported       = "yes. Please send comments via E-mail",
%%%     docstring       = "package for easy typing equations.
%%%
%%% INSTALLATION:
%%%   Put this file where your TeX looks for inputs.
%%%
%%% DOCUMENTATION:
%%%   Compile docbib.tex.
%%%
%%% COPYING:
%%%   Copying of part or all of this file is allowed under the following
%%%   conditions only:
%%%   (1) You may freely distribute unchanged copies of the file. Please
%%%       include the documentation when you do so.
%%%   (2) You may modify a renamed copy of the file, but only for personal
%%%       use or use within an organization.
%%%   (3) You may copy fragments from the file, for personal use or for
%%%       distribution, as long as credit is given where credit is due.
%%%
%%%   You are NOT ALLOWED to take money for the distribution or use of
%%%   this file or modified versions or fragments thereof, except for
%%%   a nominal charge for copying etc.
%%%
%%%  }
%%% ====================================================================
%%%       ___    ____  ___   _   _      __    __    ____ ______
%%%      /   \  /     /   \  \  /      /  \  /  \  /       /
%%%     /____/ /__   /____/   \/       \    /   / /__     /
%%%    /   \  /     /  \      /         \  /   / /       /
%%%   /____/ /____ /    \    /       \__/  \__/ /       /
%%% ====================================================================
\typeout{Document Style `easybib'  version 0.2 <15-SEPT-1996>.}
%% BEGIN easybib.sty
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{easybib}[1996/09/15 v0.2]

\def\refname{References}
\def\bibname{Bibliography}

\newbox\@bib@moreref@box

\def\@bib@define[#1]{%
\expandafter\global\expandafter\newbox\csname @bib@#1@box\endcsname%
\expandafter\xdef\csname#1\endcsname{%
\egroup\egroup\global\setbox\csname @bib@#1@box\endcsname%
\hbox\bgroup\noexpand\@killglue\csname @bib@#1@fmt\endcsname\bgroup\ignorespaces}}

\def\@bib@out@ifexist#1{%
\ifdim\wd\@nameuse{@bib@#1@box}>0pt%
\@bib@old@punct%
\expandafter\global\expandafter\let\expandafter\@bib@old@punct\csname @bib@#1@punct\endcsname%
\unhbox\csname @bib@#1@box\endcsname\unskip
\fi}

\def\@bib@list{by,bysame,book,paper,toappear,editor,jour,addr,vol,yr,page}
\@for\@name:=\@bib@list\do{\@bib@define[\@name]}

\def\bibsetfmt#1#2#3{%
    \expandafter\global\expandafter\let\csname @bib@#1@fmt\endcsname=#2%
    \expandafter\xdef\csname @bib@#1@punct\endcsname{\noexpand\@killglue#3\space}%
}

\def\@bib@toappear#1{to appear on \textit{#1}}
\def\@bib@bysame#1{#1\hbox to3em{\hrulefill}}

\bibsetfmt{by}{\textbf}{,}
\bibsetfmt{bysame}{\@bib@bysame}{,}
\bibsetfmt{book}{\textsc}{,}
\bibsetfmt{paper}{\textit}{,}
\bibsetfmt{toappear}{\@bib@toappear}{,}
\bibsetfmt{editor}{\textrm}{,}
\bibsetfmt{jour}{\textrm}{,}
\bibsetfmt{page}{\textrm}{,}
\bibsetfmt{vol}{\textbf}{,}
\bibsetfmt{yr}{\textrm}{,}
\bibsetfmt{addr}{\textrm}{,}

\def\@bib@addtolist(#1,#2){\ifx#1\@empty\xdef#1{#2}\else\xdef#1{#1,#2}\fi}

\def\bibinsertbefore#1#2#3#4{%
    \def\next{\@bib@addtolist(\@tempb,#2)}%
    \global\let\@tempb\@empty%
    \edef\tmp{#1}
    \@for\@name:=\@bib@list\do{%
        \ifx\@name\tmp\@bib@addtolist(\@tempb,#2)\def\next{}\fi%
       \@bib@addtolist(\@tempb,\@name)%
    }
    \next%
    \global\let\@bib@list\@tempb%
    \@bib@define[#2]\bibsetfmt{#2}{#3}{#4}%
}

\def\@bib@init{\bgroup\bgroup\ignorespaces}

\def\bibitem{\global\let\@bib@old@punct\@empty\@ifnextchar[\@lbibitem\@bibitem}
\def\@lbibitem[#1]#2{\item[\@biblabel{#1}\hfill]\if@filesw%
      {\let\protect\noexpand%
       \immediate\write\@auxout{\string\bibcite{#2}{#1}}}\fi%
       \@bib@init}
\def\@bibitem#1{\item\if@filesw \immediate\write\@auxout%
       {\string\bibcite{#1}{\the\value{\@listctr}}}\fi\@bib@init}

\def\enditem{\@ifnextchar[{\@enditem}{\@enditem[;]}}
\def\@enditem[#1]{\egroup\egroup\unhbox\@bib@moreref@box\@bib@outitems#1}

\def\@bib@outitems{\@for\@name:=\@bib@list\do{\@bib@out@ifexist\@name}}

\def\moreref{\global\setbox\@bib@moreref@box\hbox{%
\unhbox\@bib@moreref@box\@killglue\@bib@outitems}}

\DeclareOption{definethebibliography}{%
   \def\bibindent{1.5em}
   \def\thebibliography#1{
      \section*{\refname\@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}}%
      \small
      \list{\@biblabel{\arabic{enumiv}}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \parsep\z@
            \topsep\z@
            \partopsep\z@
            \itemsep0.25em%
            \usecounter{enumiv}}%
      \sloppy\clubpenalty4000\widowpenalty4000%
      \sfcode`\.\@m}
   \def\endthebibliography{%
      \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
}
      
\ProcessOptions

\endinput
%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%