1\let\chapterbib@include\include 2\newcounter{chap@included} 3\newcommand{\maketocbibitem}{} 4\newcommand{\@sectionbib@maketocbibitem}{\@auxdowrite{\@print{\@addcontentsline{htoc}}\{0\}\{\@print{\ahrefloc}\{bib:chap\thechap@included\}\{\refname{}\}\}\@print{ 5}}} 6\renewcommand{\include}[1] 7{\stepcounter{chap@included}% 8\def\chapterbib@include@name{#1}% 9\chapterbib@include{#1}} 10\renewcommand{\bibliography}[1]{\maketocbibitem\input{\chapterbib@include@name.bbl}} 11\let\chapterbib@thebibliography\thebibliography 12\renewcommand{\thebibliography}[1] 13{\setcounter{heveabib}{0}\chapterbib@thebibliography{#1}} 14\renewcommand{\bibtaghook}[1] 15{\@ifundefined{chapterbib@include@name}{#1}{#1@\thechap@included}} 16\newcommand{\sectionbib}[2] 17{\renewcommand{\@bibliosection}[1]{#1{\aname{bib:chap\thechap@included}{##1}}}% 18\let\maketocbibitem\@sectionbib@maketocbibitem} 19\DeclareOption{sectionbib}{\sectionbib{\section*}{section}}% 20\DeclareOption{draft}{}% 21\DeclareOption{rootbib}{}% 22\DeclareOption{duplicate}{}% 23\DeclareOption{gather}{}% 24\ProcessOptions* 25