%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Enrico Bertolazzi",
%%%     version         = "0.7",
%%%     date            = "16-MAR-99",
%%%     filename        = "easybib.sty",
%%%     address         = "Laboratorio di Matematica Applicata
%%%                        e Meccanica Strutturale,
%%%                        Trento University,
%%%                        Via Mesiano, Trento, Italy",
%%%     FAX             = "+39 (461) 882599",
%%%     email           = "enrico.bertolazzi@ing.unitn.it (Internet)",
%%%     supported       = "yes. Please send comments via E-mail",
%%%     docstring       = "package for easy customization of bibliography."
%%%
%%% INSTALLATION:
%%%   Put this file where your TeX looks for inputs.
%%%
%%% DOCUMENTATION:
%%%   Compile docbib.tex.
%%%
%%%   Copyright  1999 Enrico Bertolazzi
%%%
%%%   This program can be redistributed and/or modified under the terms
%%%   of the LaTeX Project Public License Distributed from CTAN
%%%   archives in directory macros/latex/base/lppl.txt; either
%%%   version 1 of the License, or any later version.
%%%
%%%  }
%%% ====================================================================%%%
%%%       ___    ____  ___   _   _      __    __    ____ ______         %%%
%%%      /   \  /     /   \  \  /      /  \  /  \  /       /            %%%
%%%     /____/ /__   /____/   \/       \    /   / /__     /             %%%
%%%    /   \  /     /  \      /         \  /   / /       /              %%%
%%%   /____/ /____ /    \    /       \__/  \__/ /       /               %%%
%%% ====================================================================%%%
\def\filedate{1999/03/16}
\def\fileversion{v0.7}
\typeout{Document Style `easybib'  \fileversion\space<\filedate>.}
%% BEGIN easybib.sty
%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{easy}
\ProvidesPackage{easybib}[\filedate\space\fileversion]

\@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\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{%
\@easy@gdef(@bib@#1@#2@punct){\@killglue#3\space}
\@easy@gdef(@bib@#1@#2@fmt){#4}
\@easy@gdef(@bib@#1@#2@fmtclo){\@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\@BIB@lbibitem[#1]#2{\@lbibitem[#1]{#2}\@bib@begin}
\def\@BIB@bibitem#1{\@bibitem{#1}\@bib@begin}

\def\bibdefinestyles#1{%
\@easy@xdef(#1ref){\noexpand\gdef\noexpand\@bib@act@fmt{#1}
\noexpand\@ifnextchar[\noexpand\@BIB@lbibitem\noexpand\@BIB@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}
\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{\@easy@glet(@biblabel){@bib@style#1}}
\refstyle{A}

\def\@bib@citeA#1#2{[{#1\if@tempswa , #2\fi}]}
\def\@bib@citeB#1#2{\@killglue$^{\hbox{\tiny[{#1\if@tempswa , #2\fi}]}}$}
\def\@bib@citeC#1#2{\@killglue$^{\hbox{\tiny#1\if@tempswa , #2\fi}}$}

\def\citestyle#1{\@easy@glet(@cite){@bib@cite#1}}
\citestyle{A}


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

      
\ProcessOptions

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