%% Modification of bibliographie_dans_la_marge.sty
%% in order to use marginnote.sty.
%% See the comments and instructions in
%% bibliographie_dans_la_marge.sty (if any).

%% This was written a long time ago and I no longer understand it
%% fully. 
%% 
%% I think you should use it in the following way.
%%
%%   \documentclass{article}
%%   \usepackage{widemargin,bibliomarginnote}
%%   \usepackage{afterbegindocument}
%%   \AfterBeginDocument{%
%%     \bibliographystyle{bibliographie_dans_la_marge}%
%%     \nocite{*}%
%%     \bibliography{livres}%
%%   }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% (c) 1999 Vincent Zoonekynd (zoonek@math.jussieu.fr)
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ProvidesFile{bibliomarginnote.sty}
\ProvidesPackage{bibliomarginnote}
\RequirePackage{amstext}
\RequirePackage{ifvide}
\RequirePackage{marginnote}

\newcounter{biblio@margin@numero}
\renewcommand{\thebiblio@margin@numero}{\arabic{biblio@margin@numero}}
\newcommand{\bibliomarginstyle}{\footnotesize}
\newcommand{\bibliomarginskipamount}{\bigskipamount}

\newcommand{\bibliomargin}[2]{%
  \expandafter\def\csname biblio@margin@cite@#1\endcsname{%
    \stepcounter{biblio@margin@numero}%
    \thebiblio@margin@numero
    \expandafter\global\expandafter\edef\csname biblio@margin@cite@#1\endcsname{%
      \thebiblio@margin@numero}%
    }%
  \expandafter\def\csname biblio@margin@text@#1\endcsname{%
    \insert\bot@margin@note{%
      \vskip \bibliomarginskipamount
      \noindent\parbox{\marginparwidth}{%
        \parindent=0pt
        \bibliomarginstyle
        \m@th\ensuremath{{}^{(\csname biblio@margin@cite@#1\endcsname)}}%
        \hspace{1ex}%
        \ignorespaces
        #2}}%
    \expandafter\global\expandafter\edef\csname biblio@margin@text@#1\endcsname{\relax}}%
  }

\def\biblio@margin@cite@aux#1{\immediate\write\@auxout{\string\citation{#1}}}
\def\biblio@margin@cite@text#1{\csname biblio@margin@text@#1\endcsname}
\def\biblio@margin@cite@number#1{\expandafter\ifx\expandafter\relax
  \csname biblio@margin@cite@#1\endcsname 
  \textbf{?}% 
  \G@refundefinedtrue
  \@latex@warning{Citation `#1' on page \thepage \space undefined}%
  \else \csname biblio@margin@cite@#1\endcsname\fi}

\newtoks\biblio@margin@tok@cite
\def\cite#1{%
  \edef\biblio@margin@cite@tmp{#1}% Nécessaire car la virgule peut être un
                     % caractère actif.
  \biblio@margin@tok@cite={}%
  \expandafter\biblio@margin@cite\biblio@margin@cite@tmp,@\ensuremath{^{(\the\biblio@margin@tok@cite)}}}%
\def\biblio@margin@cite#1,#2@{%
  \global\biblio@margin@tok@cite\expandafter{\the\biblio@margin@tok@cite\biblio@margin@cite@number{#1}}%
  \biblio@margin@cite@aux{#1}%
  \biblio@margin@cite@text{#1}%
  \ifvide{#2}{}{%
      \global\biblio@margin@tok@cite\expandafter{\the\biblio@margin@tok@cite,}%
      \biblio@margin@cite#2@}}
