%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Enrico Bertolazzi",
%%%     version         = "0.3",
%%%     date            = "15-FEB-97",
%%%     filename        = "easybib.sty",
%%%     address         = "Laboratorio di Matematica Applicata
%%%                        Trento University,
%%%                        Via Mesiano, Trento, Italy",
%%%     FAX             = "+39 (461) 882672",
%%%     email           = "enrico.bertolazzi@ing.unitn.it (Internet)",
%%%     supported       = "yes. Please send comments via E-mail",
%%%     docstring       = "package for easy typing bibliography.
%%%
%%% 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.3 <15-FEB-1997>.}
%% BEGIN easybib.sty
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{easybib}[1997/02/15 v0.3]

\@ifundefined{refname}{\gdef\refname{References}}{}
\@ifundefined{bibname}{\gdef\refname{Bibliography}}{}

\newif\if@bib@first@item

\def\@bib@init@cmds{\global\@bib@first@itemtrue\global\let\@bib@old@fmtclo\@empty%
\expandafter\@for\expandafter\@name\expandafter:\expandafter=\csname \@bib@act@fmt list\endcsname
\do{\expandafter\let\csname\@name\expandafter\endcsname%
\csname @bib@\@bib@act@fmt @\@name @cmd\endcsname%
\expandafter\global\expandafter\setbox\csname @bib@\@name @box\endcsname=\box\voidb@x}}

\def\@bib@begin{\begingroup\gdef\@bib@first@punct{}\@bib@init@cmds\bgroup\ignorespaces}

\def\@bib@out{\@bib@old@fmtclo\egroup\@killglue%
\expandafter\@for\expandafter\@name\expandafter:\expandafter=\csname \@bib@act@fmt list\endcsname
\do{\@bib@out@if@exist[\@bib@act@fmt,\@name]}}

\def\@bib@end#1{\@bib@out#1\endgroup}

\def\moreref{\@ifnextchar[\@bib@moreref{\@bib@moreref[;]}}%
\def\@bib@moreref[#1]#2{\@bib@out\gdef\@bib@act@fmt{#2}%
\gdef\@bib@first@punct{\@killglue#1\space}%
\@bib@init@cmds\bgroup\ignorespaces}

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

\def\endref{\@ifnextchar[\@endref{\@endref[;]}}
\def\@endref[#1]{\@bib@end{#1}}

\def\@bib@out@if@exist[#1,#2]{%
\ifdim\wd\@nameuse{@bib@#2@box}>0pt%
\@killglue\unhbox\@nameuse{@bib@#2@box}\@killglue\fi}


\def\bibsetfmt[#1,#2]#3#4#5{%
\expandafter\gdef\csname @bib@#1@#2@punct\endcsname{\@killglue#3\space}
\expandafter\gdef\csname @bib@#1@#2@fmt\endcsname{#4}
\expandafter\gdef\csname @bib@#1@#2@fmtclo\endcsname{\@killglue#5}}

\def\bibdefinestyle#1#2{\bibsetfmt[#1,#2]{,}{\rmfamily}{}%
\@ifundefined{@bib@#2@box}{\expandafter\global\expandafter\newbox\csname @bib@#2@box\endcsname}{}
\expandafter\xdef\csname @bib@#1@#2@cmd\endcsname{\noexpand\@bib@old@fmtclo\egroup
\noexpand\global\noexpand\setbox\csname @bib@#2@box\endcsname\hbox\bgroup
\noexpand\global\noexpand\let\noexpand\@bib@old@fmtclo%
\expandafter\noexpand\csname @bib@#1@#2@fmtclo\expandafter\noexpand\endcsname%
\noexpand\if@bib@first@item\noexpand\@bib@first@punct\noexpand\else%
\expandafter\noexpand\csname @bib@#1@#2@punct\expandafter\noexpand\endcsname\noexpand\fi
\noexpand\global\noexpand\@bib@first@itemfalse%
\expandafter\noexpand\csname @bib@#1@#2@fmt\expandafter\noexpand\endcsname}}

\def\bibdefinestyles#1{%
\expandafter\xdef\csname #1ref\endcsname{\noexpand\gdef\noexpand\@bib@act@fmt{#1}
\noexpand\@ifnextchar[\noexpand\@lbibitem\noexpand\@bibitem}
\expandafter\@for\expandafter\@name\expandafter:\expandafter=\csname#1list\endcsname
\do{\bibdefinestyle{#1}{\@name}}}

\def\paperlist{by,bysame,title,transl,jour,toappear,inbook,publ,eds,publaddr,vol,yr,pages,finalinfo,lang}
\def\booklist{by,bysame,title,bookinfo,publ,publaddr,pages,yr,lang,transl}

\bibdefinestyles{paper} \let\bibitem\bibpaper
\bibdefinestyles{book}
% 
\bibsetfmt[paper,by]{}{\bfseries}{}
\bibsetfmt[paper,bysame]{,}{\hbox to3em{\hrulefill\hskip.1em}}{}
\bibsetfmt[paper,title]{,}{\itshape}{}
\bibsetfmt[paper,toappear]{}{(to appear}{)}
\bibsetfmt[paper,yr]{}{(}{)}
\bibsetfmt[paper,lang]{}{(}{)}
\bibsetfmt[paper,vol]{}{\bfseries}{}
\bibsetfmt[paper,eds]{}{(}{\@killglue, eds.)}
\bibsetfmt[paper,transl]{}{}{}
% 
\bibsetfmt[book,by]{}{\bfseries}{}
\bibsetfmt[book,bysame]{}{\hbox to3em{\hrulefill\hskip.1em}}{}
\bibsetfmt[book,title]{,}{\scshape}{}
\bibsetfmt[book,lang]{}{(}{)}

\def\@bib@styleA#1{#1.}
\def\@bib@styleB#1{[#1]}
\def\@bib@styleC#1{}

\def\refstyle#1{\expandafter\global\expandafter\let\expandafter\@biblabel\csname @bib@style#1\endcsname}
\refstyle{A}

\DeclareOption{definethebibliography}{%
   \def\bibindent{1.5em}
   \def\thebibliography{\@ifnextchar[{\@bib@init}{\@bib@init[\refname]}}
   \def\@bib@init[#1]#2{
      \section*{#1\@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}%
            \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#2}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
%             \itemsep\z@% indentation
            \renewcommand\theenumiv{\arabic{enumiv}}}%
      \sloppy\clubpenalty4000\widowpenalty4000%
      \sfcode`\.\@m}
%
   \def\endthebibliography{%
      \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
}
      
\ProcessOptions

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